| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- tabsActive: 1, //tabs 选中项
- sa_salesforecastbillid: "",
- tabsList: [{
- label: "详细信息",
- icon: "icon-tabxiangxixinxi1"
- }, {
- label: "项目产品清单",
- icon: "icon-tabchanpin",
- model: "#Project"
- }, {
- label: "跟进动态",
- icon: "icon-tabgenjinjilu",
- model: "#Trace"
- }, {
- label: "操作记录",
- icon: "icon-tabcaozuojilu1",
- model: "#Record"
- }, {
- label: "附件",
- icon: "icon-tabfujian1",
- model: "#Files"
- }, {
- label: "任务",
- icon: "icon-tabrenwu",
- model: "#Work"
- }],
- tabbarList: [{
- icon: "color-genjin",
- label: "跟进"
- }, {
- icon: "icon-guanlian-bianji",
- label: "添加项目"
- }, {
- icon: "icon-guanlian-fuzhi",
- label: "移除项目"
- }],
- sColors: getApp().globalData.sColors,
- },
- onLoad(options) {
- this.setData({
- sa_salesforecastbillid: options.sa_salesforecastbillid
- });
- this.getDetail(true);
- },
- getDetail(init = false) {
- _Http.basic({
- "id": 20220914104603,
- "version": 1,
- "content": {
- nocache: true,
- "sa_salesforecastbillid": this.data.sa_salesforecastbillid
- },
- }).then(res => {
- console.log("预测详情", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setPreview(res.data[0])
- if (init) this.getTags()
- this.partialRenewal(init);
- })
- },
- /* 设置显示项 */
- setPreview(data) {
- this.setData({
- detail: data,
- briefs: [{
- label: "提报类型",
- value: data.isrepeat == 1 ? '月度提报' : '单次提报'
- }, {
- label: "提报要求",
- value: data.remarks
- }, {
- label: "提报开始时间",
- value: data.periodstart
- }, {
- label: "提报截止时间",
- value: data.periodend
- }, {
- label: "预测金额",
- value: data.sumamount
- }, {
- label: "提报人",
- value: data.createby
- }, {
- label: "状态",
- value: getApp().globalData.Language.getMapText(data.status),
- style:`color:${this.data.sColors[data.status]}`
- }],
- list1: [{
- label: "提报类型",
- value: data.isrepeat == 1 ? '月度提报' : '单次提报'
- }, {
- label: "提报要求",
- value: data.remarks
- }, {
- label: "提报开始时间",
- value: data.periodstart
- }, {
- label: "提报截止时间",
- value: data.periodend
- }, {
- label: "预测金额(元)",
- value: data.sumamount
- }, {
- label: "状态",
- value: getApp().globalData.Language.getMapText(data.status),
- style:`color:${this.data.sColors[data.status]}`
- }],
- list2: [{
- label: "提报人",
- value: data.createby
- }, {
- label: "提报时间",
- value: data.createdate
- }, {
- label: "最近编辑人",
- value: data.changeby
- }, {
- label: "最近编辑时间",
- value: data.changedate
- }]
- });
- /* 更新列表数据 */
- let page = getCurrentPages().find(v => v.__route__ == 'packageA/salesForecasting/index');
- if (page) {
- let i = page.data.list.findIndex(v => v.sa_salesforecastbillid == this.data.sa_salesforecastbillid);
- if (i != -1) {
- page.data.list[i].status = data.status;
- page.data.list[i].amount = data.sumamount;
- page.setData({
- [`list[${i}]`]: page.data.list[i]
- })
- }
- }
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- /* 添加项目 */
- addProject({
- list
- }) {
- let that = this;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- t: 1,
- v: '是否确认添加',
- r: " "
- }, {
- v: list.length,
- r: " "
- }, {
- t: 1,
- v: '个项目',
- r: "?"
- }]),
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- id: 20220913154403,
- version: 1,
- content: {
- nocache: true,
- sa_salesforecastmodelid: that.data.detail.sa_salesforecastmodelid,
- sa_salesforecastbillid: that.data.sa_salesforecastbillid,
- sa_projectids: list.map(v => {
- return {
- sa_projectid: v.sa_projectid,
- discountrate: v.discountrate
- }
- })
- }
- }).then(res => {
- console.log("添加项目", res)
- wx.showToast({
- title: res.code == '1' ? getApp().globalData.Language.getMapText('添加成功') : res.msg,
- icon: "none"
- });
- if (res.code == '1') {
- that.setData({
- tabsActive: that.data.tabsList.findIndex(v => v.label == '项目产品清单')
- });
- setTimeout(() => {
- wx.navigateBack();
- setTimeout(() => {
- that.selectComponent('#Project').getList(that.data.sa_salesforecastbillid, false, true);
- }, 300)
- }, 300)
- }
- })
- }
- })
- },
- /* 删除项目 */
- deteleProject({
- item
- }) {
- let that = this;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确认移除') + `“${item.projectname}”`,
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20220906155103,
- "version": 1,
- "content": {
- "sa_salesforecastid": 0,
- "sa_projectid": item.sa_projectid,
- "sa_salesforecastbillid": item.sa_salesforecastbillid
- }
- }).then(res => {
- console.log("移除项目", res)
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- that.selectComponent("#Project").getList(that.data.sa_salesforecastbillid);
- setTimeout(() => {
- wx.showToast({
- title: getApp().globalData.Language.getMapText('已移除') + `“${item.projectname}”`,
- icon: "none"
- })
- let page = getCurrentPages().find(v => v.__route__ == 'packageA/select/project/select');
- if (page) page.deteleItem(item.sa_projectid);
- that.getDetail();
- }, 500)
- })
- }
- })
- },
- //详情按钮回调
- tabbarOnClick({
- detail
- }) {
- switch (detail.label) {
- case "跟进":
- wx.navigateTo({
- url: `/prsx/trace/add/index?ownertable=sa_salesforecastbill&ownerid=${this.data.sa_salesforecastbillid}}&resource=销售预测`,
- })
- break;
- case "添加项目":
- wx.navigateTo({
- url: `/packageA/select/project/select?params=${JSON.stringify({
- "id": 20220906154803,
- "version":1,
- "content": {
- nocache:true,
- sa_salesforecastbillid:this.data.sa_salesforecastbillid,
- "where":{
- "condition":""
- }
- }
- })}`,
- });
- getApp().globalData.handleSelect = this.addProject.bind(this);
- break;
- case "移除项目":
- wx.navigateTo({
- url: `/packageA/select/project/select?params=${JSON.stringify({
- "id": "20220916115203",
- "version": 1,
- "content": {
- nocache: true,
- sa_salesforecastbillid:this.data.sa_salesforecastbillid,
- pageSize: 999,
- "where":{
- "condition":""
- }
- }
- })}&radio=true`,
- })
- getApp().globalData.handleSelect = this.deteleProject.bind(this);
- break;
- }
- },
- //更新标签
- getTags() {
- this.selectComponent("#Tags").getTags();
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- let model = this.data.tabsList[this.data.tabsActive].model;
- if (model) {
- let Component = this.selectComponent(model),
- {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content,
- id = this.data.sa_salesforecastbillid;
- if (model == "#Files") init = true;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- }
- }
- },
- onReachBottom() {
- this.partialRenewal();
- }
- })
|