diff --git a/src/main/resources/templates/admin/business/process-edit.ftl b/src/main/resources/templates/admin/business/process-edit.ftl index 30ad4c4..4fe93dc 100644 --- a/src/main/resources/templates/admin/business/process-edit.ftl +++ b/src/main/resources/templates/admin/business/process-edit.ftl @@ -204,20 +204,20 @@
- -
-
@@ -261,7 +261,7 @@ @@ -277,7 +277,7 @@ @@ -292,32 +292,33 @@ + + + + + style="float: right;margin: 10px 10px 0 0"> - + 返回上一级 保存草稿 提交 @@ -381,7 +382,7 @@ + + + + + style="float: right;margin: 10px 10px 0 0"> @@ -624,6 +630,29 @@ return !isBlank(obj) } + const hasProperties = obj => { + return isNotEmpty(Object.keys(obj)); + } + + const isEmptyObject = obj => { + return isEmpty(Object.keys(obj)); + } + + function checkStatus(response) { + if (response.status >= 200 && response.status < 300) { + return response + } + else { + const error = new Error(response.statusText); + error.response = response + throw error + } + } + + function parseJSON(response) { + return response.json() + } + const data = () => { return { mode: "btn", // btn , procurementContractProcess @@ -641,7 +670,7 @@ processType: "", procurementProjectSelectorVisible: false, procurementDetailSelectorVisible: false, - procurementDetailsRowKey: 0, + rowKeyCounter: 0, } } @@ -867,7 +896,7 @@ rowKey: rowKey++, children: [] })) - this.procurementDetailsRowKey = rowKey + this.rowKeyCounter = rowKey }) .catch(err => { @@ -938,19 +967,22 @@ || procurementMode === 'competitive_evaluation') { if (isEmpty(this.supplierMaterialsForm)) { - this.$message.error("供应商比选材料未填写") + this.$message.error("供应商比选材料未填写,请检查表单") return false } + + let idx = 0 for (const item in this.supplierMaterialsForm) { - if (isEmpty(Object.keys(item))) { - this.$message.error("供应商比选材料未填写") + idx++ + if (isEmptyObject(item)) { + this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单") return false } for (const [key, value] of Object.entries(item)) { if (value) { if (typeof value === 'string') { if (isBlank(value)) { - this.$message.error("有未填写的表单,请检查表单"); + this.$message.error("供应商比选材料第'" + idx + "'行有数据未填写,请检查表单") return false } } @@ -958,7 +990,7 @@ else { // 没有值 if (key !== 'remark') { - this.$message.error("有未填写的表单,请检查表单"); + this.$message.error("供应商比选材料第'" + idx + "'行有数据未填写,请检查表单") } } } @@ -1000,7 +1032,6 @@ budgetCostIdMap.set(detail.budgetCostId, detail) }) - debugger const computePurchaseAmountDetail = budgetCostId => { const detail = budgetCostIdMap.get(budgetCostId) const ret = [] @@ -1019,16 +1050,14 @@ return ret } - const applyDeptId = processForm.applyDeptId?.join(',') // (逗号分割) const form = { ...processForm, processType, - applyDeptId, + applyDeptId: processForm.applyDeptId?.join(','),// (逗号分割), attachments: fileList.map(file => ({ uri: file.response.data.url, name: file.response.data.originName })), - supplierMaterials: this.supplierMaterialsForm, incomeDetails: this.incomeDetails.map(detail => ({ id: detail.id, expirationDate: detail.expirationDate })), @@ -1038,7 +1067,8 @@ amountAlready: detail.amountAlready, amountCurrent: detail.amountCurrent, details: computePurchaseAmountDetail(detail.budgetCostId) - })) + })), + supplierMaterials: this.supplierMaterialsForm.filter(hasProperties), // 剔除空行 } fetch("${base}/process", { @@ -1047,19 +1077,25 @@ 'Content-Type': 'application/json', }, body: JSON.stringify(form), - }).then(response => { - if (response.ok) { - this.$message({ - showClose: true, - message: '提交成功', - type: 'success' - }) + }).then(checkStatus).then(data => { + this.$message({ + showClose: true, + message: processForm.status === 'draft' ? '草稿保存成功' : "提交成功", + type: 'success' + }) + }).catch(({ response }) => { + const defaultMessage = () => { + return processForm.status === 'draft' ? '草稿保存失败' : "项目提交失败" + } + if (response) { + parseJSON(response) + .then(json => { + this.$message.error(json.message || defaultMessage()) + }) } else { - return Promise.reject("失败") + this.$message.error(defaultMessage()) } - }).catch(err => { - this.$message.error("项目提交失败"); }).finally(() => loading.close()) }, @@ -1101,12 +1137,38 @@ } }, + handleSupplierMaterialRemove(scope, fileList) { + scope.row['fileList'] = fileList + }, + + handleSupplierMaterialExceed(scope, files, fileList) { + this.$message.warning("当前限制选择只能选择10个文件"); + scope.row['fileList'] = fileList + }, + + beforeSupplierMaterialRemove(scope, file, fileList) { + return this.$confirm("确定移除 " + file.name + "?"); + }, + + handleSupplierMaterialFileUploaded(scope, response, file, fileList) { + if (response.success) { + scope.row['fileList'] = fileList + + this.fileListSupplierMaterial = fileList + } + else { + this.$message.warning("上传失败"); + } + }, + indexMethod(index) { return index * 1; }, addSupplierRow() { - this.supplierMaterialsForm.push({}) + this.supplierMaterialsForm.push({ + rowKey: this.rowKeyCounter++, + }) }, addProcurementDetailRow(scope) { @@ -1114,7 +1176,7 @@ const { children } = row const newRow = { ...row, - rowKey: this.procurementDetailsRowKey++, + rowKey: this.rowKeyCounter++, newRow: true, parent: row // 记录上一级元素,在删除的时候使用 } @@ -1131,8 +1193,8 @@ }, removeProcurementDetailRow(scope) { - const { rowKey, parent } = scope.row - parent.children = parent.children.filter(child => child.rowKey !== rowKey) + const { rowKey } = scope.row + .filter(child => child.rowKey !== rowKey) }, // 区别子项 @@ -1144,6 +1206,11 @@ return ''; }, + removeSupplierMaterialRow(scope) { + const { rowKey } = scope.row + this.supplierMaterialsForm = this.supplierMaterialsForm.filter(child => child.rowKey !== rowKey) + }, + applyDeptSelected(value) { if (value.length === 0) { this.processForm['applyDept'] = null