From 8fbfac872e852a0ad0dbe04f2b7b69e4cff3c85c Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期三, 19 三月 2025 11:26:24 +0800 Subject: [PATCH] 1、MDC零件加工管理和OEE页面开发100% 2、DNC结构树取消搜索框侧边下拉菜单改为树组件空白处右键菜单 --- src/views/dnc/common/ImportFileModal.vue | 362 +++++++++++++++++++++++++-------------------------- 1 files changed, 180 insertions(+), 182 deletions(-) diff --git a/src/views/dnc/common/ImportFileModal.vue b/src/views/dnc/common/ImportFileModal.vue index 250c3b4..10be07c 100644 --- a/src/views/dnc/common/ImportFileModal.vue +++ b/src/views/dnc/common/ImportFileModal.vue @@ -7,7 +7,7 @@ </a-button> </a-upload> - <div style="margin-top: 16px">宸查�夋嫨{{fileList.length}}涓枃浠�</div> + <div style="margin-top: 16px">宸查�夋嫨{{ fileList.length }}涓枃浠�</div> <template slot="footer"> <a-button @click="handleModalClose">鍙栨秷</a-button> @@ -26,197 +26,195 @@ </template> <script> - import dncApi from '@/api/dnc' +import dncApi from '@/api/dnc' - export default { - name: 'ImportFileModal', - components: {}, - data() { - return { - visible: false, - title: '', - fileList: [], - uploadParams: {}, - uploading: false, - isUploadMultiple: true, - currentDeviceDocClassCode: 'SEND', - currentTitleAfterClass: '' +export default { + name: 'ImportFileModal', + components: {}, + data() { + return { + visible: false, + title: '', + fileList: [], + uploadParams: {}, + uploading: false, + isUploadMultiple: true, + currentDeviceDocClassCode: 'SEND', + currentTitleAfterClass: '' + } + }, + created() { + this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) + this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) + }, + methods: { + /** + * 鐐瑰嚮瀵煎叆鏂囨。鎴朜C绋嬪簭鏃惰Е鍙� + * @param treeNodeInfo 鐐瑰嚮鏍戣妭鐐瑰彸閿彍鍗曞鍏ョ▼搴忔椂浼犲叆鏍戣妭鐐逛俊鎭� + * @param tableRowInfo 鍙抽敭琛ㄦ牸琛屾椂浼犲叆琛屼俊鎭� + * @param modalTitle 寮圭獥鏍囬 + */ + handleImport(treeNodeInfo, tableRowInfo, modalTitle) { + this.isUploadMultiple = true + let attributionId // 鏂囨。鎵�灞炲眰绾d + let attributionType // 鏂囨。鎵�灞炲眰绾х被鍨� + let docClassCode // 鏂囨。绫诲瀷 + if (treeNodeInfo) { + attributionId = treeNodeInfo.treeKey + attributionType = treeNodeInfo.type + docClassCode = treeNodeInfo.param + } else { + // 鑻ュ伐搴忓強宸ユ灞傜骇涓嬫湁璁惧绫绘椂鍒欏鍏C鐨勫弬鏁伴渶瑕佽皟鏁� + attributionId = tableRowInfo.param === 'deviceCustomType' ? tableRowInfo.id : tableRowInfo.attributionId + attributionType = tableRowInfo.attributionType + docClassCode = tableRowInfo.param === 'deviceCustomType' ? 'NC' : tableRowInfo.param + } + this.setModalTitle(modalTitle, docClassCode) + this.uploadParams = Object.assign({}, { attributionId, attributionType, docClassCode }) + console.log('uploadParams=====================', this.uploadParams) + this.visible = true + }, + + /** + * 鐐瑰嚮鏂囨。鐢熷懡鍛ㄦ湡鐨勫叆搴撴椂瑙﹀彂 + * @param _ + * @param tableRowInfo 鍙抽敭琛ㄦ牸琛屾椂浼犲叆琛屼俊鎭� + */ + handlePush(_, tableRowInfo) { + this.isUploadMultiple = false + const { docId, attributionId, attributionType, param } = tableRowInfo + this.uploadParams = Object.assign({}, { + docId, + attributionId, + attributionType, + docClassCode: param + }) + this.visible = true + }, + + /** + * 閫夋嫨濂芥枃浠剁偣鍑荤‘瀹氬悗 + * @param file 鏂囦欢瀵硅薄 + */ + beforeUpload(file) { + if (this.isUploadMultiple) { + if (!this.fileList.find(item => item.name === file.name)) this.fileList = [...this.fileList, file] + } else this.fileList.splice(0, 1, file) + return false + }, + + // 鐐瑰嚮涓婁紶鑷虫湇鍔″櫒鎸夐挳鏃惰Е鍙� + handleUpload() { + const { fileList, $notification, isUploadMultiple, uploadParams, $bus, handleModalClose } = this + this.uploading = true + let uploadedFileCount = 0 + let uploadSuccessFileCount = 0 + let apiMethod,params + + fileList.forEach((file, index) => { + const formData = new FormData() + formData.append('file', file) + file.status = 'uploading' + // 鐩墠鏍规嵁鏄惁涓婁紶澶氫釜鏂囦欢鍒ゆ柇涓や釜鍔熻兘锛岃嫢鍚庣画澧炲姞鍔熻兘鎴栬皟鏁撮渶姹傚垯璋冩暣鍒ゆ柇鏉′欢 + if (isUploadMultiple) { + apiMethod = dncApi.importDocumentFromLocalApi + params = Object.assign({}, { params: uploadParams, formData }) + } else { + apiMethod = dncApi.documentVersionUpdateApi + params = Object.assign({}, { docId: uploadParams.docId, formData }) + } + apiMethod(params) + .then(res => { + if (res.success) { + file.status = 'done' + uploadSuccessFileCount++ + $notification.success({ + message: '娑堟伅', + description: res.message + }) + } else { + file.status = 'error' + $notification.error({ + message: '娑堟伅', + description: res.message + }) + } + }) + .catch(err => { + file.status = 'error' + }) + .finally(() => { + uploadedFileCount++ + fileList.splice(index, 1, file) + // 褰撴枃浠跺叏閮ㄤ笂浼犲畬鎴愬悗 + if (uploadedFileCount === fileList.length) { + // 鑷冲皯鏈変竴涓枃浠朵笂浼犳垚鍔熷悗灏遍渶瑕侀噸鏂板姞杞芥枃妗e垪琛� + if (uploadSuccessFileCount > 0) { + $bus.$emit('reloadDocumentListData', uploadParams) + if (!isUploadMultiple) { + $bus.$emit('reloadMainBottomTableData', 'documentVersion') + handleModalClose() //鏃犳硶杩炵画鍏ュ簱澶氫釜鐗堟湰鍥犳鍏ュ簱鎴愬姛鍚庡嵆鍙��鍑虹獥鍙� + } + } + this.uploading = false + } + }) + }) + }, + + /** + * 鍒犻櫎鏂囦欢鍒楄〃椤规椂瑙﹀彂 + * @param file 鏂囦欢瀵硅薄 + */ + handleRemove(file) { + const index = this.fileList.indexOf(file) + const newFileList = this.fileList.slice() + newFileList.splice(index, 1) + this.fileList = newFileList + }, + + // 鎺у埗鏂囦欢涓婁紶绐楀彛鍏抽棴骞舵竻绌烘枃浠跺垪琛� + handleModalClose() { + this.visible = false + this.fileList = [] + }, + + /** + * 璁剧疆寮圭獥鏍囬 + * @param modalTitle 寮圭獥鏍囬 + * @param docClassCode 鏂囨。绫诲瀷 + */ + setModalTitle(modalTitle, docClassCode) { + switch (docClassCode) { + case 'SEND': + this.title = modalTitle + '锛堝彂閫侊級' + break + case 'REC': + this.title = modalTitle + '锛堟帴鏀讹級' + break } }, - created() { - this.$bus.$on('treeMenuItemMethodTrigger', this.triggerCorrespondingMethod) - this.$bus.$on('tableMenuItemMethodTrigger', this.triggerCorrespondingMethod) - }, - methods: { - /** - * 鐐瑰嚮瀵煎叆鏂囨。鎴朜C绋嬪簭鏃惰Е鍙� - * @param treeNodeInfo 鐐瑰嚮鏍戣妭鐐瑰彸閿彍鍗曞鍏ョ▼搴忔椂浼犲叆鏍戣妭鐐逛俊鎭� - * @param tableRowInfo 鍙抽敭琛ㄦ牸琛屾椂浼犲叆琛屼俊鎭� - * @param modalTitle 寮圭獥鏍囬 - */ - handleImport(treeNodeInfo, tableRowInfo, modalTitle) { - this.isUploadMultiple = true - let attributionId // 鏂囨。鎵�灞炲眰绾d - let attributionType // 鏂囨。鎵�灞炲眰绾х被鍨� - let docClassCode // 鏂囨。绫诲瀷 - if (treeNodeInfo) { - attributionId = treeNodeInfo.treeKey - attributionType = treeNodeInfo.type - docClassCode = treeNodeInfo.param - } else { - // 鑻ュ伐搴忓強宸ユ灞傜骇涓嬫湁璁惧绫绘椂鍒欏鍏C鐨勫弬鏁伴渶瑕佽皟鏁� - attributionId = tableRowInfo.param==='deviceCustomType'?tableRowInfo.id:tableRowInfo.attributionId - attributionType = tableRowInfo.attributionType - docClassCode = tableRowInfo.param==='deviceCustomType'?'NC':tableRowInfo.param - } - this.setModalTitle(modalTitle, docClassCode) - this.uploadParams = Object.assign({}, { attributionId, attributionType, docClassCode }) - console.log('uploadParams=====================', this.uploadParams) - this.visible = true - }, - /** - * 鐐瑰嚮鏂囨。鐢熷懡鍛ㄦ湡鐨勫叆搴撴椂瑙﹀彂 - * @param _ - * @param tableRowInfo 鍙抽敭琛ㄦ牸琛屾椂浼犲叆琛屼俊鎭� - */ - handlePush(_, tableRowInfo) { - this.isUploadMultiple = false - console.log('tableRowInfo', tableRowInfo) - this.uploadParams = Object.assign({}, { - docId: tableRowInfo.docId, - attributionId: tableRowInfo.attributionId, - docClassCode: tableRowInfo.param - }) - this.visible = true - }, - - /** - * 閫夋嫨濂芥枃浠剁偣鍑荤‘瀹氬悗 - * @param file 鏂囦欢瀵硅薄 - */ - beforeUpload(file) { - if (this.isUploadMultiple) { - if (!this.fileList.find(item => item.name === file.name)) this.fileList = [...this.fileList, file] - } - else this.fileList.splice(0, 1, file) - return false - }, - - // 鐐瑰嚮涓婁紶鑷虫湇鍔″櫒鎸夐挳鏃惰Е鍙� - handleUpload() { - const { fileList, $notification, isUploadMultiple, uploadParams, $bus, handleModalClose } = this - this.uploading = true - let uploadedFileCount = 0 - let uploadSuccessFileCount = 0 - let apiMethod - let params - - fileList.forEach((file, index) => { - const formData = new FormData() - formData.append('file', file) - file.status = 'uploading' - // 鐩墠鏍规嵁鏄惁涓婁紶澶氫釜鏂囦欢鍒ゆ柇涓や釜鍔熻兘锛岃嫢鍚庣画澧炲姞鍔熻兘鎴栬皟鏁撮渶姹傚垯璋冩暣鍒ゆ柇鏉′欢 - if (isUploadMultiple) { - apiMethod = dncApi.importDocumentFromLocalApi - params = Object.assign({}, { params: uploadParams, formData }) - } else { - apiMethod = dncApi.documentVersionUpdateApi - params = Object.assign({}, { docId: uploadParams.docId, formData }) - } - apiMethod(params) - .then(res => { - if (res.success) { - file.status = 'done' - uploadSuccessFileCount++ - console.log('uploadSuccessFileCount++', uploadSuccessFileCount) - $notification.success({ - message: '娑堟伅', - description: res.message - }) - } else { - file.status = 'error' - $notification.error({ - message: '娑堟伅', - description: res.message - }) - } - }) - .catch(err => { - file.status = 'error' - }) - .finally(() => { - uploadedFileCount++ - fileList.splice(index, 1, file) - // 褰撴枃浠跺叏閮ㄤ笂浼犲畬鎴愬悗 - if (uploadedFileCount === fileList.length) { - // 鑷冲皯鏈変竴涓枃浠朵笂浼犳垚鍔熷悗灏遍渶瑕侀噸鏂板姞杞芥枃妗e垪琛� - if (uploadSuccessFileCount > 0) { - $bus.$emit('reloadDocumentListData', uploadParams) - if (!isUploadMultiple) { - $bus.$emit('reloadMainBottomTableData', 'documentVersion') - handleModalClose() //鏃犳硶杩炵画鍏ュ簱澶氫釜鐗堟湰鍥犳鍏ュ簱鎴愬姛鍚庡嵆鍙��鍑虹獥鍙� - } - } - this.uploading = false - } - }) - }) - }, - - /** - * 鍒犻櫎鏂囦欢鍒楄〃椤规椂瑙﹀彂 - * @param file 鏂囦欢瀵硅薄 - */ - handleRemove(file) { - const index = this.fileList.indexOf(file) - const newFileList = this.fileList.slice() - newFileList.splice(index, 1) - this.fileList = newFileList - }, - - // 鎺у埗鏂囦欢涓婁紶绐楀彛鍏抽棴骞舵竻绌烘枃浠跺垪琛� - handleModalClose() { - this.visible = false - this.fileList = [] - }, - - /** - * 璁剧疆寮圭獥鏍囬 - * @param modalTitle 寮圭獥鏍囬 - * @param docClassCode 鏂囨。绫诲瀷 - */ - setModalTitle(modalTitle, docClassCode) { - switch (docClassCode) { - case 'SEND': - this.title = modalTitle + '锛堝彂閫侊級' - break - case 'REC': - this.title = modalTitle + '锛堟帴鏀讹級' - break - } - }, - - triggerCorrespondingMethod({ methodName, modalTitle, treeNodeInfo, tableRowInfo }) { - if (this[methodName]) { - this.title = modalTitle - this[methodName](treeNodeInfo, tableRowInfo, modalTitle) - } + triggerCorrespondingMethod({ methodName, modalTitle, treeNodeInfo, tableRowInfo }) { + if (this[methodName]) { + this.title = modalTitle + this[methodName](treeNodeInfo, tableRowInfo, modalTitle) } } } +} </script> <style scoped lang="less"> - /deep/ .ant-btn-primary#custom-upload-button { - color: #fff; - background-color: #67C23A; - border-color: #67C23A; +/deep/ .ant-btn-primary#custom-upload-button { + color: #fff; + background-color: #67C23A; + border-color: #67C23A; - &[disabled] { - color: rgba(0, 0, 0, 0.25); - background-color: #f5f5f5; - border-color: #d9d9d9; - } + &[disabled] { + color: rgba(0, 0, 0, 0.25); + background-color: #f5f5f5; + border-color: #d9d9d9; } +} </style> \ No newline at end of file -- Gitblit v1.9.3