bl-common-vue3 3.7.20 → 3.7.21
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/.history/package_20230222150904.json +54 -54
- package/.history/package_20230227191203.json +54 -54
- package/.history/package_20230227193052.json +54 -54
- package/.history/package_20230308102851.json +54 -54
- package/.history/src/common/utils/util_20230210124242.js +156 -156
- package/.history/src/common/utils/util_20230228192253.js +157 -157
- package/.history/src/components/BLIcon/index_20230103102354.js +17 -17
- package/.history/src/components/BLIcon/index_20230227191108.js +18 -18
- package/.history/src/components/BLIcon/index_20230227193020.js +18 -18
- package/.history/src/components/BLIcon/index_20230227193025.js +18 -18
- package/.history/src/components/ChooseHousingResources/index_20230222193654.vue +1252 -1252
- package/.history/src/components/ChooseHousingResources/index_20230227191144.vue +1252 -1252
- package/.history/src/components/ChooseHousingResources/index_20230227193035.vue +1252 -1252
- package/.history/src/components/VillageTree/index_20230227202552.vue +298 -298
- package/.history/src/components/VillageTree/index_20230308102756.vue +305 -305
- package/.history/src/components/VillageTree/index_20230308113141.vue +305 -305
- package/.history/src/components/components_20230216190147.js +15 -15
- package/.history/src/components/components_20230227191116.js +15 -15
- package/.history/src/components/components_20230227191117.js +15 -15
- package/.history/src/components/components_20230308102833.js +16 -16
- package/.idea/components_vue3.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/lib/vue3common.common.js +21317 -34351
- package/lib/vue3common.umd.js +21317 -34351
- package/lib/vue3common.umd.min.js +41 -37
- package/package.json +1 -1
|
@@ -1,298 +1,298 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="hide-scroller-bar" style="height: 100%; overflow: hidden auto">
|
|
3
|
-
<a-tree
|
|
4
|
-
v-if="treeList.length"
|
|
5
|
-
show-icon
|
|
6
|
-
v-model:expandedKeys="expandedKeys"
|
|
7
|
-
:selectedKeys="selectedKeys"
|
|
8
|
-
:tree-data="treeList"
|
|
9
|
-
:blockNode="true"
|
|
10
|
-
:selectable="true"
|
|
11
|
-
:load-data="onLoadTreeData"
|
|
12
|
-
@select="onTreeSelect"
|
|
13
|
-
>
|
|
14
|
-
<!-- 图标 -->
|
|
15
|
-
<template #topCompanyIcon>
|
|
16
|
-
<bl-icon type="tree-jigou" class="tree-icon" />
|
|
17
|
-
</template>
|
|
18
|
-
<template #departmentIcon>
|
|
19
|
-
<GoldenFilled class="tree-icon" />
|
|
20
|
-
</template>
|
|
21
|
-
<template #villageIcon>
|
|
22
|
-
<bl-icon type="tree-xiangmu" class="tree-icon" />
|
|
23
|
-
</template>
|
|
24
|
-
<template #buildIcon>
|
|
25
|
-
<bl-icon type="tree-louyu" class="tree-icon" />
|
|
26
|
-
</template>
|
|
27
|
-
<template #layerIcon>
|
|
28
|
-
<bl-icon type="tree-louceng" class="tree-icon" />
|
|
29
|
-
</template>
|
|
30
|
-
<template #roomIcon>
|
|
31
|
-
<bl-icon type="tree-fangjian" class="tree-icon" />
|
|
32
|
-
</template>
|
|
33
|
-
</a-tree>
|
|
34
|
-
</div>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script>
|
|
38
|
-
import { defineComponent, reactive, toRefs } from "vue";
|
|
39
|
-
import { BlIcon } from "bl-common-vue3";
|
|
40
|
-
import { GoldenFilled } from "@ant-design/icons-vue";
|
|
41
|
-
export default defineComponent({
|
|
42
|
-
name: "VillageTree",
|
|
43
|
-
props: {
|
|
44
|
-
userChecked: {
|
|
45
|
-
type: Number,
|
|
46
|
-
default: 1,
|
|
47
|
-
},
|
|
48
|
-
attachDpt: {
|
|
49
|
-
type: Number,
|
|
50
|
-
default: 1,
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
components: { GoldenFilled, "bl-icon": BlIcon },
|
|
54
|
-
setup(props, { emit }) {
|
|
55
|
-
const state = reactive({
|
|
56
|
-
treeList: [],
|
|
57
|
-
expandedKeys: [],
|
|
58
|
-
selectedKeys: [],
|
|
59
|
-
selected: {},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
/** 点击选中当前项 */
|
|
63
|
-
const onTreeSelect = (value, e) => {
|
|
64
|
-
const current = e.node.dataRef;
|
|
65
|
-
if (current.childType == "department") {
|
|
66
|
-
// 部门不允许选中
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
setSelected(current);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
/** 设置选中 */
|
|
73
|
-
const setSelected = (current) => {
|
|
74
|
-
state.selectedKeys = [current.key];
|
|
75
|
-
state.selected = current;
|
|
76
|
-
emit("getCurrent", { current });
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
/** 动态加载树数据 */
|
|
80
|
-
const onLoadTreeData = (treeNode) => {
|
|
81
|
-
return new Promise((resolve) => {
|
|
82
|
-
const { dataRef } = treeNode;
|
|
83
|
-
if (dataRef.isLeaf || (dataRef.children && dataRef.children.length)) {
|
|
84
|
-
resolve();
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
if (dataRef.childType === "build") {
|
|
88
|
-
getLayerList(dataRef).then(() => {
|
|
89
|
-
resolve();
|
|
90
|
-
});
|
|
91
|
-
} else if (dataRef.childType === "layer") {
|
|
92
|
-
getRoomList(dataRef).then(() => {
|
|
93
|
-
resolve();
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
// 获取楼层列表
|
|
99
|
-
const getLayerList = (build) => {
|
|
100
|
-
return new Promise((resolve) => {
|
|
101
|
-
if (build.isLeaf || (build.children && build.children.length)) {
|
|
102
|
-
resolve(build.children || []);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
emit("request", {
|
|
106
|
-
params: {
|
|
107
|
-
method: "get",
|
|
108
|
-
server: "/village",
|
|
109
|
-
url: "/project/layer/all",
|
|
110
|
-
extra: {
|
|
111
|
-
build_id: build.id,
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
success: (res) => {
|
|
115
|
-
if (res.list.length) {
|
|
116
|
-
build.children = res.list.map((item) => ({
|
|
117
|
-
...item,
|
|
118
|
-
childType: "layer",
|
|
119
|
-
key: `${build.key}_layer_${item.id}`,
|
|
120
|
-
title: item.layer_name,
|
|
121
|
-
level: build.level + 1,
|
|
122
|
-
extra: {
|
|
123
|
-
...build.extra,
|
|
124
|
-
build_id: build.id,
|
|
125
|
-
build_number: build.build_number,
|
|
126
|
-
build_name: build.build_name,
|
|
127
|
-
},
|
|
128
|
-
isLeaf: false,
|
|
129
|
-
slots: {
|
|
130
|
-
icon: "layerIcon",
|
|
131
|
-
},
|
|
132
|
-
}));
|
|
133
|
-
}
|
|
134
|
-
resolve(build.children);
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
// 获取房间列表
|
|
140
|
-
const getRoomList = (layer) => {
|
|
141
|
-
return new Promise((resolve) => {
|
|
142
|
-
if (layer.isLeaf || (layer.children && layer.children.length)) {
|
|
143
|
-
resolve(layer.children || []);
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
emit("request", {
|
|
147
|
-
params: {
|
|
148
|
-
method: "get",
|
|
149
|
-
server: "/village",
|
|
150
|
-
url: "/project/room/all",
|
|
151
|
-
extra: {
|
|
152
|
-
village_id: layer.extra.village_id,
|
|
153
|
-
layer_id: layer.id,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
success: (res) => {
|
|
157
|
-
if (res.list.length) {
|
|
158
|
-
layer.children = res.list.map((item) => {
|
|
159
|
-
let newItem = {
|
|
160
|
-
...item,
|
|
161
|
-
childType: "room",
|
|
162
|
-
key: `${layer.key}_room_${item.id}`,
|
|
163
|
-
title: item.room_name,
|
|
164
|
-
level: layer.level + 1,
|
|
165
|
-
layer_id: layer.id,
|
|
166
|
-
layer_number: layer.layer_number,
|
|
167
|
-
layer_name: layer.layer_name,
|
|
168
|
-
property_area: item.charging_area,
|
|
169
|
-
lease_square: item.rental_area,
|
|
170
|
-
extra: {
|
|
171
|
-
...layer.extra,
|
|
172
|
-
layer_id: layer.id,
|
|
173
|
-
layer_number: layer.layer_number,
|
|
174
|
-
layer_name: layer.layer_name,
|
|
175
|
-
},
|
|
176
|
-
isLeaf: true,
|
|
177
|
-
slots: {
|
|
178
|
-
icon: "roomIcon",
|
|
179
|
-
title: "roomTitle",
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
return newItem;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
resolve(layer.children);
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
/** 获取树数据 */
|
|
192
|
-
// 获取部门树列表
|
|
193
|
-
const getDeptTreeList = (list, level) => {
|
|
194
|
-
let result = [];
|
|
195
|
-
for (let listItem of list) {
|
|
196
|
-
// 非项目管理部门
|
|
197
|
-
if (listItem.type !== 3) {
|
|
198
|
-
listItem.childType = "department"; //listItem.type == 0 ? "topCompany" : "department";
|
|
199
|
-
listItem.key = `${listItem.childType}-${listItem.id}`; // 部门用中划线,房源用下划线,方便整理选中房源key
|
|
200
|
-
listItem.title = listItem.name;
|
|
201
|
-
listItem.level = level;
|
|
202
|
-
listItem.slots = {
|
|
203
|
-
icon: `${listItem.childType}Icon`,
|
|
204
|
-
};
|
|
205
|
-
listItem.children = [];
|
|
206
|
-
if (listItem.subcat && listItem.subcat.length) {
|
|
207
|
-
listItem.children = getDeptTreeList(listItem.subcat, level + 1);
|
|
208
|
-
}
|
|
209
|
-
if (listItem.villageList && listItem.villageList.length) {
|
|
210
|
-
const villageList = getVillageTreeList(
|
|
211
|
-
listItem.villageList,
|
|
212
|
-
level,
|
|
213
|
-
listItem.key
|
|
214
|
-
);
|
|
215
|
-
listItem.children = [...listItem.children, ...villageList];
|
|
216
|
-
}
|
|
217
|
-
listItem.isLeaf = listItem.children.length === 0;
|
|
218
|
-
result.push(listItem);
|
|
219
|
-
state.expandedKeys.push(listItem.key);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
return result;
|
|
223
|
-
};
|
|
224
|
-
// 获取项目树列表
|
|
225
|
-
const getVillageTreeList = (villageList, level = 1, parentKey) => {
|
|
226
|
-
return villageList.map((village) => {
|
|
227
|
-
village.childType = "village";
|
|
228
|
-
village.key = `${parentKey ? parentKey + "-" : ""}${
|
|
229
|
-
village.childType
|
|
230
|
-
}_${village.id}`;
|
|
231
|
-
|
|
232
|
-
village.title = village.name;
|
|
233
|
-
village.level = level;
|
|
234
|
-
village.slots = {
|
|
235
|
-
icon: `${village.childType}Icon`,
|
|
236
|
-
};
|
|
237
|
-
if (village.buildList && village.buildList.length) {
|
|
238
|
-
village.isLeaf = false;
|
|
239
|
-
village.children = village.buildList.map((build) => ({
|
|
240
|
-
...build,
|
|
241
|
-
level,
|
|
242
|
-
childType: "build",
|
|
243
|
-
key: `${village.key}_build_${build.id}`,
|
|
244
|
-
title: build.build_name,
|
|
245
|
-
extra: {
|
|
246
|
-
village_id: village.id,
|
|
247
|
-
village_name: village.name,
|
|
248
|
-
village_short_name: village.short_name,
|
|
249
|
-
},
|
|
250
|
-
slots: {
|
|
251
|
-
icon: "buildIcon",
|
|
252
|
-
},
|
|
253
|
-
isLeaf: false,
|
|
254
|
-
}));
|
|
255
|
-
} else {
|
|
256
|
-
village.isLeaf = true;
|
|
257
|
-
}
|
|
258
|
-
state.expandedKeys.push(village.key);
|
|
259
|
-
if (!state.selectedKeys.length) {
|
|
260
|
-
setSelected(village);
|
|
261
|
-
}
|
|
262
|
-
return village;
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const getVillageInfo = () => {
|
|
267
|
-
emit("request", {
|
|
268
|
-
params: {
|
|
269
|
-
method: "get",
|
|
270
|
-
server: "/org",
|
|
271
|
-
url: "/build/villageAndBuildList/v2",
|
|
272
|
-
extra: {
|
|
273
|
-
checked: props.attachDpt ? 1 : props.userChecked,
|
|
274
|
-
attach_department: props.attachDpt,
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
success: (res) => {
|
|
278
|
-
state.treeList = res.list
|
|
279
|
-
? getDeptTreeList(res.list, 1)
|
|
280
|
-
: getVillageTreeList(res.villageList);
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const init = () => {
|
|
286
|
-
getVillageInfo();
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
init();
|
|
290
|
-
|
|
291
|
-
return {
|
|
292
|
-
...toRefs(state),
|
|
293
|
-
onLoadTreeData,
|
|
294
|
-
onTreeSelect,
|
|
295
|
-
};
|
|
296
|
-
},
|
|
297
|
-
});
|
|
298
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hide-scroller-bar" style="height: 100%; overflow: hidden auto">
|
|
3
|
+
<a-tree
|
|
4
|
+
v-if="treeList.length"
|
|
5
|
+
show-icon
|
|
6
|
+
v-model:expandedKeys="expandedKeys"
|
|
7
|
+
:selectedKeys="selectedKeys"
|
|
8
|
+
:tree-data="treeList"
|
|
9
|
+
:blockNode="true"
|
|
10
|
+
:selectable="true"
|
|
11
|
+
:load-data="onLoadTreeData"
|
|
12
|
+
@select="onTreeSelect"
|
|
13
|
+
>
|
|
14
|
+
<!-- 图标 -->
|
|
15
|
+
<template #topCompanyIcon>
|
|
16
|
+
<bl-icon type="tree-jigou" class="tree-icon" />
|
|
17
|
+
</template>
|
|
18
|
+
<template #departmentIcon>
|
|
19
|
+
<GoldenFilled class="tree-icon" />
|
|
20
|
+
</template>
|
|
21
|
+
<template #villageIcon>
|
|
22
|
+
<bl-icon type="tree-xiangmu" class="tree-icon" />
|
|
23
|
+
</template>
|
|
24
|
+
<template #buildIcon>
|
|
25
|
+
<bl-icon type="tree-louyu" class="tree-icon" />
|
|
26
|
+
</template>
|
|
27
|
+
<template #layerIcon>
|
|
28
|
+
<bl-icon type="tree-louceng" class="tree-icon" />
|
|
29
|
+
</template>
|
|
30
|
+
<template #roomIcon>
|
|
31
|
+
<bl-icon type="tree-fangjian" class="tree-icon" />
|
|
32
|
+
</template>
|
|
33
|
+
</a-tree>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
import { defineComponent, reactive, toRefs } from "vue";
|
|
39
|
+
import { BlIcon } from "bl-common-vue3";
|
|
40
|
+
import { GoldenFilled } from "@ant-design/icons-vue";
|
|
41
|
+
export default defineComponent({
|
|
42
|
+
name: "VillageTree",
|
|
43
|
+
props: {
|
|
44
|
+
userChecked: {
|
|
45
|
+
type: Number,
|
|
46
|
+
default: 1,
|
|
47
|
+
},
|
|
48
|
+
attachDpt: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 1,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
components: { GoldenFilled, "bl-icon": BlIcon },
|
|
54
|
+
setup(props, { emit }) {
|
|
55
|
+
const state = reactive({
|
|
56
|
+
treeList: [],
|
|
57
|
+
expandedKeys: [],
|
|
58
|
+
selectedKeys: [],
|
|
59
|
+
selected: {},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** 点击选中当前项 */
|
|
63
|
+
const onTreeSelect = (value, e) => {
|
|
64
|
+
const current = e.node.dataRef;
|
|
65
|
+
if (current.childType == "department") {
|
|
66
|
+
// 部门不允许选中
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
setSelected(current);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/** 设置选中 */
|
|
73
|
+
const setSelected = (current) => {
|
|
74
|
+
state.selectedKeys = [current.key];
|
|
75
|
+
state.selected = current;
|
|
76
|
+
emit("getCurrent", { current });
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** 动态加载树数据 */
|
|
80
|
+
const onLoadTreeData = (treeNode) => {
|
|
81
|
+
return new Promise((resolve) => {
|
|
82
|
+
const { dataRef } = treeNode;
|
|
83
|
+
if (dataRef.isLeaf || (dataRef.children && dataRef.children.length)) {
|
|
84
|
+
resolve();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (dataRef.childType === "build") {
|
|
88
|
+
getLayerList(dataRef).then(() => {
|
|
89
|
+
resolve();
|
|
90
|
+
});
|
|
91
|
+
} else if (dataRef.childType === "layer") {
|
|
92
|
+
getRoomList(dataRef).then(() => {
|
|
93
|
+
resolve();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
// 获取楼层列表
|
|
99
|
+
const getLayerList = (build) => {
|
|
100
|
+
return new Promise((resolve) => {
|
|
101
|
+
if (build.isLeaf || (build.children && build.children.length)) {
|
|
102
|
+
resolve(build.children || []);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
emit("request", {
|
|
106
|
+
params: {
|
|
107
|
+
method: "get",
|
|
108
|
+
server: "/village",
|
|
109
|
+
url: "/project/layer/all",
|
|
110
|
+
extra: {
|
|
111
|
+
build_id: build.id,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
success: (res) => {
|
|
115
|
+
if (res.list.length) {
|
|
116
|
+
build.children = res.list.map((item) => ({
|
|
117
|
+
...item,
|
|
118
|
+
childType: "layer",
|
|
119
|
+
key: `${build.key}_layer_${item.id}`,
|
|
120
|
+
title: item.layer_name,
|
|
121
|
+
level: build.level + 1,
|
|
122
|
+
extra: {
|
|
123
|
+
...build.extra,
|
|
124
|
+
build_id: build.id,
|
|
125
|
+
build_number: build.build_number,
|
|
126
|
+
build_name: build.build_name,
|
|
127
|
+
},
|
|
128
|
+
isLeaf: false,
|
|
129
|
+
slots: {
|
|
130
|
+
icon: "layerIcon",
|
|
131
|
+
},
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
resolve(build.children);
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
// 获取房间列表
|
|
140
|
+
const getRoomList = (layer) => {
|
|
141
|
+
return new Promise((resolve) => {
|
|
142
|
+
if (layer.isLeaf || (layer.children && layer.children.length)) {
|
|
143
|
+
resolve(layer.children || []);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
emit("request", {
|
|
147
|
+
params: {
|
|
148
|
+
method: "get",
|
|
149
|
+
server: "/village",
|
|
150
|
+
url: "/project/room/all",
|
|
151
|
+
extra: {
|
|
152
|
+
village_id: layer.extra.village_id,
|
|
153
|
+
layer_id: layer.id,
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
success: (res) => {
|
|
157
|
+
if (res.list.length) {
|
|
158
|
+
layer.children = res.list.map((item) => {
|
|
159
|
+
let newItem = {
|
|
160
|
+
...item,
|
|
161
|
+
childType: "room",
|
|
162
|
+
key: `${layer.key}_room_${item.id}`,
|
|
163
|
+
title: item.room_name,
|
|
164
|
+
level: layer.level + 1,
|
|
165
|
+
layer_id: layer.id,
|
|
166
|
+
layer_number: layer.layer_number,
|
|
167
|
+
layer_name: layer.layer_name,
|
|
168
|
+
property_area: item.charging_area,
|
|
169
|
+
lease_square: item.rental_area,
|
|
170
|
+
extra: {
|
|
171
|
+
...layer.extra,
|
|
172
|
+
layer_id: layer.id,
|
|
173
|
+
layer_number: layer.layer_number,
|
|
174
|
+
layer_name: layer.layer_name,
|
|
175
|
+
},
|
|
176
|
+
isLeaf: true,
|
|
177
|
+
slots: {
|
|
178
|
+
icon: "roomIcon",
|
|
179
|
+
title: "roomTitle",
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
return newItem;
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
resolve(layer.children);
|
|
186
|
+
},
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/** 获取树数据 */
|
|
192
|
+
// 获取部门树列表
|
|
193
|
+
const getDeptTreeList = (list, level) => {
|
|
194
|
+
let result = [];
|
|
195
|
+
for (let listItem of list) {
|
|
196
|
+
// 非项目管理部门
|
|
197
|
+
if (listItem.type !== 3) {
|
|
198
|
+
listItem.childType = "department"; //listItem.type == 0 ? "topCompany" : "department";
|
|
199
|
+
listItem.key = `${listItem.childType}-${listItem.id}`; // 部门用中划线,房源用下划线,方便整理选中房源key
|
|
200
|
+
listItem.title = listItem.name;
|
|
201
|
+
listItem.level = level;
|
|
202
|
+
listItem.slots = {
|
|
203
|
+
icon: `${listItem.childType}Icon`,
|
|
204
|
+
};
|
|
205
|
+
listItem.children = [];
|
|
206
|
+
if (listItem.subcat && listItem.subcat.length) {
|
|
207
|
+
listItem.children = getDeptTreeList(listItem.subcat, level + 1);
|
|
208
|
+
}
|
|
209
|
+
if (listItem.villageList && listItem.villageList.length) {
|
|
210
|
+
const villageList = getVillageTreeList(
|
|
211
|
+
listItem.villageList,
|
|
212
|
+
level,
|
|
213
|
+
listItem.key
|
|
214
|
+
);
|
|
215
|
+
listItem.children = [...listItem.children, ...villageList];
|
|
216
|
+
}
|
|
217
|
+
listItem.isLeaf = listItem.children.length === 0;
|
|
218
|
+
result.push(listItem);
|
|
219
|
+
state.expandedKeys.push(listItem.key);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return result;
|
|
223
|
+
};
|
|
224
|
+
// 获取项目树列表
|
|
225
|
+
const getVillageTreeList = (villageList, level = 1, parentKey) => {
|
|
226
|
+
return villageList.map((village) => {
|
|
227
|
+
village.childType = "village";
|
|
228
|
+
village.key = `${parentKey ? parentKey + "-" : ""}${
|
|
229
|
+
village.childType
|
|
230
|
+
}_${village.id}`;
|
|
231
|
+
|
|
232
|
+
village.title = village.name;
|
|
233
|
+
village.level = level;
|
|
234
|
+
village.slots = {
|
|
235
|
+
icon: `${village.childType}Icon`,
|
|
236
|
+
};
|
|
237
|
+
if (village.buildList && village.buildList.length) {
|
|
238
|
+
village.isLeaf = false;
|
|
239
|
+
village.children = village.buildList.map((build) => ({
|
|
240
|
+
...build,
|
|
241
|
+
level,
|
|
242
|
+
childType: "build",
|
|
243
|
+
key: `${village.key}_build_${build.id}`,
|
|
244
|
+
title: build.build_name,
|
|
245
|
+
extra: {
|
|
246
|
+
village_id: village.id,
|
|
247
|
+
village_name: village.name,
|
|
248
|
+
village_short_name: village.short_name,
|
|
249
|
+
},
|
|
250
|
+
slots: {
|
|
251
|
+
icon: "buildIcon",
|
|
252
|
+
},
|
|
253
|
+
isLeaf: false,
|
|
254
|
+
}));
|
|
255
|
+
} else {
|
|
256
|
+
village.isLeaf = true;
|
|
257
|
+
}
|
|
258
|
+
state.expandedKeys.push(village.key);
|
|
259
|
+
if (!state.selectedKeys.length) {
|
|
260
|
+
setSelected(village);
|
|
261
|
+
}
|
|
262
|
+
return village;
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const getVillageInfo = () => {
|
|
267
|
+
emit("request", {
|
|
268
|
+
params: {
|
|
269
|
+
method: "get",
|
|
270
|
+
server: "/org",
|
|
271
|
+
url: "/build/villageAndBuildList/v2",
|
|
272
|
+
extra: {
|
|
273
|
+
checked: props.attachDpt ? 1 : props.userChecked,
|
|
274
|
+
attach_department: props.attachDpt,
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
success: (res) => {
|
|
278
|
+
state.treeList = res.list
|
|
279
|
+
? getDeptTreeList(res.list, 1)
|
|
280
|
+
: getVillageTreeList(res.villageList);
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
const init = () => {
|
|
286
|
+
getVillageInfo();
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
init();
|
|
290
|
+
|
|
291
|
+
return {
|
|
292
|
+
...toRefs(state),
|
|
293
|
+
onLoadTreeData,
|
|
294
|
+
onTreeSelect,
|
|
295
|
+
};
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
</script>
|