| | |
| | | <script setup lang="tsx"> |
| | | import { ref } from 'vue'; |
| | | import { NDivider } from 'naive-ui'; |
| | | import {nextTick, ref} from 'vue'; |
| | | import {useRouter} from 'vue-router'; |
| | | import {NDivider, NDropdown} 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 {useSvgIcon} from '@/hooks/common/icon'; |
| | | import { defaultTransform, useNaivePaginatedTable, useTableOperate } from '@/hooks/common/table'; |
| | | import { $t } from '@/locales'; |
| | | import ButtonIcon from '@/components/custom/button-icon.vue'; |
| | |
| | | }); |
| | | |
| | | const appStore = useAppStore(); |
| | | const router = useRouter(); |
| | | const { download } = useDownload(); |
| | | const { hasAuth } = useAuth(); |
| | | const {SvgIconVNode} = useSvgIcon(); |
| | | |
| | | // 右键菜单相关 |
| | | const showDropdown = ref(false); |
| | | const x = ref(0); |
| | | const y = ref(0); |
| | | const currentRow = ref<Api.Qm.Batch | null>(null); |
| | | |
| | | const dropdownOptions = [ |
| | | { |
| | | label: '原始数据维护', |
| | | key: 'raw-data-maintenance', |
| | | icon: SvgIconVNode({icon: 'mdi:database-edit-outline', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '综合测试台数据维护', |
| | | key: 'test-bench-maintenance', |
| | | icon: SvgIconVNode({icon: 'mdi:monitor-dashboard', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '新建复检批次', |
| | | key: 'new-recheck-batch', |
| | | icon: SvgIconVNode({icon: 'mdi:plus-circle-outline', fontSize: 18}) |
| | | }, |
| | | { |
| | | type: 'divider', |
| | | key: 'd1' |
| | | }, |
| | | { |
| | | label: '卷包卷制检验结果报告', |
| | | key: 'report-rolling', |
| | | icon: SvgIconVNode({icon: 'mdi:file-document-outline', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '包装标识检验原始记录', |
| | | key: 'record-packaging', |
| | | icon: SvgIconVNode({icon: 'mdi:barcode-scan', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '熄火、含水率、含末率原始记录', |
| | | key: 'record-quality', |
| | | icon: SvgIconVNode({icon: 'mdi:water-percent', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '端部落丝原始记录', |
| | | key: 'record-silk', |
| | | icon: SvgIconVNode({icon: 'mdi:format-list-bulleted-type', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '综合测试台原始记录', |
| | | key: 'record-bench', |
| | | icon: SvgIconVNode({icon: 'mdi:chart-line', fontSize: 18}) |
| | | }, |
| | | { |
| | | label: '外观检验原始记录', |
| | | key: 'record-appearance', |
| | | icon: SvgIconVNode({icon: 'mdi:eye-outline', fontSize: 18}) |
| | | }, |
| | | { |
| | | type: 'divider', |
| | | key: 'd2' |
| | | }, |
| | | { |
| | | label: $t('common.edit'), |
| | | key: 'edit', |
| | | icon: SvgIconVNode({icon: 'material-symbols:drive-file-rename-outline-outline', fontSize: 18}), |
| | | show: hasAuth('qm:batch:edit') |
| | | }, |
| | | { |
| | | label: $t('common.delete'), |
| | | key: 'delete', |
| | | icon: SvgIconVNode({icon: 'material-symbols:delete-outline', fontSize: 18}), |
| | | show: hasAuth('qm:batch:remove') |
| | | } |
| | | ]; |
| | | |
| | | function handleSelect(key: string) { |
| | | showDropdown.value = false; |
| | | if (!currentRow.value) return; |
| | | |
| | | if (key === 'edit') { |
| | | edit(currentRow.value.id); |
| | | } else if (key === 'delete') { |
| | | window.$dialog?.error({ |
| | | title: $t('common.confirmDelete'), |
| | | content: $t('common.confirmDelete'), |
| | | positiveText: $t('common.confirm'), |
| | | negativeText: $t('common.cancel'), |
| | | onPositiveClick: () => { |
| | | handleDelete(currentRow.value!.id); |
| | | } |
| | | }); |
| | | } else if (key === 'raw-data-maintenance') { |
| | | // 跳转到 matcheck 页面 |
| | | if (!currentRow.value.judgeCode) { |
| | | window.$message?.warning('该批次没有判定依据'); |
| | | return; |
| | | } |
| | | router.push({ |
| | | path: '/qm/matcheck', |
| | | query: { |
| | | judgeCode: currentRow.value.judgeCode, |
| | | batchCode: currentRow.value.batchCode, |
| | | matCode: currentRow.value.matCode |
| | | } |
| | | }); |
| | | } else { |
| | | // 处理其他业务操作 |
| | | window.$message?.info(`点击了: ${key}`); |
| | | } |
| | | } |
| | | |
| | | function handleRowProps(row: Api.Qm.Batch) { |
| | | return { |
| | | onContextmenu: (e: MouseEvent) => { |
| | | e.preventDefault(); |
| | | showDropdown.value = false; |
| | | nextTick().then(() => { |
| | | currentRow.value = row; |
| | | x.value = e.clientX; |
| | | y.value = e.clientY; |
| | | showDropdown.value = true; |
| | | }); |
| | | } |
| | | }; |
| | | } |
| | | |
| | | // 类型/反馈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': '辅材' }; |
| | | |
| | |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | batchCode: null, |
| | | isflag: '1', |
| | | typ: null, |
| | | eqpCode: null, |
| | | matCode: null, |
| | |
| | | flag: null, |
| | | toMesDate: null, |
| | | fromMesDate: null, |
| | | deleted: null, |
| | | category: null, |
| | | enabled: '1', |
| | | deleted: 0, |
| | | category: '0', |
| | | state: null, |
| | | params: {} |
| | | params: { |
| | | beginBatchDate: `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, '0')}-${String(new Date().getDate()).padStart(2, '0')} 00:00:00`, |
| | | endBatchDate: `${new Date().getFullYear()}-${String(new Date().getMonth() + 1).padStart(2, '0')}-${String(new Date().getDate()).padStart(2, '0')} 23:59:59` |
| | | } |
| | | }); |
| | | |
| | | const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination, scrollX } = |
| | |
| | | render: (_, index) => index + 1 |
| | | }, |
| | | { |
| | | key: 'id', |
| | | title: '编码', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | }, |
| | | { |
| | | key: 'batchCode', |
| | | title: '批次代码', |
| | | 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', |
| | | key: 'matName', |
| | | title: '牌号', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | }, |
| | | { |
| | | key: 'judgeCode', |
| | | title: '判定依据代码', |
| | | key: 'judgeName', |
| | | title: '判定依据', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | }, |
| | |
| | | key: 'isflag', |
| | | title: '使用标志', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | minWidth: 120, |
| | | render: row => (row.isflag == '1' ? '是' : '否') |
| | | }, |
| | | { |
| | | key: 'enabled', |
| | | title: '启用标志', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | minWidth: 120, |
| | | render: row => (row.enabled == '1' ? '是' : '否') |
| | | }, |
| | | { |
| | | key: 'totalNum', |
| | |
| | | key: 'deleted', |
| | | title: '删除标志', |
| | | align: 'center', |
| | | minWidth: 120 |
| | | minWidth: 120, |
| | | render: row => (row.deleted == 1 ? '是' : '否') |
| | | }, |
| | | { |
| | | key: 'batchDes', |
| | |
| | | { |
| | | key: 'operate', |
| | | title: $t('common.operate'), |
| | | fixed: 'right', |
| | | align: 'center', |
| | | width: 130, |
| | | render: row => { |
| | |
| | | remote |
| | | :row-key="row => row.id" |
| | | :pagination="mobilePagination" |
| | | :row-props="handleRowProps" |
| | | class="sm:h-full" |
| | | /> |
| | | <NDropdown |
| | | placement="bottom-start" |
| | | trigger="manual" |
| | | :x="x" |
| | | :y="y" |
| | | :options="dropdownOptions" |
| | | :show="showDropdown" |
| | | :on-clickoutside="() => (showDropdown = false)" |
| | | @select="handleSelect" |
| | | /> |
| | | <BatchOperateDrawer |
| | | v-model:visible="drawerVisible" |
| | | :operate-type="operateType" |