From bc55e59f49229ffa77d2b32dd9fd0a9b6049b9b8 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期五, 14 三月 2025 09:44:25 +0800 Subject: [PATCH] 1、设备类管理页面完成增删改查功能 2、产品结构树工序及工步层级引入设备类概念由系统参数配置决定是否展示,若设备类存在时则NC文档挂载在设备类下不存在时则按照对应工序或工步层级下 3、产品结构树工序及工步层级的刀具列表实现增删改查功能 4、新增设备类管理页面并完成布局 5、产品结构树接口调整,产品结构树节点实体信息通过点击后调取接口获取 6、产品结构树搜素输入框增加防抖机制,避免每次输入都重新计算消耗性能使页面卡顿 7、新增工序及工步层级的刀具列表并添加系统权限 8、用户管理页面移除新增用户时的密码校验 9、产品结构树各层级属性信息展示由每行3列调整为每行4列 10、产品结构树页面在工序和工步层级实现对设备类的增删改查功能 --- src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue | 479 +++++++++++++++++++++++++++++++---------------------------- 1 files changed, 253 insertions(+), 226 deletions(-) diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue index c19f1d8..97b73a0 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue @@ -36,6 +36,7 @@ <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> @@ -50,6 +51,8 @@ <ComponentModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--闆朵欢寮圭獥--> <PartModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> + <!--宸ヨ壓瑙勭▼鐗堟湰寮圭獥--> + <ProcessSpecVersionModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--宸ュ簭寮圭獥--> <ProcessModal :currentTreeNodeInfo="rightClickSelected" @submitSuccess="modalFormSubmitSuccess"/> <!--宸ユ寮圭獥--> @@ -60,151 +63,166 @@ </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 ProcessModal from './Process/ProcessModal' - import ProcessStepModal from './ProcessStep/ProcessStepModal' - import AssignPermissionModal from './Permission/AssignPermissionModal' +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' - export default { - name: 'ProductStructureTree', - components: { - AssignPermissionModal, - ProcessStepModal, - ProcessModal, - PartModal, - ComponentModal, - ProductModal, - ProductStructureTreeContextMenu - }, - data() { - return { - searchInput: '', - cardLoading: false, - loading: false, - treeDataSource: [], - selectedKeys: [], - expandedKeys: [], - searchValue: '', - dataList: [], - autoExpandParent: true, - checkStrictly: true, - allTreeKeys: [], - currentSelected: {}, - rightClickSelected: {}, - url: { - delete: '/nc/product/delete' - } +export default { + name: 'ProductStructureTree', + components: { + AssignPermissionModal, + ProcessStepModal, + ProcessModal, + ProcessSpecVersionModal, + PartModal, + ComponentModal, + ProductModal, + ProductStructureTreeContextMenu + }, + data() { + return { + searchInput: '', + cardLoading: false, + loading: false, + treeDataSource: [], + selectedKeys: [], + expandedKeys: [], + beforeSearchExpandedKeys: [], + searchValue: '', + dataList: [], + autoExpandParent: true, + checkStrictly: true, + allTreeKeys: [], + currentSelected: {}, + rightClickSelected: {}, + url: { + delete: '/nc/product/delete' } - }, - created() { - this.getTreeDataByApi() - this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - getTreeDataByApi() { - this.loading = true - this.cardLoading = true - dncApi.getProductStructureTreeApi().then(res => { + } + }, + created() { + this.getTreeDataByApi() + this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) + }, + methods: { + getTreeDataByApi() { + this.loading = true + this.cardLoading = true + dncApi.getProductStructureTreeApi() + .then(res => { if (res.success) { + console.log('res=================', res) this.dataList = [] this.allTreeKeys = [] - this.treeDataSource = res.list + this.treeDataSource = res.result this.generateList(this.treeDataSource) // this.expandedKeys = this.allTreeKeys - if (this.expandedKeys.length === 0) this.expandedKeys = [this.treeDataSource[0].id] + 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 - }) - }, + this.loading = false + this.cardLoading = false + }) + }, - /** - * 鏍戣妭鐐归�変腑鏃惰Е鍙� - * @param selectedKeys 閫変腑鑺傜偣key - * @param {node} node 鑺傜偣瀵硅薄 - */ - handleTreeSelect(selectedKeys, { node }) { - let record = node.dataRef - this.currentSelected = Object.assign({}, record) - this.selectedKeys = selectedKeys - // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� - this.$bus.$emit('sendCurrentTreeNodeInfo', this.currentSelected) - }, + /** + * 鏍戣妭鐐归�変腑鏃惰Е鍙� + * @param selectedKeys 閫変腑鑺傜偣key + * @param {node} node 鑺傜偣瀵硅薄 + */ + handleTreeSelect(selectedKeys, { node }) { + let record = node.dataRef + this.currentSelected = Object.assign({}, record) + // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� + this.$bus.$emit('sendCurrentTreeNodeInfo', this.currentSelected) + if (selectedKeys.length === 0) return + this.selectedKeys = selectedKeys + }, - /** - * 鏍戣妭鐐瑰彸閿崟鍑昏妭鐐规椂瑙﹀彂 - * @param event 浜嬩欢瀵硅薄 - * @param node 鑺傜偣瀵硅薄 - */ - handleTreeRightClick({ event, node }) { - const record = node.dataRef - this.rightClickSelected = Object.assign({}, record) - }, + /** + * 鏍戣妭鐐瑰彸閿崟鍑昏妭鐐规椂瑙﹀彂 + * @param event 浜嬩欢瀵硅薄 + * @param node 鑺傜偣瀵硅薄 + */ + handleTreeRightClick({ event, node }) { + const record = node.dataRef + this.rightClickSelected = Object.assign({}, record) + }, - // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙� - handleDelete() { - this.$confirm({ - title: '鎻愮ず', - content: '纭鍒犻櫎姝ゆ潯璁板綍鍚楋紵', - okText: '纭', - okType: 'danger', - cancelText: '鍙栨秷', - onOk: () => { - console.log('this.rightClickSelected.id', this.rightClickSelected.id) - if (!this.url.delete) { - this.$message.error('璇疯缃畊rl.delete灞炴��!') - return - } - const that = this - deleteAction(that.url.delete, { id: this.rightClickSelected.id }) - .then((res) => { - if (res.success) { - that.getTreeDataByApi() - that.$notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { - that.$notification.warning({ - 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() + } + }) + }, - /** - * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 - */ - modalFormSubmitSuccess(isAddNextLevel) { - // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑 - if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id) - this.getTreeDataByApi() - }, + /** + * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 + */ + 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 = expandedKeys - this.autoExpandParent = false - }, + /** + * 鏍戣妭鐐瑰睍寮�鍚堝苟鏃惰Е鍙� + * @param expandedKeys 灞曞紑椤筴ey + */ + handleTreeExpand(expandedKeys) { + this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys + this.autoExpandParent = false + }, - /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ - handleSearchInputChange() { - let search = this.searchInput - let expandedKeys = this.dataList + /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ + handleSearchInputChange() { + 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) { @@ -214,128 +232,137 @@ } }) .filter((item, i, self) => item && self.indexOf(item) === i) - Object.assign(this, { - expandedKeys, - searchValue: search, - autoExpandParent: true - }) - }, + autoExpandParent = true + } else { + expandedKeys = this.beforeSearchExpandedKeys + autoExpandParent = false + } - /** - * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇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) - } + 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 - }, + } + 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) - } - }, + /** + * 閫掑綊鑾峰緱鎵�鏈夋爲鑺傜偣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) + } + }, - triggerCorrespondingMethod({ methodName }) { - if (this[methodName]) this[methodName]() - }, + triggerCorrespondingMethod({ methodName }) { + if (this[methodName]) this[methodName]() + }, - /** - * 璁剧疆鏍戣妭鐐瑰浘鏍� - * @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 5: - treeNode.slots = { icon: 'process' } - break - case 6: - treeNode.slots = { icon: 'processStep' } - break - default: - } + /** + * 璁剧疆鏍戣妭鐐瑰浘鏍� + * @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: } } } +} </script> <style lang="less" scoped> - /deep/ .ant-card-body { - padding: 0 12px 0 0; - } +/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-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; - } +/deep/ .ant-tree-title, .ant-tree-title .ant-dropdown-trigger { + display: inline-block; + width: calc(100% - 24px) !important; +} - ::-webkit-scrollbar { - width: 8px; - } +::-webkit-scrollbar { + width: 8px; +} - @media screen and (min-width: 1920px) { - .tree_con { - height: 748px !important; - } +@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: 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: 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 (min-width: 1280px) and (max-width: 1400px) { + .tree_con { + height: 501px !important; } +} - @media screen and (max-width: 1280px) { - .tree_con { - height: 501px !important; - } +@media screen and (max-width: 1280px) { + .tree_con { + height: 501px !important; } +} </style> -- Gitblit v1.9.3