From 08e52db54ce1e7563f1efe402a3f6c3931188013 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期五, 14 二月 2025 10:47:53 +0800 Subject: [PATCH] 产品结构树: 1、实现文档批量删除功能 2、实现文档列表的排序以及筛选功能 设备结构树: 1、新增权限配置弹窗,提交后由后端测试 --- src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue | 358 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 322 insertions(+), 36 deletions(-) diff --git a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue index 790df03..b0fecf4 100644 --- a/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue +++ b/src/views/dnc/base/modules/ProductStructure/ProductStructureMainTop.vue @@ -1,32 +1,36 @@ <template> - <a-tabs v-model="activeTabKey" @change="handleTabChange" @contextmenu.native="e=>e.preventDefault()" + <a-tabs v-model="activeTabKey" @contextmenu.native="e=>e.preventDefault()" v-if="Object.keys(currentTreeNodeInfo).length!==0"> - <a-tab-pane :key="1" tab="NC鏂囨。" v-if="currentTreeNodeInfo.type!==1"> + <a-tab-pane :key="1" tab="NC鏂囨。" v-if="currentTreeNodeInfo.type===5||currentTreeNodeInfo.type===6"> <NcDocumentTableList ref="ncDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo" @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/> </a-tab-pane> - <a-tab-pane :key="2" tab="鍏朵粬鏂囨。"> + <a-tab-pane :key="1" tab="鍏朵粬鏂囨。" v-else> <OtherDocumentTableList ref="otherDocumentTableListRef" :currentTreeNodeInfo="currentTreeNodeInfo" @handleTableContextMenuOpen="handleTableContextMenuOpen" :size="tableContainerSize"/> </a-tab-pane> <TableContextMenu :tableRowInfo="currentRightClickedTableRowInfo" ref="tableContextMenuRef"/> + + <DocumentBatchDeleteModal :currentDocumentInfo="currentRightClickedTableRowInfo" :size="tableContainerSize" + @reloadDocumentListData="reloadDocumentListData" ref="documentBatchDeleteModalRef"/> </a-tabs> </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' export default { name: 'ProductStructureMainTop', - components: { TableContextMenu, OtherDocumentTableList, NcDocumentTableList }, + components: { DocumentBatchDeleteModal, TableContextMenu, OtherDocumentTableList, NcDocumentTableList }, data() { return { - activeTabKey: null, - hasLoadingDataTabKey: [], + activeTabKey: 1, tableContainerSize: 'small', currentRightClickedTableRowInfo: {}, currentTreeNodeInfo: {} @@ -34,19 +38,8 @@ }, created() { this.$bus.$on('sendCurrentTreeNodeInfo', this.receiveCurrentTreeNodeInfo) - }, - watch: { - activeTabKey: { - handler(value) { - // tab鍒囨崲鏃跺姞杞藉搴旀枃妗e垪琛紝褰撳墠鏍戣妭鐐逛笅宸茬粡鍔犺浇杩囩殑鏂囨。鍒楄〃涓嶅啀閲嶅鍔犺浇 - if (!this.hasLoadingDataTabKey.includes(value)) { - if (value === 1) this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1)) - else this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1)) - this.hasLoadingDataTabKey.push(value) - } - }, - deep: true - } + this.$bus.$on('reloadDocumentListData', this.reloadDocumentListData) + this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) }, methods: { /** @@ -55,6 +48,7 @@ */ handleTableContextMenuOpen(record) { this.currentRightClickedTableRowInfo = Object.assign({}, record) + console.log('currentRightClickedTableRowInfo', this.currentRightClickedTableRowInfo) this.$refs.tableContextMenuRef.currentMenuLevel = record.param this.$refs.tableContextMenuRef.menuStyle.top = event.clientY + 'px' this.$refs.tableContextMenuRef.menuStyle.left = event.clientX + 'px' @@ -70,32 +64,324 @@ // 浠庢爲缁勪欢鎺ュ彈鏍戣妭鐐逛俊鎭悗浠庣埗缁勪欢娴佸叆瀛愮粍浠� this.currentTreeNodeInfo = treeNodeInfo // 娓呯┖涓婁竴鑺傜偣宸茬粡鍔犺浇杩囧緱鏂囨。鍒楄〃tabKey - this.hasLoadingDataTabKey = [] - if (treeNodeInfo.type !== 1) { - this.activeTabKey = 1 - this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1)) + if (treeNodeInfo.type === 5 || treeNodeInfo.type === 6) { + this.$nextTick(() => { + if (this.$refs.ncDocumentTableListRef) this.$refs.ncDocumentTableListRef.loadData(1) + }) } else { - this.activeTabKey = 2 - this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1)) - } - this.hasLoadingDataTabKey.push(this.activeTabKey) - }, - - handleTabChange(activeTabKey) { - // tab鍒囨崲鏃跺姞杞藉搴旀枃妗e垪琛紝褰撳墠鏍戣妭鐐逛笅宸茬粡鍔犺浇杩囩殑鏂囨。鍒楄〃涓嶅啀閲嶅鍔犺浇 - if (!this.hasLoadingDataTabKey.includes(activeTabKey)) { - if (activeTabKey === 1) this.$nextTick(() => this.$refs.ncDocumentTableListRef.loadData(1)) - else this.$nextTick(() => this.$refs.otherDocumentTableListRef.loadData(1)) - this.hasLoadingDataTabKey.push(activeTabKey) + this.$nextTick(() => { + if (this.$refs.otherDocumentTableListRef) this.$refs.otherDocumentTableListRef.loadData(1) + }) } }, /** - * 鎺у埗鍙抽敭鑿滃崟鐐瑰嚮鍏抽棴 + * 鏂囨。浠ュ強NC绋嬪簭瀵煎叆/鍑哄簱/鍏ュ簱鎴愬姛鍚庤Е鍙戦噸鏂板姞杞芥枃妗e垪琛� + * @param docClassCode 鏂囨。绫诲埆 + * @param attributionId 鑺傜偣Id */ + reloadDocumentListData({ docClassCode, attributionId }) { + // 濡傛灉涓婁紶鐨勬枃妗d笉鏄墍灞炰簬褰撳墠鎵�灞曠ず鑺傜偣鐨勬枃妗e垯涓嶉噸鏂拌幏鍙栨枃妗e垪琛� + if (this.currentTreeNodeInfo.id !== attributionId) return + if (docClassCode === 'NC') { + 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 && !res.success) { + that.$notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { + that.$notification.error({ + message: '娑堟伅', + description: err.message + }) + }) + }, + + // 鍒犻櫎褰撳墠鍙抽敭閫変腑鏂囨。 + handleDelete() { + const { docId, param, attributionId } = this.currentRightClickedTableRowInfo + const that = this + that.$confirm({ + title: '鎻愮ず', + content: `鍒犻櫎鍚庝笉鍙彇娑堬紝纭鍒犻櫎鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.deleteDocumentApi(docId) + .then((res) => { + if (res.success) { + that.$notification.success({ + message: '娑堟伅', + description: res.message + }) + that.reloadDocumentListData({ docClassCode: param, attributionId }) + } else { + that.$notification.warning({ + message: '娑堟伅', + description: res.message + }) + } + }) + .finally(() => { + that.$destroyAll() + }) + }, + onCancel: () => { + that.$destroyAll() + } + }) + }, + + 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 } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentOutboundApi({ docId, docName }) + .then(res => { + console.log('res------------------', res) + if (res.success) { + that.reloadDocumentListData({ docClassCode: param, attributionId }) + 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() + } + }) + }, + + /** + * 鍙栨秷鍑哄簱褰撳墠鍙抽敭閫変腑鏂囨。 + * @param menuLabel + */ + handleCancelPull(menuLabel) { + const that = this + const { docId, param, attributionId } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentCancelOutboundApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId }) + 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() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, + + /** + * 鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。 + * @param menuLabel + */ + handlePublish(menuLabel) { + const that = this + const { docId, param, attributionId } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentPublishApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId }) + 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: err.message + }) + }) + .finally(() => { + that.$destroyAll() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, + + /** + * 閲嶆柊鍙戝竷褰撳墠鍙抽敭閫変腑鏂囨。骞堕噸鏂板彂甯冮��鍥炰笂涓�鏂囨。鐗堟湰 + * @param menuLabel + */ + handleRepublish(menuLabel) { + const that = this + const { docId, param, attributionId } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentRepublishApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId }) + 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() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, + + /** + * 閲嶅綊妗e綋鍓嶅彸閿�変腑鏂囨。涓斿悗缁棤娉曠户缁彂甯冩垨褰掓。 + * @param menuLabel + */ + handlePigeonhole(menuLabel) { + const that = this + const { docId, param, attributionId } = this.currentRightClickedTableRowInfo + that.$confirm({ + title: '鎻愮ず', + content: `${menuLabel}鍚庝笉鍙彇娑堬紝纭${menuLabel}鍚楋紵`, + okText: '纭', + cancelText: '鍙栨秷', + onOk: () => { + dncApi.documentPigeonholeApi(docId) + .then(res => { + if (res.success) { + this.reloadDocumentListData({ docClassCode: param, attributionId }) + 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() + }) + }, + onCancel() { + that.$destroyAll() + } + }) + }, + + // 鎺у埗鍙抽敭鑿滃崟鍏抽棴 handleMenuClose() { this.$refs.tableContextMenuRef.menuVisible = false document.body.removeEventListener('click', this.handleMenuClose) + }, + + triggerCorrespondingMethod({ methodName, modalTitle }) { + if (this[methodName]) this[methodName](modalTitle) } } } -- Gitblit v1.9.3