소스 검색

参数管理这块编辑的时候没有回显

yanglzh 2 년 전
부모
커밋
4d8689be9e
1개의 변경된 파일99개의 추가작업 그리고 99개의 파일을 삭제
  1. 99 99
      src/views/system/config/component/editConfig.vue

+ 99 - 99
src/views/system/config/component/editConfig.vue

@@ -13,7 +13,7 @@
         </el-form-item>
         <el-form-item label="系统内置" prop="configType">
           <el-radio-group v-model="ruleForm.configType">
-            <el-radio v-for="dict in sysYesNoOptions" :key="dict.value" :label="dict.value">{{dict.label}}</el-radio>
+            <el-radio v-for="dict in sysYesNoOptions" :key="dict.value" :label="Number(dict.value)">{{dict.label}}</el-radio>
           </el-radio-group>
         </el-form-item>
         <el-form-item label="备注" prop="remark">
@@ -35,108 +35,108 @@ import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
 import { ElMessage } from 'element-plus';
 import api from '/@/api/system';
 interface RuleFormState {
-	configId: number;
-	configName: string;
-	configKey: string;
-	configValue: string;
-	configType: string;
-	remark: string;
+  configId: number;
+  configName: string;
+  configKey: string;
+  configValue: string;
+  configType: string;
+  remark: string;
 }
 interface DicState {
-	isShowDialog: boolean;
-	ruleForm: RuleFormState;
-	rules: {};
+  isShowDialog: boolean;
+  ruleForm: RuleFormState;
+  rules: {};
 }
 
 export default defineComponent({
-	name: 'systemEditDicData',
-	props: {
-		sysYesNoOptions: {
-			type: Array,
-			default: () => [],
-		},
-	},
-	setup(prop, { emit }) {
-		const formRef = ref<HTMLElement | null>(null);
-		const state = reactive<DicState>({
-			isShowDialog: false,
-			ruleForm: {
-				configId: 0,
-				configName: '',
-				configKey: '',
-				configValue: '',
-				configType: '0',
-				remark: '',
-			},
-			rules: {
-				configName: [{ required: true, message: '参数名称不能为空', trigger: 'blur' }],
-				configKey: [{ required: true, message: '参数键名不能为空', trigger: 'blur' }],
-				configValue: [{ required: true, message: '参数键值不能为空', trigger: 'blur' }],
-			},
-		});
-		// 打开弹窗
-		const openDialog = (row: RuleFormState | null) => {
-			resetForm();
-			if (row) {
-				api.config.detail(row.configId).then((res: any) => {
-					const data: RuleFormState = res.data.data;
-					data.configType = String(data.configType);
-					state.ruleForm = data;
-				});
-				state.ruleForm = row;
-			}
-			state.isShowDialog = true;
-		};
-		const resetForm = () => {
-			state.ruleForm = {
-				configId: 0,
-				configName: '',
-				configKey: '',
-				configValue: '',
-				configType: '0',
-				remark: '',
-			};
-		};
-		// 关闭弹窗
-		const closeDialog = () => {
-			state.isShowDialog = false;
-		};
-		// 取消
-		const onCancel = () => {
-			closeDialog();
-		};
-		// 新增
-		const onSubmit = () => {
-			const formWrap = unref(formRef) as any;
-			if (!formWrap) return;
-			formWrap.validate((valid: boolean) => {
-				if (valid) {
-					if (state.ruleForm.configId !== 0) {
-						//修改
-						api.config.edit(state.ruleForm).then(() => {
-							ElMessage.success('参数修改成功');
-							closeDialog(); // 关闭弹窗
-							emit('dataList');
-						});
-					} else {
-						//添加
-						api.config.add(state.ruleForm).then(() => {
-							ElMessage.success('参数添加成功');
-							closeDialog(); // 关闭弹窗
-							emit('dataList');
-						});
-					}
-				}
-			});
-		};
-		return {
-			openDialog,
-			closeDialog,
-			onCancel,
-			onSubmit,
-			formRef,
-			...toRefs(state),
-		};
-	},
+  name: 'systemEditDicData',
+  props: {
+    sysYesNoOptions: {
+      type: Array,
+      default: () => [],
+    },
+  },
+  setup(prop, { emit }) {
+    const formRef = ref<HTMLElement | null>(null);
+    const state = reactive<DicState>({
+      isShowDialog: false,
+      ruleForm: {
+        configId: 0,
+        configName: '',
+        configKey: '',
+        configValue: '',
+        configType: '0',
+        remark: '',
+      },
+      rules: {
+        configName: [{ required: true, message: '参数名称不能为空', trigger: 'blur' }],
+        configKey: [{ required: true, message: '参数键名不能为空', trigger: 'blur' }],
+        configValue: [{ required: true, message: '参数键值不能为空', trigger: 'blur' }],
+      },
+    });
+    // 打开弹窗
+    const openDialog = (row: RuleFormState | null) => {
+      resetForm();
+      if (row) {
+        api.config.detail(row.configId).then((res: any) => {
+          const data: RuleFormState = res.data.data;
+          data.configType = String(data.configType);
+          state.ruleForm = data;
+        });
+        state.ruleForm = row;
+      }
+      state.isShowDialog = true;
+    };
+    const resetForm = () => {
+      state.ruleForm = {
+        configId: 0,
+        configName: '',
+        configKey: '',
+        configValue: '',
+        configType: '0',
+        remark: '',
+      };
+    };
+    // 关闭弹窗
+    const closeDialog = () => {
+      state.isShowDialog = false;
+    };
+    // 取消
+    const onCancel = () => {
+      closeDialog();
+    };
+    // 新增
+    const onSubmit = () => {
+      const formWrap = unref(formRef) as any;
+      if (!formWrap) return;
+      formWrap.validate((valid: boolean) => {
+        if (valid) {
+          if (state.ruleForm.configId !== 0) {
+            //修改
+            api.config.edit(state.ruleForm).then(() => {
+              ElMessage.success('参数修改成功');
+              closeDialog(); // 关闭弹窗
+              emit('dataList');
+            });
+          } else {
+            //添加
+            api.config.add(state.ruleForm).then(() => {
+              ElMessage.success('参数添加成功');
+              closeDialog(); // 关闭弹窗
+              emit('dataList');
+            });
+          }
+        }
+      });
+    };
+    return {
+      openDialog,
+      closeDialog,
+      onCancel,
+      onSubmit,
+      formRef,
+      ...toRefs(state),
+    };
+  },
 });
 </script>