5353 </span >
5454 </div >
5555 </tiny-form-item >
56- <tiny-form-item v-if =" pageSettingState.currentPageData.group !== 'publicPages'" prop =" isDefault" >
57- <tiny-checkbox v-model =" pageSettingState.currentPageData.isDefault" >设为默认页</tiny-checkbox >
56+ <tiny-form-item
57+ v-if =" pageSettingState.currentPageData.group !== 'publicPages' && !isFolder"
58+ label =" 设置默认跳转页"
59+ prop =" isDefault"
60+ >
61+ <tiny-select
62+ v-model =" state.defaultPageId"
63+ :options =" state.childPageOp"
64+ placeholder =" 请选择默认跳转页"
65+ @change =" changeDefaultPage"
66+ ></tiny-select >
5867 </tiny-form-item >
5968 </tiny-form >
6069 </div >
6170</template >
6271
6372<script lang="jsx">
64- import { ref, computed, watchEffect } from 'vue'
65- import { Form, FormItem, Input, Select, Radio, Checkbox } from '@opentiny/vue'
73+ import { ref, computed, watchEffect, reactive } from 'vue'
74+ import { Form, FormItem, Input, Select, Radio } from '@opentiny/vue'
75+ import { iconFile } from '@opentiny/vue-icon'
6676import { usePage } from '@opentiny/tiny-engine-meta-register'
6777import { REGEXP_PAGE_NAME, REGEXP_FOLDER_NAME, REGEXP_ROUTE } from '@opentiny/tiny-engine-common/js/verification'
6878
@@ -72,8 +82,7 @@ export default {
7282 TinyFormItem: FormItem,
7383 TinyInput: Input,
7484 TinySelect: Select,
75- TinyRadio: Radio,
76- TinyCheckbox: Checkbox
85+ TinyRadio: Radio
7786 },
7887 props: {
7988 modelValue: {
@@ -86,7 +95,7 @@ export default {
8695 }
8796 },
8897 setup() {
89- const { pageSettingState, changeTreeData, STATIC_PAGE_GROUP_ID } = usePage()
98+ const { pageSettingState, changeTreeData, STATIC_PAGE_GROUP_ID, getPageChildren, setDefaultPage } = usePage()
9099 const ROOT_ID = pageSettingState.ROOT_ID
91100
92101 const pageParentId = computed({
@@ -99,9 +108,40 @@ export default {
99108 })
100109
101110 const oldParentId = ref(pageParentId.value)
111+ const state = reactive({
112+ childPageList: [],
113+ childPageOp: [],
114+ defaultPageId: ''
115+ })
116+
117+ const setChildAndDefaultPage = async (id) => {
118+ if (pageSettingState.isNew) {
119+ state.childPageList = []
120+ state.childPageOp = []
121+ state.defaultPageId = ''
122+ } else {
123+ state.childPageList = await getPageChildren(id)
124+ if (state.childPageList?.length) {
125+ state.defaultPageId = state.childPageList?.find((item) => item.isDefault)?.id
126+ state.childPageOp = state.childPageList.map((item) => {
127+ return {
128+ value: item.id,
129+ label: item.name,
130+ icon: iconFile()
131+ }
132+ })
133+ setDefaultPage(state.childPageList, state.defaultPageId)
134+ }
135+ }
136+ }
137+
138+ const changeDefaultPage = () => {
139+ setDefaultPage(state.childPageList, state.defaultPageId)
140+ }
102141
103142 watchEffect(() => {
104143 oldParentId.value = pageSettingState.oldParentId
144+ setChildAndDefaultPage(pageSettingState.currentPageData?.id)
105145 })
106146
107147 const currentRoute = computed(() => {
@@ -242,7 +282,9 @@ export default {
242282 validGeneralForm,
243283 treeFolderOp,
244284 currentRoute,
245- changeParentForderId
285+ changeParentForderId,
286+ state,
287+ changeDefaultPage
246288 }
247289 }
248290}
0 commit comments