diff --git a/src/api/oss/oss.js b/src/api/oss/oss.js index 8d241e9..d85144e 100644 --- a/src/api/oss/oss.js +++ b/src/api/oss/oss.js @@ -32,3 +32,7 @@ export const queryOssFilePlus = data => createAPI(`/oss/queryOssFilePlus`,'post' export const queryTaskFiles = data => createAPI('/oss/queryTaskFiles', 'post', data) +//下载附件 +export const downLoadObjectFile = data => createAPI(`/sys/oss/downLoadObjectFile?id=`+data.id,'post',777) + + diff --git a/src/views/modules/srmPart/partInfoList.vue b/src/views/modules/srmPart/partInfoList.vue index 94d93aa..f9cb810 100644 --- a/src/views/modules/srmPart/partInfoList.vue +++ b/src/views/modules/srmPart/partInfoList.vue @@ -819,6 +819,7 @@ export default { orderRef1: this.currentRow.site, orderRef2: this.currentRow.partNo, orderRef3: this.currentRow.partDesc, + orderReftype: 'part', height: Number(this.height) - 20 } this.$refs.attachments.init(inData) diff --git a/src/views/modules/supplier/purHeaderList.vue b/src/views/modules/supplier/purHeaderList.vue index 1f43830..75f8f49 100644 --- a/src/views/modules/supplier/purHeaderList.vue +++ b/src/views/modules/supplier/purHeaderList.vue @@ -30,6 +30,7 @@ @@ -68,8 +69,6 @@
物料明细列表 新增物料 - -
编辑 删除 + 附件
@@ -263,7 +263,111 @@ - + + +
+ + + + + Upload + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
Drag files here, or click to upload
+
+
+
+ + + + + +
+
+ + Confirm + Close + +
+ + +
@@ -279,13 +383,20 @@ import { searchMaterialList, createMaterial, updateMaterial, - deleteMaterial + deleteMaterial, + updatePurDetailStatus } from '@/api/supplier/purQuotation.js' import { getSupplierInfo } from '@/api/srm/srmSupplier.js' +import { + ossUploadNoSaveOSSForYJY, + queryOssFilePlus, + removeOss, + downLoadObjectFile +} from "../../../api/oss/oss"; export default { components: { @@ -352,6 +463,24 @@ export default { remark2: '', status: '待提交' }, + searchParams: { + orderRef1: '', + orderRef2: '', + orderRef3: '', + orderReftype: '' + }, + fileList: [], + fileList2: [], + ossVisible: false, + ossForm: { + remark: '', + }, + uploadLoading: false, + // staged files selected in upload dialog but not yet persisted + stagedFiles: [], + stagedFileRemark: '', + uploadDialogTitle: '上传附件', + uploadDialogVisible: false, tagNo: null, tagNo1: null } @@ -583,6 +712,26 @@ export default { }) }).catch(() => {}) }, + updateQuoDetail(row) { + this.$confirm('确定提交询价单: ' + row.orderNo + ' ?', '提示', { type: 'warning' }).then(() => { + updatePurDetailStatus({ + orderNo: row.orderNo, + site: row.site, + status : "待报价", + submitFlag : "Y" + }).then(({data}) => { + if (data && data.code === 0) { + this.$message.success('提交成功') + this.getList() + } else { + this.$message.error((data && data.msg) || '提交失败') + } + }).catch(err => { + this.$message.error('提交失败: ' + err.message) + }) + }).catch(() => {}) + }, + // 物料操作 openMaterialDialog(row) { if (!this.currentInquiry) { @@ -660,6 +809,231 @@ export default { this.$message.error('删除失败: ' + err.message) }) }).catch(() => {}) + }, + + openUploadDialog(row) { + if (!row) { + this.$message.warning('请先选择一个物料') + return + } + if (row) { + this.uploadDialogTitle = '上传附件' + this.searchParams = { + orderRef1: this.$store.state.user.site, + orderRef2: row.partNo, + orderRef3: row.partDesc, + orderReftype: 'purQuotationDetail' + } + + } + this.uploadDialogVisible = true + this.searchTable() + }, + // 关闭弹窗 + handleClose() { + this.$emit('update:visible', false); + this.$emit('close'); + }, + + // 关闭上传弹窗 + handleUploadClose() { + this.fileList2 = []; + this.ossForm.remark = ''; + }, + + // 查询文件列表 + searchTable() { + queryOssFilePlus(this.searchParams).then(({ data }) => { + if (data && data.code == 0) { + this.fileList = data.rows || []; + } else { + this.fileList = []; + } + }).catch(() => { + this.fileList = []; + }); + }, + + // 打开上传弹窗 + handleUpload() { + this.$nextTick(() => { + if (this.$refs.upload) { + this.$refs.upload.clearFiles(); + } + }) + this.fileList2 = []; + this.ossForm.remark = ''; + this.ossVisible = true; + }, + + onRemoveFile(file, fileList) { + this.fileList2 = fileList; + }, + + onChangeFile(file, fileList) { + this.fileList2 = fileList; + }, + + // 提交上传 + submitData() { + if (this.fileList2.length === 0) { + this.$message.error('请选择文件'); + return; + } + + this.stagedFileRemark = this.ossForm.remark || ''; + this.uploadLoading = true; + + // 准备要上传的文件 + const stagedFiles = []; + for (let i = 0; i < this.fileList2.length; i++) { + stagedFiles.push(this.fileList2[i].raw); + } + + // 立即关闭弹窗 + this.ossVisible = false; + this.fileList2 = []; + this.ossForm.remark = ''; + + // 上传文件 + const formData = new FormData(); + for (let i = 0; i < stagedFiles.length; i++) { + formData.append('file', stagedFiles[i]); + } + formData.append('orderRef1', this.searchParams.orderRef1 || ''); + formData.append('orderRef2', this.searchParams.orderRef2 || ''); + formData.append('orderRef3', this.searchParams.orderRef3 || ''); + formData.append('createdBy', this.$store.state.user.name); + formData.append('fileRemark', this.stagedFileRemark || ''); + formData.append('orderReftype', this.searchParams.orderReftype || 'purQuotationDetail'); + + ossUploadNoSaveOSSForYJY(formData) + .then(({ data }) => { + if (data && data.code === 0) { + // 移除临时文件,添加上传成功的文件 + this.fileList = this.fileList.filter(f => !f._staged); + for (let i = 0; i < data.rows.length; i++) { + this.fileList.push(data.rows[i]); + } + + // 清除暂存数据 + this.stagedFiles = []; + this.stagedFileRemark = ''; + this.uploadLoading = false; + + this.$message.success('上传成功'); + this.$emit('upload-success', data.rows); + } else { + this.uploadLoading = false; + this.$message.warning(data.msg || '文件上传失败'); + } + }) + .catch(err => { + this.uploadLoading = false; + this.$message.error(err.message || err); + }); + }, + + // 下载/预览文件 + handleDownload(row) { + let image = ['jpg', 'jpeg', 'png', 'gif', 'bmp']; + let video = ['mp4', 'avi', 'mov', 'wmv', 'flv']; + let office = ['doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']; + let txt = ['txt']; + let pdf = ['pdf']; + let type = ''; + + if (image.includes(row.fileType.toLowerCase())) { + type = 'image/' + row.fileType; + downLoadObjectFile(row).then(({ data }) => { + const blob = new Blob([data], { type: type }); + const fileURL = URL.createObjectURL(blob); + window.open(fileURL, '_blank'); + }); + } else if (video.includes(row.fileType.toLowerCase())) { + type = 'video/' + row.fileType; + downLoadObjectFile(row).then(({ data }) => { + const blob = new Blob([data], { type: type }); + const fileURL = URL.createObjectURL(blob); + window.open(fileURL, '_blank'); + }); + } else if (txt.includes(row.fileType.toLowerCase())) { + type = 'text/plain'; + downLoadObjectFile(row).then(({ data }) => { + const blob = new Blob([data], { type: type }); + const fileURL = URL.createObjectURL(blob); + window.open(fileURL, '_blank'); + }); + } else if (office.includes(row.fileType.toLowerCase())) { + if (row.fileType.toLowerCase() === 'doc' || row.fileType.toLowerCase() === 'docx') { + type = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'; + } else if (row.fileType.toLowerCase() === 'ppt' || row.fileType.toLowerCase() === 'pptx') { + type = 'application/vnd.openxmlformats-officedocument.presentationml.presentation'; + } else { + type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; + } + downLoadObjectFile(row).then(({ data }) => { + const blob = new Blob([data], { type: 'application/octet-stream;charset=utf-8' }); + const fileName = row.fileName; + const linkNode = document.createElement('a'); + linkNode.download = fileName; + linkNode.style.display = 'none'; + linkNode.href = URL.createObjectURL(blob); + document.body.appendChild(linkNode); + linkNode.click(); + URL.revokeObjectURL(linkNode.href); + document.body.removeChild(linkNode); + }); + } else if (pdf.includes(row.fileType.toLowerCase())) { + type = 'application/pdf'; + downLoadObjectFile(row).then(({ data }) => { + const blob = new Blob([data], { type: type }); + const fileURL = URL.createObjectURL(blob); + window.open(fileURL, '_blank'); + }); + } else { + this.$message({ + message: '不支持的文件类型', + type: 'warning' + }); + } + }, + + // 删除已保存的文件 + deleteFileReal(row) { + if (!row || !row.id) return; + this.$confirm('确定要删除该文件吗?', '删除确认', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + removeOss([row.id]).then(({ data }) => { + if (data && data.code === 0) { + const idx = this.fileList.findIndex(f => f.id === row.id); + if (idx !== -1) this.fileList.splice(idx, 1); + this.$message.success(data.msg || '文件已删除'); + this.$emit('delete-success', row); + } else { + this.$message.warning(data.msg || '删除失败'); + } + }).catch(err => { + this.$message.error('删除失败:' + (err.message || err)); + }); + }).catch(() => { }); + }, + + // 删除临时文件 + deleteFile(index) { + const f = this.fileList[index]; + if (f && f._staged && f.raw) { + const idx = this.stagedFiles.findIndex(sf => sf.name === f.raw.name && sf.size === f.raw.size); + if (idx !== -1) this.stagedFiles.splice(idx, 1); + } + this.fileList.splice(index, 1); + }, + // 刷新列表 + refresh() { + this.searchTable(); } } } @@ -706,4 +1080,9 @@ export default { .dialog-footer { text-align: center; } + +.rq .auto /deep/ .el-form-item__content { + height: auto; + line-height: 1.5; +} \ No newline at end of file