From 08d9280fecf72e1e97b6703fb9dc47cfbdef4700 Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 19 May 2023 17:57:47 +0800 Subject: [PATCH] fix: bug#13846.13671,13974,13188,13222,13639,13975,13668 --- package.json | 2 +- src/store/department.ts | 6 +- .../DataCollect/Collector/Tree/Save/index.vue | 2 +- .../Detail/DeviceAccess/accessModal.vue | 16 ++ src/views/device/Product/Save/index.vue | 3 + src/views/device/Product/index.vue | 6 +- .../components/AddDeviceOrProductDialog.vue | 167 +++++++----------- .../components/EditDepartmentDialog.vue | 1 + .../components/EditPermissionDialog.vue | 1 + .../system/Department/components/LeftTree.vue | 8 +- .../Department/components/NextDialog.vue | 14 +- src/views/system/Department/device/index.vue | 2 +- src/views/system/Department/product/index.vue | 4 +- src/views/system/Menu/Detail/BasicInfo.vue | 25 +-- .../system/User/components/EditUserDialog.vue | 5 +- 15 files changed, 128 insertions(+), 134 deletions(-) diff --git a/package.json b/package.json index ff972c4b..581ec969 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.16", + "jetlinks-ui-components": "^1.0.18", "js-cookie": "^3.0.1", "less": "^4.1.3", "less-loader": "^11.1.0", diff --git a/src/store/department.ts b/src/store/department.ts index 72abbff5..ca278f37 100644 --- a/src/store/department.ts +++ b/src/store/department.ts @@ -2,7 +2,7 @@ import { defineStore } from "pinia"; type DepartmentStateType = { - productId: string; + productId?: string[]; optType: string | undefined; crossPageKeys: string[]; changedApis: any; @@ -11,7 +11,7 @@ type DepartmentStateType = { export const useDepartmentStore = defineStore({ id: 'department', state: (): DepartmentStateType => ({ - productId: '', + productId: undefined, // 设备资产分配弹窗操作类型: // 1. optType === 'handle': 手动点击资产分配按钮; // 2. optType === ': 产品资产分配后, 自动弹出设备资产分配 @@ -20,7 +20,7 @@ export const useDepartmentStore = defineStore({ changedApis: {}, }), actions: { - setProductId(value: string) { + setProductId(value?: string[]) { this.productId = value; }, setType(value: string | undefined) { diff --git a/src/views/DataCollect/Collector/Tree/Save/index.vue b/src/views/DataCollect/Collector/Tree/Save/index.vue index 42c95c48..658f9ce1 100644 --- a/src/views/DataCollect/Collector/Tree/Save/index.vue +++ b/src/views/DataCollect/Collector/Tree/Save/index.vue @@ -186,7 +186,7 @@ const endianData = computed(() => { if (endian === 'BIG') { return endianIn === 'BIG' ? 'ABCD' : 'BADC'; } else { - return endianIn === 'BIG' ? 'CDBA' : 'DCBA'; + return endianIn === 'BIG' ? 'CDAB' : 'DCBA'; } } else { return endian === 'BIG' ? 'ABCD' : 'DCBA'; diff --git a/src/views/device/Product/Detail/DeviceAccess/accessModal.vue b/src/views/device/Product/Detail/DeviceAccess/accessModal.vue index 69286ec9..faa08732 100644 --- a/src/views/device/Product/Detail/DeviceAccess/accessModal.vue +++ b/src/views/device/Product/Detail/DeviceAccess/accessModal.vue @@ -130,6 +130,7 @@ import { queryList, getAccessConfig } from '@/api/device/product' import { message } from 'jetlinks-ui-components' import { useMenuStore } from '@/store/menu'; import { getProductByPluginId } from '@/api/link/plugin' +import { getProviders } from '@/api/link/accessConfig' type Emit = { (e: 'submit', data: any): void @@ -219,6 +220,21 @@ const columns = [ type: 'string', }, }, + { + title: '网关类型', + dataIndex: 'provider', + key: 'provider', + search: { + type: 'select', + options: () => { + return new Promise(resolve => { + getProviders().then(res => { + resolve(res.result?.map((item: any) => ({ ...item, label: item.name, value: item.id })) || []) + }) + }) + }, + }, + }, { title: '状态', dataIndex: 'state', diff --git a/src/views/device/Product/Save/index.vue b/src/views/device/Product/Save/index.vue index c4472e90..a3490969 100644 --- a/src/views/device/Product/Save/index.vue +++ b/src/views/device/Product/Save/index.vue @@ -309,11 +309,13 @@ const submitData = () => { .validate() .then(async () => { // 新增 + loading.value = true if (props.isAdd === 1) { if (form.id === '') { form.id = undefined; } const res = await addProduct(form); + loading.value = false if (res.status === 200) { message.success('保存成功!'); visible.value = false; @@ -331,6 +333,7 @@ const submitData = () => { ? form.classifiedName : (form.classifiedName = ''); const res = await editProduct(form); + loading.value = false if (res.status === 200) { message.success('保存成功!'); emit('success'); diff --git a/src/views/device/Product/index.vue b/src/views/device/Product/index.vue index 567bf0b9..364bf578 100644 --- a/src/views/device/Product/index.vue +++ b/src/views/device/Product/index.vue @@ -470,8 +470,8 @@ const query = reactive({ }, { title: '接入方式', - key: 'accessId', - dataIndex: 'accessId', + key: 'accessName', + dataIndex: 'accessName', search: { type: 'select', options: async () => { @@ -482,7 +482,7 @@ const query = reactive({ typeList.value = []; typeList.value = resp.result.map((item: any) => ({ label: item.name, - value: item.id, + value: item.name, })); res(typeList.value); }); diff --git a/src/views/system/Department/components/AddDeviceOrProductDialog.vue b/src/views/system/Department/components/AddDeviceOrProductDialog.vue index 3ba88933..08e4bf9e 100644 --- a/src/views/system/Department/components/AddDeviceOrProductDialog.vue +++ b/src/views/system/Department/components/AddDeviceOrProductDialog.vue @@ -3,9 +3,10 @@ class="add-device-or-product-dialog-container" title="绑定" width="1440px" + :maskClosable="false" @ok="confirm" :confirmLoading="loading" - @cancel="emits('update:visible', false)" + @cancel="cancel" visible >
@@ -28,9 +29,9 @@ { return message.warning('请先勾选数据'); } - console.log('table.selectedRows: ', table.selectedRows); const params = table.selectedRows.map((item: any) => ({ targetType: 'org', targetId: props.parentId, @@ -187,8 +187,8 @@ const confirm = () => { ), })); - // 分配产品资产后, 进入设备资产分配,默认查询第一个产品下的设备 - departmentStore.setProductId(params[0].assetIdList[0]); + // 分配产品资产后, 进入设备资产分配 + departmentStore.setProductId(table.selectedRows.map((item: any) => item.id)); loading.value = true; bindDeviceOrProductList_api(props.assetType, params) @@ -216,6 +216,26 @@ const columns = props.queryColumns.filter( (item) => item.dataIndex !== 'action', ); +const searchColumns = computed(() => { + return props.queryColumns.map(item => { + if (departmentStore.productId) { + if (item.dataIndex === 'productName') { + item.search.first = true + item.search.componentProps = { + mode: 'multiple', + "max-tag-count": "responsive" + } + item.search.defaultTermType = 'eq' + item.search.defaultOnceValue = departmentStore.productId + + } else if (item.search && 'first' in item.search) { + delete item.search.first + } + } + return item + }) +}) + const queryParams = ref({}); const table: any = { _selectedRowKeys: ref([]), // 选中项的id @@ -234,19 +254,6 @@ const table: any = { // 启用批量设置 if (bulkBool.value) { // 将已勾选的权限和批量设置的权限进行合并,并与自己可选的权限进行比对,取交集作为当前选中的权限 - // let newPermission = uniq([ - // ...item.selectPermissions, - // ...bulkList.value, - // ]); - // const allPermissions = item.permissionList.map( - // (item: any) => item.value, - // ); - // newPermission = intersection( - // newPermission, - // allPermissions, - // ); - // item.selectPermissions = newPermission; - // fix: bug#10756 item.selectPermissions = n[1]; // 禁用单独勾选 @@ -390,99 +397,40 @@ const table: any = { }); }, ); - // getPermission_api(props.assetType, ids, parentId).then( - // (perResp: any) => { - // console.log('perResp: ', perResp); - // console.log('props.allPermission: ', props.allPermission); - // const permissionObj = {}; - // perResp.result.forEach((item: any) => { - // permissionObj[item.assetId] = props.allPermission - // .filter((permission) => - // item.allPermissions.includes(permission.id), - // ) - // .map((item) => ({ - // label: item.name, - // value: item.id, - // disabled: true, - // })); - // }); - // data.forEach((item) => { - // item.permissionList = permissionObj[item.id]; - // item.selectPermissions = ['read']; - - // // 产品的状态进行转换处理 - // if (props.assetType === 'product') { - // item.state = { - // value: - // item.state === 1 - // ? 'online' - // : item.state === 0 - // ? 'offline' - // : '', - // text: - // item.state === 1 - // ? '正常' - // : item.state === 0 - // ? '禁用' - // : '', - // }; - // } - // }); - - // resolve({ - // code: 200, - // result: { - // data: data, - // pageIndex, - // pageSize, - // total, - // }, - // status: 200, - // }); - // }, - // ); }); }), // 整理参数并获取数据 requestFun: async (oParams: any) => { queryCount.value += 1; if (props.parentId) { - const terms = [ - { - terms: [ - { - column: 'id', - termType: 'dim-assets$not', - value: { - assetType: props.assetType, - targets: [ - { - type: 'org', - id: props.parentId, - }, - ], - }, - }, - { - column: 'productId$product-info', - type: 'and', - value: `id is ${departmentStore.productId}`, - }, - ], - }, - ]; + let terms = [{ + column: 'id', + termType: 'dim-assets$not', + value: { + assetType: props.assetType, + targets: [ + { + type: 'org', + id: props.parentId, + }, + ], + }, + type: 'and' + }] - if ( - props.assetType !== 'device' || - !departmentStore.productId || - queryCount.value > 1 || - departmentStore.optType === 'handle' - ) { - // 非设备|产品id不存在|有其他查询操作(queryCount+1)|设备页面手动点击资产分配, 均删除产品带入的id - terms[0].terms.pop(); + // if ( + // props.assetType !== 'device' || + // !departmentStore.productId || + // queryCount.value > 1 || + // departmentStore.optType === 'handle' + // ) { + // // 非设备|产品id不存在|有其他查询操作(queryCount+1)|设备页面手动点击资产分配, 均删除产品带入的id + // terms[0].terms.pop(); + // } + if (oParams.terms && oParams.terms.length > 0) { + terms = [ ...oParams.terms, ...terms] } - if (oParams.terms && oParams.terms.length > 0) - terms.unshift({ terms: oParams.terms }); + const params = { ...oParams, sorts: [{ name: 'createTime', order: 'desc' }], @@ -526,6 +474,15 @@ const selectChange = (keys: string[], rows: any[]) => { table.selectedRows = rows; table._selectedRowKeys.value = keys; }; + +const cancel = () => { + departmentStore.setProductId() + emits('update:visible', false) +} + +const search = (query: any) => { + queryParams.value = query +} diff --git a/src/views/system/Department/device/index.vue b/src/views/system/Department/device/index.vue index fff0b6b5..9503d64d 100644 --- a/src/views/system/Department/device/index.vue +++ b/src/views/system/Department/device/index.vue @@ -269,7 +269,7 @@ const columns = [ rename: 'productId$product-info', type: 'select', handleValue(value: string) { - return `id is ${value}`; + return `id in ${value.toString()}`; }, options: () => new Promise((resolve) => { diff --git a/src/views/system/Department/product/index.vue b/src/views/system/Department/product/index.vue index 049bda46..c214af6c 100644 --- a/src/views/system/Department/product/index.vue +++ b/src/views/system/Department/product/index.vue @@ -208,7 +208,7 @@ v-if="dialogs.addShow" v-model:visible="dialogs.addShow" :query-columns="columns" - :parent-id="props.parentId" + :parent-id="parentId" :all-permission="tableData.permissionList" asset-type="product" @confirm="table.addConfirm" @@ -218,7 +218,7 @@ v-model:visible="dialogs.editShow" :ids="dialogs.selectIds" :permission-list="dialogs.permissList" - :parent-id="props.parentId" + :parent-id="parentId" :all-permission="tableData.permissionList" asset-type="product" @confirm="table.refresh" diff --git a/src/views/system/Menu/Detail/BasicInfo.vue b/src/views/system/Menu/Detail/BasicInfo.vue index b6b443b3..d0fada9f 100644 --- a/src/views/system/Menu/Detail/BasicInfo.vue +++ b/src/views/system/Menu/Detail/BasicInfo.vue @@ -317,17 +317,20 @@ const form = reactive({ }; form.sourceCode = resp.result.code; }); - // 获取关联菜单 - getMenuTree_api({ paging: false }).then((resp: any) => { - form.treeData = resp.result; - }); - // 获取资产类型 - getAssetsType_api().then((resp: any) => { - form.assetsType = resp.result.map((item: any) => ({ - label: item.name, - value: item.id, - })); - }); + + if (isNoCommunity) { + // 获取关联菜单 + getMenuTree_api({ paging: false }).then((resp: any) => { + form.treeData = resp.result; + }); + // 获取资产类型 + getAssetsType_api().then((resp: any) => { + form.assetsType = resp.result.map((item: any) => ({ + label: item.name, + value: item.id, + })); + }); + } }, checkCode: async (_rule: Rule, value: string): Promise => { if (!value) return Promise.reject(''); diff --git a/src/views/system/User/components/EditUserDialog.vue b/src/views/system/User/components/EditUserDialog.vue index f63ffac7..1c381935 100644 --- a/src/views/system/User/components/EditUserDialog.vue +++ b/src/views/system/User/components/EditUserDialog.vue @@ -2,6 +2,7 @@ @@ -115,7 +116,7 @@