linwe
2024-08-08 3c738f4fe2762bba8087e5a22fc0dc06560eab0e
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
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
<template>
    <view class="wrap">
 
        <!-- <view class="info-row flex j-c-s-b a-i-c" @click="isShowPopup = true">
            <text class="f-28">场所名称</text>
            <view class="flex">
                <text class="mr-10">{{selectedPlace.placeName}}</text>
                <u-icon name="arrow-right"></u-icon>
            </view>
        </view> -->
 
        <view class="section mb-20">
            <u-collapse :value="itemIndex" ref="collapse">
                <u-collapse-item :title="item.title" :name="index" v-for="(item,index)  in questionList">
                    <u-form :model="info" ref="form">
                        <block v-for="(i,k) in item.children">
                            <view class="f-30 c-33">
                                {{i.title}}
                            </view>
                            <u-form-item labelWidth="90" prop="gateStatus">
                                <view class="btn-group flex">
                                    <view class="value-item" :class="i.state == 0?'active bgc-main c-ff':''"
                                        @click="changeStatus(0,i,index,k)">
                                        是
                                    </view>
                                    <view class="value-item" :class="i.state == 1?'active bgc-main c-ff':''"
                                        @click="changeStatus(1,i,index,k)">
                                        否
                                    </view>
                                </view>
                            </u-form-item>
                            <view class="" v-if="i.state == 1">
                                <u-form-item labelWidth="100" label="照片" prop="gateStatus">
                                    <u-upload :fileList="i.urls" :previewFullImage="uploadConfig.previewFullImage"
                                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture"
                                        @afterRead="afterReadImgs($event,i,index,k)"
                                        @delete="deleteImages($event,index,k)">
                                        <view class="upload-item upload-icon flex_base">
                                            <u-icon name="/static/icon/upload.png" width="60rpx"
                                                height="60rpx"></u-icon>
                                        </view>
                                    </u-upload>
                                </u-form-item>
                                <u-form-item labelWidth="100" label="描述" prop="gateStatus">
                                    <u-textarea v-model="i.remark" placeholder="请输入描述"
                                        placeholderClass="c-99 f-26"></u-textarea>
                                </u-form-item>
                            </view>
                        </block>
                    </u-form>
                </u-collapse-item>
            </u-collapse>
        </view>
 
        <!-- <view class="content bgc-ff" v-if="dangerCount > 0">
            <view class="upload ">
                <view class="flex j-c-s-b a-i-c" @click="showSelectDate = true">
                    <view class="f-28">整改截止时间</view>
                    <view class="flex a-i-c">
                        <text class="mr-10">{{info.rectificationEndTime}}</text>
                        <u-icon name="arrow-right"></u-icon>
                    </view>
                </view>
                <view class="mt-20">
                    <view class="f-28 mb-20">整改文件</view>
                    <u-upload :fileList="form.images" :previewFullImage="uploadConfig.previewFullImage"
                        :accept="uploadConfig.acceptImg" :multiple="uploadConfig.multiple"
                        :maxCount="uploadConfig.maxCount" :capture="uploadConfig.capture" @afterRead="afterReadImg"
                        @delete="deletePic">
                        <view class="upload-item upload-icon flex_base">
                            <u-icon name="/static/icon/upload.png" width="60rpx" height="60rpx"></u-icon>
                        </view>
                    </u-upload>
                </view>
            </view>
        </view> -->
 
        <!-- <footer-btn @click="sumitInfo"></footer-btn> -->
 
 
        <button class="submit-btn" @click="sumitInfo">提交</button>
        <button class="list-btn mb-20" @click="navTo">提交记录</button>
 
 
 
 
        <u-datetime-picker ref="datetimePicker" :show="showSelectDate" v-model="time" mode="datetime"
            :formatter="formatter" @confirm="confirmDate" @cancel="showSelectDate = false"></u-datetime-picker>
 
 
        <view class="blank"></view>
 
 
 
 
        <u-popup :show="isShowPopup" mode="bottom" :round="10" closeable="true" @close="isShowPopup = false">
            <view class="popup-content">
                <view class="popup-title f-30">选择场所</view>
                <u-search placeholder="请输入场所名称" :showAction="true" actionText="搜索" :animation="true" v-model="placeName"
                    @search="searchPlace" @custom="searchPlace" @clear="clearKeyword"></u-search>
                <scroll-view class="popup-list" :scroll-y="true">
                    <view class="popup-list-item" v-for="(i,k) in placeList" :key="k" @click="selectPlace(i)">
                        <view class="flex a-i-c mb-10">
                            <text class="f-28 fw mr-20">{{i.placeName}}</text>
                            <text class="f-26" v-if="i.phoneNumber">{{i.phoneNumber}}</text>
                        </view>
                        <!-- 
                        <view class="f-28">
                            {{i.townStreetName}}{{i.neiName}}{{i.aoiName}}{{i.address || ""}}
                        </view> -->
                        <view class="check-icon" v-if="i.houseCode == info.houseCode">
                            <u-icon name="checkbox-mark" color="#017BFC" size="30"></u-icon>
                        </view>
                    </view>
                </scroll-view>
            </view>
        </u-popup>
 
 
    </view>
</template>
 
<script>
    import uploadMixin from "@/mixin/uploadMixinPlace";
    import {
        getPlaceCheckItem
    } from "@/api/place/place.js"
 
    import {
        savePlaceCheck,
        getPlaceCheckDetail,
        updatePlaceCheck,
        auditPlaceCheck
    } from "@/api/reporting/reporting.js"
 
    export default {
        mixins: [uploadMixin],
        data() {
            return {
                form: {
                    images: []
                },
                info: {
                    remark: "",
                    imageUrls: "",
                    houseCode: ""
                },
 
                desc: "",
                title: "",
                curSelectSite: {},
                showSignature: false,
                signatureUrl: "",
                signatureSettings: { //签名设置
                    width: '700', //签名区域的宽
                    height: '800', //签名区域的高
                    lineWidth: 3, //签名时线宽
                    textColor: '#007AFF' //签名文字颜色
                },
                statusOption: [{
                        text: "存在",
                        value: 0
                    },
                    {
                        text: "不存在",
                        value: 1
                    },
                ],
                questionList: [],
                itemIndex: [],
                patrolRecordVOList: [],
                count: 0,
                statusList: [{
                        name: "是",
                        id: 2
                    },
                    {
                        name: "否",
                        id: 1
                    }
                ],
                time: Number(new Date()),
                showSelectDate: false,
                dangerCount: 0, //隐患项数量
                isEdit: false,
                isShowPopup: false,
                selectedPlace: {}
 
            }
        },
        async onLoad(option) {
            await this.getItem();
            this.isEdit = true;
            this.getDetail(option.taskId)
            // if (option.houseCode) {
            //     this.info.houseCode = option.houseCode;
            // }
 
        },
 
        methods: {
 
            getDetail(id) {
                getPlaceCheckDetail({
                    taskId: id
                }).then(res => {
                    let data = res.data;
                    for (let i = 0, ii = this.questionList.length; i < ii; i++) {
                        for (let k = 0, kk = this.questionList[i].children.length; k < kk; k++) {
                            for (let j = 0, jj = data.taskPlaceRecordVOList.length; j < jj; j++) {
                                if (this.questionList[i].children[k].id == data.taskPlaceRecordVOList[j].itemId) {
                                    let children = this.questionList[i]
                                    children.children[k].state = data.taskPlaceRecordVOList[j].state;
                                    if (data.taskPlaceRecordVOList[j].imageUrls) {
                                        children.children[k].urls = this.$setImageUrl(data.taskPlaceRecordVOList[j]
                                            .imageUrls, 2);
                                    }
                                    children.children[k].remark = data.taskPlaceRecordVOList[j].remark || "";
                                    this.$set(this.questionList, i, children)
                                }
                            }
                        }
                    }
                    this.info.id = data.id;
                    this.info.taskId = data.taskId;
                    this.info.remark = data.remark;
                    this.info.houseCode = data.houseCode;
 
                    if (data.signaturePath) {
                        this.signatureUrl = this.$setFullUrl(data.signaturePath);
                        this.info.signaturePath = data.signaturePath;
                    }
                    this.form.images = this.$setImageUrl(data.imageUrls, 2)
 
                })
            },
 
 
            getItem() {
                getPlaceCheckItem({
                    childType: 9,
                    type: 3
                }).then(res => {
                    let data = res.data;
                    this.questionList = res.data;
                    let arr = []
                    let obj = {
                        itemId: "",
                        state: "",
                        imagesUrl: "",
                        remark: ""
                    }
                    let count = 0;
                    for (let i = 0, ii = data.length; i < ii; i++) {
                        arr.push(i);
                        for (let k = 0, kk = data[i].children.length; k < kk; k++) {
                            // this.info.patrolRecordVOList.push(obj);
                            count += 1;
                        }
                    }
                    this.count = count;
                    this.itemIndex = arr;
                })
            },
 
            changeStatus(value, item, fIndex, cIndex) {
                let children = this.questionList[fIndex];
                children.children[cIndex].state = value;
                this.$set(this.questionList, fIndex, children)
                if (value == 0 && !item.urls) {
                    children.children[cIndex].urls = [];
                    this.$set(this.questionList, fIndex, children)
                }
                this.$nextTick(() => {
                    this.$refs.collapse.init();
                })
                this.getSelected()
            },
 
            getSelected() {
                let arr = [];
                let count = 0;
                for (let i = 0, ii = this.questionList.length; i < ii; i++) {
                    for (let k = 0, kk = this.questionList[i].children.length; k < kk; k++) {
                        if (this.questionList[i].children[k].state != null) {
                            arr.push({
                                itemId: this.questionList[i].children[k].id,
                                state: this.questionList[i].children[k].state,
                                imageUrls: this.setImages(this.questionList[i].children[k].urls),
                                remark: this.questionList[i].children[k].remark || "",
                                type: 3
                            })
                            if (this.questionList[i].children[k].state == 1) {
                                count += 1;
                            }
                        }
                    }
                }
                this.dangerCount = count;
                return arr;
            },
 
            setImages(key) {
                if (!key) {
                    return ""
                } else {
                    let urls = [];
                    for (let i of key) {
                        urls.push(i.name);
                    }
                    return urls.join(",")
                }
            },
 
            async afterReadImgs(event, item, fIndex, cIndex) {
                uni.showLoading({
                    title: "上传中..."
                })
                let children = this.questionList[fIndex];
                let lists = [].concat(event.file)
                let fileListLen = item.urls.length;
                lists.map((item) => {
                    children.children[cIndex].urls.push({
                        ...item,
                        status: 'uploading',
                        message: '上传中'
                    })
                    this.$set(this.questionList, fIndex, children)
                })
                for (let i = 0; i < lists.length; i++) {
                    const result = await this.uploadFilePromise(lists[i].url)
                    children.children[cIndex].urls.splice(fileListLen, 1, Object.assign({}, {
                        url: result.data.link,
                        name: result.data.name
                    }))
                    this.$set(this.questionList, fIndex, children)
                    fileListLen++
                }
                this.loadingClose()
                this.getSelected()
            },
 
            deleteImages(event, fIndex, cIndex) {
                let children = this.questionList[fIndex];
                children.children[cIndex].urls.splice(event.index, 1);
                this.$set(this.questionList, fIndex, children);
                this.getSelected()
            },
 
            signatureChange(e) {
                // this.signatureUrl = e;
                this.uploadSignImg(e)
            },
 
            showSignPopup() {
                // if (this.getSelected().length < this.count) {
                //     this.$showTips("还有内容还未完善");
                //     return;
                // }
 
                let data = this.getSelected();
                for (let i of data) {
                    if (i.state == 1) {
                        if (i.imageUrls || i.remark) {
                            i.imageUrls = "";
                            i.remark = "";
                        }
                    } else {
                        if (!i.imageUrls && !i.remark) {
                            this.$showTips("请上传隐患照片或填写隐患描述");
                            return;
                        }
                    }
                }
                this.showSignature = true;
            },
 
            uploadSignImg(url) {
                uni.uploadFile({
                    url: this.uploadConfig.url,
                    filePath: url,
                    name: 'file',
                    header: this.uploadConfig.header,
                    success: (res) => {
                        console.log(res);
                        let data = JSON.parse(res.data);
                        if (res.statusCode == 200 && data.code == 200) {
                            // this.handleSubmit(data.data.name);
                            this.showSignature = false;
                            this.signatureUrl = data.data.link;
                            this.info.signaturePath = data.data.name;
                            // this.sumitInfo()
                        }
                    }
                })
            },
 
            sumitInfo() {
                uni.showLoading({
                    title: "加载中..."
                })
                if (this.form.images.length > 0) {
                    let urls = []
                    this.form.images.forEach(e => {
                        urls.push(e.name)
                    })
                    this.info.rectificationNoticeImgUrl = urls.join(",")
                }
                if (!this.getSelected().length < this.count) {
                    this.$showTips("还未完善");
                    return;
                }
 
 
                this.info.taskPlaceRecordVOList = this.getSelected()
                this.info.status = 1;
                this.info.type = 2;
 
                auditPlaceCheck(this.info).then(res => {
                    uni.hideLoading();
                    uni.showToast({
                        icon: 'success',
                        title: '提交成功',
                        success() {
                            setTimeout(() => {
                                uni.navigateBack();
                            }, 300)
                        }
                    })
                })
 
            },
 
            previewImg() {
                uni.previewImage({
                    urls: [this.signatureUrl],
                    current: this.signatureUrl
                })
            },
 
            confirmDate(e) {
                this.showSelectDate = false;
                this.info.rectificationEndTime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM:ss')
            },
 
            navTo() {
                uni.navigateTo({
                    url: 'securityRecord'
                })
            },
 
        }
    }
</script>
 
<style lang="less">
    page {
        background-color: #f5f5f5;
    }
 
    .wrap {
        .section {
            padding: 0 20rpx;
            margin: 20rpx 20rpx 0;
            background-color: #fff;
        }
    }
 
    .top {
        display: flex;
        justify-content: flex-end;
        padding: 20rpx;
    }
 
    .top-btn {
        padding: 16rpx 22rpx;
        border-radius: 6rpx;
        text-align: center;
    }
 
    .content {
        margin: 20rpx;
        padding: 20rpx 30rpx;
    }
 
    .cell {
        margin: 0 20rpx;
        padding: 20rpx 30rpx;
    }
 
    .site-box {
        padding: 30rpx;
        margin: 20rpx 30rpx;
        border-radius: 4rpx;
 
        .c-aa {
            color: #aaa;
        }
 
        .address {
            width: 60%;
            margin-left: 25rpx;
        }
    }
 
    .upload-item {
        width: 140rpx;
        height: 140rpx;
        border: 1px solid #EEEEEE;
    }
 
    .upload {
        // margin: 0 30rpx;
        padding: 30rpx 0;
    }
 
    .submit-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .list-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .address-row {
        flex: 1;
        justify-content: flex-end;
        align-items: center;
    }
 
    .address-content {
        width: calc(100% - 116rpx - 20rpx);
        margin-right: 20rpx;
        text-align: right;
    }
 
    .location-btn {
        width: 116rpx;
        height: 46rpx;
        line-height: 46rpx;
        border-radius: 4rpx;
        border: 1px solid currentColor;
        padding: 0;
        background-color: #fff;
        text-align: center;
    }
 
 
    .signture-popup {
        padding-bottom: 20rpx;
    }
 
    .sign {
        padding: 30rpx;
        // margin: 0 30rpx;
    }
 
    .value-item {
        flex: 1;
        // background-color: #ffffff;
        // width: 120rpx;
        border: 2rpx solid #f5f5f5;
        height: 70rpx;
        line-height: 70rpx;
        box-sizing: border-box;
        text-align: center;
    }
 
    .active {
        border: 2rpx solid currentColor;
    }
 
    .btn-group {
        flex: 1;
    }
 
    /deep/ .u-cell__title-text {
        font-weight: bold;
        font-size: 30rpx;
    }
 
    /deep/ .u-form-item__body__left__content {
        font-size: 26rpx;
    }
 
    .blank {
        width: 100%;
        height: 140rpx;
    }
 
 
    .submit-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #01BDFC 0%, #017BFC 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
 
    .list-btn {
        width: 690rpx;
        height: 78rpx;
        line-height: 78rpx;
        background: linear-gradient(163deg, #c7d7dc 0%, #c3cdd8 100%);
        border-radius: 8rpx 8rpx 8rpx 8rpx;
        font-size: 32rpx;
        color: #fff;
        margin-top: 50rpx;
    }
</style>