9 changed files with 560 additions and 2 deletions
			
			
		@ -0,0 +1,98 @@ | 
				
			|||||||
 | 
					<template> | 
				
			||||||
 | 
					  <div> | 
				
			||||||
 | 
					    <BasicTable @register="registerTable"> | 
				
			||||||
 | 
					      <template #toolbar> | 
				
			||||||
 | 
					        <a-button type="primary" @click="handleCreate">新增字典数据</a-button> | 
				
			||||||
 | 
					      </template> | 
				
			||||||
 | 
					      <template #bodyCell="{ column, record }"> | 
				
			||||||
 | 
					        <template v-if="column.key === 'action'"> | 
				
			||||||
 | 
					          <TableAction | 
				
			||||||
 | 
					            :actions="[ | 
				
			||||||
 | 
					              { | 
				
			||||||
 | 
					                icon: 'clarity:note-edit-line', | 
				
			||||||
 | 
					                tooltip: '编辑字典数据', | 
				
			||||||
 | 
					                onClick: handleEdit.bind(null, record) | 
				
			||||||
 | 
					              }, | 
				
			||||||
 | 
					              { | 
				
			||||||
 | 
					                icon: 'ant-design:delete-outlined', | 
				
			||||||
 | 
					                color: 'error', | 
				
			||||||
 | 
					                tooltip: '删除字典数据', | 
				
			||||||
 | 
					                popConfirm: { | 
				
			||||||
 | 
					                  title: '是否确认删除', | 
				
			||||||
 | 
					                  placement: 'left', | 
				
			||||||
 | 
					                  confirm: handleDelete.bind(null, record) | 
				
			||||||
 | 
					                } | 
				
			||||||
 | 
					              } | 
				
			||||||
 | 
					            ]" | 
				
			||||||
 | 
					          /> | 
				
			||||||
 | 
					        </template> | 
				
			||||||
 | 
					      </template> | 
				
			||||||
 | 
					    </BasicTable> | 
				
			||||||
 | 
					    <DictDataModel @register="registerModal" @success="reload()" /> | 
				
			||||||
 | 
					  </div> | 
				
			||||||
 | 
					</template> | 
				
			||||||
 | 
					<script lang="ts" setup name="DictData"> | 
				
			||||||
 | 
					// import { reactive } from 'vue' | 
				
			||||||
 | 
					import { BasicTable, useTable, TableAction } from '@/components/Table' | 
				
			||||||
 | 
					import { useModal } from '@/components/Modal' | 
				
			||||||
 | 
					import DictDataModel from './DictDataModel.vue' | 
				
			||||||
 | 
					import { dataColumns, dataSearchFormSchema } from './dict.data' | 
				
			||||||
 | 
					import { getDictDataPageApi } from '@/api/system/dict/data' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerModal, { openModal }] = useModal() | 
				
			||||||
 | 
					// const searchInfo = reactive<Recordable>({}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerTable, { reload }] = useTable({ | 
				
			||||||
 | 
					  title: '字典数据列表', | 
				
			||||||
 | 
					  api: getDictDataPageApi, | 
				
			||||||
 | 
					  columns: dataColumns, | 
				
			||||||
 | 
					  formConfig: { | 
				
			||||||
 | 
					    labelWidth: 120, | 
				
			||||||
 | 
					    schemas: dataSearchFormSchema, | 
				
			||||||
 | 
					    autoSubmitOnEnter: true | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  useSearchForm: true, | 
				
			||||||
 | 
					  showTableSetting: true, | 
				
			||||||
 | 
					  showIndexColumn: false, | 
				
			||||||
 | 
					  actionColumn: { | 
				
			||||||
 | 
					    width: 120, | 
				
			||||||
 | 
					    title: '操作', | 
				
			||||||
 | 
					    dataIndex: 'action', | 
				
			||||||
 | 
					    fixed: 'right' | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleCreate() { | 
				
			||||||
 | 
					  openModal(true, { | 
				
			||||||
 | 
					    isUpdate: false | 
				
			||||||
 | 
					  }) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleEdit(record: Recordable) { | 
				
			||||||
 | 
					  console.log(record) | 
				
			||||||
 | 
					  openModal(true, { | 
				
			||||||
 | 
					    record, | 
				
			||||||
 | 
					    isUpdate: true | 
				
			||||||
 | 
					  }) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleDelete(record: Recordable) { | 
				
			||||||
 | 
					  console.log(record) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// function handleSuccess({ isUpdate, values }) { | 
				
			||||||
 | 
					//   if (isUpdate) { | 
				
			||||||
 | 
					//     // 演示不刷新表格直接更新内部数据。 | 
				
			||||||
 | 
					//     // 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中 | 
				
			||||||
 | 
					//     const result = updateTableDataRecord(values.id, values) | 
				
			||||||
 | 
					//     console.log(result) | 
				
			||||||
 | 
					//   } else { | 
				
			||||||
 | 
					//     reload() | 
				
			||||||
 | 
					//   } | 
				
			||||||
 | 
					// } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// function handleSelect(deptId = '') { | 
				
			||||||
 | 
					//   searchInfo.deptId = deptId | 
				
			||||||
 | 
					//   reload() | 
				
			||||||
 | 
					// } | 
				
			||||||
 | 
					</script> | 
				
			||||||
@ -0,0 +1,58 @@ | 
				
			|||||||
 | 
					<template> | 
				
			||||||
 | 
					  <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> | 
				
			||||||
 | 
					    <BasicForm @register="registerForm" /> | 
				
			||||||
 | 
					  </BasicModal> | 
				
			||||||
 | 
					</template> | 
				
			||||||
 | 
					<script lang="ts" setup name="PostModal"> | 
				
			||||||
 | 
					import { ref, computed, unref } from 'vue' | 
				
			||||||
 | 
					import { BasicModal, useModalInner } from '@/components/Modal' | 
				
			||||||
 | 
					import { BasicForm, useForm } from '@/components/Form' | 
				
			||||||
 | 
					import { dataFormSchema } from './dict.data' | 
				
			||||||
 | 
					import { createDictDataApi, getDictDataApi, updateDictDataApi } from '@/api/system/dict/data' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const emit = defineEmits(['success', 'register']) | 
				
			||||||
 | 
					const isUpdate = ref(true) | 
				
			||||||
 | 
					const rowId = ref() | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ | 
				
			||||||
 | 
					  labelWidth: 100, | 
				
			||||||
 | 
					  baseColProps: { span: 24 }, | 
				
			||||||
 | 
					  schemas: dataFormSchema, | 
				
			||||||
 | 
					  showActionButtonGroup: false, | 
				
			||||||
 | 
					  actionColOptions: { | 
				
			||||||
 | 
					    span: 23 | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | 
				
			||||||
 | 
					  resetFields() | 
				
			||||||
 | 
					  setModalProps({ confirmLoading: false }) | 
				
			||||||
 | 
					  isUpdate.value = !!data?.isUpdate | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (unref(isUpdate)) { | 
				
			||||||
 | 
					    const res = await getDictDataApi(data.record.id) | 
				
			||||||
 | 
					    rowId.value = res.id | 
				
			||||||
 | 
					    setFieldsValue({ | 
				
			||||||
 | 
					      ...res | 
				
			||||||
 | 
					    }) | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getTitle = computed(() => (!unref(isUpdate) ? '新增字典分类' : '编辑字典分类')) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function handleSubmit() { | 
				
			||||||
 | 
					  try { | 
				
			||||||
 | 
					    const values = await validate() | 
				
			||||||
 | 
					    setModalProps({ confirmLoading: true }) | 
				
			||||||
 | 
					    if (unref(isUpdate)) { | 
				
			||||||
 | 
					      await updateDictDataApi(values) | 
				
			||||||
 | 
					    } else { | 
				
			||||||
 | 
					      await createDictDataApi(values) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					    closeModal() | 
				
			||||||
 | 
					    emit('success') | 
				
			||||||
 | 
					  } finally { | 
				
			||||||
 | 
					    setModalProps({ confirmLoading: false }) | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					</script> | 
				
			||||||
@ -0,0 +1,58 @@ | 
				
			|||||||
 | 
					<template> | 
				
			||||||
 | 
					  <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> | 
				
			||||||
 | 
					    <BasicForm @register="registerForm" /> | 
				
			||||||
 | 
					  </BasicModal> | 
				
			||||||
 | 
					</template> | 
				
			||||||
 | 
					<script lang="ts" setup name="PostModal"> | 
				
			||||||
 | 
					import { ref, computed, unref } from 'vue' | 
				
			||||||
 | 
					import { BasicModal, useModalInner } from '@/components/Modal' | 
				
			||||||
 | 
					import { BasicForm, useForm } from '@/components/Form' | 
				
			||||||
 | 
					import { typeFormSchema } from './dict.type' | 
				
			||||||
 | 
					import { createDictTypeApi, getDictTypeApi, updateDictTypeApi } from '@/api/system/dict/type' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const emit = defineEmits(['success', 'register']) | 
				
			||||||
 | 
					const isUpdate = ref(true) | 
				
			||||||
 | 
					const rowId = ref() | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({ | 
				
			||||||
 | 
					  labelWidth: 100, | 
				
			||||||
 | 
					  baseColProps: { span: 24 }, | 
				
			||||||
 | 
					  schemas: typeFormSchema, | 
				
			||||||
 | 
					  showActionButtonGroup: false, | 
				
			||||||
 | 
					  actionColOptions: { | 
				
			||||||
 | 
					    span: 23 | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | 
				
			||||||
 | 
					  resetFields() | 
				
			||||||
 | 
					  setModalProps({ confirmLoading: false }) | 
				
			||||||
 | 
					  isUpdate.value = !!data?.isUpdate | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (unref(isUpdate)) { | 
				
			||||||
 | 
					    const res = await getDictTypeApi(data.record.id) | 
				
			||||||
 | 
					    rowId.value = res.id | 
				
			||||||
 | 
					    setFieldsValue({ | 
				
			||||||
 | 
					      ...res | 
				
			||||||
 | 
					    }) | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const getTitle = computed(() => (!unref(isUpdate) ? '新增字典分类' : '编辑字典分类')) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					async function handleSubmit() { | 
				
			||||||
 | 
					  try { | 
				
			||||||
 | 
					    const values = await validate() | 
				
			||||||
 | 
					    setModalProps({ confirmLoading: true }) | 
				
			||||||
 | 
					    if (unref(isUpdate)) { | 
				
			||||||
 | 
					      await updateDictTypeApi(values) | 
				
			||||||
 | 
					    } else { | 
				
			||||||
 | 
					      await createDictTypeApi(values) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					    closeModal() | 
				
			||||||
 | 
					    emit('success') | 
				
			||||||
 | 
					  } finally { | 
				
			||||||
 | 
					    setModalProps({ confirmLoading: false }) | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					</script> | 
				
			||||||
@ -0,0 +1,159 @@ | 
				
			|||||||
 | 
					import { BasicColumn, FormSchema, useRender } from '@/components/Table' | 
				
			||||||
 | 
					import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const dataColumns: BasicColumn[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典编码', | 
				
			||||||
 | 
					    dataIndex: 'id', | 
				
			||||||
 | 
					    width: 100 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典标签', | 
				
			||||||
 | 
					    dataIndex: 'label', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典键值', | 
				
			||||||
 | 
					    dataIndex: 'value', | 
				
			||||||
 | 
					    width: 100 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典排序', | 
				
			||||||
 | 
					    dataIndex: 'sort', | 
				
			||||||
 | 
					    width: 120 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '状态', | 
				
			||||||
 | 
					    dataIndex: 'status', | 
				
			||||||
 | 
					    width: 180, | 
				
			||||||
 | 
					    customRender: ({ text }) => { | 
				
			||||||
 | 
					      return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '颜色类型', | 
				
			||||||
 | 
					    dataIndex: 'colorType', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: 'CSS Class', | 
				
			||||||
 | 
					    dataIndex: 'cssClass', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '备注', | 
				
			||||||
 | 
					    dataIndex: 'remark', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '创建时间', | 
				
			||||||
 | 
					    dataIndex: 'createTime', | 
				
			||||||
 | 
					    width: 180, | 
				
			||||||
 | 
					    customRender: ({ text }) => { | 
				
			||||||
 | 
					      return useRender.renderDate(text) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const dataSearchFormSchema: FormSchema[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '字典标签', | 
				
			||||||
 | 
					    field: 'label', | 
				
			||||||
 | 
					    component: 'Input', | 
				
			||||||
 | 
					    colProps: { span: 8 } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '状态', | 
				
			||||||
 | 
					    field: 'status', | 
				
			||||||
 | 
					    component: 'Select', | 
				
			||||||
 | 
					    componentProps: { | 
				
			||||||
 | 
					      options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    }, | 
				
			||||||
 | 
					    colProps: { span: 8 } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const dataFormSchema: FormSchema[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '编号', | 
				
			||||||
 | 
					    field: 'id', | 
				
			||||||
 | 
					    show: false, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '字典类型', | 
				
			||||||
 | 
					    field: 'dictType', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '数据标签', | 
				
			||||||
 | 
					    field: 'label', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '数据键值', | 
				
			||||||
 | 
					    field: 'value', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '显示排序', | 
				
			||||||
 | 
					    field: 'sort', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'InputNumber' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '状态', | 
				
			||||||
 | 
					    field: 'status', | 
				
			||||||
 | 
					    component: 'Select', | 
				
			||||||
 | 
					    defaultValue: 0, | 
				
			||||||
 | 
					    componentProps: { | 
				
			||||||
 | 
					      options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '颜色类型', | 
				
			||||||
 | 
					    field: 'colorType', | 
				
			||||||
 | 
					    component: 'Select', | 
				
			||||||
 | 
					    componentProps: { | 
				
			||||||
 | 
					      options: [ | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'default', | 
				
			||||||
 | 
					          label: '默认' | 
				
			||||||
 | 
					        }, | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'primary', | 
				
			||||||
 | 
					          label: '主要' | 
				
			||||||
 | 
					        }, | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'success', | 
				
			||||||
 | 
					          label: '成功' | 
				
			||||||
 | 
					        }, | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'info', | 
				
			||||||
 | 
					          label: '信息' | 
				
			||||||
 | 
					        }, | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'warning', | 
				
			||||||
 | 
					          label: '警告' | 
				
			||||||
 | 
					        }, | 
				
			||||||
 | 
					        { | 
				
			||||||
 | 
					          value: 'danger', | 
				
			||||||
 | 
					          label: '危险' | 
				
			||||||
 | 
					        } | 
				
			||||||
 | 
					      ] | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: 'CSS Class', | 
				
			||||||
 | 
					    field: 'cssClass', | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '备注', | 
				
			||||||
 | 
					    field: 'remark', | 
				
			||||||
 | 
					    component: 'InputTextArea' | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
@ -0,0 +1,89 @@ | 
				
			|||||||
 | 
					import { BasicColumn, FormSchema, useRender } from '@/components/Table' | 
				
			||||||
 | 
					import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const typeColumns: BasicColumn[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典编号', | 
				
			||||||
 | 
					    dataIndex: 'id', | 
				
			||||||
 | 
					    width: 100 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '字典名称', | 
				
			||||||
 | 
					    dataIndex: 'name', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '状态', | 
				
			||||||
 | 
					    dataIndex: 'status', | 
				
			||||||
 | 
					    width: 180, | 
				
			||||||
 | 
					    customRender: ({ text }) => { | 
				
			||||||
 | 
					      return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '备注', | 
				
			||||||
 | 
					    dataIndex: 'remark', | 
				
			||||||
 | 
					    width: 180 | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    title: '创建时间', | 
				
			||||||
 | 
					    dataIndex: 'createTime', | 
				
			||||||
 | 
					    width: 180, | 
				
			||||||
 | 
					    customRender: ({ text }) => { | 
				
			||||||
 | 
					      return useRender.renderDate(text) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const typeSearchFormSchema: FormSchema[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '字典名称', | 
				
			||||||
 | 
					    field: 'name', | 
				
			||||||
 | 
					    component: 'Input', | 
				
			||||||
 | 
					    colProps: { span: 8 } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '状态', | 
				
			||||||
 | 
					    field: 'status', | 
				
			||||||
 | 
					    component: 'Select', | 
				
			||||||
 | 
					    componentProps: { | 
				
			||||||
 | 
					      options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    }, | 
				
			||||||
 | 
					    colProps: { span: 8 } | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export const typeFormSchema: FormSchema[] = [ | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '编号', | 
				
			||||||
 | 
					    field: 'id', | 
				
			||||||
 | 
					    show: false, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '字典名称', | 
				
			||||||
 | 
					    field: 'name', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '字典类型', | 
				
			||||||
 | 
					    field: 'type', | 
				
			||||||
 | 
					    required: true, | 
				
			||||||
 | 
					    component: 'Input' | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '状态', | 
				
			||||||
 | 
					    field: 'status', | 
				
			||||||
 | 
					    component: 'Select', | 
				
			||||||
 | 
					    defaultValue: 0, | 
				
			||||||
 | 
					    componentProps: { | 
				
			||||||
 | 
					      options: getIntDictOptions(DICT_TYPE.COMMON_STATUS) | 
				
			||||||
 | 
					    } | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  { | 
				
			||||||
 | 
					    label: '备注', | 
				
			||||||
 | 
					    field: 'remark', | 
				
			||||||
 | 
					    component: 'InputTextArea' | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					] | 
				
			||||||
@ -1,3 +1,99 @@ | 
				
			|||||||
<template> | 
					<template> | 
				
			||||||
  <div>开发中</div> | 
					  <div class="flex"> | 
				
			||||||
 | 
					    <BasicTable @register="registerTable" class="w-1/2 xl:w-1/2"> | 
				
			||||||
 | 
					      <template #toolbar> | 
				
			||||||
 | 
					        <a-button type="primary" @click="handleCreate">新增字典类型</a-button> | 
				
			||||||
      </template> | 
					      </template> | 
				
			||||||
 | 
					      <template #bodyCell="{ column, record }"> | 
				
			||||||
 | 
					        <template v-if="column.key === 'action'"> | 
				
			||||||
 | 
					          <TableAction | 
				
			||||||
 | 
					            :actions="[ | 
				
			||||||
 | 
					              { | 
				
			||||||
 | 
					                icon: 'clarity:note-edit-line', | 
				
			||||||
 | 
					                tooltip: '编辑字典分类', | 
				
			||||||
 | 
					                onClick: handleEdit.bind(null, record) | 
				
			||||||
 | 
					              }, | 
				
			||||||
 | 
					              { | 
				
			||||||
 | 
					                icon: 'ant-design:delete-outlined', | 
				
			||||||
 | 
					                color: 'error', | 
				
			||||||
 | 
					                tooltip: '删除字典分类', | 
				
			||||||
 | 
					                popConfirm: { | 
				
			||||||
 | 
					                  title: '是否确认删除', | 
				
			||||||
 | 
					                  placement: 'left', | 
				
			||||||
 | 
					                  confirm: handleDelete.bind(null, record) | 
				
			||||||
 | 
					                } | 
				
			||||||
 | 
					              } | 
				
			||||||
 | 
					            ]" | 
				
			||||||
 | 
					          /> | 
				
			||||||
 | 
					        </template> | 
				
			||||||
 | 
					      </template> | 
				
			||||||
 | 
					    </BasicTable> | 
				
			||||||
 | 
					    <DictData class="w-1/2 xl:w-1/2" /> | 
				
			||||||
 | 
					    <DictTypeModel @register="registerModal" @success="reload()" /> | 
				
			||||||
 | 
					  </div> | 
				
			||||||
 | 
					</template> | 
				
			||||||
 | 
					<script lang="ts" setup name="Dict"> | 
				
			||||||
 | 
					// import { reactive } from 'vue' | 
				
			||||||
 | 
					import { BasicTable, useTable, TableAction } from '@/components/Table' | 
				
			||||||
 | 
					import { useModal } from '@/components/Modal' | 
				
			||||||
 | 
					import DictData from './DictData.vue' | 
				
			||||||
 | 
					import DictTypeModel from './DictTypeModel.vue' | 
				
			||||||
 | 
					import { typeColumns, typeSearchFormSchema } from './dict.type' | 
				
			||||||
 | 
					import { getDictTypePageApi } from '@/api/system/dict/type' | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerModal, { openModal }] = useModal() | 
				
			||||||
 | 
					// const searchInfo = reactive<Recordable>({}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const [registerTable, { reload }] = useTable({ | 
				
			||||||
 | 
					  title: '字典分类列表', | 
				
			||||||
 | 
					  api: getDictTypePageApi, | 
				
			||||||
 | 
					  columns: typeColumns, | 
				
			||||||
 | 
					  formConfig: { | 
				
			||||||
 | 
					    labelWidth: 120, | 
				
			||||||
 | 
					    schemas: typeSearchFormSchema | 
				
			||||||
 | 
					  }, | 
				
			||||||
 | 
					  useSearchForm: true, | 
				
			||||||
 | 
					  showTableSetting: true, | 
				
			||||||
 | 
					  showIndexColumn: false, | 
				
			||||||
 | 
					  actionColumn: { | 
				
			||||||
 | 
					    width: 120, | 
				
			||||||
 | 
					    title: '操作', | 
				
			||||||
 | 
					    dataIndex: 'action', | 
				
			||||||
 | 
					    fixed: 'right' | 
				
			||||||
 | 
					  } | 
				
			||||||
 | 
					}) | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleCreate() { | 
				
			||||||
 | 
					  openModal(true, { | 
				
			||||||
 | 
					    isUpdate: false | 
				
			||||||
 | 
					  }) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleEdit(record: Recordable) { | 
				
			||||||
 | 
					  console.log(record) | 
				
			||||||
 | 
					  openModal(true, { | 
				
			||||||
 | 
					    record, | 
				
			||||||
 | 
					    isUpdate: true | 
				
			||||||
 | 
					  }) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function handleDelete(record: Recordable) { | 
				
			||||||
 | 
					  console.log(record) | 
				
			||||||
 | 
					} | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// function handleSuccess({ isUpdate, values }) { | 
				
			||||||
 | 
					//   if (isUpdate) { | 
				
			||||||
 | 
					//     // 演示不刷新表格直接更新内部数据。 | 
				
			||||||
 | 
					//     // 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中 | 
				
			||||||
 | 
					//     const result = updateTableDataRecord(values.id, values) | 
				
			||||||
 | 
					//     console.log(result) | 
				
			||||||
 | 
					//   } else { | 
				
			||||||
 | 
					//     reload() | 
				
			||||||
 | 
					//   } | 
				
			||||||
 | 
					// } | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// function handleSelect(deptId = '') { | 
				
			||||||
 | 
					//   searchInfo.deptId = deptId | 
				
			||||||
 | 
					//   reload() | 
				
			||||||
 | 
					// } | 
				
			||||||
 | 
					</script> | 
				
			||||||
 | 
				
			|||||||
		Reference in new issue