Ver código fonte

feat :字典模块完成

duanyan 5 meses atrás
pai
commit
3f002fb171
1 arquivos alterados com 31 adições e 27 exclusões
  1. 31 27
      src/views/system/dict/index.vue

+ 31 - 27
src/views/system/dict/index.vue

@@ -1,17 +1,12 @@
 <template>
     <div class="container">
         <div class="head-title">
-            <span> 字典 </span>
+            <span> 字典管理 </span>
             <div class="form-row">
-                <a-input v-model="formData.type_key" style="margin: 0 0.6rem" placeholder="请输入type_key" />
-                <a-input v-model="formData.type_label" style="margin: 0 0.6rem" placeholder="请输入type_label" />
-                <a-button type="primary" style="margin: 0 0.6rem" @click="intData">
-                    <template #icon>
-                        <icon-search />
-                    </template>
-                    查询
-                </a-button>
-                <!-- <a-button style="margin: 0 0.6rem 0 0" @click="intData">重置</a-button> -->
+                <a-input v-model="formData.type_label" style="margin: 0 0.6rem" placeholder="请输入字典名称" />
+                <a-input v-model="formData.type_key" style="margin: 0 0.6rem" placeholder="请输入字典类型" />
+                <a-button type="primary" style="margin: 0 0.6rem" @click="intData">查询</a-button>
+                <a-button style="margin: 0 0.6rem 0 0" @click="resetSelectData">重置</a-button>
                 <a-button type="primary" @click="dictShowModel(1, null)">添加字典</a-button>
             </div>
         </div>
@@ -30,18 +25,18 @@
         <a-modal :title="typeCurrent == 1 ? '添加字典' : '修改字典'" v-model:visible="visible" @onCancel="resetForm" centered
             :maskClosable="false" :footer="null">
             <a-form ref="formRef" :rules="rules" :model="formState" @submit="handleSubmit">
-                <a-form-item label="字典名称" field="label">
-                    <a-input v-model="formState.label" />
-                </a-form-item>
-                <a-form-item label="key" field="value">
-                    <a-input v-model="formState.value" />
-                </a-form-item>
-                <a-form-item label="字典类型" field="typeLabel">
+                <a-form-item label="字典名称" field="typeLabel">
                     <a-input v-model="formState.typeLabel" />
                 </a-form-item>
-                <a-form-item label="数据键值" field="typeKey">
+                <a-form-item label="字典类型" field="typeKey">
                     <a-input v-model="formState.typeKey" />
                 </a-form-item>
+                <a-form-item label="数据标签" field="label">
+                    <a-input v-model="formState.label" />
+                </a-form-item>
+                <a-form-item label="数据键值" field="value">
+                    <a-input v-model="formState.value" />
+                </a-form-item>
                 <a-form-item label="备注" field="remark">
                     <a-textarea v-model="formState.remark" />
                 </a-form-item>
@@ -65,12 +60,13 @@ const dicId = ref(null);
 
 const formData = ref({
     type_key: '',
-    type_label: ''
+    type_label: '',
+
 });
 const columns = ref([
     { title: '字典编号', dataIndex: 'id', align: 'center', width: 120 },
-    { title: '字典名称', dataIndex: 'label', align: 'center', width: 120 },
-    { title: '字典类型', dataIndex: 'type_label', align: 'center', width: 120 },
+    { title: '字典名称', dataIndex: 'type_label', align: 'center', width: 120 },
+    { title: '字典类型', dataIndex: 'type_key', align: 'center', width: 120 },
     {
         title: '备注',
         dataIndex: 'remark',
@@ -87,7 +83,6 @@ const columns = ref([
         fixed: "right",
     }
 ])
-
 const rules = {
     label: [{ required: true, trigger: 'change', }],
     value: [
@@ -150,17 +145,21 @@ const handleSubmit = ({ values, errors }) => {
         typeKey: formState.typeKey,
         typeLabel: formState.typeLabel,
         remark: formState.remark,
-        id: typeCurrent == 1 ? undefined : dicId.value
+        id: typeCurrent.value == 1 ? undefined : dicId.value
     }
-    if (typeCurrent == 1) {
+    if (typeCurrent.value == 1) {
         dictionaryAdd(submitData).then(res => {
             intData();
             visible.value = false;
+            dicId.value = null;
+
         })
     } else {
         dictionaryUpdate(submitData).then(res => {
             intData();
             visible.value = false;
+            dicId.value = null;
+
         })
     }
 
@@ -168,7 +167,7 @@ const handleSubmit = ({ values, errors }) => {
 // 删除
 const deleteChange = (e) => {
     dictionaryDelete({ id: e }).then(res => {
-        console.log(res, '///////////');
+        intData();
     })
 }
 // 弹框
@@ -176,7 +175,6 @@ const dictShowModel = (type, data) => {
     typeCurrent.value = type;
     visible.value = true;
     if (type == 2) {
-        console.log(data.id);
         dicId.value = data.id;
         formState.label = data.label;
         formState.value = data.value;
@@ -185,10 +183,16 @@ const dictShowModel = (type, data) => {
         formState.remark = data.remark;
     }
 }
-
 // 取消
 const resetForm = () => {
     visible.value = false;
+    dicId.value = null;
+}
+// 重置
+const resetSelectData = () => {
+    formData.value.type_key = "";
+    formData.value.type_label = "";
+    intData();
 }
 
 onMounted(() => {