王飞
2025-01-23 99365608dec6eade7d645a91fb0f2205a332d1f1
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
// pages/fireSafetymeasure/fireSafetymeasure.js
var req_url = getApp().globalData.base_url;
const app = getApp()
Page({
 
  /**
   * 页面的初始数据
   */
  data: {
    locknum:0,
    firesafetymeasure:'',
    opinion: '',
    bumen: '',
    zypcode:'',
    username : wx.getStorageSync('username'),
    phone : wx.getStorageSync('phone'),
    safetyMeasure: [
        {
            context: "作业前,制定交通组织方案,并已通知相关部门或单位",
            safetymeasure: '',
            refer: "",
            name:'',
            phone:'',
            lock:true,
        },
        {
            context: "作业前,在断路的路口和相关道路上设置交通警示标志,在作业区域附近设置路栏、道路作业警示灯、导向标等交通警示设施",
            safetymeasure: '',
            refer: "",
            name:'',
            phone:'',
            lock:true,
        },
        {
            context: "夜间作业设置警示灯",
            safetymeasure: '',
            refer: "",
            name:'',
            phone:'',
            lock:true,
        },
        {
            context: "",
            safetymeasure: '',
            refer: "",
            name:'',
            phone:'',
            lock:true,
        },
    ],
    
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
      console.log(options);
      this.setData({
        firesafetymeasure:options.safetymeasure,
        opinion: options.opinion,
        bumen: options.bumen,
        zypcode:options.zypcode
      })
      this.getList();
  },
  getList: function () {
    var that = this;
    console.log(that.data.zypcode);
    //请求后台数据
    wx.request({
        url: req_url + "/findCircuitCode",
        data: {
            code: that.data.zypcode,
        },
        method: 'get',
        success: function (res) {
 
            console.log(res);
            var datas = res.data;
            if (res.statusCode != 200) {
                wx.showToast({
                    title: '获取数据失败',
                    icon: 'none',
                    duration: 2000
                });
            } else {
                var zypd = []
                var json = {}
                json.context = that.data.safetyMeasure[0].context
                json.refer = datas.refer1
                json.safetymeasure = datas.safetymeasure1
                json.name = datas.safetymeasure1.split(',')[0]
                json.phone = datas.safetymeasure1.split(',')[1]
                if (wx.getStorageSync('username')==datas.safetymeasure1.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure1.split(',')[1]) {
                   console.log(11111);
                    json.lock=false
                }else{
                    that.setData({
                        locknum:that.data.locknum+1
                    })
                    json.lock=true
                }
                zypd.push(json)
                var json1 = {}
                json1.context = that.data.safetyMeasure[1].context
                json1.refer = datas.refer2
                json1.safetymeasure = datas.safetymeasure2
                json1.name = datas.safetymeasure2.split(',')[0]
                json1.phone = datas.safetymeasure2.split(',')[1]
                if (wx.getStorageSync('username')==datas.safetymeasure2.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure2.split(',')[1]) {
                    
                     json1.lock=false
                 }else{
                    that.setData({
                        locknum:that.data.locknum+1
                    })
                     json1.lock=true
                 }
                zypd.push(json1)
                if (datas.safetymeasureother!='') {
                var json2 = {}
                json2.context = that.data.safetyMeasure[2].context
                json2.refer = datas.refer3
                json2.safetymeasure = datas.safetymeasure3
                json2.name = datas.safetymeasure3.split(',')[0]
                json2.phone = datas.safetymeasure3.split(',')[1]
                if (wx.getStorageSync('username')==datas.safetymeasure3.split(',')[0]&&wx.getStorageSync('phone')==datas.safetymeasure3.split(',')[1]) {
                    
                     json2.lock=false
                 }else{
                    that.setData({
                        locknum:that.data.locknum+1
                    })
                     json2.lock=true
                 }
                zypd.push(json2)
            }else{
                var json2 = {}
                json2.context =''
                json2.refer = ''
                json2.safetymeasure = ''
                json2.name = ''
                json2.phone = ''
                that.setData({
                    locknum:that.data.locknum+1
                })
                json2.lock=true
                zypd.push(json2)  
                }
                var fenxian = []
                that.setData({
                    safetyMeasure: zypd,
                })
            }
        }
    })
},
 onChange(event) {
     var that = this;
     var zypd = []
     var json = {}
     json.context = that.data.safetyMeasure[0].context
     json.refer = that.data.safetyMeasure[0].refer
     json.lock = that.data.safetyMeasure[0].lock
     if (event.currentTarget.dataset.index==0) {
     
     json.refer = event.detail
    }
    zypd.push(json)
     var json1 = {}
     json1.context = that.data.safetyMeasure[1].context
     json1.refer = that.data.safetyMeasure[1].refer
     json1.lock = that.data.safetyMeasure[1].lock
     if (event.currentTarget.dataset.index==1) {
     json1.refer =event.detail
    }
     zypd.push(json1)
     var json2 = {}
     json2.context = that.data.safetyMeasure[2].context
     json2.refer = that.data.safetyMeasure[2].refer
     json2.lock = that.data.safetyMeasure[2].lock
     if (event.currentTarget.dataset.index==2) {
     json2.refer = event.detail
     }
     zypd.push(json2)
     
 
     var fenxian = []
     that.setData({
         safetyMeasure: zypd,
     })
    
     var fenxian = []
     that.setData({
         safetyMeasure: zypd,
     })
    // this.setData({
    //     safetyMeasure[1].refer: event.detail,
    // });
  },
  showBack() {
    wx.navigateBack({
        delta: 1
    })
},
  showPopup() {
    var that = this;
      var json = {}
      
        json.code= that.data.zypcode,
        json.refer1= that.data.safetyMeasure[0].refer,
        json.refer2= that.data.safetyMeasure[1].refer,
        json.refer3= that.data.safetyMeasure[2].refer,
 
 
    wx.navigateTo({
        url: '../safetyMeasureSign/safetyMeasureSign?opinion=' + that.data.opinion + '&bumen=' + that.data.bumen + '&name=' + that.data.zypcode+ '&url=/updateGround'+ '&refer=' + json
    })
 
},
  submitForm: function (e) {
    var that = this;
    console.log(that.data.zypcode);
    console.log(that.data.safetyMeasure[1].refer);
    wx.request({
        url: req_url + "/updateCircuit",
        method: 'post',
        data: {
            code: that.data.zypcode,
            refer1: that.data.safetyMeasure[0].refer,
            refer2: that.data.safetyMeasure[1].refer,
            refer3: that.data.safetyMeasure[2].refer,
            
        },
        header: {
            'Content-Type': 'application/json'
        },
        success: (res) => {
            if (res.errMsg == "request:ok") {
                wx.showToast({
                    title: '操作成功',
                    icon: 'success',
                    duration: 2000
                });
                wx.navigateBack({
                    delta: 1
                })
            } else {
                wx.showToast({
                    title: '操作失败',
                })
            }
        }
        // })
    });
  },
 
  uploadPerPic(url, back) {
    var name = ''
    var that=this
        name = 'sign'+that.data.zypcode+ wx.getStorageSync('phone');
    wx.uploadFile({
        url: req_url + "addsafetyMeasurepic",
        method: "POST",
        filePath: url,
        name: 'file',
        formData: {
            'opinion': that.data.opinion,
            'bumen': that.data.bumen,
            'name': name,
        },
        success(res) {
            console.log(res);
            back(res.data);
        },
        fail(e) { }
    })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
 
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    console.log(this.data.signtempFilePaths);
    if (this.data.signtempFilePaths!='') {
        var that = this;
        that.uploadPerPic(this.data.signtempFilePaths, function back(resp) {
        wx.request({
            url: req_url + "/updateCircuit",
            method: 'post',
            data: {
                username:wx.getStorageSync('username'),
                phone:wx.getStorageSync('phone'),
                sign: resp,
                code: that.data.zypcode,
                refer1: that.data.safetyMeasure[0].refer,
                refer2: that.data.safetyMeasure[1].refer,
                refer3: that.data.safetyMeasure[2].refer,
 
            },
            header: {
                'Content-Type': 'application/json'
            },
            success: (res) => {
                if (res.errMsg == "request:ok") {
                    var content = "用户:" + wx.getStorageSync('username') + "提交安全措施确认"
                            wx.request({
                                url: req_url + "/addZypLog",
                                method: 'post',
                                data: {
                                    name: wx.getStorageSync('username'),
                                    zyptype: "断路安全作业",
                                    // bumen: that.data.bumen,
                                    zypcode: that.data.zypcode,
                                    content: content,
                                },
                                header: {
                                    'Content-Type': 'application/json'
                                },
                                success: (res) => {
                                    console.log(res);
 
                                }
                            });
                    wx.showToast({
                        title: '操作成功',
                        icon: 'success',
                        duration: 2000
                    });
                    wx.navigateBack({
                        delta: 1
                    })
                } else {
                    wx.showToast({
                        title: '操作失败',
                    })
                }
            }
            // })
        });
    })
    }
 
  },
 
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {
 
  },
 
  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
 
  },
 
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {
 
  },
 
  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
 
  },
 
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {
 
  }
})