|
|
@@ -1,4 +1,5 @@
|
|
|
-const _Http = getApp().globalData.http;
|
|
|
+const _Http = getApp().globalData.http,
|
|
|
+ file = require("../../../../utils/matchingFeilType");
|
|
|
Component({
|
|
|
data: {
|
|
|
viewIndex: 0,
|
|
|
@@ -17,6 +18,8 @@ Component({
|
|
|
"content": {
|
|
|
nocache: true,
|
|
|
"sa_salesforecastbillid": "",
|
|
|
+ pageNumber: 1,
|
|
|
+ pageTotal: 1,
|
|
|
"where": {
|
|
|
"condition": "",
|
|
|
"sa_projectid": ""
|
|
|
@@ -50,22 +53,39 @@ Component({
|
|
|
'param.content.where.sa_projectid': res.data[0].sa_projectid,
|
|
|
'param.content.sa_salesforecastbillid': id,
|
|
|
})
|
|
|
- this.getProduct();
|
|
|
+ this.getProduct(true);
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/* 获取产品清单 */
|
|
|
- getProduct() {
|
|
|
+ getProduct(init = false) {
|
|
|
let param = this.data.param;
|
|
|
+ if (init) param.content.pageNumber = 1;
|
|
|
+ if (param.content.pageNumber > param.content.pageTotal) return;
|
|
|
_Http.basic(param).then(res => {
|
|
|
console.log("产品列表", res)
|
|
|
if (res.msg != '成功') return wx.showToast({
|
|
|
title: res.msg,
|
|
|
icon: "none"
|
|
|
});
|
|
|
- if (res.data.length == 1 && !res.data[0].itemname) res.data = [];
|
|
|
+ if (res.data.length == 1 && !res.data[0].itemname) {
|
|
|
+ res.data = []
|
|
|
+ } else {
|
|
|
+ res.data = res.data.map(value => {
|
|
|
+ if (value.attinfos.length != 0) {
|
|
|
+ value.attinfos = file.fileList(value.attinfos)
|
|
|
+ let image = value.attinfos.find(v => v.fileType == "image");
|
|
|
+ value.cover = image ? image.cover : "";
|
|
|
+ }
|
|
|
+ // value.className = value.itemclass.length == 0 ? "暂无类目" : value.itemclass.map(v => v.itemclassname);
|
|
|
+ // value.brandName = value.brand.length == 0 ? "暂无品牌" : value.brand.map(v => v.brandname);
|
|
|
+ return value;
|
|
|
+ })
|
|
|
+ }
|
|
|
this.setData({
|
|
|
- productList: res.data
|
|
|
+ productList: res.pageNumber == 1 ? res.data : this.data.productList.concat(res.data),
|
|
|
+ "param.content.pageNumber": res.pageNumber + 1,
|
|
|
+ "param.content.pageTotal": res.pageTotal,
|
|
|
})
|
|
|
})
|
|
|
},
|
|
|
@@ -75,7 +95,7 @@ Component({
|
|
|
"param.content.where.sa_projectid": e.detail.name,
|
|
|
viewIndex: e.detail.index,
|
|
|
});
|
|
|
- this.getProduct();
|
|
|
+ this.getProduct(true);
|
|
|
},
|
|
|
/* 添加产品 */
|
|
|
addProduct() {
|
|
|
@@ -121,12 +141,68 @@ Component({
|
|
|
})
|
|
|
if (res.msg != '成功') return;
|
|
|
setTimeout(() => {
|
|
|
- that.getProduct();
|
|
|
+ that.getProduct(true);
|
|
|
wx.navigateBack();
|
|
|
}, 300)
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
+ },
|
|
|
+ /* 生成修改队列 */
|
|
|
+ changeQueue({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ const that = this,
|
|
|
+ page = getCurrentPages().find(v => v.__route__ == 'packageA/salesForecasting/detail')
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906155003,
|
|
|
+ "version": 1,
|
|
|
+ "content": {
|
|
|
+ "sa_salesforecastmodelid": page.data.detail.sa_salesforecastmodelid,
|
|
|
+ "sa_salesforecastbillid": that.data.sa_salesforecastbillid,
|
|
|
+ "sa_projectid": that.data.param.content.where.sa_projectid,
|
|
|
+ itemclassinfos: detail
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ console.log("项目修改产品", res)
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ let index = that.data.productList.findIndex(v => v.sa_salesforecastid == detail[0].sa_salesforecastid);
|
|
|
+ if (index != -1) that.data.productList[index] = {
|
|
|
+ ...that.data.productList[index],
|
|
|
+ ...detail[0]
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ [`productList[${index}]`]: that.data.productList[index],
|
|
|
+ [`productList[0].sumamount`]: res.data[0].sumamount,
|
|
|
+ })
|
|
|
+ console.log(that.data.productList[index])
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 删除 */
|
|
|
+ deleteItem({
|
|
|
+ detail
|
|
|
+ }) {
|
|
|
+ _Http.basic({
|
|
|
+ "id": 20220906155103,
|
|
|
+ "version": 1,
|
|
|
+ "content": detail
|
|
|
+ }).then(res => {
|
|
|
+ console.log("删除产品", res);
|
|
|
+ if (res.msg != '成功') return wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none"
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ productList: this.data.productList.filter(v => v.sa_salesforecastid != detail.sa_salesforecastid)
|
|
|
+ });
|
|
|
+ wx.showToast({
|
|
|
+ title: '删除成功',
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
})
|