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 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 419 insertions(+), 386 deletions(-) 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 -- Gitblit v1.9.3