Переглянути джерело

feat(系统工具): 添加序列号工具类

shizhongming 2 роки тому
батько
коміт
c36e5202fb

+ 46 - 0
src/modules/system/views/serial/SmartSerialNoListView.api.ts

@@ -0,0 +1,46 @@
+import { ApiServiceEnum, defHttp } from '@/utils/http/axios';
+
+enum Api {
+  list = '/smart/tool/serial/list',
+  getById = '/smart/tool/serial/getById',
+  batchSaveUpdate = '/smart/tool/serial/saveUpdateBatch',
+  delete = '/smart/tool/serial/batchDeleteById',
+}
+
+export const listApi = (params) => {
+  const parameter = {
+    ...params,
+  };
+  if (!parameter.sortName) {
+    parameter.sortName = 'seq';
+  }
+  return defHttp.post({
+    service: ApiServiceEnum.SMART_SYSTEM,
+    url: Api.list,
+    data: parameter,
+  });
+};
+
+export const batchSaveUpdateApi = (modelList: any[]) => {
+  return defHttp.post({
+    service: ApiServiceEnum.SMART_SYSTEM,
+    url: Api.batchSaveUpdate,
+    data: modelList,
+  });
+};
+
+export const deleteApi = (removeRecords: Recordable[]) => {
+  return defHttp.post({
+    service: ApiServiceEnum.SMART_SYSTEM,
+    url: Api.delete,
+    data: removeRecords.map((item) => item.id),
+  });
+};
+
+export const getByIdApi = (id: number) => {
+  return defHttp.post({
+    service: ApiServiceEnum.SMART_SYSTEM,
+    url: Api.getById,
+    data: id,
+  });
+};

+ 261 - 0
src/modules/system/views/serial/SmartSerialNoListView.config.ts

@@ -0,0 +1,261 @@
+import type { SmartColumn, SmartSearchFormSchema } from '@/components/SmartTable';
+import type { FormSchema } from '@/components/Form';
+import { tableUseYnClass } from '@/components/SmartTable';
+
+/**
+ * 表格列表
+ */
+export const getTableColumns = (): SmartColumn[] => {
+  return [
+    {
+      type: 'checkbox',
+      width: 60,
+      align: 'center',
+      fixed: 'left',
+    },
+    {
+      field: 'seq',
+      title: '{common.table.seq}',
+      fixed: 'left',
+      width: 120,
+      sortable: true,
+    },
+    {
+      field: 'code',
+      title: '{smart.tools.serial.title.code}',
+      fixed: 'left',
+      width: 120,
+    },
+    {
+      field: 'name',
+      fixed: 'left',
+      title: '{smart.tools.serial.title.name}',
+      width: 120,
+    },
+    {
+      field: 'remark',
+      title: '{common.table.remark}',
+      width: 120,
+    },
+    {
+      field: 'serialFormat',
+      title: '{smart.tools.serial.title.serialFormat}',
+      width: 180,
+    },
+    {
+      field: 'prefix',
+      title: '{smart.tools.serial.title.prefix}',
+      width: 120,
+    },
+    {
+      field: 'dateFormat',
+      title: '{smart.tools.serial.title.dateFormat}',
+      width: 200,
+    },
+    {
+      field: 'serialLength',
+      title: '{smart.tools.serial.title.serialLength}',
+      width: 120,
+    },
+    {
+      field: 'minValue',
+      title: '{smart.tools.serial.title.minValue}',
+      width: 120,
+    },
+    {
+      field: 'maxValue',
+      title: '{smart.tools.serial.title.maxValue}',
+      width: 120,
+    },
+    {
+      field: 'stepValue',
+      title: '{smart.tools.serial.title.stepValue}',
+      width: 120,
+    },
+    {
+      field: 'currentDate',
+      title: '{smart.tools.serial.title.currentDate}',
+      width: 120,
+    },
+    {
+      field: 'currentValue',
+      title: '{smart.tools.serial.title.currentValue}',
+      width: 120,
+    },
+    {
+      field: 'createTime',
+      title: '{common.table.createTime}',
+      width: 160,
+      sortable: true,
+    },
+    {
+      field: 'createBy',
+      title: '{common.table.createUser}',
+      width: 120,
+    },
+    {
+      field: 'updateTime',
+      title: '{common.table.updateTime}',
+      width: 160,
+      sortable: true,
+    },
+    {
+      field: 'updateBy',
+      title: '{common.table.updateUser}',
+      width: 120,
+    },
+    {
+      ...tableUseYnClass(),
+    },
+    {
+      title: '{common.table.operation}',
+      field: 'operation',
+      width: 120,
+      fixed: 'right',
+      slots: {
+        default: 'table-operation',
+      },
+    },
+  ];
+};
+
+/**
+ * 添加修改表单
+ */
+export const getFormSchemas = (t: Function): FormSchema[] => {
+  return [
+    {
+      field: 'id',
+      label: '',
+      component: 'Input',
+      show: false,
+      componentProps: {},
+    },
+    {
+      field: 'code',
+      label: t('smart.tools.serial.title.code'),
+      component: 'Input',
+      required: true,
+      componentProps: {},
+    },
+    {
+      field: 'name',
+      label: t('smart.tools.serial.title.name'),
+      component: 'Input',
+      required: true,
+      componentProps: {},
+    },
+    {
+      field: 'remark',
+      label: t('common.table.remark'),
+      component: 'Input',
+      componentProps: {},
+    },
+    {
+      field: 'seq',
+      label: t('common.table.seq'),
+      component: 'InputNumber',
+      required: true,
+      defaultValue: 1,
+      componentProps: {},
+    },
+    {
+      field: 'serialFormat',
+      label: t('smart.tools.serial.title.serialFormat'),
+      component: 'Input',
+      required: true,
+      defaultValue: '{PREFIX}{DATE}{NUMBER}',
+      componentProps: {},
+    },
+    {
+      field: 'prefix',
+      label: t('smart.tools.serial.title.prefix'),
+      component: 'Input',
+      required: true,
+      componentProps: {},
+    },
+    {
+      field: 'dateFormat',
+      label: t('smart.tools.serial.title.dateFormat'),
+      component: 'Input',
+      required: true,
+      componentProps: {},
+    },
+    {
+      field: 'serialLength',
+      label: t('smart.tools.serial.title.serialLength'),
+      component: 'Input',
+      required: true,
+      componentProps: {},
+    },
+    {
+      field: 'minValue',
+      label: t('smart.tools.serial.title.minValue'),
+      component: 'InputNumber',
+      required: true,
+      defaultValue: 1,
+      componentProps: {},
+    },
+    {
+      field: 'maxValue',
+      label: t('smart.tools.serial.title.maxValue'),
+      component: 'InputNumber',
+      required: true,
+      defaultValue: -1,
+      componentProps: {},
+    },
+    {
+      field: 'stepValue',
+      label: t('smart.tools.serial.title.stepValue'),
+      component: 'InputNumber',
+      required: true,
+      defaultValue: 1,
+      componentProps: {},
+    },
+    {
+      field: 'currentDate',
+      label: t('smart.tools.serial.title.currentDate'),
+      component: 'DatePicker',
+      defaultValue: new Date(),
+      componentProps: {
+        disabled: true,
+        style: {
+          width: '100%',
+        },
+      },
+    },
+    {
+      field: 'currentValue',
+      label: t('smart.tools.serial.title.currentValue'),
+      component: 'Input',
+      componentProps: {
+        disabled: true,
+      },
+    },
+    {
+      field: 'useYn',
+      label: t('common.table.useYn'),
+      component: 'Switch',
+      required: true,
+      defaultValue: true,
+      componentProps: {},
+    },
+  ];
+};
+
+export const getSearchFormSchemas = (t: Function): SmartSearchFormSchema[] => {
+  return [
+    {
+      field: 'code',
+      label: t('smart.tools.serial.title.code'),
+      component: 'Input',
+      searchSymbol: '=',
+    },
+    {
+      field: 'name',
+      label: t('smart.tools.serial.title.name'),
+      component: 'Input',
+      searchSymbol: '=',
+    },
+  ];
+};

+ 94 - 0
src/modules/system/views/serial/SmartSerialNoListView.vue

@@ -0,0 +1,94 @@
+<template>
+  <div class="full-height page-container">
+    <SmartTable @register="registerTable" :size="getTableSize">
+      <template #table-operation="{ row }">
+        <SmartVxeTableAction :actions="getActions(row)" />
+      </template>
+    </SmartTable>
+  </div>
+</template>
+
+<script lang="ts" setup>
+  import { useI18n } from '@/hooks/web/useI18n';
+  import { useSizeSetting } from '@/hooks/setting/UseSizeSetting';
+
+  import {
+    ActionItem,
+    SmartTable,
+    SmartVxeTableAction,
+    useSmartTable,
+  } from '@/components/SmartTable';
+
+  import {
+    getTableColumns,
+    getFormSchemas,
+    getSearchFormSchemas,
+  } from './SmartSerialNoListView.config';
+  import { listApi, deleteApi, getByIdApi, batchSaveUpdateApi } from './SmartSerialNoListView.api';
+
+  const { t } = useI18n();
+  const { getTableSize } = useSizeSetting();
+
+  const getActions = (row: Recordable): ActionItem[] => {
+    return [
+      {
+        label: t('common.button.edit'),
+        onClick: () => editByRowModal(row),
+      },
+    ];
+  };
+
+  const [registerTable, { editByRowModal }] = useSmartTable({
+    id: 'smart-system-tool-serial',
+    customConfig: { storage: true },
+    columns: getTableColumns(),
+    height: 'auto',
+    border: true,
+    sortConfig: {
+      remote: true,
+    },
+    pagerConfig: true,
+    useSearchForm: true,
+    searchFormConfig: {
+      schemas: getSearchFormSchemas(t),
+      searchWithSymbol: true,
+      colon: true,
+      layout: 'inline',
+      compact: true,
+      actionColOptions: {
+        span: undefined,
+      },
+    },
+    addEditConfig: {
+      formConfig: {
+        schemas: getFormSchemas(t),
+        colon: true,
+        baseColProps: { span: 24 },
+        labelCol: { span: 6 },
+        wrapperCol: { span: 17 },
+      },
+    },
+    proxyConfig: {
+      ajax: {
+        query: (params) => listApi(params.ajaxParameter),
+        save: ({ body: { insertRecords, updateRecords } }) =>
+          batchSaveUpdateApi([...insertRecords, ...updateRecords]),
+        delete: ({ body: { removeRecords } }) => deleteApi(removeRecords),
+        getById: (params) => getByIdApi(params.id),
+      },
+    },
+    toolbarConfig: {
+      zoom: true,
+      refresh: true,
+      column: { columnOrder: true },
+      buttons: [
+        {
+          code: 'ModalAdd',
+        },
+        {
+          code: 'delete',
+        },
+      ],
+    },
+  });
+</script>

+ 37 - 0
src/modules/system/views/serial/lang/en_US.ts

@@ -0,0 +1,37 @@
+/**
+ * 业务编码表 国际化信息
+ */
+export default {
+  trans: true,
+  key: 'smart.tools.serial',
+  data: {
+    title: {
+      code: 'Code',
+      name: 'Name',
+      prefix: 'Prefix',
+      dateFormat: 'Date format',
+      serialLength: 'Length',
+      minValue: 'Min',
+      maxValue: 'Mx',
+      stepValue: 'Step',
+      currentValue: 'Current value',
+      currentDate: 'Curretn date',
+      serialFormat: 'Format',
+    },
+    validate: {
+      code: 'Please enter code',
+      name: 'Please enter name',
+      prefix: 'Please enter prefix',
+      dateFormat: 'Please enter date format',
+      serialLength: 'Please enter length',
+      minValue: 'Please enter min value',
+      maxValue: 'Please enter max value',
+      stepValue: 'Please enter step',
+    },
+    rules: {},
+    search: {
+      code: 'Please enter code',
+      name: 'Please enter name',
+    },
+  },
+};

+ 38 - 0
src/modules/system/views/serial/lang/zh_CN.ts

@@ -0,0 +1,38 @@
+/**
+ * 业务编码表 国际化信息
+ */
+export default {
+  trans: true,
+  key: 'smart.tools.serial',
+  data: {
+    title: {
+      code: '编号',
+      name: '名称',
+      prefix: '编码前缀',
+      dateFormat: '日期格式',
+      serialLength: '流水长度',
+      minValue: '最小值',
+      maxValue: '最大值',
+      stepValue: '步长',
+      currentValue: '当前值',
+      currentDate: '当前日期',
+      serialFormat: '格式化',
+    },
+    validate: {
+      code: '请输入编号',
+      name: '请输入名称',
+      prefix: '请输入编码前缀',
+      dateFormat: '请输入日期格式',
+      serialLength: '请输入流水长度',
+      minValue: '请输入最小值',
+      maxValue: '请输入最大值,-1不限制',
+      stepValue: '请输入步长',
+      currentValue: '请输入当前值',
+    },
+    rules: {},
+    search: {
+      code: '请输入编号',
+      name: '请输入名称',
+    },
+  },
+};