chenlu
2024-03-01 ede4e6aef5421f3a28fb4bc083ee60025b1b5f03
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
<script setup>
import {reactive, ref} from "vue";
import {useRouter} from 'vue-router'
import request from "@/utils/request";
import {ElMessage} from "element-plus";
import {changeFilterEvent, filterChanged} from "@/hook"
import {indexOf} from "xe-utils";
 
const xGrid = ref()
let router = useRouter()
const getTableRow = (row, type) => {
  switch (type) {
    case 'edit' : {
      //alert('我接收到子组件传送的编辑信息')
      router.push({path: '/main/processCard/PrintFlowCard', query: {id: row.id}})
      break
    }
    case 'delete': {
      alert('我接收到子组件传送的删除信息')
      break
    }
    case  'setType': {
      alert('我接收到子组件传送的排版状态')
      break
    }
  }
}
 
//定义表头数据
const titleUploadData = ref({
  //销售单号
  orderId: '',
  //生产单号
  productionId: '',
  //设备类型
  deviceType: '',
  //班组类型
  teamsType: '',
  //生产日期
  reportingWorkDate: '',
  //报工工序
  thisProcess: '',
  //上工序
  previousProcess: '',
  //下工序
  nextProcess: '',
  //备注
  notes: '',
  //本工序完工数
  thisCompletedQuantity: '',
  //本工序报废数
  thisWornQuantity: '',
  //班次
  classes: '',
  //责任工序
  responsibleProcess: '',
  order: {
    //客户编号
    customerId: '',
    //客户名称
    customerName: '',
    //项目名称
    project: '',
  },
  flowCard: {
    //可报工数量
    quantity: ''
  },
 
 
})
 
//定义接收加载表头下拉数据
const titleSelectJson = ref({
  deviceType: [],
  teamsType: [],
  processType: [],
  thisProcessType: [],
  mateProcessType: [],
})
 
//表尾求和
const sumNum = (list, field) => {
  let count = 0
  list.forEach(item => {
    count += Number(item[field])
  })
  return count.toFixed(2)
}
 
const form = reactive({
  processId: 'NG24022302A01/1'
})
 
const optionVal = ref('')
const options = [
  {
    value: '切割',
    label: '切割',
  },
  {
    value: '磨边',
    label: '磨边',
  },
  {
    value: '钢化',
    label: '钢化',
  },
]
 
//班次
const classesVal = ref('早班')
const classesOption = [
  {
    value: '早班',
    label: '早班',
  },
  {
    value: '晚班',
    label: '晚班',
  },
]
 
 
//子组件接收参数
const gridOptions = reactive({
  border: "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe: true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true, height: 30},//鼠标移动或选择高亮
  id: 'CustomerList',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY: {enabled: true},//开启虚拟滚动
  showOverflow: true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
                    // remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },//表头参数
  columns: [
    //  {type:'expand',fixed:"left",slots: { content:'content' },width: 50},
    {
      field: 'order_number',
      width: 90,
      title: '序号',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'glass_child',
      width: 120,
      title: '单片名称',
      showOverflow: "ellipsis",
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'technology_number',
      width: 90,
      title: '标记',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'glass_address',
      width: 100,
      title: '片标记',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'quantity_card',
      width: 110,
      title: '流程卡数量',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      showOverflow: "ellipsis",
      filterMethod: filterChanged
    },
    {
      field: 'child_width',
      width: 70,
      title: '宽',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'child_height',
      width: 70,
      title: '高',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      filterMethod: filterChanged
    },
    {
      field: 'shape',
      width: 70,
      title: '形状',
      filters: [{data: ''}],
      slots: {filter: 'num1_filter'},
      showOverflow: "ellipsis",
      filterMethod: filterChanged
    },
    {field: 'quantity', width: 120, title: '上工完工数量',},
    {
      field: 'completedQuantity', width: 100, title: '完工数量',
      editRender: {
        name: 'input',
        attrs: {placeholder: ''},
      },
 
    },
    {
      field: 'breakageNumber', width: 100, title: '次破数量',
      editRender: {
        name: 'input',
        attrs: {placeholder: ''}
      }
    },
    {field: 'available', width: 80, title: '可利用', editRender: {name: 'input', attrs: {placeholder: ''}}},
    {field: 'returnProcess', width: 100, title: '退回工序', editRender: {name: 'input', attrs: {placeholder: ''}}},
    {
      field: 'reasonType', width: 100, title: '次破类型',
      editRender: {name: 'input', attrs: {placeholder: '', type: 'selected'}}
    },
    {
      field: 'reasonDamage', width: 100, title: '次破原因',
      editRender: {name: 'input', attrs: {placeholder: ''}}
    },
    {
      field: 'responsibleProcess', width: 100, title: '责任工序',
      editRender: {},
      slots: {default: 'reportingWordSort_default', edit: 'reportingWordSort'}
      //editRender: {name: 'input', attrs: {placeholder: '',type: 'selected'}},
 
    },
    {
      field: 'responsibleEquipment',
      width: 100,
      title: '责任设备',
      editRender: {},
      slots: {default: 'reportingDeviceSort_default', edit: 'reportingDeviceSort'}
      // editRender: {name: 'input', attrs: {placeholder: ''}}
    },
 
    {
      field: 'responsibleTeam', width: 100, title: '责任班组',
      editRender: {name: 'input', attrs: {placeholder: ''}}
    },
    {
      field: 'responsibilityPersonnel',
      width: 100,
      title: '责任人员',
      editRender: {name: 'input', attrs: {placeholder: ''}}
 
    },
    {field: 'completed', width: 90, title: '已完工',},
    {field: 'onceBroken', width: 90, title: '已次破',},
 
  ],
//表单验证
  editRules: {},
  toolbarConfig: {//表头按钮
    buttons: [
      // {code: 'empty', name: '清空报工数量'},
      // {code: 'sameCompletion', name: '完工相同'},
      // {code: 'sameDamage', name: '次破相同'},
      // {code: 'sameOneCompletion', name: '完工一列相同'},
      // {code: 'sameOneDamage', name: '次破一列相同'},
      {code: 'print_lck', name: '保存', status: 'primary', icon: 'vxe-icon-save'},
      {code: 'print_lck', name: '保存并审核', status: 'primary', icon: 'vxe-icon-save'},
    ],
    // import: false,
    // export: true,
    // print: true,
    zoom: true,
    custom: true
  },
  data: [],//table body实际数据
  //脚部求和
  footerMethod({columns, data}) {//页脚函数
    let footList = ['', '', '', '', '']
    return [
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return '合计:'
        }
        if (footList.includes(column.field)) {
          return sumNum(data, column.field)
        }
        return ''
      })
    ]
  }
 
})
 
//第一次加载数据
 
request.post(`/reportingWork/selectProcess`).then((res) => {
 
  if (res.code == 200) {
    titleSelectJson.value.processType = res.data.process;
    //console.log(titleSelectJson.value.processType)
  } else {
    ElMessage.warning(res.msg)
  }
})
 
//下拉款选择工序时查询
const getWork = () => {
 
  let processId = form.processId
  if (processId.indexOf("/") < 0) {
 
    ElMessage.success("请输入正确格式流程卡")
    return
  }
  let indexOfChar = processId.indexOf("/")
  let leftString = processId.slice(0, indexOfChar)
  if (leftString.length != 13) {
    ElMessage.success("请输入正确位数的流程卡")
    return
  }
//工序
  let process = titleUploadData.value.thisProcess
  if (process == "" || process == null) {
 
    ElMessage.success("请选择工序")
    return
  }
 
  if (titleSelectJson.value.thisProcessType.indexOf(process) == -1 && process != "切割" && titleSelectJson.value.thisProcessType != "") {
    ElMessage.success("此工序不属于该流程卡")
    return
  }
  //流程卡号
  let processIdStr = processId.substring(0, 13);
  //层号
  let technologyStr = processId.substring(14);
 
  request.post(`/reportingWork/addSelectLastWork/${processIdStr}/${technologyStr}/${process}`).then((res) => {
    if (res.code == 200) {
      //表头赋值
      titleUploadData.value = res.data.data
      //设备下拉框
      titleSelectJson.value.deviceType = res.data.device
      //班组下拉框
      titleSelectJson.value.teamsType = res.data.teams
      //当前流程卡工序
      titleSelectJson.value.thisProcessType = res.data.thisProcess
      //报工时间默认当天
      const today = new Date
      today.setTime(today.getTime())
      titleUploadData.value.reportingWorkDate = today.getFullYear() +
          '-' + ("0" + (today.getMonth() + 1)).slice(-2)
          + '-' + ("0" + today.getDate()).slice(-2)
      //绑定下方表格
      xGrid.value.reloadData(res.data.Detail)
    } else {
      ElMessage.warning(res.msg)
    }
  })
}
 
//判断完工次破数量是否满足条件
const verifyNum = () => {
  const $grid = xGrid.value
  const table = $grid.getTableData().fullData
  //console.log(table)
  let sum = 0;
  let sumBreak = 0;
  table.forEach((item) => {
    if (item.completedQuantity == null || item.completedQuantity == "") {
      item.completedQuantity = 0;
    }
    if (item.breakageNumber == null || item.breakageNumber == "") {
      item.breakageNumber = 0;
    }
 
    if (item.quantity < item.completedQuantity) {
      ElMessage.success("序号" + item.order_number + "的数量不能大于上工序数量")
 
 
    } else if (item.breakageNumber * 1 + item.completedQuantity * 1 > item.quantity * 1) {
      ElMessage.success("请输入序号" + item.order_number + "正确的完工或次破数量")
    }
 
    sum = item.completedQuantity * 1 + sum * 1
 
    sumBreak = item.breakageNumber * 1 + sumBreak * 1
 
  })
  titleUploadData.value.thisCompletedQuantity = sum
  titleUploadData.value.thisWornQuantity = sumBreak
}
 
 
const ptypeChangeEvent = (row) => {
  // for (let i = 0; i < row.length; i++){
  //
  //  let process=row[i].responsibleProcess
  // }
}
</script>
 
<template>
  <div style="height: 100%;width: 100%">
    <div id="head" style="height: 5%;width: 100%;margin-bottom: 5px">
      <el-input v-model="form.processId" placeholder="流程卡号" style="width: 200px" @keyup.enter.native="getWork"/>
      &nbsp;
      <el-select v-model="titleUploadData.thisProcess" clearable placeholder="请选择工序" style="width: 120px"
                 @change="getWork">
        <el-option
            v-for="item in titleSelectJson['processType']"
            :key="item.id"
            :label="item.basic_name"
            :value="item.basic_name"
        />
      </el-select>
      &nbsp;
      <el-button type="primary">审核通过</el-button>
      <el-button type="primary">审核不通过</el-button>
      &nbsp;
      <label>流程卡面积:xxx平方米</label>
    </div>
    <div style="background-color: white;margin-bottom: 5px;height: 17%;width: 100%">
      <el-row>
        <el-col :span="2">
          <el-text>销售单号:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text>{{ titleUploadData.orderId }}</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>生产订单号:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text>{{ titleUploadData.productionId }}</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>客户编码:</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>{{ titleUploadData.order.customerId }}</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>客户名称:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text class="customClass">{{ titleUploadData.order.customerName }}</el-text>
 
        </el-col>
        <el-col :span="2">
          <el-text>项目名称:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text wrap-text="false">{{ titleUploadData.order.project }}</el-text>
        </el-col>
 
      </el-row>
      <el-row>
        <el-col :span="2">
          <el-text>报工设备:</el-text>
        </el-col>
        <el-col :span="3">
          <el-select v-model="titleUploadData.deviceType" clearable placeholder="请选择设备">
            <el-option
                v-for="item in titleSelectJson['deviceType']"
                :key="item.id"
                :label="item.basicName"
                :value="item.basicName"
            />
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-text>上工序:</el-text>
        </el-col>
        <el-col :span="3">
 
          <el-text>{{ titleUploadData.previousProcess }}</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>可报工数量:</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>{{ titleUploadData.flowCard.quantity }}</el-text>
 
        </el-col>
        <el-col :span="2">
          <el-text>本工序完工:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text>{{ titleUploadData.thisCompletedQuantity }}</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>本工序次破:</el-text>
        </el-col>
        <el-col :span="3">
          <el-text>{{ titleUploadData.thisWornQuantity }}</el-text>
        </el-col>
 
      </el-row>
      <el-row>
        <el-col :span="2">
          <el-text>报工班组:</el-text>
        </el-col>
        <el-col :span="3">
          <el-select v-model="titleUploadData.teamsType" clearable placeholder="请选择班组">
            <el-option
                v-for="item in titleSelectJson['teamsType']"
                :key="item.id"
                :label="item.basicName"
                :value="item.basicName"
            />
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-text>班次:</el-text>
        </el-col>
        <el-col :span="3">
          <el-select v-model="classesVal" class="processesSt" placeholder="">
            <el-option
                v-for="item in classesOption"
                :key="item.value"
                :label="item.label"
                :value="item.value"
            />
          </el-select>
        </el-col>
        <el-col :span="2">
          <el-text>下工序:</el-text>
        </el-col>
        <el-col :span="2">
          <el-text>{{ titleUploadData.nextProcess }}</el-text>
 
        </el-col>
        <el-col :span="2">
          <el-text>报工日期:</el-text>
        </el-col>
        <el-col :span="3">
          <el-date-picker
              v-model="titleUploadData.reportingWorkDate"
              placeholder=""
              style="width: 100%"
              type="date"
          />
        </el-col>
        <el-col :span="2">
          <el-text>备注:</el-text>
        </el-col>
        <el-col :span="3">
 
        </el-col>
 
      </el-row>
    </div>
    <div class="main-div-customer" style="width: 100%;height: 70%">
      <vxe-grid
          ref="xGrid"
          class="mytable-scrollbar"
          max-height="100%"
          size="small"
          v-bind="gridOptions"
          @filter-change="filterChanged"
          @edit-closed="verifyNum"
 
      >
        <!--        责任工序-->
        <template #reportingWordSort="{ row }">
          <vxe-select v-model="row.responsibleProcess" transfer @change="ptypeChangeEvent(row)">
            <vxe-option v-for="item in titleSelectJson.thisProcessType" :key="item" :label="item" :value="item"/>
          </vxe-select>
        </template>
        <template #reportingWordSort_default="{ row }">
          <span>{{ row.responsibleProcess }}</span>
        </template>
        <!--     责任设备    -->
        <template #reportingDeviceSort="{ row }">
          <vxe-select v-model="row.responsibleEquipment" transfer>
            <vxe-option v-for="item in titleSelectJson.mateProcessType" :key="item" :label="item" :value="item"/>
          </vxe-select>
        </template>
        <template #reportingDeviceSort_default="{ row }">
          <span>{{ row.responsibleEquipment }}</span>
        </template>
 
        <template #num1_filter="{ column, $panel }">
          <div>
            <div v-for="(option, index) in column.filters" :key="index">
              <input v-model="option.data" type="type" @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </template>
 
 
      </vxe-grid>
    </div>
  </div>
</template>
 
<style scoped>
 
 
.processCard {
  width: 140px;
}
 
.processesSt {
  height: 33px;
  width: 120px;
  background-color: #409eff;
  color: white;
  border: none;
  border-radius: 5px;
}
 
#titleTable tr, #titleTable td {
  border: 1px solid #000;
}
 
#titleTable {
  border-collapse: collapse;
  text-align: center;
  width: 100%;
  height: 100%;
}
 
#titleTable td {
  width: 100px;
  height: 30px;
}
 
#titleTable td:nth-child(1) {
  width: 100px;
  height: 30px;
}
 
#titleTable td:nth-child(2) {
  width: 100px;
}
 
.chaxun {
  background-color: #D5EAFF;
  border: none;
}
 
.customClass {
  white-space: nowrap; /* 不换行 */
}
 
.el-text {
 
}
 
.el-col .el-select {
  width: 100%;
  height: 100%;
}
 
.el-col {
  text-align: center;
  border: #181818 1px solid;
}
 
</style>