const _Http = getApp().globalData.http, currency = require("../../utils/currency"), CNY = (value, symbol = "¥", precision = 2) => currency(value, { symbol, precision }).format(); Component({ options: { addGlobalClass: true }, lifetimes: { attached: function () { getApp().globalData.Language.getLanguagePackage(this) let idName = 'sa_customersid', ParamId = 20230713104104; switch (this.data.mode) { case '项目': ParamId = 20230715112204; idName = 'sa_projectid'; break; case '业务员': ParamId = 20230717101204; idName = 'hrid'; this.setData({ dateTypes: ["全部", "本年", "本季", "本月"] }) break; case '联系人': ParamId = 20240605133604; idName = 'sys_phonebookid'; this.setData({ dateTypes: ["全部", "本年", "本季", "本月"], typeList: [{ remarks: "全部", value: "全部" }, { remarks: "项目报价单", value: "项目报价单" }, { remarks: "客户报价单", value: "客户报价单" }], "content.where.isproject": "" }) break; } this.setData({ idName, ParamId, }) } }, properties: { mode: { type: String, value: "客户" }, }, data: { dateTypes: ["全部", "本年"], dateType: "本年", type: "全部", showList: false, list: [], "isAll": 0, //1全部 0本年 "content": { "nocache": true, "pageNumber": 1, "pageTotal": 1, "total": null, "where": { type: "", begdate: "", enddate: "", } }, typeList: [] }, methods: { getList(id, init) { let content = this.data.content; content[this.data.idName] = id; if (this.data.mode == "业务员") { content.type = 99; switch (this.data.dateType) { case '全部': content.type = 0 break; case '本年': content.type = 1 break; case '本季': content.type = 2 break; case '本月': content.type = 3 break; } } else if (this.data.mode == "联系人") { content.dateType = this.data.dateType || '自定义' } else { content.isAll = this.data.isAll; } if (init) { content.pageNumber = 1; content.total = null; } if (!this.data.showList && content.total != null) return; if (content.pageNumber > content.pageTotal) return; _Http.basic({ "id": this.data.ParamId, content }).then(res => { console.log(this.data.mode + "关联报价单", res) if (res.code != '1') return wx.showToast({ title: res.data, icon: "none" }) content.pageNumber = res.pageNumber + 1; content.pageSize = res.pageSize; content.pageTotal = res.pageTotal; content.total = res.total; res.data = res.data.map(v => { v.topQuotedpriceamount = CNY((v.quotedpriceamount || 0) / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)); v.quotedpriceamount = CNY(v.quotedpriceamount); v.begdate = v.begdate.split(" ")[0] v.enddate = v.enddate.split(" ")[0] try { v.discountrate = (v.discountrate * 100).toFixed(2) + '%' } catch (error) { } return v }) this.setData({ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), content, id: id, }); try { this.selectComponent("#TimeRange").onCancel() } catch (error) { } try { this.selectComponent("#Filtrate").onCancel() } catch (error) { } }) }, changeDate({ detail }) { this.setData({ dateType: detail.dateType, isAll: detail.isAll === "" ? 99 : detail.isAll, "content.where.begdate": detail.begdate || "", "content.where.enddate": detail.enddate || "" }) this.getList(this.data.id, true) }, changeType({ detail }) { let isproject = ""; switch (detail) { case '项目报价单': isproject = "1"; break; case '客户报价单': isproject = "0"; break; } this.setData({ "content.where.isproject": isproject, type: detail, }) this.getList(this.data.id, true) }, shrinkChange({ detail }) { this.setData({ showList: detail }) }, upDateList() { let content = JSON.parse(JSON.stringify(this.data.content)); try { content[this.data.idName] = this.data.id; if (this.data.mode == "业务员") { content.type = 99; switch (this.data.dateType) { case '全部': content.type = 0 break; case '本年': content.type = 1 break; case '本季': content.type = 2 break; case '本月': content.type = 3 break; } } else if (this.data.mode == "联系人") { content.dateType = this.data.dateType || '自定义' } else { content.isAll = this.data.isAll; } content.pageSize = (content.pageNumber - 1) * content.pageSize; content.pageNumber = 1; } catch (error) { console.log("error", error) } _Http.basic({ id: this.data.ParamId, content }).then(res => { console.log(this.data.mode + "更新关联报价单", res); if (res.code == '1') { res.data = res.data.map(v => { v.topQuotedpriceamount = CNY((v.quotedpriceamount || 0) / (wx.getStorageSync('languagecode') == 'ZH' ? 10000 : 1000)); v.quotedpriceamount = CNY(v.quotedpriceamount); v.begdate = v.begdate.split(" ")[0] v.enddate = v.enddate.split(" ")[0] try { v.discountrate = (v.discountrate * 100).toFixed(2) + '%' } catch (error) { } return v }) this.setData({ list: res.data, "content.total": res.total }) } }) } } })