diff --git a/package.json b/package.json index ffd51198..85968eac 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ "event-source-polyfill": "^1.0.31", "global": "^4.4.0", "jetlinks-store": "^0.0.3", - "jetlinks-ui-components": "^1.0.28", + "jetlinks-ui-components": "^1.0.33", "js-cookie": "^3.0.1", "jsencrypt": "^3.3.2", "less": "^4.1.3", diff --git a/src/utils/encodeQuery.ts b/src/utils/encodeQuery.ts index 27991057..b406d719 100644 --- a/src/utils/encodeQuery.ts +++ b/src/utils/encodeQuery.ts @@ -1,5 +1,19 @@ import { isObject, isArray } from 'lodash-es' +type TermsType = { + column: string + type: string + value: string + termsType: string + terms: Array +} + +type ParamsType = { + terms?: Array + sorts?: Array<{name:string, order: string }> + current?: any +} + export const encodeParams = (params: Record) => { const _params = new URLSearchParams() for (const key in params) { @@ -10,6 +24,42 @@ export const encodeParams = (params: Record) => { return _params.toString() } +const handleTermsToString = (queryTerms: any, terms: Array, parentKey?: string) => { + terms.forEach((a, aIndex) => { + Object.keys(a).forEach((b) => { + const key = `${parentKey}[${aIndex}].${b}` + if (b === 'terms') { + handleTermsToString(queryTerms, a[b], `${key}.`) + } else { + queryTerms[key] = a[b] + } + }) + + }) +} + +export const paramsEncodeQuery = (params?: ParamsType) => { + if (!params) return {} + + const queryParams = { + current: params.current, + } + + const { sorts, terms } = params + + if (terms) { + handleTermsToString(queryParams, terms, 'terms.') + } + + if (sorts) { + sorts.forEach((item, index) => { + queryParams[`sorts[${index}].name`] = item.name; + queryParams[`sorts[${index}].order`] = item.order; + }) + } + return queryParams +} + export default function encodeQuery(params: any) { if (!params) return {}; const queryParam = { diff --git a/src/views/device/Instance/Export/index.vue b/src/views/device/Instance/Export/index.vue index 7bb54b6d..7e159ff1 100644 --- a/src/views/device/Instance/Export/index.vue +++ b/src/views/device/Instance/Export/index.vue @@ -50,7 +50,7 @@ \ No newline at end of file + diff --git a/src/views/device/Instance/index.vue b/src/views/device/Instance/index.vue index 7ee8e92c..efa93c5c 100644 --- a/src/views/device/Instance/index.vue +++ b/src/views/device/Instance/index.vue @@ -17,7 +17,9 @@ isCheck ? { selectedRowKeys: _selectedRowKeys, - onChange: onSelectChange, + onSelect: onSelectChange, + onSelectAll: selectAll, + onSelectNone: ()=>_selectedRowKeys = [] } : false " @@ -708,10 +710,37 @@ const getActions = ( return actions; }; -const onSelectChange = (keys: string[]) => { - _selectedRowKeys.value = [...keys]; +const onSelectChange = (item: any,state: boolean) => { + const arr = new Set(_selectedRowKeys.value); + // console.log(item, state); + if (state) { + arr.add(item.id); + } else { + arr.delete(item.id); + } + _selectedRowKeys.value = [...arr.values()]; }; +const selectAll = (selected: Boolean, selectedRows: any,changeRows:any) => { + if (selected) { + changeRows.map((i: any) => { + if (!_selectedRowKeys.value.includes(i.id)) { + _selectedRowKeys.value.push(i.id) + } + }) + } else { + const arr = changeRows.map((item: any) => item.id) + const _ids: string[] = []; + _selectedRowKeys.value.map((i: any) => { + if (!arr.includes(i)) { + _ids.push(i) + } + }) + _selectedRowKeys.value = _ids + + } +} + const handleClick = (dt: any) => { if (isCheck.value) { if (_selectedRowKeys.value.includes(dt.id)) { diff --git a/src/views/device/components/Metadata/Import/index.vue b/src/views/device/components/Metadata/Import/index.vue index 2ad7fdd4..f269e46c 100644 --- a/src/views/device/components/Metadata/Import/index.vue +++ b/src/views/device/components/Metadata/Import/index.vue @@ -510,11 +510,17 @@ const beforeUpload: UploadProps['beforeUpload'] = (file) => { reader.onload = (json) => { if(json.target?.result){ const data = JSON.parse(json.target?.result); - + Object.keys(data).forEach((i:any)=>{ + const map = new Map() + data[i].forEach((item:any)=>( + map.set(item.id,item) + )) + data[i] = [...map.values()] + }) let check = formModel.metadata === 'jetlinks' ? requiredCheck(data) : aliCheck(data) if(!check){ onlyMessage('操作成功!') - formModel.import = json.target?.result; + formModel.import = JSON.stringify(data); } } else { onlyMessage('文件内容不能为空', 'error') diff --git a/src/views/link/Certificate/Detail/index.vue b/src/views/link/Certificate/Detail/index.vue index f843b403..889a9985 100644 --- a/src/views/link/Certificate/Detail/index.vue +++ b/src/views/link/Certificate/Detail/index.vue @@ -47,6 +47,18 @@ placeholder="请输入证书文件" /> + + + 客户端 + 服务端 + + + + + 单向认证 + 双向认证 + + ({ key: '', }, description: '', + mode:'server', + authenticationMethod:'single' }); const { resetFields, validate, validateInfos } = useForm( @@ -148,13 +163,25 @@ const { resetFields, validate, validateInfos } = useForm( { required: true, message: '请输入或上传文件', trigger: 'blur' }, ], description: [{ max: 200, message: '最多可输入200个字符' }], + mode:[{ required: true, message: '请选择证书类型', trigger: 'blur' }], + authenticationMethod:[{ required: true, message: '请选择认证方式', trigger: 'blur' }] }), ); const onSubmit = () => { validate() .then(async (res) => { - const params = toRaw(formData.value); + let params:any = toRaw(formData.value); + if(formData.value.mode === 'client'){ + if(formData.value.authenticationMethod === 'binomial'){ + params.configs.trust = params.configs.cert + }else{ + params.configs = { + key:formData.value.configs.key, + trust:formData.value.configs.cert + } + } + } loading.value = true; const response = id === ':id' @@ -190,6 +217,12 @@ const detail = async (id: string) => { const type = result.type.value as TypeObjType; formData.value = { ...result, + configs:{ + key:result.configs.key, + cert:result.configs?.cert ? result.configs?.cert : result.configs?.trust + }, + mode: result.mode.value, + authenticationMethod: result.authenticationMethod.value, type, }; } diff --git a/src/views/link/Certificate/type.d.ts b/src/views/link/Certificate/type.d.ts index eb38e3e6..bf772358 100644 --- a/src/views/link/Certificate/type.d.ts +++ b/src/views/link/Certificate/type.d.ts @@ -13,7 +13,8 @@ export type FormDataType = { }; id?: string; format?: string; - mode?: object; + mode?: object | string; creatorId?: string; createTime?: number; + authenticationMethod: string; }; diff --git a/src/views/system/NoticeRule/index.vue b/src/views/system/NoticeRule/index.vue index 4d3b093e..cea4280c 100644 --- a/src/views/system/NoticeRule/index.vue +++ b/src/views/system/NoticeRule/index.vue @@ -21,7 +21,7 @@ />