|
@@ -3,38 +3,38 @@
|
|
|
<el-row>
|
|
|
<el-col :span="24" class="main animate__animated animate__backInRight">
|
|
|
<el-col :span="24" class="one">
|
|
|
- <c-search :is_title="false" :is_back="true" @toBack="toBack"> </c-search>
|
|
|
- </el-col>
|
|
|
- <el-col :span="24" class="two">
|
|
|
- <component :is="search1" :form="searchForm" @onSubmit="toSearch" @toReset="toReset" @changeType="changeType"></component>
|
|
|
+ <c-search :is_title="false" :is_back="true" @toBack="toBack" :is_search="true" :fields="fields" @search="toSearch">
|
|
|
+ <template #type>
|
|
|
+ <el-select v-model="searchForm.type" filterable placeholder="请选择" style="width: 100%" @change="changeType">
|
|
|
+ <el-option v-for="(item, index) in typeList" :key="index" :label="item.name" :value="item.type"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </template>
|
|
|
+ </c-search>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="two">
|
|
|
<cButton @toAdd="toAdd()"> </cButton>
|
|
|
</el-col>
|
|
|
<el-col :span="24" class="fou">
|
|
|
- <cTable :fields="fields" :opera="opera" :data="list" @query="search" :total="total" @edit="toEdit" @del="toDel" :select="false"> </cTable>
|
|
|
+ <cTable :fields="fields" :opera="opera" :list="list" @query="search" :total="total" @edit="toEdit" @del="toDel" :select="false">
|
|
|
+ <template #type="{ item, row }">
|
|
|
+ <template v-if="item.model === 'type'">
|
|
|
+ {{ getProps(row, item.model) }}
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </cTable>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<cDialog :dialog="dialog" @handleClose="toClose">
|
|
|
<template v-slot:info>
|
|
|
- <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit">
|
|
|
- <template #status>
|
|
|
- <el-radio label="0">正常</el-radio>
|
|
|
- <el-radio label="1">停用</el-radio>
|
|
|
- </template>
|
|
|
- <template #is_default>
|
|
|
- <el-radio label="0">非默认</el-radio>
|
|
|
- <el-radio label="1">默认</el-radio>
|
|
|
- </template>
|
|
|
- </cForm>
|
|
|
+ <cForm v-if="dialog.type == '1'" :span="24" :fields="formFields" :form="form" :rules="rules" @save="onSubmit"> </cForm>
|
|
|
</template>
|
|
|
</cDialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts" setup>
|
|
|
import _ from 'lodash'
|
|
|
-import search1 from './parts_two/search-1.vue'
|
|
|
+// import search1 from './parts_two/search-1.vue'
|
|
|
import type { FormRules } from 'element-plus'
|
|
|
import type { Ref } from 'vue'
|
|
|
import { ref, onMounted, getCurrentInstance, reactive } from 'vue'
|
|
@@ -48,16 +48,17 @@ const dictData = DictDataStore()
|
|
|
const route = useRoute()
|
|
|
const { proxy } = getCurrentInstance() as any
|
|
|
// 列表数据
|
|
|
-let list: Ref<any[]> = ref([])
|
|
|
+let list: Ref<any> = ref([])
|
|
|
// 总数
|
|
|
let total: Ref<number> = ref(0)
|
|
|
let skip = 0
|
|
|
let limit: number = proxy.$limit
|
|
|
// 列表
|
|
|
let fields: Ref<any[]> = ref([
|
|
|
- { label: '字典标签', model: 'dict_label' },
|
|
|
- { label: '字典键值', model: 'dict_value' },
|
|
|
- { label: '字典排序', model: 'dict_sort' },
|
|
|
+ { label: '字典类型', model: 'type', isSearch: true, custom: true },
|
|
|
+ { label: '字典标签', model: 'label', isSearch: true },
|
|
|
+ { label: '字典键值', model: 'value' },
|
|
|
+ { label: '字典排序', model: 'sort' },
|
|
|
{ label: '状态', model: 'status', format: (i) => (i == '0' ? '正常' : '停用') }
|
|
|
])
|
|
|
// 操作
|
|
@@ -70,23 +71,24 @@ let form: Ref<any> = ref({})
|
|
|
|
|
|
// 表单
|
|
|
let formFields: Ref<any[]> = ref([
|
|
|
- { label: '字典类型', model: 'dict_type' },
|
|
|
- { label: '字典标签', model: 'dict_label' },
|
|
|
- { label: '字典键值', model: 'dict_value' },
|
|
|
- { label: '显示排序', model: 'dict_sort', type: 'number' },
|
|
|
- { label: '是否默认', model: 'is_default', type: 'radio' },
|
|
|
- { label: '状态', model: 'status', type: 'radio' }
|
|
|
+ { label: '字典类型', model: 'type' },
|
|
|
+ { label: '字典标签', model: 'label' },
|
|
|
+ { label: '字典键值', model: 'value' },
|
|
|
+ { label: '显示排序', model: 'sort', type: 'number' },
|
|
|
+ { label: '是否启用', model: 'is_use', type: 'radio' }
|
|
|
])
|
|
|
const rules = reactive<FormRules>({
|
|
|
- dict_name: [{ required: true, message: '请输入字典名称', trigger: 'blur' }],
|
|
|
- dict_type: [{ required: true, message: '请输入字典类型', trigger: 'blur' }],
|
|
|
- status: [{ required: true, message: '请选择状态', trigger: 'change' }]
|
|
|
+ type: [{ required: true, message: '请输入字典类型', trigger: 'blur' }],
|
|
|
+ label: [{ required: true, message: '请输入字典标签', trigger: 'blur' }],
|
|
|
+ value: [{ required: true, message: '请输入字典键值', trigger: 'blur' }],
|
|
|
+ sort: [{ required: true, message: '请输入显示排序', trigger: 'blur' }]
|
|
|
+ // is_use: [{ required: true, message: '请选择是否启用', trigger: 'change' }]
|
|
|
})
|
|
|
|
|
|
// 查询数据
|
|
|
let searchForm: Ref<any> = ref({})
|
|
|
-let dict_type: Ref<any> = ref('')
|
|
|
-let dict_typeList: Ref<any> = ref([])
|
|
|
+let type: Ref<any> = ref('')
|
|
|
+let typeList: Ref<any> = ref([])
|
|
|
|
|
|
onMounted(async () => {
|
|
|
await searchOther()
|
|
@@ -107,15 +109,11 @@ const toSearch = () => {
|
|
|
search({ skip, limit })
|
|
|
}
|
|
|
const searchOther = async () => {
|
|
|
- if (route.query.dict_type) dict_type.value = route.query.dict_type
|
|
|
- form.value.dict_type = dict_type.value
|
|
|
- searchForm.value.dict_type = dict_type.value
|
|
|
+ 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) dict_typeList.value = res.data as any[]
|
|
|
-}
|
|
|
-const toReset = () => {
|
|
|
- searchForm.value = { dict_type: route.query.dict_type }
|
|
|
- search({ skip, limit })
|
|
|
+ if (res.errcode == 0) typeList.value = res.data
|
|
|
}
|
|
|
// 新增
|
|
|
const toAdd = () => {
|
|
@@ -139,6 +137,13 @@ 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)
|
|
@@ -149,8 +154,8 @@ const toDel = async (data) => {
|
|
|
}
|
|
|
// 选择字典名称
|
|
|
const changeType = (value) => {
|
|
|
- dict_type.value = value
|
|
|
- form.value.dict_type = value
|
|
|
+ type.value = value
|
|
|
+ form.value.type = value
|
|
|
}
|
|
|
// 返回
|
|
|
const toBack = () => {
|
|
@@ -159,7 +164,7 @@ const toBack = () => {
|
|
|
// 弹框关闭
|
|
|
const toClose = () => {
|
|
|
form.value = {}
|
|
|
- searchForm.value = { dict_type: dict_type.value }
|
|
|
+ searchForm.value = { type: type.value }
|
|
|
dialog.value = { title: '信息管理', show: false, type: '1' }
|
|
|
search({ skip, limit })
|
|
|
}
|