郑永安
2023-06-19 6ae336af4670a425ae8892aacda560ec2147d8a7
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
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
<template>
  <el-dialog :title="title" :visible.sync="centerDialogVisible" width="70%" center @close='reset()'>
    <el-form :model="companyInfo" :rules="rules" ref="ruleForm" label-width="120px">
      <el-row>
        <el-col :span="10">
          <el-form-item label="企业名称" prop="companyName">
            <el-input v-model="companyInfo.companyName" placeholder="企业名称"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4">
          <el-form-item label="法定负责人" prop="companyLegalRepresentative">
            <el-input v-model="companyInfo.companyLegalRepresentative" placeholder="企业负责人"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="许可证类型" prop="certificateType">
            <el-radio-group v-model="companyInfo.certificateType">
              <el-radio border :label="1">生产</el-radio>
              <el-radio border :label="2">经营</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4">
          <el-form-item label="许可证编号" prop="certificateNum">
            <el-input v-model="companyInfo.certificateNum" placeholder="证书编号">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="证书有效期" prop="validityDate">
            <el-date-picker
              v-model="companyInfo.validityDate"
              @input="changeTime"
              @blur="changeTime"
              value-format="yyyy-MM-dd"
              type="daterange"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4" style='display: flex;align-items: center;justify-content: space-between'>
          <el-form-item label="工艺类型" prop="technologyType" style='margin-bottom: 0'>
            <el-select clearable v-model="companyInfo.technologyType" style="width: 100%">
              <el-option v-for='(item,index) in techTypeList' :label="item.technologyName" :value="item.id" :key='index'></el-option>
            </el-select>
          </el-form-item>
          <el-button type='primary' @click='openTypeDialog()'>管理</el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="所在地区" prop="companyCityValue">
            <el-cascader
              v-model="companyInfo.companyCityValue"
              :options="areaInfo"
              :props="{ expandTrigger: 'hover', value: 'label' }"
              style="width: 100%"
              @change="handleChangeAddArea"
            ></el-cascader>
            <!--              <el-input v-model="companyInfo.companyCity" style="width: 100%" placeholder="所在城市">-->
            <!--              </el-input>-->
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4">
          <el-form-item label="住所" prop='companyAddress'>
            <el-input type='textarea' v-model="companyInfo.companyAddress" style="width: 100%" placeholder="请输入详细地址"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="许可范围" prop="licenseScope">
            <el-input v-model="companyInfo.licenseScope" type="textarea" style="width: 100%;" placeholder="请描述许可范围">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="发证机关" prop="licenceIssuingAuthority">
            <el-input v-model="companyInfo.licenceIssuingAuthority" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4">
          <el-form-item label="发证时间" prop="licenceIssuingTime">
            <el-date-picker
              v-model="companyInfo.licenceIssuingTime"
              type="date"
              value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-row>
<!--      <el-dialog :visible.sync="dialogVisible">-->
<!--        <img width="100%" :src="dialogImageUrl" alt="">-->
<!--      </el-dialog>-->
      <el-row>
        <el-col :span="8">
          <el-form-item label="企业图片 " prop="companyImage">
            <el-upload
              action="#" ref="upload" :http-request="httpRequestCompanyImage" list-type="picture-card"
              v-model="companyInfo.companyImage"
              :on-success="fileUploadSuccess" :before-upload="addFileList"
              :limit="1"
              :file-list="companyImageList"
              accept=".jpg,.jpeg,.png"
              :on-change="(file, fileList) => {handleChangeFile(file, fileList, 1)}"
              :on-remove="(file, fileList) => {handleRemove(file, fileList, 1)}"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
        </el-col>
 
        <el-col :span="8">
          <el-form-item label="营业执照 " prop="businessLicense">
            <el-upload size="small"
                       action="#" ref="upload" :http-request="httpRequestBusinessLicense" list-type="picture-card"
                       v-model="companyInfo.businessLicense"
                       :on-success="fileUploadSuccess"
                       :before-upload="addFileList"
                       :limit="1"
                       :file-list="businessLicenseList"
                       :on-change="(file, fileList) => {handleChangeFile(file, fileList, 2)}"
                       accept=".jpg,.jpeg,.png"
                       :on-remove="(file, fileList) => {handleRemove(file, fileList, 2)}"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
        </el-col>
 
        <el-col :span="8">
          <el-form-item label="经营许可证书 " prop="securityCertificate">
            <el-upload
              action="#" ref="upload" :http-request="httpRequestSecurityCertificate" list-type="picture-card"
              v-model="companyInfo.securityCertificate"
              :on-success="fileUploadSuccess" :before-upload="addFileList"
              :limit="1"
              :file-list="securityCertificateList"
              :on-change="(file, fileList) => {handleChangeFile(file, fileList, 3)}"
              accept=".jpg,.jpeg,.png"
              :on-remove="(file, fileList) => {handleRemove(file, fileList, 3)}"
            >
              <i class="el-icon-plus"></i>
            </el-upload>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="重大危险源总数" label-width='140px'>
            <el-input readonly v-model.number="totalRisk" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="一级重大危险源总数" label-width='140px' prop='levelOneMajorHazardSourceSum'>
            <el-input type='number' v-model.number="companyInfo.levelOneMajorHazardSourceSum" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4" v-if='companyInfo.levelOneMajorHazardSourceSum > 0'>
          <el-form-item label="一级重大危险源描述" label-width='140px' prop='levelOneMajorHazardSourceDesc'>
            <el-input type='textarea' v-model="companyInfo.levelOneMajorHazardSourceDesc" style="width: 100%" placeholder="请简单描述一级重大危险源"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="二级重大危险源总数" label-width='140px' prop='levelTwoMajorHazardSourceSum'>
            <el-input type='number'v-model.number="companyInfo.levelTwoMajorHazardSourceSum" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4" v-if='companyInfo.levelTwoMajorHazardSourceSum > 0'>
          <el-form-item label="二级重大危险源描述" label-width='140px' prop='levelTwoMajorHazardSourceDesc'>
            <el-input type='textarea' v-model="companyInfo.levelTwoMajorHazardSourceDesc" style="width: 100%" placeholder="请简单描述二级重大危险源"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="三级重大危险源总数" label-width='140px' prop='levelThreeMajorHazardSourceSum'>
            <el-input type='number' v-model.number="companyInfo.levelThreeMajorHazardSourceSum" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4" v-if='companyInfo.levelThreeMajorHazardSourceSum > 0'>
          <el-form-item label="三级重大危险源描述" label-width='140px' prop='levelThreeMajorHazardSourceDesc'>
            <el-input type='textarea' v-model="companyInfo.levelThreeMajorHazardSourceDesc" style="width: 100%" placeholder="请简单描述三级重大危险源"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="10">
          <el-form-item label="四级重大危险源总数" label-width='140px' prop='levelFourMajorHazardSourceSum'>
            <el-input type='number' v-model.number="companyInfo.levelFourMajorHazardSourceSum" style="width: 100%" placeholder=""></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="10" :offset="4" v-if='companyInfo.levelFourMajorHazardSourceSum > 0'>
          <el-form-item label="四级重大危险源描述" label-width='140px' prop='levelFourMajorHazardSourceDesc'>
            <el-input type='textarea' v-model="companyInfo.levelFourMajorHazardSourceDesc" style="width: 100%" placeholder="请简单描述四级重大危险源"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
 
    <el-form :model="companyInfo" class="demo-form-inline" style="padding-left: 40px;">
      <el-row>
        <el-col :span="24">
          <el-form-item label="企业基本情况">
            <el-input v-model="companyInfo.companyInfo" type="textarea" style="width: 100%;" placeholder="">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="“两重点一重大”情况">
            <el-input v-model="companyInfo.keynoteGreatSituation" type="textarea" style="width: 100%"
                      placeholder=""
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="安全生产情况">
            <el-input v-model="companyInfo.safetyProductionLicenseSituation" type="textarea" style="width: 100%"
                      placeholder=""
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="主要安全风险">
            <el-input v-model="companyInfo.mainSafetyRisks" style="width: 100%" type="textarea" placeholder="">
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="当前存在问题">
            <el-input v-model="companyInfo.currentProblems" style="width: 100%" type="textarea"
                      placeholder=""
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="24">
          <el-form-item label="安全风险主要控制措施">
            <el-input v-model="companyInfo.safetyRiskControlMeasures" style="width: 100%" type="textarea"
                      placeholder=""
            ></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
 
    <span slot="footer" class="dialog-footer">
                <el-button @click="centerDialogVisible = false">取 消</el-button>
                <el-button v-stop-re-click type="primary" @click="saveData">确 定</el-button>
            </span>
    <el-dialog title="工艺类型管理" :visible.sync="typeDialog" :append-to-body="true">
      <el-button type="primary" size="medium" @click='editType(null)'>新增</el-button>
      <el-table :data="techTypeList" border :header-cell-style="{ background: '#f4f4f4' }" style="width: 100%; margin-top: 20px">
        <el-table-column prop="technologyName" label="工艺类型" align='center'></el-table-column>
        <el-table-column label="操作" align='center'>
          <template slot-scope="scope">
            <el-button type="text" size="medium" @click='editType(scope.row)'>编辑</el-button>
            <el-button type="text" size="medium" @click='deleteType(scope.row.id)'>删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="工艺类型编辑" :visible.sync="typeEditDialog" @close='closeEdit()' :append-to-body="true">
      <el-form ref="typeForm" :model="typeForm" :rules="typeRules" label-width="80px">
        <el-form-item label="类型名称" prop="technologyName">
          <el-input v-model="typeForm.technologyName"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="typeEditDialog = false">取 消</el-button>
        <el-button v-stop-re-click type="primary" @click="confirmTypeAdd('typeForm')">确 定</el-button>
      </div>
    </el-dialog>
  </el-dialog>
</template>
 
<script>
import {
  getTechType,
  addTechType,
  updateTechType,
  deleteTechType,
  saveCompanyInfo,
  updateCompanyInfo,
  getAreaInfo,
  getEnterpriseInfoById
} from '@/api/company';
 
    export default {
      name: "companyDialog",
      props: {
        typeList:{
          type: Array
        }
      },
      data(){
        return{
          centerDialogVisible:false,
          techTypeList: [],
          areaInfo: [],
          typeForm: {
            id: null,
            technologyName: ''
          },
          typeDialog: false,
          typeEditDialog: false,
          typeRules: {
            technologyName: [{ required: true, message: '请输入工艺类型名称', trigger: 'blur' }],
          },
          title: '',
          companyInfo: {
            id: null,
            companyName: '',
            companyLegalRepresentative: '',
            certificateType: null,
            certificateNum: '',
            validityDate: [],
            validityDateStart: '',
            validityDateEnd: '',
            technologyType: null,
            companyCityValue: [],
            companyCity: '',
            companyArea: '',
            companyAddress: '',
            licenseScope: '',
            licenceIssuingAuthority: '',
            licenceIssuingTime: '',
            levelOneMajorHazardSourceSum: 0,
            levelOneMajorHazardSourceDesc: '',
            levelTwoMajorHazardSourceSum: 0,
            levelTwoMajorHazardSourceDesc: '',
            levelThreeMajorHazardSourceSum: 0,
            levelThreeMajorHazardSourceDesc: '',
            levelFourMajorHazardSourceSum: 0,
            levelFourMajorHazardSourceDesc: '',
            companyInfo: '',
            keynoteGreatSituation: '',
            safetyProductionLicenseSituation: '',
            mainSafetyRisks: '',
            currentProblems: '',
            safetyRiskControlMeasures: '',
            companyImageFile: null,
            businessLicenseFile: null,
            securityCertificateFile: null
          },
          rules: {
            companyCityValue: [{required: true, message: '请选择企业所在区域', trigger: 'blur'}],
            companyName: [{required: true, message: '请输入企业名称', trigger: 'blur'}],
            companyLegalRepresentative: [{required: true, message: '请输入企业负责人', trigger: 'blur'}],
            certificateType: [{required: true, message: '请选择许可证类型', trigger: 'blur'}],
            certificateNum: [{required: true, message: '请输入证书编号', trigger: 'blur'}],
            validityDate: [{required: true, message: '请选择日期区间', trigger: 'blur'}],
            technologyType: [{required: true, message: '请输入工艺类型', trigger: 'blur'}],
            companyAddress: [{required: true, message: '请输入详细地址', trigger: 'blur'}],
            licenseScope: [{required: true, message: '请输入许可范围', trigger: 'blur'}],
            licenceIssuingAuthority: [{required: true, message: '请输入发证机关', trigger: 'blur'}],
            licenceIssuingTime: [{required: true, message: '请选择发证时间', trigger: 'blur'}],
            levelOneMajorHazardSourceSum: [{required: true, message: '请输入一级重大危险源总数', trigger: 'blur'}],
            levelTwoMajorHazardSourceSum: [{required: true, message: '请输入二级重大危险源总数', trigger: 'blur'}],
            levelThreeMajorHazardSourceSum: [{required: true, message: '请输入三级重大危险源总数', trigger: 'blur'}],
            levelFourMajorHazardSourceSum: [{required: true, message: '请输入四级重大危险源总数', trigger: 'blur'}],
            levelOneMajorHazardSourceDesc: [{required: true, message: '请填写描述信息', trigger: 'blur'}],
            levelTwoMajorHazardSourceDesc: [{required: true, message: '请填写描述信息', trigger: 'blur'}],
            levelThreeMajorHazardSourceDesc: [{required: true, message: '请填写描述信息', trigger: 'blur'}],
            levelFourMajorHazardSourceDesc: [{required: true, message: '请填写描述信息', trigger: 'blur'}]
          },
          dialogImageUrl: '',
          fileList: [],
          companyImageList: [],
          businessLicenseList: [],
          securityCertificateList: [],
        }
      },
      created() {
 
      },
      mounted() {
        const t = this
        t.getAreaInfo()
      },
      watch: {
      },
      computed:{
        totalRisk:{
          get(){
            return Number(this.companyInfo.levelOneMajorHazardSourceSum) + Number(this.companyInfo.levelTwoMajorHazardSourceSum) + Number(this.companyInfo.levelThreeMajorHazardSourceSum) + Number(this.companyInfo.levelFourMajorHazardSourceSum)
          },
          set(newValue){
            return newValue;
          }
        }
      },
      methods:{
        changeTime(e) {
          if (this.companyInfo.validityDate == null) {
            this.companyInfo.validityDate = new Array()
            this.companyInfo.validityDate[0] = ''
            this.companyInfo.validityDate[1] = ''
          }
          this.$forceUpdate()
        },
        getTechType() {
          getTechType().then(res => {
            if(res.code == 200){
              this.techTypeList = res.data;
            }else{
              this.$message(res.msg || '查询失败!请重试', 'error', 3 * 1000)
            }
 
          })
        },
        getAreaInfo() {
          getAreaInfo().then(res => {
            if(res.code == 200){
              this.areaInfo = res.data;
            }else{
              this.$message(res.msg || '查询失败!请重试', 'error', 3 * 1000)
            }
          })
        },
        getEnterpriseInfo(id){
          const t = this
          getEnterpriseInfoById({ id: id }).then(res =>{
            if(res.code == 200){
              t.companyInfo=res.data
              // t.companyInfo.technologyType = t.typeList.find((item) => item.id == res.data.technologyType).technologyName
              t.companyInfo.technologyType = res.data.technologyType
              t.companyInfo.companyCityValue = new Array()
              t.companyInfo.companyCityValue[0] = res.data.companyCity
              t.companyInfo.companyCityValue[1] = res.data.companyArea
              t.totalRisk = res.data.levelOneMajorHazardSourceSum + res.data.levelTwoMajorHazardSourceSum + res.data.levelThreeMajorHazardSourceSum + res.data.levelFourMajorHazardSourceSum
              t.companyInfo.validityDate = new Array()
              t.companyInfo.validityDate[0] = res.data.validityDateStart
              t.companyInfo.validityDate[1] = res.data.validityDateEnd
              if (res.data.companyImage) {
                t.companyImageList.push({'url': process.env.VUE_APP_BASE_API + res.data.companyImage})
              }
              if (res.data.businessLicense) {
                t.businessLicenseList.push({'url': process.env.VUE_APP_BASE_API + res.data.businessLicense})
              }
              if (res.data.securityCertificate) {
                t.securityCertificateList.push({'url': process.env.VUE_APP_BASE_API + res.data.securityCertificate})
              }
              // t.$set(t.companyInfo, 'validityDate', [t.companyInfo.validityDateStart != null ?t.companyInfo.validityDateStart : '', t.companyInfo.validityDateEnd != null ? t.companyInfo.validityDateEnd : ''])
            }else{
              t.$message(res.msg || '查询失败!请重试', 'error', 3 * 1000)
            }
          }).catch((error)=>{
            console.log(error)
          })
        },
        openTypeDialog(){
          const t = this
          t.getTechType()
          t.typeDialog = true
        },
        editType(row){
          const t = this
          if(row != null){
            t.typeForm.id = row.id
            t.typeForm.technologyName = row.technologyName
          }
          t.typeEditDialog = true
        },
 
        confirmTypeAdd(formName) {
          this.$refs[formName].validate((valid) => {
            if (valid) {
              const t = this
              if(t.typeForm.id == null){
                addTechType(t.typeForm).then((res)=>{
                  if(res.code == 200){
                    t.$message(res.msg || '添加成功!')
                    t.typeEditDialog = false
                    t.getTechType()
                  }else{
                    t.$message(res.msg || '添加失败,请重试', 'error', 3 * 1000)
                  }
                }).catch((error)=>{
                  console.log(error)
                })
              }else{
                updateTechType(t.typeForm).then((res)=>{
                  if(res.code == 200){
                    t.$message(res.msg || '修改成功!')
                    t.typeEditDialog = false
                    t.getTechType()
                  }else{
                    t.$message(res.msg || '修改失败,请重试', 'error', 3 * 1000)
                  }
                }).catch((error)=>{
                  console.log(error)
                })
              }
            } else {
              console.log('error submit!!');
              return false;
            }
          });
        },
        deleteType(id){
          const t = this
          t.$confirm('此操作将删除该工艺类型, 是否继续?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            deleteTechType({ id: id }).then((res)=>{
              if(res.code == 200){
                t.$message(res.msg || '删除成功!')
                t.getTechType()
              }else{
                t.$message(res.msg || '删除失败,请重试', 'error', 3 * 1000)
              }
            }).catch((error)=>{
              console.log(error)
            })
          }).catch(() => {
            t.$message({
              type: 'info',
              message: '已取消删除'
            });
          });
        },
        closeEdit(){
          this.typeForm = {
            id: null,
            technologyName: ''
          }
        },
        handleChangeAddArea(row) {
          if(row){
            this.companyInfo.companyCity = row[0];
            this.companyInfo.companyArea = row[1];
          }
        },
        httpRequestCompanyImage(data) {
          let t = this
          let rd = new FileReader() // 创建文件读取对象
          let file = data.file
          const isLt2M = file.size / 1024 / 1024 < 3
          if (!isLt2M) {
            // this.$refs.upload.clearFiles()
            t.$message('上传图片大小不能超过 3MB!', 'warn', 3 * 1000)
            t.companyImageList = [];
            return;
          }
          t.companyInfo.companyImageFile = file
          rd.readAsDataURL(file) // 文件读取装换为base64类型
          rd.onloadend = function (e) {
            t.imageUrl = this.result // this指向当前方法onloadend的作用域
          }
        },
        httpRequestBusinessLicense(data) {
          let t = this
          let rd = new FileReader() // 创建文件读取对象
          let file = data.file
          const isLt2M = file.size / 1024 / 1024 < 3
          if (!isLt2M) {
            // this.$refs.upload.clearFiles()
            t.$message('上传图片大小不能超过 3MB!', 'warn', 3 * 1000)
            t.businessLicenseList = [];
            return;
          }
          t.companyInfo.businessLicenseFile = file
          rd.readAsDataURL(file) // 文件读取装换为base64类型
          rd.onloadend = function (e) {
            t.imageUrl = t.result // this指向当前方法onloadend的作用域
          }
        },
        httpRequestSecurityCertificate(data) {
          let t = this
          let rd = new FileReader() // 创建文件读取对象
          let file = data.file
          const isLt2M = file.size / 1024 / 1024 < 3
          if (!isLt2M) {
            // this.$refs.upload.clearFiles()
            t.$message('上传图片大小不能超过 3MB!', 'warn', 3 * 1000)
            t.securityCertificateList = [];
            return;
          }
          t.companyInfo.securityCertificateFile = file
          rd.readAsDataURL(file) // 文件读取装换为base64类型
          rd.onloadend = function (e) {
            t.imageUrl = t.result // this指向当前方法onloadend的作用域
          }
        },
        fileUploadSuccess(response, file, fileList) {
        },
 
        addFileList(file) {
        },
 
        handleRemove(file, fileList, index) {
          if (index == 1) {
            this.companyInfo.deleteCompanyImage = true
          }
          if (index == 2) {
            this.companyInfo.deleteBusinessLicense = true
          }
          if (index == 3) {
            this.companyInfo.deleteSecurityCertificate = true
          }
        },
        handleChangeFile(file, fileList, index) {
          this.isDisabled = false
          if (!file) return
          const isLt2M = file.size / 1024 / 1024 < 3
          if (!isLt2M) {
            // this.$refs.upload.clearFiles()
            this.$message('上传图片大小不能超过 3MB!', 'warn', 3 * 1000)
            if (index == 1) {
              console.log(index)
              this.companyImageList = []
              this.companyInfo.companyImageFile = null;
            }
            if (index == 2) {
              console.log(index)
              this.businessLicenseList = []
              this.companyInfo.businessLicenseFile = null;
            }
            if (index == 3) {
              console.log(index)
              this.securityCertificateList = []
              this.companyInfo.securityCertificateFile = null;
            }
          }
          this.fileName = file.name
        },
 
        // handlePictureCardPreview(file) {
        //   this.dialogImageUrl = file.url
        //   this.dialogVisible = true
        // },
 
        saveData() {
          const t = this
          t.loading = true
          t.$refs['ruleForm'].validate((valid) => {
            if (valid) {
              t.companyInfo.validityDateStart = t.companyInfo.validityDate[0]
              t.companyInfo.validityDateEnd = t.companyInfo.validityDate[1]
              t.companyInfo.companyCity = t.companyInfo.companyCityValue[0]
              t.companyInfo.companyArea = t.companyInfo.companyCityValue[1]
              if(t.companyInfo.levelOneMajorHazardSourceSum == 0){
                t.companyInfo.levelOneMajorHazardSourceDesc = ''
              }
              if(t.companyInfo.levelTwoMajorHazardSourceSum == 0){
                t.companyInfo.levelTwoMajorHazardSourceDesc = ''
              }
              if(t.companyInfo.levelThreeMajorHazardSourceSum == 0){
                t.companyInfo.levelThreeMajorHazardSourceDesc = ''
              }
              if(t.companyInfo.levelFourMajorHazardSourceSum == 0){
                t.companyInfo.levelFourMajorHazardSourceDesc = ''
              }
              // const {validityDate,companyCityValue, ...data} = t.companyInfo
              var formData = t.initFile()
              // return
              if (t.companyInfo.id == null) {
                saveCompanyInfo(formData).then(res => {
                  if (res.code == 200) {
                    t.loading = false
                    t.$message(res.msg, 'success', 3 * 1000)
                  } else {
                    t.loading = false
                    t.$message(res.msg, 'errot', 3 * 1000)
                  }
                }).catch(function () {
                  this.$message('添加失败!请重试', 'error', 3 * 1000)
                  this.loading = false
                })
              } else {
                updateCompanyInfo(formData).then(res => {
                  if (res.code == 200) {
                    t.loading = false
                    t.$message(res.msg, 'success', 3 * 1000)
                  } else {
                    t.loading = false
                    t.$message(res.msg, 'errot', 3 * 1000)
                  }
                }).catch(function () {
                  t.$message('修改失败!请重试', 'error', 3 * 1000)
                  t.loading = false
                })
              }
              t.$parent.getProInfo()
              if(t.$parent.pageStatus==1){
                t.$parent.getData()
              }else{
                t.$parent.getAllCompany()
              }
              t.centerDialogVisible = false
            } else {
              t.loading = false
              return false
            }
          })
        },
        initFile() {
          let formData = new FormData()
          for (const fileName in this.companyInfo) {
            if (this.companyInfo[fileName] != null && fileName != 'params' && fileName != 'imageBase64') {
              formData.append(fileName, this.companyInfo[fileName])
            }
          }
          return formData
        },
        reset(){
          this.companyImageList = []
          this.businessLicenseList = []
          this.securityCertificateList = []
          this.companyInfo = {
              id: null,
              companyName: '',
              companyLegalRepresentative: '',
              certificateType: null,
              certificateNum: '',
              validityDate: [],
              validityDateStart: '',
              validityDateEnd: '',
              technologyType: null,
              companyCityValue: [],
              companyCity: '',
              companyArea: '',
              companyAddress: '',
              licenseScope: '',
              licenceIssuingAuthority: '',
              licenceIssuingTime: '',
              levelOneMajorHazardSourceSum: 0,
              levelOneMajorHazardSourceDesc: '',
              levelTwoMajorHazardSourceSum: 0,
              levelTwoMajorHazardSourceDesc: '',
              levelThreeMajorHazardSourceSum: 0,
              levelThreeMajorHazardSourceDesc: '',
              levelFourMajorHazardSourceSum: 0,
              levelFourMajorHazardSourceDesc: '',
              companyInfo: '',
              keynoteGreatSituation: '',
              safetyProductionLicenseSituation: '',
              mainSafetyRisks: '',
              currentProblems: '',
              safetyRiskControlMeasures: '',
              companyImageFile: null,
              businessLicenseFile: null,
              securityCertificateFile: null
          }
        }
      },
    }
</script>
 
<style lang="scss" scoped>
::v-deep .el-upload--picture-card {
  background-color: #fbfdff;
  border: 1px dashed #c0ccda;
  border-radius: 6px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  width: 100px;
  height: 100px;
  line-height: 100px;
  vertical-align: top;
}
.el-date-editor.el-input {
  width: 100%;
}
</style>