-
@@ -84,7 +91,7 @@
}
})
- const emits = defineEmits('selectTree', 'delTree')
+ const emit = defineEmits(['selectTree', 'delTree'])
const tool = [
{
@@ -112,12 +119,20 @@
// 树结构
const expandedKeys = ref()
const selectedKeys = ref([])
- const treeData = ref([])
+ const localLoading = ref(false)
+ const treeData = ref([
+ {
+ id: 0,
+ parentId: '-1',
+ name: '顶级',
+ children: ''
+ }
+ ])
let treeRow = {}
const handleTreeClick = (selectedKeys, event) => {
treeRow = event.node
- emits('selectTree', treeRow)
+ emit('selectTree', treeRow)
}
const handleAddTree = () => {
@@ -141,11 +156,13 @@
const loadTreeData = async () => {
try {
+ localLoading.value = true
const treeRes = await props.apiModel.getTree()
+ console.log(treeRes, 'treeRes')
if (Array.isArray(treeRes)) {
- treeData.value = treeRes
+ treeData.value[0].children = treeRes
} else {
- treeData.value = []
+ treeData.value[0].children = []
}
if (selectedKeys.value.length > 0) {
@@ -157,7 +174,12 @@
if (treeRow.id) {
treeRow = []
}
+
+ setTimeout(() => {
+ localLoading.value = false
+ }, 800)
} catch (e) {
+ localLoading.value = false
message.error('获取树结构数据失败:' + e)
console.error('获取树结构数据失败:' + e)
}
diff --git a/src/components/OperationalInformation/index.vue b/src/components/OperationalInformation/index.vue
index f8ce042..9903a9f 100644
--- a/src/components/OperationalInformation/index.vue
+++ b/src/components/OperationalInformation/index.vue
@@ -62,7 +62,8 @@
detailDataProps.value = props.detailData
},
{
- immediate: true
+ immediate: true,
+ deep: true
}
)
diff --git a/src/components/XnPageSelect/README.assets/鍒嗛〉涓嬫媺鏌ヨ灞曠ず.gif b/src/components/XnPageSelect/README.assets/鍒嗛〉涓嬫媺鏌ヨ灞曠ず.gif
new file mode 100644
index 0000000..be20102
Binary files /dev/null and b/src/components/XnPageSelect/README.assets/鍒嗛〉涓嬫媺鏌ヨ灞曠ず.gif differ
diff --git a/src/hook/useFormHandler.js b/src/hook/useFormHandler.js
index 2b5c466..2fd29e4 100644
--- a/src/hook/useFormHandler.js
+++ b/src/hook/useFormHandler.js
@@ -13,6 +13,7 @@ export default function useFormHandler(formItems, api) {
const state = reactive({
PAGE_TYPE: ''
})
+ let detailData = reactive({})
// 初始化表单数据对象
let formData = reactive({})
@@ -84,8 +85,8 @@ export default function useFormHandler(formItems, api) {
* 处理返回操作,返回上一级页面并关闭当前标签页。
*/
const handleBack = () => {
+ useTabs.close(route)
router.go(-1) // 优化为通用的返回上一页操作
- useTabs.close()
}
/**
@@ -98,6 +99,7 @@ export default function useFormHandler(formItems, api) {
if (pageType && pageType !== 'ADD') {
try {
const res = await api.getDetail({ id: route.query.id })
+
// 根据返回的详情数据初始化表单数据
for (let key in formData) {
if (res[key] !== undefined) {
@@ -117,6 +119,7 @@ export default function useFormHandler(formItems, api) {
formData,
submitLoading,
formRefs,
+ detailData,
onSubmit,
handleBack,
fetchData
diff --git a/src/layout/components/tags.vue b/src/layout/components/tags.vue
index f2627cf..16abe77 100644
--- a/src/layout/components/tags.vue
+++ b/src/layout/components/tags.vue
@@ -52,7 +52,7 @@