|
@@ -31,6 +31,39 @@
|
|
|
<template #is_use>
|
|
|
<el-radio v-for="(i, index) in is_useList" :key="index" :label="i.value">{{ i.label }}</el-radio>
|
|
|
</template>
|
|
|
+ <template #children>
|
|
|
+ <el-col :span="24" class="children">
|
|
|
+ <el-col :span="24" class="children_1">
|
|
|
+ <el-button type="primary" @click="clAdd()">添加</el-button>
|
|
|
+ <el-button type="primary" @click="clReload()">刷新排序</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="24" class="children_2">
|
|
|
+ <el-table :data="form.children" border size="small">
|
|
|
+ <el-table-column type="index" label="序号" width="50" align="center"> </el-table-column>
|
|
|
+ <el-table-column prop="label" label="标签" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-model="scope.row.label" placeholder="请输入标签"></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="value" label="键值" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-model="scope.row.value" placeholder="请输入键值"></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="sort" label="排序" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-input v-model="scope.row.sort" type="number" placeholder="请输入排序"></el-input>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" width="100">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-button size="small" type="danger" @click="clDel(scope.row)">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ </template>
|
|
|
</cForm>
|
|
|
</template>
|
|
|
</cDialog>
|
|
@@ -38,7 +71,7 @@
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
import _ from 'lodash';
|
|
|
-// import search1 from './parts_two/search-1.vue'
|
|
|
+import moment from 'moment';
|
|
|
import type { FormRules } from 'element-plus';
|
|
|
import type { Ref } from 'vue';
|
|
|
import { ref, onMounted, getCurrentInstance, reactive } from 'vue';
|
|
@@ -80,7 +113,8 @@ let formFields: Ref<any[]> = ref([
|
|
|
{ label: '字典标签', model: 'label' },
|
|
|
{ label: '字典键值', model: 'value' },
|
|
|
{ label: '显示排序', model: 'sort', type: 'number' },
|
|
|
- { label: '状态', model: 'is_use', type: 'radio' }
|
|
|
+ { label: '状态', model: 'is_use', type: 'radio' },
|
|
|
+ { label: '子数据', model: 'children', custom: true }
|
|
|
]);
|
|
|
const rules = reactive<FormRules>({
|
|
|
type: [{ required: true, message: '请输入字典类型', trigger: 'blur' }],
|
|
@@ -115,15 +149,7 @@ const search = async (e: { skip: number; limit: number }) => {
|
|
|
const toSearch = () => {
|
|
|
search({ skip, limit });
|
|
|
};
|
|
|
-const searchOther = async () => {
|
|
|
- if (route.query.type) type.value = route.query.type;
|
|
|
- form.value.type = type.value;
|
|
|
- searchForm.value.type = type.value;
|
|
|
- let res: IQueryResult = await dictType.query();
|
|
|
- if (res.errcode == 0) typeList.value = res.data;
|
|
|
- let aee: IQueryResult = await dictData.query({ type: 'common_use' });
|
|
|
- if (aee.errcode == 0) is_useList.value = aee.data;
|
|
|
-};
|
|
|
+
|
|
|
// 新增
|
|
|
const toAdd = () => {
|
|
|
dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
@@ -136,6 +162,17 @@ const toEdit = async (data) => {
|
|
|
dialog.value = { title: '信息管理', show: true, type: '1' };
|
|
|
}
|
|
|
};
|
|
|
+// 选择字典名称
|
|
|
+const changeType = (value) => {
|
|
|
+ type.value = value;
|
|
|
+ form.value.type = value;
|
|
|
+};
|
|
|
+const getProps = (e, model) => {
|
|
|
+ if (model == 'type') {
|
|
|
+ let data = typeList.value.find((i) => i.type == e.type);
|
|
|
+ if (data) return data.name;
|
|
|
+ }
|
|
|
+};
|
|
|
// 提交
|
|
|
const onSubmit = async (data) => {
|
|
|
let res: IQueryResult;
|
|
@@ -146,13 +183,6 @@ const onSubmit = async (data) => {
|
|
|
toClose();
|
|
|
}
|
|
|
};
|
|
|
-const getProps = (e, model) => {
|
|
|
- if (model == 'type') {
|
|
|
- let data = typeList.value.find((i) => i.type == e.type);
|
|
|
- if (data) return data.name;
|
|
|
- }
|
|
|
-};
|
|
|
-
|
|
|
// 删除
|
|
|
const toDel = async (data) => {
|
|
|
let res: IQueryResult = await dictData.del(data._id);
|
|
@@ -161,15 +191,6 @@ const toDel = async (data) => {
|
|
|
search({ skip, limit });
|
|
|
}
|
|
|
};
|
|
|
-// 选择字典名称
|
|
|
-const changeType = (value) => {
|
|
|
- type.value = value;
|
|
|
- form.value.type = value;
|
|
|
-};
|
|
|
-// 返回
|
|
|
-const toBack = () => {
|
|
|
- window.history.go(-1);
|
|
|
-};
|
|
|
// 弹框关闭
|
|
|
const toClose = () => {
|
|
|
form.value = { type: type.value };
|
|
@@ -177,6 +198,35 @@ const toClose = () => {
|
|
|
dialog.value = { title: '信息管理', show: false, type: '1' };
|
|
|
search({ skip, limit });
|
|
|
};
|
|
|
+// 子数据
|
|
|
+const clAdd = () => {
|
|
|
+ let children = form.value.children || [];
|
|
|
+ children.push({ id: moment().valueOf(), label: '', value: '', sort: 0 });
|
|
|
+ form.value.children = children;
|
|
|
+};
|
|
|
+// 子数据删除
|
|
|
+const clDel = (e) => {
|
|
|
+ let children = form.value.children.filter((i: any) => i.id != e.id);
|
|
|
+ form.value.children = children;
|
|
|
+};
|
|
|
+// 子数据刷新
|
|
|
+const clReload = () => {
|
|
|
+ let children = _.sortBy(form.value.children, ['sort']);
|
|
|
+ form.value.children = children;
|
|
|
+};
|
|
|
+const searchOther = async () => {
|
|
|
+ if (route.query.type) type.value = route.query.type;
|
|
|
+ form.value.type = type.value;
|
|
|
+ searchForm.value.type = type.value;
|
|
|
+ let res: IQueryResult = await dictType.query();
|
|
|
+ if (res.errcode == 0) typeList.value = res.data;
|
|
|
+ let aee: IQueryResult = await dictData.query({ type: 'common_use' });
|
|
|
+ if (aee.errcode == 0) is_useList.value = aee.data;
|
|
|
+};
|
|
|
+// 返回
|
|
|
+const toBack = () => {
|
|
|
+ window.history.go(-1);
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.main {
|
|
@@ -187,4 +237,9 @@ const toClose = () => {
|
|
|
margin: 0 0 10px 0;
|
|
|
}
|
|
|
}
|
|
|
+.children {
|
|
|
+ .children_1 {
|
|
|
+ margin: 0 0 10px 0;
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|