centaline-data-driven-v3 0.1.31 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -51,6 +51,10 @@ const props = defineProps({
|
|
|
51
51
|
Number,
|
|
52
52
|
default: 500,
|
|
53
53
|
},
|
|
54
|
+
apiParam: {
|
|
55
|
+
type: Object,
|
|
56
|
+
default: () => { },
|
|
57
|
+
}
|
|
54
58
|
})
|
|
55
59
|
const refTree = ref()
|
|
56
60
|
const rootNode = ref();
|
|
@@ -64,7 +68,7 @@ const defaultProps = ref({
|
|
|
64
68
|
id: 'code',
|
|
65
69
|
})
|
|
66
70
|
const searchStatus = ref([])
|
|
67
|
-
|
|
71
|
+
const screenPara = ref(props.apiParam);
|
|
68
72
|
const menuVisible = ref(false)//右键菜单显示控制
|
|
69
73
|
const currentData = ref({ code: "" })// 当前节点所对应的数据
|
|
70
74
|
const currentNode = ref(null)//当前节点对应的 Node
|
|
@@ -91,33 +95,34 @@ onBeforeUnmount(() => {
|
|
|
91
95
|
|
|
92
96
|
//搜索(查询条件调用)
|
|
93
97
|
function search(m) {
|
|
98
|
+
screenPara.value = m;
|
|
94
99
|
if (searchStatus.value.length == 0) {
|
|
95
100
|
// 重置计数器
|
|
96
101
|
retryCount.value = 0
|
|
97
102
|
if (qrtimer.value) clearTimeout(qrtimer.value);
|
|
98
103
|
searchStatus.value.push('a');
|
|
99
104
|
rootNode.value.childNodes = []
|
|
100
|
-
loadNode(rootNode.value, rootResolve.value
|
|
105
|
+
loadNode(rootNode.value, rootResolve.value)
|
|
101
106
|
}
|
|
102
107
|
else {
|
|
103
108
|
if (retryCount.value >= 50) {
|
|
104
|
-
console.warn(`搜索繁忙,请稍后再试`);
|
|
109
|
+
console.warn(`搜索繁忙,请稍后再试`);
|
|
105
110
|
return;
|
|
106
111
|
}
|
|
107
112
|
retryCount.value++
|
|
108
113
|
|
|
109
114
|
qrtimer.value = setTimeout(() => {
|
|
110
|
-
search(
|
|
115
|
+
search();
|
|
111
116
|
}, 200);
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
//加载节点(点击节点加号时调用)
|
|
115
|
-
function loadNode(node, resolve
|
|
120
|
+
function loadNode(node, resolve) {
|
|
116
121
|
if (node.level === 0) {
|
|
117
122
|
loading.value = true;
|
|
118
123
|
rootNode.value = node
|
|
119
124
|
rootResolve.value = resolve;
|
|
120
|
-
return SearchTree(
|
|
125
|
+
return SearchTree(screenPara.value || undefined).then(data => {
|
|
121
126
|
loading.value = false;
|
|
122
127
|
resolve(data.rows);
|
|
123
128
|
load(data, true)
|
|
@@ -126,7 +131,15 @@ function loadNode(node, resolve, m) {
|
|
|
126
131
|
if (node.level >= 1) {
|
|
127
132
|
let fields = model.value.searchData("code", node.data.code, 9, 3);
|
|
128
133
|
let filter = {
|
|
129
|
-
"searchData":
|
|
134
|
+
"searchData": {
|
|
135
|
+
// 先保留searchData的其他属性
|
|
136
|
+
...(screenPara.value?.searchData || {}),
|
|
137
|
+
// 再合并fields数组(将两个数组合并,而不是覆盖)
|
|
138
|
+
fields: [
|
|
139
|
+
...fields.fields,
|
|
140
|
+
...(screenPara.value?.searchData?.fields || [])
|
|
141
|
+
]
|
|
142
|
+
}
|
|
130
143
|
};
|
|
131
144
|
return SearchTree(filter).then(data => {
|
|
132
145
|
loading.value = false;
|
|
@@ -204,7 +217,9 @@ function rightClick(event, object, Node) { // event、object该节点所对应
|
|
|
204
217
|
}
|
|
205
218
|
})
|
|
206
219
|
}
|
|
207
|
-
|
|
220
|
+
if (menuVisible.value) {
|
|
221
|
+
document.addEventListener('click', closeMenu) // 监听事件鼠标点击事件,若点击则隐藏菜单
|
|
222
|
+
}
|
|
208
223
|
}
|
|
209
224
|
//关闭菜单
|
|
210
225
|
function closeMenu() {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
3
|
<div ref="refscreenDiv" id="refscreenDiv">
|
|
4
|
-
<ct-searchscreen ref="reftreescreen" :from="'tree'" style="padding-left: 11px;" :api="searchConditionApi"
|
|
5
|
-
@search="search" @loaded="screenload"
|
|
4
|
+
<ct-searchscreen ref="reftreescreen" :from="'tree'" style="padding-left: 11px;" :api="searchConditionApi"
|
|
5
|
+
:screenPara="apiParam" @search="search" @loaded="screenload"></ct-searchscreen>
|
|
6
6
|
</div>
|
|
7
|
-
<tree v-if="loadTree" ref="reftree" :api="searchDataApi"
|
|
7
|
+
<tree v-if="loadTree" ref="reftree" :api="searchDataApi" @loaded="loaded" :treeHeight="treeHeight"
|
|
8
|
+
:apiParam="{ searchData:searchData }">
|
|
8
9
|
</tree>
|
|
9
10
|
|
|
10
11
|
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
import { ref, nextTick, watch, onMounted, onBeforeUnmount } from 'vue'
|
|
15
16
|
import Tree from './Tree/Tree.vue';
|
|
16
17
|
const emit = defineEmits(['loaded'])
|
|
17
|
-
const loadTree=ref(false)
|
|
18
|
+
const loadTree = ref(false)
|
|
18
19
|
|
|
19
20
|
const props = defineProps({
|
|
20
21
|
searchConditionApi: String,
|
|
@@ -33,19 +34,19 @@ const refscreenDiv = ref()
|
|
|
33
34
|
const reftreescreen = ref()
|
|
34
35
|
const reftree = ref()
|
|
35
36
|
const treeHeight = ref(0)
|
|
36
|
-
|
|
37
|
-
const qrtimer=ref(null)
|
|
38
|
-
onBeforeUnmount(()=>{
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
const searchData = ref([])
|
|
38
|
+
const qrtimer = ref(null)
|
|
39
|
+
onBeforeUnmount(() => {
|
|
40
|
+
if (qrtimer.value) {
|
|
41
|
+
clearTimeout(qrtimer.value);
|
|
42
|
+
qrtimer.value = null;
|
|
43
|
+
}
|
|
43
44
|
})
|
|
44
45
|
|
|
45
46
|
function setTreeHeight() {
|
|
46
47
|
nextTick(() => {
|
|
47
48
|
if (refscreenDiv.value) {
|
|
48
|
-
|
|
49
|
+
qrtimer.value = setTimeout(() => {
|
|
49
50
|
let searchHeight = refscreenDiv.value.offsetHeight;
|
|
50
51
|
treeHeight.value = props.searchtreeHeight - searchHeight;
|
|
51
52
|
}, 200);
|
|
@@ -56,6 +57,7 @@ function setTreeHeight() {
|
|
|
56
57
|
|
|
57
58
|
function search() {
|
|
58
59
|
setTreeHeight();
|
|
60
|
+
searchData.value = reftreescreen.value?.model?.searchData;
|
|
59
61
|
reftree.value.search(reftreescreen.value.model);
|
|
60
62
|
}
|
|
61
63
|
function loaded(data) {
|
|
@@ -64,15 +66,18 @@ function loaded(data) {
|
|
|
64
66
|
} catch (e) { }
|
|
65
67
|
}
|
|
66
68
|
function screenload(data) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
nextTick(() => {
|
|
70
|
+
searchData.value = reftreescreen.value?.model?.searchData;
|
|
71
|
+
loadTree.value = true
|
|
72
|
+
setTreeHeight();
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
75
|
onMounted(() => {
|
|
71
76
|
|
|
72
77
|
})
|
|
73
78
|
watch(() => props.searchtreeHeight, () => {
|
|
74
79
|
setTreeHeight();
|
|
75
|
-
|
|
80
|
+
})
|
|
76
81
|
// watch(() => reftreescreen.value?.model, // 监听子组件的someData属性
|
|
77
82
|
// (newVal, oldVal) => {
|
|
78
83
|
// if (newVal?.searchData != oldVal?.searchData) {
|