广丰卷烟厂数采质量分析系统
baoshiwei
5 小时以前 e97b55310155a2dd691bd698a10295a4d867f60c
ruoyi-plus-soybean/src/views/qm/batch/index.vue
old mode 100644 new mode 100755
@@ -1,12 +1,14 @@
<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 {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';
import BatchOperateDrawer from './modules/batch-operate-drawer.vue';
import BatchSearch from './modules/batch-search.vue';
@@ -16,18 +18,145 @@
});
const appStore = useAppStore();
const { download } = useDownload();
const { hasAuth } = useAuth();
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': '辅材' };
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,
  isflag: '1',
  typ: null,
  eqpCode: null,
  matCode: null,
@@ -35,13 +164,17 @@
  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 } =
const {columns, columnChecks, data, getData, getDataByPage, loading, mobilePagination, scrollX} =
  useNaivePaginatedTable({
    api: () => fetchGetBatchList(searchParams.value),
    transform: response => defaultTransform(response),
@@ -63,45 +196,20 @@
        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
      },
@@ -115,13 +223,15 @@
        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',
@@ -200,7 +310,8 @@
        key: 'deleted',
        title: '删除标志',
        align: 'center',
        minWidth: 120
        minWidth: 120,
        render: row => (row.deleted == 1 ? '是' : '否')
      },
      {
        key: 'batchDes',
@@ -350,6 +461,7 @@
      {
        key: 'operate',
        title: $t('common.operate'),
        fixed: 'right',
        align: 'center',
        width: 130,
        render: row => {
@@ -357,7 +469,7 @@
            if (!hasAuth('qm:batch:edit') || !hasAuth('qm:batch:remove')) {
              return null;
            }
            return <NDivider vertical />;
            return <NDivider vertical/>;
          };
          const editBtn = () => {
@@ -403,19 +515,19 @@
    ]
  });
const { drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted } =
const {drawerVisible, operateType, editingData, handleAdd, handleEdit, checkedRowKeys, onBatchDeleted, onDeleted} =
  useTableOperate(data, 'id', getData);
async function handleBatchDelete() {
  // request
  const { error } = await fetchBatchDeleteBatch(checkedRowKeys.value);
  const {error} = await fetchBatchDeleteBatch(checkedRowKeys.value);
  if (error) return;
  onBatchDeleted();
}
async function handleDelete(id: CommonType.IdType) {
  // request
  const { error } = await fetchBatchDeleteBatch([id]);
  const {error} = await fetchBatchDeleteBatch([id]);
  if (error) return;
  onDeleted();
}
@@ -431,7 +543,7 @@
<template>
  <div class="min-h-500px flex-col-stretch gap-16px overflow-hidden lt-sm:overflow-auto">
    <BatchSearch v-model:model="searchParams" @search="getDataByPage" />
    <BatchSearch v-model:model="searchParams" @search="getDataByPage"/>
    <NCard title="检验批次列表" :bordered="false" size="small" class="card-wrapper sm:flex-1-hidden">
      <template #header-extra>
        <TableHeaderOperation
@@ -458,8 +570,19 @@
        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"