| | |
| | | /** |
| | | * 点击导入文档或NC程序时触发 |
| | | * @param treeNodeInfo 点击树节点右键菜单导入程序时传入树节点信息 |
| | | * @param tableRowInfo 点击表格行右键菜单导入程序时传入行信息 |
| | | * @param tableRowInfo 右键表格行时传入行信息 |
| | | */ |
| | | handleImport(treeNodeInfo, tableRowInfo) { |
| | | this.isUploadMultiple = true |
| | |
| | | this.visible = true |
| | | }, |
| | | |
| | | /** |
| | | * 点击文档生命周期的入库时触发 |
| | | * @param _ |
| | | * @param tableRowInfo 右键表格行时传入行信息 |
| | | */ |
| | | handlePush(_, tableRowInfo) { |
| | | this.isUploadMultiple = false |
| | | console.log('tableRowInfo', tableRowInfo) |
| | | this.uploadParams = Object.assign({}, { |
| | | id: tableRowInfo.docId, |
| | | docId: tableRowInfo.docId, |
| | | attributionId: tableRowInfo.attributionId, |
| | | docClassCode: tableRowInfo.param |
| | | }) |
| | | this.visible = true |
| | | }, |
| | | |
| | | handleRemove(file) { |
| | | const index = this.fileList.indexOf(file) |
| | | const newFileList = this.fileList.slice() |
| | | newFileList.splice(index, 1) |
| | | this.fileList = newFileList |
| | | }, |
| | | |
| | | /** |
| | | * 选择好文件点击确定后 |
| | | * @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) |
| | | } |
| | | else this.fileList.splice(0, 1, file) |
| | | return false |
| | | }, |
| | | |
| | | /** |
| | | * 点击上传至服务器按钮时触发 |
| | | */ |
| | | handleUpload() { |
| | | const { fileList, $notification, isUploadMultiple, uploadParams, $bus } = this |
| | | const { fileList, $notification, isUploadMultiple, uploadParams, $bus, handleModalClose } = this |
| | | this.uploading = true |
| | | let uploadedFileCount = 0 |
| | | let uploadSuccessFileCount = 0 |
| | |
| | | params = Object.assign({}, { params: uploadParams, formData }) |
| | | } else { |
| | | apiMethod = dncApi.documentVersionUpdateApi |
| | | params = Object.assign({}, { id: uploadParams.id, formData }) |
| | | params = Object.assign({}, { docId: uploadParams.docId, formData }) |
| | | } |
| | | apiMethod(params) |
| | | .then(res => { |
| | |
| | | if (uploadedFileCount === fileList.length) { |
| | | // 至少有一个文件上传成功后就需要重新加载文档列表 |
| | | if (uploadSuccessFileCount > 0) { |
| | | $bus.$emit('importFileSuccess', uploadParams) |
| | | if (!isUploadMultiple) this.visible = false //无法连续入库多个版本因此入库成功后即可退出窗口 |
| | | $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() { |