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
<template>
  <a-card
    :bordered="false"
    title=""
  >
    <!-- table区域-begin -->
    <div>
      <div
        class="ant-alert ant-alert-info"
        style="margin-bottom: 16px;"
      >
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a
          style="margin-left: 24px"
          @click="onClearSelected"
        >清空</a>
      </div>
 
      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: 'calc(2200px + 50%)', y: 900 }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        :rowClassName="tableRowClass"
      >
        <!-- :rowSelection="rowSelection" -->
        <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->
 
        <span
          slot="action"
          slot-scope="text, record"
        >
          <a-popconfirm
            title="确定接收工单吗?"
            @confirm="() => handleOrderIssue(record)"
            v-has="'dailyInspectionOrder:issue'"
          >
            <a v-if="record.status == '1'">接收</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status == '1'"
            type="vertical"
          />
          <a-popconfirm
            title="确定撤回工单吗?"
            @confirm="() => handleOrderReset(record)"
            v-has="'dailyInspectionOrder:issue'"
          >
            <a v-if="record.status == '2'">撤回</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status == '2'"
            type="vertical"
          />
          <!-- <a-popconfirm
            title="确定恢复工单吗?"
            @confirm="() => handleOrderRecover(record)"
            v-has="'dailyInspectionOrder:recover'"
          >
            <a v-if="record.status == '7'">恢复</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status == '7'"
            type="vertical"
          /> -->
          <!-- <a-popconfirm
            title="确定作废工单吗?"
            @confirm="() => handleOrderCancel(record)"
            v-has="'dailyInspectionOrder:recover'"
          >
            <a v-if="record.status == '2'">作废</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status == '2'"
            type="vertical"
          /> -->
          <a-popconfirm
            title="确定领取工单吗?"
            @confirm="() => handleOrderGet(record)"
            v-has="'dailyInspectionOrder:get'"
          >
            <a v-if="record.status == '2' && record.assignMode == '1'">领取</a>
          </a-popconfirm>
          <!-- <a
            v-if="record.status == '2' && record.assignMode == '2'  "
            @click="handleAssignOrder(record)"
            v-has="'dailyInspectionOrder:assign'"
          >派工</a> -->
          <!-- <a
            v-if="record.status == '2'&& record.assignMode == '3'  && record.inspectionUserName != null  "
            @click="handleAssignOrder(record)"
            v-has="'dailyInspectionOrder:assign'"
          >改派</a>
          <a
            v-if="record.status == '3'"
            @click="handleAssignOrder(record)"
            v-has="'dailyInspectionOrder:assign'"
          >改派</a>-->
          <a-divider
            v-if="record.status == '2'"
            type="vertical"
          />
          <a-divider
            v-if="record.status === '3'"
            type="vertical"
          />
          <a
            v-if="record.status === '3' || record.status === '4'  "
            @click="handleOrderExe(record)"
            v-has="'dailyInspectionOrder:exe'"
          >执行</a>
          <a-divider
            v-if="record.status === '3' || record.status === '4' "
            type="vertical"
          />
          <a-popconfirm
            title="维修人确认完工吗?"
            @confirm="() => handleOrderRepairConfirm(record)"
            v-has="'dailyInspectionOrder:repairConfirm'"
          >
            <a v-if="record.status == '5'">维修确认</a>
          </a-popconfirm>
          <a-divider
            v-if="record.status == '5'"
            type="vertical"
          />
          <a
            v-if="record.status === '1'"
            @click="handleEdit(record)"
            v-has="'dailyInspectionOrder:edit'"
          >编辑</a>
          <a-divider
            v-if="record.status === '1'"
            type="vertical"
          />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                  v-has="'dailyInspectionOrder:delete'"
                >
                  <a v-if="record.status === '1'">删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
 
        <span
          slot="num"
          slot-scope="text, record"
        >
          <a
            v-if="record.status === '3' || record.status === '4' ||record.status === '5'  ||record.status === '6' "
            class="lot"
            @click="handleOrderExe(record)"
          >{{record.num}}</a>
          <span v-else>{{record.num}}</span>
        </span>
 
      </a-table>
    </div>
 
    <daily-inspection-order-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></daily-inspection-order-modal>
 
    <inspection-order-assign-modal
      ref="InspectionOrderAssignModal"
      @ok="modalFormOk"
    ></inspection-order-assign-modal>
 
    <inspection-order-exe-modal
      ref="InspectionOrderExeModal"
      @ok="modalFormOk"
    ></inspection-order-exe-modal>
    <daily-inspection-order-exe-drawer
      ref="DailyInspectionOrderExeDrawer"
      @ok="modalFormOk"
    ></daily-inspection-order-exe-drawer>
 
  </a-card>
</template>
 
<script>
 
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import DailyInspectionOrderModal from '@/views/eam/modules/dailyInspectionOrder/DailyInspectionOrderModal'
import InspectionOrderAssignModal from '@/views/eam/modules/dailyInspectionOrder/InspectionOrderAssignModal'
import InspectionOrderExeModal from '@/views/eam/modules/dailyInspectionOrder/InspectionOrderExeModal'
import DailyInspectionOrderExeDrawer from '@/views/eam/modules/dailyInspectionOrder/DailyInspectionOrderExeDrawer'
import { getAction, postAction, requestPut } from '@/api/manage'
import moment from 'moment'
 
export default {
  name: 'DailyInspectionOrderListComponent',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    DailyInspectionOrderModal,
    InspectionOrderExeModal,
    DailyInspectionOrderExeDrawer,
    InspectionOrderAssignModal
  },
  props:{
    mainId:{
      type:String,
      default:'',
      required:false
    }
  },
  watch:{
    mainId:{
      immediate: true,
      handler(val) {
        if(!this.mainId){
          this.queryParam['equipmentId'] = 'NAN'
          this.loadData(1);
        }else{
          this.queryParam['equipmentId'] = val
          this.queryParam['statusEnums'] = '6,7'
          this.loadData(1);
        }
      }
    }
  },
  data() {
    return {
      description: '自主维护点检工单',
      finishTime: [],
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
 
        {
          title: '点检工单号',
          align: "center",
          dataIndex: 'num',
          scopedSlots: { customRender: 'num' }
        },
        {
          title: '统一编码',
          align: "center",
          dataIndex: 'equipmentNum'
        },
        {
          title: '状态',
          align: "center",
          width: 100,
          dataIndex: 'statusName'
        },
        {
          title: '点检周期',
          align: "center",
          width: 100,
          dataIndex: 'inspectionCycleName'
        },
        // {
        //   title: '点检日期',
        //   align: "center",
        //   dataIndex: 'inspectionDate',
        //   customRender: function (text) {
        //     return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
        //   }
        // },
        // {
        //   title: '点检时间',
        //   align: "center",
        //   dataIndex: 'inspectionTime',
        //   // customRender: function (text) {
        //   //   return !text ? "" : (text.length > 10 ? text.substr(11, 20) : text)
        //   // }
        // },
        // {
        //   title: '截止时间',
        //   align: "center",
        //   dataIndex: 'inspectionDeadline',
        // },
 
        {
          title: '设备名称',
          align: "center",
          dataIndex: 'equipmentName'
        },
        {
          title: '设备型号',
          align: "center",
          dataIndex: 'equipmentModel'
        },
        {
          title: '使用部门',
          align: "center",
          dataIndex: 'useDepartName'
        },
        {
          title: '责任班组',
          align: "center",
          dataIndex: 'teamName'
        },
        // {
        //   title: '开工条件',
        //   align: "center",
        //   dataIndex: 'startWorkCondition',
        //   customRender: (text) => {
        //     if (text == '1') {
        //       return "是";
        //     } else if (text == '0') {
        //       return "否";
        //     }
        //   },
        // },
        // {
        //   title: '点检标准编码',
        //   align: "center",
        //   dataIndex: 'inspectionStandardNum'
        // },
 
        // {
        //   title: '派工方式',
        //   align: "center",
        //   dataIndex: 'assignModeName'
        // },
        // {
        //   title: '点检结果',
        //   align: "center",
        //   dataIndex: 'result'
        // },
        {
          title: '点检人',
          align: "center",
          dataIndex: 'inspectionUserName'
        },
        {
          title: '点检时间',
          align: "center",
          dataIndex: 'actualEndTime',
          // customRender: function (text) {
          //   return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          // }
        },
        {
          title: '维修确认人',
          align: "center",
          dataIndex: 'repairConfirmPerson'
        },
        {
          title: '确认时间',
          align: "center",
          dataIndex: 'repairConfirmDate',
          // customRender: function (text) {
          //   return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
          // }
        },
        // {
        //   title: '创建人',
        //   align: "center",
        //   dataIndex: 'createBy'
        // },
        // {
        //   title: '创建日期',
        //   align: "center",
        //   dataIndex: 'createTime',
        // },
 
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 230,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: "/eam/inspectionOrder/getInspectionOrderList",
        delete: "/eam/inspectionOrder/delete",
        deleteBatch: "/eam/inspectionOrder/deleteBatch",
        exportXlsUrl: "/eam/inspectionOrder/exportXls",
        importExcelUrl: "eam/inspectionOrder/importExcel",
        edit: "/eam/inspectionOrder/editStatus",
        orderGet: "/eam/inspectionOrder/orderGet",
      },
 
    }
  },
  created() {
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
    rowSelection() {
      return {
        type: 'checkbox',
        onChange: (selectedRowKeys, selectedRows) => {
          this.selectedRowKeys = selectedRowKeys;
          this.onSelectChange(selectedRows);
        },
        getCheckboxProps: record => ({
          props: {
            disabled: record.distable
          },
        }),
        selectedRowKeys: this.selectedRowKeys,
      };
    },
  },
  methods: {
 
    // handleOrderExe(record) {
    //   this.$refs.InspectionOrderExeModal.visible = true
    //   this.$refs.InspectionOrderExeModal.title = '日常点检执行'
    //   this.$refs.InspectionOrderExeModal.handleShow(record)
    // },
    //改派
    handleAssignOrder: function (record) {
      this.$refs.InspectionOrderAssignModal.edit(record)
      this.$refs.InspectionOrderAssignModal.title = '工单改派'
      this.$refs.InspectionOrderAssignModal.disableSubmit = false
    },
    handleOrderExe(record) {
      this.$refs.DailyInspectionOrderExeDrawer.visible = true
      this.$refs.DailyInspectionOrderExeDrawer.title = '自主维护点检执行'
      this.$refs.DailyInspectionOrderExeDrawer.handleShow(record)
      if (record.status === '3') {
        this.$refs.DailyInspectionOrderExeDrawer.buttonDistable = true//保存、暂存、报工
        this.$refs.DailyInspectionOrderExeDrawer.revocationDistable = true//撤销按钮
        this.$refs.DailyInspectionOrderExeDrawer.SWbuttonDistable = false//开工按钮
      } else if (record.status === '4') {
        this.$refs.DailyInspectionOrderExeDrawer.buttonDistable = false
        this.$refs.DailyInspectionOrderExeDrawer.revocationDistable = true
        this.$refs.DailyInspectionOrderExeDrawer.SWbuttonDistable = true
      } else if (record.status === '5') {
        this.$refs.DailyInspectionOrderExeDrawer.buttonDistable = true
        this.$refs.DailyInspectionOrderExeDrawer.revocationDistable = false
        this.$refs.DailyInspectionOrderExeDrawer.SWbuttonDistable = true
      } else if (record.status === '6') {
        this.$refs.DailyInspectionOrderExeDrawer.buttonDistable = true
        this.$refs.DailyInspectionOrderExeDrawer.revocationDistable = true
        this.$refs.DailyInspectionOrderExeDrawer.SWbuttonDistable = true
      }
    },
 
    onSelectChange(selectionRows) {
      this.selectionRows = selectionRows;
    },
 
    handleOrderIssue(record) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: '2' }).then((res) => {
        if (res.success) {
          that.$message.success("工单下发成功!")
          that.loadData()
        } else {
          that.$message.warning("工单下发失败!")
        }
      })
    },
    //撤回
    handleOrderReset(record) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: '1' }).then((res) => {
        if (res.success) {
          that.$message.success("工单撤回成功!")
          that.loadData()
        } else {
          that.$message.warning("工单撤回失败!")
        }
      })
    },
    handleOrderGet(record) {
      const that = this;
      requestPut(that.url.orderGet, { id: record.id, status: '3' }).then((res) => {
        if (res.success) {
          that.$message.success("工单领取成功!")
          that.loadData()
        } else {
          that.$message.warning("工单领取失败!")
        }
      })
    },
    //维修确认
    handleOrderRepairConfirm(record) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: '6' }).then((res) => {
        if (res.success) {
          that.$message.success("工单完工成功!")
          that.loadData()
        } else {
          that.$message.warning("工单完工失败!")
        }
      })
    },
 
    //恢复
    handleOrderRecover(record) {
      const that = this;
      requestPut(that.url.edit, { id: record.id, status: '2' }).then((res) => {
        if (res.success) {
          that.$message.success("工单恢复成功!")
          that.loadData()
        } else {
          that.$message.warning("工单恢复失败!")
        }
      })
    },
 
    //预警颜色
    tableRowClass(record, index) {
      if (("1" == record.status || "2" == record.status) && "1日" == record.inspectionCycleName) {
        if (record.redWarningTime < record.currentDateTime) {
          return 'error'
        }
      }
    },
    clearList(){
      this.dataSource=[]
      this.selectedRowKeys=[]
      this.ipagination.current = 1
    }
 
  }
}
</script>
<style>
@import '~@assets/less/common.less';
.frozenRowClass {
  color: #c9c9c9;
  font-weight: bold;
}
.success {
  color: green;
}
.error {
  color: red;
  font-weight: bold;
}
.yellow {
  color: rgba(255, 255, 0, 0.443);
  font-weight: bold;
}
.fontweight {
  font-weight: bold;
}
 
.ant-table-tbody .red {
  background-color: red !important;
}
</style>