采购合同编辑界面

master
Harry Yang 2023-01-03 00:14:37 +08:00
parent d8e2dc63dc
commit d20af67b42
2 changed files with 71 additions and 34 deletions

View File

@ -392,7 +392,7 @@
<el-table-column prop="amountLeft" label="未采购数量" width="100">
<template slot-scope="scope">
<span>{{scope.row.amount - scope.row.amountAlready}}</span>
<span v-if="scope.row.amount && scope.row.amountAlready">{{scope.row.amount - scope.row.amountAlready}}</span>
</template>
</el-table-column>
@ -526,6 +526,10 @@
return response.json()
}
const hasProperties = obj => {
return isNotEmpty(Object.keys(obj));
}
const data = () => {
return {
mode: "btn", // btn
@ -542,7 +546,6 @@
supplierMaterialsForm: [],
rowKeyCounter: 0,
procurementDetails: [],
filteredProcurementDetails: [],
}
}
@ -666,10 +669,23 @@
name: item.name, url: item.uri
}))
const mapAttachment = attachment => {
if (hasText(attachment)) {
try {
return JSON.parse(attachment).map(item => ({
name: item.name, url: item.uri
}))
} catch (e) {
return []
}
}
else {
return []
}
}
this.supplierMaterialsForm = supplierMaterials && supplierMaterials.map(material => ({
...material, attachment: material.attachment && JSON.parse(material.attachment).map(item => ({
name: item.name, url: item.uri
}))
...material, attachment: mapAttachment(material.attachment)
}))
let rowKey = 0
@ -696,7 +712,7 @@
const first = purchaseDetails.shift();
// 再处理剩余的子元素
purchaseDetails = purchaseDetails.map(purchase => ({
...purchase, ...convertCommon(detail), parent, newRow: true
...purchase, rowKey: rowKey++, parent, newRow: true
}))
// 合并第一行到父级
Object.assign(parent, first)
@ -721,9 +737,9 @@
}
})
.catch(err => {
if (err.response) {
parseJSON(err.response)
.catch(({ response }) => {
if (response) {
parseJSON(response)
.then(json => {
this.$message.error(json.message || "项目加载失败");
})
@ -751,9 +767,11 @@
},
submit(needValid) {
const fileList = this.fileList
const processForm = this.processForm
const processType = this.processType
const fileList = this.fileList
const supplierMaterialsForm = this.supplierMaterialsForm
let validStatus = !needValid
if (needValid) {
// 校验表单
@ -784,13 +802,13 @@
if (procurementMode === 'price_comparison'
|| procurementMode === 'competitive_evaluation') {
if (isEmpty(this.supplierMaterialsForm)) {
if (isEmpty(supplierMaterialsForm)) {
this.$message.error("供应商比选材料未填写,请检查表单")
return false
}
let idx = 0
for (const item in this.supplierMaterialsForm) {
for (const item in supplierMaterialsForm) {
idx++
if (isEmptyObject(item)) {
this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单")
@ -837,13 +855,6 @@
return false
}
const loading = this.$loading({
lock: true,
text: processForm.status === 'draft' ? '正在保存草稿' : "正在提交",
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const budgetCostIdMap = new Map()
this.procurementDetails.forEach(detail => {
budgetCostIdMap.set(detail.budgetCostId, detail)
@ -853,7 +864,7 @@
const detail = budgetCostIdMap.get(budgetCostId)
const ret = []
const map = detail => {
const ret = {}
const ret = { id: detail.id }
procurementDetailProperties.forEach(property => {
ret[property] = detail[property]
})
@ -867,6 +878,13 @@
return ret
}
const mapAttachment = attachments => {
return attachments && JSON.stringify(attachments.map(file => ({
uri: file.response.data.url,
name: file.response.data.originName
})))
}
const form = {
...processForm,
processType,
@ -880,17 +898,27 @@
incomeDetails: this.incomeDetails.map(detail => ({
id: detail.id, expirationDate: detail.expirationDate
})),
purchaseAmount: this.filteredProcurementDetails.map(detail => ({
purchaseAmount: this.procurementDetails.map(detail => ({
amount: detail.amount,
amountId: detail.amountId,
budgetCostId: detail.budgetCostId,
amountAlready: detail.amountAlready,
amountCurrent: detail.amountCurrent,
details: computePurchaseAmountDetail(detail.budgetCostId)
})),
supplierMaterials: this.supplierMaterialsForm.filter(hasProperties), // 剔除空行
supplierMaterials: supplierMaterialsForm.filter(hasProperties).map(item => ({
...item, attachment: mapAttachment(item.attachment)
})),
}
fetch("${base}/process", {
const loading = this.$loading({
lock: true,
text: processForm.status === 'draft' ? '正在保存草稿' : "正在提交",
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
fetch("${base}/process/" + form.processId, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',

View File

@ -928,9 +928,10 @@
},
async submit(needValid) {
const fileList = this.fileList
const processForm = this.processForm
const processType = this.processType
const fileList = this.fileList
const supplierMaterialsForm = this.supplierMaterialsForm
if (!processForm.projectId) {
this.$message.error("未选择项目");
@ -966,13 +967,13 @@
if (procurementMode === 'price_comparison'
|| procurementMode === 'competitive_evaluation') {
if (isEmpty(this.supplierMaterialsForm)) {
if (isEmpty(supplierMaterialsForm)) {
this.$message.error("供应商比选材料未填写,请检查表单")
return false
}
let idx = 0
for (const item in this.supplierMaterialsForm) {
for (const item in supplierMaterialsForm) {
idx++
if (isEmptyObject(item)) {
this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单")
@ -1020,13 +1021,6 @@
}
// 提交
const loading = this.$loading({
lock: true,
text: processForm.status === 'draft' ? '正在保存草稿' : "正在提交",
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
const budgetCostIdMap = new Map()
this.procurementDetails.forEach(detail => {
budgetCostIdMap.set(detail.budgetCostId, detail)
@ -1050,6 +1044,12 @@
return ret
}
const mapAttachment = attachments => {
return attachments && JSON.stringify(attachments.map(file => ({
uri: file.response.data.url,
name: file.response.data.originName
})))
}
const form = {
...processForm,
processType,
@ -1068,8 +1068,17 @@
amountCurrent: detail.amountCurrent,
details: computePurchaseAmountDetail(detail.budgetCostId)
})),
supplierMaterials: this.supplierMaterialsForm.filter(hasProperties), // 剔除空行
// 剔除空行
supplierMaterials: supplierMaterialsForm.filter(hasProperties).map(item => ({
...item, attachment: mapAttachment(item.attachment)
})),
}
const loading = this.$loading({
lock: true,
text: processForm.status === 'draft' ? '正在保存草稿' : "正在提交",
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
})
fetch("${base}/process", {
method: 'POST', // or 'PUT'