From e9353e9639ac50735713eb85a8fe0ef7e06afa4f Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期一, 10 三月 2025 13:41:25 +0800 Subject: [PATCH] 1、产品和设备结构树选择节点时可以连续点击相同节点且不会取消选中当前节点 2、产品结构树接口调整,产品结构树节点实体信息通过点击后调取接口获取(仍有bug,点击一次会出现多次重复请求) --- src/views/dnc/base/modules/ProductStructure/Process/ProcessModalForm.vue | 5 src/api/dnc.js | 4 src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepInfo.vue | 2 src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue | 509 ++++++++++++++++++------------------ src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue | 4 src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModalForm.vue | 6 src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue | 228 ++++++++------- src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue | 18 - src/views/dnc/base/modules/ProductStructure/ProcessSpecVersion/ProcessSpecVersionModal.vue | 5 src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModal.vue | 18 - 10 files changed, 384 insertions(+), 415 deletions(-) diff --git a/src/api/dnc.js b/src/api/dnc.js index 0fba512..ef1c3db 100644 --- a/src/api/dnc.js +++ b/src/api/dnc.js @@ -13,7 +13,9 @@ export default { //-------------------------浜у搧缁撴瀯鏍�------------------------------------------------ // 鑾峰彇浜у搧缁撴瀯鏍� - getProductStructureTreeApi: () => getAction('/nc/product/load/tree'), + getProductStructureTreeApi: () => getAction('/nc/product/getTree'), + // 鑾峰彇浜у搧缁撴瀯鏍戣妭鐐瑰疄浣撲俊鎭� + getProductStructureTreeNodeEntityApi:params=> getAction('/nc/product/getTreeById',params), // 鑾峰彇鎵�鏈夎澶囩殑鍒楄〃 getAllDeviceListApi: (type) => getAction('/nc/device/list/all'), // 瀵煎叆NC绋嬪簭/鏂囨。 diff --git a/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue b/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue index 5e53cf4..a930ddd 100644 --- a/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue +++ b/src/views/dnc/base/modules/DeviceStructure/DeviceStructureTree.vue @@ -114,9 +114,11 @@ handleTreeSelect(selectedKeys, { node }) { let record = node.dataRef this.currentSelected = Object.assign({}, record) - this.selectedKeys = selectedKeys // 鍚戝彸渚х埗绾х粍浠跺彂閫佸綋鍓嶉�変腑鏍戣妭鐐逛俊鎭� this.$bus.$emit('sendDeviceTreeNodeInfo', this.currentSelected) + if (selectedKeys.length === 0) return + this.selectedKeys = selectedKeys + }, /** diff --git a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue index e1f60d7..0f35c26 100644 --- a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue +++ b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModal.vue @@ -8,12 +8,11 @@ @ok="handleOk" @cancel="handleCancel" cancelText="鍏抽棴"> - <ProcessModalForm ref="realForm" @ok="submitCallback" :allDeviceList="allDeviceList"/> + <ProcessModalForm ref="realForm" @ok="submitCallback"/> </j-modal> </template> <script> - import dncApi from '@/api/dnc' import ProcessModalForm from './ProcessModalForm.vue' export default { @@ -31,28 +30,13 @@ title: '', width: 700, visible: false, - allDeviceList: [], isAddNextLevel: false // 鏄惁涓烘坊鍔犱笅绾э紝浣滀负鏍戣妭鐐规槸鍚﹀睍寮�鐨勫垽鏂� - } - }, - watch: { - visible: { - handler(value) { - if (value) this.getAllDeviceListByApi() - } } }, created() { this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) }, methods: { - getAllDeviceListByApi() { - dncApi.getAllDeviceListApi() - .then(res => { - if (res.success) this.allDeviceList = res.list - }) - }, - /** * 鐐瑰嚮閮ㄤ欢鍒涘缓閮ㄤ欢涓嬬骇宸ュ簭 */ diff --git a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModalForm.vue b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModalForm.vue index 1866bd5..0823c70 100644 --- a/src/views/dnc/base/modules/ProductStructure/Process/ProcessModalForm.vue +++ b/src/views/dnc/base/modules/ProductStructure/Process/ProcessModalForm.vue @@ -83,11 +83,6 @@ export default { name: 'ProcessModalForm', components: {}, - props: { - allDeviceList: { - type: Array - } - }, data() { return { model: { diff --git a/src/views/dnc/base/modules/ProductStructure/ProcessSpecVersion/ProcessSpecVersionModal.vue b/src/views/dnc/base/modules/ProductStructure/ProcessSpecVersion/ProcessSpecVersionModal.vue index 420927b..d19371b 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProcessSpecVersion/ProcessSpecVersionModal.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProcessSpecVersion/ProcessSpecVersionModal.vue @@ -8,12 +8,11 @@ @ok="handleOk" @cancel="handleCancel" cancelText="鍏抽棴"> - <ProcessSpecVersionModalForm ref="realForm" @ok="submitCallback" :allDeviceList="allDeviceList"/> + <ProcessSpecVersionModalForm ref="realForm" @ok="submitCallback"/> </j-modal> </template> <script> - import dncApi from '@/api/dnc' import ProcessSpecVersionModalForm from './ProcessSpecVersionModalForm.vue' export default { @@ -31,7 +30,6 @@ title: '', width: 500, visible: false, - allDeviceList: [], isAddNextLevel: false // 鏄惁涓烘坊鍔犱笅绾э紝浣滀负鏍戣妭鐐规槸鍚﹀睍寮�鐨勫垽鏂� } }, @@ -42,7 +40,6 @@ handleOk() { this.$refs.realForm.submitForm() }, - // 鍒涘缓闆朵欢涓嬬骇宸ヨ壓瑙勭▼鐗堟湰 handlePartsAddRelative() { diff --git a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepInfo.vue b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepInfo.vue index 0fb30cd..d4649d5 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepInfo.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepInfo.vue @@ -5,7 +5,7 @@ <a-descriptions-item label="宸ユ绫诲瀷">{{currentLevelDetails.stepType}}</a-descriptions-item> <a-descriptions-item label="鍔犲伐璁惧鍨嬪彿">{{currentLevelDetails.processingEquipmentModel}}</a-descriptions-item> <a-descriptions-item label="鍔犲伐璁惧绫诲瀷">{{currentLevelDetails.processingEquipmentOs}}</a-descriptions-item> - <a-descriptions-item label="鍔犲伐璁惧缂栧彿">{{currentLevelDetails.deviceNo_dictText}}</a-descriptions-item> + <a-descriptions-item label="鍔犲伐璁惧缂栧彿">{{currentLevelDetails.deviceNo}}</a-descriptions-item> <a-descriptions-item label="宸ヨ缂栧彿">{{currentLevelDetails.assembleStep}}</a-descriptions-item> <a-descriptions-item label="宸ヨ鍚嶇О " :span="2">{{currentLevelDetails.assembleName}}</a-descriptions-item> <a-descriptions-item label="鍒涘缓浜�">{{currentLevelDetails.createName}}</a-descriptions-item> diff --git a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModal.vue b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModal.vue index 5456b2f..c430569 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModal.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModal.vue @@ -8,12 +8,11 @@ @ok="handleOk" @cancel="handleCancel" cancelText="鍏抽棴"> - <ProcessStepModalForm ref="realForm" @ok="submitCallback" :allDeviceList="allDeviceList"/> + <ProcessStepModalForm ref="realForm" @ok="submitCallback"/> </j-modal> </template> <script> - import dncApi from '@/api/dnc' import ProcessStepModalForm from './ProcessStepModalForm.vue' export default { @@ -26,19 +25,11 @@ type: Object } }, - watch: { - visible: { - handler(value) { - if (value) this.getAllDeviceListByApi() - } - } - }, data() { return { title: '', width: 700, visible: false, - allDeviceList: [], isAddNextLevel: false // 鏄惁涓烘坊鍔犱笅绾э紝浣滀负鏍戣妭鐐规槸鍚﹀睍寮�鐨勫垽鏂� } }, @@ -46,13 +37,6 @@ this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) }, methods: { - getAllDeviceListByApi() { - dncApi.getAllDeviceListApi() - .then(res => { - if (res.success) this.allDeviceList = res.list - }) - }, - /** * 鐐瑰嚮宸ュ簭鍒涘缓宸ュ簭涓嬬骇宸ユ */ diff --git a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModalForm.vue b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModalForm.vue index 782759a..63d9a73 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModalForm.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProcessStep/ProcessStepModalForm.vue @@ -35,7 +35,6 @@ </a-col> </a-row> - <a-row> <a-col :span="12"> <a-form-model-item label="宸ユ绫诲瀷"> @@ -71,11 +70,6 @@ export default { name: 'ProcessStepModalForm', components: {}, - props: { - allDeviceList: { - type: Array - } - }, data() { return { model: { diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue index 3ec0b3e..c00a390 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainBottom.vue @@ -1,27 +1,27 @@ <template> <div v-if="currentLevelInfo.type!==4"> <a-tabs v-model="activeTabKey" v-if="Object.keys(currentLevelInfo).length>0" @change="handleTabChange"> - <a-tab-pane :key="1" tab="灞炴�т俊鎭�" v-if="currentLevelInfo.type===1"> + <a-tab-pane :key="1" tab="灞炴�т俊鎭�" v-if="+currentLevelInfo.type===1"> <ProductInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="1" tab="灞炴�т俊鎭�" v-if="currentLevelInfo.type===2"> + <a-tab-pane :key="1" tab="灞炴�т俊鎭�" v-if="+currentLevelInfo.type===2"> <ComponentInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="1" tab="闆朵欢灞炴��" v-if="currentLevelInfo.type===3"> + <a-tab-pane :key="1" tab="闆朵欢灞炴��" v-if="+currentLevelInfo.type===3"> <PartInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="1" tab="宸ュ簭灞炴��" v-if="currentLevelInfo.type===5"> + <a-tab-pane :key="1" tab="宸ュ簭灞炴��" v-if="+currentLevelInfo.type===5"> <ProcessInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="1" tab="宸ユ灞炴��" v-if="currentLevelInfo.type===6"> + <a-tab-pane :key="1" tab="宸ユ灞炴��" v-if="+currentLevelInfo.type===6"> <ProcessStepInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="2" tab="鍒�鍏蜂俊鎭�" v-if="currentLevelInfo.type===5||currentLevelInfo.type===6"> + <a-tab-pane :key="2" tab="鍒�鍏蜂俊鎭�" v-if="+currentLevelInfo.type===5||+currentLevelInfo.type===6"> <CutterInfo :currentLevelDetails="currentLevelInfo.entity" :size="containerSize"/> </a-tab-pane> @@ -41,7 +41,7 @@ :size="containerSize"/> </a-tab-pane> - <a-tab-pane :key="4" tab="浣跨敤璁惧" v-if="currentLevelInfo.attributionType===5"> + <a-tab-pane :key="4" tab="浣跨敤璁惧" v-if="+currentLevelInfo.attributionType===5"> <UseDocumentEquipmentTableList ref="useDocumentEquipmentTableRef" :currentDocumentInfo="currentLevelInfo" :size="containerSize"/> </a-tab-pane> @@ -53,117 +53,125 @@ </template> <script> - import ProductInfo from './Product/ProductInfo' - import ComponentInfo from './Component/ComponentInfo' - import PartInfo from './Part/PartInfo' - import ProcessInfo from './Process/ProcessInfo' - import DocumentInfo from '../../../common/DocumentInfo' - import DocumentVersionTableList from '../../../common/DocumentVersionTableList' - import UseDocumentEquipmentTableList from './Document/UseNcDocumentEquipmentTableList' - import ProcessStepInfo from './ProcessStep/ProcessStepInfo' - import FilePreview from '../../../common/FilePreview' - import TableContextMenu from '../../../common/TableContextMenu' - import CutterInfo from '@views/dnc/base/modules/ProductStructure/Cutter/CutterInfo.vue' +import ProductInfo from './Product/ProductInfo' +import ComponentInfo from './Component/ComponentInfo' +import PartInfo from './Part/PartInfo' +import ProcessInfo from './Process/ProcessInfo' +import DocumentInfo from '../../../common/DocumentInfo' +import DocumentVersionTableList from '../../../common/DocumentVersionTableList' +import UseDocumentEquipmentTableList from './Document/UseNcDocumentEquipmentTableList' +import ProcessStepInfo from './ProcessStep/ProcessStepInfo' +import FilePreview from '../../../common/FilePreview' +import TableContextMenu from '../../../common/TableContextMenu' +import CutterInfo from '@views/dnc/base/modules/ProductStructure/Cutter/CutterInfo.vue' +import dncApi from '@/api/dnc' - export default { - name: 'ProductStructureMainBottom', - components: { - CutterInfo, - TableContextMenu, - FilePreview, - ProcessStepInfo, - UseDocumentEquipmentTableList, - DocumentVersionTableList, - DocumentInfo, - ProcessInfo, - PartInfo, - ProductInfo, - ComponentInfo - }, - data() { - return { - activeTabKey: 1, - containerSize: 'small', - currentLevelInfo: {}, - currentRightClickedTableRowInfo: {}, - hasLoadedDataTabKeyArray: [] - } - }, - created() { - this.$bus.$on('sendCurrentClickedDocumentInfo', this.receiveCurrentLevelInfo) - this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentLevelInfo) - this.$bus.$on('reloadMainBottomTableData', this.reloadMainBottomTableData) - }, - methods: { - /** - * 鎺ユ敹鏍戠粍浠朵互鍙婅〃鏍间紶鏉ョ殑褰撳墠閫変腑鎴栫偣鍑荤殑椤逛俊鎭� - * @param levelInfo 褰撳墠灞傜骇淇℃伅 - */ - receiveCurrentLevelInfo(levelInfo) { - this.currentLevelInfo = levelInfo - this.activeTabKey = 1 - this.hasLoadedDataTabKeyArray = [] - }, - - handleTabChange(activeTabKey) { - if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) { - switch (activeTabKey) { - case 2: - this.$nextTick(() => this.$refs.filePreviewRef.getFilePreviewByApi()) - break - case 3: - this.$nextTick(() => this.$refs.documentVersionTableRef.loadData()) - break - case 4: - this.$nextTick(() => this.$refs.useDocumentEquipmentTableRef.loadData()) - break - default: +export default { + name: 'ProductStructureMainBottom', + components: { + CutterInfo, + TableContextMenu, + FilePreview, + ProcessStepInfo, + UseDocumentEquipmentTableList, + DocumentVersionTableList, + DocumentInfo, + ProcessInfo, + PartInfo, + ProductInfo, + ComponentInfo + }, + data() { + return { + activeTabKey: 1, + containerSize: 'small', + currentLevelInfo: {}, + currentRightClickedTableRowInfo: {}, + hasLoadedDataTabKeyArray: [] + } + }, + created() { + this.$bus.$on('sendCurrentClickedDocumentInfo', this.receiveCurrentLevelInfo) + this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentLevelInfo) + this.$bus.$on('reloadMainBottomTableData', this.reloadMainBottomTableData) + }, + methods: { + /** + * 鎺ユ敹鏍戠粍浠朵互鍙婅〃鏍间紶鏉ョ殑褰撳墠閫変腑鎴栫偣鍑荤殑椤逛俊鎭� + * @param levelInfo 褰撳墠灞傜骇淇℃伅 + */ + receiveCurrentLevelInfo(levelInfo) { + const { id, type } = levelInfo + dncApi.getProductStructureTreeNodeEntityApi({ id, type }) + .then(res => { + if (res.success) { + console.log('res-------------', res) + this.currentLevelInfo = Object.assign(levelInfo, { entity: res.result[0] }) } - // 闃绘鎺ュ彛鍦ㄥ悓涓�鏂囨。涓�娆$偣鍑诲唴澶氭瑙﹀彂 - this.hasLoadedDataTabKeyArray.push(activeTabKey) + }) + this.activeTabKey = 1 + this.hasLoadedDataTabKeyArray = [] + }, + + handleTabChange(activeTabKey) { + if (!this.hasLoadedDataTabKeyArray.includes(activeTabKey)) { + switch (activeTabKey) { + case 2: + this.$nextTick(() => this.$refs.filePreviewRef.getFilePreviewByApi()) + break + case 3: + this.$nextTick(() => this.$refs.documentVersionTableRef.loadData()) + break + case 4: + this.$nextTick(() => this.$refs.useDocumentEquipmentTableRef.loadData()) + break + default: } - }, - - // 閲婃斁鏂囦欢棰勮鎺ュ彛 - releaseFilePreviewApi() { - // 濡傛灉宸茬粡棰勮杩囨鏂囨。锛屽彲鍦ㄦ鏂囨。褰撳墠鐗堟湰鍙戠敓鏀瑰彉鍚庡啀娆¢瑙堟柊鐗堟湰鍐呭 - if (this.hasLoadedDataTabKeyArray.includes(2)) this.hasLoadedDataTabKeyArray = this.hasLoadedDataTabKeyArray.filter(item => item !== 2) - }, - - /** - * 鎺у埗鍙抽敭鑿滃崟寮�鍚� - * @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) - }, - - /** - * 鎺у埗鍙抽敭鑿滃崟鐐瑰嚮鍏抽棴 - */ - handleMenuClose() { - this.$refs.tableContextMenuRef.menuVisible = false - document.body.removeEventListener('click', this.handleMenuClose) - }, - - reloadMainBottomTableData(tableName) { - if (this.$refs[tableName + 'TableRef']) this.$refs[tableName + 'TableRef'].loadData() + // 闃绘鎺ュ彛鍦ㄥ悓涓�鏂囨。涓�娆$偣鍑诲唴澶氭瑙﹀彂 + this.hasLoadedDataTabKeyArray.push(activeTabKey) } + }, + + // 閲婃斁鏂囦欢棰勮鎺ュ彛 + releaseFilePreviewApi() { + // 濡傛灉宸茬粡棰勮杩囨鏂囨。锛屽彲鍦ㄦ鏂囨。褰撳墠鐗堟湰鍙戠敓鏀瑰彉鍚庡啀娆¢瑙堟柊鐗堟湰鍐呭 + if (this.hasLoadedDataTabKeyArray.includes(2)) this.hasLoadedDataTabKeyArray = this.hasLoadedDataTabKeyArray.filter(item => item !== 2) + }, + + /** + * 鎺у埗鍙抽敭鑿滃崟寮�鍚� + * @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) + }, + + /** + * 鎺у埗鍙抽敭鑿滃崟鐐瑰嚮鍏抽棴 + */ + handleMenuClose() { + this.$refs.tableContextMenuRef.menuVisible = false + document.body.removeEventListener('click', this.handleMenuClose) + }, + + reloadMainBottomTableData(tableName) { + if (this.$refs[tableName + 'TableRef']) this.$refs[tableName + 'TableRef'].loadData() } } +} </script> <style scoped> - /deep/ .ant-tabs-content { - height: calc(100% - 65px); - } +/deep/ .ant-tabs-content { + height: calc(100% - 65px); +} - /deep/ .ant-tabs-tabpane { - overflow: auto; - } +/deep/ .ant-tabs-tabpane { + overflow: auto; +} </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 1a8ebdf..97b73a0 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureTree.vue @@ -63,63 +63,65 @@ </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 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, - 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' - } +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.beforeSearchExpandedKeys = [this.treeDataSource[0].id] @@ -127,239 +129,240 @@ 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() { - 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() + // 鏍戣妭鐐瑰彸閿崟鍑昏彍鍗曚腑鍒犻櫎鎸夐挳鏃惰Е鍙� + 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 } - }) - }, - - /** - * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 - */ - 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 - }, - - /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ - 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) { - return this.getParentKey(item.key, this.treeDataSource) - } - return null + 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 + }) } }) - .filter((item, i, self) => item && self.indexOf(item) === i) - autoExpandParent = true - } else { - expandedKeys = this.beforeSearchExpandedKeys - autoExpandParent = false + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() } + }) + }, - Object.assign(this, { - expandedKeys, - searchValue: search, - autoExpandParent - }) - }, + /** + * 鑷姩灞曞紑娣诲姞涓嬬骇鑺傜偣鐨勭埗鑺傜偣 + */ + modalFormSubmitSuccess(isAddNextLevel) { + // 鍒ゆ柇鏄惁涓烘坊鍔犱笅绾у苟涓斿垽鏂埗鑺傜偣鏄惁灞曞紑 + if (isAddNextLevel && !this.expandedKeys.includes(this.rightClickSelected.id)) this.expandedKeys.push(this.rightClickSelected.id) + this.getTreeDataByApi() + }, - /** - * 閫掑綊鑾峰緱杈撳叆椤圭殑鐖剁骇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 expandedKeys 灞曞紑椤筴ey + */ + handleTreeExpand(expandedKeys) { + this.expandedKeys = this.beforeSearchExpandedKeys = expandedKeys + this.autoExpandParent = false + }, + + /* 杈撳叆鏌ヨ鍐呭鍙樺寲鏃惰Е鍙� */ + 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) { + 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 - }, + } + 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 4: - treeNode.slots = { icon: 'processSpecVersion' } - 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