Admin
2022-08-09 9cb42e93ea6fc79268b7c43a4115b8f0076c84e1
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
<template>
    <div class="home-container">
        <div style="height: 100%">
        <el-form :model="form" label-width="150px" :rules="applyRules" ref="ruleFormRef2">
<!--            <blind-panel-form :bpForm="form.addForm" ref="additionalForm"></blind-panel-form>-->
<!--            <cut-line-form :clForm="form.addForm" ref="additionalForm"></cut-line-form>-->
<!--            <dirt-work-form :dwForm="form.addForm" ref="additionalForm"></dirt-work-form>-->
            <fire-work-form :fwForm="form.addForm" ref="additionalForm"></fire-work-form>
<!--            <hang-load-form :hlForm="form.addForm" ref="additionalForm"></hang-load-form>-->
<!--            <high-work-form :hwForm="form.addForm" ref="additionalForm"></high-work-form>-->
<!--            <limited-space-form :lsForm="form.addForm" ref="additionalForm"></limited-space-form>-->
<!--            <temp-elect-form :teForm="form.addForm" ref="additionalForm"></temp-elect-form>-->
            <div>
            <div class="homeCard">
            <el-row>
                <el-col :span="3"><el-button type="primary" size="default" @click="dialogAddWorker = true">添加作业人</el-button></el-col>
                <el-col :span="21">
                    <el-table :data="form.workerList" style="width: 100%">
                        <el-table-column type="index" label="序号" width="100"/>
                        <el-table-column prop="worker" label="作业人"/>
                        <el-table-column prop="role" label="作业人角色" width="180"/>
                        <el-table-column prop="unit" label="所属单位" width="180" />
                        <el-table-column prop="certificate" label="证书名称" width="180" />
                        <el-table-column prop="certificateId" label="证书号" />
                        <el-table-column fixed="right" label="操作" align="center" width="180">
                            <template #default="scope">
                                <el-button link type="danger" size="small" @click="deleteRow(scope.$index)">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业地点" prop="workLocation">
                        <el-input
                            v-model="form.workLocation"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="作业期限" prop="workTimeLine">
                        <el-date-picker
                            v-model="form.workTimeLine"
                            type="daterange"
                            unlink-panels
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            :shortcuts="shortcuts"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="作业内容" prop="workContent">
                        <el-input
                            v-model="form.workContent"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="作业单位" prop="workUnit">
                        <el-input
                            v-model="form.workUnit"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>选择作业单位</template>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="8">
                    <el-form-item label="作业负责人" prop="responsor">
                        <el-input
                            v-model="form.responsor"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="监护人" prop="monitor">
                        <el-input
                            v-model="form.monitor"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="8">
                    <el-form-item label="监护人岗位" prop="monitorStation">
                        <el-input
                            v-model="form.monitorStation"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="生产车间负责人" prop="workhouseLeader">
                        <el-input
                            v-model="form.workhouseLeader"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="申请日期" prop="applyDate">
                        <el-date-picker
                            size="large"
                            v-model="form.applyDate"
                            type="date"
                            placeholder="请选择"
                            style="width: 100%"
                        ></el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>
            </div>
            <div class="homeCard">
            <el-row>
                <el-col :span="24">
                    <el-form-item label="涉及的其他特殊作业" prop="otherSpecialWorks">
                        <el-checkbox-group v-model="form.otherSpecialWorks">
                            <el-checkbox label="动火作业" />
                            <el-checkbox label="受限空间" />
                            <el-checkbox label="高处作业" />
                            <el-checkbox label="吊装作业" />
                            <el-checkbox label="临时用电" />
                            <el-checkbox label="设备检修" />
                            <el-checkbox label="盲板抽堵" />
                            <el-checkbox label="断路作业" />
                            <el-checkbox label="动土作业" />
                        </el-checkbox-group>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col>
                    <el-form-item label="防护用品" prop="protections">
                        <el-cascader
                            v-model="form.protections"
                            :options="protectOption"
                            :props="{expandTrigger: 'hover'}"
                            @change="protectionsChange"
                            placeholder="请选择"
                            style="width: 100%"
                        />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row style="justify-content: center">
                <el-button type="primary" size="default" @click="dialogAddFile = true">点击添加安全交底和风险告知书</el-button>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item label="实施安全教育人" prop="safetyMan">
                        <el-input
                            v-model="form.safetyMan"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search"/>
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="被教育人" prop="educated">
                        <el-input
                            v-model="form.educated"
                            placeholder="请输入"
                            class="input-with-select"
                        >
                            <template #append>
                                <el-button :icon="Search" />
                            </template>
                        </el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            </div>
            </div>
        </el-form>
        <div class="applyBtn">
            <el-col :span="24" class="submitBtn">
                <el-button type="primary" size="large" plain @click="handleApply(ruleFormRef2)">发起申请</el-button>
            </el-col>
        </div>
        <el-dialog v-model="dialogAddWorker" title="添加作业人">
            <el-form :model="addWorkerForm" label-width="120px" :rules="addWorkerRules" ref='ruleFormRef3'>
                <el-form-item label="作业人" prop="worker">
                    <el-input
                            v-model="addWorkerForm.worker"
                            placeholder="请输入"
                            class="input-with-select"
                    >
                        <template #append>
                            <el-button :icon="Search" />
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item label="作业人角色" prop="role">
                    <el-input
                            v-model="addWorkerForm.role"
                            placeholder="请输入"
                            class="input-with-select"
                    >
                        <template #append>
                            <el-button :icon="Search" />
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item label="作业人角色" prop="unit">
                    <el-input
                            v-model="addWorkerForm.unit"
                            placeholder="请输入"
                            class="input-with-select"
                    >
                        <template #append>
                            <el-button :icon="Search" />
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item label="证书名称" prop="certificate">
                    <el-input
                            v-model="addWorkerForm.certificate"
                            placeholder="请输入"
                            class="input-with-select"
                    >
                        <template #append>
                            <el-button :icon="Search" />
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item label="证书号" prop="certificateId">
                    <el-input
                            v-model="addWorkerForm.certificateId"
                            placeholder="请输入"
                            class="input-with-select"
                    >
                        <template #append>
                            <el-button :icon="Search" />
                        </template>
                    </el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmitAddForm(ruleFormRef3)" size="default">确认</el-button>
                    <el-button size="default" @click="cancleAdd">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
        <el-dialog v-model="dialogAddFile" title="安全交底和风险告知">
            <el-form :model="saftyFileForm" label-width="0" ref="ruleFormRef" :rules="saftyFileRules">
                <el-form-item label="" prop="surrounding">
                    <div>1.作业许可范围及作业环境:</div>
                    <el-input
                            v-model="saftyFileForm.surrounding"
                            :rows="2"
                            type="textarea"
                            placeholder="请输入"
                    />
                </el-form-item>
                <el-form-item label="" prop="risk">
                    <div>2.作业风险:</div>
                    <el-input
                            v-model="saftyFileForm.risk"
                            :rows="2"
                            type="textarea"
                            placeholder="请输入"
                    />
                </el-form-item>
                <el-form-item label="" prop="protection">
                    <div>3.防范措施(工艺、设备、个体防护等):</div>
                    <el-input
                            v-model="saftyFileForm.protection"
                            :rows="2"
                            type="textarea"
                            placeholder="请输入"
                    />
                </el-form-item>
                <el-form-item label="" prop="emergency">
                    <div>4.应急措施:</div>
                    <el-input
                            v-model="saftyFileForm.emergency"
                            :rows="2"
                            type="textarea"
                            placeholder="请输入"
                    />
                </el-form-item>
                <el-form-item label="" prop="otherStuff">
                    <div>5.其他注意事项:</div>
                    <el-input
                            v-model="saftyFileForm.otherStuff"
                            :rows="2"
                            type="textarea"
                            placeholder="请输入"
                    />
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="onSubmitAddFile(ruleFormRef)" size="default">确认</el-button>
                    <el-button size="default" @click="cancleAddFile">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
    </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 } from 'element-plus'
    import type { FormInstance, FormRules } from 'element-plus'
    let global: any = {
        homeChartOne: null,
        homeChartTwo: null,
        homeCharThree: null,
        dispose: [null, '', undefined],
    };
 
    interface stateType {
        homeOne: Array <type>
    }
    interface type {
 
    }
    export default defineComponent({
        name: 'workApplyForm',
        components: {
            fireWorkForm: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/fireWorkForm.vue')),
            limitedSpaceForm: defineAsyncComponent(() => import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/limitedSpaceForm.vue')),
            hangLoadForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/hangLoadForm.vue')),
            dirtWorkForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/dirtWorkForm.vue')),
            cutLineForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/cutLineForm.vue')),
            highWorkForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/highWorkForm.vue')),
            tempElectForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/tempElectForm.vue')),
            blindPanelForm: defineAsyncComponent(()=> import('/@/views/specialWorkSystem/workApplyManage/workApplyForm/components/blindPanelForm.vue'))
        },
        setup() {
            const userInfo = useUserInfo()
            const { userInfos } = storeToRefs(userInfo);
            const state  = reactive<stateType>({
                homeOne:[{id:1,name:'安全基础信息系统'},{id:2,name:'双重预防系统'},{id:3,name:'系统2'},{id:4,name:'系统3'},{id:5,name:'系统4'}],
            });
            const form = reactive({
                addForm: {},
                workerList: [],
                workLocation: '',
                workTimeLine: '',
                workContent: '',
                workUnit: '',
                responsor: '',
                monitor: '',
                workMonitor: '',
                monitorStation: '',
                workhouseLeader: '',
                applyDate: '',
                otherSpecialWorks: [],
                protections: '',
                saftyFile: {},
                safetyMan: '',
                educated: ''
            })
            const dialogAddWorker = ref(false)
            const dialogAddFile = ref(false)
            const addWorkerForm = ref({
                worker: '',
                role: '',
                unit: '',
                certificate: '',
                certificateId: ''
            })
            const saftyFileForm = reactive({
                surrounding: '',
                risk: '',
                protection: '',
                emergency: '',
                otherStuff: ''
            })
            const shortcuts = [
                {
                    text: 'Last week',
                    value: () => {
                        const end = new Date()
                        const start = new Date()
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
                        return [start, end]
                    },
                },
                {
                    text: 'Last month',
                    value: () => {
                        const end = new Date()
                        const start = new Date()
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
                        return [start, end]
                    },
                },
                {
                    text: 'Last 3 months',
                    value: () => {
                        const end = new Date()
                        const start = new Date()
                        start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
                        return [start, end]
                    },
                },
            ]
            const protectOption = [
                {
                    value: 'guide',
                    label: 'Guide',
                    children: [
                        {
                            value: 'disciplines',
                            label: 'Disciplines',
                            children: [
                                {
                                    value: 'consistency',
                                    label: 'Consistency',
                                },
                                {
                                    value: 'feedback',
                                    label: 'Feedback',
                                }
                            ],
                        },
                        {
                            value: 'navigation',
                            label: 'Navigation',
                            children: [
                                {
                                    value: 'side nav',
                                    label: 'Side Navigation',
                                }
                            ],
                        },
                    ],
                }
            ]
            const ruleFormRef = ref<FormInstance>()
            const ruleFormRef2 = ref<FormInstance>()
            const ruleFormRef3 = ref<FormInstance>()
            const applyRules = reactive<FormRules>({
                extraForm: [{type: 'object', required: true,message: '此处不能为空'}],
                workLocation: [{required: true,message: '此处不能为空'}],
                workTimeLine: [{required: true,message: '此处不能为空'}],
                workContent: [{required: true,message: '此处不能为空'}],
                workUnit: [{required: true,message: '此处不能为空'}],
                responsor: [{required: true,message: '此处不能为空'}],
                monitor: [{required: true,message: '此处不能为空'}],
                workMonitor: [{required: true,message: '此处不能为空'}],
                monitorStation: [{required: true,message: '此处不能为空'}],
                workhouseLeader: [{required: true,message: '此处不能为空'}],
                applyDate: [{required: true,message: '此处不能为空'}],
                otherSpecialWorks: [{type: 'array', required: true,message: '此处不能为空'}],
                protections: [{required: true,message: '此处不能为空'}],
                safetyMan: [{required: true,message: '此处不能为空'}],
                educated: [{required: true,message: '此处不能为空'}]
            })
            const addWorkerRules = reactive<FormRules>({
                worker: [{required: true,message: '此处不能为空'}],
                role: [{required: true,message: '此处不能为空'}],
                unit: [{required: true,message: '此处不能为空'}],
                certificate: [{required: true,message: '此处不能为空'}],
                certificateId: [{required: true,message: '此处不能为空'}]
            })
            const saftyFileRules = reactive<FormRules>({
                surrounding: [{required: true,message: '该选项不能为空'}],
                risk: [{required: true,message: '该选项不能为空'}],
                protection: [{required: true,message: '该选项不能为空'} ],
                emergency: [{required: true,message: '该选项不能为空'} ]
            })
            const protectionsChange = (value) => {
                console.log(value)
            }
 
            const onSubmitAddForm = async (formEl: FormInstance | undefined) => {
                if (!formEl) return
                await formEl.validate((valid, fields) => {
                    if (valid) {
                        form.workerList.unshift(addWorkerForm.value)
                        addWorkerForm.value = {
                            worker: '',
                            role: '',
                            unit: '',
                            certificate: '',
                            certificateId: ''
                        }
                        dialogAddWorker.value = false
                    } else {
                        console.log('error submit!', fields)
                    }
                })
            }
            const onSubmitAddFile = () =>{
 
            }
            const cancleAdd = ()=> {
                addWorkerForm.value = {
                    worker: '',
                    role: '',
                    unit: '',
                    certificate: '',
                    certificateId: ''
                }
                dialogAddWorker.value = false
            }
            const cancleAddFile = ()=>{
 
            }
            const deleteRow = (index) =>{
                form.workerList.splice( index,1)
            }
            const isValid = ref(false)
            const additionalForm = ref(null)
            const handleApply = async (formEl: FormInstance | undefined) =>{
                if (!formEl) return
                const flag = additionalForm.value.validateForm()
                await flag.then((res)=>{
                    isValid.value = res
                })
                await formEl.validate((valid, fields) => {
                    console.log(valid,'and',isValid.value)
                    if (valid && isValid.value) {
                        console.log('submit',form,fields)
                        ElMessage({
                            message: '提交成功!',
                            type: 'success',
                        })
                    } else {
                        // console.log('error submit!',form,fields)
                        ElMessage({
                            message: '表单未填写完整',
                            type: 'error',
                        })
                    }
                })
 
            }
            // 折线图
            const renderMenu = async (value: string) => {
                Session.set('projectId',value)
                userInfos.value.projectId = value
                await initBackEndControlRoutes();
            };
            return {
                renderMenu,
                form,
                Search,
                shortcuts,
                protectOption,
                dialogAddWorker,
                dialogAddFile,
                addWorkerForm,
                saftyFileForm,
                ruleFormRef,
                ruleFormRef2,
                ruleFormRef3,
                additionalForm,
                addWorkerRules,
                saftyFileRules,
                applyRules,
                isValid,
                handleApply,
                cancleAddFile,
                deleteRow,
                cancleAdd,
                onSubmitAddForm,
                onSubmitAddFile,
                protectionsChange,
                ...toRefs(state),
            };
        },
    });
</script>
 
<style scoped lang="scss">
    .home-container {
        height: 100%;
        overflow: hidden;
        position: relative;
        .homeCard{
            width: 100%;
            padding: 20px;
            background: #fff;
            border-radius: 4px;
            margin-bottom: 20px;
 
            &:last-of-type{
                margin-bottom: 100px;
            }
        }
        .applyBtn{
            position: absolute;
            width: 100%;
            padding: 20px;
            background: #fff;
            bottom: 0;
            left: 0;
            height: 80px;
            z-index: 999;
            margin-bottom: 0;
            border-radius: 0;
            box-shadow: 0 -3px 8px rgba(150,150,150,.1);
        }
        .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;
        }
        .submitBtn{
            display: flex;
            justify-content: center;
        }
    }
</style>