采购合同编辑界面
parent
d8e2dc63dc
commit
d20af67b42
|
@ -392,7 +392,7 @@
|
||||||
|
|
||||||
<el-table-column prop="amountLeft" label="未采购数量" width="100">
|
<el-table-column prop="amountLeft" label="未采购数量" width="100">
|
||||||
<template slot-scope="scope">
|
<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>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
@ -526,6 +526,10 @@
|
||||||
return response.json()
|
return response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const hasProperties = obj => {
|
||||||
|
return isNotEmpty(Object.keys(obj));
|
||||||
|
}
|
||||||
|
|
||||||
const data = () => {
|
const data = () => {
|
||||||
return {
|
return {
|
||||||
mode: "btn", // btn
|
mode: "btn", // btn
|
||||||
|
@ -542,7 +546,6 @@
|
||||||
supplierMaterialsForm: [],
|
supplierMaterialsForm: [],
|
||||||
rowKeyCounter: 0,
|
rowKeyCounter: 0,
|
||||||
procurementDetails: [],
|
procurementDetails: [],
|
||||||
filteredProcurementDetails: [],
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,10 +669,23 @@
|
||||||
name: item.name, url: item.uri
|
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 => ({
|
this.supplierMaterialsForm = supplierMaterials && supplierMaterials.map(material => ({
|
||||||
...material, attachment: material.attachment && JSON.parse(material.attachment).map(item => ({
|
...material, attachment: mapAttachment(material.attachment)
|
||||||
name: item.name, url: item.uri
|
|
||||||
}))
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
let rowKey = 0
|
let rowKey = 0
|
||||||
|
@ -696,7 +712,7 @@
|
||||||
const first = purchaseDetails.shift();
|
const first = purchaseDetails.shift();
|
||||||
// 再处理剩余的子元素
|
// 再处理剩余的子元素
|
||||||
purchaseDetails = purchaseDetails.map(purchase => ({
|
purchaseDetails = purchaseDetails.map(purchase => ({
|
||||||
...purchase, ...convertCommon(detail), parent, newRow: true
|
...purchase, rowKey: rowKey++, parent, newRow: true
|
||||||
}))
|
}))
|
||||||
// 合并第一行到父级
|
// 合并第一行到父级
|
||||||
Object.assign(parent, first)
|
Object.assign(parent, first)
|
||||||
|
@ -721,9 +737,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(({ response }) => {
|
||||||
if (err.response) {
|
if (response) {
|
||||||
parseJSON(err.response)
|
parseJSON(response)
|
||||||
.then(json => {
|
.then(json => {
|
||||||
this.$message.error(json.message || "项目加载失败");
|
this.$message.error(json.message || "项目加载失败");
|
||||||
})
|
})
|
||||||
|
@ -751,9 +767,11 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
submit(needValid) {
|
submit(needValid) {
|
||||||
|
const fileList = this.fileList
|
||||||
const processForm = this.processForm
|
const processForm = this.processForm
|
||||||
const processType = this.processType
|
const processType = this.processType
|
||||||
const fileList = this.fileList
|
const supplierMaterialsForm = this.supplierMaterialsForm
|
||||||
|
|
||||||
let validStatus = !needValid
|
let validStatus = !needValid
|
||||||
if (needValid) {
|
if (needValid) {
|
||||||
// 校验表单
|
// 校验表单
|
||||||
|
@ -784,13 +802,13 @@
|
||||||
if (procurementMode === 'price_comparison'
|
if (procurementMode === 'price_comparison'
|
||||||
|| procurementMode === 'competitive_evaluation') {
|
|| procurementMode === 'competitive_evaluation') {
|
||||||
|
|
||||||
if (isEmpty(this.supplierMaterialsForm)) {
|
if (isEmpty(supplierMaterialsForm)) {
|
||||||
this.$message.error("供应商比选材料未填写,请检查表单")
|
this.$message.error("供应商比选材料未填写,请检查表单")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = 0
|
let idx = 0
|
||||||
for (const item in this.supplierMaterialsForm) {
|
for (const item in supplierMaterialsForm) {
|
||||||
idx++
|
idx++
|
||||||
if (isEmptyObject(item)) {
|
if (isEmptyObject(item)) {
|
||||||
this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单")
|
this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单")
|
||||||
|
@ -837,13 +855,6 @@
|
||||||
return false
|
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()
|
const budgetCostIdMap = new Map()
|
||||||
this.procurementDetails.forEach(detail => {
|
this.procurementDetails.forEach(detail => {
|
||||||
budgetCostIdMap.set(detail.budgetCostId, detail)
|
budgetCostIdMap.set(detail.budgetCostId, detail)
|
||||||
|
@ -853,7 +864,7 @@
|
||||||
const detail = budgetCostIdMap.get(budgetCostId)
|
const detail = budgetCostIdMap.get(budgetCostId)
|
||||||
const ret = []
|
const ret = []
|
||||||
const map = detail => {
|
const map = detail => {
|
||||||
const ret = {}
|
const ret = { id: detail.id }
|
||||||
procurementDetailProperties.forEach(property => {
|
procurementDetailProperties.forEach(property => {
|
||||||
ret[property] = detail[property]
|
ret[property] = detail[property]
|
||||||
})
|
})
|
||||||
|
@ -867,6 +878,13 @@
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapAttachment = attachments => {
|
||||||
|
return attachments && JSON.stringify(attachments.map(file => ({
|
||||||
|
uri: file.response.data.url,
|
||||||
|
name: file.response.data.originName
|
||||||
|
})))
|
||||||
|
}
|
||||||
|
|
||||||
const form = {
|
const form = {
|
||||||
...processForm,
|
...processForm,
|
||||||
processType,
|
processType,
|
||||||
|
@ -880,17 +898,27 @@
|
||||||
incomeDetails: this.incomeDetails.map(detail => ({
|
incomeDetails: this.incomeDetails.map(detail => ({
|
||||||
id: detail.id, expirationDate: detail.expirationDate
|
id: detail.id, expirationDate: detail.expirationDate
|
||||||
})),
|
})),
|
||||||
purchaseAmount: this.filteredProcurementDetails.map(detail => ({
|
purchaseAmount: this.procurementDetails.map(detail => ({
|
||||||
amount: detail.amount,
|
amount: detail.amount,
|
||||||
|
amountId: detail.amountId,
|
||||||
budgetCostId: detail.budgetCostId,
|
budgetCostId: detail.budgetCostId,
|
||||||
amountAlready: detail.amountAlready,
|
amountAlready: detail.amountAlready,
|
||||||
amountCurrent: detail.amountCurrent,
|
amountCurrent: detail.amountCurrent,
|
||||||
details: computePurchaseAmountDetail(detail.budgetCostId)
|
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',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
|
|
|
@ -928,9 +928,10 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
async submit(needValid) {
|
async submit(needValid) {
|
||||||
|
const fileList = this.fileList
|
||||||
const processForm = this.processForm
|
const processForm = this.processForm
|
||||||
const processType = this.processType
|
const processType = this.processType
|
||||||
const fileList = this.fileList
|
const supplierMaterialsForm = this.supplierMaterialsForm
|
||||||
|
|
||||||
if (!processForm.projectId) {
|
if (!processForm.projectId) {
|
||||||
this.$message.error("未选择项目");
|
this.$message.error("未选择项目");
|
||||||
|
@ -966,13 +967,13 @@
|
||||||
if (procurementMode === 'price_comparison'
|
if (procurementMode === 'price_comparison'
|
||||||
|| procurementMode === 'competitive_evaluation') {
|
|| procurementMode === 'competitive_evaluation') {
|
||||||
|
|
||||||
if (isEmpty(this.supplierMaterialsForm)) {
|
if (isEmpty(supplierMaterialsForm)) {
|
||||||
this.$message.error("供应商比选材料未填写,请检查表单")
|
this.$message.error("供应商比选材料未填写,请检查表单")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
let idx = 0
|
let idx = 0
|
||||||
for (const item in this.supplierMaterialsForm) {
|
for (const item in supplierMaterialsForm) {
|
||||||
idx++
|
idx++
|
||||||
if (isEmptyObject(item)) {
|
if (isEmptyObject(item)) {
|
||||||
this.$message.error("供应商比选材料第'" + idx + "'行未填写,请检查表单")
|
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()
|
const budgetCostIdMap = new Map()
|
||||||
this.procurementDetails.forEach(detail => {
|
this.procurementDetails.forEach(detail => {
|
||||||
budgetCostIdMap.set(detail.budgetCostId, detail)
|
budgetCostIdMap.set(detail.budgetCostId, detail)
|
||||||
|
@ -1050,6 +1044,12 @@
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const mapAttachment = attachments => {
|
||||||
|
return attachments && JSON.stringify(attachments.map(file => ({
|
||||||
|
uri: file.response.data.url,
|
||||||
|
name: file.response.data.originName
|
||||||
|
})))
|
||||||
|
}
|
||||||
const form = {
|
const form = {
|
||||||
...processForm,
|
...processForm,
|
||||||
processType,
|
processType,
|
||||||
|
@ -1068,8 +1068,17 @@
|
||||||
amountCurrent: detail.amountCurrent,
|
amountCurrent: detail.amountCurrent,
|
||||||
details: computePurchaseAmountDetail(detail.budgetCostId)
|
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", {
|
fetch("${base}/process", {
|
||||||
method: 'POST', // or 'PUT'
|
method: 'POST', // or 'PUT'
|
||||||
|
|
Loading…
Reference in New Issue