Browse Source

填写金额未携带回去问题

xiaohaizhao 1 year ago
parent
commit
608715a149
2 changed files with 35 additions and 27 deletions
  1. 32 22
      Eservice/nodeDetail/index.js
  2. 3 5
      Eservice/nodeDetail/index.wxml

+ 32 - 22
Eservice/nodeDetail/index.js

@@ -1,5 +1,6 @@
 import api from '../api/api';
-const _Http = getApp().globalData.http
+const _Http = getApp().globalData.http;
+let deleteUsers = [];
 Page({
   data: {
     stopClick: '',
@@ -39,12 +40,15 @@ Page({
       "id": "20230209091103",
       "version": 1,
       "content": {
+        nocache: true,
         "sa_workorderid": this.data.sa_workorderid,
         "sa_workorder_nodeid": this.data.sa_workorder_nodeid
       }
     })
+    console.log("详情", res.data)
     this.setData({
       mainData: res.data[0],
+      teams: res.data[0].team.map(v => v.userid),
       titems: res.data[0].titems
     })
     this.setDefaultData()
@@ -209,7 +213,6 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-    console.log(options)
     this.data.bindContractData.ownerid = options.id
     this.data.bindNormalData.ownerid = options.id
     this.data.bindSignNameData.ownerid = options.id
@@ -237,16 +240,12 @@ Page({
       SignName: false
     })
   },
-
   /**
    * 开始添加成员或者取消添加
    */
   showTeamDialog() {
     this.setData({
-      showTeams: !this.data.showTeams,
-      teams: this.data.mainData.team.map(v => {
-        return v.isleader == 1 ? 0 : v.userid
-      })
+      showTeams: !this.data.showTeams
     })
   },
   /**
@@ -257,9 +256,9 @@ Page({
       userid
     } = e.currentTarget.dataset.item;
     let teams = this.data.teams;
-    let i = teams.findIndex(v => v == userid);
-    if (i != -1) {
+    if (teams.some(v => v == userid)) {
       teams = teams.filter(v => v != userid)
+      deleteUsers.push(userid);
     } else {
       teams.push(userid)
     }
@@ -269,23 +268,34 @@ Page({
   },
   addUser(init = true) {
     api._post({
-      "id": 20220930103603,
+      "id": 20220930103803,
       "content": {
         ownertable: 'sa_workorder_node',
         ownerid: this.data.mainData.sa_workorder_nodeid,
-        "userids": this.data.teams
-      }
-    }).then(res => {
-      console.log("添加成员", res)
-      wx.showToast({
-        title: res.msg == '成功' ? '修改成功' : res.msg,
-        icon: "none",
-        mask: true
-      });
-      if (res.msg == '成功') {
-        this.nodeDetail();
-        if (init) this.showTeamDialog();
+        "userids": deleteUsers
       }
+    }).then(s => {
+      console.log("先删除", s)
+      deleteUsers = [];
+      api._post({
+        "id": 20220930103603,
+        "content": {
+          ownertable: 'sa_workorder_node',
+          ownerid: this.data.mainData.sa_workorder_nodeid,
+          "userids": this.data.teams
+        }
+      }).then(res => {
+        console.log("添加成员", res)
+        wx.showToast({
+          title: res.msg == '成功' ? '修改成功' : res.msg,
+          icon: "none",
+          mask: true
+        });
+        if (res.msg == '成功') {
+          this.nodeDetail();
+          if (init) this.showTeamDialog();
+        }
+      })
     })
 
   },

+ 3 - 5
Eservice/nodeDetail/index.wxml

@@ -16,10 +16,9 @@
     </view>
   </card>
   <view style="margin-bottom: 5px;" class="small"><text class="label">参与人</text></view>
-
-  <card>
+  <card bindtap="showTeamDialog">
     <text class="label">参与人:</text>
-    <view slot="content" bindtap="showTeamDialog">
+    <view slot="content">
       <view wx:if="{{mainData.team.length === 0}}">
         <text class="small">暂无参与人</text>
       </view>
@@ -28,7 +27,6 @@
       </view>
     </view>
   </card>
-
   <t-dialog visible="{{showTeams}}" title="参与成员" confirm-btn="确定" cancel-btn="取消" bind:confirm="addUser" bind:cancel="showTeamDialog">
     <view slot="content">
       <view style="height: 40rpx;" />
@@ -98,7 +96,7 @@
     </view>
     <card>
       <view style="flex:1" slot="content">
-        <t-input default-value="{{form.amount}}" label="输入金额" placeholder="输入金额" bind:blur="amountPay" borderless></t-input>
+        <t-input default-value="{{form.amount}}" value='{{form.amount||0}}' label="输入金额" placeholder="输入金额" bind:blur="amountPay" borderless></t-input>
       </view>
     </card>
   </view>