| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- const _Http = getApp().globalData.http;
- Component({
- options: {
- addGlobalClass: true
- },
- properties: {
- list: Array,
- changeTotal: Function,
- disabled:Boolean
- },
- data: {
- range: ['高层', '中层', '项目负责人']
- },
- methods: {
- handleItem(e) {
- const {
- name,
- item
- } = e.target.dataset,
- that = this;
- switch (name) {
- case "call":
- if (!item.phonenumber) return wx.showToast({
- title: '该用户手机号为空',
- icon: "none"
- })
- wx.makePhoneCall({
- phoneNumber: item.phonenumber,
- })
- break;
- case "delete":
- wx.showModal({
- title: '提示',
- content: `是否确认删除"${item.name}"`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": "20221111130904",
- "content": {
- sa_project_contactsids: [item.sa_project_contactsid],
- }
- }).then(res => {
- console.log("删除联系人", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.showToast({
- title: `删除成功!`,
- icon: "none"
- })
- getCurrentPages().forEach(v => {
- if (v.selectComponent("#Contacts")) {
- const page = v.selectComponent("#Contacts");
- page.setData({
- list: page.data.list.filter(v => v.contactsid != item.contactsid)
- });
- page.changeTotal();
- } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
- v.setData({
- list: v.data.list.filter(v => v.contactsid != item.contactsid),
- 'content.total': v.data.content.total - 1
- });
- } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
- wx.navigateBack()
- }
- })
- })
- }
- })
- break;
- case "edit":
- wx.navigateTo({
- url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
- })
- break;
- }
- },
- bindPickerChange(e) {
- let item = e.currentTarget.dataset.item,
- tag = this.data.range[e.detail.value];
- if (item.tag == tag) return;
- _Http.basic({
- "id": 20221119103902,
- "content": {
- "sa_project_contactsid": item.sa_project_contactsid,
- tag,
- },
- }).then(res => {
- console.log("修改关联客户类型", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- this.setData({
- [`list[${this.data.list.findIndex(v=>v.sa_project_contactsid==item.sa_project_contactsid)}].tag[0]`]: tag
- });
- wx.showToast({
- title: `已更改“${item.name}”联系人类型为“${tag}”`,
- icon: "none"
- })
- })
- },
- }
- })
|