feat: dict vxe
This commit is contained in:
parent
22748c5aa8
commit
42eb550858
@ -2,105 +2,87 @@ import { reactive } from 'vue'
|
|||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
|
||||||
// 国际化
|
// 国际化
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
// 表单校验
|
// 表单校验
|
||||||
export const dictDataRules = reactive({
|
export const dictDataRules = reactive({
|
||||||
label: [required],
|
title: [required],
|
||||||
value: [required],
|
value: [required],
|
||||||
sort: [required]
|
sort: [required]
|
||||||
})
|
})
|
||||||
// crudSchemas
|
// crudSchemas
|
||||||
export const crudSchemas = reactive<CrudSchema[]>([
|
export const crudSchemas = reactive<VxeCrudSchema>({
|
||||||
|
primaryKey: 'id',
|
||||||
|
primaryType: 'seq',
|
||||||
|
action: true,
|
||||||
|
actionWidth: '140px',
|
||||||
|
columns: [
|
||||||
{
|
{
|
||||||
label: t('common.index'),
|
title: '字典类型',
|
||||||
field: 'id',
|
|
||||||
type: 'index',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '字典类型',
|
|
||||||
field: 'dictType',
|
field: 'dictType',
|
||||||
table: {
|
isTable: false,
|
||||||
show: false
|
isForm: false
|
||||||
},
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '数据标签',
|
title: '数据标签',
|
||||||
field: 'label',
|
field: 'label',
|
||||||
search: {
|
isSearch: true
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '数据键值',
|
title: '数据键值',
|
||||||
field: 'value'
|
field: 'value'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '颜色类型',
|
title: '颜色类型',
|
||||||
field: 'colorType',
|
field: 'colorType',
|
||||||
form: {
|
form: {
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
label: 'default',
|
title: 'default',
|
||||||
value: ''
|
value: ''
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'success',
|
title: 'success',
|
||||||
value: 'success'
|
value: 'success'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'info',
|
title: 'info',
|
||||||
value: 'info'
|
value: 'info'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'warning',
|
title: 'warning',
|
||||||
value: 'warning'
|
value: 'warning'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'danger',
|
title: 'danger',
|
||||||
value: 'danger'
|
value: 'danger'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
table: {
|
isTable: false
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: 'CSS Class',
|
title: 'CSS Class',
|
||||||
field: 'cssClass',
|
field: 'cssClass',
|
||||||
table: {
|
isTable: false
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '显示排序',
|
title: '显示排序',
|
||||||
field: 'sort',
|
field: 'sort',
|
||||||
table: {
|
isTable: false
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('common.status'),
|
title: t('common.status'),
|
||||||
field: 'status',
|
field: 'status',
|
||||||
dictType: DICT_TYPE.COMMON_STATUS,
|
dictType: DICT_TYPE.COMMON_STATUS,
|
||||||
dictClass: 'number'
|
dictClass: 'number'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('form.remark'),
|
title: t('form.remark'),
|
||||||
field: 'remark',
|
field: 'remark',
|
||||||
form: {
|
form: {
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
@ -112,21 +94,8 @@ export const crudSchemas = reactive<CrudSchema[]>([
|
|||||||
span: 24
|
span: 24
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
table: {
|
isTable: false
|
||||||
show: false
|
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
{
|
})
|
||||||
label: t('table.action'),
|
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
||||||
field: 'action',
|
|
||||||
width: '180px',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|
||||||
|
@ -2,75 +2,53 @@ import { reactive } from 'vue'
|
|||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
|
||||||
// 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const { t } = useI18n()
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
export const dictTypeRules = reactive({
|
export const dictTypeRules = reactive({
|
||||||
name: [required],
|
name: [required],
|
||||||
type: [required]
|
type: [required]
|
||||||
})
|
})
|
||||||
// 新增 + 修改
|
// 新增 + 修改
|
||||||
const crudSchemas = reactive<CrudSchema[]>([
|
const crudSchemas = reactive<VxeCrudSchema>({
|
||||||
|
primaryKey: 'id',
|
||||||
|
primaryType: 'seq',
|
||||||
|
action: true,
|
||||||
|
actionWidth: '140px',
|
||||||
|
columns: [
|
||||||
{
|
{
|
||||||
label: t('common.index'),
|
title: '字典名称',
|
||||||
field: 'id',
|
|
||||||
type: 'index',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '字典名称',
|
|
||||||
field: 'name',
|
field: 'name',
|
||||||
search: {
|
isSearch: true
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: '字典类型',
|
title: '字典类型',
|
||||||
field: 'type',
|
field: 'type',
|
||||||
search: {
|
isSearch: true
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('common.status'),
|
title: t('common.status'),
|
||||||
field: 'status',
|
field: 'status',
|
||||||
dictType: DICT_TYPE.COMMON_STATUS,
|
dictType: DICT_TYPE.COMMON_STATUS,
|
||||||
dictClass: 'number'
|
dictClass: 'number',
|
||||||
|
table: {
|
||||||
|
width: 70
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('common.createTime'),
|
title: t('common.createTime'),
|
||||||
field: 'createTime',
|
field: 'createTime',
|
||||||
|
formatter: 'formatDate',
|
||||||
|
isForm: false,
|
||||||
table: {
|
table: {
|
||||||
show: false
|
width: 150
|
||||||
},
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
search: {
|
|
||||||
show: true,
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
type: 'datetimerange',
|
|
||||||
valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
||||||
defaultTime: [new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('form.remark'),
|
title: t('form.remark'),
|
||||||
field: 'remark',
|
field: 'remark',
|
||||||
table: {
|
isTable: false,
|
||||||
show: false
|
|
||||||
},
|
|
||||||
form: {
|
form: {
|
||||||
componentProps: {
|
componentProps: {
|
||||||
type: 'textarea',
|
type: 'textarea',
|
||||||
@ -80,18 +58,7 @@ const crudSchemas = reactive<CrudSchema[]>([
|
|||||||
span: 24
|
span: 24
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
field: 'action',
|
|
||||||
width: '180px',
|
|
||||||
label: t('table.action'),
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
])
|
})
|
||||||
|
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|
||||||
|
@ -6,13 +6,13 @@
|
|||||||
<span>字典分类</span>
|
<span>字典分类</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<Search
|
<vxe-grid
|
||||||
:schema="DictTypeSchemas.allSchemas.searchSchema"
|
ref="xTypeGrid"
|
||||||
@search="setTypeSearchParams"
|
v-bind="typeGridOptions"
|
||||||
@reset="setTypeSearchParams"
|
@cell-click="cellClickEvent"
|
||||||
/>
|
class="xtable-scrollbar"
|
||||||
<!-- 操作工具栏 -->
|
>
|
||||||
<div class="mb-10px">
|
<template #toolbar_buttons>
|
||||||
<XButton
|
<XButton
|
||||||
type="primary"
|
type="primary"
|
||||||
preIcon="ep:zoom-in"
|
preIcon="ep:zoom-in"
|
||||||
@ -20,40 +20,22 @@
|
|||||||
v-hasPermi="['system:dict:create']"
|
v-hasPermi="['system:dict:create']"
|
||||||
@click="handleTypeCreate()"
|
@click="handleTypeCreate()"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<!-- 列表 -->
|
|
||||||
<Table
|
|
||||||
@row-click="onClickType"
|
|
||||||
:columns="DictTypeSchemas.allSchemas.tableColumns"
|
|
||||||
:selection="false"
|
|
||||||
:data="typeTableObject.tableList"
|
|
||||||
:loading="typeTableObject.loading"
|
|
||||||
:pagination="{
|
|
||||||
total: typeTableObject.total
|
|
||||||
}"
|
|
||||||
:highlight-current-row="true"
|
|
||||||
v-model:pageSize="typeTableObject.pageSize"
|
|
||||||
v-model:currentPage="typeTableObject.currentPage"
|
|
||||||
@register="typeRegister"
|
|
||||||
>
|
|
||||||
<template #status="{ row }">
|
|
||||||
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #actionbtns_default="{ row }">
|
||||||
<XTextButton
|
<XTextButton
|
||||||
preIcon="ep:edit"
|
preIcon="ep:edit"
|
||||||
:title="t('action.edit')"
|
:title="t('action.edit')"
|
||||||
v-hasPermi="['system:dict:update']"
|
v-hasPermi="['system:dict:update']"
|
||||||
@click="handleTypeUpdate(row)"
|
@click="handleTypeUpdate(row.id)"
|
||||||
/>
|
/>
|
||||||
<XTextButton
|
<XTextButton
|
||||||
preIcon="ep:delete"
|
preIcon="ep:delete"
|
||||||
:title="t('action.del')"
|
:title="t('action.del')"
|
||||||
v-hasPermi="['system:dict:delete']"
|
v-hasPermi="['system:dict:delete']"
|
||||||
@click="delTypeList(row.id, false)"
|
@click="handleTypeDelete(row.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</vxe-grid>
|
||||||
</el-card>
|
</el-card>
|
||||||
<el-card class="w-1/2 dict" style="margin-left: 10px" :gutter="12" shadow="hover">
|
<el-card class="w-1/2 dict" style="margin-left: 10px" :gutter="12" shadow="hover">
|
||||||
<template #header>
|
<template #header>
|
||||||
@ -66,13 +48,9 @@
|
|||||||
<span>请从左侧选择</span>
|
<span>请从左侧选择</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="tableTypeSelect">
|
<div v-if="tableTypeSelect">
|
||||||
<Search
|
<!-- 列表 -->
|
||||||
:schema="DictDataSchemas.allSchemas.searchSchema"
|
<vxe-grid ref="xDataGrid" v-bind="dataGridOptions" class="xtable-scrollbar">
|
||||||
@search="setDataSearchParams"
|
<template #toolbar_buttons>
|
||||||
@reset="setDataSearchParams"
|
|
||||||
/>
|
|
||||||
<!-- 操作工具栏 -->
|
|
||||||
<div class="mb-10px">
|
|
||||||
<XButton
|
<XButton
|
||||||
type="primary"
|
type="primary"
|
||||||
preIcon="ep:zoom-in"
|
preIcon="ep:zoom-in"
|
||||||
@ -80,37 +58,22 @@
|
|||||||
v-hasPermi="['system:dict:create']"
|
v-hasPermi="['system:dict:create']"
|
||||||
@click="handleDataCreate()"
|
@click="handleDataCreate()"
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
<Table
|
|
||||||
:columns="DictDataSchemas.allSchemas.tableColumns"
|
|
||||||
:selection="false"
|
|
||||||
:data="dataTableObject.tableList"
|
|
||||||
:loading="dataTableObject.loading"
|
|
||||||
:pagination="{
|
|
||||||
total: dataTableObject.total
|
|
||||||
}"
|
|
||||||
v-model:pageSize="dataTableObject.pageSize"
|
|
||||||
v-model:currentPage="dataTableObject.currentPage"
|
|
||||||
@register="dataRegister"
|
|
||||||
>
|
|
||||||
<template #status="{ row }">
|
|
||||||
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
<template #actionbtns_default="{ row }">
|
||||||
<XTextButton
|
<XTextButton
|
||||||
v-hasPermi="['system:dict:update']"
|
v-hasPermi="['system:dict:update']"
|
||||||
preIcon="ep:edit"
|
preIcon="ep:edit"
|
||||||
:title="t('action.edit')"
|
:title="t('action.edit')"
|
||||||
@click="handleDataUpdate(row)"
|
@click="handleDataUpdate(row.id)"
|
||||||
/>
|
/>
|
||||||
<XTextButton
|
<XTextButton
|
||||||
v-hasPermi="['system:dict:delete']"
|
v-hasPermi="['system:dict:delete']"
|
||||||
preIcon="ep:delete"
|
preIcon="ep:delete"
|
||||||
:title="t('action.del')"
|
:title="t('action.del')"
|
||||||
@click="delDataList(row.id, false)"
|
@click="handleDataDelete(row.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</vxe-grid>
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
<XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
|
<XModal id="dictModel" v-model="dialogVisible" :title="dialogTitle">
|
||||||
@ -155,82 +118,81 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, unref, onMounted } from 'vue'
|
import { ref, unref, reactive } from 'vue'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||||
|
import { VxeGridInstance, VxeTableEvents } from 'vxe-table'
|
||||||
import { FormExpose } from '@/components/Form'
|
import { FormExpose } from '@/components/Form'
|
||||||
import { ElInput, ElTag } from 'element-plus'
|
import { ElInput, ElTag, ElCard } from 'element-plus'
|
||||||
import * as DictTypeSchemas from './dict.type'
|
import * as DictTypeSchemas from './dict.type'
|
||||||
import * as DictDataSchemas from './dict.data'
|
import * as DictDataSchemas from './dict.data'
|
||||||
import { useTable } from '@/hooks/web/useTable'
|
|
||||||
import { ElCard, ElMessage } from 'element-plus'
|
|
||||||
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
import * as DictTypeApi from '@/api/system/dict/dict.type'
|
||||||
import * as DictDataApi from '@/api/system/dict/dict.data'
|
import * as DictDataApi from '@/api/system/dict/dict.data'
|
||||||
import { DictDataVO, DictTypeVO } from '@/api/system/dict/types'
|
import { DictDataVO, DictTypeVO } from '@/api/system/dict/types'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
// ========== 字典分类列表相关 ==========
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const xTypeGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const {
|
const {
|
||||||
register: typeRegister,
|
gridOptions: typeGridOptions,
|
||||||
tableObject: typeTableObject,
|
getList: typeGetList,
|
||||||
methods: typeMethods
|
deleteData: typeDeleteData
|
||||||
} = useTable<DictTypeVO>({
|
} = useVxeGrid<DictTypeVO>({
|
||||||
|
allSchemas: DictTypeSchemas.allSchemas,
|
||||||
getListApi: DictTypeApi.getDictTypePageApi,
|
getListApi: DictTypeApi.getDictTypePageApi,
|
||||||
delListApi: DictTypeApi.deleteDictTypeApi
|
deleteApi: DictTypeApi.deleteDictTypeApi
|
||||||
|
})
|
||||||
|
|
||||||
|
const xDataGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
|
const queryParams = reactive({
|
||||||
|
dictType: null
|
||||||
})
|
})
|
||||||
const {
|
const {
|
||||||
getList: getTypeList,
|
gridOptions: dataGridOptions,
|
||||||
setSearchParams: setTypeSearchParams,
|
getList: dataGetList,
|
||||||
delList: delTypeList
|
deleteData: dataDeleteData
|
||||||
} = typeMethods
|
} = useVxeGrid<DictDataVO>({
|
||||||
|
allSchemas: DictDataSchemas.allSchemas,
|
||||||
|
queryParams: queryParams,
|
||||||
|
getListApi: DictDataApi.getDictDataPageApi,
|
||||||
|
deleteApi: DictDataApi.deleteDictDataApi
|
||||||
|
})
|
||||||
|
// ========== 字典分类列表相关 ==========
|
||||||
const dictTypeValue = ref('')
|
const dictTypeValue = ref('')
|
||||||
// 字典分类修改操作
|
// 字典分类修改操作
|
||||||
const handleTypeCreate = () => {
|
const handleTypeCreate = () => {
|
||||||
dictTypeValue.value = ''
|
dictTypeValue.value = ''
|
||||||
setDialogTile('typeCreate')
|
setDialogTile('typeCreate')
|
||||||
}
|
}
|
||||||
const handleTypeUpdate = async (row: DictTypeVO) => {
|
const handleTypeUpdate = async (rowId: number) => {
|
||||||
setDialogTile('typeUpdate')
|
setDialogTile('typeUpdate')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await DictTypeApi.getDictTypeApi(row.id)
|
const res = await DictTypeApi.getDictTypeApi(rowId)
|
||||||
dictTypeValue.value = res.type
|
dictTypeValue.value = res.type
|
||||||
unref(typeFormRef)?.setValues(res)
|
unref(typeFormRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 字典数据列表相关 ==========
|
|
||||||
const tableTypeSelect = ref(false)
|
|
||||||
const {
|
|
||||||
register: dataRegister,
|
|
||||||
tableObject: dataTableObject,
|
|
||||||
methods: dataMethods
|
|
||||||
} = useTable<DictDataVO>({
|
|
||||||
getListApi: DictDataApi.getDictDataPageApi,
|
|
||||||
delListApi: DictDataApi.deleteDictDataApi
|
|
||||||
})
|
|
||||||
const {
|
|
||||||
getList: getDataList,
|
|
||||||
setSearchParams: setDataSearchParams,
|
|
||||||
delList: delDataList
|
|
||||||
} = dataMethods
|
|
||||||
|
|
||||||
// 字典数据修改操作
|
// 字典数据修改操作
|
||||||
const handleDataCreate = () => {
|
const handleDataCreate = () => {
|
||||||
setDialogTile('dataCreate')
|
setDialogTile('dataCreate')
|
||||||
}
|
}
|
||||||
const handleDataUpdate = async (row: DictDataVO) => {
|
const handleDataUpdate = async (rowId: number) => {
|
||||||
setDialogTile('dataUpdate')
|
setDialogTile('dataUpdate')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await DictDataApi.getDictDataApi(row.id)
|
const res = await DictDataApi.getDictDataApi(rowId)
|
||||||
unref(dataFormRef)?.setValues(res)
|
unref(dataFormRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
// 字典分类点击行事件
|
// 字典分类点击行事件
|
||||||
const parentType = ref('')
|
const parentType = ref('')
|
||||||
const onClickType = async (data: { [key: string]: any }) => {
|
const tableTypeSelect = ref(false)
|
||||||
|
const cellClickEvent: VxeTableEvents.CellClick = async ({ row }) => {
|
||||||
|
console.info(row['type'])
|
||||||
tableTypeSelect.value = true
|
tableTypeSelect.value = true
|
||||||
dataTableObject.params = {
|
queryParams.dictType = row['type']
|
||||||
dictType: data.type
|
await dataGetList(xDataGrid)
|
||||||
}
|
parentType.value = row['type']
|
||||||
getDataList()
|
|
||||||
parentType.value = data.type
|
|
||||||
}
|
}
|
||||||
// 弹出框
|
// 弹出框
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
@ -246,6 +208,16 @@ const setDialogTile = (type: string) => {
|
|||||||
actionType.value = type
|
actionType.value = type
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleTypeDelete = async (rowId: number) => {
|
||||||
|
await typeDeleteData(xTypeGrid, rowId)
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleDataDelete = async (rowId: number) => {
|
||||||
|
await dataDeleteData(xDataGrid, rowId)
|
||||||
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
const submitTypeForm = async () => {
|
const submitTypeForm = async () => {
|
||||||
const elForm = unref(typeFormRef)?.getElFormRef()
|
const elForm = unref(typeFormRef)?.getElFormRef()
|
||||||
@ -259,16 +231,15 @@ const submitTypeForm = async () => {
|
|||||||
if (actionType.value === 'typeCreate') {
|
if (actionType.value === 'typeCreate') {
|
||||||
data.type = dictTypeValue.value
|
data.type = dictTypeValue.value
|
||||||
await DictTypeApi.createDictTypeApi(data)
|
await DictTypeApi.createDictTypeApi(data)
|
||||||
ElMessage.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else if (actionType.value === 'typeUpdate') {
|
} else if (actionType.value === 'typeUpdate') {
|
||||||
await DictTypeApi.updateDictTypeApi(data)
|
await DictTypeApi.updateDictTypeApi(data)
|
||||||
ElMessage.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
// 操作成功,重新加载列表
|
|
||||||
await getTypeList()
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
|
typeGetList(xTypeGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -285,23 +256,17 @@ const submitDataForm = async () => {
|
|||||||
if (actionType.value === 'dataCreate') {
|
if (actionType.value === 'dataCreate') {
|
||||||
data.dictType = parentType.value
|
data.dictType = parentType.value
|
||||||
await DictDataApi.createDictDataApi(data)
|
await DictDataApi.createDictDataApi(data)
|
||||||
ElMessage.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else if (actionType.value === 'dataUpdate') {
|
} else if (actionType.value === 'dataUpdate') {
|
||||||
await DictDataApi.updateDictDataApi(data)
|
await DictDataApi.updateDictDataApi(data)
|
||||||
ElMessage.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
await getDataList()
|
|
||||||
// 操作成功,重新加载列表
|
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
|
dataGetList(xDataGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
// 初始化查询
|
|
||||||
onMounted(async () => {
|
|
||||||
await getTypeList()
|
|
||||||
typeTableObject.tableList[0] && onClickType(typeTableObject.tableList[0])
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user