zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
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
<template>
  <div class="mod-config">
    <basic-container>
      <ttable
        :table="table"
        @currentChange="handleCurrentChange"
        @rowClick="rowClick"
        :uploadInfo="uploadInfo"
        :prelang="prelang"
        :options="options"
        :ajaxFun="ajaxFun"
        :paramObj="paramObj"
        ref="dutyRecordTable"
        :bottomOffset="400"
        :fixedHeight="400"
      >
        <template #toolbar></template>
      </ttable>
      <div style="background-color: #F0F2F5;height: 10px" />
      <el-tabs type="border-card" ref="tabs">
        <el-tab-pane label="人工" type="card">
          <el-row style="background-color: #F0F2F5">
            <el-col :span="7" style="height: 400px">
              <el-table
                border
                ref="handymanTypeTable"
                :data="handymanTypeList"
                height="100%"
                :row-style="{ height: '26px' }"
                :cell-style="{ padding: '0' }"
                highlight-current-row
                @row-click="changeHandymanType"
              >
                <el-table-column
                  label="人工名称"
                  prop="handymanName"
                  align="center"
                  min-width="50%"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="标准定额"
                  prop="standardHourWage"
                  align="center"
                  min-width="25%"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="转换系数"
                  prop="conversionCoefficient"
                  align="center"
                  min-width="25%"
                  show-overflow-tooltip
                />
              </el-table>
            </el-col>
            <el-col :span="17" style="height: 400px;padding-left: 10px">
              <el-table
                border
                height="100%"
                ref="artificialInformationTable"
                :data="artificialInformationList"
                :row-style="{ height: '26px' }"
                :cell-style="cellStyle"
                :span-method="objectSpanMethod"
              >
                <el-table-column
                  label="处理"
                  prop="processed"
                  align="center"
                  min-width="5%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="人员"
                  prop="staffName"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="个人工时"
                  prop="workingHours"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="个人次数"
                  prop="personNumber"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="个人产量"
                  prop="personOutput"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="结算"
                  prop="settlement"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="各项总和"
                  prop="totalSettlement"
                  align="center"
                  min-width="10%"
                  show-overflow-tooltip
                ></el-table-column>
                <el-table-column
                  label="备注"
                  prop="remark"
                  align="center"
                  min-width="20%"
                  show-overflow-tooltip
                ></el-table-column>
              </el-table>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="产量" type="card">
          <el-row>
            <el-col :span="24" style="height: 400px">
              <el-table
                stripe
                ref="outputList"
                :data="outputList"
                height="100%"
                border
                :row-style="{ height: '26px' }"
                :cell-style="{ padding: '0' }"
              >
                <el-table-column
                  label="产出序列号"
                  prop="systemNo"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="缆号"
                  prop="outBatchNo"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="数量"
                  prop="productQty"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="单位"
                  prop="unit"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="零件编号"
                  prop="partNo"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="零件规格"
                  prop="specs"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="工单编号"
                  prop="optaskNo"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
              </el-table>
            </el-col>
          </el-row>
        </el-tab-pane>
        <el-tab-pane label="出勤时间" type="card">
          <el-row>
            <el-col :span="24" style="height: 400px">
              <el-table
                stripe
                ref="personList"
                :data="personList"
                height="100%"
                border
                :row-style="{ height: '26px' }"
                :cell-style="{ padding: '0' }"
              >
                <el-table-column
                  label="人员名称"
                  prop="staffName"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="人员编号"
                  prop="staffNo"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="出勤时间"
                  prop="dutyTime"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="工资"
                  prop="salary"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="出勤总时间"
                  prop="totalDutyTime"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
                <el-table-column
                  label="总工资"
                  prop="totalSalary"
                  align="center"
                  width="120px"
                  show-overflow-tooltip
                />
              </el-table>
            </el-col>
          </el-row>
        </el-tab-pane>
      </el-tabs>
    </basic-container>
  </div>
</template>
 
<script>
import {
  fetchListDutyRecord,
  getPersonByDutyRecordId,
  getOutputByDutyRecordId,
  putDutyRecord
} from '@/api/product/dutyrecord'
import { getAllHandymanTemplate } from '@/api/product/handymantemplate'
import { computeByDutyRecordId } from '@/api/product/computation'
import {
  getHandymanTypeByDutyRecordId,
  getComputationArtificialInformation
} from '@/api/product/artificialinformation'
import { mapGetters } from 'vuex'
import ttable from '@/views/common/ztt-table.vue'
import { highPrecisionAdd } from '@/util/highPrecision'
 
export default {
  props: {
    workstationId: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      ajaxFun: fetchListDutyRecord,
      dataListLoading: false,
      isShowQuery: false,
      multipleSelection: [],
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: false,
        url: ''
      },
      dateTimeFilters: {},
      prelang: 'operation',
      options: {
        height: 300, // 默认高度-为了表头固定
        stripe: true, // 是否为斑马纹 table
        highlightCurrentRow: false, // 是否要高亮当前行
        border: true, // 是否有纵向边框
        lazy: false, // 是否需要懒加载
        fit: true, // 列的宽度是否自撑开
        multiSelect: false, //
        seqNo: true,
        isRefresh: true, // 是否显示刷新按钮
        isShowHide: true, // 是否显示显影按钮
        isSearch: false, // 高级查询按钮
        defaultOrderBy: { column: 'dutyDate', direction: 'desc' }
      },
      table: {
        total: 0,
        currentPage: 1,
        pageSize: 20,
        data: [],
        // 标题
        column: [
          {
            width: '100',
            prop: 'dutyNo',
            label: '班次编号',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '60',
            prop: 'isConfirm',
            label: '确认',
            sort: false,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'select',
            formatter: this.formatIsConfirm,
            optList: () => {
              return this.isConfirmOptions
            }
          },
          {
            width: '100',
            prop: 'dutyDate',
            label: '班次日期',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'datetimerange',
            formatter: this.formatDutyDate
          },
          {
            width: '80',
            prop: 'shiftName',
            label: '生产班次',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '100',
            prop: 'workstationName',
            label: '工作站',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '80',
            prop: 'dutyTime',
            label: '班次时间',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '80',
            prop: 'crewName',
            label: '生产班组',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '100',
            prop: 'dutyOutput',
            label: '班次产量',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '80',
            prop: 'pending',
            label: '待处理',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '140',
            prop: 'receiveRemark',
            label: '接班记录',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '140',
            prop: 'deliveryRemark',
            label: '交班记录',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '140',
            prop: 'startTime',
            label: '开始',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'datetimerange'
          },
          {
            width: '140',
            prop: 'endTime',
            label: '结束',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'datetimerange'
          },
          {
            width: '80',
            prop: 'createUser',
            label: '创建人',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          {
            width: '140',
            prop: 'createTime',
            label: '创建时间',
            sort: true,
            isTrue: true,
            isSearch: true,
            searchInfoType: 'datetimerange'
          }
        ],
        toolbar: [
          {
            text: '计算',
            type: 'primary',
            disabled: true,
            fun: this.computation
          },
          {
            text: '确认',
            type: 'primary',
            disabled: true,
            fun: this.confirmDutyRecord
          },
          {
            text: '退回',
            type: 'primary',
            disabled: true,
            fun: this.cancelDutyRecord
          }
        ],
        operatorConfig: {
          fixed: 'right',
          label: '操作',
          width: 100,
          minWidth: 100
        }
      },
      personList: [],
      outputList: [],
      currentDutyRecord: null,
      showStaff: false,
      artificialInformationList: [],
      handymanTypeList: [],
      showHandymanType: false,
      handymanTemplates: [],
      paramObj: { isSubmit: true },
      spanArr: [],
      summaryArr: [],
      isConfirmOptions: [
        { value: true, label: '是' },
        { value: false, label: '否' }
      ],
      currentHandymanTypeId: 0
    }
  },
  components: {
    ttable
  },
  computed: {
    ...mapGetters(['permissions'])
  },
  watch: {
    currentDutyRecord: {
      handler: function(newVal, oldVal) {
        const computationButton = this.table.toolbar.find(
          (item) => item.text == '计算'
        )
        const confirmButton = this.table.toolbar.find(
          (item) => item.text == '确认'
        )
        const cancelButton = this.table.toolbar.find(
          (item) => item.text == '退回'
        )
        if (this.currentDutyRecord && this.currentDutyRecord.id) {
          // 计算提交取消按钮是否可用
          if (confirmButton) {
            confirmButton.disabled = this.currentDutyRecord.isConfirm
          }
          if (cancelButton) {
            cancelButton.disabled = !this.currentDutyRecord.isConfirm
          }
          if (computationButton) {
            computationButton.disabled = !this.currentDutyRecord.isConfirm
          }
        } else {
          if (confirmButton) {
            confirmButton.disabled = true
          }
          if (cancelButton) {
            cancelButton.disabled = true
          }
          if (computationButton) {
            computationButton.disabled = true
          }
        }
      },
      immediate: true
    }
  },
  methods: {
    // 获取数据列表
    getData() {
      this.$refs.dutyRecordTable.getDataList()
      this.currentDutyRecord = null
    },
    // 获取人工列表
    getHandymanType() {
      // 1.获取人工类型
      getHandymanTypeByDutyRecordId([this.currentDutyRecord.id]).then(
        (response) => {
          this.handymanTypeList = response.data.data
        }
      )
      // 2.获取所有的人工
      this.getArtificialInformation(
        Object.assign({ dutyRecordId: this.currentDutyRecord.id })
      )
    },
    // 获取人工
    getArtificialInformation(paramObj) {
      getComputationArtificialInformation(paramObj).then((response) => {
        this.artificialInformationList = response.data.data
        this.getSpanArr(this.artificialInformationList)
      })
    },
    // 获取出勤时间
    getPerson() {
      getPersonByDutyRecordId(this.currentDutyRecord.id).then((response) => {
        this.personList = response.data.data
      })
    },
    // 单行选中
    handleCurrentChange(val) {
      if (
        val &&
        (!this.currentDutyRecord || this.currentDutyRecord.id != val.id)
      ) {
        this.currentDutyRecord = val
        // 1.出勤时间
        this.getPerson()
        // 2.产量
        getOutputByDutyRecordId(this.currentDutyRecord.id).then((response) => {
          this.outputList = response.data.data
        })
        // 3.人工
        this.getHandymanType()
        // 4.清数据
        this.currentHandymanTypeId = 0
      }
    },
    // 单行点击
    rowClick(val) {
      this.handleCurrentChange(val)
    },
    // 格式化日期
    formatDutyDate(row, column, cellValue) {
      if (cellValue) {
        const dutyDateList = /\d{4}-\d{1,2}-\d{1,2}/g.exec(cellValue)
        if (dutyDateList && dutyDateList.length > 0) {
          return dutyDateList[0]
        }
      }
      return ''
    },
    // 单行点击人工项目
    changeHandymanType(row) {
      if (row && row.id && row.id != this.currentHandymanTypeId) {
        this.currentHandymanTypeId = row.id
        this.getArtificialInformation(
          Object.assign({
            dutyRecordId: this.currentDutyRecord.id,
            handymanTypeId: row.id
          })
        )
      } else {
        this.currentHandymanTypeId = 0
        this.$refs.handymanTypeTable.setCurrentRow(-1)
        this.getArtificialInformation(
          Object.assign({ dutyRecordId: this.currentDutyRecord.id })
        )
      }
    },
    // 计算已确认班次的工资
    computation() {
      computeByDutyRecordId(this.currentDutyRecord.id).then((data) => {
        this.$message.success('计算完成')
        this.getHandymanType()
        this.getPerson()
      })
    },
    // 确认班次报工信息
    confirmDutyRecord() {
      this.$confirm('是否确认', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '退回',
        closeOnClickModal: false,
        type: 'warning'
      }).then(() => {
        putDutyRecord(
          Object.assign({
            id: this.currentDutyRecord.id,
            isConfirm: !this.currentDutyRecord.isConfirm
          })
        ).then((data) => {
          this.$message.success('确认成功')
          this.getData()
        })
      })
    },
    // 取消班次报工信息
    cancelDutyRecord() {
      putDutyRecord(
        Object.assign({
          id: this.currentDutyRecord.id,
          isConfirm: !this.currentDutyRecord.isConfirm
        })
      ).then((data) => {
        this.$message.success('取消成功')
        this.getData()
      })
    },
    // 确认列中文格式化
    formatIsConfirm(row, column, cellValue) {
      if (cellValue) {
        return '是'
      } else {
        return '否'
      }
    },
    // 单元格-处理上色
    cellStyle({ row, column, rowIndex, columnIndex }) {
      if (column.label == '处理' && row.processed == '是') {
        return 'background: #007D65;color:white;padding: 0px'
      }
      return 'padding: 0px'
    },
    // 合并行
    getSpanArr(data) {
      this.spanArr.length = 0
      this.summaryArr.length = 0
      for (var i = 0; i < data.length; i++) {
        if (i === 0) {
          this.spanArr.push(1)
          this.summaryArr.push(data[i].settlement)
          this.pos = 0
        } else {
          // 判断人员是否相同
          if (data[i].staffId && data[i].staffId === data[i - 1].staffId) {
            this.spanArr[this.pos] += 1
            this.summaryArr[this.pos] = highPrecisionAdd(
              this.summaryArr[this.pos],
              data[i].settlement
            )
            this.spanArr.push(0)
            this.summaryArr.push(0)
          } else {
            this.spanArr.push(1)
            this.summaryArr.push(data[i].settlement)
            this.pos = i
          }
        }
      }
    },
    // 单元格合并
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (columnIndex === 1) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        return {
          // [0,0] 表示这一行不显示, [2,1]表示行的合并数
          rowspan: _row,
          colspan: _col
        }
      }
      if (columnIndex === 6) {
        const _row = this.spanArr[rowIndex]
        const _col = _row > 0 ? 1 : 0
        row.totalSettlement = this.summaryArr[rowIndex]
        return {
          // [0,0] 表示这一行不显示, [2,1]表示行的合并数
          rowspan: _row,
          colspan: _col
        }
      }
    }
  }
}
</script>
 
<style>
.el-table .warning-row {
  background: oldlace;
}
.img-onlyRead {
  pointer-events: none;
}
</style>