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