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