feat: 字典增加显示父级字典value
This commit is contained in:
parent
b727b0d998
commit
103b376945
@ -2,16 +2,17 @@
|
||||
<main class="dict-main">
|
||||
<!-- 上面有一排操作按钮:input框查询 查询按钮,新增 -->
|
||||
<!-- 字典表格,含有字段:字典id,字典名称,字典值,字典标签,操作列(编辑 删除) -->
|
||||
<div v-if="tableTitle === ''" class="dict-main__empty">
|
||||
<div v-if="parentProps.value === ''" class="dict-main__empty">
|
||||
<LsEmpty type="no-data" v-model:title="emptyStateTitle" v-model:description="emptyStateDescription" />
|
||||
</div>
|
||||
<div v-if="tableTitle !== ''" class="dict-main__content">
|
||||
<div v-if="parentProps.value !== ''" class="dict-main__content">
|
||||
<div class="dict-main__header">
|
||||
<h1>{{ tableTitle }}</h1>
|
||||
<h1>{{ parentProps.label }}</h1>
|
||||
<h3>{{ parentProps.value }}</h3>
|
||||
</div>
|
||||
<div class="dict-main__search">
|
||||
<n-input autosize v-model:value="mainSearch" placeholder="查询字典名称(中/英)或字典值" clearable
|
||||
@keyup.enter="handleFindDatas" @input="handleInputSearch" class="dict-main__search-input" >
|
||||
@keyup.enter="handleFindDatas" class="dict-main__search-input">
|
||||
</n-input>
|
||||
<n-button type="primary" @click="handleFindDatas" :focusable="false" class="dict-main__search-btn">
|
||||
<template #icon>
|
||||
@ -82,7 +83,6 @@ watch(parentProps, async (newValue) => {
|
||||
console.log(newValue);
|
||||
|
||||
loading.value = true;
|
||||
tableTitle.value = newValue.label;
|
||||
if (!height.value) {
|
||||
nextTick(() => {
|
||||
if (tableMainRef.value) {
|
||||
@ -90,14 +90,9 @@ watch(parentProps, async (newValue) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (tableTitle.value !== '') {
|
||||
try {
|
||||
await getDatas();
|
||||
} catch (error) {
|
||||
console.error('数据获取失败:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
if (newValue.value !== '') {
|
||||
await getDatas();
|
||||
loading.value = false;
|
||||
}
|
||||
});
|
||||
|
||||
@ -256,8 +251,8 @@ const getDatas = async () => {
|
||||
});
|
||||
currentData.value = tableData.value
|
||||
} catch (error) {
|
||||
console.log('获取失败', error);
|
||||
message.error('获取数据失败');
|
||||
console.log('数据获取失败', error);
|
||||
message.error(`数据获取失败:${error.message}`);
|
||||
}
|
||||
};
|
||||
|
||||
@ -363,14 +358,10 @@ const handleFormSubmit = async (e: MouseEvent) => {
|
||||
console.log(result);
|
||||
message.success('修改成功');
|
||||
}
|
||||
try {
|
||||
await getDatas();
|
||||
} catch (error) {
|
||||
console.error('数据获取失败:', error);
|
||||
}
|
||||
await getDatas();
|
||||
} catch (error) {
|
||||
console.log('提交失败', error);
|
||||
message.error('提交失败');
|
||||
message.error(`提交失败:${error.message}`);
|
||||
} finally {
|
||||
modifyChildUuid.value = '';
|
||||
showDataModal.value = false;
|
||||
@ -396,6 +387,7 @@ const handleDeleteDatas = async (row: DictRow) => {
|
||||
await handleDeleteSubmit(row);
|
||||
} catch (error) {
|
||||
console.log('删除失败', error);
|
||||
message.error(`删除失败${error.message}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -406,14 +398,10 @@ const handleDeleteSubmit = async (deleteData: DictRow) => {
|
||||
try {
|
||||
await deleteChildDict(deleteData.uuid);
|
||||
message.success('删除成功');
|
||||
try {
|
||||
await getDatas();
|
||||
} catch (error) {
|
||||
console.error('数据获取失败:', error);
|
||||
}
|
||||
await getDatas();
|
||||
} catch (error) {
|
||||
console.log('删除失败', error);
|
||||
message.error('删除失败');
|
||||
message.error(`删除失败:${error.message}`);
|
||||
} finally {
|
||||
showDataModal.value = false;
|
||||
}
|
||||
@ -424,8 +412,7 @@ const emptyStateTitle = ref('');
|
||||
const emptyStateDescription = ref('');
|
||||
// 搜索绑定字段
|
||||
const mainSearch = ref('');
|
||||
// 页面标题、表格列名、总数据、表格展示数据、表格是否加载
|
||||
const tableTitle = ref('');
|
||||
// 表格列名、总数据、表格展示数据、表格是否加载
|
||||
const columns = ref(getColumns({ mod: hanldeModifyData, del: handleDeleteDatas }));
|
||||
const tableData = ref<DictRow[]>([]);
|
||||
const currentData = ref<DictRow[]>([]);
|
||||
@ -465,9 +452,9 @@ const height = ref(null);
|
||||
|
||||
&__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
padding-bottom: $smallGap;
|
||||
gap: $miniGap;
|
||||
border-bottom: 1px solid $dashLineColor;
|
||||
|
||||
h1 {
|
||||
@ -475,6 +462,11 @@ const height = ref(null);
|
||||
font-weight: 600;
|
||||
color: $titleTextColor;
|
||||
}
|
||||
h3 {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
color: $titleTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
&__search {
|
||||
|
@ -184,10 +184,10 @@ const handleFormSubmit = async (e: MouseEvent) => {
|
||||
console.log(result);
|
||||
message.success('修改成功');
|
||||
}
|
||||
handleFindParent(navSearch.value);
|
||||
await handleFindParent(navSearch.value);
|
||||
} catch (error) {
|
||||
console.log('提交失败', error);
|
||||
message.error('提交失败');
|
||||
message.error(`提交失败:${error.message}`);
|
||||
} finally {
|
||||
modifyParentUuid.value = '';
|
||||
showDataModal.value = false;
|
||||
@ -229,10 +229,10 @@ const handleDeleteSubmit = async (deleteData: DictRow) => {
|
||||
emit('update:parentTitle', '');
|
||||
}
|
||||
message.success('删除成功');
|
||||
handleFindParent(navSearch.value);
|
||||
await handleFindParent(navSearch.value);
|
||||
} catch (error) {
|
||||
console.log('删除失败', error);
|
||||
message.error('删除失败');
|
||||
message.error(`删除失败:${error.message}`);
|
||||
} finally {
|
||||
showDataModal.value = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user