| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- tabsActive: 0, //tabs 选中项
- sys_taskid: "",
- detail: '',
- tabsList: [{
- label: "详细信息",
- icon: "icon-tabxiangxixinxi1"
- }, {
- label: "跟进动态",
- icon: "icon-tabgenjinjilu"
- }, {
- label: "操作",
- icon: "icon-tabcaozuojilu1"
- }, {
- label: "附件",
- icon: "icon-tabfujian1"
- }],
- tabbarList: [],
- confirmShow: false,
- finishnotes: "", //完成说明
- },
- /* 完成情况说明输入 */
- areaInput(e) {
- this.setData({
- finishnotes: e.detail.value
- })
- },
- onConfirm(e) {
- _Http.basic({
- "id": 20221211112501,
- "content": {
- "sys_taskid": this.data.sys_taskid,
- "finishnotes": this.data.finishnotes
- }
- }).then(res => {
- console.log("完成情况说明", res)
- wx.showToast({
- title: res.msg == '成功' ? "提交成功" : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(this.getDetail, 500)
- })
- },
- /* 取消提交说明 */
- onCancel(e) {
- this.setData({
- confirmShow: false
- })
- },
- onLoad(options) {
- this.setData({
- sys_taskid: options.id
- });
- this.getDetail();
- getApp().globalData.previewClick = this.previewClick.bind(this);
- },
- previewClick({
- label,
- value
- }) {
- if (label == '关联应用数据') {
- const detail = this.data.detail;
- if (detail.ownerid) {
- const authComparison = wx.getStorageSync('authComparison');
- //判断具体消息归属
- switch (detail.ownertable) {
- case "sa_customers":
- this.saCustomer(detail.ownerid);
- break;
- case "sat_orderclue":
- this.satOrderclue(detail.ownerid);
- break;
- case "sa_order":
- this.saOrder(detail.ownerid)
- break;
- case "sa_salesforecastbill":
- let url = detail.baseonproject == 1 ? '/packageA/finishforecast/detail' : '/packageA/invoiceforecast/detail';
- wx.navigateTo({
- url: url + "?id=" + detail.ownerid,
- })
- break;
- case "sys_phonebook":
- wx.navigateTo({
- url: `/packageA/contacts/detail?id=${detail.ownerid}&contactsid=0&sa_project_contactsid=0`,
- })
- break;
- case "sys_enterprise_contacts":
- wx.navigateTo({
- url: `/packageA/contacts/detail?id=0&contactsid=${detail.ownerid}&sa_project_contactsid=0`,
- })
- break;
- case "sa_project_contacts":
- wx.navigateTo({
- url: `/packageA/contacts/detail?id=0&contactsid=0&sa_project_contactsid=${detail.ownerid}`,
- })
- break;
- default:
- let data = authComparison.find(s => (s.objectname || "") == detail.ownertable);
- if (data) wx.navigateTo({
- url: data.path.split("/index")[0] + "/detail?id=" + detail.ownerid,
- })
- break;
- }
- }
- }
- },
- saOrder(sa_orderid) {
- _Http.basic({
- "id": 20221108151302,
- "content": {
- nocache: true,
- sa_orderid
- }
- }).then(res => {
- console.log("订单", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- let path = '';
- switch (res.data.type) {
- case '工具借用单':
- path = '/packageA/borrow/detail'
- break;
- case '借用归还单':
- path = '/packageA/toolBill/detail'
- break;
- default:
- path = '/packageA/orderForm/detail'
- break;
- }
- wx.navigateTo({
- url: path + '?id=' + sa_orderid,
- })
- });
- },
- satOrderclue(sat_orderclueid) {
- _Http.basic({
- "classname": "saletool.orderclue.web.orderclue",
- "method": "selectDetail",
- "version": 1,
- "content": {
- "nocache": true,
- sat_orderclueid
- },
- }).then(res => {
- console.log("线索详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.navigateTo({
- url: (res.data.isprivate ? '/packageA/saleClue/detail' : '/packageA/publicClue/detail') + '?id=' + sat_orderclueid,
- })
- });
- },
- saCustomer(sa_customersid) {
- _Http.basic({
- "id": 20221012164302,
- "content": {
- sa_customersid
- },
- }).then(res => {
- console.log("客户详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.navigateTo({
- url: (res.data.ispublic ? '/packageA/publicCustomer/detail' : '/packageA/setclient/detail') + '?id=' + sa_customersid,
- })
- });
- },
- getDetail() {
- _Http.basic({
- "id": 20221211111901,
- "content": {
- "nocache": true,
- "sys_taskid": this.data.sys_taskid
- },
- }).then(res => {
- console.log("任务详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- let tabbarList = [{
- icon: "icon-genjin",
- label: "跟进"
- }];
- if (res.data.status != '已完成') tabbarList.push({
- icon: "icon-dibu-chengjiao",
- label: "完成"
- })
- try {
- let isLeader = res.data.createuserid == wx.getStorageSync('userMsg').userid;
- if (isLeader) {
- tabbarList.splice(1, 0, {
- icon: "icon-shanchu",
- label: "删除"
- })
- tabbarList.splice(1, 0, {
- icon: "icon-guanlian-bianji",
- label: "编辑"
- })
- }
- } catch (error) {}
- this.setData({
- tabbarList,
- detail: res.data,
- briefs: [{
- label: "任务内容",
- value: res.data.remarks
- }, {
- label: "开始日期",
- value: res.data.starttime
- }, {
- label: "结束日期",
- value: res.data.endtime
- },
- {
- label: '关联应用数据',
- value: res.data.title
- }, {
- label: '状态',
- value: res.data.status
- }
- ],
- list1: [{
- label: "任务标题",
- value: res.data.title
- }, {
- label: "任务内容",
- value: res.data.remarks
- }, {
- label: "开始日期",
- value: res.data.starttime
- }, {
- label: "结束日期",
- value: res.data.endtime
- }, {
- label: "执行人",
- value: res.data.leader[0].name
- }, {
- label: "协助人",
- value: ""
- }, {
- label: '关联应用数据',
- value: res.data.title,
- color: "#085CDF",
- slot: 'title'
- }, {
- label: '状态',
- value: res.data.status
- }, {
- label: '完成说明',
- value: res.data.finishnotes
- }],
- list2: [{
- label: "创建人",
- value: res.data.createby
- }, {
- label: "创建时间",
- value: res.data.createdate
- }, {
- label: "最近编辑人",
- value: res.data.changeby
- }, {
- label: "最近编辑时间",
- value: res.data.changedate
- }, {
- label: "完成人",
- value: res.data.finishby
- }, {
- label: "完成时间",
- value: res.data.finishdate
- }, {
- label: "转手次数",
- value: res.data.leader.length ? res.data.leader[0].leadernum : 0
- }]
- });
- /* 更新列表中状态 */
- let page = getCurrentPages().find(v => v.__route__ == 'packageA/saleClue/index');
- if (page) {
- let index = page.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
- if (index != -1) page.setData({
- [`list[${index}].status`]: res.data.status,
- [`list[${index}].title`]: res.data.title,
- [`list[${index}].remarks`]: res.data.remarks
- })
- } else {
- let pages = getCurrentPages(),
- p = pages[pages.length - 2].selectComponent("#Work");
- if (p) {
- let index = p.data.list.findIndex(v => v.sys_taskid == res.data.sys_taskid);
- if (index != -1) p.setData({
- [`list[${index}].status`]: res.data.status,
- [`list[${index}].title`]: res.data.title,
- [`list[${index}].remarks`]: res.data.remarks
- })
- }
- }
- this.getTags();
- this.getGroup();
- this.partialRenewal();
- })
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- //更新标签
- getTags() {
- this.selectComponent("#Tags").getTags();
- },
- //更新团队成员
- getGroup() {
- this.selectComponent("#Group").getList().then(res => {
- let i = this.data.list1.findIndex(v => v.label == '协助人')
- this.setData({
- [`list1[${i}].value`]: res.filter(v => !v.isleader).map(v => v.name)
- })
- });
- },
- onClose() {
- this.setData({
- show: false
- });
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- let id = this.data.detail.sys_taskid;
- let model = '';
- let name = this.data.tabsList[this.data.tabsActive].label;
- switch (name) {
- case "操作":
- model = "#Record"
- break;
- case "跟进动态":
- model = "#Trace"
- break;
- case "附件":
- model = "#Files"
- break;
- };
- if (model) {
- // 确定好模块ID total = null 是第一次加载 加载数据
- // init是新增或修改需要清数据
- let Component = this.selectComponent(model);
- const {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- } else {
- //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
- }
- }
- },
- onReachBottom() {
- this.partialRenewal();
- },
- //详情按钮回调
- tabbarOnClick({
- detail
- }) {
- let that = this;
- switch (detail.label) {
- case "编辑":
- let group = this.selectComponent("#Group").query();
- wx.navigateTo({
- url: `/packageA/work/add?data=${JSON.stringify(this.data.detail)}&group=${JSON.stringify(group)}`,
- })
- break;
- case "完成":
- this.setData({
- confirmShow: true
- })
- break;
- case "跟进":
- wx.navigateTo({
- url: `/packageA/setclient/modules/trace/add/index?ownertable=sys_task&ownerid=${this.data.sys_taskid}`,
- })
- break;
- case "删除":
- wx.showModal({
- title: '提示',
- content: `是否要删除当前任务?`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20221211112601,
- "content": {
- "sys_taskids": [that.data.detail.sys_taskid]
- }
- }).then(res => {
- console.log("删除任务", res)
- wx.showToast({
- title: res.msg == '成功' ? '删除成功' : res.msg,
- icon: "none",
- mask: res.msg == '成功'
- })
- if (res.msg == '成功') setTimeout(() => {
- wx.navigateBack()
- }, 800)
- })
- }
- })
- break;
- }
- },
- onUnload() {
- let page = getCurrentPages()[getCurrentPages().length - 2]
- if (page.__route__ == 'packageA/work/index') {
- let content = JSON.parse(JSON.stringify(page.data.content));
- content.pageSize = (content.pageNumber - 1) * content.pageSize;
- content.pageNumber = 1;
- _Http.basic({
- id: '20220901162901',
- content
- }).then(res => {
- console.log("更新任务列表", res);
- if (res.msg == '成功') page.setData({
- list: res.data,
- "content.total": res.total
- })
- })
- } else {
- page.getTags && page.getTags()
- page.partialRenewal && page.partialRenewal(true)
- }
- },
- startSynchronization() {
- console.log("开始同步")
- wx.navigateTo({
- url: '/packageA/work/synchronization?data=' + JSON.stringify({
- ownertable: this.data.detail.ownertable,
- ownerid: this.data.detail.ownerid
- }),
- });
- _Http.selectSync = (item, ownertable) => {
- if (["sys_task", "sa_customers", "sa_project"].includes(ownertable)) {
- this.setData({
- finishnotes: `跟进类型:${item.type}\n跟进对象:${item.contacts ? item.contacts.join(","):""}\n${item.content}`
- })
- } else if (ownertable == 'sat_orderclue') {
- this.setData({
- finishnotes: `跟进类型:${item.followupmode}\n跟进内容:${item.content}`
- })
- } else {
- this.setData({
- finishnotes: '跟进内容:' + item.content
- })
- }
- wx.navigateBack()
- delete(_Http.selectSync)
- }
- },
- })
|