const _Http = getApp().globalData.http; Page({ data: { isLeader: false, //是否为负责人 tabsActive: 0, //tabs 选中项 sa_customersid: 0, detail: {}, //详情数据 briefs: [], //简介列表 tabsList: [{ label: "跟进动态", icon: "icon-tabgenjinjilu" }, { label: "详细信息", icon: "icon-tabxiangxixinxi1" }, { label: "线索", icon: "icon-tabxiansuo" }, { label: "项目商机", icon: "icon-tabxiangmu" }, { label: "客户地址", icon: "icon-tabdizhi" }, { label: "联系人", icon: "icon-tablianxiren" }, { label: "报价单", icon: "icon-tabbaojiadan" }, { label: "开票信息", icon: "icon-tabkaipiaoxinxi" }, { label: "任务", icon: "icon-tabrenwu" }], list1: [], //基本信息 list2: [], //系统信息 tabbarList: [] }, onLoad(options) { this.setData({ sa_customersid: options.id, isAdmin: wx.getStorageSync('auth').wCustomer.options.some(v => v == "admin"), //是否具有管理权限 options: wx.getStorageSync('auth').wCustomer.options, //权限列表 }) this.getDetail(); }, //详情按钮回调 tabbarOnClick({ detail }) { let data = this.data.detail, that = this; switch (detail.label) { case "分享": wx.navigateTo({ url: `/packageA/publicCustomer/pond/index?params=${JSON.stringify({ "id": 20221206195102, name:"分享",                 "content": {                     "pageNumber": 1,                     "pageSize": 20,                     "where": {                         "condition": ""                     }                 } })}`, }) break; case "退回": wx.showModal({ title: '提示', content: `是否确定将${data.enterprisename}退回到公海客户`, complete: (res) => { console.log(data) if (res.confirm) _Http.basic({ "id": 20221014102602, "content": { "sa_customerpoolid": data.sa_customerpoolid_source, "sa_customersids": [data.sa_customersid] } }).then(res => { console.log("公海线索退回", res) wx.showToast({ title: res.msg == '成功' ? '退回成功' : res.msg, icon: "none" }); if (res.msg == '成功') setTimeout(() => { let page = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/index'); if (page) page.setData({ list: page.data.list.filter(v => v.sa_customersid != data.sa_customersid) }); wx.redirectTo({ url: '/packageA/publicCustomer/detail?id' + data.sa_customersid, }) }, 300) }) } }); break; case "回收": wx.navigateTo({ url: `/packageA/publicCustomer/pond/index?params=${JSON.stringify({ "id": 20221206195102, name:"回收",                 "content": {                     "pageNumber": 1,                     "pageSize": 20,                     "where": {                         "condition": ""                     }                 } })}`, }) break; case "跟进": wx.navigateTo({ url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_customers&ownerid=${data.sa_customersid}`, }) break; case "编辑": wx.navigateTo({ url: `/packageA/setclient/addAndEditor?data=${JSON.stringify(data)}`, }) break; case "作废": wx.navigateTo({ url: `/packageA/setclient/delete?item=${JSON.stringify({ "sa_customersids": [this.data.detail.sa_customersid], datastatus: 1, //(0:正常;1:作废;2:锁定) })}`, }) break; case "更换负责人": wx.navigateTo({ url: `/pages/group/select?data=${JSON.stringify({ ownertable:"sa_customers", ownerid:this.data.sa_customersid, })}&radio=true&principal=true`, }) break; default: console.log(detail) break; } }, handleTransfer(ids, list, name) { console.log(ids, list, name) wx.showModal({ title: '提示', content: `是否确定将客户${name}至${list[0].poolname}?`, complete: (res) => { if (res.confirm) _Http.basic({ "id": name == '回收' ? 20221014165602 : 20221014102502, "content": { "sa_customerpoolid": ids[0], //公海池id "sa_customersids": [this.data.detail.sa_customersid] }, }).then(res => { console.log(name, res) wx.showToast({ title: res.data == '成功' ? `${name}成功` : res.msg, icon: "none" }); if (res.data == '成功') setTimeout(() => { wx.navigateBack() let page = getCurrentPages().find(v => v.__route__ == 'packageA/setclient/index'); if (page) page.setData({ list: page.data.list.filter(v => v.sa_customersid != this.data.detail.sa_customersid) }); wx.redirectTo({ url: '/packageA/publicCustomer/detail?id=' + this.data.detail.sa_customersid, }) }, 300) }) } }) }, /* 更换负责人 */ handelSubmit(arr) { const that = this; wx.showModal({ title: '提示', content: '是否确认更换负责人', complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": 20220930103701, "content": { ownertable: "sa_customers", ownerid: that.data.sa_customersid, userid: arr[0] } }).then(res => { console.log("更换负责人", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }); wx.showToast({ title: '更换成功!', icon: "none" }); setTimeout(() => { that.getDetail(); getCurrentPages().forEach(v => { if (['packageA/setclient/index'].includes(v.__route__)) v.getList(true) }) wx.navigateBack(); }, 300) }) } }) }, /* 获取详情 */ getDetail() { /* 基本信息 */ _Http.basic({ "id": 20221012164302, "content": { sa_customersid: this.data.sa_customersid }, }).then(res => { console.log("详情", res) if (res.msg != '成功') return wx.showToast({ title: res.data, icon: "none" }) /* 摘要信息 */ let briefs = [{ label: "客户级别", value: res.data.grade }, { label: "客户类型", value: res.data.type }, { label: "上级企业", value: res.data.superiorenterprisename }]; /* 基本信息 */ let list1 = [{ label: "客户名称", value: res.data.enterprisename }, { label: "客户编号", value: res.data.sa_customersid }, { label: "客户级别", value: res.data.grade }, { label: "客户类型", value: res.data.type }, { label: "上级企业", value: res.data.superiorenterprisename }, { label: "分配状态", value: "" }, { label: "合作状态", value: res.data.status }, { label: "成交次数", value: res.data.contact_signnum }, { label: "来源", value: res.data.source }]; /* 系统信息 */ let list2 = [{ label: "创建人", value: res.data.createby }, { label: "创建时间", value: res.data.createdate }, { label: "成交状态", value: res.data.tradingstatus }]; this.setData({ detail: res.data, briefs, list1, list2 }); //负责人 _Http.basic({ "id": 20220930103501, "content": { "ownertable": "sa_customers", "ownerid": this.data.sa_customersid } }).then(s => { console.log("负责人", s) let tabbarList = [{ icon: "icon-genjin", label: "跟进" }]; if (s.data.length != 0) { let userList = s.data.map(user => user.team[0]), isLeader = userList.some(some => some.userid == wx.getStorageSync('userMsg').userid); if (isLeader || this.data.isAdmin) tabbarList = [{ icon: "icon-bianji", label: "编辑" }, { icon: "icon-zhuanyi", label: "更换负责人" }, { icon: "icon-shanchu", label: "作废" }].concat(tabbarList); if (isLeader && res.data.ispublic == 1) tabbarList = tabbarList.concat([{ icon: "icon-dibu-fenxiang", label: "分享" }, { icon: "icon-dibu-chehui", label: "退回" }]); if (isLeader) tabbarList.splice(0, 0, { icon: "icon-dibu-tuihui", label: "回收" }) let list = list1.concat([{ label: "负责人", value: s.data[0].teamleader[0].name }, { label: "负责人部门", value: s.data[0].teamleader[0].position }]) list[5].value = s.data.length > 0 ? '已分配' : '未分配'; this.setData({ isLeader, principal: s.data, list1: list, briefs: this.data.briefs.concat([{ label: "负责人", value: s.data[0].teamleader[0].name }, { label: "最近跟进时间", value: s.data[0].teamleader[0].changedate }]) }); } this.setData({ tabbarList, }) }); //系统信息 _Http.basic({ "id": 20221019091602, "content": { "sa_customersid": this.data.sa_customersid } }).then(s => { console.log("系统信息", s) let list = this.data.list2.concat([{ label: "转手次数", value: s.data.changecount }, { label: "最近编辑人", value: s.data.changeby }, { label: "最近编辑时间", value: s.data.changedate }]) /* { label: "客户资料完善度", value: s.data.tradingstatus + '%' } */ this.setData({ list2: list }) }) //获取标签 this.getTags(); this.getGroup() this.partialRenewal(); }); }, //tabs 切换 tabsChange({ detail }) { this.setData({ tabsActive: detail }); this.partialRenewal(); }, //局部数据更新 tabs partialRenewal(init = false) { let id = this.data.detail.sys_enterpriseid; let model = ''; let name = this.data.tabsList[this.data.tabsActive].label; switch (name) { case "任务": model = "#Work" break; case "跟进动态": model = "#Trace" break; case "项目商机": model = "#Project" break; case "线索": id = this.data.detail.sa_customersid; model = "#Clue" break; case "客户地址": model = "#Address" break; case "报价单": model = "#Offers" break; case "联系人": model = "#Contacts" break; case "开票信息": model = "#Financing" break; default: break; }; if (model) { // 确定好模块ID total = null 是第一次加载 加载数据 // init是新增或修改需要清数据 let Component = this.selectComponent(model); const { total, pageNumber, pageTotal } = Component.data.content; if (total == null || init) { console.log(1) Component.getList(id, init); } else if (pageNumber <= pageTotal) { console.log(2) Component.getList(id, false); } else { //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据 } } }, //更新标签 getTags() { this.selectComponent("#Tags").getTags(); }, //更新团队成员 getGroup() { this.selectComponent("#Group").getList(); }, onReachBottom() { this.partialRenewal(); }, onShareAppMessage() {} })