liulingling.177216
2024-08-26 349f1cfc5fa77fbc636d542df0d8050fddec48c2
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
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
<template>
  <div>
    <basic-container>
      <el-form class="special-form" :model="queryParams" ref="queryForm" label-width="72px">
        <el-row :gutter="24">
          <el-col :span="6">
            <el-form-item label="编码" prop="code">
              <el-input
                  v-model="queryParams.code"
                  placeholder="请输入编码"
                  clearable
                  size="small"
                  @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备名称" prop="facilityName">
              <el-input
                  v-model="queryParams.facilityName"
                  placeholder="请输入设备名称"
                  clearable
                  size="small"
                  @keyup.enter.native="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="设备类型" prop="facilityType">
              <el-select v-model="queryParams.facilityType" placeholder="请选择设备类型" clearable size="small"
                         style="width: 100%">
                <el-option
                    v-for="dict in facilityTypeOptions"
                    :key="dict.dictValue"
                    :label="dict.dictLabel"
                    :value="dict.dictValue"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="6">-->
          <!--            <el-form-item label="使用分厂" prop="branchFactory">-->
          <!--              <el-select v-model="queryParams.branchFactory" placeholder="请选择使用分厂" clearable size="small"-->
          <!--                         style="width: 100%">-->
          <!--                <el-option-->
          <!--                    v-for="dict in branchFactoryOptions"-->
          <!--                    :key="dict.dictValue"-->
          <!--                    :label="dict.dictLabel"-->
          <!--                    :value="dict.dictValue"-->
          <!--                />-->
          <!--              </el-select>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :span="6">-->
          <!--            <el-form-item label="物理位置" prop="istallationLocationn">-->
          <!--              <el-input-->
          <!--                  v-model="queryParams.istallationLocationn"-->
          <!--                  placeholder="请输入物理位置"-->
          <!--                  clearable-->
          <!--                  size="small"-->
          <!--                  @keyup.enter.native="handleQuery"-->
          <!--              />-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :span="6">-->
          <!--            <el-form-item label="能耗等级" prop="facilityGrade">-->
          <!--              <el-select v-model="queryParams.facilityGrade" placeholder="请选择能耗等级" clearable size="small"-->
          <!--                         style="width: 100%">-->
          <!--                <el-option-->
          <!--                    v-for="dict in facilityGradeOptions"-->
          <!--                    :key="dict.dictValue"-->
          <!--                    :label="dict.dictLabel"-->
          <!--                    :value="dict.dictValue"-->
          <!--                />-->
          <!--              </el-select>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :span="6">-->
          <!--            <el-form-item label="生产厂家" prop="manufacturer">-->
          <!--              <el-input-->
          <!--                  v-model="queryParams.manufacturer"-->
          <!--                  placeholder="请输入生产厂家"-->
          <!--                  clearable-->
          <!--                  size="small"-->
          <!--                  @keyup.enter.native="handleQuery"-->
          <!--              />-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <!--          <el-col :span="6">-->
          <!--            <el-form-item label="额定功率" prop="ratedPower">-->
          <!--              <el-select v-model="queryParams.ratedPower" placeholder="请选择额定功率" clearable size="small"-->
          <!--                         style="width: 100%">-->
          <!--                <el-option-->
          <!--                    v-for="dict in ratedPowerOptions"-->
          <!--                    :key="dict.dictValue"-->
          <!--                    :label="dict.dictLabel"-->
          <!--                    :value="dict.dictValue"-->
          <!--                />-->
          <!--              </el-select>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <el-col :span="6">
            <el-form-item class="operation">
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </basic-container>
    <basic-container style="margin-top: 16px" :bodyStyle="bodyStyle">
      <el-row :gutter="10" class="mb8" style="margin-bottom: 19px">
        <el-col :span="1.5">
          <el-button
              type="primary"
              icon="el-icon-plus"
              size="mini"
              @click="handleAdd"
              v-hasPermi="['facility:archives:add']"
          >新增
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="success"
              icon="el-icon-edit"
              size="mini"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['facility:archives:edit']"
          >修改
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['facility:archives:remove']"
          >删除
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
              type="warning"
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
              v-hasPermi="['facility:archives:export']"
          >导出
          </el-button>
        </el-col>
        <!--        <el-col :span="1.5">-->
        <!--          <el-button-->
        <!--              type="info"-->
        <!--              icon="el-icon-upload2"-->
        <!--              size="mini"-->
        <!--              @click="handleImport"-->
        <!--              v-hasPermi="['facility:archives:import']"-->
        <!--          >导入-->
        <!--          </el-button>-->
        <!--        </el-col>-->
      </el-row>
      <el-table v-loading="loading" :data="archivesList" @selection-change="handleSelectionChange" :height="height">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="编码" align="center" prop="code" show-overflow-tooltip/>
        <el-table-column label="设备名称" align="center" prop="facilityName" show-overflow-tooltip/>
        <el-table-column label="设备类型" align="center" prop="facilityType" :formatter="facilityTypeFormat"
                         show-overflow-tooltip/>
        <el-table-column label="使用分厂" align="center" prop="branchFactory" :formatter="branchFactoryFormat"
                         show-overflow-tooltip/>
        <el-table-column label="重点设备" align="center" prop="pointFlag" :formatter="pointFlagFactoryFormat"
                         show-overflow-tooltip/>
        <el-table-column label="物理位置" align="center" prop="istallationLocationn" show-overflow-tooltip/>
        <el-table-column label="能耗等级" align="center" prop="facilityGrade" :formatter="facilityGradeFormat"
                         show-overflow-tooltip/>
        <el-table-column label="额定功率" align="center" width="100" prop="ratedPower" show-overflow-tooltip/>
        <el-table-column label="投运日期" align="center" prop="putrunDate" width="180" show-overflow-tooltip/>
        <el-table-column label="生产厂家" align="center" width="220" prop="manufacturer" show-overflow-tooltip/>
        <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width"
                         show-overflow-tooltip fixed="right">
          <template slot-scope="scope">
            <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row)"
                v-hasPermi="['facility:archives:edit']"
            >修改
            </el-button>
            <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="openImportAnnexTable(scope.row)"
                v-hasPermi="['tool:gen:import']"
            >附件
            </el-button>
            <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['facility:archives:remove']"
            >删除
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getList"
      />
      <!-- 添加或修改设备档案对话框 -->
      <el-dialog :title="title" :visible.sync="open" width="820px" class="dialog-form-row">
        <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="编码" prop="code">
                <el-input v-model="form.code" placeholder="请输入编码"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="设备名称" prop="facilityName">
                <el-input v-model="form.facilityName" placeholder="请输入设备名称"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="设备类型">
                <el-select v-model="form.facilityType" placeholder="请选择设备类型" filterable>
                  <el-option
                      v-for="dict in facilityTypeOptions"
                      :key="dict.dictValue"
                      :label="dict.dictLabel"
                      :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="使用分厂">
                <el-select v-model="form.branchFactory" placeholder="请选择使用分厂" style="width: 100%">
                  <el-option
                      v-for="dict in branchFactoryOptions"
                      :key="dict.dictValue"
                      :label="dict.dictLabel"
                      :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="能耗等级">
                <el-select v-model="form.facilityGrade" placeholder="请选择能耗等级">
                  <el-option
                      v-for="dict in facilityGradeOptions"
                      :key="dict.dictValue"
                      :label="dict.dictLabel"
                      :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="额定功率" prop="ratedPower">
                <el-input v-model="form.ratedPower" placeholder="请输入额定功率" style="width: 100%"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="生产日期" prop="productionDate">
                <el-date-picker clearable size="small" style="width: 100%"
                                v-model="form.productionDate"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择生产日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="投运日期" prop="putrunDate">
                <el-date-picker clearable size="small" style="width: 100%"
                                v-model="form.putrunDate"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择投运日期">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="重点设备" prop="pointFlag">
                <el-select v-model="form.pointFlag" placeholder="请选择">
                  <el-option
                      v-for="dict in pointFlagOptions"
                      :key="dict.dictValue"
                      :label="dict.dictLabel"
                      :value="dict.dictValue"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="生产厂家" prop="manufacturer">
                <el-input v-model="form.manufacturer" placeholder="请输入生产厂家"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="负责人" prop="personCharge">
                <el-input v-model="form.personCharge" placeholder="请输入负责人"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="物理位置" prop="istallationLocationn">
                <el-input v-model="form.istallationLocationn" placeholder="请输入物理位置"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="技术参数" prop="technicalData">
                <el-input v-model="form.technicalData" placeholder="请输入技术参数"/>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="起始时间" prop="startTime">
                <el-date-picker clearable size="small" style="width: 100%"
                                v-model="form.startTime"
                                type="date"
                                value-format="yyyy-MM-dd"
                                placeholder="选择起始时间">
                </el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="检定周期" prop="checkCycle">
                <el-input v-model="form.checkCycle" placeholder="请输入检定周期"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="8">
              <el-form-item label="提醒周期" prop="reminderCycle">
                <el-input v-model="form.reminderCycle" placeholder="请输入提醒周期"/>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="24">
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer" style="padding-top: 5px">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 设备档案 导入对话框 -->
      <el-dialog :title="upload.title" :visible.sync="upload.open" :destroy-on-close="true" width="400px">
        <el-upload
            ref="upload"
            :limit="1"
            :accept="upload.accept"
            :headers="upload.headers"
            :action="upload.url"
            :disabled="upload.isUploading"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :auto-upload="false"
            drag
        >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">
            将文件拖到此处,或
            <em>点击上传</em>
          </div>
          <div class="el-upload__tip" slot="tip">
            <el-link type="info" style="font-size:12px;color:blue;" @click="importTemplate">下载模板</el-link>
          </div>
          <div class="el-upload__tip" style="color:red" slot="tip">
            导入提示:<br>1、新增导入,仅允许导入“xls”或“xlsx”格式文件!
            <br>2、编码必须唯一,重复数据无法导入
            <br>3、设备种类、使用分厂、能源等级填写错误的数据无法导入
            <br>4、检定周期、提醒周期大于0正整数,填写错误则默认为1
            <br>5、起始时间填写错误或不填则默认为空
          </div>
 
        </el-upload>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
        </div>
      </el-dialog>
      <importAnnexTable ref="importAnnex"/>
    </basic-container>
  </div>
</template>
<style scoped>
.el-dialog__body {
  padding: 10px 10px 10px 10px;
  color: #606266;
  font-size: 14px;
  word-break: break-all;
}
</style>
<script>
import {
  listArchives,
  getArchives,
  delArchives,
  addArchives,
  updateArchives,
  exportArchives,
  importTemplate
} from "@/api/facility/archives";
import {getToken} from "@/utils/auth";
import importAnnexTable from "./importAnnexTable";
import mixins from "@/layout/mixin/getHeight";
 
const facilityType = "0";
const branchFactory = "0";
const facilityGrade = "0";
export default {
  name: "importAnnex",
  components: {importAnnexTable},
  mixins: [mixins],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 编码选中数组
      codes: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 设备档案表格数据
      archivesList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 主键id字典
      idOptions: [],
      // 编码字典
      codeOptions: [],
      // 设备名称字典
      facilityNameOptions: [],
      // 设备类型字典
      facilityTypeOptions: [],
      // 重点设备字典
      pointFlagOptions: [],
      // 使用分厂字典
      branchFactoryOptions: [],
      // 物理位置字典
      istallationLocationnOptions: [],
      // 能耗等级字典
      facilityGradeOptions: [],
      // 额定功率字典
      ratedPowerOptions: [],
      // 生产日期字典
      productionDateOptions: [],
      // 投运日期字典
      putrunDateOptions: [],
      // 生产厂家字典
      manufacturerOptions: [],
      // 负责人字典
      personChargeOptions: [],
      // 技术参数字典
      technicalDataOptions: [],
      // 起始时间字典
      startTimeOptions: [],
      // 检定周期字典
      checkCycleOptions: [],
      // 提醒周期字典
      reminderCycleOptions: [],
      // 备注字典
      remarkOptions: [],
      // 建立时间字典
      createTimeOptions: [],
      // 监理人字典
      createByOptions: [],
      // 修改时间字典
      updateTimeOptions: [],
      // 修改人字典
      updateByOptions: [],
      upload: {
        // 是否显示弹出层(计量器具档案导入)
        open: false,
        //上传文件类型控制
        accept: undefined,
        // 弹出层标题(计量器具档案导入)
        title: undefined,
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的计量器具档案
        updateSupport: 0,
        // 设置上传的请求头部
        headers: {Authorization: "Bearer " + getToken()},
        // 上传的地址
        url: ""
      },
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        code: undefined,
        facilityName: undefined,
        facilityType: undefined,
        branchFactory: undefined,
        pointFlag: undefined,
        istallationLocationn: undefined,
        facilityGrade: undefined,
        manufacturer: undefined,
        ratedPower: undefined
      },
      height: null,
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        code: [
          {required: true, message: "编码不能为空", trigger: "blur"}
        ],
        facilityName: [
          {required: true, message: "设备名称不能为空", trigger: "blur"}
        ],
        installactionLocation: [
          {required: true, message: "安装位置不能为空", trigger: "blur"}
        ],
        startTime: [
          {required: true, message: "起始时间不能为空", trigger: "blur"}
        ],
        putrunTime: [
          {required: true, message: "投运时间不能为空", trigger: "blur"}
        ],
        checkCycle: [
          {required: true, pattern: /^\+?[1-9]\d*$/, message: "检定周期必须是大于0的正整数", trigger: "blur"}
        ],
        reminderCycle: [
          {required: true, pattern: /^\+?[1-9]\d*$/, message: "提醒周期必须是大于0的正整数", trigger: "blur"}
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("facility_type").then(response => {
      for (let i = 0; i < response.data.length; i++) {
        if (response.data[i].isDefault == "Y") {
          this.facilityType = response.data[i].dictValue;
        }
      }
      this.facilityTypeOptions = response.data;
    });
    this.getDicts("pointFlag").then(response => {
      for (let i = 0; i < response.data.length; i++) {
        if (response.data[i].isDefault == "Y") {
          this.pointFlag = response.data[i].dictValue;
        }
      }
      this.pointFlagOptions = response.data;
    });
    this.getDicts("branch_factory").then(response => {
      for (let i = 0; i < response.data.length; i++) {
        if (response.data[i].isDefault == "Y") {
          this.branchFactory = response.data[i].dictValue;
        }
      }
      this.branchFactoryOptions = response.data;
    });
    this.getDicts("facility_grade").then(response => {
      for (let i = 0; i < response.data.length; i++) {
        if (response.data[i].isDefault == "Y") {
          this.facilityGrade = response.data[i].dictValue;
        }
      }
      this.facilityGradeOptions = response.data;
    });
    this.getDicts("ratedPower").then(response => {
      this.ratedPowerOptions = response.data;
    });
  },
  methods: {
    setCharts() {
      this.bodyStyle = {
        height: window.innerHeight - 210 + 'px',
        overflow: 'hidden'
      }
      this.height = window.innerHeight - 370;
    },
    /** 查询设备档案列表 */
    getList() {
      this.loading = true;
      listArchives(this.queryParams).then(response => {
        this.archivesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 设备类型字典翻译
    facilityTypeFormat(row, column) {
      return this.selectDictLabel(this.facilityTypeOptions, row.facilityType);
    },
    // 使用分厂字典翻译
    branchFactoryFormat(row, column) {
      return this.selectDictLabel(this.branchFactoryOptions, row.branchFactory);
    },
    // 重点设备字典翻译
    pointFlagFactoryFormat(row, column) {
      return this.selectDictLabel(this.pointFlagOptions, row.pointFlag);
    },
    // 能耗等级字典翻译
    facilityGradeFormat(row, column) {
      return this.selectDictLabel(this.facilityGradeOptions, row.facilityGrade);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        code: undefined,
        facilityName: undefined,
        facilityType: undefined,
        branchFactory: undefined,
        istallationLocationn: undefined,
        facilityGrade: undefined,
        ratedPower: undefined,
        productionDate: undefined,
        putrunDate: undefined,
        manufacturer: undefined,
        personCharge: undefined,
        technicalData: undefined,
        startTime: undefined,
        checkCycle: undefined,
        reminderCycle: undefined,
        remark: undefined,
        createTime: undefined,
        createBy: undefined,
        updateTime: undefined,
        updateBy: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.codes = selection.map(item => item.code)
      this.single = selection.length != 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加设备档案";
      this.form.facilityGrade = this.facilityGrade;
      this.form.facilityType = this.facilityType;
      this.form.branchFactory = this.branchFactory
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getArchives(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改设备档案";
      });
    },
    /** 提交按钮 */
    submitForm: function () {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != undefined) {
            updateArchives(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          } else {
            addArchives(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              } else {
                this.msgError(response.msg);
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      const codes = row.code || this.codes;
      this.$confirm('是否确认删除设备档案编编为"' + codes + '"的设备档案吗 ?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return delArchives(ids);
      }).then(() => {
        this.getList();
        this.msgSuccess("删除成功");
      }).catch(function () {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有设备档案数据项?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(function () {
        return exportArchives(queryParams);
      }).then(response => {
        this.download(response.msg);
      }).catch(function () {
      });
    },
    /** 导入按钮操作 */
    handleImport() {
      //this.$refs.upload.clearFiles();
      this.upload.title = "设备档案导入";
      this.upload.accept = ".xlsx, .xls";
      this.upload.url = process.env.VUE_APP_BASE_API + "/facility/archives/imporel-colata?updateSupport=0";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      importTemplate().then(response => {
        this.download(response.msg);
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    /** 打开附件表弹窗 */
    openImportAnnexTable(row) {
      let facid = row.id;
      let faccode = row.code;
      this.$refs.importAnnex.show(facid, faccode);
    },
  }
};
</script>
<style scoped lang="scss">
.special-form {
  @import "~@/assets/styles/common-table-form.scss";
}
 
.dialog-form-row {
  .el-row {
    margin-bottom: 0;
  }
}
</style>