From 2a7f7124c307216faaef321dff84aa5c67c7058c Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期五, 13 六月 2025 15:48:13 +0800 Subject: [PATCH] 实现产品结构树页面检索NC文件窗口中点击NC文件后界面跳转至树节点层级下NC文件界面功能 --- src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue | 805 +++++++------- src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue | 857 +++++++------- src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue | 824 ++++++++------- src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue | 426 ++++--- src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue | 316 +++-- src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue | 2 6 files changed, 1,687 insertions(+), 1,543 deletions(-) diff --git a/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue b/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue index cc8b2e5..3acc91b 100644 --- a/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue +++ b/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModalForm.vue @@ -49,7 +49,7 @@ deviceCustomTypeList: [], labelCol: { xs: { span: 24 }, - sm: { span: 6 } + sm: { span: 7 } }, wrapperCol: { xs: { span: 24 }, diff --git a/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue b/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue index 5619cec..549e6c6 100644 --- a/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue +++ b/src/views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue @@ -8,162 +8,194 @@ </template> <script> -import { JeecgListMixin } from '@/mixins/JeecgListMixin' -import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue' -import { deleteAction } from '@api/manage' + import { JeecgListMixin } from '@/mixins/JeecgListMixin' + import DeviceCustomTypeModal + from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue' + import { getAction, deleteAction } from '@api/manage' -export default { - name: 'DeviceCustomTypeTableList', - components: { DeviceCustomTypeModal }, - mixins: [JeecgListMixin], - props: { - currentTreeNodeInfo: { - type: Object - }, - size: { - type: String - } - }, - data() { - return { - disableMixinCreated: true, - columns: [ - // { - // title: '杞﹂棿', - // dataIndex: 'productionId_dictText', - // align: 'center' - // }, - { - title: '杞存暟', - dataIndex: 'deviceManagementCode_dictText', - align: 'center' - }, - { - title: '鏁版帶绯荤粺绫诲埆', - dataIndex: 'deviceManagementId_dictText', - align: 'center' - } - ], - dataSource: [], - currentRightClickedTypeInfo: {}, - currentClickedTypeInfo: {}, - url: { - list: '/nc/deviceType/getByBusinessId', - delete: '/nc/deviceType/delete' - } - } - }, - watch: { - currentTreeNodeInfo: { - handler(value) { - this.currentClickedTypeInfo = {} + export default { + name: 'DeviceCustomTypeTableList', + components: { DeviceCustomTypeModal }, + mixins: [JeecgListMixin], + props: { + currentTreeNodeInfo: { + type: Object }, - immediate: true - } - }, - created() { - this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) - this.$bus.$on('deviceCustomTypeAddSubmitSuccess', this.loadData) - }, - methods: { - setQueryParamAndLoadData() { - console.log('currentLevelInfo', this.currentTreeNodeInfo) - const { id, type } = this.currentTreeNodeInfo - this.queryParam = Object.assign({}, { attributionId: id, attributionType: type }) - this.dataSource = [] - this.loadData() + size: { + type: String + } }, - - customRow(record) { + data() { return { - style: { - backgroundColor: this.currentClickedTypeInfo.id === record.id ? '#BAE7FF' : 'transparent' - }, - on: { - contextmenu: event => { - event.preventDefault() - this.currentRightClickedTypeInfo = Object.assign({ param: 'deviceCustomType' }, record) - this.$emit('handleTableContextMenuOpen', this.currentRightClickedTypeInfo) + disableMixinCreated: true, + columns: [ + // { + // title: '杞﹂棿', + // dataIndex: 'productionId_dictText', + // align: 'center' + // }, + { + title: '杞存暟', + dataIndex: 'deviceManagementCode_dictText', + align: 'center' }, - click: () => { - if (this.currentClickedTypeInfo.id === record.id) return - this.currentClickedTypeInfo = Object.assign({}, record) - this.$bus.$emit('sendCurrentClickedTypeInfo', record) + { + title: '鏁版帶绯荤粺绫诲埆', + dataIndex: 'deviceManagementId_dictText', + align: 'center' } + ], + dataSource: [], + currentRightClickedTypeInfo: {}, + currentClickedTypeInfo: {}, + url: { + list: '/nc/deviceType/getByBusinessId', + delete: '/nc/deviceType/delete' } } }, - - /** - * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 - * @param pagination 鍒嗛〉鍣ㄩ�夐」 - * @param filters 绛涢�夐�夐」 - * @param sorter 鎺掑簭閫夐」 - */ - handleTableChange(pagination, filters, sorter) { - if (sorter.order) { - this.isorter.column = sorter.field - this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' - } else { - this.isorter.column = 'createTime' - this.isorter.order = 'desc' - } - for (let key in filters) { - this.filters[key] = filters[key].join(',') - } - this.ipagination = pagination - this.loadData() - }, - - /** - * 鍒犻櫎宸ュ簭鎴栧伐姝ュ眰绾ф坊鍔犵殑璁惧绫� - * @param tableRowInfo - */ - handleTypeDelete(tableRowInfo) { - const { id } = tableRowInfo - const { $confirm, url, loadData, $notification, $destroyAll } = this - $confirm({ - title: '鎻愮ず', - content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵', - okText: '纭', - okType: 'danger', - cancelText: '鍙栨秷', - onOk: () => { - if (!url.delete) { - this.$message.error('璇疯缃畊rl.delete灞炴��!') - return - } - - deleteAction(url.delete, { id: id }) - .then((res) => { - if (res.success) { - $notification.success({ - message: '娑堟伅', - description: res.message - }) - loadData() - } else { - $notification.warning({ - message: '娑堟伅', - description: res.message - }) - } - }) - .finally(() => { - $destroyAll() - }) + watch: { + currentTreeNodeInfo: { + handler(value) { + this.currentClickedTypeInfo = {} }, - onCancel: () => { - $destroyAll() - } - }) + immediate: true + } }, + created() { + this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) + this.$bus.$on('deviceCustomTypeAddSubmitSuccess', this.loadData) + }, + methods: { + setQueryParamAndLoadData() { + const { id, type } = this.currentTreeNodeInfo + this.queryParam = Object.assign({}, { attributionId: id, attributionType: type }) + this.dataSource = [] + this.loadData() + }, - triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) { - if (this[methodName] && tableRowInfo.param === 'deviceCustomType') this[methodName](tableRowInfo, modalTitle) + loadData() { + const params = this.getQueryParams()//鏌ヨ鏉′欢 + this.loading = true + getAction(this.url.list, params) + .then((res) => { + if (res.success) { + this.dataSource = res.result.records || res.result + const { autoClickedLevelInfo } = this.currentTreeNodeInfo + if (autoClickedLevelInfo) { + const tableRowRecord = this.dataSource.find(item => item.id === autoClickedLevelInfo.attributionId) + this.handleTableRowClick(tableRowRecord) + } + } else { + this.$message.warning(res.message) + } + }).finally(() => { + this.loading = false + }) + }, + + /** + * 鑷畾涔夎〃鏍艰鍔熻兘 + * @param record 琛ㄦ牸琛岃褰� + */ + customRow(record) { + return { + style: { + backgroundColor: this.currentClickedTypeInfo.id === record.id ? '#BAE7FF' : 'transparent' + }, + on: { + contextmenu: event => { + event.preventDefault() + this.currentRightClickedTypeInfo = Object.assign({ param: 'deviceCustomType' }, record) + this.$emit('handleTableContextMenuOpen', this.currentRightClickedTypeInfo) + }, + click: () => { + this.handleTableRowClick(record) + } + } + } + }, + + /** + * 琛ㄦ牸琛岀偣鍑讳簨浠� + * @param record 琛ㄦ牸琛岃褰� + */ + handleTableRowClick(record) { + if (this.currentClickedTypeInfo.id === record.id) return + this.currentClickedTypeInfo = Object.assign({}, record) + this.$bus.$emit('sendCurrentClickedTypeInfo', record) + }, + + /** + * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 + * @param pagination 鍒嗛〉鍣ㄩ�夐」 + * @param filters 绛涢�夐�夐」 + * @param sorter 鎺掑簭閫夐」 + */ + handleTableChange(pagination, filters, sorter) { + if (sorter.order) { + this.isorter.column = sorter.field + this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' + } else { + this.isorter.column = 'createTime' + this.isorter.order = 'desc' + } + for (let key in filters) { + this.filters[key] = filters[key].join(',') + } + this.ipagination = pagination + this.loadData() + }, + + /** + * 鍒犻櫎宸ュ簭鎴栧伐姝ュ眰绾ф坊鍔犵殑璁惧绫� + * @param tableRowInfo + */ + handleTypeDelete(tableRowInfo) { + const { id } = tableRowInfo + const { $confirm, url, loadData, $notification, $destroyAll } = this + $confirm({ + title: '鎻愮ず', + content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵', + okText: '纭', + okType: 'danger', + cancelText: '鍙栨秷', + onOk: () => { + if (!url.delete) { + this.$message.error('璇疯缃畊rl.delete灞炴��!') + return + } + + deleteAction(url.delete, { id: id }) + .then((res) => { + if (res.success) { + $notification.success({ + message: '娑堟伅', + description: res.message + }) + loadData() + } else { + $notification.warning({ + message: '娑堟伅', + description: res.message + }) + } + }) + .finally(() => { + $destroyAll() + }) + }, + onCancel: () => { + $destroyAll() + } + }) + }, + + triggerCorrespondingMethod({ methodName, modalTitle, tableRowInfo }) { + if (this[methodName] && tableRowInfo.param === 'deviceCustomType') this[methodName](tableRowInfo, modalTitle) + } } } -} </script> <style scoped> diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue index 14e6a1e..bc4c54c 100644 --- a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue +++ b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue @@ -49,7 +49,7 @@ </a-form-item> </a-col> - <a-col :md="11" :sm="11"> + <a-col :md="7" :sm="7"> <a-form-item label="涓婁紶鏃堕棿"> <a-range-picker v-model="date" value-format="YYYY-MM-DD" @change="handleDateChange" allow-clear></a-range-picker> @@ -66,7 +66,7 @@ <a-table :columns="columns" :data-source="dataSource" bordered :pagination="false" :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys,selectedRows:selectionRows, onChange: onSelectChange}" - @change="handleTableChange" + @change="handleTableChange" :customRow="customRow" :scroll="{y:456}" :size="size" rowKey="docId"> <!-- 瀛楃涓茶秴闀挎埅鍙栫渷鐣ュ彿鏄剧ず--> @@ -120,430 +120,463 @@ </a-tabs> </div> </div> + + </a-modal> </template> <script> -import { getAction } from '@/api/manage' -import dncApi from '@/api/dnc' -import { JeecgListMixin } from '@/mixins/JeecgListMixin' + import { getAction } from '@/api/manage' + import dncApi from '@/api/dnc' + import { JeecgListMixin } from '@/mixins/JeecgListMixin' -export default { - name: 'NcDocumentSearchNcModal', - components: {}, - mixins: [JeecgListMixin], - props: { - currentDocumentInfo: { - type: Object - }, - size: { - type: String - } - }, - data() { - return { - disableMixinCreated: true, - visible: false, - title: '', - columns: [ - { - title: '搴忓彿', - dataIndex: 'rowIndex', - key: 'rowIndex', - width: 50, - align: 'center', - customRender: function(t, r, index) { - return parseInt(index) + 1 - } - }, - { - title: '鑺傜偣鍚嶇О', - dataIndex: 'nodeName', - align: 'center', - width: 80, - sorter: false - }, - { - title: '鑺傜偣浠e彿', - dataIndex: 'nodeCode', - align: 'center', - width: 80, - sorter: false - }, - { - title: '鏁版帶绯荤粺绫诲埆', - dataIndex: 'deviceName', - align: 'center', - width: 80, - sorter: false - }, - { - title: '杞存暟', - dataIndex: 'deviceCode', - align: 'center', - width: 50, - sorter: false - }, - { - title: '鏂囦欢鍚嶇О', - dataIndex: 'docName', - key: 'docName', - align: 'center', - scopedSlots: { customRender: 'docName' }, - width: 240, - sorter: true - }, - { - title: '鍑哄簱鐘舵��', - dataIndex: 'pullStatus_dictText', - key: 'pullStatus', - align: 'center', - width: 80, - filters: [ - { text: '鏈嚭搴�', value: 1 }, - { text: '宸插嚭搴�', value: 2 } - ] - }, - { - title: '鐘� 鎬�', - dataIndex: 'docDispatchStatus_dictText', - key: 'docDispatchStatus', - align: 'center', - width: 60, - filters: [ - { text: '缂栧埗', value: 1 }, - { text: '鏍″', value: 2 }, - { text: '鎵瑰噯', value: 3 }, - { text: '璇曞垏', value: 4 }, - { text: '瀹氬瀷', value: 5 } - ] - }, - { - title: '鍒涘缓鏃堕棿', - dataIndex: 'createTime', - align: 'center', - width: 150, - sorter: true - } - ], - searchValue: '', - searchInput: '', - spinning: false, - treeDataSource: [], - allTreeKeys: [], - checkedKeys: [], - expandedKeys: [], - autoExpandParent: true, - isExpandAllTreeNode: true, - date: [], - url: { - list: '/nc/product/query/nc' + export default { + name: 'NcDocumentSearchNcModal', + components: {}, + mixins: [JeecgListMixin], + props: { + currentDocumentInfo: { + type: Object + }, + size: { + type: String } - } - }, - watch: { - visible: { - handler(value) { - if (value) { - this.resetData() - this.loadData() - this.getDocumentAssignDeviceTreeByApi() + }, + data() { + return { + disableMixinCreated: true, + visible: false, + title: '', + columns: [ + { + title: '搴忓彿', + dataIndex: 'rowIndex', + key: 'rowIndex', + width: 50, + align: 'center', + customRender: function(t, r, index) { + return parseInt(index) + 1 + } + }, + { + title: '鑺傜偣鍚嶇О', + dataIndex: 'nodeName', + align: 'center', + width: 80, + sorter: false + }, + { + title: '鑺傜偣浠e彿', + dataIndex: 'nodeCode', + align: 'center', + width: 80, + sorter: false + }, + { + title: '鏁版帶绯荤粺绫诲埆', + dataIndex: 'deviceName', + align: 'center', + width: 80, + sorter: false + }, + { + title: '杞存暟', + dataIndex: 'deviceCode', + align: 'center', + width: 50, + sorter: false + }, + { + title: '鏂囦欢鍚嶇О', + dataIndex: 'docName', + key: 'docName', + align: 'center', + scopedSlots: { customRender: 'docName' }, + width: 240, + sorter: true + }, + { + title: '鍑哄簱鐘舵��', + dataIndex: 'pullStatus_dictText', + key: 'pullStatus', + align: 'center', + width: 80, + filters: [ + { text: '鏈嚭搴�', value: 1 }, + { text: '宸插嚭搴�', value: 2 } + ] + }, + { + title: '鐘� 鎬�', + dataIndex: 'docDispatchStatus_dictText', + key: 'docDispatchStatus', + align: 'center', + width: 60, + filters: [ + { text: '缂栧埗', value: 1 }, + { text: '鏍″', value: 2 }, + { text: '鎵瑰噯', value: 3 }, + { text: '璇曞垏', value: 4 }, + { text: '瀹氬瀷', value: 5 } + ] + }, + { + title: '鍒涘缓鏃堕棿', + dataIndex: 'createTime', + align: 'center', + width: 150, + sorter: true + } + ], + searchValue: '', + searchInput: '', + spinning: false, + fullScreenSpinning: false, + treeDataSource: [], + allTreeKeys: [], + checkedKeys: [], + expandedKeys: [], + autoExpandParent: true, + isExpandAllTreeNode: true, + date: [], + url: { + list: '/nc/product/query/nc' } } }, - isExpandAllTreeNode: { - handler(value) { - if (value) this.expandedKeys = this.allTreeKeys - else this.expandedKeys = [] - } - } - }, - created() { - this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - handleSearchNc() { - this.visible = true - }, - // 鑾峰彇褰撳墠瀵瑰簲鏂囨。鍒楄〃 - loadData() { - this.dataSource = [] - if (!this.url.list) { - this.$message.error('璇疯缃畊rl.list灞炴��!') - return - } - var params = this.getQueryParams()//鏌ヨ鏉′欢 - if (!params) return false - params.attributionType = this.currentDocumentInfo.type - params.attributionId = this.currentDocumentInfo.key - this.loading = true - getAction(this.url.list, params).then((res) => { - if (res.success) this.dataSource = res.result - else this.$message.warning(res.message) - }).finally(() => { - this.loading = false - }) - }, - - // 鑾峰彇DNC璁惧鏍� - getDocumentAssignDeviceTreeByApi() { - this.spinning = true - this.treeDataSource = [] - dncApi.getDeviceTreeDataApi() - .then(res => { - if (res.success) { - this.dataList = [] - this.allTreeKeys = [] - this.treeDataSource = res.result - this.generateList(this.treeDataSource) - this.expandedKeys = this.allTreeKeys - } else { - this.$message.warn(res.message) + watch: { + visible: { + handler(value) { + if (value) { + this.resetData() + this.loadData() + this.getDocumentAssignDeviceTreeByApi() } - }) - .finally(() => { - this.spinning = false - }) - }, - - // 鏃堕棿閫夋嫨鍣ㄩ�夋嫨瀹屾垚鍚庤Е鍙� - handleDateChange(value) { - this.queryParam.startTime = value[0] - this.queryParam.endTime = value[1] - }, - - /** - * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 - * @param pagination 鍒嗛〉鍣ㄩ�夐」 - * @param filters 绛涢�夐�夐」 - * @param sorter 鎺掑簭閫夐」 - */ - handleTableChange(pagination, filters, sorter) { - if (sorter.order) { - this.isorter.column = sorter.field - this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' - } else { - this.isorter.column = 'createTime' - this.isorter.order = 'desc' + } + }, + isExpandAllTreeNode: { + handler(value) { + if (value) this.expandedKeys = this.allTreeKeys + else this.expandedKeys = [] + } } - for (let key in filters) { - this.filters[key] = filters[key].join(',') - } - this.loadData() }, + created() { + this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) + }, + methods: { + handleSearchNc() { + this.visible = true + }, - // 鎸囨淳鍒拌澶囩獥鍙g偣鍑荤‘瀹氭寚娲捐澶囧悗瑙﹀彂 - handleAssignDocumentToDevice() { - const { - checkedKeys, - selectedRowKeys, - selectionRows, - dataList, - $confirm, - $notification, - currentDocumentInfo, - queryParam: { applyReason }, - $destroyAll, - $bus - } = this - const { attributionId, attributionType } = currentDocumentInfo - const paramsArray = [] - // 杩囨护杞﹂棿key浠呮斁鍏ヨ澶噆ey - const treeCheckedDeviceKeys = [] - checkedKeys.forEach(checkedKey => { - const device = dataList.find(item => item.key === checkedKey && item.type === 2) - if (device) treeCheckedDeviceKeys.push(device.key) - }) - - if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) { - $notification.warning({ - message: '娑堟伅', - description: '璇烽�夋嫨璁惧鎴栨枃妗�' + // 鑾峰彇褰撳墠瀵瑰簲鏂囨。鍒楄〃 + loadData() { + this.dataSource = [] + if (!this.url.list) { + this.$message.error('璇疯缃畊rl.list灞炴��!') + return + } + var params = this.getQueryParams()//鏌ヨ鏉′欢 + if (!params) return false + params.attributionType = this.currentDocumentInfo.type + params.attributionId = this.currentDocumentInfo.key + this.loading = true + getAction(this.url.list, params).then((res) => { + if (res.success) this.dataSource = res.result + else this.$message.warning(res.message) + }).finally(() => { + this.loading = false }) - return - } + }, - $confirm({ - title: '鎻愮ず', - content: `纭鎻愪氦鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - // 鍙岄噸寰幆纭畾姣忎竴缁勮澶囦笌鏂囨。鐨勫弬鏁� - treeCheckedDeviceKeys.forEach(deviceId => { - selectionRows.forEach(({ docId, publishFileId ,attributionId,attributionType}) => { - paramsArray.push({ - docId, - deviceId, - fileId: publishFileId, - attributionId, - attributionType, - applyReason - }) - }) + /** + * 鍒楄〃鑷畾涔夎 + * @param record 鍒楄〃琛岃褰� + */ + customRow(record) { + return { + style: { + cursor: 'pointer' + }, + on: { + click: () => { + let selectedRowKeys = [...this.selectedRowKeys] + let selectionRows = [...this.selectionRows] + if (selectedRowKeys.includes(record.docId)) { + selectedRowKeys = selectedRowKeys.filter(item => item !== record.docId) + selectionRows = selectionRows.filter(item => item.docId !== record.docId) + } else { + selectedRowKeys.push(record.docId) + selectionRows.push(record) + } + this.onSelectChange(selectedRowKeys, selectionRows) + }, + dblclick: () => { + this.$emit('searchTreeNode', record) + this.visible = false + } + } + } + }, + + // 鑾峰彇DNC璁惧鏍� + getDocumentAssignDeviceTreeByApi() { + this.spinning = true + this.treeDataSource = [] + dncApi.getDeviceTreeDataApi() + .then(res => { + if (res.success) { + this.dataList = [] + this.allTreeKeys = [] + this.treeDataSource = res.result + this.generateList(this.treeDataSource) + this.expandedKeys = this.allTreeKeys + } else { + this.$message.warn(res.message) + } }) + .finally(() => { + this.spinning = false + }) + }, - paramsArray.forEach(item => { - dncApi.assignDocumentToDeviceApi(item) - .then(res => { - if (res.success) { - $bus.$emit('reloadMainBottomTableData', 'useDocumentEquipment') - $notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { - $notification.error({ - message: '娑堟伅', - description: res.message - }) - } - }) - .catch(err => { - $notification.error({ - message: '娑堟伅', - description: err.message + // 鏃堕棿閫夋嫨鍣ㄩ�夋嫨瀹屾垚鍚庤Е鍙� + handleDateChange(value) { + this.queryParam.startTime = value[0] + this.queryParam.endTime = value[1] + }, + + /** + * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 + * @param pagination 鍒嗛〉鍣ㄩ�夐」 + * @param filters 绛涢�夐�夐」 + * @param sorter 鎺掑簭閫夐」 + */ + handleTableChange(pagination, filters, sorter) { + if (sorter.order) { + this.isorter.column = sorter.field + this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' + } else { + this.isorter.column = 'createTime' + this.isorter.order = 'desc' + } + for (let key in filters) { + this.filters[key] = filters[key].join(',') + } + this.loadData() + }, + + // 鎸囨淳鍒拌澶囩獥鍙g偣鍑荤‘瀹氭寚娲捐澶囧悗瑙﹀彂 + handleAssignDocumentToDevice() { + const { + checkedKeys, + selectedRowKeys, + selectionRows, + dataList, + $confirm, + $notification, + currentDocumentInfo, + queryParam: { applyReason }, + $destroyAll, + $bus + } = this + const { attributionId, attributionType } = currentDocumentInfo + const paramsArray = [] + // 杩囨护杞﹂棿key浠呮斁鍏ヨ澶噆ey + const treeCheckedDeviceKeys = [] + checkedKeys.forEach(checkedKey => { + const device = dataList.find(item => item.key === checkedKey && item.type === 2) + if (device) treeCheckedDeviceKeys.push(device.key) + }) + + if (treeCheckedDeviceKeys.length === 0 || selectedRowKeys.length === 0) { + $notification.warning({ + message: '娑堟伅', + description: '璇烽�夋嫨璁惧鎴栨枃妗�' + }) + return + } + + $confirm({ + title: '鎻愮ず', + content: `纭鎻愪氦鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + // 鍙岄噸寰幆纭畾姣忎竴缁勮澶囦笌鏂囨。鐨勫弬鏁� + treeCheckedDeviceKeys.forEach(deviceId => { + selectionRows.forEach(({ docId, publishFileId, attributionId, attributionType }) => { + paramsArray.push({ + docId, + deviceId, + fileId: publishFileId, + attributionId, + attributionType, + applyReason }) }) - .finally(() => { - $destroyAll() - }) - }) - }, - onCancel: () => { - $destroyAll() - } - }) - }, + }) - /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ - handleSearchInputChange() { - let search = this.searchInput - console.log('data', this.dataList) - console.log('search', search) - let expandedKeys = this.dataList - .map(item => { - if (item.title != null) { - if (item.title.indexOf(search) > -1) { - return this.getParentKey(item.key, this.treeDataSource) - } - return null + paramsArray.forEach(item => { + dncApi.assignDocumentToDeviceApi(item) + .then(res => { + if (res.success) { + $bus.$emit('reloadMainBottomTableData', 'useDocumentEquipment') + $notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + $notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { + $notification.error({ + message: '娑堟伅', + description: err.message + }) + }) + .finally(() => { + $destroyAll() + }) + }) + }, + onCancel: () => { + $destroyAll() } }) - .filter((item, i, self) => item && self.indexOf(item) === i) - Object.assign(this, { - expandedKeys, - searchValue: search, - autoExpandParent: true - }) - }, + }, - /** - * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙� - * @param expandedKeys 灞曞紑椤筴ey - */ - handleTreeNodeExpand(expandedKeys) { - this.expandedKeys = expandedKeys - this.autoExpandParent = false - }, + /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ + handleSearchInputChange() { + let search = this.searchInput + console.log('data', this.dataList) + console.log('search', search) + let expandedKeys = this.dataList + .map(item => { + if (item.title != null) { + if (item.title.indexOf(search) > -1) { + return this.getParentKey(item.key, this.treeDataSource) + } + return null + } + }) + .filter((item, i, self) => item && self.indexOf(item) === i) + Object.assign(this, { + expandedKeys, + searchValue: search, + autoExpandParent: true + }) + }, - /** - * 鏍戣妭鐐瑰閫夋閫変腑鏃惰Е鍙� - * @param selectedKeys 閫変腑鑺傜偣key - * @param {node} node 鑺傜偣瀵硅薄 - */ - handleTreeNodeCheck(checkedKeys, { node }) { - let record = node.dataRef - this.checkedKeys = checkedKeys - }, + /** + * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙� + * @param expandedKeys 灞曞紑椤筴ey + */ + handleTreeNodeExpand(expandedKeys) { + this.expandedKeys = expandedKeys + this.autoExpandParent = false + }, - /** - * 鏍戣妭鐐归�変腑鏃惰Е鍙戯紙妯℃嫙鏍戣妭鐐瑰閫夋閫変腑鏃剁殑鏁堟灉锛� - * @param selectedKeys 閫変腑鑺傜偣key - * @param {node} node 鑺傜偣瀵硅薄 - */ - handleTreeNodeSelect(selectedKeys, { node }) { - node.$el.childNodes[1].click() - }, + /** + * 鏍戣妭鐐瑰閫夋閫変腑鏃惰Е鍙� + * @param selectedKeys 閫変腑鑺傜偣key + * @param {node} node 鑺傜偣瀵硅薄 + */ + handleTreeNodeCheck(checkedKeys, { node }) { + let record = node.dataRef + this.checkedKeys = checkedKeys + }, - /** - * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇key - * @param key 瀛愰」key - * @param tree 瀛愰」 - */ - getParentKey(key, tree) { - let parentKey - for (let i = 0; i < tree.length; i++) { - const node = tree[i] - if (node.children) { - if (node.children.some(item => item.key === key)) { - parentKey = node.key - console.log('parentKey', parentKey) - } else if ( - this.getParentKey(key, node.children)) { - parentKey = this.getParentKey(key, node.children) + /** + * 鏍戣妭鐐归�変腑鏃惰Е鍙戯紙妯℃嫙鏍戣妭鐐瑰閫夋閫変腑鏃剁殑鏁堟灉锛� + * @param selectedKeys 閫変腑鑺傜偣key + * @param {node} node 鑺傜偣瀵硅薄 + */ + handleTreeNodeSelect(selectedKeys, { node }) { + node.$el.childNodes[1].click() + }, + + /** + * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇key + * @param key 瀛愰」key + * @param tree 瀛愰」 + */ + getParentKey(key, tree) { + let parentKey + for (let i = 0; i < tree.length; i++) { + const node = tree[i] + if (node.children) { + if (node.children.some(item => item.key === key)) { + parentKey = node.key + console.log('parentKey', parentKey) + } else if ( + this.getParentKey(key, node.children)) { + parentKey = this.getParentKey(key, node.children) + } } } - } - return parentKey - }, + return parentKey + }, - /** - * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key - * @param data 璁惧鏍戞暟鎹� - */ - generateList(data) { - for (let i = 0; i < data.length; i++) { - const node = data[i] - const key = node.key - const title = node.title - const type = node.type - this.dataList.push({ key, title, type }) - this.allTreeKeys.push(key) - if (node.children) this.generateList(node.children) - } - }, + /** + * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key + * @param data 璁惧鏍戞暟鎹� + */ + generateList(data) { + for (let i = 0; i < data.length; i++) { + const node = data[i] + const key = node.key + const title = node.title + const type = node.type + this.dataList.push({ key, title, type }) + this.allTreeKeys.push(key) + if (node.children) this.generateList(node.children) + } + }, - resetData() { - this.searchInput = '' - this.expandedKeys = [] - this.selectedRowKeys = [] - this.selectionRows = {} - this.checkedKeys = [] - this.filters = {} - this.isorter = Object.assign({}, this.defaultSorter) - }, + resetData() { + this.searchInput = '' + this.expandedKeys = [] + this.selectedRowKeys = [] + this.selectionRows = [] + this.checkedKeys = [] + this.filters = {} + this.isorter = Object.assign({}, this.defaultSorter) + }, - handleDelete() { - // 姝ゅ鍑芥暟涓哄睆钄絤ixins涓殑鍚屽悕鍑芥暟锛岄�氱敤鍑芥暟鍐欏湪鐖剁骇涓� - }, + handleDelete() { + // 姝ゅ鍑芥暟涓哄睆钄絤ixins涓殑鍚屽悕鍑芥暟锛岄�氱敤鍑芥暟鍐欏湪鐖剁骇涓� + }, - triggerCorrespondingMethod({ methodName, modalTitle }) { - if (this[methodName]) { - this[methodName]() - this.title = modalTitle + triggerCorrespondingMethod({ methodName, modalTitle }) { + if (this[methodName]) { + this[methodName]() + this.title = modalTitle + } } } } -} </script> <style scoped lang="less"> -/deep/ .ant-modal { - .tabs-container { - display: flex; - justify-content: space-between; + /deep/ .ant-modal { + .tabs-container { + display: flex; + justify-content: space-between; - .replaceSearch { - color: #40a9ff; - font-weight: bold; - background-color: rgb(204, 204, 204); + .replaceSearch { + color: #40a9ff; + font-weight: bold; + background-color: rgb(204, 204, 204); + } } } -} - -::-webkit-scrollbar { - width: 8px; -} + ::-webkit-scrollbar { + width: 8px; + } </style> \ No newline at end of file diff --git a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue index 25d1a1a..c3c709f 100644 --- a/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue +++ b/src/views/dnc/base/modules/ProductStructure/Document/NcDocumentTableList.vue @@ -17,234 +17,250 @@ </template> <script> -import { getAction } from '@/api/manage' -import { JeecgListMixin } from '@/mixins/JeecgListMixin' -import DocumentModal from '../../../../common/DocumentModal' -import NcDocumentAssignModal from './NcDocumentAssignModal' -import dncApi from '@api/dnc' + import { getAction } from '@/api/manage' + import { JeecgListMixin } from '@/mixins/JeecgListMixin' + import DocumentModal from '../../../../common/DocumentModal' + import NcDocumentAssignModal from './NcDocumentAssignModal' + import dncApi from '@api/dnc' -export default { - name: 'NcDocumentTableList', - components: { NcDocumentAssignModal, DocumentModal }, - mixins: [JeecgListMixin], - props: { - currentNCDocumentAttributionInfo: { - type: Object - }, - size: { - type: String - } - }, - data() { - return { - disableMixinCreated: true, - columns: [ - { - title: '搴忓彿', - dataIndex: 'rowIndex', - key: 'rowIndex', - width: 50, - align: 'center', - customRender: function(t, r, index) { - return parseInt(index) + 1 - } - }, - { - title: '鏂囦欢鍚嶇О', - dataIndex: 'docName', - key: 'docName', - align: 'center', - scopedSlots: {customRender: 'docName'}, - width: 500, - sorter: true - }, - { - title: '鍑哄簱鐘舵��', - dataIndex: 'pullStatus_dictText', - key: 'pullStatus', - align: 'center', - filters: [ - { text: '鏈嚭搴�', value: 1 }, - { text: '宸插嚭搴�', value: 2 } - ], - width: 100 - }, - { - title: '鐘舵��', - dataIndex: 'docDispatchStatus_dictText', - key: 'docDispatchStatus', - align: 'center', - filters: [ - { text: '缂栧埗', value: 1 }, - { text: '鏍″', value: 2 }, - { text: '鎵瑰噯', value: 3 }, - { text: '璇曞垏', value: 4 }, - { text: '瀹氬瀷', value: 5 } - ], - width: 70 - }, - { title: '绯荤粺鎸囧畾鐗堟湰', dataIndex: 'publishVersion', align: 'center', width: 120 }, - { - title: '鍒涘缓鏃堕棿', - dataIndex: 'createTime', - align: 'center', - width: 150, - sorter: true - } - ], - dataSource: [], - currentRightClickedDocumentInfo: {}, - currentClickedDocumentInfo: {}, - url: { - list: '/nc/doc/find/page' - } - } - }, - watch: { - currentNCDocumentAttributionInfo: { - handler(value) { - this.currentClickedDocumentInfo = this.currentRightClickedDocumentInfo = {} + export default { + name: 'NcDocumentTableList', + components: { NcDocumentAssignModal, DocumentModal }, + mixins: [JeecgListMixin], + props: { + currentNCDocumentAttributionInfo: { + type: Object }, - immediate: true - } - }, - created() { - this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - loadData(arg) { - if (!this.url.list) { - this.$message.error('璇疯缃畊rl.list灞炴��!') - return + size: { + type: String } - console.log('currentNCDocumentAttributionInfo', this.currentNCDocumentAttributionInfo) - const { attributionId, attributionType, docClassCode } = this.currentNCDocumentAttributionInfo - //鍔犺浇鏁版嵁 鑻ヤ紶鍏ュ弬鏁�1鍒欏姞杞界涓�椤电殑鍐呭 - if (arg === 1) this.ipagination.current = 1 - var params = this.getQueryParams()//鏌ヨ鏉′欢 - params.attributionId = attributionId - params.attributionType = attributionType - params.docClassCode = docClassCode - if (!params) return false - this.dataSource = [] - this.loading = true - getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => { - if (res.success) { - this.dataSource = res.result.records - if (res.result.total) { - this.ipagination.total = res.result.total - } else { - this.ipagination.total = 0 - } - } else { - this.$message.warning(res.message) - } - }).finally(() => { - this.loading = false - }) }, - - customRow(record) { + data() { return { - style: { - backgroundColor: this.currentClickedDocumentInfo.docId === record.docId ? '#BAE7FF' : 'transparent' - }, - on: { - contextmenu: event => { - event.preventDefault() - this.currentRightClickedDocumentInfo = Object.assign({ param: 'NC' }, record) - this.$emit('handleTableContextMenuOpen', this.currentRightClickedDocumentInfo) + disableMixinCreated: true, + columns: [ + { + title: '搴忓彿', + dataIndex: 'rowIndex', + key: 'rowIndex', + width: 50, + align: 'center', + customRender: function(t, r, index) { + return parseInt(index) + 1 + } }, - click: () => { - if (this.currentClickedDocumentInfo.docId === record.docId) return - this.currentClickedDocumentInfo = Object.assign({}, record) - this.$bus.$emit('sendCurrentClickedDocumentInfo', record) + { + title: '鏂囦欢鍚嶇О', + dataIndex: 'docName', + key: 'docName', + align: 'center', + scopedSlots: { customRender: 'docName' }, + width: 500, + sorter: true + }, + { + title: '鍑哄簱鐘舵��', + dataIndex: 'pullStatus_dictText', + key: 'pullStatus', + align: 'center', + filters: [ + { text: '鏈嚭搴�', value: 1 }, + { text: '宸插嚭搴�', value: 2 } + ], + width: 100 + }, + { + title: '鐘舵��', + dataIndex: 'docDispatchStatus_dictText', + key: 'docDispatchStatus', + align: 'center', + filters: [ + { text: '缂栧埗', value: 1 }, + { text: '鏍″', value: 2 }, + { text: '鎵瑰噯', value: 3 }, + { text: '璇曞垏', value: 4 }, + { text: '瀹氬瀷', value: 5 } + ], + width: 70 + }, + { title: '绯荤粺鎸囧畾鐗堟湰', dataIndex: 'publishVersion', align: 'center', width: 120 }, + { + title: '鍒涘缓鏃堕棿', + dataIndex: 'createTime', + align: 'center', + width: 150, + sorter: true } + ], + dataSource: [], + currentRightClickedDocumentInfo: {}, + currentClickedDocumentInfo: {}, + url: { + list: '/nc/doc/find/page' } } }, - - /** - * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 - * @param pagination 鍒嗛〉鍣ㄩ�夐」 - * @param filters 绛涢�夐�夐」 - * @param sorter 鎺掑簭閫夐」 - */ - handleTableChange(pagination, filters, sorter) { - if (sorter.order) { - this.isorter.column = sorter.field - this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' - } else { - this.isorter.column = 'createTime' - this.isorter.order = 'desc' + watch: { + currentNCDocumentAttributionInfo: { + handler(value) { + this.currentClickedDocumentInfo = this.currentRightClickedDocumentInfo = {} + }, + immediate: true } - for (let key in filters) { - this.filters[key] = filters[key].join(',') - } - this.ipagination = pagination - this.loadData() }, - - handleDocumentEdit(record, modalTitle) { - if (!this.$refs.modalForm) return - this.$refs.modalForm.edit(record) - this.$refs.modalForm.title = modalTitle + created() { + this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) }, + methods: { + loadData(arg) { + if (!this.url.list) { + this.$message.error('璇疯缃畊rl.list灞炴��!') + return + } + const { attributionId, attributionType, docClassCode, autoClickedLevelInfo } = this.currentNCDocumentAttributionInfo + //鍔犺浇鏁版嵁 鑻ヤ紶鍏ュ弬鏁�1鍒欏姞杞界涓�椤电殑鍐呭 + if (arg === 1) this.ipagination.current = 1 + var params = this.getQueryParams()//鏌ヨ鏉′欢 + params.attributionId = attributionId + params.attributionType = attributionType + params.docClassCode = docClassCode + if (!params) return false + this.dataSource = [] + this.loading = true + getAction(this.url.list + `/${this.ipagination.current}/${this.ipagination.pageSize}`, params).then((res) => { + if (res.success) { + this.dataSource = res.result.records + if (autoClickedLevelInfo) { + const tableRowRecord = this.dataSource.find(item => item.docId === autoClickedLevelInfo.docId) + this.handleTableRowClick(tableRowRecord) + this.$bus.$emit('searchNcFinished') + } + if (res.result.total) { + this.ipagination.total = res.result.total + } else { + this.ipagination.total = 0 + } + } else { + this.$message.warning(res.message) + } + }).finally(() => { + this.loading = false + }) + }, - handleDocumentAssign(record, modalTitle) { - if (!this.$refs.documentAssignModalRef) return - this.$refs.documentAssignModalRef.title = modalTitle - this.$refs.documentAssignModalRef.visible = true - }, + /** + * 鑷畾涔夎〃鏍艰鍔熻兘 + * @param record 琛ㄦ牸琛岃褰� + */ + customRow(record) { + return { + style: { + backgroundColor: this.currentClickedDocumentInfo.docId === record.docId ? '#BAE7FF' : 'transparent' + }, + on: { + contextmenu: event => { + event.preventDefault() + this.currentRightClickedDocumentInfo = Object.assign({ param: 'NC' }, record) + this.$emit('handleTableContextMenuOpen', this.currentRightClickedDocumentInfo) + }, + click: () => { + this.handleTableRowClick(record) + } + } + } + }, - handleDocumentExtract(record){ - const that = this - const { docId,attributionId, attributionType } = record - that.$confirm({ - title: '鎻愮ず', - content: `纭鎻愬彇鍒�鍏峰悧锛焋, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.extractToolsApi({ docId, attributionId, attributionType }) - .then(res => { - if (res.success) { - that.$notification.success({ - message: '娑堟伅', - description: `鎻愬彇鎴愬姛` - }) - } else { + /** + * 琛ㄦ牸琛岀偣鍑讳簨浠� + * @param record 琛ㄦ牸琛岃褰� + */ + handleTableRowClick(record) { + if (this.currentClickedDocumentInfo.docId === record.docId) return + this.currentClickedDocumentInfo = Object.assign({}, record) + this.$bus.$emit('sendCurrentClickedDocumentInfo', record) + }, + + /** + * 琛ㄦ牸鍒嗛〉銆佹帓搴忔敼鍙樸�佺瓫閫夋椂瑙﹀彂 + * @param pagination 鍒嗛〉鍣ㄩ�夐」 + * @param filters 绛涢�夐�夐」 + * @param sorter 鎺掑簭閫夐」 + */ + handleTableChange(pagination, filters, sorter) { + if (sorter.order) { + this.isorter.column = sorter.field + this.isorter.order = sorter.order === 'ascend' ? 'asc' : 'desc' + } else { + this.isorter.column = 'createTime' + this.isorter.order = 'desc' + } + for (let key in filters) { + this.filters[key] = filters[key].join(',') + } + this.ipagination = pagination + this.loadData() + }, + + handleDocumentEdit(record, modalTitle) { + if (!this.$refs.modalForm) return + this.$refs.modalForm.edit(record) + this.$refs.modalForm.title = modalTitle + }, + + handleDocumentAssign(record, modalTitle) { + if (!this.$refs.documentAssignModalRef) return + this.$refs.documentAssignModalRef.title = modalTitle + this.$refs.documentAssignModalRef.visible = true + }, + + handleDocumentExtract(record) { + const that = this + const { docId, attributionId, attributionType } = record + that.$confirm({ + title: '鎻愮ず', + content: `纭鎻愬彇鍒�鍏峰悧锛焋, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.extractToolsApi({ docId, attributionId, attributionType }) + .then(res => { + if (res.success) { + that.$notification.success({ + message: '娑堟伅', + description: `鎻愬彇鎴愬姛` + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel: () => { - that.$destroyAll() - } - }) - }, + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() + } + }) + }, - handleDelete() { - // 姝ゅ鍑芥暟涓哄睆钄絤ixins涓殑鍚屽悕鍑芥暟锛岄�氱敤鍑芥暟鍐欏湪鐖剁骇涓� - }, + handleDelete() { + // 姝ゅ鍑芥暟涓哄睆钄絤ixins涓殑鍚屽悕鍑芥暟锛岄�氱敤鍑芥暟鍐欏湪鐖剁骇涓� + }, - triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) { - if (this[methodName] && tableRowInfo.param === 'NC') this[methodName](tableRowInfo, modalTitle) + triggerCorrespondingMethod({ methodName, level, modalTitle, tableRowInfo }) { + if (this[methodName] && tableRowInfo.param === 'NC') this[methodName](tableRowInfo, modalTitle) + } } } -} </script> <style scoped> diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue index a63cbc8..e0d1f7d 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue @@ -30,478 +30,481 @@ </template> <script> -import dncApi from '@/api/dnc' -import NcDocumentTableList from './Document/NcDocumentTableList' -import OtherDocumentTableList from './Document/OtherDocumentTableList' -import TableContextMenu from '../../../common/TableContextMenu' -import DocumentBatchDeleteModal from '../../../common/DocumentBatchDeleteModal' -import DeviceCustomTypeTableList - from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue' -import { getAction } from '@api/manage' + import dncApi from '@/api/dnc' + import NcDocumentTableList from './Document/NcDocumentTableList' + import OtherDocumentTableList from './Document/OtherDocumentTableList' + import TableContextMenu from '../../../common/TableContextMenu' + import DocumentBatchDeleteModal from '../../../common/DocumentBatchDeleteModal' + import DeviceCustomTypeTableList + from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeTableList.vue' + import { getAction } from '@api/manage' -export default { - name: 'ProductStructureMainTop', - components: { - DeviceCustomTypeTableList, - DocumentBatchDeleteModal, - TableContextMenu, - OtherDocumentTableList, - NcDocumentTableList - }, - data() { - return { - activeTabKey: 2, - tableContainerSize: 'small', - isProcessHasDeviceTypeList: false, - isProcessStepHasDeviceTypeList: false, - currentRightClickedTableRowInfo: {}, - currentTreeNodeInfo: {}, - currentClickedTypeInfo: {}, - currentNCDocumentAttributionInfo: {},//褰撳墠NC鏂囨。鐨勬墍灞炵骇鍗崇埗绾х殑璇︾粏淇℃伅锛堝紩鍏ヨ澶囩被鍚嶯C鎸傝浇鑷宠澶囩被涓嬪弽涔嬪垯鎸傝浇鍦ㄥ伐搴忓拰宸ユ涓嬶級 - hasLoadedDataTabKeyArray: [] - } - }, - created() { - this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo) - this.$bus.$on('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo) - this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData) - this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) - this.getDeviceTypeListDisplayPermission('dnc_device_type_process', 'isProcessHasDeviceTypeList') - this.getDeviceTypeListDisplayPermission('dnc_device_type_step', 'isProcessStepHasDeviceTypeList') - }, - beforeDestroy() { - this.$bus.$off('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo) - this.$bus.$off('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo) - this.$bus.$off('reloadDocumentListData', this.reloadDocumentListData) - this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - /** - * 鑾峰彇璁惧绫诲瀷鍒楄〃鍦ㄥ伐搴忓拰宸ユ灞傜骇鐨勫睍绀烘潈闄� - * @param settingKey 鍚勫眰绾у睍绀烘潈闄恔ey - * @param dataProperty 缁勪欢data涓殑灞炴�у�肩敤鏉ユ帶鍒舵槸鍚﹀睍绀� - */ - getDeviceTypeListDisplayPermission(settingKey, dataProperty) { - getAction(`/system/sysParams/query/by/settingKey?settingKey=${settingKey}`).then(res => { - if (res.success) { - this[dataProperty] = res.result.settingValue === '1' - } - }) + export default { + name: 'ProductStructureMainTop', + components: { + DeviceCustomTypeTableList, + DocumentBatchDeleteModal, + TableContextMenu, + OtherDocumentTableList, + NcDocumentTableList }, - - /** - * 鎺ユ敹鏍戠粍浠朵紶鏉ョ殑褰撳墠閫変腑鐨勬爲鑺傜偣淇℃伅 - * @param treeNodeInfo 鏍戣妭鐐逛俊鎭� - */ - receiveCurrentTreeNodeInfo(treeNodeInfo) { - console.log('treeNodeInfo', treeNodeInfo) - const { id, type } = treeNodeInfo - // 浠庢爲缁勪欢鎺ュ彈鏍戣妭鐐逛俊鎭悗浠庣埗缁勪欢娴佸叆瀛愮粍浠跺苟閲嶇疆鏁版嵁 - this.currentClickedTypeInfo = this.currentRightClickedTableRowInfo = {} - this.currentTreeNodeInfo = treeNodeInfo - this.currentNCDocumentAttributionInfo = Object.assign({}, { - attributionId: id, - attributionType: type, - docClassCode: 'NC' - }) - this.hasLoadedDataTabKeyArray = [] - - if (+type === 5 || +type === 6) { - this.activeTabKey = 1 - this.$nextTick(() => { - if (this.$refs.deviceCustomTypeTableList) { - this.$refs.deviceCustomTypeTableList.setQueryParamAndLoadData() - // 鍒囨崲鏍戜箣鍚庢竻绌篘C绋嬪簭鍒楄〃 - if (this.$refs.ncDocumentTableListRef && this.$refs.ncDocumentTableListRef.dataSource.length > 0) this.$refs.ncDocumentTableListRef.dataSource = [] - } else if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) - }) - } else { - this.activeTabKey = 2 - this.$nextTick(() => { - if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) - }) - } - this.hasLoadedDataTabKeyArray.push(this.activeTabKey) - }, - - /** - * 鎺ュ彈褰撳墠鐐瑰嚮鐨勮澶囩被淇℃伅 - * @param record 褰撳墠鐐瑰嚮鐨勮澶囩被琛屼俊鎭� - */ - receiveCurrentClickedTypeInfo(record) { - const { id, attributionType } = record - this.currentClickedTypeInfo = Object.assign({}, record) - this.currentNCDocumentAttributionInfo = Object.assign({}, { - attributionId: id, - attributionType, - docClassCode: 'NC' - }) - this.$nextTick(() => { - if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) - }) - }, - - /** - * 鎺у埗鍙抽敭鑿滃崟寮�鍚� - * @param record 褰撳墠琛ㄦ牸琛屼俊鎭� - */ - handleTableContextMenuOpen(record) { - this.currentRightClickedTableRowInfo = Object.assign({}, record) - this.$refs.tableContextMenuRef.currentMenuLevel = record.param - this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px' - this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px' - this.$refs.tableContextMenuRef.menuVisible = true - document.body.addEventListener('click', this.handleMenuClose) - }, - - /** - * tab鏍忓垏鎹㈡椂瑙﹀彂 - * @param activeTabKey 鍒囨崲鍚庣殑tabKey - */ - handleTabChange(activeTabKey) { - if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) { - this.$nextTick(() => { - if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) - }) - // 闃绘鎺ュ彛鍦ㄥ悓涓�鏂囨。涓�娆$偣鍑诲唴澶氭瑙﹀彂 - this.hasLoadedDataTabKeyArray.push(activeTabKey) + data() { + return { + activeTabKey: 2, + tableContainerSize: 'small', + isProcessHasDeviceTypeList: false, + isProcessStepHasDeviceTypeList: false, + currentRightClickedTableRowInfo: {}, + currentTreeNodeInfo: {}, + currentClickedTypeInfo: {}, + currentNCDocumentAttributionInfo: {},//褰撳墠NC鏂囨。鐨勬墍灞炵骇鍗崇埗绾х殑璇︾粏淇℃伅锛堝紩鍏ヨ澶囩被鍚嶯C鎸傝浇鑷宠澶囩被涓嬪弽涔嬪垯鎸傝浇鍦ㄥ伐搴忓拰宸ユ涓嬶級 + hasLoadedDataTabKeyArray: [] } }, + created() { + this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo) + this.$bus.$on('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo) + this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData) + this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) + this.getDeviceTypeListDisplayPermission('dnc_device_type_process', 'isProcessHasDeviceTypeList') + this.getDeviceTypeListDisplayPermission('dnc_device_type_step', 'isProcessStepHasDeviceTypeList') + }, + beforeDestroy() { + this.$bus.$off('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo) + this.$bus.$off('sendCurrentClickedTypeInfo', this.receiveCurrentClickedTypeInfo) + this.$bus.$off('reloadDocumentListData', this.reloadDocumentListData) + this.$bus.$off('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) + }, + methods: { + /** + * 鑾峰彇璁惧绫诲瀷鍒楄〃鍦ㄥ伐搴忓拰宸ユ灞傜骇鐨勫睍绀烘潈闄� + * @param settingKey 鍚勫眰绾у睍绀烘潈闄恔ey + * @param dataProperty 缁勪欢data涓殑灞炴�у�肩敤鏉ユ帶鍒舵槸鍚﹀睍绀� + */ + getDeviceTypeListDisplayPermission(settingKey, dataProperty) { + getAction(`/system/sysParams/query/by/settingKey?settingKey=${settingKey}`).then(res => { + if (res.success) { + this[dataProperty] = res.result.settingValue === '1' + } + }) + }, - /** - * 鏂囨。浠ュ強NC绋嬪簭瀵煎叆/鍑哄簱/鍏ュ簱/鍙栨秷鍑哄簱/鍙戝竷/褰掓。鎴愬姛鍚庤Е鍙戦噸鏂板姞杞芥枃妗e垪琛� - * @param docClassCode 鏂囨。绫诲埆 - * @param attributionType 鏂囨。鐖剁骇type绫诲瀷 - * @param attributionId 鏂囨。鐖剁骇Id - */ - reloadDocumentListData({ docClassCode, attributionType, attributionId }) { - console.log('docClassCode, attributionType, attributionId', docClassCode, attributionType, attributionId) - // 鍦ㄦ澶勮澶嘚C鏂囨。鐖剁骇鍙傛暟鏄彲姝ゆ柟娉曟槸缁撴瀯鏍戜互鍙婅澶囩被涓ょ涓嶅悓瀵煎叆鏂瑰紡鐨勫叡鍚屽嚭鍙� - this.currentNCDocumentAttributionInfo = Object.assign({}, { docClassCode, attributionId, attributionType }) + /** + * 鎺ユ敹鏍戠粍浠朵紶鏉ョ殑褰撳墠閫変腑鐨勬爲鑺傜偣淇℃伅 + * @param treeNodeInfo 鏍戣妭鐐逛俊鎭� + */ + receiveCurrentTreeNodeInfo(treeNodeInfo) { + const { id, type, autoClickedLevelInfo } = treeNodeInfo + // 浠庢爲缁勪欢鎺ュ彈鏍戣妭鐐逛俊鎭悗浠庣埗缁勪欢娴佸叆瀛愮粍浠跺苟閲嶇疆鏁版嵁 + this.currentClickedTypeInfo = this.currentRightClickedTableRowInfo = {} + this.currentTreeNodeInfo = treeNodeInfo + this.currentNCDocumentAttributionInfo = Object.assign({}, { + attributionId: id, + attributionType: type, + docClassCode: 'NC', + autoClickedLevelInfo + }) + this.hasLoadedDataTabKeyArray = [] - // 鍒ゆ柇褰撳墠鍙充晶灞曠ず鐨勬枃妗g殑鎵�灞炴槸鍚︽槸褰撳墠宸﹂敭閫変腑鏍戣妭鐐规垨璁惧绫伙紝鑻ヤ笉鏄綋鍓嶅乏閿�変腑鐨勫垯鍦ㄥ鍏ュ悗涓嶅埛鏂板彸渚х殑鏂囨。鍒楄〃(閬垮厤鏃犳晥鍒锋柊) - // 鍒ゆ柇鏄惁鏄湪鏂囨。鍒楄〃涓繘琛屽嚭搴�/鍏ュ簱/鍙戝竷/褰掓。绛夋搷浣�,鑻ユ槸鍦ㄦ枃妗e垪琛ㄤ腑鎿嶄綔鍒欐搷浣滄垚鍔熷悗鐩存帴鍒锋柊鏂囨。鍒楄〃 - if (!this.currentRightClickedTableRowInfo.hasOwnProperty('docId')) { - if (this.currentRightClickedTableRowInfo.hasOwnProperty('deviceManagementId')) { - // 姝ょ鎯呭喌鏄湪寮曞叆璁惧绫诲苟鍦ㄨ澶囩被鍒楄〃涓繘琛孨C鏂囨。瀵煎叆 - if (this.currentClickedTypeInfo.id !== attributionId) return + if (+type === 5 || +type === 6) { + this.activeTabKey = 1 + this.$nextTick(() => { + if (this.$refs.deviceCustomTypeTableList) { + this.$refs.deviceCustomTypeTableList.setQueryParamAndLoadData() + // 鍒囨崲鏍戜箣鍚庢竻绌篘C绋嬪簭鍒楄〃 + if (this.$refs.ncDocumentTableListRef && this.$refs.ncDocumentTableListRef.dataSource.length > 0) this.$refs.ncDocumentTableListRef.dataSource = [] + } + else if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) + }) } else { - // 姝ょ鎯呭喌鏄湪缁撴瀯鏍戣妭鐐逛笂杩涜鏂囨。瀵煎叆 - if (this.currentTreeNodeInfo.id !== attributionId) return + this.activeTabKey = 2 + this.$nextTick(() => { + if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) + }) } - } + this.hasLoadedDataTabKeyArray.push(this.activeTabKey) + }, - if (docClassCode === 'NC') { + /** + * 鎺ュ彈褰撳墠鐐瑰嚮鐨勮澶囩被淇℃伅 + * @param record 褰撳墠鐐瑰嚮鐨勮澶囩被琛屼俊鎭� + */ + receiveCurrentClickedTypeInfo(record) { + const { id, attributionType } = record + const { autoClickedLevelInfo } = this.currentTreeNodeInfo + this.currentClickedTypeInfo = Object.assign({}, record) + this.currentNCDocumentAttributionInfo = Object.assign({}, { + attributionId: id, + attributionType, + docClassCode: 'NC', + autoClickedLevelInfo + }) this.$nextTick(() => { if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) }) - } else { - if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) - } - }, + }, - // 涓嬭浇褰撳墠鍙抽敭閫変腑鏂囨。 - handleDownload() { - const that = this - const { docId, docName } = this.currentRightClickedTableRowInfo - dncApi.downloadDocumentApi({ docId, docName }) - .then(res => { - if (!res.success) { + /** + * 鎺у埗鍙抽敭鑿滃崟寮�鍚� + * @param record 褰撳墠琛ㄦ牸琛屼俊鎭� + */ + handleTableContextMenuOpen(record) { + this.currentRightClickedTableRowInfo = Object.assign({}, record) + this.$refs.tableContextMenuRef.currentMenuLevel = record.param + this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px' + this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px' + this.$refs.tableContextMenuRef.menuVisible = true + document.body.addEventListener('click', this.handleMenuClose) + }, + + /** + * tab鏍忓垏鎹㈡椂瑙﹀彂 + * @param activeTabKey 鍒囨崲鍚庣殑tabKey + */ + handleTabChange(activeTabKey) { + if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) { + this.$nextTick(() => { + if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) + }) + // 闃绘鎺ュ彛鍦ㄥ悓涓�鏂囨。涓�娆$偣鍑诲唴澶氭瑙﹀彂 + this.hasLoadedDataTabKeyArray.push(activeTabKey) + } + }, + + /** + * 鏂囨。浠ュ強NC绋嬪簭瀵煎叆/鍑哄簱/鍏ュ簱/鍙栨秷鍑哄簱/鍙戝竷/褰掓。鎴愬姛鍚庤Е鍙戦噸鏂板姞杞芥枃妗e垪琛� + * @param docClassCode 鏂囨。绫诲埆 + * @param attributionType 鏂囨。鐖剁骇type绫诲瀷 + * @param attributionId 鏂囨。鐖剁骇Id + */ + reloadDocumentListData({ docClassCode, attributionType, attributionId }) { + console.log('docClassCode, attributionType, attributionId', docClassCode, attributionType, attributionId) + // 鍦ㄦ澶勮澶嘚C鏂囨。鐖剁骇鍙傛暟鏄彲姝ゆ柟娉曟槸缁撴瀯鏍戜互鍙婅澶囩被涓ょ涓嶅悓瀵煎叆鏂瑰紡鐨勫叡鍚屽嚭鍙� + this.currentNCDocumentAttributionInfo = Object.assign({}, { docClassCode, attributionId, attributionType }) + + // 鍒ゆ柇褰撳墠鍙充晶灞曠ず鐨勬枃妗g殑鎵�灞炴槸鍚︽槸褰撳墠宸﹂敭閫変腑鏍戣妭鐐规垨璁惧绫伙紝鑻ヤ笉鏄綋鍓嶅乏閿�変腑鐨勫垯鍦ㄥ鍏ュ悗涓嶅埛鏂板彸渚х殑鏂囨。鍒楄〃(閬垮厤鏃犳晥鍒锋柊) + // 鍒ゆ柇鏄惁鏄湪鏂囨。鍒楄〃涓繘琛屽嚭搴�/鍏ュ簱/鍙戝竷/褰掓。绛夋搷浣�,鑻ユ槸鍦ㄦ枃妗e垪琛ㄤ腑鎿嶄綔鍒欐搷浣滄垚鍔熷悗鐩存帴鍒锋柊鏂囨。鍒楄〃 + if (!this.currentRightClickedTableRowInfo.hasOwnProperty('docId')) { + if (this.currentRightClickedTableRowInfo.hasOwnProperty('deviceManagementId')) { + // 姝ょ鎯呭喌鏄湪寮曞叆璁惧绫诲苟鍦ㄨ澶囩被鍒楄〃涓繘琛孨C鏂囨。瀵煎叆 + if (this.currentClickedTypeInfo.id !== attributionId) return + } else { + // 姝ょ鎯呭喌鏄湪缁撴瀯鏍戣妭鐐逛笂杩涜鏂囨。瀵煎叆 + if (this.currentTreeNodeInfo.id !== attributionId) return + } + } + + if (docClassCode === 'NC') { + this.$nextTick(() => { + if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) + }) + } else { + if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) + } + }, + + // 涓嬭浇褰撳墠鍙抽敭閫変腑鏂囨。 + handleDownload() { + const that = this + const { docId, docName } = this.currentRightClickedTableRowInfo + dncApi.downloadDocumentApi({ docId, docName }) + .then(res => { + if (!res.success) { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) + }) + }, + + // 鍒犻櫎褰撳墠鍙抽敭閫変腑鏂囨。 + handleDelete() { + const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + const that = this + that.$confirm({ + title: '鎻愮ず', + content: `鍒犻櫎鍚庝笉鍙彇娑堬紝纭鍒犻櫎鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.deleteDocumentApi({ docId, attributionType, attributionId }) + .then((res) => { + if (res.success) { + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + } else { + that.$notification.warning({ + message: '娑堟伅', + description: res.message + }) + } + }) + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() } }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message - }) + }, + + /** + * 鐐瑰嚮鎵归噺鍒犻櫎鍚庡嚭鐜板脊绐� + * @param modalTitle 寮圭獥鏍囬 + */ + handleBatchRemove(modalTitle) { + if (!this.$refs.documentBatchDeleteModalRef) return + this.$refs.documentBatchDeleteModalRef.title = modalTitle + this.$refs.documentBatchDeleteModalRef.visible = true + }, + + /** + * 鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。 + * @param menuLabel + */ + handlePull(menuLabel) { + const that = this + const { docId, docName, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentOutboundApi({ docId, docName }) + .then(res => { + if (res.success) { + that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + that.$notification.success({ + message: '娑堟伅', + description: `${menuLabel}鎴愬姛` + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { + that.$notification.error({ + message: '娑堟伅', + description: err.message + }) + }) + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() + } }) - }, + }, - // 鍒犻櫎褰撳墠鍙抽敭閫変腑鏂囨。 - handleDelete() { - const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - const that = this - that.$confirm({ - title: '鎻愮ず', - content: `鍒犻櫎鍚庝笉鍙彇娑堬紝纭鍒犻櫎鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.deleteDocumentApi({docId,attributionType,attributionId}) - .then((res) => { - if (res.success) { - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - } else { - that.$notification.warning({ - message: '娑堟伅', - description: res.message - }) - } - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel: () => { - that.$destroyAll() - } - }) - }, - - /** - * 鐐瑰嚮鎵归噺鍒犻櫎鍚庡嚭鐜板脊绐� - * @param modalTitle 寮圭獥鏍囬 - */ - handleBatchRemove(modalTitle) { - if (!this.$refs.documentBatchDeleteModalRef) return - this.$refs.documentBatchDeleteModalRef.title = modalTitle - this.$refs.documentBatchDeleteModalRef.visible = true - }, - - /** - * 鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。 - * @param menuLabel - */ - handlePull(menuLabel) { - const that = this - const { docId, docName, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - that.$confirm({ - title: '鎻愮ず', - content: `纭${menuLabel}鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.documentOutboundApi({ docId, docName }) - .then(res => { - if (res.success) { - that.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - that.$notification.success({ - message: '娑堟伅', - description: `${menuLabel}鎴愬姛` - }) - } else { + /** + * 鍙栨秷鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。 + * @param menuLabel + */ + handleCancelPull(menuLabel) { + const that = this + const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentCancelOutboundApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel: () => { - that.$destroyAll() - } - }) - }, + .finally(() => { + that.$destroyAll() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, - /** - * 鍙栨秷鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。 - * @param menuLabel - */ - handleCancelPull(menuLabel) { - const that = this - const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - that.$confirm({ - title: '鎻愮ず', - content: `纭${menuLabel}鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.documentCancelOutboundApi(docId) - .then(res => { - if (res.success) { - this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { + /** + * 鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。 + * @param menuLabel + */ + handlePublish(menuLabel) { + const that = this + const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentPublishApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + this.$bus.$emit('reloadMainBottomTableData', 'documentVersion') + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel() { - that.$destroyAll() - } - }) - }, + .finally(() => { + that.$destroyAll() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, - /** - * 鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。 - * @param menuLabel - */ - handlePublish(menuLabel) { - const that = this - const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - that.$confirm({ - title: '鎻愮ず', - content: `纭${menuLabel}鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.documentPublishApi(docId) - .then(res => { - if (res.success) { - this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - this.$bus.$emit('reloadMainBottomTableData', 'documentVersion') - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { + /** + * 閲嶆柊鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。骞堕噸鏂板彂甯冮��鍥炰笂涓�鏂囨。鐗堟湰 + * @param menuLabel + */ + handleRepublish(menuLabel) { + const that = this + const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentRepublishApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel() { - that.$destroyAll() - } - }) - }, + .finally(() => { + that.$destroyAll() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, - /** - * 閲嶆柊鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。骞堕噸鏂板彂甯冮��鍥炰笂涓�鏂囨。鐗堟湰 - * @param menuLabel - */ - handleRepublish(menuLabel) { - const that = this - const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - that.$confirm({ - title: '鎻愮ず', - content: `纭${menuLabel}鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.documentRepublishApi(docId) - .then(res => { - if (res.success) { - this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { + /** + * 褰掓。褰撳墠鍙抽敭閫変腑鏂囨。涓斿悗缁棤娉曠户缁彂甯冩垨褰掓。 + * @param menuLabel + */ + handlePigeonhole(menuLabel) { + const that = this + const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `${menuLabel}鍚庝笉鍙彇娑堬紝纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentPigeonholeApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { that.$notification.error({ message: '娑堟伅', - description: res.message + description: err.message }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel() { - that.$destroyAll() - } - }) - }, - - /** - * 褰掓。褰撳墠鍙抽敭閫変腑鏂囨。涓斿悗缁棤娉曠户缁彂甯冩垨褰掓。 - * @param menuLabel - */ - handlePigeonhole(menuLabel) { - const that = this - const { docId, param, attributionId, attributionType } = this.currentRightClickedTableRowInfo - that.$confirm({ - title: '鎻愮ず', - content: `${menuLabel}鍚庝笉鍙彇娑堬紝纭${menuLabel}鍚楋紵`, - okText: '纭', - cancelText: '鍙栨秷', - onOk: () => { - dncApi.documentPigeonholeApi(docId) - .then(res => { - if (res.success) { - this.reloadDocumentListData({ docClassCode: param, attributionId, attributionType }) - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { - that.$notification.error({ - message: '娑堟伅', - description: res.message - }) - } - }) - .catch(err => { - that.$notification.error({ - message: '娑堟伅', - description: err.message + .finally(() => { + that.$destroyAll() }) - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel() { - that.$destroyAll() - } - }) - }, + }, + onCancel() { + that.$destroyAll() + } + }) + }, - // 鎺у埗鍙抽敭鑿滃崟鍏抽棴 - handleMenuClose() { - this.$refs.tableContextMenuRef.menuVisible = false - document.body.removeEventListener('click', this.handleMenuClose) - }, + // 鎺у埗鍙抽敭鑿滃崟鍏抽棴 + handleMenuClose() { + this.$refs.tableContextMenuRef.menuVisible = false + document.body.removeEventListener('click', this.handleMenuClose) + }, - triggerCorrespondingMethod({ methodName, modalTitle }) { - if (this[methodName]) this[methodName](modalTitle) + triggerCorrespondingMethod({ methodName, modalTitle }) { + if (this[methodName]) this[methodName](modalTitle) + } } } -} </script> <style scoped> -/deep/ .ant-table-tbody .ant-table-row { - cursor: pointer; -} + /deep/ .ant-table-tbody .ant-table-row { + cursor: pointer; + } </style> \ No newline at end of file diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue index 9d8320b..7ca8dcb 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue @@ -4,7 +4,7 @@ <div style="display: flex;flex-direction: column;height: 100%"> <div style="display: flex;justify-content: space-between"> <a-input placeholder="杈撳叆鍏抽敭瀛楄繘琛屾悳绱�" allowClear v-model="searchInput" - @change="handleSearchInputChange" /> + @change="handleSearchInputChange"/> <!-- <a-tooltip title="鍒锋柊">--> <!-- <a-button icon="reload" @click="handleTreeReload" style="width: 18%;margin-left: 8px"></a-button>--> <!-- </a-tooltip>--> @@ -31,16 +31,16 @@ @select="handleTreeSelect" @expand="handleTreeExpand" @rightClick="handleTreeRightClick"> <template slot="title" slot-scope="{ label, parentId, key:treeKey,type}"> <ProductStructureTreeContextMenu ref="contextMenuRef" - :treeParams="{label,treeKey,searchValue,type}" /> + :treeParams="{label,treeKey,searchValue,type}"/> </template> - <a-icon slot="switcherIcon" type="down" /> - <a-icon slot="product" type="shopping" /> - <a-icon slot="component" type="camera" /> - <a-icon slot="part" type="hdd" /> - <a-icon slot="processSpecVersion" type="tag" /> - <a-icon slot="process" type="apartment" /> - <a-icon slot="processStep" type="tool" /> + <a-icon slot="switcherIcon" type="down"/> + <a-icon slot="product" type="shopping"/> + <a-icon slot="component" type="camera"/> + <a-icon slot="part" type="hdd"/> + <a-icon slot="processSpecVersion" type="tag"/> + <a-icon slot="process" type="apartment"/> + <a-icon slot="processStep" type="tool"/> </a-tree> </div> </div> @@ -48,421 +48,481 @@ <!--浜у搧寮圭獥--> <ProductModal ref="productModalFormRef" :currentTreeNodeInfo="rightClickSelected" - @submitSuccess="getTreeDataByApi" /> + @submitSuccess="getTreeDataByApi"/> <!--閮ㄤ欢寮圭獥--> - <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--闆朵欢寮圭獥--> - <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--宸ヨ壓瑙勭▼鐗堟湰寮圭獥--> - <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--宸ュ簭寮圭獥--> - <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--宸ユ寮圭獥--> - <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <ProcessStepModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--鏉冮檺閰嶇疆寮圭獥--> - <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <AssignPermissionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--妫�绱㈢數瀛愭ā鏉垮脊绐�--> - <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <NcDocumentSearchModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--妫�绱C鏂囦欢寮圭獥--> - <NcDocumentSearchNcModal :currentDocumentInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <NcDocumentSearchNcModal :currentDocumentInfo="rightClickSelected" @searchTreeNode="searchTreeNode" + @submitSuccess="modalFormSubmitSuccess"/> <!--寮曠敤閮ㄤ欢--> - <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess" /> + <NcComponentBorrowModal :currentBorrowInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--浜у搧缁撴瀯鏍戝熀鏈彸閿彍鍗�(绌虹櫧澶勮Е鍙�)--> - <ProductStructureBaseContextMenu ref="baseContextmenuRef" /> + <ProductStructureBaseContextMenu ref="baseContextmenuRef"/> + + <div class="full-screen-container" v-if="fullScreenSpinning"> + <a-spin :spinning="fullScreenSpinning" size="large" tip="NC鏂囦欢妫�绱腑..."/> + </div> </a-card> </template> <script> -import dncApi from '@/api/dnc' -import { deleteAction } from '@/api/manage' -import ProductStructureTreeContextMenu from './ProductStructureTreeContextMenu' -import ProductModal from './Product/ProductModal' -import ComponentModal from './Component/ComponentModal' -import PartModal from './Part/PartModal' -import ProcessSpecVersionModal from './ProcessSpecVersion/ProcessSpecVersionModal' -import ProcessModal from './Process/ProcessModal' -import ProcessStepModal from './ProcessStep/ProcessStepModal' -import AssignPermissionModal from './Permission/AssignPermissionModal' -import DeviceCustomTypeModal from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue' -import ProductStructureBaseContextMenu - from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue' -import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue' -import NcDocumentSearchNcModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue' -import NcComponentBorrowModal from '@views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue' + import dncApi from '@/api/dnc' + import { deleteAction } from '@/api/manage' + import ProductStructureTreeContextMenu from './ProductStructureTreeContextMenu' + import ProductModal from './Product/ProductModal' + import ComponentModal from './Component/ComponentModal' + import PartModal from './Part/PartModal' + import ProcessSpecVersionModal from './ProcessSpecVersion/ProcessSpecVersionModal' + import ProcessModal from './Process/ProcessModal' + import ProcessStepModal from './ProcessStep/ProcessStepModal' + import AssignPermissionModal from './Permission/AssignPermissionModal' + import DeviceCustomTypeModal + from '@views/dnc/base/modules/ProductStructure/DeviceCustomType/DeviceCustomTypeModal.vue' + import ProductStructureBaseContextMenu + from '@views/dnc/base/modules/ProductStructure/ProductStructureBaseContextMenu.vue' + import NcDocumentSearchModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchModal.vue' + import NcDocumentSearchNcModal from '@views/dnc/base/modules/ProductStructure/Document/NcDocumentSearchNcModal.vue' + import NcComponentBorrowModal from '@views/dnc/base/modules/ProductStructure/Document/NcComponentBorrowModal.vue' -export default { - name: 'ProductStructureTree', - components: { - ProductStructureBaseContextMenu, - DeviceCustomTypeModal, - AssignPermissionModal, - ProcessStepModal, - ProcessModal, - ProcessSpecVersionModal, - PartModal, - ComponentModal, - ProductModal, - ProductStructureTreeContextMenu, - NcDocumentSearchModal, - NcDocumentSearchNcModal, - NcComponentBorrowModal - }, - data() { - return { - searchInput: '', - cardLoading: false, - loading: false, - treeDataSource: [], - selectedKeys: [], - expandedKeys: [], - beforeSearchExpandedKeys: [], - searchValue: '', - dataList: [], - autoExpandParent: true, - checkStrictly: true, - allTreeKeys: [], - rightClickSelected: {}, - url: { - delete: '/nc/product/delete' - } - } - }, - created() { - this.getTreeDataByApi() - this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - beforeDestroy() { - this.$bus.$off('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - // 璋冪敤鎺ュ彛鑾峰彇鏍戠殑鏁版嵁 - getTreeDataByApi() { - this.loading = true - this.cardLoading = true - this.treeDataSource = [] - dncApi.getProductStructureTreeApi() - .then(res => { - if (res.success) { - this.dataList = [] - this.allTreeKeys = [] - this.treeDataSource = res.result - this.generateList(this.treeDataSource) - // this.expandedKeys = this.allTreeKeys - if (this.expandedKeys.length === 0) this.expandedKeys = this.beforeSearchExpandedKeys = [this.treeDataSource[0].id] - } else { - this.$message.warn(res.message) - } - }).finally(() => { - this.loading = false - this.cardLoading = false - }) + export default { + name: 'ProductStructureTree', + components: { + ProductStructureBaseContextMenu, + DeviceCustomTypeModal, + AssignPermissionModal, + ProcessStepModal, + ProcessModal, + ProcessSpecVersionModal, + PartModal, + ComponentModal, + ProductModal, + ProductStructureTreeContextMenu, + NcDocumentSearchModal, + NcDocumentSearchNcModal, + NcComponentBorrowModal }, - - /** - * 鏍戣妭鐐归�変腑鏃惰Е鍙� - * @param selectedKeys 閫変腑鑺傜偣key - * @param {node} node 鑺傜偣瀵硅薄 - */ - handleTreeSelect(selectedKeys, { node }) { - const that = this - let record = node.dataRef - const { id, type } = record - dncApi.getProductStructureTreeNodeEntityApi({ id, type }) - .then(res => { - if (res.success) { - let currentSelectedNodeInfo - if (res.result.length > 0) { - currentSelectedNodeInfo = Object.assign({}, record, { entity: res.result[0] }) - } else { - currentSelectedNodeInfo = {} - that.$notification.warning({ - message: '娑堟伅', - description: '鏆傛棤璇ヨ妭鐐硅缁嗕俊鎭�' - }) - } - // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� - this.$bus.$emit('sendCurrentTreeNodeInfo', currentSelectedNodeInfo) - } else { - that.$notification.error({ - message: '娑堟伅', - description: res.message - }) - } - }) - if (selectedKeys.length === 0) return - this.selectedKeys = selectedKeys - }, - - /** - * 鏍戣妭鐐瑰彸閿崟鍑昏妭鐐规椂瑙﹀彂 - * @param node 鑺傜偣瀵硅薄 - */ - handleTreeRightClick({ node }) { - if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false - const that = this - const record = node.dataRef - const { id, type } = record - dncApi.getProductStructureTreeNodeEntityApi({ id, type }) - .then(res => { - if (res.success) { - if (res.result.length > 0) { - that.rightClickSelected = Object.assign({}, record, { entity: res.result[0] }) - } else { - that.rightClickSelected = {} - that.$notification.warning({ - message: '娑堟伅', - description: '鏆傛棤璇ヨ妭鐐硅缁嗕俊鎭�' - }) - } - } else { - that.$notification.error({ - message: '娑堟伅', - description: res.message - }) - } - }) - }, - - // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙� - handleDelete() { - const that = this - const { rightClickSelected: { id, type }, $confirm, url, $notification } = that - $confirm({ - title: '鎻愮ず', - content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵', - okText: '纭', - okType: 'danger', - cancelText: '鍙栨秷', - onOk: () => { - if (!url.delete) { - this.$message.error('璇疯缃畊rl.delete灞炴��!') - return - } - deleteAction(url.delete + `/${id}/${type}`) - .then((res) => { - if (res.success) { - that.getTreeDataByApi() - $notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { - $notification.warning({ - message: '娑堟伅', - description: res.message - }) - } - }) - .finally(() => { - that.$destroyAll() - }) - }, - onCancel: () => { - that.$destroyAll() + data() { + return { + searchInput: '', + cardLoading: false, + loading: false, + treeDataSource: [], + selectedKeys: [], + expandedKeys: [], + beforeSearchExpandedKeys: [], + searchValue: '', + dataList: [], + autoExpandParent: true, + checkStrictly: true, + allTreeKeys: [], + rightClickSelected: {}, + fullScreenSpinning: false, + url: { + delete: '/nc/product/delete' } - }) + } }, - - /** - * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 - * @param isAddNextLevel 鏄惁闇�瑕佸睍寮�涓嬬骇 - */ - modalFormSubmitSuccess(isAddNextLevel) { - // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑 - if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id) + created() { this.getTreeDataByApi() + this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) + this.$bus.$on('searchNcFinished', () => this.fullScreenSpinning = false) }, - - /** - * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙� - * @param expandedKeys 灞曞紑椤筴ey - */ - handleTreeExpand(expandedKeys) { - this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys - this.autoExpandParent = false + beforeDestroy() { + this.$bus.$off('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) }, + methods: { + // 璋冪敤鎺ュ彛鑾峰彇鏍戠殑鏁版嵁 + getTreeDataByApi() { + this.loading = true + this.cardLoading = true + this.treeDataSource = [] + dncApi.getProductStructureTreeApi() + .then(res => { + if (res.success) { + this.dataList = [] + this.allTreeKeys = [] + this.treeDataSource = res.result + this.generateList(this.treeDataSource) + // this.expandedKeys = this.allTreeKeys + if (this.expandedKeys.length === 0) this.expandedKeys = this.beforeSearchExpandedKeys = [this.treeDataSource[0].id] + } else { + this.$message.warn(res.message) + } + }).finally(() => { + this.loading = false + this.cardLoading = false + }) + }, - // 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙戯紙澧炲姞闃叉姈鏈哄埗锛� - handleSearchInputChange() { - const that = this - let timer - if (timer) clearTimeout(timer) - timer = setTimeout(function() { - that.searchAndExpandTreeNode() // 鍔犲皬鎷彿璋冪敤鍑芥暟 - }, 1000) - }, - - // 闃叉姈鍑芥暟涓Е鍙戞悳绱㈠苟灞曞紑鏍戣妭鐐� - searchAndExpandTreeNode() { - let search = this.searchInput - let expandedKeys - let autoExpandParent - if (search !== '') { - expandedKeys = this.dataList - .map(item => { - if (item.title != null) { - if (item.title.indexOf(search) > -1) { - return this.getParentKey(item.key, this.treeDataSource) + /** + * 鏍戣妭鐐归�変腑鏃惰Е鍙� + * @param selectedKeys 閫変腑鑺傜偣key + * @param eventOrRecord 鑺傜偣瀵硅薄鎴栬�呮墜鍔ㄤ紶鍏ecord + */ + handleTreeSelect(selectedKeys, eventOrRecord) { + const that = this + let record = eventOrRecord.node ? eventOrRecord.node.dataRef : eventOrRecord + const { id, type } = record + dncApi.getProductStructureTreeNodeEntityApi({ id, type }) + .then(res => { + if (res.success) { + let currentSelectedNodeInfo + if (res.result.length > 0) { + currentSelectedNodeInfo = Object.assign({}, record, { entity: res.result[0] }) + } else { + currentSelectedNodeInfo = {} + that.$notification.warning({ + message: '娑堟伅', + description: '鏆傛棤璇ヨ妭鐐硅缁嗕俊鎭�' + }) } - return null + // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� + this.$bus.$emit('sendCurrentTreeNodeInfo', currentSelectedNodeInfo) + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) } }) - .filter((item, i, self) => item && self.indexOf(item) === i) - autoExpandParent = true - } else { - expandedKeys = this.beforeSearchExpandedKeys - autoExpandParent = false - } - Object.assign(this, { - expandedKeys, - searchValue: search, - autoExpandParent - }) - }, + if (selectedKeys.length === 0) return + this.selectedKeys = selectedKeys + }, - /** - * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇key - * @param key 瀛愰」key - * @param tree 瀛愰」 - */ - getParentKey(key, tree) { - let parentKey - for (let i = 0; i < tree.length; i++) { - const node = tree[i] - if (node.children) { - if (node.children.some(item => item.key === key)) { - parentKey = node.key - } else if ( - this.getParentKey(key, node.children)) { - parentKey = this.getParentKey(key, node.children) + /** + * 鏍戣妭鐐瑰彸閿崟鍑昏妭鐐规椂瑙﹀彂 + * @param node 鑺傜偣瀵硅薄 + */ + handleTreeRightClick({ node }) { + if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false + const that = this + const record = node.dataRef + const { id, type } = record + dncApi.getProductStructureTreeNodeEntityApi({ id, type }) + .then(res => { + if (res.success) { + if (res.result.length > 0) { + that.rightClickSelected = Object.assign({}, record, { entity: res.result[0] }) + } else { + that.rightClickSelected = {} + that.$notification.warning({ + message: '娑堟伅', + description: '鏆傛棤璇ヨ妭鐐硅缁嗕俊鎭�' + }) + } + } else { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + }, + + // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙� + handleDelete() { + const that = this + const { rightClickSelected: { id, type }, $confirm, url, $notification } = that + $confirm({ + title: '鎻愮ず', + content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵', + okText: '纭', + okType: 'danger', + cancelText: '鍙栨秷', + onOk: () => { + if (!url.delete) { + this.$message.error('璇疯缃畊rl.delete灞炴��!') + return + } + deleteAction(url.delete + `/${id}/${type}`) + .then((res) => { + if (res.success) { + that.getTreeDataByApi() + $notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + $notification.warning({ + message: '娑堟伅', + description: res.message + }) + } + }) + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() + } + }) + }, + + /** + * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 + * @param isAddNextLevel 鏄惁闇�瑕佸睍寮�涓嬬骇 + */ + modalFormSubmitSuccess(isAddNextLevel) { + // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑 + if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id) + this.getTreeDataByApi() + }, + + /** + * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙� + * @param expandedKeys 灞曞紑椤筴ey + */ + handleTreeExpand(expandedKeys) { + this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys + this.autoExpandParent = false + }, + + /** + * 妫�绱C鏂囦欢寮圭獥涓弻鍑昏璁板綍鍚庤Е鍙戞悳绱C鏂囦欢瀵瑰簲鏍戣妭鐐瑰苟妯℃嫙閫変腑鏍戣妭鐐规煡璇㈠搴旇澶囩被鎴朜C鏂囦欢 + * @param searchNcRecord 妫�绱C鏂囦欢寮圭獥涓弻鍑昏幏寰楃殑NC鏂囦欢鍒楄〃琛岃褰� + */ + searchTreeNode(searchNcRecord) { + this.fullScreenSpinning = true + const { attributionId, nodeCode, nodeName, nodeId, docId } = searchNcRecord + this.searchInput = `[${nodeCode}]${nodeName}` + this.searchAndExpandTreeNode() + const treeNodeRecord = Object.assign({ + autoClickedLevelInfo: { + attributionId, + docId + } + }, this.getTreeNodeRecord(nodeId, this.treeDataSource)) + this.handleTreeSelect([treeNodeRecord.id], treeNodeRecord) + }, + + // 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙戯紙澧炲姞闃叉姈鏈哄埗锛� + handleSearchInputChange() { + const that = this + let timer + if (timer) clearTimeout(timer) + timer = setTimeout(function() { + that.searchAndExpandTreeNode() // 鍔犲皬鎷彿璋冪敤鍑芥暟 + }, 1000) + }, + + // 闃叉姈鍑芥暟涓Е鍙戞悳绱㈠苟灞曞紑鏍戣妭鐐� + searchAndExpandTreeNode() { + let search = this.searchInput + let expandedKeys + let autoExpandParent + if (search !== '') { + expandedKeys = this.dataList + .map(item => { + if (item.title != null) { + if (item.title.indexOf(search) > -1) { + return this.getParentKey(item.key, this.treeDataSource) + } + return null + } + }) + .filter((item, i, self) => item && self.indexOf(item) === i) + autoExpandParent = true + } else { + expandedKeys = this.beforeSearchExpandedKeys + autoExpandParent = false + } + Object.assign(this, { + expandedKeys, + searchValue: search, + autoExpandParent + }) + }, + + /** + * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇key + * @param key 瀛愰」key + * @param tree 瀛愰」 + */ + getParentKey(key, tree) { + let parentKey + for (let i = 0; i < tree.length; i++) { + const node = tree[i] + if (node.children) { + if (node.children.some(item => item.key === key)) { + parentKey = node.key + } else if ( + this.getParentKey(key, node.children)) { + parentKey = this.getParentKey(key, node.children) + } } } + return parentKey + }, + + /** + * 閫掑綊鑾峰緱杈撳叆椤圭殑record瀵硅薄 + * @param key record瀵硅薄key鍊� + * @param tree 鏍戣妭鐐� + */ + getTreeNodeRecord(key, tree) { + let treeNodeRecord + for (let i = 0; i < tree.length; i++) { + const node = tree[i] + if (node.children) { + if (node.children.findIndex(item => item.key === key) > -1) { + treeNodeRecord = node.children.find(item => item.key === key) + } else if (this.getTreeNodeRecord(key, node.children)) { + treeNodeRecord = this.getTreeNodeRecord(key, node.children) + } + } + } + return treeNodeRecord + }, + + /** + * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key + * @param data + */ + generateList(data) { + for (let i = 0; i < data.length; i++) { + data[i].key = data[i].id + const node = data[i] + const key = node.id + const title = node.label + this.dataList.push({ key, title }) + this.allTreeKeys.push(key) + this.setTreeNodeIcon(node) + if (node.children) this.generateList(node.children) + } + }, + + /** + * 鏍戞墍鍦ㄧ埗鍏冪礌鐨勫彸閿簨浠� + * @param event 浜嬩欢瀵硅薄 + */ + openBaseContextMenu(event) { + event.preventDefault() + if (event.target.id !== 'tree-container') return + this.$refs.baseContextmenuRef.menuStyle.top = event.clientY + 'px' + this.$refs.baseContextmenuRef.menuStyle.left = event.clientX + 'px' + this.$refs.baseContextmenuRef.menuVisible = true + document.body.addEventListener('click', this.handleBaseContextMenuClose) + }, + + /** + * 璁剧疆鏍戣妭鐐瑰浘鏍� + * @param treeNode + */ + setTreeNodeIcon(treeNode) { + switch (+treeNode.type) { + case 1: + treeNode.slots = { icon: 'product' } + break + case 2: + treeNode.slots = { icon: 'component' } + break + case 3: + treeNode.slots = { icon: 'part' } + break + case 4: + treeNode.slots = { icon: 'processSpecVersion' } + break + case 5: + treeNode.slots = { icon: 'process' } + break + case 6: + treeNode.slots = { icon: 'processStep' } + break + default: + } + }, + + // 鎺у埗鍩虹鍙抽敭鑿滃崟鍏抽棴 + handleBaseContextMenuClose() { + if (this.$refs.baseContextmenuRef) this.$refs.baseContextmenuRef.menuVisible = false + document.body.removeEventListener('click', this.handleBaseContextMenuClose) + }, + + // 鍒锋柊閲嶆柊鑾峰彇鏍戠殑鏁版嵁 + handleTreeReload() { + this.getTreeDataByApi() + }, + + triggerCorrespondingMethod({ methodName }) { + if (this[methodName]) this[methodName]() } - return parentKey - }, - /** - * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣key - * @param data - */ - generateList(data) { - for (let i = 0; i < data.length; i++) { - data[i].key = data[i].id - const node = data[i] - const key = node.id - const title = node.label - this.dataList.push({ key, title }) - this.allTreeKeys.push(key) - this.setTreeNodeIcon(node) - if (node.children) this.generateList(node.children) - } - }, - - /** - * 鏍戞墍鍦ㄧ埗鍏冪礌鐨勫彸閿簨浠� - * @param event 浜嬩欢瀵硅薄 - */ - openBaseContextMenu(event) { - event.preventDefault() - if (event.target.id !== 'tree-container') return - this.$refs.baseContextmenuRef.menuStyle.top = event.clientY + 'px' - this.$refs.baseContextmenuRef.menuStyle.left = event.clientX + 'px' - this.$refs.baseContextmenuRef.menuVisible = true - document.body.addEventListener('click', this.handleBaseContextMenuClose) - }, - - /** - * 璁剧疆鏍戣妭鐐瑰浘鏍� - * @param treeNode - */ - setTreeNodeIcon(treeNode) { - switch (+treeNode.type) { - case 1: - treeNode.slots = { icon: 'product' } - break - case 2: - treeNode.slots = { icon: 'component' } - break - case 3: - treeNode.slots = { icon: 'part' } - break - case 4: - treeNode.slots = { icon: 'processSpecVersion' } - break - case 5: - treeNode.slots = { icon: 'process' } - break - case 6: - treeNode.slots = { icon: 'processStep' } - break - default: - } - }, - - // 鎺у埗鍩虹鍙抽敭鑿滃崟鍏抽棴 - handleBaseContextMenuClose() { - if(this.$refs.baseContextmenuRef)this.$refs.baseContextmenuRef.menuVisible = false - document.body.removeEventListener('click', this.handleBaseContextMenuClose) - }, - - // 鍒锋柊閲嶆柊鑾峰彇鏍戠殑鏁版嵁 - handleTreeReload() { - this.getTreeDataByApi() - }, - - triggerCorrespondingMethod({ methodName }) { - if (this[methodName]) this[methodName]() } - } -} </script> <style lang="less" scoped> -/deep/ .ant-card-body { - padding: 0 12px 0 0; -} - -/deep/ .ant-card-body, /deep/ .ant-spin-nested-loading, /deep/ .ant-spin-container { - height: 100%; -} - -/deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger { - display: inline-block; - width: calc(100% - 24px) !important; -} - -::-webkit-scrollbar { - width: 8px; -} - -@media screen and (min-width: 1920px) { - .tree_con { - height: 748px !important; + /deep/ .ant-card-body { + padding: 0 12px 0 0; } -} -@media screen and (min-width: 1680px) and (max-width: 1920px) { - .tree_con { - height: 748px !important; + /deep/ .ant-card-body, /deep/ .ant-spin-nested-loading, /deep/ .ant-spin-container { + height: 100%; } -} -@media screen and (min-width: 1400px) and (max-width: 1680px) { - .tree_con { - height: 600px !important; + /deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger { + display: inline-block; + width: calc(100% - 24px) !important; } -} -@media screen and (min-width: 1280px) and (max-width: 1400px) { - .tree_con { - height: 501px !important; + ::-webkit-scrollbar { + width: 8px; } -} -@media screen and (max-width: 1280px) { - .tree_con { - height: 501px !important; + .full-screen-container { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, .8); + z-index: 9999; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; } -} + + @media screen and (min-width: 1920px) { + .tree_con { + height: 748px !important; + } + } + + @media screen and (min-width: 1680px) and (max-width: 1920px) { + .tree_con { + height: 748px !important; + } + } + + @media screen and (min-width: 1400px) and (max-width: 1680px) { + .tree_con { + height: 600px !important; + } + } + + @media screen and (min-width: 1280px) and (max-width: 1400px) { + .tree_con { + height: 501px !important; + } + } + + @media screen and (max-width: 1280px) { + .tree_con { + height: 501px !important; + } + } </style> -- Gitblit v1.9.3