“linengliang”
2023-08-25 02d86ec24676f6d682277eb8e493e755d677c179
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
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules" >
        <a-row>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 设备基础信息 </a-divider>
          <a-col :span="6">
            <a-form-model-item label="设备所属分类" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentCategoryId">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择设备所属分类" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="mom_eam_equipment_category,name,id"
                v-model="model.equipmentCategoryId"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="统一编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="num">
              <a-input v-model="model.num" placeholder="由系统生成"  :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设备名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
              <a-input v-model="model.name" placeholder="请输入设备名称"  :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="型号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="model">
              <a-input v-model="model.model" placeholder="请输入型号"  :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="规格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specification">
              <a-input v-model="model.specification" placeholder="请输入规格"  :disabled="formDisabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="总功率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gpo">
              <a-input v-model="model.gpo" placeholder="请输入总功率" :disabled="formDisabled"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设备图片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentPhoto">
              <j-image-upload
                :isMultiple="false"
                v-model="model.equipmentPhoto"
              ></j-image-upload>
            </a-form-model-item>
          </a-col>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">维护及使用信息</a-divider>
          <a-col :span="6">
            <a-form-model-item label="维护部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="manageId">
              <a-tree-select
                :disabled="formDisabled"
                style="width: 100%"
                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                :tree-data="treeData"
                placeholder="请选择维护部门" 
                tree-default-expand-all
                v-model="model.manageId"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="使用部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="useId">
              <a-tree-select
                style="width: 100%"
                :disabled="formDisabled"
                :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
                :tree-data="treeData"
                placeholder="请选择使用部门"
                tree-default-expand-all
                v-model="model.useId"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="维修班组" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
              <j-dict-select-tag
                allow-clear
                :disabled="formDisabled"
                placeholder="请选择责任班组"
                :triggerChange="true"
                dictCode="mom_base_team,name,id,status='1' and del_flag='0'"
                v-model="model.teamId"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="资产制造商" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="constructorId">
              <j-dict-select-tag
                allow-clear
                :disabled="formDisabled" 
                placeholder="请选择资产制造商"
                :triggerChange="true"
                dictCode="mom_base_constructor,name,id,status!='0' and del_flag!='1'"
                v-model="model.constructorId"
              />
            </a-form-model-item>
          </a-col>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">状态及标识</a-divider>
          <a-col :span="6">
            <a-form-model-item label="关键设备标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="specificEquipment">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择关键设备标识" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="specific_equipment"
                v-model="model.specificEquipment"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设备状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentStatus">
              <j-dict-select-tag
                allow-clear
                :disabled="formDisabled"
                placeholder="请输入设备状态"
                :triggerChange="true"
                dictCode="equipment_status"
                v-model="model.equipmentStatus"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="技术状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="technologyStatus">
              <j-dict-select-tag
                allow-clear
                :disabled="formDisabled"
                placeholder="请选择技术状态"  
                :triggerChange="true"
                dictCode="technology_status"
                v-model="model.technologyStatus"
              />
            </a-form-model-item>
          </a-col>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">出厂及安装信息</a-divider>
          <a-col :span="6">
            <a-form-model-item label="出厂编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="factoryNumber">
              <a-input
               :disabled="formDisabled"
                placeholder="请输入出厂编号"
                v-model="model.factoryNumber"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="出厂日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="leaveFactoryDate">
              <a-date-picker
                :disabled="formDisabled"
                placeholder="请输入出厂日期"
                style="width: 100%;"
                v-model="model.leaveFactoryDate"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="验收日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="acceptanceCheckDate">
              <a-date-picker
                :disabled="formDisabled"
                placeholder="请输入验收日期"
                style="width: 100%;"
                v-model="model.acceptanceCheckDate"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="立项卡号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectApprovalNo">
              <a-input v-model="model.projectApprovalNo" :disabled="formDisabled" placeholder="请输入立项卡号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工区" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentUda1">
              <a-input v-model="model.equipmentUda1" placeholder="请输入工区" :disabled="formDisabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="重量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentUda3">
              <a-input v-model="model.equipmentUda3"  :disabled="formDisabled" placeholder="请输入重量" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="重量计量单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentUda4">
              <a-input v-model="model.equipmentUda4" :disabled="formDisabled" placeholder="请输入重量计量单位ID" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="安装位置" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="location">
              <a-input v-model="model.location" placeholder="请输入安装位置" :disabled="formDisabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="功能位置" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentUda5">
              <a-input v-model="model.equipmentUda5" :disabled="formDisabled" placeholder="请输入功能位置" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="资金来源" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fundSource">
              <a-input v-model="model.fundSource" :disabled="formDisabled" placeholder="请输入资金来源" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="资产来源国家" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sourceCountry">
              <a-input v-model="model.sourceCountry" :disabled="formDisabled" placeholder="请输入资产来源国家" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="安全配置" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="securityConfiguration">
              <a-input v-model="model.securityConfiguration" :disabled="formDisabled" placeholder="请输入安全配置" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="冷却系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coolingSystem">
              <a-input v-model="model.coolingSystem" :disabled="formDisabled" placeholder="请输入冷却系统" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="灭火器" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fireExtinguisher">
              <a-input v-model="model.fireExtinguisher" :disabled="formDisabled" placeholder="请输入灭火器" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="灭火器有效期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="fireExtinguisherValidityPeriod">
              <a-input v-model="model.fireExtinguisherValidityPeriod" :disabled="formDisabled" placeholder="请输入灭火器有效期" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="操作系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operatingSystem">
              <a-input v-model="model.operatingSystem" :disabled="formDisabled" placeholder="请输入操作系统" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="系统" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="system">
              <a-input v-model="model.system" :disabled="formDisabled" placeholder="请输入系统" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="端口" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="port">
              <a-input v-model="model.port" :disabled="formDisabled"  placeholder="请输入端口" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="坐标数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="coordinateNum">
              <a-input-number v-model="model.coordinateNum" :disabled="formDisabled" placeholder="请输入坐标数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-input v-model="model.remark" placeholder="请输入备注" :disabled="formDisabled" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;">ABC标识</a-divider>
          <a-col :span="6">
            <a-form-model-item label="平均使用率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardA">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择平均使用率" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardA"
                v-model="model.standardA"
                @change="standardResultCompute"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="可替换性" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardB">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择可替换性" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardB"
                v-model="model.standardB"
                @change="standardResultCompute"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="故障影响度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardC">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择故障影响度" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardC"
                v-model="model.standardC"
                @change="standardResultCompute"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="生产超差度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardD">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择生产超差度" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardD"
                v-model="model.standardD"
                @change="standardResultCompute"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="故障频率" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardE">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择故障频率" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardE"
                @change="standardResultCompute"
                v-model="model.standardE"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="设备价值" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="standardF">
              <j-dict-select-tag
                allow-clear
                placeholder="请选择设备价值" 
                :disabled="formDisabled" 
                :triggerChange="true"
                dictCode="ABC-standardF"
                v-model="model.standardF"
                @change="standardResultCompute"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="ABC标识" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentImportanceId">
              <j-dict-select-tag
                allow-clear
                :disabled="formDisabled"
                placeholder ="请选择ABC标识"
                :triggerChange="true"
                dictCode="ABC-standard-result"
                v-model="model.equipmentImportanceId"
              />
            </a-form-model-item>
          </a-col>
          <a-divider orientation="center" style="font-size: large;font-style: italic;color: #66aeed;"> 精度及模版 </a-divider>
          <a-col :span="6">
            <a-form-model-item label="设备精度管理" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="precisionParameters">
              <a-switch
                :disabled="formDisabled" 
                checked-children="是"
                un-checked-children="否"
                :checked="model.precisionParameters == '1'"
                @change="handle2Switch(model.precisionParameters)"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6" v-if="model.precisionParameters == '1'">
            <a-form-model-item label="设备精度模版" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="precisionParametersTemplateId">
              <a-input-search
              :disabled="formDisabled"
                placeholder="请选择设备精度模板"
                enter-button
                @search="onSearchPrecisionParametersTemplate()"
                :read-only="true"
                v-model="model.precisionParametersTemplateName"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6">
            <a-form-model-item label="工艺模版管理" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="processParameters">
              <a-switch
              :disabled="formDisabled"
                checked-children="是"
                un-checked-children="否"
                :checked="model.processParameters == '1'"
                @change="handleSwitch(model.processParameters)"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="6" v-if="model.processParameters == '1'">
            <a-form-model-item label="设备工艺模版" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="precisionParametersTemplateId">
              <a-input-search
              :disabled="formDisabled"
                placeholder="请选择设备工艺模板"
                enter-button
                @search="onSearchProcessParametersTemplate()"
                :read-only="true"
                v-model="model.processParametersTemplateName"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <process-parameters-template-list
      ref="ProcessParametersTemplateList"
      @sendProcessParametersTemplateRecord='sendProcessParametersTemplateRecord'
    ></process-parameters-template-list>
    <precision-parameters-template-list
      ref="PrecisionParametersTemplateList"
      @sendPrecisionParametersTemplateRecord='sendPrecisionParametersTemplateRecord'
    ></precision-parameters-template-list>
    </a-spin>
  </j-modal>
</template>
<script>
  import { httpAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import pick from 'lodash.pick'
  import { postAction, requestPut, getAction } from '@/api/manage'
  import { duplicateCheck } from '@/api/api'
  import moment from 'moment'
  import ProcessParametersTemplateList from '../equipment/ProcessParametersTemplateList'
  import PrecisionParametersTemplateList from '../equipment/PrecisionParametersTemplateList'
  import { JVxeTableModelMixin } from '@/mixins/JVxeTableModelMixin.js'
  import { JVXETypes } from '@/components/jeecg/JVxeTable'
  export default {
    name: "EquipmentModal",
    mixins: [JVxeTableModelMixin],
    components: { 
      validateDuplicateValue,
      ProcessParametersTemplateList,
      PrecisionParametersTemplateList,
    },
    props:{
      disableSubmit: {
        type: Boolean,
        default: false,
        required: false
      },
    },
    data () {
      return {
        title:"操作",
        width:1500,
        visible: false,
        model:{
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
 
        confirmLoading: false,
        validatorRules: {
          num: [
            { required: true, message: '请输入设备编号!' },
            { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
            { validator: this.validateNum },
          ],
        name:[
            { required: true, message: '请输入设备名称!' },
            { min: 2, max: 30, message: '长度在 2 到 30 个字符', trigger: 'blur' },
            { validator: this.validateName },
          ],
        teamId:[
            { required: true, message: '请选择责任班组!' },
          ],
        processParametersTemplateName:[
            { required: true, message: '请选择工艺参数模板!' },
          ],
        precisionParametersTemplateName: [
            { required: true, message: '请选择设备精度模板!' },
          ],
        remark:[
            { min: 0, max: 100, message: '长度不超过 100 个字符', trigger: 'blur' },
          ],
        equipmentCategoryId:[
          { required: true, message: '请选则设备类别!' },
        ]
        },
        url: {
          add: "/eam/equipment/add",
         edit: "/eam/equipment/edit",
         loadOptions: '/sys/sysDepart/loadDepartTreeOptions',
        },
        treeData: [],
     
      }
    },
    created () {
    //备份model原始值
      this.initOptions();
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        console.log(this.disabled)
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false
          }
        })
      },
      handleCancel () {
        this.close()
      },
      validateNum(rule, value, callback) {
      var params = {
        tableName: 'mom_eam_equipment',
        fieldName: 'num',
        fieldVal: value,
        dataId: this.model.id,
        //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
        delFlag: '0',
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback();
        } else {
          callback("编号已存在!");
        }
      })
    },
 
    //验证 名称
    validateName(rule, value, callback) {
      var params = {
        tableName: 'mom_eam_equipment',
        fieldName: 'name',
        fieldVal: value,
        dataId: this.model.id,
        //数据库中存在字段del_flag并使用该字段作为未删除策略,真删除:false 假删除:true
        delFlag: '0',
      };
      duplicateCheck(params).then((res) => {
        if (res.success) {
          callback();
        } else {
          callback("名称已存在!");
        }
      })
    },
 
    handleSwitch(processParameters) {
      if ('1' == processParameters) {
        this.model.processParameters = '0'
      } else {
        this.model.processParameters = '1'
      }
      this.model = Object.assign({},this.model);
    },
    handle2Switch(precisionParameters) {
      if ('1' == precisionParameters) {
        this.model.precisionParameters = '0'
      } else {
        this.model.precisionParameters = '1'
      }
      this.model = Object.assign({},this.model);
    },
    initOptions() {
      getAction(this.url.loadOptions).then(res => {
        if (res.success) {
          this.treeData = res.result
        } else {
          this.$message.warning(res.message)
        }
      })
    },
 
    handle2Change(val) {
      if (val === null) {
        setTimeout(() => {
          this.form.setFieldsValue({ useId: "" });
        }, 100)
      }
    },
    handle1Change(val) {
      if (val === null) {
        setTimeout(() => {
          this.form.setFieldsValue({ affiliationId: "" });
        }, 100)
      }
    },
 
    handle3Change(val) {
      if (val === null) {
        setTimeout(() => {
          this.form.setFieldsValue({ manageId: "" });
        }, 100)
      }
    },
 
    uploadOk(imgList) {
      this.model.sysUploadList = imgList
      this.equipmentPhoto = this.getSrc(imgList[0])
      // this.$set(this.model, 'photo', res);
      // this.$set(this.model, 'sysUploadList', imgList);
    },
    
    onSearchProcessParametersTemplate() {
      this.$refs.ProcessParametersTemplateList.list();
      this.$refs.ProcessParametersTemplateList.title = "选择工艺参数模板";
    },
    sendProcessParametersTemplateRecord(data) {
      let record = data.record;
      this.model.processParametersTemplateId = record.id
      this.model.processParametersTemplateName = record.name
      this.model = Object.assign({},this.model);
    },
 
    onSearchPrecisionParametersTemplate() {
      this.$refs.PrecisionParametersTemplateList.list();
      this.$refs.PrecisionParametersTemplateList.title = "选择设备精度模板";
    },
    sendPrecisionParametersTemplateRecord(data) {
      let record = data.record;
      this.model.precisionParametersTemplateId = record.id
      this.model.precisionParametersTemplateName = record.name
      this.model = Object.assign({},this.model);
    },
    standardResultCompute(){
 
      var standardA = this.model.standardA==null||this.model.standardA==undefined||this.model.standardA==''?0:parseInt(this.model.standardA);
      var standardB = this.model.standardB==null||this.model.standardB==undefined||this.model.standardB==''?0:parseInt(this.model.standardB);
      var standardC = this.model.standardA==null||this.model.standardC==undefined||this.model.standardC==''?0:parseInt(this.model.standardC);
      var standardD = this.model.standardD==null||this.model.standardD==undefined||this.model.standardD==''?0:parseInt(this.model.standardD);
      var standardE = this.model.standardE==null||this.model.standardE==undefined||this.model.standardE==''?0:parseInt(this.model.standardE);
      var standardF = this.model.standardF==null||this.model.standardF==undefined||this.model.standardF==''?0:parseInt(this.model.standardF);
 
      var sum = standardA+standardB+standardC+standardD+standardE+standardF;
      console.log(sum)
      if(sum>=18){
         this.model.equipmentImportanceId='A'
      }else if(sum>=10&&sum<=17){
        this.model.equipmentImportanceId='B'
      }else{
        this.model.equipmentImportanceId='C'
      }
      this.model = Object.assign({},this.model);
      
    }
    },
    computed: {
      formDisabled(){
        return this.disableSubmit
      },
    },
    watch: {
    alterFlag() {
      this.$bus.$emit('queryTreeData');
    },
    },
  }
</script>