|
@@ -211,6 +211,28 @@ export default {
|
|
|
API.purchaseContractDetail(data).then(
|
|
|
(res) => {
|
|
|
this.form = res.data.data
|
|
|
+ if (this.form.subscriberId) {
|
|
|
+ subscriberDetail({ id: this.form.subscriberId }).then((resDetail) => {
|
|
|
+ if (this.form.purchaseContractProductList && this.form.purchaseContractProductList.length > 0) {
|
|
|
+ this.form.purchaseContractProductList = this.form.purchaseContractProductList.map((item) => {
|
|
|
+ let quantity = 0
|
|
|
+ if (resDetail.data.data.subscriberBomList && resDetail.data.data.subscriberBomList.length > 0) {
|
|
|
+ let data = resDetail.data.data.subscriberBomList.filter((itemBom) => itemBom.bomColorId === item.bomColorId)
|
|
|
+ if (data && data.length > 0) {
|
|
|
+ quantity = data[0].quantity
|
|
|
+ if (data[0].purchaseCount) {
|
|
|
+ quantity = Number(parseFloat(Number(quantity) - Number(data[0].purchaseCount)).toFixed(0))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ availablePurchase: quantity,
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
this.attachments = res.data.data.att
|
|
|
this.loadingStatus = false
|
|
|
},
|
|
@@ -225,13 +247,18 @@ export default {
|
|
|
this.form.subscriberId = res.data.data.id
|
|
|
if (res.data.data.subscriberBomList && res.data.data.subscriberBomList.length > 0) {
|
|
|
this.form.purchaseContractProductList = res.data.data.subscriberBomList.map((item) => {
|
|
|
+ let quantity = item.quantity
|
|
|
+ if (item.purchaseCount) {
|
|
|
+ quantity = Number(parseFloat(Number(quantity) - Number(item.purchaseCount)).toFixed(0))
|
|
|
+ }
|
|
|
return {
|
|
|
bomColorId: item.bomColorId,
|
|
|
bomColorName: item.bomColorName,
|
|
|
bomColorCode: item.bomColorCode,
|
|
|
bomColorImg: '',
|
|
|
bomColorLogo: '',
|
|
|
- quantity: item.quantity,
|
|
|
+ availablePurchase: quantity,
|
|
|
+ quantity: quantity,
|
|
|
price: undefined,
|
|
|
sumPrice: '',
|
|
|
remark: '',
|
|
@@ -270,6 +297,11 @@ export default {
|
|
|
let flagPayment = this.$refs.Payment.validateForm()
|
|
|
if (flagSupplier && flagProduct && flagAddress && flagPayment) {
|
|
|
if (this.form.purchaseContractProductList && this.form.purchaseContractProductList.length > 0) {
|
|
|
+ for (let i = 0; i < this.form.purchaseContractProductList.length; i++) {
|
|
|
+ if (this.form.purchaseContractProductList[i].quantity > this.form.purchaseContractProductList[i].availablePurchase) {
|
|
|
+ return this.msgInfo('采购数量不能大于可采购数量!')
|
|
|
+ }
|
|
|
+ }
|
|
|
this.loadingText = '提交数据中,请稍后'
|
|
|
this.loadingStatus = true
|
|
|
this.form.att = this.conversion(this.form.att)
|