Ver Fonte

添加任务删除

xiaohaizhao há 2 anos atrás
pai
commit
60eaf804ba
1 ficheiros alterados com 63 adições e 15 exclusões
  1. 63 15
      packageA/work/detail.js

+ 63 - 15
packageA/work/detail.js

@@ -173,20 +173,26 @@ Page({
                 title: res.msg,
                 icon: "none"
             });
-
-            let isCreateby = res.data.createuserid == wx.getStorageSync('userMsg').userid,
-                tabbarList = [{
-                    icon: "icon-genjin",
-                    label: "跟进"
-                }, {
-                    icon: "icon-dibu-chengjiao",
-                    label: "完成"
-                }];
-            if (isCreateby) tabbarList.splice(1, 0, {
-                icon: "icon-guanlian-bianji",
-                label: "编辑"
-            })
-
+            let tabbarList = [{
+                icon: "icon-genjin",
+                label: "跟进"
+            }, {
+                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,
@@ -335,6 +341,7 @@ Page({
     tabbarOnClick({
         detail
     }) {
+        let that = this;
         switch (detail.label) {
             case "编辑":
                 let group = this.selectComponent("#Group").query();
@@ -342,7 +349,6 @@ Page({
                     url: `/packageA/work/add?data=${JSON.stringify(this.data.detail)}&group=${JSON.stringify(group)}`,
                 })
 
-
                 break;
             case "完成":
                 this.setData({
@@ -354,6 +360,48 @@ Page({
                     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().find(v => v.__route__ == 'packageA/work/index')
+        if (page) {
+            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
+                })
+            })
         }
     }
 })