Admin
2022-10-11 75ffe344e591348402a5a302d85f01653ab71bc8
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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
<template>
    <div class="home-container">
        <div style="height: 100%">
        <el-form :model="form" label-width="150px" :rules="applyRules" ref="ruleFormRef">
            <div class="homeCard">
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业人" prop="operatorUids">
                        <el-select v-model="form.operatorUids" multiple>
                            <el-option
                                    v-for="item in workerList"
                                    :key="item.uid"
                                    :label="item.username"
                                    :value="item.uid"
                            />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="作业时间" prop="workTimeLine">
                        <el-date-picker
                                v-model="form.workTimeLine"
                                format="YYYY-MM-DD HH:mm"
                                value-format="YYYY-MM-DD HH:mm:00"
                                type="datetimerange"
                                range-separator="至"
                                start-placeholder="开始时间"
                                end-placeholder="结束时间"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业等级" prop="workLevel">
                        <el-select v-model="form.workLevel">
                            <el-option
                                    v-for="item in workLevelList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                            />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="作业内容" prop="workContent">
                        <el-input
                                v-model="form.workContent"
                                autosize
                                type="textarea"
                                placeholder="请输入作业内容"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业地址" prop="workLocation">
                        <el-input
                                v-model="form.workLocation"
                                autosize
                                type="textarea"
                                placeholder="请输入作业地址"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="危害辨识" prop="hazardIdentification">
                        <el-input
                                v-model="form.hazardIdentification"
                                placeholder="请输入危害辨识"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
                <el-divider border-style="dashed"/>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="盲板编号" prop="workDetail.bpCode">
                        <el-input
                                v-model="form.workDetail.bpCode"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="主要介质" prop="workDetail.mainMedia">
                        <el-input
                                v-model="form.workDetail.mainMedia"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="温度" prop="workDetail.temperature">
                        <el-input
                                v-model="form.workDetail.temperature"
                                type="number"
                                placeholder="请输入"
                        >
                            <template #append>摄氏度(℃)</template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="压力" prop="workDetail.pressure">
                        <el-input
                                v-model="form.workDetail.pressure"
                                type="number"
                                placeholder="请输入"
                        >
                            <template #append>千帕(kPa)</template>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="盲板材质" prop="workDetail.bpMaterialQuality">
                        <el-input
                                v-model="form.workDetail.bpMaterialQuality"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="盲板规格" prop="workDetail.bpSpecification">
                        <el-input
                                v-model="form.workDetail.bpSpecification"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="盲板时间" prop="workDetail.installLine">
                        <el-date-picker
                                v-model="form.workDetail.installLine"
                                format="YYYY-MM-DD HH:mm"
                                value-format="YYYY-MM-DD HH:mm:00"
                                type="datetimerange"
                                range-separator="--"
                                start-placeholder="装盲板时间"
                                end-placeholder="拆盲板时间"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="盲板位置" prop="workDetail.bpLocation">
                        <el-input
                                v-model="form.workDetail.bpLocation"
                                autosize
                                type="textarea"
                                placeholder="请输入"
                        />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="关联作业" prop="workDetail.otherSpecialWork">
                        <el-select v-model="form.workDetail.otherSpecialWork" multiple>
                            <el-option
                                    v-for="item in otherWorkList"
                                    :key="item.value"
                                    :label="item.label"
                                    :value="item.value"
                            />
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label="盲板位置图" prop="workDetail.bpLocationMapPath">
                        <el-upload accept="image/*" :on-exceed="showTip" :on-preview="handlePictureCardPreview" :limit='imgLimit' v-model:file-list="fileList" :http-request="upload" :action="uploadUrl" list-type="picture-card" :on-remove="handleRemove" :before-remove="beforeRemove" :before-upload="getUploadUrl">
                            <el-icon><Plus /></el-icon>
                            <template #tip>
                                <div class="el-upload__tip">上传jpg/png图片尺寸小于500KB,最多可上传3张</div>
                            </template>
                        </el-upload>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="选择关联物资">
                        <el-button type="primary" @click="getMaList">选择物资标准</el-button>
                    </el-form-item>
                </el-col>
            </el-row>
            </div>
        </el-form>
        <el-dialog v-model="equipmentDialog" title="关联物资标准" width="40%" center @close="closeMaterial">
            <el-tabs tab-position="left" class="demo-tabs" type="border-card">
                <el-tab-pane v-for="(item,index) in materialList" :label="item.materialTypeName" :key="index">
                    <div style="margin-bottom: 20px">
                        <el-form label-width="150px" label-position="top">
                            <div v-if="item.mustList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">必选</div>
                            <el-form-item v-if="item.mustList.length>0" class="tab-i" v-for="(i,x) in item.mustList" :key="x" :label="item.mustList[x].materialName + ':'" prop="defaultVal" :rules="[{ type: 'defaultVal', required: true, message: '该内容不能为空', trigger: 'blur'}]">
                                <el-input size="default" type="number" v-model="item.mustList[x].value" @change="(val)=>toZero(val,index,'mustList',x)" placeholder="请输入配置数量,空值默认为0">
                                    <template #append>{{'库存:' + item.mustList[x].stock}}</template>
                                </el-input>
                            </el-form-item>
                            <div v-if="item.unList.length>0" style="width: 100%;border-bottom: 1px solid #ccc;padding-bottom: 6px;margin-bottom: 10px;font-weight: bolder">其他</div>
                            <el-form-item v-if="item.unList.length>0" class="tab-i" v-for="(i,x) in item.unList" :key="x" :label="item.unList[x].materialName + ':'">
                                <el-input size="default" type="number" v-model="item.unList[x].value" @change="(val)=>toZero(val,index,'unList',x)" placeholder="请输入配置数量,空值默认为0">
                                    <template #append>{{'库存:' + item.unList[x].stock}}</template>
                                </el-input>
                            </el-form-item>
                        </el-form>
                    </div>
                </el-tab-pane>
            </el-tabs>
            <template #footer>
            <span class="dialog-footer">
                <el-button @click="equipmentDialog = false" size="default">取消</el-button>
                <el-button type="primary" @click="conFirmDevices" size="default">确认</el-button>
            </span>
            </template>
        </el-dialog>
        <div class="applyBtn">
            <el-button type="primary" size="large" plain @click="submitForm(ruleFormRef)">发起申请</el-button>
        </div>
    </div>
    <el-dialog v-model="dialogVisible">
        <img w-full :src="dialogImageUrl" alt="Preview Image" />
    </el-dialog>
    </div>
</template>
 
<script lang="ts">
    import { toRefs, reactive, defineComponent, ref, defineAsyncComponent } from 'vue';
    import { storeToRefs } from 'pinia';
    import { initBackEndControlRoutes } from '/@/router/backEnd';
    import {useUserInfo} from "/@/stores/userInfo";
    import { Session } from '/@/utils/storage';
    import { Search } from '@element-plus/icons-vue'
    import { ElMessage, ElMessageBox } from 'element-plus'
    import type { FormInstance, FormRules, UploadProps, UploadUserFile } from 'element-plus'
    import { workApplyApi } from '/@/api/specialWorkSystem/workApply';
    import axios from 'axios';
 
    interface stateType {
        form: Object,
        csDepList: Array<any>,
        otherWorkList: Array<any>,
        workLevelList: Array<any>,
        fileList: Array<file>,
        uploadUrl: string,
        dialogVisible: Boolean,
        dialogImageUrl: string | null,
        imgLimit: number,
        isOverSize: boolean,
        equipmentDialog: boolean,
        materialList: Array<any>
    }
    interface file {
        url: string;
    }
    export default defineComponent({
        name: 'plateForm',
        components: {},
        props:['workerList'],
        setup() {
            const userInfo = useUserInfo()
            const { userInfos } = storeToRefs(userInfo);
            const state  = reactive<stateType>({
                equipmentDialog: false,
                materialList: [],
                form: {
                    operatorUids: [],
                    workType: 8,
                    workLevel: null,
                    workContent: '',
                    workLocation: '',
                    hazardIdentification: '',
                    workDetail:{
                        bpCode: '',
                        mainMedia: '',
                        temperature: null,
                        pressure: null,
                        bpMaterialQuality: '',
                        bpSpecification: '',
                        bpLocation: '',
                        bpLocationMapPath: [],
                        installLine: [],
                        installBpTime: '',
                        uninstallBpTime: '',
                        otherSpecialWork: []
                    },
                    wmAddReqDTOList: [],
                    workTimeLine: [],
                    expStartTime: '',
                    expEndTime: ''
                },
                isOverSize: false,
                fileList: [],
                imgLimit: 3,
                uploadUrl: '',
                dialogVisible: false,
                dialogImageUrl: null,
                workLevelList: [
                    {
                        label: "抽盲板作业",
                        value: 11
                    },
                    {
                        label: "堵盲板作业",
                        value: 12
                    }
                ],
                csDepList: [
                    {
                        label: "单位一",
                        value: 1
                    },
                    {
                        label: "单位二",
                        value: 2
                    },
                    {
                        label: "单位三",
                        value: 3
                    },
                    {
                        label: "单位四",
                        value: 4
                    },
                    {
                        label: "单位五",
                        value: 5
                    },
                    {
                        label: "单位六",
                        value: 6
                    }
                ],
                otherWorkList: [
                    {
                        label: "动火作业",
                        value: 1
                    },
                    {
                        label: "受限空间作业",
                        value: 2
                    },
                    {
                        label: "吊装作业",
                        value: 3
                    },
                    {
                        label: "动土作业",
                        value: 4
                    },
                    {
                        label: "断路作业",
                        value: 5
                    },
                    {
                        label: "高处作业",
                        value: 6
                    },
                    {
                        label: "临时用电作业",
                        value: 7
                    },
                    {
                        label: "盲板抽堵作业",
                        value: 8
                    }
                ]
            });
            const ruleFormRef = ref<FormInstance>()
            const applyRules = reactive<FormRules>({
                operatorUids: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workType: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workLevel: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workContent: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workLocation: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                hazardIdentification: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                workTimeLine: [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bpCode": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.mainMedia": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.temperature": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.pressure": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bpMaterialQuality": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bpSpecification": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.installLine": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bpLocation": [{ required: true, message: '该内容不能为空', trigger: 'blur' }],
                "workDetail.bpLocationMapPath": [{ required: true, message: '该内容不能为空', trigger: 'blur' }]
            });
 
            const toZero = (value: string | number,index: number,name: string,x:number) =>{
                if(!value){
                    state.materialList[index][name][x].value = 0
                }
            }
 
            const submitForm = async (formEl: FormInstance | undefined) => {
                if (!formEl) return
                await formEl.validate(async (valid, fields) => {
                    if (valid) {
                        for(let i in state.materialList){
                            for(let j in state.materialList[i].mustList){
                                if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){
                                    ElMessage({
                                        type: 'warning',
                                        message: '部分物资库存不足,请重新配置数量。'
                                    });
                                    return
                                }
                            }
                            for(let j in state.materialList[i].unList){
                                if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){
                                    ElMessage({
                                        type: 'warning',
                                        message: '部分物资库存不足,请重新配置数量。'
                                    });
                                    return
                                }
                            }
                            state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
                                const obj = {
                                    defaultVal: item.value,
                                    id: item.id
                                }
                                return {...obj}
                            })
                            state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
                                const obj = {
                                    defaultVal: item.value,
                                    id: item.id
                                }
                                return {...obj}
                            })
                            state.materialList[i].postList = [...state.materialList[i].mustList,...state.materialList[i].unList]
                            state.form.wmAddReqDTOList = [...state.form.wmAddReqDTOList,...state.materialList[i].postList]
                        }
                        state.form.expStartTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[0]
                        state.form.expEndTime = JSON.parse(JSON.stringify(state.form.workTimeLine))[1]
                        state.form.workDetail.installBpTime = JSON.parse(JSON.stringify(state.form.workDetail.installLine))[0]
                        state.form.workDetail.uninstallBpTime = JSON.parse(JSON.stringify(state.form.workDetail.installLine))[1]
                        let { workTimeLine, ...data } = JSON.parse(JSON.stringify(state.form))
                        let { installLine, ...data2 } = JSON.parse(JSON.stringify(state.form.workDetail))
                        data.workDetail = data2
                        data.workDetail.otherSpecialWork = data.workDetail.otherSpecialWork.join(',')
                        data.workDetail.bpLocationMapPath = data.workDetail.bpLocationMapPath.join(',')
                        data.workDetail.temperature = Number(data.workDetail.temperature)
                        data.workDetail.pressure = Number(data.workDetail.pressure)
                        const res = await workApplyApi().postPlateApply(data)
                        if (res.data.code === '200') {
                                ElMessage({
                                    type: 'success',
                                    message: '提交成功!'
                                });
                                formEl.resetFields()
                                state.form.workDetail.bpLocationMapPath = []
                                state.fileList = []
                        } else {
                            ElMessage({
                                type: 'warning',
                                message: res.data.msg
                            });
                        }
                        state.materialList = []
                    } else {
                        console.log('error submit!', fields)
                    }
                })
            }
            const handlePreview: UploadProps['onPreview'] = (uploadFile) => {
                console.log(uploadFile);
            };
 
            const handlePictureCardPreview = (uploadFile: { url: string }) => {
                state.dialogImageUrl = uploadFile.url!;
                state.dialogVisible = true;
            };
 
            const getUploadUrl = async (rawFile: any) => {
                const fileSize = rawFile.size / 1024 < 500 ? '1' : '0'
                if(fileSize === '0'){
                    ElMessage({
                        type: 'warning',
                        message: '文件大小不能超过500k。'
                    });
                    state.isOverSize = true
                    return false
                }else{
                    const res = await workApplyApi().getUploadUrl(rawFile.name);
                    state.form.workDetail.bpLocationMapPath.push(res.data.data.fileName)
                    state.uploadUrl = res.data.data.uploadUrl;
                    console.log(res.data.data.fileName,'name')
                }
            };
 
            const upload = async (params: any) => {
                // const formData = new FormData();
                // formData.append('file', state.fileList[0].raw);
                let reader = new FileReader();
                reader.readAsArrayBuffer(params.file);
                reader.onload = async () => {
                    axios
                            .put(state.uploadUrl, reader.result, {
                                header: { 'Content-Type': 'multipart/form-data' }
                            })
                            .then(() => {
                                // if (state.fileList.length === 2) {
                                //     state.fileList.splice(0, 1);
                                // }
                                // console.log(state.form.workDetail.bpLocationMapPath,'bpLocationMapPath')
                            });
                };
            };
 
            const beforeRemove = (file: {}, fileList: []) => {
                const result = new Promise((resolve, reject) => {
                    if(!state.isOverSize){
                        ElMessageBox.confirm('此操作将删除该图片, 是否继续?', '提示', {
                            confirmButtonText: '确定',
                            cancelButtonText: '取消',
                            type: 'warning'
                        })
                                .then(() => {
                                    // console.log(state.workDetail.bpLocationMapPath,'path')
                                    const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
                                    fileList.map((item,index)=>{
                                        if(item.uid === file.uid){
                                            fileList.splice(index,1)
                                            state.form.workDetail.bpLocationMapPath.splice(index,1)
                                            deletePic(false,list[index])
                                        }
                                    })
                                    // 请求删除接口
                                })
                                .catch(() => {
                                    reject(false);
                                });
                    }else{
                        const list = JSON.parse(JSON.stringify(state.form.workDetail.bpLocationMapPath))
                        fileList.map((item,index)=>{
                            if(item.uid === file.uid){
                                fileList.splice(index,1)
                                state.form.workDetail.bpLocationMapPath.splice(index,1)
                                deletePic(true,list[index])
                            }
                        })
                        state.isOverSize = false
                    }
                });
                return result;
            };
 
 
            // 删除图片接口
            const deletePic = async(isOverSize:boolean,fileName:string)=>{
                console.log(fileName,'fileName')
                const res = await workApplyApi().deleteFile({fileName: fileName})
                if (res.data.code === '200') {
                    ElMessage({
                        type: isOverSize ? 'error' : 'success',
                        message: isOverSize ? '上传失败':'删除成功!'
                    });
                } else {
                    ElMessage({
                        type: 'warning',
                        message: res.data.msg
                    });
                }
            }
            const showTip =()=>{
                ElMessage({
                    type: 'warning',
                    message: '超出文件上传数量'
                });
            }
 
            // 确认物资标准
            const getMaList = async() =>{
                if(state.materialList.length == 0){
                    const data = {workType: 8,workLevel: state.form.workLevel}
                    const res = await workApplyApi().getMaterial(data)
                    if (res.data.code === '200') {
                        state.materialList = JSON.parse(JSON.stringify(res.data.data.materialTypeList))
                        for(let i in state.materialList){
                            state.materialList[i].mustList = []
                            state.materialList[i].unList = []
                            state.materialList[i].mdList = state.materialList[i].mdList?.map((item:any) => {
                                if(item.configurationLevel == 0){
                                    state.materialList[i].mustList.push(item)
                                    return
                                }else{
                                    state.materialList[i].unList.push(item)
                                    return
                                }
                            })
                            state.materialList[i].mustList = state.materialList[i].mustList.map((item:any)=>{
                                const obj = {
                                    value: item.defaultVal,
                                    materialName: item.materialName,
                                    configurationLevel: item.configurationLevel,
                                    id: item.id,
                                    stock: item.stock
                                }
                                return {...obj}
                            })
                            state.materialList[i].unList = state.materialList[i].unList.map((item:any)=>{
                                const obj = {
                                    value: item.defaultVal,
                                    materialName: item.materialName,
                                    configurationLevel: item.configurationLevel,
                                    id: item.id,
                                    stock: item.stock
                                }
                                return {...obj}
                            })
                        }
                        state.equipmentDialog = true
                    } else {
                        ElMessage({
                            type: 'warning',
                            message: res.data.msg
                        });
                    }
                }else{
                    state.materialList = state.materialList
                    state.equipmentDialog = true
                }
            }
            const conFirmDevices = ()=>{
                for(let i in state.materialList){
                    for(let j in state.materialList[i].mustList){
                        if(state.materialList[i].mustList[j].value>state.materialList[i].mustList[j].stock){
                            ElMessage({
                                type: 'warning',
                                message: '部分物资库存不足,请重新配置数量。'
                            });
                            return
                        }
                    }
                    for(let j in state.materialList[i].unList){
                        if(state.materialList[i].unList[j].value>state.materialList[i].unList[j].stock){
                            ElMessage({
                                type: 'warning',
                                message: '部分物资库存不足,请重新配置数量。'
                            });
                            return
                        }
                    }
 
                }
                ElMessageBox.confirm('是否确认物资及数量配置?')
                        .then(() => {
                            state.equipmentDialog = false
                        })
                        .catch(() => {
                            // catch error
                        })
            }
 
            const closeMaterial = ()=>{
 
            }
 
            // 折线图
            const renderMenu = async (value: string) => {
                Session.set('projectId',value)
                userInfos.value.projectId = value
                await initBackEndControlRoutes();
            };
            return {
                renderMenu,
                Search,
                ruleFormRef,
                applyRules,
                toZero,
                getMaList,
                conFirmDevices,
                closeMaterial,
                handlePreview,
                getUploadUrl,
                beforeRemove,
                upload,
                showTip,
                submitForm,
                handlePictureCardPreview,
                ...toRefs(state),
            };
        },
    });
</script>
 
<style scoped lang="scss">
    .home-container {
        height: 100%;
        overflow: hidden;
        position: relative;
        .homeCard{
            width: 100%;
            padding: 20px;
            box-sizing: border-box;
            background: #fff;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        .applyBtn{
            width: 100%;
            background: #fff;
            padding-top: 15px;
            z-index: 5;
            box-shadow: 0 -3px 8px rgba(150,150,150,.1);
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .el-row{
            margin-bottom: 20px;
        }
        .el-row:last-child {
            margin-bottom: 0;
        }
        .el-input{
            width: 100% !important;
        }
        .el-date-editor::v-deep{
            width: 100%;
        }
        .el-select{
            width: 100%;
        }
        .el-cascader{
            width: 100% !important;
        }
    }
</style>