feat: dict view done

pull/1/MERGE
xingyuv 2023-03-21 18:20:13 +08:00
parent 4a3d8adcce
commit 9c60aa3640
4 changed files with 60 additions and 45 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<BasicTable @register="registerTable"> <BasicTable @register="registerTable" :searchInfo="searchInfo">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreate"></a-button> <a-button type="primary" @click="handleCreate"></a-button>
</template> </template>
@ -32,13 +32,22 @@
</div> </div>
</template> </template>
<script lang="ts" setup name="DictData"> <script lang="ts" setup name="DictData">
// import { reactive } from 'vue' import { watch } from 'vue'
import { BasicTable, useTable, TableAction } from '@/components/Table' import { BasicTable, useTable, TableAction } from '@/components/Table'
import { useModal } from '@/components/Modal' import { useModal } from '@/components/Modal'
import DictDataModel from './DictDataModel.vue' import DictDataModel from './DictDataModel.vue'
import { dataColumns, dataSearchFormSchema } from './dict.data' import { dataColumns, dataSearchFormSchema } from './dict.data'
import { getDictDataPageApi } from '@/api/system/dict/data' import { deleteDictDataApi, getDictDataPageApi } from '@/api/system/dict/data'
import { useMessage } from '@/hooks/web/useMessage'
const props = defineProps({
searchInfo: {
type: Object as PropType<Recordable>,
default: () => ({})
}
})
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
// const searchInfo = reactive<Recordable>({}) // const searchInfo = reactive<Recordable>({})
@ -64,12 +73,12 @@ const [registerTable, { reload }] = useTable({
function handleCreate() { function handleCreate() {
openModal(true, { openModal(true, {
record: props.searchInfo.dictType,
isUpdate: false isUpdate: false
}) })
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
console.log(record)
openModal(true, { openModal(true, {
record, record,
isUpdate: true isUpdate: true
@ -77,22 +86,24 @@ function handleEdit(record: Recordable) {
} }
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
console.log(record) createConfirm({
title: '删除',
iconType: 'warning',
content: '是否要删除数据?',
async onOk() {
await deleteDictDataApi(record.id)
createMessage.success('删除成功')
reload()
}
})
} }
// function handleSuccess({ isUpdate, values }) { watch(
// if (isUpdate) { () => props.searchInfo,
// // (val) => {
// // updateTableDataRecordrowKeystringrecordkeys console.info(val)
// const result = updateTableDataRecord(values.id, values) val && reload()
// console.log(result) },
// } else { { deep: true }
// reload() )
// }
// }
// function handleSelect(deptId = '') {
// searchInfo.deptId = deptId
// reload()
// }
</script> </script>

View File

@ -35,6 +35,10 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
setFieldsValue({ setFieldsValue({
...res ...res
}) })
} else {
setFieldsValue({
dictType: data.record
})
} }
}) })

View File

@ -84,7 +84,8 @@ export const dataFormSchema: FormSchema[] = [
label: '字典类型', label: '字典类型',
field: 'dictType', field: 'dictType',
required: true, required: true,
component: 'Input' component: 'Input',
dynamicDisabled: ({ values }) => !!values.dictType
}, },
{ {
label: '数据标签', label: '数据标签',

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="flex"> <div class="flex">
<BasicTable @register="registerTable" class="w-1/2 xl:w-1/2"> <BasicTable @register="registerTable" class="w-1/2 xl:w-1/2" @row-click="handleRowClick">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreate"></a-button> <a-button type="primary" @click="handleCreate"></a-button>
</template> </template>
@ -28,21 +28,23 @@
</template> </template>
</template> </template>
</BasicTable> </BasicTable>
<DictData class="w-1/2 xl:w-1/2" /> <DictData class="w-1/2 xl:w-1/2" :searchInfo="searchInfo" />
<DictTypeModel @register="registerModal" @success="reload()" /> <DictTypeModel @register="registerModal" @success="reload()" />
</div> </div>
</template> </template>
<script lang="ts" setup name="Dict"> <script lang="ts" setup name="Dict">
// import { reactive } from 'vue' import { reactive } from 'vue'
import { BasicTable, useTable, TableAction } from '@/components/Table' import { BasicTable, useTable, TableAction } from '@/components/Table'
import { useModal } from '@/components/Modal' import { useModal } from '@/components/Modal'
import DictData from './DictData.vue' import DictData from './DictData.vue'
import DictTypeModel from './DictTypeModel.vue' import DictTypeModel from './DictTypeModel.vue'
import { typeColumns, typeSearchFormSchema } from './dict.type' import { typeColumns, typeSearchFormSchema } from './dict.type'
import { getDictTypePageApi } from '@/api/system/dict/type' import { deleteDictTypeApi, getDictTypePageApi } from '@/api/system/dict/type'
import { useMessage } from '@/hooks/web/useMessage'
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal() const [registerModal, { openModal }] = useModal()
// const searchInfo = reactive<Recordable>({}) const searchInfo = reactive<Recordable>({})
const [registerTable, { reload }] = useTable({ const [registerTable, { reload }] = useTable({
title: '字典分类列表', title: '字典分类列表',
@ -63,6 +65,11 @@ const [registerTable, { reload }] = useTable({
} }
}) })
function handleRowClick(record) {
console.info(record.type)
searchInfo.dictType = record.type
}
function handleCreate() { function handleCreate() {
openModal(true, { openModal(true, {
isUpdate: false isUpdate: false
@ -70,30 +77,22 @@ function handleCreate() {
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
console.log(record)
openModal(true, { openModal(true, {
record, record,
isUpdate: true isUpdate: true
}) })
} }
function handleDelete(record: Recordable) { async function handleDelete(record: Recordable) {
console.log(record) createConfirm({
title: '删除',
iconType: 'warning',
content: '是否要删除数据?',
async onOk() {
await deleteDictTypeApi(record.id)
createMessage.success('删除成功')
reload()
}
})
} }
// function handleSuccess({ isUpdate, values }) {
// if (isUpdate) {
// //
// // updateTableDataRecordrowKeystringrecordkeys
// const result = updateTableDataRecord(values.id, values)
// console.log(result)
// } else {
// reload()
// }
// }
// function handleSelect(deptId = '') {
// searchInfo.deptId = deptId
// reload()
// }
</script> </script>