Skip to content

Commit

Permalink
fix(schema-form): move setDefaultValue out of onMouted
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Apr 5, 2024
1 parent da782b0 commit 63721b3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 38 deletions.
8 changes: 3 additions & 5 deletions src/components/core/schema-form/src/schema-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</template>

<script lang="ts" setup>
import { useAttrs, onMounted } from 'vue';
import { useAttrs } from 'vue';
import { pick } from 'lodash-es';
import { Form, Row } from 'ant-design-vue';
import SchemaFormItem from './schema-form-item.vue';
Expand Down Expand Up @@ -99,8 +99,6 @@
defineExpose(instance);
onMounted(() => {
// 初始化表单默认值
setDefaultValue(formSchemasRef.value);
});
// 初始化表单默认值
setDefaultValue(formSchemasRef.value);
</script>
64 changes: 31 additions & 33 deletions src/views/system/dict-type/index.vue
Original file line number Diff line number Diff line change
@@ -1,34 +1,32 @@
<template>
<div>
<DynamicTable
row-key="id"
header-title="字典管理"
:data-request="Api.systemDictType.dictTypeList"
:columns="columns"
bordered
size="small"
@expand="handleExpand"
>
<template #toolbar>
<a-button
type="primary"
:disabled="!$auth('system:dict-type:create')"
@click="openMenuModal({})"
>
新增
</a-button>
</template>
<template v-if="$router.hasRoute(dictItemRouteName)" #expandedRowRender="{ record }">
<a-table
size="small"
:columns="dictItemColumns"
:loading="expandedRowLoding[record.id]"
:data-source="expandedRowData[record.id]"
:pagination="false"
/>
</template>
</DynamicTable>
</div>
<DynamicTable
row-key="id"
header-title="字典管理"
:data-request="Api.systemDictType.dictTypeList"
:columns="columns"
bordered
size="small"
@expand="handleExpand"
>
<template #toolbar>
<a-button
type="primary"
:disabled="!$auth('system:dict-type:create')"
@click="openMenuModal({})"
>
新增
</a-button>
</template>
<template v-if="$router.hasRoute(dictItemRouteName)" #expandedRowRender="{ record }">
<a-table
size="small"
:columns="dictItemColumns"
:loading="expandedRowLoading[record.id]"
:data-source="expandedRowData[record.id]"
:pagination="false"
/>
</template>
</DynamicTable>
</template>

<script lang="ts" setup>
Expand All @@ -51,7 +49,7 @@
});
const expandedRowData = ref<Recordable<any[]>>({});
const expandedRowLoding = ref<Recordable<boolean>>({});
const expandedRowLoading = ref<Recordable<boolean>>({});
const [DynamicTable, dynamicTableInstance] = useTable({
formProps: {
Expand Down Expand Up @@ -127,10 +125,10 @@
const handleExpand = async (expanded, record) => {
const typeId = record.id;
if (expanded) {
expandedRowLoding.value[typeId] = true;
expandedRowLoading.value[typeId] = true;
const { items = [] } = await Api.systemDictItem
.dictItemList({ typeId })
.finally(() => (expandedRowLoding.value[typeId] = false));
.finally(() => (expandedRowLoading.value[typeId] = false));
expandedRowData.value[typeId] = items;
}
};
Expand Down

0 comments on commit 63721b3

Please sign in to comment.