const _Http = getApp().globalData.http; Component({ properties: { disabled: { type: Boolean } }, data: { "sa_projectid": null, content: { nocache: true, pageNumber: 1, pageTotal: 1, pageSize: 10, total: null, where: { condition: "", } }, }, lifetimes: { attached: function () { getApp().globalData.Language.getLanguagePackage(this) } }, methods: { /* 获取地址列表 */ getList(id, init) { let content = this.data.content; content.sa_projectid = id; if (init) { content.pageNumber = 1 content.pageTotal = 1 } _Http.basic({ "id": "20221027143702", content }).then(res => { console.log("关联客户列表", res) if (res.code != '1') return wx.showToast({ title: res.data, icon: "none" }) this.setData({ list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data), "content.pageNumber": res.pageNumber + 1, "content.pageSize": res.pageSize, "content.pageTotal": res.pageTotal, "content.total": res.total, sa_projectid: id }) this.getTags(); }) }, /* 获取列表标签 */ getTags() { let list = this.data.list, ownerids = list.map(v => v.sa_customersid); _Http.basic({ "id": 20221018102001, "content": { "ownertable": "sa_customers", ownerids } }).then(res => { console.log("标签", res) for (let key in res.data) { let index = list.findIndex(v => v.sa_customersid == key); if (index != -1) list[index].tags = res.data[key] }; this.setData({ list }) }) }, fastCallBack({ detail }) { const that = this; switch (detail.name) { case 'delete': wx.showModal({ title: getApp().globalData.Language.getMapText('提示'), content: getApp().globalData.Language.getMapText('是否确认删除') + `"${detail.item.enterprisename}"?`, cancelText: getApp().globalData.Language.getMapText('取消'), confirmText: getApp().globalData.Language.getMapText('确定'), complete: ({ confirm }) => { if (confirm) _Http.basic({ "id": 20221027143802, "content": { "sa_project_partiesids": [detail.item.sa_project_partiesid], sa_projectid: detail.item.sa_projectid }, }).then(res => { if (res.code != '1') return wx.showToast({ title: res.data, icon: "none" }); that.setData({ list: that.data.list.filter(v => v.sa_project_partiesid != detail.item.sa_project_partiesid), 'content.total': that.data.content.total - 1 }); wx.showToast({ title: getApp().globalData.Language.getMapText('已删除') + `"${detail.item.enterprisename}"`, icon: "none" }) }) } }) break; default: break; } }, /* 添加关联 */ submit(content = false) { if (!content) return; _Http.basic({ "id": 20221111102902, content }).then(res => { console.log("批量添加客户", res) if (res.code != '1') return wx.showToast({ title: res.data, icon: "none" }); getApp().globalData.Language.showToast('添加成功') setTimeout(() => { this.getList(content.sa_projectid, true); wx.navigateBack(); }, 300) }) } } })