Преглед на файлове

perf: 字典id改为string类型

曾坤森 преди 2 месеца
родител
ревизия
b6ee5a8088
променени са 5 файла, в които са добавени 17 реда и са изтрити 21 реда
  1. 5 5
      src/api/dict.ts
  2. 4 4
      src/views/system/dict-item/edit.vue
  3. 4 7
      src/views/system/dict-item/index.vue
  4. 4 1
      src/views/system/dict/edit.vue
  5. 0 4
      src/views/system/dict/index.vue

+ 5 - 5
src/api/dict.ts

@@ -3,7 +3,7 @@ import type { RouteRecordNormalized } from 'vue-router';
 import { UserState } from '@/store/modules/user/types';
 import instance from './interceptor';
 export interface DataList {
-  id?: number;
+  id?: string;
   name?: string;
   description?: string;
 }
@@ -21,15 +21,15 @@ export interface DictParams {
   pageSize: number;
 }
 export interface DictItemParams {
-  dictId: number;
+  dictId: string;
   name: string;
   dictCode: number;
   description: string;
 }
 export interface ItemDataList {
-  id?: number;
-  dictId?: number;
-  dictCode?: string | null;
+  id?: string;
+  dictId?: string;
+  dictCode?: number | null;
   number?: number | null;
   name: string;
   chsName?: string;

+ 4 - 4
src/views/system/dict-item/edit.vue

@@ -47,7 +47,7 @@
               :label="t('dict.form.dictCode')"
               :rules="getRules(t).required"
             >
-              <a-input v-model="form.dictCode" />
+              <a-input-number v-model="form.dictCode" />
             </a-form-item>
           </a-col>
         </a-row>
@@ -120,8 +120,8 @@ watch(
       props.listObj.dictCode?.toString();
       form.value = props.listObj;
       if (!props.listObj.id) {
-        form.value.id = 0;
-        form.value.dictId = Number(id);
+        form.value.id = '0';
+        form.value.dictId = id.toString();
         form.value.status = 1;
       }
     }
@@ -129,7 +129,7 @@ watch(
 );
 const formModel = () => {
   return {
-    id: 0,
+    id: '0',
     number: null,
     name: '',
     chsName: '',

+ 4 - 7
src/views/system/dict-item/index.vue

@@ -132,10 +132,9 @@ import {
   getCurrentInstance,
   computed,
 } from 'vue';
-import { getDictItemList, fetchDeleteDict } from '@/api/dict';
+import { getDictItemList, fetchDeleteDictItem } from '@/api/dict';
 import type { DictItemParams, DataList, ItemDataList } from '@/api/dict';
 import { SizeProps, Pagination } from '@/types/global';
-import BTag from '@/components/business/b-tag/index.vue';
 import { Modal } from '@arco-design/web-vue';
 import useLoading from '@/hooks/loading';
 import { useI18n } from 'vue-i18n';
@@ -217,7 +216,7 @@ const pagination = reactive({
 });
 const generateFormModel = () => {
   return {
-    dictId: 0,
+    dictId: '0',
   } as DictItemParams;
 };
 const renderData = ref<ItemDataList[]>([] as ItemDataList[]);
@@ -229,7 +228,7 @@ const listObj = ref<ItemDataList>({} as ItemDataList);
 const this_ = getCurrentInstance()?.appContext.config.globalProperties;
 function searchTable() {
   // setLoading(true);
-  formModel.value.dictId = Number(id);
+  formModel.value.dictId = id.toString();
   getDictItemList(formModel.value)
     .then(res => {
       pagination.current = 1;
@@ -256,8 +255,6 @@ const updateListFun = () => {
   searchTable();
 };
 const handleEditFun = (value: ItemDataList) => {
-  value.dictCode = value.dictCode?.toString();
-  console.log('aaa', value);
   listObj.value = value as ItemDataList;
   showEditDialog.value = true;
 };
@@ -267,7 +264,7 @@ const handleDeleteFun = (id: number) => {
     content: t('modal.warning.content'),
     okText: t('searchTable.form.confirm'),
     onBeforeOk: (done: (closed: boolean) => void) => {
-      fetchDeleteDict({ id })
+      fetchDeleteDictItem({ id })
         .then(res => {
           if (res.success) {
             this_?.$message.success(t('message.success'));

+ 4 - 1
src/views/system/dict/edit.vue

@@ -66,12 +66,15 @@ watch(
     visible.value = value;
     if (value) {
       form.value = props.listObj;
+      if (!props.listObj.id) {
+        form.value.id = '0';
+      }
     }
   }
 );
 const formModel = () => {
   return {
-    id: 0,
+    id: '',
     name: '',
     description: '',
   } as DataList;

+ 0 - 4
src/views/system/dict/index.vue

@@ -131,13 +131,9 @@ import {
 import { getDictList, fetchDeleteDict } from '@/api/dict';
 import type { DictParams, DataList } from '@/api/dict';
 import { SizeProps, Pagination } from '@/types/global';
-import BTag from '@/components/business/b-tag/index.vue';
 import { Modal } from '@arco-design/web-vue';
 import useLoading from '@/hooks/loading';
 import { useI18n } from 'vue-i18n';
-import dayjs from 'dayjs';
-import { downLoadFun } from '@/utils/const';
-import { useIntervalFn } from '@vueuse/core';
 import EditDialog from './edit.vue';
 import router from '@/router';