|
@@ -522,6 +522,7 @@ export default {
|
|
examineRemark: '',
|
|
examineRemark: '',
|
|
refCount: '',
|
|
refCount: '',
|
|
regionWork: '',
|
|
regionWork: '',
|
|
|
|
+ examineStatus: ''
|
|
},
|
|
},
|
|
mainFormRules: {
|
|
mainFormRules: {
|
|
// orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
|
|
// orderDate: [{ required: true, message: '请选择单据日期', trigger: 'change' }],
|
|
@@ -578,6 +579,8 @@ export default {
|
|
|
|
|
|
isFirst: false,
|
|
isFirst: false,
|
|
salesmanList: [],
|
|
salesmanList: [],
|
|
|
|
+ oldSaleType: '',
|
|
|
|
+ notInRefQueryGoodsList: ''
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -625,6 +628,9 @@ export default {
|
|
},
|
|
},
|
|
immediate: true,
|
|
immediate: true,
|
|
deep: true
|
|
deep: true
|
|
|
|
+ },
|
|
|
|
+ 'mainForm.saleType': function (newValue, oldValue) {
|
|
|
|
+ this.oldSaleType = oldValue
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -759,86 +765,63 @@ export default {
|
|
},
|
|
},
|
|
|
|
|
|
// 选择工程登录
|
|
// 选择工程登录
|
|
- chooseItem(id, uid) {
|
|
|
|
|
|
+ async chooseItem(id, uid, isChangeSaleType = false) {
|
|
getHomeLoginDetail({
|
|
getHomeLoginDetail({
|
|
recordNo: id,
|
|
recordNo: id,
|
|
saleTypeId: this.mainForm.saleType,
|
|
saleTypeId: this.mainForm.saleType,
|
|
userId: uid,
|
|
userId: uid,
|
|
enginOrderId: this.mainForm.orderNum,
|
|
enginOrderId: this.mainForm.orderNum,
|
|
customerId: JSON.parse(localStorage.getItem("supply_user")).customerId
|
|
customerId: JSON.parse(localStorage.getItem("supply_user")).customerId
|
|
- }).then(res => {
|
|
|
|
- this.isShowDialog = false;
|
|
|
|
- let data = res.data;
|
|
|
|
- this.mainForm.type = data.productCategory;
|
|
|
|
- this.mainForm.loginUserId = data.userid;
|
|
|
|
- // this.mainForm.saleType = '';
|
|
|
|
- this.mainForm.loginNum = data.recordNo;
|
|
|
|
- this.mainForm.enginName = data.projectName;
|
|
|
|
- this.mainForm.loginType = data.tradeCategory;
|
|
|
|
- this.mainForm.factoryNum = data.factoryNo;
|
|
|
|
- this.mainForm.promiseStatus = data.promiseStatus;
|
|
|
|
- this.mainForm.company = data.useUnit;
|
|
|
|
- this.mainForm.contactMan = data.buyUnitCallMen;
|
|
|
|
- this.mainForm.tel = data.buyUnitTel;
|
|
|
|
- this.mainForm.phone = data.buyUnitPhone;
|
|
|
|
- this.mainForm.address = data.installAddress;
|
|
|
|
- this.mainForm.declareNo = data.declareNo;
|
|
|
|
- this.mainForm.projectRemark = data.buChonShuoMing;
|
|
|
|
- this.mainForm.projectType = data.govBuyType;
|
|
|
|
- this.mainForm.refCount = data.refCount;
|
|
|
|
- this.mainForm.regionWork = data.regionWork;
|
|
|
|
-
|
|
|
|
- let saleTypeItem = this.salesTypeList.find(o => o.id == this.mainForm.saleType);
|
|
|
|
|
|
+ }).then(async res => {
|
|
|
|
+ // 复制当前明细数据
|
|
|
|
+ let copyGoodsList = JSON.parse(JSON.stringify(this.goodsList));
|
|
|
|
+ console.log('未刷新前', copyGoodsList)
|
|
|
|
+ if (!isChangeSaleType) {
|
|
|
|
+ this.setMainAndItem(res.data)
|
|
|
|
+ } else {
|
|
|
|
+ // 找出不属于引用单上的产品
|
|
|
|
+ if (copyGoodsList && copyGoodsList.length > 0) {
|
|
|
|
+ let notInRefGoodsList = []
|
|
|
|
+
|
|
|
|
+ for (let i = 0; i < copyGoodsList.length; i++) {
|
|
|
|
+ let goods = copyGoodsList[i]
|
|
|
|
+ let index = res.data.items.findIndex(v => v.materialOldNumber === goods.materialOldNumber)
|
|
|
|
+ if (index < 0) {
|
|
|
|
+ notInRefGoodsList.push(goods)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- this.goodsList = data.items.map(item => {
|
|
|
|
- return {
|
|
|
|
- useRefCount: item.useRefCount,
|
|
|
|
- saleTypeId: saleTypeItem.id,
|
|
|
|
- saleTypeCode: saleTypeItem.saleCode,
|
|
|
|
- saleTypeName: saleTypeItem.saleName,
|
|
|
|
- materialId: item.materialId,
|
|
|
|
- materialNumber: item.materialNumber,
|
|
|
|
- materialOldNumber: item.materialOldNumber,
|
|
|
|
- materialName: item.materialName,
|
|
|
|
- specification: item.machine,
|
|
|
|
- enginNum: item.num,
|
|
|
|
- enginPrice: item.price,
|
|
|
|
- enginTotality: item.totality,
|
|
|
|
- historyHasDeliverQty: item.hasDeliverQty,
|
|
|
|
- unit: item.unit,
|
|
|
|
- price: item.price,
|
|
|
|
- qty: item.num,
|
|
|
|
- customerWalletId2: '',
|
|
|
|
- rebateRate: '',
|
|
|
|
- discAmount: '',
|
|
|
|
- customerWalletId: '',
|
|
|
|
- isDirectTransfer: false,
|
|
|
|
- directTransferQty: '',
|
|
|
|
- hasSendQty: '',
|
|
|
|
- remark: item.discri,
|
|
|
|
- tax: '',
|
|
|
|
- status1: '',
|
|
|
|
- status2: '',
|
|
|
|
- rebateWallets: item.customerWalletList.filter(item => {
|
|
|
|
- return item.type === 'REBATE';
|
|
|
|
- }),
|
|
|
|
- wallets: item.customerWalletList.filter(item => {
|
|
|
|
- return item.type === 'COMMONLY';
|
|
|
|
- }),
|
|
|
|
|
|
+ if (notInRefGoodsList && notInRefGoodsList.length > 0) {
|
|
|
|
+ let oldNumbers = []
|
|
|
|
+ notInRefGoodsList.forEach(v => oldNumbers.push(v.materialOldNumber))
|
|
|
|
+ console.log('请求前可选机型接口', notInRefGoodsList, oldNumbers)
|
|
|
|
+ // 请求可选机型接口
|
|
|
|
+ await this.querySaleTypeGoods(oldNumbers)
|
|
|
|
+ console.log('返回新加明细', this.notInRefQueryGoodsList)
|
|
|
|
+ if (!this.notInRefQueryGoodsList) {
|
|
|
|
+ console.log('结束执行下去')
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.addRefItems(res.data.items, notInRefGoodsList)
|
|
|
|
+ }
|
|
|
|
+ // 数量和价格不变更
|
|
|
|
+ console.log('执行下去,数量和价格不变更')
|
|
}
|
|
}
|
|
- })
|
|
|
|
- this.goodsList.forEach(item => {
|
|
|
|
- item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
|
|
|
|
- item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
|
|
|
|
- item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
|
|
|
|
- })
|
|
|
|
|
|
+ console.log('替换前', res.data.items)
|
|
|
|
+ res.data.items = this.replaceHistoryItems(res.data.items, copyGoodsList)
|
|
|
|
+ console.log('替换后', res.data.items)
|
|
|
|
+ this.setMainAndItem(res.data)
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }).catch(() => {
|
|
|
|
+ this.mainForm.saleType = this.oldSaleType
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
|
|
// 选择销售类型
|
|
// 选择销售类型
|
|
changeSaleType() {
|
|
changeSaleType() {
|
|
if(this.mainForm.loginNum) {
|
|
if(this.mainForm.loginNum) {
|
|
- this.chooseItem(this.mainForm.loginNum, this.mainForm.loginUserId);
|
|
|
|
|
|
+ this.chooseItem(this.mainForm.loginNum, this.mainForm.loginUserId, true);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
@@ -910,6 +893,7 @@ export default {
|
|
this.mainForm.examineRemark = data.examineNote;
|
|
this.mainForm.examineRemark = data.examineNote;
|
|
this.mainForm.loginUserId = data.loginUserId;
|
|
this.mainForm.loginUserId = data.loginUserId;
|
|
this.mainForm.regionWork = data.refRegionWork;
|
|
this.mainForm.regionWork = data.refRegionWork;
|
|
|
|
+ this.mainForm.examineStatus = data.examineStatus;
|
|
|
|
|
|
data.items.forEach(item => {
|
|
data.items.forEach(item => {
|
|
item.status1 = '';
|
|
item.status1 = '';
|
|
@@ -958,6 +942,8 @@ export default {
|
|
item.materialCode = item.number;
|
|
item.materialCode = item.number;
|
|
item.saleTypeName = item.saleName;
|
|
item.saleTypeName = item.saleName;
|
|
item.unit = item.baseUnit;
|
|
item.unit = item.baseUnit;
|
|
|
|
+ item.enginNum = 0;
|
|
|
|
+ item.qty = 0;
|
|
item.price = item.batchPrice;
|
|
item.price = item.batchPrice;
|
|
item.tax = item.taxRate;
|
|
item.tax = item.taxRate;
|
|
item.isDirectTransfer = false;
|
|
item.isDirectTransfer = false;
|
|
@@ -1201,6 +1187,154 @@ export default {
|
|
}
|
|
}
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ setMainAndItem(data) {
|
|
|
|
+ this.isShowDialog = false;
|
|
|
|
+ this.mainForm.type = data.productCategory;
|
|
|
|
+ this.mainForm.loginUserId = data.userid;
|
|
|
|
+ // this.mainForm.saleType = '';
|
|
|
|
+ this.mainForm.loginNum = data.recordNo;
|
|
|
|
+ this.mainForm.enginName = data.projectName;
|
|
|
|
+ this.mainForm.loginType = data.tradeCategory;
|
|
|
|
+ this.mainForm.factoryNum = data.factoryNo;
|
|
|
|
+ this.mainForm.promiseStatus = data.promiseStatus;
|
|
|
|
+ this.mainForm.company = data.useUnit;
|
|
|
|
+ this.mainForm.contactMan = data.buyUnitCallMen;
|
|
|
|
+ this.mainForm.tel = data.buyUnitTel;
|
|
|
|
+ this.mainForm.phone = data.buyUnitPhone;
|
|
|
|
+ this.mainForm.address = data.installAddress;
|
|
|
|
+ this.mainForm.declareNo = data.declareNo;
|
|
|
|
+ this.mainForm.projectRemark = data.buChonShuoMing;
|
|
|
|
+ this.mainForm.projectType = data.govBuyType;
|
|
|
|
+ this.mainForm.refCount = data.refCount;
|
|
|
|
+ this.mainForm.regionWork = data.regionWork;
|
|
|
|
+
|
|
|
|
+ let saleTypeItem = this.salesTypeList.find(o => o.id === this.mainForm.saleType);
|
|
|
|
+
|
|
|
|
+ this.goodsList = data.items.map(item => {
|
|
|
|
+ return {
|
|
|
|
+ useRefCount: item.useRefCount,
|
|
|
|
+ saleTypeId: saleTypeItem.id,
|
|
|
|
+ saleTypeCode: saleTypeItem.saleCode,
|
|
|
|
+ saleTypeName: saleTypeItem.saleName,
|
|
|
|
+ materialId: item.materialId,
|
|
|
|
+ materialNumber: item.materialNumber,
|
|
|
|
+ materialOldNumber: item.materialOldNumber,
|
|
|
|
+ materialName: item.materialName,
|
|
|
|
+ specification: item.machine,
|
|
|
|
+ enginNum: item.num,
|
|
|
|
+ enginPrice: item.price,
|
|
|
|
+ enginTotality: item.totality,
|
|
|
|
+ historyHasDeliverQty: item.hasDeliverQty,
|
|
|
|
+ unit: item.unit,
|
|
|
|
+ price: item.price,
|
|
|
|
+ qty: item.num,
|
|
|
|
+ customerWalletId2: '',
|
|
|
|
+ rebateRate: '',
|
|
|
|
+ discAmount: '',
|
|
|
|
+ customerWalletId: '',
|
|
|
|
+ isDirectTransfer: false,
|
|
|
|
+ directTransferQty: '',
|
|
|
|
+ hasSendQty: '',
|
|
|
|
+ remark: item.discri,
|
|
|
|
+ tax: '',
|
|
|
|
+ status1: '',
|
|
|
|
+ status2: '',
|
|
|
|
+ rebateWallets: item.customerWalletList.filter(item => {
|
|
|
|
+ return item.type === 'REBATE';
|
|
|
|
+ }),
|
|
|
|
+ wallets: item.customerWalletList.filter(item => {
|
|
|
|
+ return item.type === 'COMMONLY';
|
|
|
|
+ }),
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ this.goodsList.forEach(item => {
|
|
|
|
+ item.customerWalletId = (item.wallets && item.wallets.length) ? item.wallets[0].customerWalletId : '';
|
|
|
|
+ item.serviceId = (item.wallets && item.wallets.length) ? item.wallets[0].serviceId : '';
|
|
|
|
+ item.serviceName = (item.wallets && item.wallets.length) ? item.wallets[0].serviceName : '';
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ async querySaleTypeGoods(oldNumbers) {
|
|
|
|
+ await getRetailProductList({
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize: -1,
|
|
|
|
+ saleId: this.mainForm.saleType,
|
|
|
|
+ billType: 'HOME',
|
|
|
|
+ oldNumbers: oldNumbers.join(','),
|
|
|
|
+ customerId: this.mainForm.jxsNum
|
|
|
|
+ }).then(res => {
|
|
|
|
+ console.log('请求后可选机型接口', res.data.records)
|
|
|
|
+ if (!res.data.records || res.data.records.length === 0) {
|
|
|
|
+ this.mainForm.saleType = this.oldSaleType
|
|
|
|
+ console.log(1)
|
|
|
|
+ this.$errorMsg(oldNumbers.join(',') + " 产品无此销售类型")
|
|
|
|
+ this.notInRefQueryGoodsList = ''
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if (res.data.records.length < oldNumbers.length) {
|
|
|
|
+ let notInOldNumbers = []
|
|
|
|
+ for (let i = 0; i < oldNumbers.length; i++) {
|
|
|
|
+ let oldNumber = oldNumbers[i]
|
|
|
|
+ let index = res.data.records.findIndex(v => v.materialOldNumber === oldNumber)
|
|
|
|
+ if (index < 0) {
|
|
|
|
+ notInOldNumbers.push(oldNumber)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ this.mainForm.saleType = this.oldSaleType
|
|
|
|
+ console.log(2)
|
|
|
|
+ this.$errorMsg(notInOldNumbers.join(',') + " 产品无此销售类型")
|
|
|
|
+ this.notInRefQueryGoodsList = ''
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ this.notInRefQueryGoodsList = res.data.records
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ replaceHistoryItems(items, copyGoodsList) {
|
|
|
|
+ if (items && copyGoodsList) {
|
|
|
|
+ for (let i = 0; i < items.length; i++) {
|
|
|
|
+ let index = copyGoodsList.findIndex(v => v.materialOldNumber === items[i].materialOldNumber)
|
|
|
|
+ if (index >= 0) {
|
|
|
|
+ items[i].price = copyGoodsList[index].price
|
|
|
|
+ items[i].num = copyGoodsList[index].qty
|
|
|
|
+ items[i].discri = copyGoodsList[index].remark
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return items
|
|
|
|
+ },
|
|
|
|
+ addRefItems(items, notInRefGoodsList) {
|
|
|
|
+ if (notInRefGoodsList && this.notInRefQueryGoodsList) {
|
|
|
|
+ for (let i = 0; i < notInRefGoodsList.length; i++) {
|
|
|
|
+ let index = this.notInRefQueryGoodsList.findIndex(v => v.materialOldNumber === notInRefGoodsList[i].materialOldNumber)
|
|
|
|
+ if (index >= 0) {
|
|
|
|
+ this.notInRefQueryGoodsList[index].batchPrice = notInRefGoodsList[i].price
|
|
|
|
+ this.notInRefQueryGoodsList[index].qty = notInRefGoodsList[i].qty
|
|
|
|
+ this.notInRefQueryGoodsList[index].remark = notInRefGoodsList[i].remark
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ console.log('非引用单产品', this.notInRefQueryGoodsList)
|
|
|
|
+ for (let i = 0; i < this.notInRefQueryGoodsList.length; i++) {
|
|
|
|
+ let goods = this.notInRefQueryGoodsList[i]
|
|
|
|
+ let customerWalletList = [].concat(goods.rebateWallets).concat(goods.wallets)
|
|
|
|
+
|
|
|
|
+ items.push({
|
|
|
|
+ saleTypeId: goods.saleTypeId,
|
|
|
|
+ saleTypeCode: goods.saleTypeCode,
|
|
|
|
+ saleTypeName: goods.saleTypeName,
|
|
|
|
+ materialId: goods.materialId,
|
|
|
|
+ materialNumber: goods.materialNumber,
|
|
|
|
+ materialOldNumber: goods.materialOldNumber,
|
|
|
|
+ materialName: goods.materialName,
|
|
|
|
+ machine: goods.specification,
|
|
|
|
+ num: goods.qty,
|
|
|
|
+ batchPrice: goods.batchPrice,
|
|
|
|
+ discri: goods.remark,
|
|
|
|
+ customerWalletList: customerWalletList
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|