refactor: API类型声明优化调整
Former-commit-id: 0ae696c2e872fa90feba0c5df9a92391c02d3e0b
This commit is contained in:
@@ -1,46 +1,41 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'dictItem'
|
||||
name: 'dictItem',
|
||||
};
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref, toRefs, watch } from 'vue';
|
||||
import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
||||
import {
|
||||
DictItem,
|
||||
DictItemFormData,
|
||||
DictItemQueryParam
|
||||
} from '@/types/api/dict';
|
||||
|
||||
import { Dialog } from '@/types/common';
|
||||
import {
|
||||
listDictItemPages,
|
||||
getDictItemData,
|
||||
saveDictItem,
|
||||
updateDictItem,
|
||||
deleteDictItems
|
||||
deleteDictItems,
|
||||
} from '@/api/dict';
|
||||
import { Search, Plus, Edit, Refresh, Delete } from '@element-plus/icons-vue';
|
||||
import { DictItem, DictItemForm, DictItemQuery } from '@/api/dict/types';
|
||||
|
||||
const props = defineProps({
|
||||
typeCode: {
|
||||
type: String,
|
||||
default: () => {
|
||||
return '';
|
||||
}
|
||||
},
|
||||
},
|
||||
typeName: {
|
||||
type: String,
|
||||
default: () => {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.typeCode,
|
||||
value => {
|
||||
(value) => {
|
||||
state.queryParams.typeCode = value;
|
||||
state.formData.typeCode = value;
|
||||
handleQuery();
|
||||
@@ -59,21 +54,21 @@ const state = reactive({
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
total: 0,
|
||||
queryParams: { pageNum: 1, pageSize: 10 } as DictItemQueryParam,
|
||||
queryParams: { pageNum: 1, pageSize: 10 } as DictItemQuery,
|
||||
dictItemList: [] as DictItem[],
|
||||
dialog: { visible: false } as Dialog,
|
||||
dialog: { visible: false } as DialogType,
|
||||
formData: {
|
||||
typeCode: props.typeCode,
|
||||
typeName: props.typeName,
|
||||
status: 1,
|
||||
sort: 1
|
||||
} as DictItemFormData,
|
||||
sort: 1,
|
||||
} as DictItemForm,
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入字典项名称', trigger: 'blur' }],
|
||||
value: [{ required: true, message: '请输入字典项值', trigger: 'blur' }]
|
||||
value: [{ required: true, message: '请输入字典项值', trigger: 'blur' }],
|
||||
},
|
||||
localDictCode: props.typeCode,
|
||||
localDictName: props.typeName
|
||||
localDictName: props.typeName,
|
||||
});
|
||||
|
||||
const {
|
||||
@@ -84,7 +79,7 @@ const {
|
||||
dialog,
|
||||
formData,
|
||||
rules,
|
||||
total
|
||||
total,
|
||||
} = toRefs(state);
|
||||
|
||||
function handleQuery() {
|
||||
@@ -121,14 +116,14 @@ function handleAdd() {
|
||||
}
|
||||
state.dialog = {
|
||||
title: '添加字典数据项',
|
||||
visible: true
|
||||
visible: true,
|
||||
};
|
||||
}
|
||||
|
||||
function handleUpdate(row: any) {
|
||||
state.dialog = {
|
||||
title: '修改字典数据项',
|
||||
visible: true
|
||||
visible: true,
|
||||
};
|
||||
const id = row.id || state.ids;
|
||||
getDictItemData(id).then(({ data }) => {
|
||||
@@ -167,7 +162,7 @@ function handleDelete(row: any) {
|
||||
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
deleteDictItems(ids).then(() => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'dictType'
|
||||
name: 'dictType',
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -135,13 +135,11 @@ import {
|
||||
getDictTypeForm,
|
||||
addDictType,
|
||||
updateDictType,
|
||||
deleteDictTypes
|
||||
deleteDictTypes,
|
||||
} from '@/api/dict';
|
||||
import { Search, Plus, Edit, Refresh, Delete } from '@element-plus/icons-vue';
|
||||
import { ElForm, ElMessage, ElMessageBox } from 'element-plus';
|
||||
|
||||
import { Dialog } from '@/types/common';
|
||||
import { Dict, DictTypeFormData, DictQueryParam } from '@/types/api/dict';
|
||||
import { Dict, DictQuery, DictTypeForm } from '@/api/dict/types';
|
||||
|
||||
const queryFormRef = ref(ElForm);
|
||||
const dataFormRef = ref(ElForm);
|
||||
@@ -158,18 +156,18 @@ const state = reactive({
|
||||
multiple: true,
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
} as DictQueryParam,
|
||||
pageSize: 10,
|
||||
} as DictQuery,
|
||||
dictList: [] as Dict[],
|
||||
total: 0,
|
||||
dialog: { visible: false } as Dialog,
|
||||
dialog: { visible: false } as DialogType,
|
||||
formData: {
|
||||
status: 1
|
||||
} as DictTypeFormData,
|
||||
status: 1,
|
||||
} as DictTypeForm,
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入字典名称', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入字典编码', trigger: 'blur' }]
|
||||
}
|
||||
code: [{ required: true, message: '请输入字典编码', trigger: 'blur' }],
|
||||
},
|
||||
});
|
||||
|
||||
const { total, dialog, loading, dictList, formData, rules, queryParams } =
|
||||
@@ -199,14 +197,14 @@ function handleSelectionChange(selection: any) {
|
||||
function handleAdd() {
|
||||
state.dialog = {
|
||||
title: '添加字典',
|
||||
visible: true
|
||||
visible: true,
|
||||
};
|
||||
}
|
||||
|
||||
function handleUpdate(row: any) {
|
||||
state.dialog = {
|
||||
title: '修改字典',
|
||||
visible: true
|
||||
visible: true,
|
||||
};
|
||||
const id = row.id || state.ids;
|
||||
getDictTypeForm(id).then(({ data }) => {
|
||||
@@ -245,7 +243,7 @@ function handleDelete(row: any) {
|
||||
ElMessageBox.confirm('确认删除已选中的数据项?', '警告', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
type: 'warning',
|
||||
})
|
||||
.then(() => {
|
||||
deleteDictTypes(ids).then(() => {
|
||||
|
||||
Reference in New Issue
Block a user