广丰卷烟厂数采质量分析系统
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
<script setup lang="tsx">
import { ref } from 'vue';
import { NDivider } from 'naive-ui';
import { fetchBatchDeleteBatch, fetchGetBatchList } from '@/service/api/qm/batch';
import { useAppStore } from '@/store/modules/app';
import { useAuth } from '@/hooks/business/auth';
import { useDownload } from '@/hooks/business/download';
import { defaultTransform, useNaivePaginatedTable, useTableOperate } from '@/hooks/common/table';
import { $t } from '@/locales';
import ButtonIcon from '@/components/custom/button-icon.vue';
import BatchOperateDrawer from './modules/batch-operate-drawer.vue';
import BatchSearch from './modules/batch-search.vue';
 
defineOptions({
  name: 'BatchList'
});
 
const appStore = useAppStore();
const { download } = useDownload();
const { hasAuth } = useAuth();
 
// 类型/反馈MES/类别的 value->label 映射(用于表格显示)
const TYP_MAP: Record<string, string> = { A: '制丝', B: '成型', C: '卷包', D: '封箱', E: '糖香料' };
const FLAG_MAP: Record<string, string> = { '0': '未上传mes', '1': '已上传', '3': '从MES下载' };
const CATEGORY_MAP: Record<string, string> = { '0': '成品', '1': '辅材' };
 
const searchParams = ref<Api.Qm.BatchSearchParams>({
  pageNum: 1,
  pageSize: 10,
  batchCode: null,
  typ: null,
  eqpCode: null,
  matCode: null,
  batchDate: null,
  flag: null,
  toMesDate: null,
  fromMesDate: null,
  deleted: null,
  category: null,
  state: null,
  params: {}
});
 
const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination, scrollX } =
  useNaivePaginatedTable({
    api: () => fetchGetBatchList(searchParams.value),
    transform: response => defaultTransform(response),
    onPaginationParamsChange: params => {
      searchParams.value.pageNum = params.page;
      searchParams.value.pageSize = params.pageSize;
    },
    columns: () => [
      {
        type: 'selection',
        align: 'center',
        width: 48
      },
      {
        key: 'index',
        title: $t('common.index'),
        align: 'center',
        width: 64,
        render: (_, index) => index + 1
      },
      {
        key: 'id',
        title: '编码',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'batchCode',
        title: '批次代码',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'batchName',
        title: '批次名称',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'typ',
        title: '类型',
        align: 'center',
        minWidth: 120,
        render: row => TYP_MAP[row.typ] ?? row.typ
      },
      {
        key: 'eqpCode',
        title: '机台代码',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'matCode',
        title: '牌号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'judgeCode',
        title: '判定依据代码',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'batchDate',
        title: '批次生成日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'isflag',
        title: '使用标志',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'enabled',
        title: '启用标志',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'totalNum',
        title: '到货总量',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'results',
        title: '综合判定',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'approver',
        title: '批准人',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'auditor',
        title: '审核人',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'creater',
        title: '创建人',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'tabDate',
        title: '制表日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'verName',
        title: '版本名称',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'verCode',
        title: '版本编号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'archDate',
        title: '保存期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'flag',
        title: '反馈MES',
        align: 'center',
        minWidth: 120,
        render: row => FLAG_MAP[String(row.flag)] ?? row.flag
      },
      {
        key: 'toMesDate',
        title: '上传MES时间',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'fromMesDate',
        title: '从MES时间下载',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'deleted',
        title: '删除标志',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'batchDes',
        title: '批次描述',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'category',
        title: '类别',
        align: 'center',
        minWidth: 120,
        render: row => CATEGORY_MAP[String(row.category)] ?? row.category
      },
      {
        key: 'makeno',
        title: '卷制工号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'shifteqpno',
        title: '班次机号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'boxno',
        title: '装箱号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'pid',
        title: '父批次号',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'reviewer',
        title: '复核人',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'rvcount',
        title: '复检次数',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'state',
        title: '批次状态',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'reviewTime',
        title: '复核日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'auditTime',
        title: '审核日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'spec',
        title: '规格',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'approveTime',
        title: '批准时间',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'unit',
        title: '到货单位',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'arrivalTime',
        title: '到货日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'storagePlace',
        title: '存放地点',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'checker',
        title: '检验员',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'receiveTime',
        title: '接单日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'inspTime',
        title: '报检日期',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'storer',
        title: '仓库保管员',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'isverify',
        title: '是否验证',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'ischk',
        title: '是否检验',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'bak1',
        title: '备用1',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'bak2',
        title: '备用2',
        align: 'center',
        minWidth: 120
      },
      {
        key: 'operate',
        title: $t('common.operate'),
        align: 'center',
        width: 130,
        render: row => {
          const divider = () => {
            if (!hasAuth('qm:batch:edit') || !hasAuth('qm:batch:remove')) {
              return null;
            }
            return <NDivider vertical />;
          };
 
          const editBtn = () => {
            if (!hasAuth('qm:batch:edit')) {
              return null;
            }
            return (
              <ButtonIcon
                text
                type="primary"
                icon="material-symbols:drive-file-rename-outline-outline"
                tooltipContent={$t('common.edit')}
                onClick={() => edit(row.id)}
              />
            );
          };
 
          const deleteBtn = () => {
            if (!hasAuth('qm:batch:remove')) {
              return null;
            }
            return (
              <ButtonIcon
                text
                type="error"
                icon="material-symbols:delete-outline"
                tooltipContent={$t('common.delete')}
                popconfirmContent={$t('common.confirmDelete')}
                onPositiveClick={() => handleDelete(row.id)}
              />
            );
          };
 
          return (
            <div class="flex-center gap-8px">
              {editBtn()}
              {divider()}
              {deleteBtn()}
            </div>
          );
        }
      }
    ]
  });
 
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
  useTableOperate(data, 'id', getData);
 
async function handleBatchDelete() {
  // request
  const { error } = await fetchBatchDeleteBatch(checkedRowKeys.value);
  if (error) return;
  onBatchDeleted();
}
 
async function handleDelete(id: CommonType.IdType) {
  // request
  const { error } = await fetchBatchDeleteBatch([id]);
  if (error) return;
  onDeleted();
}
 
function edit(id: CommonType.IdType) {
  handleEdit(id);
}
 
function handleExport() {
  download('/qm/batch/export', searchParams.value, `检验批次_${new Date().getTime()}.xlsx`);
}
</script>
 
<template>
  <div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
    <BatchSearch v-model:model="searchParams" @search="getDataByPage" />
    <NCard title="检验批次列表" :bordered="false" size="small" class="card-wrapper sm:flex-1-hidden">
      <template #header-extra>
        <TableHeaderOperation
          v-model:columns="columnChecks"
          :disabled-delete="checkedRowKeys.length === 0"
          :loading="loading"
          :show-add="hasAuth('qm:batch:add')"
          :show-delete="hasAuth('qm:batch:remove')"
          :show-export="hasAuth('qm:batch:export')"
          @add="handleAdd"
          @delete="handleBatchDelete"
          @export="handleExport"
          @refresh="getData"
        />
      </template>
      <NDataTable
        v-model:checked-row-keys="checkedRowKeys"
        :columns="columns"
        :data="data"
        size="small"
        :flex-height="!appStore.isMobile"
        :scroll-x="scrollX"
        :loading="loading"
        remote
        :row-key="row => row.id"
        :pagination="mobilePagination"
        class="sm:h-full"
      />
      <BatchOperateDrawer
        v-model:visible="drawerVisible"
        :operate-type="operateType"
        :row-data="editingData"
        @submitted="getDataByPage"
      />
    </NCard>
  </div>
</template>
 
<style scoped></style>