forked from nsjcy/frontEnd/nsjcy

liuwh
2020-05-09 6ee2429b63ff94f80a5c3e5db963ef77745b0094
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
// pages/progressQuery/progressQuery.js
const app = getApp();
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    src: app.globalData.imgUrl +'/image/bg.jpg',
    itemIcon: app.globalData.imgUrl +'/image/ceshi.jpg',
    icon: app.globalData.imgUrl +'/image/fzl.svg',
    user: app.globalData.imgUrl +'/image/user.svg',
    yes: app.globalData.imgUrl +'/image/yes.svg',
    add: app.globalData.imgUrl +'/image/add.svg',
    del: app.globalData.imgUrl +'/image/del.svg',
    disabled: false,
    imgdisabled:false,
    id: '',
    evalList: {},
    caseQuery: {},
    showTime:Date.now(),
    status: 0,
    auditOpinion: '',
    userType: ['请选择身份关系', '诉讼代理人','辩护人','近亲属'],
  },
 
 
  selectChange: function (e) {
    var name = e.currentTarget.dataset.name;
    this.setData({
      caseQuery: {
        ...this.data.caseQuery,
        [name]: e.detail.value
      }
    })
 
  },
 
  inputChange: function(e) {
    var name = e.currentTarget.dataset.name;
    this.setData({
      caseQuery: {
        ...this.data.caseQuery,
        [name]: e.detail.value
      }
    })
  },
 
  onLoad: function(option) {
    this.setData({
      id: option.id,
    })
    var userinfo = wx.getStorageSync("user");
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/caseQuery/find?id=' + that.data.id + '&openId=' + userinfo.wxUnionId,
      success: function(res) {
        if (res.data.code == 0) {
          var data = res.data.data.caseQuery;
          var status = data.status;
          if (status == 0) {
            that.setData({ imgdisabled: false })
          } else {
            that.setData({ imgdisabled: true })
          }
          var disabled = app.judgeDisable(status);
          data.userName = userinfo.userName;
          data.createrId = userinfo.id;
          if (!data.relation){
            data.relation = 0;
          }
          var attList = data.attachments || [];
          var evalList1001 = app.where(attList, {
            associateTypeId: 1001
          }) || [];
          var evalList1002 = app.where(attList, {
            associateTypeId: 1002
          }) || [];
          var evalList1003 = app.where(attList, {
            associateTypeId: 1003
          }) || [];
          var evalList1004 = app.where(attList, {
            associateTypeId: 1004
          }) || [];
          var evalList1014 = app.where(attList, {
            associateTypeId: 1014
          }) || [];
          var evalList = {
            evalList1001,
            evalList1002,
            evalList1003,
            evalList1004,
            evalList1014
          };
          for (var i in evalList) {
            evalList[i] = evalList[i].map(({
              path: pic,
              id
            }) => ({
              pic,
              id
            }))
          }
          that.setData({
            caseQuery: data,
            disabled: disabled,
            evalList,
            id: data.id,
            showTime: app.formatDate(data.createTime),
            status,
            auditOpinion: res.data.data.auditOpinion || ''
          })
        } else {
          wx.showModal({
            title: '提示',
            content: "请求失败!"
          })
        }
      }
    })
  },
 
  submit: function(e) {
    var caseQuery = this.data.caseQuery;
    var status = e.currentTarget.dataset.type;
    caseQuery.status = status;
    var title = '';
    if (status == "1") {
      if (!caseQuery.caseTitle) {
        return app.showModal("请填写案件名称!");
      }
      if (!caseQuery.unit) {
        return app.showModal("请填写工作单位!");
      }
      if (!caseQuery.relation) {
        return app.showModal("请填写身份关系!");
      }
      if (!caseQuery.content) {
        return app.showModal("请填写查询内容!");
      }
      const {
        evalList1001,
        evalList1002,
        evalList1003,
        evalList1004,
        evalList1014
      } = this.data.evalList;
 
      if (caseQuery.relation == 1 || caseQuery.relation == 2) {
        if (evalList1002.length == 0) {
          return app.showModal("请上传律师证!");
        }
        if (evalList1003.length == 0) {
          return app.showModal("请上传律师所函!");
        }
        if (evalList1004.length == 0) {
          return app.showModal("请上传授权委托书(或法律援助公函)!");
        }
      }
 
      if (caseQuery.relation == 3){
        if (evalList1001.length == 0) {
          return app.showModal("请上传申请人身份证正反面!");
        }
        if (evalList1001.length < 2) {
          return app.showModal("请至少上传两张身份证附件!")
        }
        if (evalList1014.length == 0) {
          return app.showModal("请上传关系证明!");
        }
      }
    }
    var that = this;
    wx.request({
      url: app.globalData.url + '/api/caseQuery/save',
      data: caseQuery,
      method: 'POST',
      header: {
        "Content-Type": "application/json"
      },
      success: function(res) {
        if (res.data.code == 0) {
          if (status == 0) {
            title = '保存草稿成功!';
          } else {
            title = '提交成功!';
          }
          wx.showToast({
            title,
            icon: 'success',
            duration: 2000
          })
          setTimeout(function(){
            wx.reLaunch({
              url: '../index/index',
            })
          }, 2000)
        } else {
          wx.showModal({
            title: '提示',
            content: "提交失败!"
          })
        }
      }
    })
  },
 
  //添加图片
  joinPicture: function(e) {
    var that = this;
    app.joinPicture(e, that)
  },
 
  // 删除图片
  clearImg: function(e) {
    var that = this;
    app.clearImg(e, that)
  },
 
  //预览图片
  previewImage: function(e) {
    app.previewImage(e)
  },
 
  goback: function() {
    wx.navigateBack({
      changed: true
    }); //返回上一页
  }
})