| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- const _Http = getApp().globalData.http,
- file = require("../../../../utils/matchingFeilType");
- Component({
- data: {
- viewIndex: 0,
- sa_salesforecastbillid: 0,
- "content": {
- nocache: true,
- pageSize: 999,
- total: null,
- "where": {
- "condition": ""
- }
- },
- param: {
- "id": 20220906154703,
- "version": 1,
- "content": {
- nocache: true,
- "sa_salesforecastbillid": "",
- pageNumber: 1,
- pageTotal: 1,
- "where": {
- "condition": "",
- "sa_projectid": ""
- }
- }
- },
- productList: [], //产品列表
- },
- methods: {
- /* 获取产品列表 */
- getList(id) {
- let content = this.data.content;
- content.sa_salesforecastbillid = id;
- _Http.basic({
- "id": "20220916115203",
- "version": 1,
- content
- }).then(res => {
- console.log("项目清单", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- "content.total": res.total,
- sa_salesforecastbillid: id
- });
- if (res.data.length) {
- this.setData({
- 'param.content.where.sa_projectid': res.data[0].sa_projectid,
- 'param.content.sa_salesforecastbillid': id,
- })
- this.getProduct(true);
- }
- })
- },
- /* 获取产品清单 */
- 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 = []
- } 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.pageNumber == 1 ? res.data : this.data.productList.concat(res.data),
- "param.content.pageNumber": res.pageNumber + 1,
- "param.content.pageTotal": res.pageTotal,
- })
- })
- },
- /* 切换tab */
- onChange(e) {
- this.setData({
- "param.content.where.sa_projectid": e.detail.name,
- viewIndex: e.detail.index,
- });
- this.getProduct(true);
- },
- /* 添加产品 */
- addProduct() {
- wx.navigateTo({
- url: `/packageA/select/product/select?params=${JSON.stringify({
- id: 20221208105403,
- version: 1,
- model:'#Project',
- content: {
- nocache:true,
- sa_projectid: this.data.param.content.where.sa_projectid,
- sa_salesforecastbillid: this.data.sa_salesforecastbillid,
- pageSize: 20,
- pageNumber: 1,
- pageTotal: 1
- }
- })}`
- })
- },
- handleSelectProduct(itemclassinfos, oldList) {
- const that = this,
- page = getCurrentPages().find(v => v.__route__ == 'packageA/salesForecasting/detail')
- wx.showModal({
- title: '提示',
- content: '是否确认添加产品',
- complete: ({
- confirm
- }) => {
- if (confirm) _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
- }
- }).then(res => {
- console.log("项目添加产品", res)
- wx.showToast({
- title: res.msg == '成功' ? '添加成功' : res.msg,
- icon: "none"
- })
- if (res.msg != '成功') return;
- setTimeout(() => {
- 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"
- })
- })
- }
- }
- })
|