فهرست منبع

perf: 字典添加status

曾坤森 1 ماه پیش
والد
کامیت
e0cf063866
3فایلهای تغییر یافته به همراه34 افزوده شده و 0 حذف شده
  1. 1 0
      src/api/dict.ts
  2. 21 0
      src/views/system/dict/edit.vue
  3. 12 0
      src/views/system/dict/index.vue

+ 1 - 0
src/api/dict.ts

@@ -5,6 +5,7 @@ import instance from './interceptor';
 export interface DataList {
   id?: string;
   name?: string;
+  status?: number;
   description?: string;
 }
 

+ 21 - 0
src/views/system/dict/edit.vue

@@ -29,6 +29,25 @@
             </a-form-item>
           </a-col>
         </a-row>
+        <a-row :gutter="8">
+          <a-col :span="12">
+            <a-form-item
+              field="status"
+              :label="t('dict.form.status')"
+              :rules="getRules(t).required"
+            >
+              <a-switch
+                v-model="form.status"
+                type="round"
+                :checked-value="1"
+                :unchecked-value="0"
+              >
+                <template #checked> {{ t('tag.status.enable') }}</template>
+                <template #unchecked> {{ t('tag.status.disable') }} </template>
+              </a-switch>
+            </a-form-item>
+          </a-col>
+        </a-row>
       </a-form>
     </a-modal>
   </div>
@@ -68,6 +87,7 @@ watch(
       form.value = props.listObj;
       if (!props.listObj.id) {
         form.value.id = '0';
+        form.value.status = 1;
       }
     }
   }
@@ -76,6 +96,7 @@ const formModel = () => {
   return {
     id: '',
     name: '',
+    status: 1,
     description: '',
   } as DataList;
 };

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

@@ -88,6 +88,11 @@
             {{ record.name }}
           </div>
         </template>
+        <template #status="{ record }">
+          <a-tag :color="record.status === 1 ? 'green' : 'red'">{{
+            record.status ? t('tag.status.enable') : t('tag.status.disable')
+          }}</a-tag>
+        </template>
         <template #optional="{ record }">
           <a-button
             type="primary"
@@ -156,6 +161,13 @@ const cloneColumns = computed(() => [
     ellipsis: true,
     align: 'center',
   },
+  {
+    title: t('dict.form.status'),
+    dataIndex: 'status',
+    slotName: 'status',
+    ellipsis: true,
+    align: 'center',
+  },
   {
     title: t('dict.form.description'),
     dataIndex: 'description',