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,1252 +1,1252 @@
|
|
|
1
|
-
<!--
|
|
2
|
-
* @Description: 选择房源组件
|
|
3
|
-
-->
|
|
4
|
-
|
|
5
|
-
<template>
|
|
6
|
-
<div class="choose-housing beauty-scroller-bar">
|
|
7
|
-
<a-alert
|
|
8
|
-
show-icon
|
|
9
|
-
:message="alertTip"
|
|
10
|
-
v-if="alertTip"
|
|
11
|
-
style="margin-bottom: 10px"
|
|
12
|
-
/>
|
|
13
|
-
<div class="tree-view" v-if="treeList.length">
|
|
14
|
-
<a-tree
|
|
15
|
-
:checkable="checkable"
|
|
16
|
-
show-icon
|
|
17
|
-
v-model:expandedKeys="expandedKeys"
|
|
18
|
-
:checkedKeys="checkedKeys"
|
|
19
|
-
:tree-data="treeList"
|
|
20
|
-
:blockNode="true"
|
|
21
|
-
:selectable="false"
|
|
22
|
-
:load-data="onLoadTreeData"
|
|
23
|
-
:disabled="allDisabled"
|
|
24
|
-
@check="handleTreeCheck"
|
|
25
|
-
>
|
|
26
|
-
<!-- 图标 -->
|
|
27
|
-
<template #topCompanyIcon>
|
|
28
|
-
<bl-icon type="tree-jigou" class="tree-icon" />
|
|
29
|
-
</template>
|
|
30
|
-
<template #departmentIcon>
|
|
31
|
-
<GoldenFilled class="tree-icon" />
|
|
32
|
-
</template>
|
|
33
|
-
<template #villageIcon>
|
|
34
|
-
<bl-icon type="tree-xiangmu" class="tree-icon" />
|
|
35
|
-
</template>
|
|
36
|
-
<template #buildIcon>
|
|
37
|
-
<bl-icon type="tree-louyu" class="tree-icon" />
|
|
38
|
-
</template>
|
|
39
|
-
<template #layerIcon>
|
|
40
|
-
<bl-icon type="tree-louceng" class="tree-icon" />
|
|
41
|
-
</template>
|
|
42
|
-
<template #roomIcon>
|
|
43
|
-
<bl-icon type="tree-fangjian" class="tree-icon" />
|
|
44
|
-
</template>
|
|
45
|
-
<!-- 标题 -->
|
|
46
|
-
<template #roomTitle="{ dataRef }">
|
|
47
|
-
<a-tooltip placement="topLeft">
|
|
48
|
-
<template #title>{{ dataRef.disabledTip }}</template>
|
|
49
|
-
<div class="room-title">
|
|
50
|
-
<div class="title-show" key="title-disabled-tip">
|
|
51
|
-
<div class="title">
|
|
52
|
-
<LockOutlined v-if="dataRef.is_lock == 1" class="locked" />
|
|
53
|
-
<span>{{ dataRef.title }}</span>
|
|
54
|
-
</div>
|
|
55
|
-
<span
|
|
56
|
-
v-if="checkable"
|
|
57
|
-
:class="dataRef.disabled ? 'text-gray' : 'text-primary'"
|
|
58
|
-
>
|
|
59
|
-
{{ dataRef.showArea }}㎡
|
|
60
|
-
</span>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</a-tooltip>
|
|
64
|
-
</template>
|
|
65
|
-
</a-tree>
|
|
66
|
-
</div>
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
69
|
-
|
|
70
|
-
<script>
|
|
71
|
-
import {
|
|
72
|
-
computed,
|
|
73
|
-
defineComponent,
|
|
74
|
-
nextTick,
|
|
75
|
-
reactive,
|
|
76
|
-
toRaw,
|
|
77
|
-
toRefs,
|
|
78
|
-
watch,
|
|
79
|
-
} from "vue";
|
|
80
|
-
import { LockOutlined, GoldenFilled } from "@ant-design/icons-vue";
|
|
81
|
-
import { message, Tree, Alert, Tooltip } from "ant-design-vue";
|
|
82
|
-
import BLIcon from "../BLIcon/index.js";
|
|
83
|
-
|
|
84
|
-
export default defineComponent({
|
|
85
|
-
name: "ChooseHousingResources",
|
|
86
|
-
components: {
|
|
87
|
-
GoldenFilled,
|
|
88
|
-
LockOutlined,
|
|
89
|
-
"bl-icon": BLIcon,
|
|
90
|
-
"a-tree": Tree,
|
|
91
|
-
"a-alert": Alert,
|
|
92
|
-
"a-tooltip": Tooltip,
|
|
93
|
-
},
|
|
94
|
-
props: {
|
|
95
|
-
// 是否追加组织架构层级部门
|
|
96
|
-
attachDpt: {
|
|
97
|
-
type: [Number, String],
|
|
98
|
-
default: 1,
|
|
99
|
-
},
|
|
100
|
-
// 是否只展示用户选中查看的项目楼宇 attachDpt为1时userChecked必为1
|
|
101
|
-
userChecked: {
|
|
102
|
-
type: [Number, String],
|
|
103
|
-
default: 1,
|
|
104
|
-
},
|
|
105
|
-
// alert提示语
|
|
106
|
-
alertTip: {
|
|
107
|
-
type: String,
|
|
108
|
-
default: "",
|
|
109
|
-
},
|
|
110
|
-
// 选择的类型级别: village build layer room
|
|
111
|
-
checkType: {
|
|
112
|
-
type: String,
|
|
113
|
-
default: "room",
|
|
114
|
-
},
|
|
115
|
-
// 不允许跨类型选择: village【不允许跨项目选择】 build【不允许跨楼层选择】 layer【不允许跨楼层选择】 不传为不限制
|
|
116
|
-
limitType: {
|
|
117
|
-
type: [String, null],
|
|
118
|
-
default: "",
|
|
119
|
-
},
|
|
120
|
-
// 是否禁选所有
|
|
121
|
-
allDisabled: {
|
|
122
|
-
type: Boolean,
|
|
123
|
-
default: false,
|
|
124
|
-
},
|
|
125
|
-
// 可租赁面积为0时是否禁选
|
|
126
|
-
areaEmptyDisabled: {
|
|
127
|
-
type: Boolean,
|
|
128
|
-
default: true,
|
|
129
|
-
},
|
|
130
|
-
// 默认选中房源
|
|
131
|
-
defaultChecked: {
|
|
132
|
-
type: Object,
|
|
133
|
-
default: () => ({
|
|
134
|
-
// villageList: [],
|
|
135
|
-
// buildList: [],
|
|
136
|
-
// layerList: [],
|
|
137
|
-
// roomList: [],
|
|
138
|
-
}),
|
|
139
|
-
},
|
|
140
|
-
// 默认选中房源改变 重新渲染
|
|
141
|
-
defaultCheckedChanged: {
|
|
142
|
-
type: [Number, Boolean],
|
|
143
|
-
default: 0,
|
|
144
|
-
},
|
|
145
|
-
// 默认选中房源id
|
|
146
|
-
defaultCheckedIds: {
|
|
147
|
-
type: Object,
|
|
148
|
-
default: () => ({
|
|
149
|
-
// villageId: 0,
|
|
150
|
-
// buildId: 0,
|
|
151
|
-
// layerId: 0,
|
|
152
|
-
// roomId: 0,
|
|
153
|
-
}),
|
|
154
|
-
},
|
|
155
|
-
// 只展示某个类型的项目,不传为展示所有类型的项目
|
|
156
|
-
villageType: {
|
|
157
|
-
type: String,
|
|
158
|
-
default: "",
|
|
159
|
-
},
|
|
160
|
-
// 重置
|
|
161
|
-
resetTrigger: {
|
|
162
|
-
type: Number,
|
|
163
|
-
default: 0,
|
|
164
|
-
},
|
|
165
|
-
// 是否可选
|
|
166
|
-
checkable: {
|
|
167
|
-
type: Boolean,
|
|
168
|
-
default: true,
|
|
169
|
-
},
|
|
170
|
-
// 条款类型 lease租赁条款 property物业条款
|
|
171
|
-
clauseType: {
|
|
172
|
-
type: String,
|
|
173
|
-
default: "",
|
|
174
|
-
},
|
|
175
|
-
// 是否只展示部分数据 0表示展示所有数据
|
|
176
|
-
getShowList: {
|
|
177
|
-
type: Number,
|
|
178
|
-
default: 0,
|
|
179
|
-
},
|
|
180
|
-
// 展示的部分数据
|
|
181
|
-
showList: {
|
|
182
|
-
type: Object,
|
|
183
|
-
default: () => ({
|
|
184
|
-
villageId: [], // village id集合
|
|
185
|
-
buildId: [], // build id集合
|
|
186
|
-
projectBuild: [], // {id, build,room} 房源关系和房间列表
|
|
187
|
-
}),
|
|
188
|
-
},
|
|
189
|
-
// 包含自己的面积的房源
|
|
190
|
-
includeAreaRoom: {
|
|
191
|
-
type: Object,
|
|
192
|
-
default: () => ({}),
|
|
193
|
-
},
|
|
194
|
-
},
|
|
195
|
-
setup(props, { emit }) {
|
|
196
|
-
// 打印方法
|
|
197
|
-
const CL = (key, value) => {
|
|
198
|
-
console.info(`$$$$$$$$$$$$----${key}`, toRaw(value));
|
|
199
|
-
};
|
|
200
|
-
// 是否展示组织架构层级
|
|
201
|
-
const showDpt = computed(() => props.attachDpt == 1);
|
|
202
|
-
|
|
203
|
-
const initState = {
|
|
204
|
-
// 展示的树数据
|
|
205
|
-
treeList: [],
|
|
206
|
-
originData: undefined,
|
|
207
|
-
// 树展开节点key值集合
|
|
208
|
-
initExpandKeys: [],
|
|
209
|
-
expandedKeys: [],
|
|
210
|
-
// 选中节点的key值集合
|
|
211
|
-
checkedKeys: [],
|
|
212
|
-
tempCheckedKeys: [],
|
|
213
|
-
// 当前选中的房间等所在的项目、楼宇、楼层id
|
|
214
|
-
currentCheck: {
|
|
215
|
-
villageId: 0,
|
|
216
|
-
buildId: 0,
|
|
217
|
-
layerId: 0,
|
|
218
|
-
},
|
|
219
|
-
deptVillageMap: {},
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
const state = reactive({
|
|
223
|
-
...initState,
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
/** 重置 */
|
|
227
|
-
watch(
|
|
228
|
-
() => props.resetTrigger,
|
|
229
|
-
() => {
|
|
230
|
-
reset();
|
|
231
|
-
}
|
|
232
|
-
);
|
|
233
|
-
const reset = () => {
|
|
234
|
-
state.expandedKeys = [...state.initExpandKeys];
|
|
235
|
-
state.checkedKeys = [];
|
|
236
|
-
state.tempCheckedKeys = [];
|
|
237
|
-
checkedIds = [];
|
|
238
|
-
state.currentCheck = { ...initState.currentCheck };
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* 只展示部分数据
|
|
243
|
-
* 监听 getShowList 变化,变化后重新设置treeList
|
|
244
|
-
* */
|
|
245
|
-
let getShowListLoadedTimes = 0;
|
|
246
|
-
watch(
|
|
247
|
-
() => props.getShowList,
|
|
248
|
-
(val) => {
|
|
249
|
-
if (getShowListLoadedTimes != val) {
|
|
250
|
-
getShowListLoadedTimes = val;
|
|
251
|
-
reset();
|
|
252
|
-
state.treeList = [];
|
|
253
|
-
if (val) {
|
|
254
|
-
filterTreeListByShowList();
|
|
255
|
-
} else {
|
|
256
|
-
nextTick(() => {
|
|
257
|
-
state.treeList = JSON.parse(state.originData);
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
);
|
|
263
|
-
const filterTreeListByShowList = () => {
|
|
264
|
-
const originData = JSON.parse(state.originData);
|
|
265
|
-
state.treeList = getShowList(originData);
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
let getShowListArr = [];
|
|
269
|
-
let showExpandedKeys = [];
|
|
270
|
-
const getShowListAfter = (type) => {
|
|
271
|
-
getShowListArr.push(type);
|
|
272
|
-
if (getShowListArr.length == 2) {
|
|
273
|
-
setDeptVillageMap();
|
|
274
|
-
nextTick(() => {
|
|
275
|
-
state.expandedKeys = [...state.expandedKeys, ...showExpandedKeys];
|
|
276
|
-
if (state.tempCheckedKeys.length) {
|
|
277
|
-
state.checkedKeys = [...state.tempCheckedKeys];
|
|
278
|
-
}
|
|
279
|
-
// 重置
|
|
280
|
-
getShowListArr = [];
|
|
281
|
-
showExpandedKeys = [];
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
const getShowList = (list) => {
|
|
286
|
-
let result = [];
|
|
287
|
-
if (!list.length) {
|
|
288
|
-
return result;
|
|
289
|
-
}
|
|
290
|
-
const childType = list[0].childType;
|
|
291
|
-
if (["build", "layer", "room"].includes(childType)) {
|
|
292
|
-
if (childType == "build") {
|
|
293
|
-
const { buildId } = props.showList;
|
|
294
|
-
// 楼宇
|
|
295
|
-
result = list.filter((item) => buildId.includes(item.id));
|
|
296
|
-
result.forEach((item, index) => {
|
|
297
|
-
getLayerList(item).then((layerList) => {
|
|
298
|
-
item.children = getShowList(layerList);
|
|
299
|
-
showExpandedKeys.push(item.key);
|
|
300
|
-
if (index == result.length - 1) {
|
|
301
|
-
// 获取楼层列表结束
|
|
302
|
-
getShowListAfter("layer");
|
|
303
|
-
}
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
} else {
|
|
307
|
-
const { projectBuild } = props.showList;
|
|
308
|
-
const vId = list[0].extra.village_id;
|
|
309
|
-
const vItem = projectBuild.find((item) => item.id == vId);
|
|
310
|
-
if (childType == "layer") {
|
|
311
|
-
// 楼层
|
|
312
|
-
const layerIds = vItem.room.map((item) => item.extra.layer_id);
|
|
313
|
-
result = list.filter((item) => layerIds.includes(item.id));
|
|
314
|
-
result.forEach((item, index) => {
|
|
315
|
-
getRoomList(item).then((roomList) => {
|
|
316
|
-
item.children = getShowList(roomList);
|
|
317
|
-
showExpandedKeys.push(item.key);
|
|
318
|
-
if (index == result.length - 1) {
|
|
319
|
-
// 获取房间列表结束
|
|
320
|
-
getShowListAfter("room");
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
} else {
|
|
325
|
-
// 房间
|
|
326
|
-
const roomIds = vItem.room.map((item) => item.id);
|
|
327
|
-
result = list.filter((item) => roomIds.includes(item.id));
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
} else {
|
|
331
|
-
// 部门 或者 项目
|
|
332
|
-
const { villageId } = props.showList;
|
|
333
|
-
for (let item of list) {
|
|
334
|
-
if (item.childType == "department") {
|
|
335
|
-
item.children = getShowList(item.children);
|
|
336
|
-
if (item.children.length) {
|
|
337
|
-
result.push(item);
|
|
338
|
-
}
|
|
339
|
-
} else if (item.childType == "village") {
|
|
340
|
-
if (villageId.includes(item.id)) {
|
|
341
|
-
item.children = getShowList(item.children);
|
|
342
|
-
result.push(item);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return result;
|
|
348
|
-
};
|
|
349
|
-
|
|
350
|
-
/************* 选中房源 --start **************/
|
|
351
|
-
// 未选中任何房源
|
|
352
|
-
// 选中的房源id
|
|
353
|
-
let checkedIds = {
|
|
354
|
-
// village: new Set(),
|
|
355
|
-
// build: new Set(),
|
|
356
|
-
// layer: new Set(),
|
|
357
|
-
// room: new Set(),
|
|
358
|
-
};
|
|
359
|
-
const handleTreeCheck = (checkedKeys, e) => {
|
|
360
|
-
CL("handleTreeCheck checkedKeys", checkedKeys);
|
|
361
|
-
CL("handleTreeCheck ", e);
|
|
362
|
-
const { checked } = e;
|
|
363
|
-
if (checked) {
|
|
364
|
-
// 选中
|
|
365
|
-
const idsResult = getIdsByCheckedKeys(checkedKeys);
|
|
366
|
-
if (!checkedIds.village || canCheck(idsResult)) {
|
|
367
|
-
checkedIds = idsResult;
|
|
368
|
-
state.checkedKeys = checkedKeys;
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
if (!checkedKeys.length) {
|
|
372
|
-
checkedIds = {};
|
|
373
|
-
}
|
|
374
|
-
state.checkedKeys = checkedKeys;
|
|
375
|
-
}
|
|
376
|
-
};
|
|
377
|
-
// 根据key值获取id
|
|
378
|
-
const getIdsByCheckedKeys = (checkedKeys) => {
|
|
379
|
-
let result = {
|
|
380
|
-
village: new Set(),
|
|
381
|
-
build: new Set(),
|
|
382
|
-
layer: new Set(),
|
|
383
|
-
room: new Set(),
|
|
384
|
-
};
|
|
385
|
-
for (let key of checkedKeys) {
|
|
386
|
-
const keyArr = key.split("_");
|
|
387
|
-
result.village.add(Number(keyArr[1]));
|
|
388
|
-
if (keyArr[3]) {
|
|
389
|
-
result.build.add(Number(keyArr[3]));
|
|
390
|
-
}
|
|
391
|
-
if (keyArr[5]) {
|
|
392
|
-
result.layer.add(Number(keyArr[5]));
|
|
393
|
-
}
|
|
394
|
-
if (keyArr[7]) {
|
|
395
|
-
result.room.add(Number(keyArr[7]));
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
CL("getIdsByCheckedKeys result", result);
|
|
399
|
-
return result;
|
|
400
|
-
};
|
|
401
|
-
// 房源是否可选
|
|
402
|
-
const canCheck = (newcheckedIds) => {
|
|
403
|
-
if (props.limitType) {
|
|
404
|
-
// 不能跨项目选择房源
|
|
405
|
-
if (newcheckedIds.village.size > 1) {
|
|
406
|
-
message.warning("不能跨项目选择房源!");
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
// 不能跨楼宇选择房源
|
|
410
|
-
if (props.limitType === "build" && newcheckedIds.build.size > 1) {
|
|
411
|
-
message.warning("不能跨楼宇选择房源!");
|
|
412
|
-
return false;
|
|
413
|
-
}
|
|
414
|
-
// 不能跨楼层选择房源
|
|
415
|
-
if (props.limitType === "layer" && newcheckedIds.layer.size > 1) {
|
|
416
|
-
message.warning("不能跨楼层选择房源!");
|
|
417
|
-
return false;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return true;
|
|
421
|
-
};
|
|
422
|
-
// 整理出选择的village build layer room信息
|
|
423
|
-
let emitIdsTimeout = null;
|
|
424
|
-
watch(
|
|
425
|
-
() => state.checkedKeys,
|
|
426
|
-
() => {
|
|
427
|
-
if (emitIdsTimeout) {
|
|
428
|
-
clearTimeout(emitIdsTimeout);
|
|
429
|
-
emitIdsTimeout = null;
|
|
430
|
-
}
|
|
431
|
-
emitIdsTimeout = setTimeout(() => {
|
|
432
|
-
getCheckedInfoByKeys();
|
|
433
|
-
}, 800);
|
|
434
|
-
}
|
|
435
|
-
);
|
|
436
|
-
|
|
437
|
-
const emitResult = (result) => {
|
|
438
|
-
CL("emitResult====", result);
|
|
439
|
-
emit("getResult", result);
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const getCheckedInfoByKeys = () => {
|
|
443
|
-
let result = {
|
|
444
|
-
villageList: [], // 选中项目以及下面所有的房源
|
|
445
|
-
buildList: [], // 选中楼宇以及下面所有的房源
|
|
446
|
-
layerList: [], // 选中楼层以及下面所有的房源
|
|
447
|
-
roomList: [],
|
|
448
|
-
};
|
|
449
|
-
if (!state.checkedKeys.length) {
|
|
450
|
-
emitResult(result);
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
let initKeys = [...state.checkedKeys];
|
|
454
|
-
let checkedKeys = getInitKeys(initKeys, "village");
|
|
455
|
-
let villageList = state.treeList;
|
|
456
|
-
const setResult = (key, value) => {
|
|
457
|
-
result[key].push(value);
|
|
458
|
-
let totalLength = 0;
|
|
459
|
-
for (let key in result) {
|
|
460
|
-
totalLength += result[key].length;
|
|
461
|
-
}
|
|
462
|
-
CL("setResult", totalLength);
|
|
463
|
-
if (checkedKeys.length == totalLength) {
|
|
464
|
-
CL("setResult getCheckedInfoByCheckType before", result);
|
|
465
|
-
getCheckedInfoByCheckType(result).then((newResult) => {
|
|
466
|
-
emitResult(newResult);
|
|
467
|
-
});
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
let villageMap = {};
|
|
471
|
-
for (let key of checkedKeys) {
|
|
472
|
-
let arrKey = [];
|
|
473
|
-
if (showDpt.value) {
|
|
474
|
-
arrKey = key.split("-");
|
|
475
|
-
villageList = state.deptVillageMap[arrKey[1]];
|
|
476
|
-
}
|
|
477
|
-
arrKey = key.split("_");
|
|
478
|
-
// 找到对应village
|
|
479
|
-
const villageId = Number(arrKey[1]);
|
|
480
|
-
let village = villageMap[villageId];
|
|
481
|
-
if (!village) {
|
|
482
|
-
village = villageMap[villageId] = villageList.find(
|
|
483
|
-
(item) => item.id == villageId
|
|
484
|
-
);
|
|
485
|
-
}
|
|
486
|
-
if (arrKey.length == 2) {
|
|
487
|
-
// 选中项目
|
|
488
|
-
setResult("villageList", village);
|
|
489
|
-
} else {
|
|
490
|
-
const buildId = Number(arrKey[3]);
|
|
491
|
-
const build = village.children.find((item) => item.id == buildId);
|
|
492
|
-
if (arrKey.length == 4) {
|
|
493
|
-
// 选中楼宇
|
|
494
|
-
setResult("buildList", build);
|
|
495
|
-
} else {
|
|
496
|
-
const layerId = Number(arrKey[5]);
|
|
497
|
-
getLayerList(build).then((layerList) => {
|
|
498
|
-
const layer = layerList.find((item) => item.id == layerId);
|
|
499
|
-
if (arrKey.length == 6) {
|
|
500
|
-
setResult("layerList", layer);
|
|
501
|
-
} else {
|
|
502
|
-
const roomId = Number(arrKey[7]);
|
|
503
|
-
getRoomList(layer).then((roomList) => {
|
|
504
|
-
const room = roomList.find((item) => item.id == roomId);
|
|
505
|
-
setResult("roomList", room);
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
});
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
|
|
514
|
-
const fKeyMap = { village: "build", build: "layer", layer: "room" };
|
|
515
|
-
const getInitKeys = (initKeys, type = "village") => {
|
|
516
|
-
let filterKeys = [];
|
|
517
|
-
let fKey = fKeyMap[type];
|
|
518
|
-
if (initKeys.length) {
|
|
519
|
-
if (fKey) {
|
|
520
|
-
filterKeys = initKeys.filter((item) => item.indexOf(fKey) === -1);
|
|
521
|
-
if (filterKeys.length) {
|
|
522
|
-
filterKeys.forEach((key) => {
|
|
523
|
-
initKeys = initKeys.filter((item) => item.indexOf(key) === -1);
|
|
524
|
-
});
|
|
525
|
-
}
|
|
526
|
-
const result = getInitKeys(initKeys, fKey);
|
|
527
|
-
filterKeys = [...filterKeys, ...result];
|
|
528
|
-
} else {
|
|
529
|
-
// type = room
|
|
530
|
-
filterKeys = [...filterKeys, ...initKeys];
|
|
531
|
-
initKeys = [];
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
return filterKeys;
|
|
535
|
-
};
|
|
536
|
-
// 数据具体到 checkType
|
|
537
|
-
const getCheckedInfoByCheckType = (result) => {
|
|
538
|
-
return new Promise((resolve) => {
|
|
539
|
-
if (
|
|
540
|
-
!props.checkType ||
|
|
541
|
-
props.checkType == "village" ||
|
|
542
|
-
props.checkType == "build"
|
|
543
|
-
) {
|
|
544
|
-
resolve(result);
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
if (result.villageList.length) {
|
|
548
|
-
result.villageList.forEach((village) => {
|
|
549
|
-
result.buildList = [...result.buildList, ...village.children];
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
const getRoom = () => {
|
|
553
|
-
if (result.layerList.length) {
|
|
554
|
-
result.layerList.forEach((layer, layerIndex) => {
|
|
555
|
-
getRoomList(layer).then((roomList) => {
|
|
556
|
-
if (roomList && roomList.length) {
|
|
557
|
-
const list = roomList.filter((item) => !item.disabled);
|
|
558
|
-
result.roomList = [...result.roomList, ...list];
|
|
559
|
-
}
|
|
560
|
-
if (layerIndex == result.layerList.length - 1) {
|
|
561
|
-
resolve(result);
|
|
562
|
-
}
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
} else {
|
|
566
|
-
resolve(result);
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
if (result.buildList.length) {
|
|
570
|
-
result.buildList.forEach((build, buildIndex) => {
|
|
571
|
-
getLayerList(build).then((layerList) => {
|
|
572
|
-
if (layerList && layerList.length) {
|
|
573
|
-
const list = layerList.filter((item) => !item.disabled);
|
|
574
|
-
result.layerList = [...result.layerList, ...list];
|
|
575
|
-
}
|
|
576
|
-
if (buildIndex == result.buildList.length - 1) {
|
|
577
|
-
if (props.checkType == "room") {
|
|
578
|
-
getRoom();
|
|
579
|
-
} else {
|
|
580
|
-
resolve(result);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
} else {
|
|
586
|
-
getRoom();
|
|
587
|
-
}
|
|
588
|
-
});
|
|
589
|
-
};
|
|
590
|
-
/************* 选中房源 --end **************/
|
|
591
|
-
|
|
592
|
-
/************* 动态获取楼层、房间 --start **************/
|
|
593
|
-
const onLoadTreeData = (treeNode) => {
|
|
594
|
-
return new Promise((resolve) => {
|
|
595
|
-
CL("onLoadTreeData treeNode", treeNode);
|
|
596
|
-
const { dataRef } = treeNode;
|
|
597
|
-
if (dataRef.isLeaf || (dataRef.children && dataRef.children.length)) {
|
|
598
|
-
resolve();
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
// const success = (result) => {
|
|
602
|
-
// resolve();
|
|
603
|
-
// };
|
|
604
|
-
if (dataRef.childType === "build") {
|
|
605
|
-
getLayerList(dataRef).then(() => {
|
|
606
|
-
resolve();
|
|
607
|
-
});
|
|
608
|
-
} else if (dataRef.childType === "layer") {
|
|
609
|
-
getRoomList(dataRef).then(() => {
|
|
610
|
-
resolve();
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
});
|
|
614
|
-
};
|
|
615
|
-
// 获取楼层列表
|
|
616
|
-
const getLayerList = (build) => {
|
|
617
|
-
return new Promise((resolve) => {
|
|
618
|
-
if (build.isLeaf || (build.children && build.children.length)) {
|
|
619
|
-
resolve(build.children || []);
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
emit("request", {
|
|
623
|
-
params: {
|
|
624
|
-
method: "get",
|
|
625
|
-
server: "/village",
|
|
626
|
-
url: "/project/layer/all",
|
|
627
|
-
extra: {
|
|
628
|
-
build_id: build.id,
|
|
629
|
-
},
|
|
630
|
-
},
|
|
631
|
-
success: (res) => {
|
|
632
|
-
if (res.list.length) {
|
|
633
|
-
build.children = res.list.map((item) => ({
|
|
634
|
-
...item,
|
|
635
|
-
childType: "layer",
|
|
636
|
-
key: `${build.key}_layer_${item.id}`,
|
|
637
|
-
title: item.layer_name,
|
|
638
|
-
level: build.level + 1,
|
|
639
|
-
disableCheckbox: props.limitType == "room",
|
|
640
|
-
extra: {
|
|
641
|
-
...build.extra,
|
|
642
|
-
build_id: build.id,
|
|
643
|
-
build_number: build.build_number,
|
|
644
|
-
build_name: build.build_name,
|
|
645
|
-
},
|
|
646
|
-
isLeaf: props.checkType == "layer",
|
|
647
|
-
slots: {
|
|
648
|
-
icon: "layerIcon",
|
|
649
|
-
},
|
|
650
|
-
}));
|
|
651
|
-
} else {
|
|
652
|
-
build.isLeaf = true;
|
|
653
|
-
}
|
|
654
|
-
resolve(build.children);
|
|
655
|
-
},
|
|
656
|
-
});
|
|
657
|
-
});
|
|
658
|
-
};
|
|
659
|
-
// 获取房间列表
|
|
660
|
-
const getRoomList = (layer) => {
|
|
661
|
-
return new Promise((resolve) => {
|
|
662
|
-
if (layer.isLeaf || (layer.children && layer.children.length)) {
|
|
663
|
-
resolve(layer.children || []);
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
emit("request", {
|
|
667
|
-
params: {
|
|
668
|
-
method: "get",
|
|
669
|
-
server: "/village",
|
|
670
|
-
url: "/project/room/all",
|
|
671
|
-
extra: {
|
|
672
|
-
village_id: layer.extra.village_id,
|
|
673
|
-
layer_id: layer.id,
|
|
674
|
-
},
|
|
675
|
-
},
|
|
676
|
-
success: (res) => {
|
|
677
|
-
if (res.list.length) {
|
|
678
|
-
layer.children = res.list.map((item) => {
|
|
679
|
-
let newItem = {
|
|
680
|
-
...item,
|
|
681
|
-
childType: "room",
|
|
682
|
-
key: `${layer.key}_room_${item.id}`,
|
|
683
|
-
title: item.room_name,
|
|
684
|
-
level: layer.level + 1,
|
|
685
|
-
layer_id: layer.id,
|
|
686
|
-
layer_number: layer.layer_number,
|
|
687
|
-
layer_name: layer.layer_name,
|
|
688
|
-
property_area: item.charging_area,
|
|
689
|
-
lease_square: item.rental_area,
|
|
690
|
-
extra: {
|
|
691
|
-
...layer.extra,
|
|
692
|
-
layer_id: layer.id,
|
|
693
|
-
layer_number: layer.layer_number,
|
|
694
|
-
layer_name: layer.layer_name,
|
|
695
|
-
},
|
|
696
|
-
isLeaf: true,
|
|
697
|
-
slots: {
|
|
698
|
-
icon: "roomIcon",
|
|
699
|
-
title: "roomTitle",
|
|
700
|
-
},
|
|
701
|
-
};
|
|
702
|
-
// 展示的可租赁面积
|
|
703
|
-
newItem.showArea =
|
|
704
|
-
props.clauseType == "property" && newItem.charging_area
|
|
705
|
-
? Number(newItem.charging_area)
|
|
706
|
-
: Number(newItem.rental_area);
|
|
707
|
-
if (newItem.rent_area) {
|
|
708
|
-
const rentArea =
|
|
709
|
-
props.clauseType == "property" &&
|
|
710
|
-
newItem.rent_area.property_square
|
|
711
|
-
? newItem.rent_area.property_square
|
|
712
|
-
: newItem.rent_area.lease_square;
|
|
713
|
-
newItem.showArea = Number(
|
|
714
|
-
Number(newItem.showArea) - Number(rentArea)
|
|
715
|
-
);
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
if (props.includeAreaRoom[newItem.id]) {
|
|
719
|
-
newItem.rentedArea = props.includeAreaRoom[newItem.id];
|
|
720
|
-
newItem.showArea =
|
|
721
|
-
newItem.showArea + Number(newItem.rentedArea.lease);
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
// 禁用以及禁用提示
|
|
725
|
-
if (props.checkable) {
|
|
726
|
-
if (props.areaEmptyDisabled && !newItem.showArea) {
|
|
727
|
-
newItem.disabled = true;
|
|
728
|
-
newItem.disabledTip = "当前房间可租面积为0,请选择其他房间";
|
|
729
|
-
}
|
|
730
|
-
if (newItem.is_lock == 1) {
|
|
731
|
-
newItem.disabled = true;
|
|
732
|
-
newItem.disabledTip = newItem.lock_reason;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
return newItem;
|
|
736
|
-
});
|
|
737
|
-
} else {
|
|
738
|
-
layer.isLeaf = true;
|
|
739
|
-
}
|
|
740
|
-
resolve(layer.children);
|
|
741
|
-
},
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
/************* 动态获取楼层、房间 --end **************/
|
|
747
|
-
|
|
748
|
-
/************* 根据项目类型筛选项目 --start **************/
|
|
749
|
-
watch(
|
|
750
|
-
() => props.villageType,
|
|
751
|
-
() => {
|
|
752
|
-
state.checkedKeys = [];
|
|
753
|
-
filterVillageByType();
|
|
754
|
-
}
|
|
755
|
-
);
|
|
756
|
-
const filterVillageByType = () => {
|
|
757
|
-
if (!state.originData || !state.treeList.length) {
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
if (props.villageType) {
|
|
761
|
-
if (showDpt.value) {
|
|
762
|
-
state.treeList = filterDeptVillageByType(state.treeList);
|
|
763
|
-
} else {
|
|
764
|
-
let originData = JSON.parse(state.originData);
|
|
765
|
-
state.treeList = originData.filter(
|
|
766
|
-
(item) => item.type == props.villageType
|
|
767
|
-
);
|
|
768
|
-
}
|
|
769
|
-
} else {
|
|
770
|
-
state.treeList = JSON.parse(state.originData);
|
|
771
|
-
}
|
|
772
|
-
emitTreeList();
|
|
773
|
-
};
|
|
774
|
-
const filterDeptVillageByType = (list) => {
|
|
775
|
-
let result = [];
|
|
776
|
-
for (let item of list) {
|
|
777
|
-
if (item.childType != "village" || item.type == props.villageType) {
|
|
778
|
-
result.push(item);
|
|
779
|
-
if (item.children && item.children.length) {
|
|
780
|
-
item.children = filterDeptVillageByType(item.children);
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
return result;
|
|
785
|
-
};
|
|
786
|
-
/************* 根据项目类型筛选项目 --end **************/
|
|
787
|
-
|
|
788
|
-
/************* 设置默认选中房源 --start **************/
|
|
789
|
-
watch(
|
|
790
|
-
() => props.defaultCheckedChanged,
|
|
791
|
-
() => {
|
|
792
|
-
reset();
|
|
793
|
-
setDefaultChecked();
|
|
794
|
-
}
|
|
795
|
-
);
|
|
796
|
-
|
|
797
|
-
watch(
|
|
798
|
-
() => props.defaultChecked,
|
|
799
|
-
() => {
|
|
800
|
-
if (!state.checkedKeys.length) {
|
|
801
|
-
setDefaultChecked(1);
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
);
|
|
805
|
-
|
|
806
|
-
watch(
|
|
807
|
-
() => props.defaultCheckedIds,
|
|
808
|
-
() => {
|
|
809
|
-
if (!state.checkedKeys.length) {
|
|
810
|
-
setDefaultChecked(2);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
);
|
|
814
|
-
|
|
815
|
-
// 默认选中参数是否为空
|
|
816
|
-
const defaultCheckedNotEmpty = (type = 1) => {
|
|
817
|
-
const checked =
|
|
818
|
-
type == 1 ? props.defaultChecked : props.defaultCheckedIds;
|
|
819
|
-
for (let key in checked) {
|
|
820
|
-
if (
|
|
821
|
-
(type == 1 && checked[key] && checked[key].length) ||
|
|
822
|
-
(type == 2 && checked[key])
|
|
823
|
-
) {
|
|
824
|
-
return true;
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
return false;
|
|
828
|
-
};
|
|
829
|
-
// 设置默认选中
|
|
830
|
-
const setDefaultChecked = (type = 0) => {
|
|
831
|
-
if (!state.treeList.length) {
|
|
832
|
-
return;
|
|
833
|
-
}
|
|
834
|
-
nextTick(() => {
|
|
835
|
-
if (!type || type == 1) {
|
|
836
|
-
setDefaultListChecked();
|
|
837
|
-
}
|
|
838
|
-
if (!type || type == 2) {
|
|
839
|
-
setDefaultIdsChecked();
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
};
|
|
843
|
-
// 根据房源列表选中房源
|
|
844
|
-
const setDefaultListChecked = () => {
|
|
845
|
-
if (!defaultCheckedNotEmpty(1)) {
|
|
846
|
-
return;
|
|
847
|
-
}
|
|
848
|
-
const { defaultChecked } = props;
|
|
849
|
-
CL("setDefaultChecked defaultChecked", toRaw(defaultChecked));
|
|
850
|
-
CL("setDefaultChecked deptVillageMap", toRaw(state.deptVillageMap));
|
|
851
|
-
const checkedKeys = [];
|
|
852
|
-
const expandedKeys = [];
|
|
853
|
-
let loadedVillage = {};
|
|
854
|
-
for (let key in defaultChecked) {
|
|
855
|
-
if (defaultChecked[key].length) {
|
|
856
|
-
defaultChecked[key].forEach((dcItem) => {
|
|
857
|
-
if (dcItem.extra) {
|
|
858
|
-
dcItem = {
|
|
859
|
-
...dcItem,
|
|
860
|
-
...dcItem.extra,
|
|
861
|
-
};
|
|
862
|
-
}
|
|
863
|
-
let itemKey = "";
|
|
864
|
-
let villageId =
|
|
865
|
-
key == "villageList" ? dcItem.id : dcItem.village_id;
|
|
866
|
-
if (key == "buildList" && !dcItem.village_id) {
|
|
867
|
-
// 只知道楼宇id不知道项目id
|
|
868
|
-
villageId = getVillageByBuildId(dcItem.id);
|
|
869
|
-
}
|
|
870
|
-
if (!villageId) {
|
|
871
|
-
emitError();
|
|
872
|
-
return;
|
|
873
|
-
}
|
|
874
|
-
let result = loadedVillage[villageId];
|
|
875
|
-
if (!result) {
|
|
876
|
-
result = loadedVillage[villageId] = getVillageById(villageId);
|
|
877
|
-
}
|
|
878
|
-
if (!result) {
|
|
879
|
-
emitError();
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
itemKey = result.depId
|
|
883
|
-
? `department-${result.depId}-village_${villageId}`
|
|
884
|
-
: `village_${villageId}`;
|
|
885
|
-
if (key != "villageList") {
|
|
886
|
-
// 楼栋+
|
|
887
|
-
const buildId = key == "buildList" ? dcItem.id : dcItem.build_id;
|
|
888
|
-
itemKey = `${itemKey}_build_${buildId}`;
|
|
889
|
-
if (key != "buildList") {
|
|
890
|
-
// 楼层+
|
|
891
|
-
if (!expandedKeys.includes(itemKey)) {
|
|
892
|
-
expandedKeys.push(itemKey);
|
|
893
|
-
}
|
|
894
|
-
const layerId =
|
|
895
|
-
key == "layerList" ? dcItem.id : dcItem.layer_id;
|
|
896
|
-
itemKey = `${itemKey}_layer_${layerId}`;
|
|
897
|
-
if (key != "layerList") {
|
|
898
|
-
// 选中房间
|
|
899
|
-
if (!expandedKeys.includes(itemKey)) {
|
|
900
|
-
expandedKeys.push(itemKey);
|
|
901
|
-
}
|
|
902
|
-
const roomId = dcItem.id;
|
|
903
|
-
itemKey = `${itemKey}_room_${roomId}`;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
}
|
|
907
|
-
checkedKeys.push(itemKey);
|
|
908
|
-
});
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
|
|
912
|
-
if (checkedKeys.length) {
|
|
913
|
-
nextTick(() => {
|
|
914
|
-
if (props.getShowList) {
|
|
915
|
-
state.tempCheckedKeys = [...state.tempCheckedKeys, ...checkedKeys];
|
|
916
|
-
} else {
|
|
917
|
-
state.checkedKeys = [...checkedKeys];
|
|
918
|
-
state.expandedKeys = [...state.expandedKeys, ...expandedKeys];
|
|
919
|
-
}
|
|
920
|
-
CL("setDefaultChecked checkedKeys", toRaw(state.checkedKeys));
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
};
|
|
924
|
-
|
|
925
|
-
const emitError = (type = "notFound", msg = "未查找到该房源") => {
|
|
926
|
-
emit("error", {
|
|
927
|
-
type,
|
|
928
|
-
msg,
|
|
929
|
-
});
|
|
930
|
-
};
|
|
931
|
-
|
|
932
|
-
// 根据id选中房源
|
|
933
|
-
const setDefaultIdsChecked = () => {
|
|
934
|
-
if (!defaultCheckedNotEmpty(2)) {
|
|
935
|
-
return;
|
|
936
|
-
}
|
|
937
|
-
const { defaultCheckedIds } = props;
|
|
938
|
-
const expandedKeys = [];
|
|
939
|
-
const checkedKeys = [];
|
|
940
|
-
if (defaultCheckedIds.villageId) {
|
|
941
|
-
let itemKey = "";
|
|
942
|
-
const result = getVillageById(defaultCheckedIds.villageId);
|
|
943
|
-
if (!result) {
|
|
944
|
-
emitError();
|
|
945
|
-
return;
|
|
946
|
-
}
|
|
947
|
-
itemKey = result.depId
|
|
948
|
-
? `department-${result.depId}-village_${defaultCheckedIds.villageId}`
|
|
949
|
-
: `village_${defaultCheckedIds.villageId}`;
|
|
950
|
-
if (defaultCheckedIds.buildId) {
|
|
951
|
-
itemKey = `${itemKey}_build_${defaultCheckedIds.buildId}`;
|
|
952
|
-
if (defaultCheckedIds.layerId) {
|
|
953
|
-
expandedKeys.push(itemKey);
|
|
954
|
-
itemKey = `${itemKey}_layer_${defaultCheckedIds.layerId}`;
|
|
955
|
-
if (defaultCheckedIds.roomId) {
|
|
956
|
-
expandedKeys.push(itemKey);
|
|
957
|
-
itemKey = `${itemKey}_room_${defaultCheckedIds.roomId}`;
|
|
958
|
-
}
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
checkedKeys.push(itemKey);
|
|
962
|
-
}
|
|
963
|
-
if (checkedKeys.length) {
|
|
964
|
-
nextTick(() => {
|
|
965
|
-
if (props.getShowList) {
|
|
966
|
-
state.tempCheckedKeys = [...state.tempCheckedKeys, ...checkedKeys];
|
|
967
|
-
} else {
|
|
968
|
-
state.checkedKeys = [...checkedKeys];
|
|
969
|
-
state.expandedKeys = [...state.expandedKeys, ...expandedKeys];
|
|
970
|
-
}
|
|
971
|
-
CL("setDefaultChecked checkedKeys", toRaw(state.checkedKeys));
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
// 根据项目id获取项目信息
|
|
976
|
-
const getVillageById = (villageId) => {
|
|
977
|
-
if (showDpt.value) {
|
|
978
|
-
for (let depId in state.deptVillageMap) {
|
|
979
|
-
const village = state.deptVillageMap[depId].find(
|
|
980
|
-
(item) => item.id == villageId
|
|
981
|
-
);
|
|
982
|
-
if (village) {
|
|
983
|
-
return {
|
|
984
|
-
village,
|
|
985
|
-
depId,
|
|
986
|
-
};
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
} else {
|
|
990
|
-
const village = state.treeList.find((item) => item.id == villageId);
|
|
991
|
-
return {
|
|
992
|
-
village,
|
|
993
|
-
depId: 0,
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
};
|
|
997
|
-
// 根据楼宇id查找项目id
|
|
998
|
-
const getVillageByBuildId = (buildId) => {
|
|
999
|
-
if (showDpt.value) {
|
|
1000
|
-
for (let depId in state.deptVillageMap) {
|
|
1001
|
-
const villageList = state.deptVillageMap[depId];
|
|
1002
|
-
if (villageList && villageList.length) {
|
|
1003
|
-
for (let village of villageList) {
|
|
1004
|
-
if (village.children && village.children.length) {
|
|
1005
|
-
const build = village.children.find((b) => b.id == buildId);
|
|
1006
|
-
if (build) {
|
|
1007
|
-
return village.id;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
} else {
|
|
1014
|
-
for (let village of state.treeList) {
|
|
1015
|
-
if (village.children && village.children.length) {
|
|
1016
|
-
const build = village.children.find((b) => b.id == buildId);
|
|
1017
|
-
if (build) {
|
|
1018
|
-
return village.id;
|
|
1019
|
-
}
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
return 0;
|
|
1024
|
-
};
|
|
1025
|
-
|
|
1026
|
-
/************* 设置默认选中房源 --end **************/
|
|
1027
|
-
|
|
1028
|
-
/************* 获取树数据 --start **************/
|
|
1029
|
-
const emitTreeList = () => {
|
|
1030
|
-
// 过滤treeList
|
|
1031
|
-
if (props.getShowList && getShowListLoadedTimes != props.getShowList) {
|
|
1032
|
-
getShowListLoadedTimes = props.getShowList;
|
|
1033
|
-
filterTreeListByShowList();
|
|
1034
|
-
}
|
|
1035
|
-
// 默认选中值
|
|
1036
|
-
setDefaultChecked();
|
|
1037
|
-
// 最终treeList
|
|
1038
|
-
emit("getTree", {
|
|
1039
|
-
list: state.treeList,
|
|
1040
|
-
oList: JSON.parse(state.originData),
|
|
1041
|
-
});
|
|
1042
|
-
CL("treeList", state.treeList);
|
|
1043
|
-
};
|
|
1044
|
-
|
|
1045
|
-
const setDeptVillageMap = () => {
|
|
1046
|
-
state.deptVillageMap = {};
|
|
1047
|
-
if (showDpt.value) {
|
|
1048
|
-
getDeptMap(state.treeList);
|
|
1049
|
-
}
|
|
1050
|
-
};
|
|
1051
|
-
const getDeptMap = (list) => {
|
|
1052
|
-
for (let item of list) {
|
|
1053
|
-
if (
|
|
1054
|
-
item.childType == "department" &&
|
|
1055
|
-
item.children &&
|
|
1056
|
-
item.children.length
|
|
1057
|
-
) {
|
|
1058
|
-
const villageList = item.children.filter(
|
|
1059
|
-
(it) => it.childType == "village"
|
|
1060
|
-
);
|
|
1061
|
-
if (villageList.length) {
|
|
1062
|
-
state.deptVillageMap[item.id] = villageList;
|
|
1063
|
-
}
|
|
1064
|
-
getDeptMap(item.children);
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
};
|
|
1068
|
-
// ------case 1
|
|
1069
|
-
const getDeptAndVillageTree = (list) => {
|
|
1070
|
-
state.treeList = getDeptTreeList(list, 1);
|
|
1071
|
-
state.originData = JSON.stringify(state.treeList);
|
|
1072
|
-
filterVillageByType();
|
|
1073
|
-
};
|
|
1074
|
-
// 获取部门树列表
|
|
1075
|
-
const getDeptTreeList = (list, level) => {
|
|
1076
|
-
let result = [];
|
|
1077
|
-
for (let listItem of list) {
|
|
1078
|
-
// 非项目管理部门
|
|
1079
|
-
if (listItem.type !== 3) {
|
|
1080
|
-
listItem.childType = "department"; //listItem.type == 0 ? "topCompany" : "department";
|
|
1081
|
-
listItem.key = `${listItem.childType}-${listItem.id}`; // 部门用中划线,房源用下划线,方便整理选中房源key
|
|
1082
|
-
listItem.title = listItem.name;
|
|
1083
|
-
listItem.level = level;
|
|
1084
|
-
listItem.disableCheckbox = true;
|
|
1085
|
-
listItem.slots = {
|
|
1086
|
-
icon: `${listItem.childType}Icon`,
|
|
1087
|
-
};
|
|
1088
|
-
listItem.children = [];
|
|
1089
|
-
if (listItem.subcat && listItem.subcat.length) {
|
|
1090
|
-
listItem.children = getDeptTreeList(listItem.subcat, level + 1);
|
|
1091
|
-
}
|
|
1092
|
-
if (listItem.villageList && listItem.villageList.length) {
|
|
1093
|
-
const villageList = getVillageTreeList(
|
|
1094
|
-
listItem.villageList,
|
|
1095
|
-
level,
|
|
1096
|
-
listItem.key
|
|
1097
|
-
);
|
|
1098
|
-
state.deptVillageMap[listItem.id] = villageList;
|
|
1099
|
-
listItem.children = [...listItem.children, ...villageList];
|
|
1100
|
-
}
|
|
1101
|
-
listItem.isLeaf = listItem.children.length === 0;
|
|
1102
|
-
result.push(listItem);
|
|
1103
|
-
state.expandedKeys.push(listItem.key);
|
|
1104
|
-
state.initExpandKeys.push(listItem.key);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
return result;
|
|
1108
|
-
};
|
|
1109
|
-
// 获取项目树列表
|
|
1110
|
-
const getVillageTreeList = (villageList, level = 1, parentKey) => {
|
|
1111
|
-
return villageList.map((village) => {
|
|
1112
|
-
village.childType = "village";
|
|
1113
|
-
village.key = `${parentKey ? parentKey + "-" : ""}${
|
|
1114
|
-
village.childType
|
|
1115
|
-
}_${village.id}`;
|
|
1116
|
-
village.title = village.name;
|
|
1117
|
-
village.level = level;
|
|
1118
|
-
village.disableCheckbox = !!props.limitType;
|
|
1119
|
-
village.slots = {
|
|
1120
|
-
icon: `${village.childType}Icon`,
|
|
1121
|
-
};
|
|
1122
|
-
if (props.checkType == village.childType) {
|
|
1123
|
-
village.isLeaf = true;
|
|
1124
|
-
} else {
|
|
1125
|
-
if (village.buildList && village.buildList.length) {
|
|
1126
|
-
village.isLeaf = false;
|
|
1127
|
-
village.children = village.buildList.map((build) => ({
|
|
1128
|
-
...build,
|
|
1129
|
-
level,
|
|
1130
|
-
childType: "build",
|
|
1131
|
-
key: `${village.key}_build_${build.id}`,
|
|
1132
|
-
title: build.build_name,
|
|
1133
|
-
disableCheckbox:
|
|
1134
|
-
props.limitType == "layer" || props.limitType == "room",
|
|
1135
|
-
extra: {
|
|
1136
|
-
village_id: village.id,
|
|
1137
|
-
village_name: village.name,
|
|
1138
|
-
village_short_name: village.short_name,
|
|
1139
|
-
},
|
|
1140
|
-
slots: {
|
|
1141
|
-
icon: "buildIcon",
|
|
1142
|
-
},
|
|
1143
|
-
isLeaf: props.checkType == "build",
|
|
1144
|
-
}));
|
|
1145
|
-
} else {
|
|
1146
|
-
village.isLeaf = true;
|
|
1147
|
-
}
|
|
1148
|
-
state.expandedKeys.push(village.key);
|
|
1149
|
-
state.initExpandKeys.push(village.key);
|
|
1150
|
-
}
|
|
1151
|
-
return village;
|
|
1152
|
-
});
|
|
1153
|
-
};
|
|
1154
|
-
|
|
1155
|
-
// -------case 2
|
|
1156
|
-
const getVillageTree = (villageList) => {
|
|
1157
|
-
state.treeList = getVillageTreeList(villageList);
|
|
1158
|
-
state.originData = JSON.stringify(state.treeList);
|
|
1159
|
-
filterVillageByType();
|
|
1160
|
-
};
|
|
1161
|
-
|
|
1162
|
-
/************* 获取树数据 --end **************/
|
|
1163
|
-
|
|
1164
|
-
/** 获取接口数据 */
|
|
1165
|
-
const getVillageInfo = () => {
|
|
1166
|
-
emit("request", {
|
|
1167
|
-
params: {
|
|
1168
|
-
method: "get",
|
|
1169
|
-
server: "/org",
|
|
1170
|
-
url: "/build/villageAndBuildList/v2",
|
|
1171
|
-
extra: {
|
|
1172
|
-
checked: props.attachDpt ? 1 : props.userChecked,
|
|
1173
|
-
attach_department: props.attachDpt,
|
|
1174
|
-
},
|
|
1175
|
-
},
|
|
1176
|
-
success: (res) => {
|
|
1177
|
-
if (showDpt.value) {
|
|
1178
|
-
getDeptAndVillageTree(res.list);
|
|
1179
|
-
} else {
|
|
1180
|
-
getVillageTree(res.villageList);
|
|
1181
|
-
}
|
|
1182
|
-
},
|
|
1183
|
-
});
|
|
1184
|
-
};
|
|
1185
|
-
/************* 初始化 --start **************/
|
|
1186
|
-
const init = () => {
|
|
1187
|
-
getVillageInfo();
|
|
1188
|
-
};
|
|
1189
|
-
init();
|
|
1190
|
-
/************* 初始化 --end **************/
|
|
1191
|
-
|
|
1192
|
-
return {
|
|
1193
|
-
showDpt,
|
|
1194
|
-
...toRefs(state),
|
|
1195
|
-
onLoadTreeData,
|
|
1196
|
-
handleTreeCheck,
|
|
1197
|
-
};
|
|
1198
|
-
},
|
|
1199
|
-
});
|
|
1200
|
-
</script>
|
|
1201
|
-
|
|
1202
|
-
<style lang="less" scoped>
|
|
1203
|
-
.choose-housing {
|
|
1204
|
-
width: 100%;
|
|
1205
|
-
height: 100%;
|
|
1206
|
-
overflow: hidden auto;
|
|
1207
|
-
.tree-view {
|
|
1208
|
-
:deep(.ant-tree-checkbox-disabled) {
|
|
1209
|
-
display: none;
|
|
1210
|
-
}
|
|
1211
|
-
:deep(.ant-tree-treenode-disabled .ant-tree-checkbox-disabled) {
|
|
1212
|
-
display: inline-block;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
|
-
.tree-icon {
|
|
1216
|
-
font-size: 16px;
|
|
1217
|
-
width: 24px;
|
|
1218
|
-
height: 24px;
|
|
1219
|
-
line-height: 24px;
|
|
1220
|
-
text-align: center;
|
|
1221
|
-
vertical-align: middle;
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
.room-title {
|
|
1225
|
-
display: inline-block;
|
|
1226
|
-
width: 100%;
|
|
1227
|
-
.title-show {
|
|
1228
|
-
display: flex;
|
|
1229
|
-
align-content: center;
|
|
1230
|
-
justify-content: space-between;
|
|
1231
|
-
padding-right: 20px;
|
|
1232
|
-
overflow: hidden;
|
|
1233
|
-
.title {
|
|
1234
|
-
flex: 1;
|
|
1235
|
-
margin-right: 6px;
|
|
1236
|
-
overflow: hidden;
|
|
1237
|
-
.locked {
|
|
1238
|
-
margin-right: 6px;
|
|
1239
|
-
color: @warning-color;
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
.text-primary {
|
|
1246
|
-
color: @primary-color;
|
|
1247
|
-
}
|
|
1248
|
-
.text-gray {
|
|
1249
|
-
color: @disabled-color;
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
</style>
|
|
1
|
+
<!--
|
|
2
|
+
* @Description: 选择房源组件
|
|
3
|
+
-->
|
|
4
|
+
|
|
5
|
+
<template>
|
|
6
|
+
<div class="choose-housing beauty-scroller-bar">
|
|
7
|
+
<a-alert
|
|
8
|
+
show-icon
|
|
9
|
+
:message="alertTip"
|
|
10
|
+
v-if="alertTip"
|
|
11
|
+
style="margin-bottom: 10px"
|
|
12
|
+
/>
|
|
13
|
+
<div class="tree-view" v-if="treeList.length">
|
|
14
|
+
<a-tree
|
|
15
|
+
:checkable="checkable"
|
|
16
|
+
show-icon
|
|
17
|
+
v-model:expandedKeys="expandedKeys"
|
|
18
|
+
:checkedKeys="checkedKeys"
|
|
19
|
+
:tree-data="treeList"
|
|
20
|
+
:blockNode="true"
|
|
21
|
+
:selectable="false"
|
|
22
|
+
:load-data="onLoadTreeData"
|
|
23
|
+
:disabled="allDisabled"
|
|
24
|
+
@check="handleTreeCheck"
|
|
25
|
+
>
|
|
26
|
+
<!-- 图标 -->
|
|
27
|
+
<template #topCompanyIcon>
|
|
28
|
+
<bl-icon type="tree-jigou" class="tree-icon" />
|
|
29
|
+
</template>
|
|
30
|
+
<template #departmentIcon>
|
|
31
|
+
<GoldenFilled class="tree-icon" />
|
|
32
|
+
</template>
|
|
33
|
+
<template #villageIcon>
|
|
34
|
+
<bl-icon type="tree-xiangmu" class="tree-icon" />
|
|
35
|
+
</template>
|
|
36
|
+
<template #buildIcon>
|
|
37
|
+
<bl-icon type="tree-louyu" class="tree-icon" />
|
|
38
|
+
</template>
|
|
39
|
+
<template #layerIcon>
|
|
40
|
+
<bl-icon type="tree-louceng" class="tree-icon" />
|
|
41
|
+
</template>
|
|
42
|
+
<template #roomIcon>
|
|
43
|
+
<bl-icon type="tree-fangjian" class="tree-icon" />
|
|
44
|
+
</template>
|
|
45
|
+
<!-- 标题 -->
|
|
46
|
+
<template #roomTitle="{ dataRef }">
|
|
47
|
+
<a-tooltip placement="topLeft">
|
|
48
|
+
<template #title>{{ dataRef.disabledTip }}</template>
|
|
49
|
+
<div class="room-title">
|
|
50
|
+
<div class="title-show" key="title-disabled-tip">
|
|
51
|
+
<div class="title">
|
|
52
|
+
<LockOutlined v-if="dataRef.is_lock == 1" class="locked" />
|
|
53
|
+
<span>{{ dataRef.title }}</span>
|
|
54
|
+
</div>
|
|
55
|
+
<span
|
|
56
|
+
v-if="checkable"
|
|
57
|
+
:class="dataRef.disabled ? 'text-gray' : 'text-primary'"
|
|
58
|
+
>
|
|
59
|
+
{{ dataRef.showArea }}㎡
|
|
60
|
+
</span>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</a-tooltip>
|
|
64
|
+
</template>
|
|
65
|
+
</a-tree>
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</template>
|
|
69
|
+
|
|
70
|
+
<script>
|
|
71
|
+
import {
|
|
72
|
+
computed,
|
|
73
|
+
defineComponent,
|
|
74
|
+
nextTick,
|
|
75
|
+
reactive,
|
|
76
|
+
toRaw,
|
|
77
|
+
toRefs,
|
|
78
|
+
watch,
|
|
79
|
+
} from "vue";
|
|
80
|
+
import { LockOutlined, GoldenFilled } from "@ant-design/icons-vue";
|
|
81
|
+
import { message, Tree, Alert, Tooltip } from "ant-design-vue";
|
|
82
|
+
import BLIcon from "../BLIcon/index.js";
|
|
83
|
+
|
|
84
|
+
export default defineComponent({
|
|
85
|
+
name: "ChooseHousingResources",
|
|
86
|
+
components: {
|
|
87
|
+
GoldenFilled,
|
|
88
|
+
LockOutlined,
|
|
89
|
+
"bl-icon": BLIcon,
|
|
90
|
+
"a-tree": Tree,
|
|
91
|
+
"a-alert": Alert,
|
|
92
|
+
"a-tooltip": Tooltip,
|
|
93
|
+
},
|
|
94
|
+
props: {
|
|
95
|
+
// 是否追加组织架构层级部门
|
|
96
|
+
attachDpt: {
|
|
97
|
+
type: [Number, String],
|
|
98
|
+
default: 1,
|
|
99
|
+
},
|
|
100
|
+
// 是否只展示用户选中查看的项目楼宇 attachDpt为1时userChecked必为1
|
|
101
|
+
userChecked: {
|
|
102
|
+
type: [Number, String],
|
|
103
|
+
default: 1,
|
|
104
|
+
},
|
|
105
|
+
// alert提示语
|
|
106
|
+
alertTip: {
|
|
107
|
+
type: String,
|
|
108
|
+
default: "",
|
|
109
|
+
},
|
|
110
|
+
// 选择的类型级别: village build layer room
|
|
111
|
+
checkType: {
|
|
112
|
+
type: String,
|
|
113
|
+
default: "room",
|
|
114
|
+
},
|
|
115
|
+
// 不允许跨类型选择: village【不允许跨项目选择】 build【不允许跨楼层选择】 layer【不允许跨楼层选择】 不传为不限制
|
|
116
|
+
limitType: {
|
|
117
|
+
type: [String, null],
|
|
118
|
+
default: "",
|
|
119
|
+
},
|
|
120
|
+
// 是否禁选所有
|
|
121
|
+
allDisabled: {
|
|
122
|
+
type: Boolean,
|
|
123
|
+
default: false,
|
|
124
|
+
},
|
|
125
|
+
// 可租赁面积为0时是否禁选
|
|
126
|
+
areaEmptyDisabled: {
|
|
127
|
+
type: Boolean,
|
|
128
|
+
default: true,
|
|
129
|
+
},
|
|
130
|
+
// 默认选中房源
|
|
131
|
+
defaultChecked: {
|
|
132
|
+
type: Object,
|
|
133
|
+
default: () => ({
|
|
134
|
+
// villageList: [],
|
|
135
|
+
// buildList: [],
|
|
136
|
+
// layerList: [],
|
|
137
|
+
// roomList: [],
|
|
138
|
+
}),
|
|
139
|
+
},
|
|
140
|
+
// 默认选中房源改变 重新渲染
|
|
141
|
+
defaultCheckedChanged: {
|
|
142
|
+
type: [Number, Boolean],
|
|
143
|
+
default: 0,
|
|
144
|
+
},
|
|
145
|
+
// 默认选中房源id
|
|
146
|
+
defaultCheckedIds: {
|
|
147
|
+
type: Object,
|
|
148
|
+
default: () => ({
|
|
149
|
+
// villageId: 0,
|
|
150
|
+
// buildId: 0,
|
|
151
|
+
// layerId: 0,
|
|
152
|
+
// roomId: 0,
|
|
153
|
+
}),
|
|
154
|
+
},
|
|
155
|
+
// 只展示某个类型的项目,不传为展示所有类型的项目
|
|
156
|
+
villageType: {
|
|
157
|
+
type: String,
|
|
158
|
+
default: "",
|
|
159
|
+
},
|
|
160
|
+
// 重置
|
|
161
|
+
resetTrigger: {
|
|
162
|
+
type: Number,
|
|
163
|
+
default: 0,
|
|
164
|
+
},
|
|
165
|
+
// 是否可选
|
|
166
|
+
checkable: {
|
|
167
|
+
type: Boolean,
|
|
168
|
+
default: true,
|
|
169
|
+
},
|
|
170
|
+
// 条款类型 lease租赁条款 property物业条款
|
|
171
|
+
clauseType: {
|
|
172
|
+
type: String,
|
|
173
|
+
default: "",
|
|
174
|
+
},
|
|
175
|
+
// 是否只展示部分数据 0表示展示所有数据
|
|
176
|
+
getShowList: {
|
|
177
|
+
type: Number,
|
|
178
|
+
default: 0,
|
|
179
|
+
},
|
|
180
|
+
// 展示的部分数据
|
|
181
|
+
showList: {
|
|
182
|
+
type: Object,
|
|
183
|
+
default: () => ({
|
|
184
|
+
villageId: [], // village id集合
|
|
185
|
+
buildId: [], // build id集合
|
|
186
|
+
projectBuild: [], // {id, build,room} 房源关系和房间列表
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
// 包含自己的面积的房源
|
|
190
|
+
includeAreaRoom: {
|
|
191
|
+
type: Object,
|
|
192
|
+
default: () => ({}),
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
setup(props, { emit }) {
|
|
196
|
+
// 打印方法
|
|
197
|
+
const CL = (key, value) => {
|
|
198
|
+
console.info(`$$$$$$$$$$$$----${key}`, toRaw(value));
|
|
199
|
+
};
|
|
200
|
+
// 是否展示组织架构层级
|
|
201
|
+
const showDpt = computed(() => props.attachDpt == 1);
|
|
202
|
+
|
|
203
|
+
const initState = {
|
|
204
|
+
// 展示的树数据
|
|
205
|
+
treeList: [],
|
|
206
|
+
originData: undefined,
|
|
207
|
+
// 树展开节点key值集合
|
|
208
|
+
initExpandKeys: [],
|
|
209
|
+
expandedKeys: [],
|
|
210
|
+
// 选中节点的key值集合
|
|
211
|
+
checkedKeys: [],
|
|
212
|
+
tempCheckedKeys: [],
|
|
213
|
+
// 当前选中的房间等所在的项目、楼宇、楼层id
|
|
214
|
+
currentCheck: {
|
|
215
|
+
villageId: 0,
|
|
216
|
+
buildId: 0,
|
|
217
|
+
layerId: 0,
|
|
218
|
+
},
|
|
219
|
+
deptVillageMap: {},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const state = reactive({
|
|
223
|
+
...initState,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
/** 重置 */
|
|
227
|
+
watch(
|
|
228
|
+
() => props.resetTrigger,
|
|
229
|
+
() => {
|
|
230
|
+
reset();
|
|
231
|
+
}
|
|
232
|
+
);
|
|
233
|
+
const reset = () => {
|
|
234
|
+
state.expandedKeys = [...state.initExpandKeys];
|
|
235
|
+
state.checkedKeys = [];
|
|
236
|
+
state.tempCheckedKeys = [];
|
|
237
|
+
checkedIds = [];
|
|
238
|
+
state.currentCheck = { ...initState.currentCheck };
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 只展示部分数据
|
|
243
|
+
* 监听 getShowList 变化,变化后重新设置treeList
|
|
244
|
+
* */
|
|
245
|
+
let getShowListLoadedTimes = 0;
|
|
246
|
+
watch(
|
|
247
|
+
() => props.getShowList,
|
|
248
|
+
(val) => {
|
|
249
|
+
if (getShowListLoadedTimes != val) {
|
|
250
|
+
getShowListLoadedTimes = val;
|
|
251
|
+
reset();
|
|
252
|
+
state.treeList = [];
|
|
253
|
+
if (val) {
|
|
254
|
+
filterTreeListByShowList();
|
|
255
|
+
} else {
|
|
256
|
+
nextTick(() => {
|
|
257
|
+
state.treeList = JSON.parse(state.originData);
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
);
|
|
263
|
+
const filterTreeListByShowList = () => {
|
|
264
|
+
const originData = JSON.parse(state.originData);
|
|
265
|
+
state.treeList = getShowList(originData);
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
let getShowListArr = [];
|
|
269
|
+
let showExpandedKeys = [];
|
|
270
|
+
const getShowListAfter = (type) => {
|
|
271
|
+
getShowListArr.push(type);
|
|
272
|
+
if (getShowListArr.length == 2) {
|
|
273
|
+
setDeptVillageMap();
|
|
274
|
+
nextTick(() => {
|
|
275
|
+
state.expandedKeys = [...state.expandedKeys, ...showExpandedKeys];
|
|
276
|
+
if (state.tempCheckedKeys.length) {
|
|
277
|
+
state.checkedKeys = [...state.tempCheckedKeys];
|
|
278
|
+
}
|
|
279
|
+
// 重置
|
|
280
|
+
getShowListArr = [];
|
|
281
|
+
showExpandedKeys = [];
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
const getShowList = (list) => {
|
|
286
|
+
let result = [];
|
|
287
|
+
if (!list.length) {
|
|
288
|
+
return result;
|
|
289
|
+
}
|
|
290
|
+
const childType = list[0].childType;
|
|
291
|
+
if (["build", "layer", "room"].includes(childType)) {
|
|
292
|
+
if (childType == "build") {
|
|
293
|
+
const { buildId } = props.showList;
|
|
294
|
+
// 楼宇
|
|
295
|
+
result = list.filter((item) => buildId.includes(item.id));
|
|
296
|
+
result.forEach((item, index) => {
|
|
297
|
+
getLayerList(item).then((layerList) => {
|
|
298
|
+
item.children = getShowList(layerList);
|
|
299
|
+
showExpandedKeys.push(item.key);
|
|
300
|
+
if (index == result.length - 1) {
|
|
301
|
+
// 获取楼层列表结束
|
|
302
|
+
getShowListAfter("layer");
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
});
|
|
306
|
+
} else {
|
|
307
|
+
const { projectBuild } = props.showList;
|
|
308
|
+
const vId = list[0].extra.village_id;
|
|
309
|
+
const vItem = projectBuild.find((item) => item.id == vId);
|
|
310
|
+
if (childType == "layer") {
|
|
311
|
+
// 楼层
|
|
312
|
+
const layerIds = vItem.room.map((item) => item.extra.layer_id);
|
|
313
|
+
result = list.filter((item) => layerIds.includes(item.id));
|
|
314
|
+
result.forEach((item, index) => {
|
|
315
|
+
getRoomList(item).then((roomList) => {
|
|
316
|
+
item.children = getShowList(roomList);
|
|
317
|
+
showExpandedKeys.push(item.key);
|
|
318
|
+
if (index == result.length - 1) {
|
|
319
|
+
// 获取房间列表结束
|
|
320
|
+
getShowListAfter("room");
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
} else {
|
|
325
|
+
// 房间
|
|
326
|
+
const roomIds = vItem.room.map((item) => item.id);
|
|
327
|
+
result = list.filter((item) => roomIds.includes(item.id));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
} else {
|
|
331
|
+
// 部门 或者 项目
|
|
332
|
+
const { villageId } = props.showList;
|
|
333
|
+
for (let item of list) {
|
|
334
|
+
if (item.childType == "department") {
|
|
335
|
+
item.children = getShowList(item.children);
|
|
336
|
+
if (item.children.length) {
|
|
337
|
+
result.push(item);
|
|
338
|
+
}
|
|
339
|
+
} else if (item.childType == "village") {
|
|
340
|
+
if (villageId.includes(item.id)) {
|
|
341
|
+
item.children = getShowList(item.children);
|
|
342
|
+
result.push(item);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return result;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
/************* 选中房源 --start **************/
|
|
351
|
+
// 未选中任何房源
|
|
352
|
+
// 选中的房源id
|
|
353
|
+
let checkedIds = {
|
|
354
|
+
// village: new Set(),
|
|
355
|
+
// build: new Set(),
|
|
356
|
+
// layer: new Set(),
|
|
357
|
+
// room: new Set(),
|
|
358
|
+
};
|
|
359
|
+
const handleTreeCheck = (checkedKeys, e) => {
|
|
360
|
+
CL("handleTreeCheck checkedKeys", checkedKeys);
|
|
361
|
+
CL("handleTreeCheck ", e);
|
|
362
|
+
const { checked } = e;
|
|
363
|
+
if (checked) {
|
|
364
|
+
// 选中
|
|
365
|
+
const idsResult = getIdsByCheckedKeys(checkedKeys);
|
|
366
|
+
if (!checkedIds.village || canCheck(idsResult)) {
|
|
367
|
+
checkedIds = idsResult;
|
|
368
|
+
state.checkedKeys = checkedKeys;
|
|
369
|
+
}
|
|
370
|
+
} else {
|
|
371
|
+
if (!checkedKeys.length) {
|
|
372
|
+
checkedIds = {};
|
|
373
|
+
}
|
|
374
|
+
state.checkedKeys = checkedKeys;
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
// 根据key值获取id
|
|
378
|
+
const getIdsByCheckedKeys = (checkedKeys) => {
|
|
379
|
+
let result = {
|
|
380
|
+
village: new Set(),
|
|
381
|
+
build: new Set(),
|
|
382
|
+
layer: new Set(),
|
|
383
|
+
room: new Set(),
|
|
384
|
+
};
|
|
385
|
+
for (let key of checkedKeys) {
|
|
386
|
+
const keyArr = key.split("_");
|
|
387
|
+
result.village.add(Number(keyArr[1]));
|
|
388
|
+
if (keyArr[3]) {
|
|
389
|
+
result.build.add(Number(keyArr[3]));
|
|
390
|
+
}
|
|
391
|
+
if (keyArr[5]) {
|
|
392
|
+
result.layer.add(Number(keyArr[5]));
|
|
393
|
+
}
|
|
394
|
+
if (keyArr[7]) {
|
|
395
|
+
result.room.add(Number(keyArr[7]));
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
CL("getIdsByCheckedKeys result", result);
|
|
399
|
+
return result;
|
|
400
|
+
};
|
|
401
|
+
// 房源是否可选
|
|
402
|
+
const canCheck = (newcheckedIds) => {
|
|
403
|
+
if (props.limitType) {
|
|
404
|
+
// 不能跨项目选择房源
|
|
405
|
+
if (newcheckedIds.village.size > 1) {
|
|
406
|
+
message.warning("不能跨项目选择房源!");
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
// 不能跨楼宇选择房源
|
|
410
|
+
if (props.limitType === "build" && newcheckedIds.build.size > 1) {
|
|
411
|
+
message.warning("不能跨楼宇选择房源!");
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
// 不能跨楼层选择房源
|
|
415
|
+
if (props.limitType === "layer" && newcheckedIds.layer.size > 1) {
|
|
416
|
+
message.warning("不能跨楼层选择房源!");
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
return true;
|
|
421
|
+
};
|
|
422
|
+
// 整理出选择的village build layer room信息
|
|
423
|
+
let emitIdsTimeout = null;
|
|
424
|
+
watch(
|
|
425
|
+
() => state.checkedKeys,
|
|
426
|
+
() => {
|
|
427
|
+
if (emitIdsTimeout) {
|
|
428
|
+
clearTimeout(emitIdsTimeout);
|
|
429
|
+
emitIdsTimeout = null;
|
|
430
|
+
}
|
|
431
|
+
emitIdsTimeout = setTimeout(() => {
|
|
432
|
+
getCheckedInfoByKeys();
|
|
433
|
+
}, 800);
|
|
434
|
+
}
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
const emitResult = (result) => {
|
|
438
|
+
CL("emitResult====", result);
|
|
439
|
+
emit("getResult", result);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
const getCheckedInfoByKeys = () => {
|
|
443
|
+
let result = {
|
|
444
|
+
villageList: [], // 选中项目以及下面所有的房源
|
|
445
|
+
buildList: [], // 选中楼宇以及下面所有的房源
|
|
446
|
+
layerList: [], // 选中楼层以及下面所有的房源
|
|
447
|
+
roomList: [],
|
|
448
|
+
};
|
|
449
|
+
if (!state.checkedKeys.length) {
|
|
450
|
+
emitResult(result);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
let initKeys = [...state.checkedKeys];
|
|
454
|
+
let checkedKeys = getInitKeys(initKeys, "village");
|
|
455
|
+
let villageList = state.treeList;
|
|
456
|
+
const setResult = (key, value) => {
|
|
457
|
+
result[key].push(value);
|
|
458
|
+
let totalLength = 0;
|
|
459
|
+
for (let key in result) {
|
|
460
|
+
totalLength += result[key].length;
|
|
461
|
+
}
|
|
462
|
+
CL("setResult", totalLength);
|
|
463
|
+
if (checkedKeys.length == totalLength) {
|
|
464
|
+
CL("setResult getCheckedInfoByCheckType before", result);
|
|
465
|
+
getCheckedInfoByCheckType(result).then((newResult) => {
|
|
466
|
+
emitResult(newResult);
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
let villageMap = {};
|
|
471
|
+
for (let key of checkedKeys) {
|
|
472
|
+
let arrKey = [];
|
|
473
|
+
if (showDpt.value) {
|
|
474
|
+
arrKey = key.split("-");
|
|
475
|
+
villageList = state.deptVillageMap[arrKey[1]];
|
|
476
|
+
}
|
|
477
|
+
arrKey = key.split("_");
|
|
478
|
+
// 找到对应village
|
|
479
|
+
const villageId = Number(arrKey[1]);
|
|
480
|
+
let village = villageMap[villageId];
|
|
481
|
+
if (!village) {
|
|
482
|
+
village = villageMap[villageId] = villageList.find(
|
|
483
|
+
(item) => item.id == villageId
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
if (arrKey.length == 2) {
|
|
487
|
+
// 选中项目
|
|
488
|
+
setResult("villageList", village);
|
|
489
|
+
} else {
|
|
490
|
+
const buildId = Number(arrKey[3]);
|
|
491
|
+
const build = village.children.find((item) => item.id == buildId);
|
|
492
|
+
if (arrKey.length == 4) {
|
|
493
|
+
// 选中楼宇
|
|
494
|
+
setResult("buildList", build);
|
|
495
|
+
} else {
|
|
496
|
+
const layerId = Number(arrKey[5]);
|
|
497
|
+
getLayerList(build).then((layerList) => {
|
|
498
|
+
const layer = layerList.find((item) => item.id == layerId);
|
|
499
|
+
if (arrKey.length == 6) {
|
|
500
|
+
setResult("layerList", layer);
|
|
501
|
+
} else {
|
|
502
|
+
const roomId = Number(arrKey[7]);
|
|
503
|
+
getRoomList(layer).then((roomList) => {
|
|
504
|
+
const room = roomList.find((item) => item.id == roomId);
|
|
505
|
+
setResult("roomList", room);
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
|
|
514
|
+
const fKeyMap = { village: "build", build: "layer", layer: "room" };
|
|
515
|
+
const getInitKeys = (initKeys, type = "village") => {
|
|
516
|
+
let filterKeys = [];
|
|
517
|
+
let fKey = fKeyMap[type];
|
|
518
|
+
if (initKeys.length) {
|
|
519
|
+
if (fKey) {
|
|
520
|
+
filterKeys = initKeys.filter((item) => item.indexOf(fKey) === -1);
|
|
521
|
+
if (filterKeys.length) {
|
|
522
|
+
filterKeys.forEach((key) => {
|
|
523
|
+
initKeys = initKeys.filter((item) => item.indexOf(key) === -1);
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
const result = getInitKeys(initKeys, fKey);
|
|
527
|
+
filterKeys = [...filterKeys, ...result];
|
|
528
|
+
} else {
|
|
529
|
+
// type = room
|
|
530
|
+
filterKeys = [...filterKeys, ...initKeys];
|
|
531
|
+
initKeys = [];
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return filterKeys;
|
|
535
|
+
};
|
|
536
|
+
// 数据具体到 checkType
|
|
537
|
+
const getCheckedInfoByCheckType = (result) => {
|
|
538
|
+
return new Promise((resolve) => {
|
|
539
|
+
if (
|
|
540
|
+
!props.checkType ||
|
|
541
|
+
props.checkType == "village" ||
|
|
542
|
+
props.checkType == "build"
|
|
543
|
+
) {
|
|
544
|
+
resolve(result);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
if (result.villageList.length) {
|
|
548
|
+
result.villageList.forEach((village) => {
|
|
549
|
+
result.buildList = [...result.buildList, ...village.children];
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
const getRoom = () => {
|
|
553
|
+
if (result.layerList.length) {
|
|
554
|
+
result.layerList.forEach((layer, layerIndex) => {
|
|
555
|
+
getRoomList(layer).then((roomList) => {
|
|
556
|
+
if (roomList && roomList.length) {
|
|
557
|
+
const list = roomList.filter((item) => !item.disabled);
|
|
558
|
+
result.roomList = [...result.roomList, ...list];
|
|
559
|
+
}
|
|
560
|
+
if (layerIndex == result.layerList.length - 1) {
|
|
561
|
+
resolve(result);
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
});
|
|
565
|
+
} else {
|
|
566
|
+
resolve(result);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
if (result.buildList.length) {
|
|
570
|
+
result.buildList.forEach((build, buildIndex) => {
|
|
571
|
+
getLayerList(build).then((layerList) => {
|
|
572
|
+
if (layerList && layerList.length) {
|
|
573
|
+
const list = layerList.filter((item) => !item.disabled);
|
|
574
|
+
result.layerList = [...result.layerList, ...list];
|
|
575
|
+
}
|
|
576
|
+
if (buildIndex == result.buildList.length - 1) {
|
|
577
|
+
if (props.checkType == "room") {
|
|
578
|
+
getRoom();
|
|
579
|
+
} else {
|
|
580
|
+
resolve(result);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
} else {
|
|
586
|
+
getRoom();
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
};
|
|
590
|
+
/************* 选中房源 --end **************/
|
|
591
|
+
|
|
592
|
+
/************* 动态获取楼层、房间 --start **************/
|
|
593
|
+
const onLoadTreeData = (treeNode) => {
|
|
594
|
+
return new Promise((resolve) => {
|
|
595
|
+
CL("onLoadTreeData treeNode", treeNode);
|
|
596
|
+
const { dataRef } = treeNode;
|
|
597
|
+
if (dataRef.isLeaf || (dataRef.children && dataRef.children.length)) {
|
|
598
|
+
resolve();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
// const success = (result) => {
|
|
602
|
+
// resolve();
|
|
603
|
+
// };
|
|
604
|
+
if (dataRef.childType === "build") {
|
|
605
|
+
getLayerList(dataRef).then(() => {
|
|
606
|
+
resolve();
|
|
607
|
+
});
|
|
608
|
+
} else if (dataRef.childType === "layer") {
|
|
609
|
+
getRoomList(dataRef).then(() => {
|
|
610
|
+
resolve();
|
|
611
|
+
});
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
};
|
|
615
|
+
// 获取楼层列表
|
|
616
|
+
const getLayerList = (build) => {
|
|
617
|
+
return new Promise((resolve) => {
|
|
618
|
+
if (build.isLeaf || (build.children && build.children.length)) {
|
|
619
|
+
resolve(build.children || []);
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
emit("request", {
|
|
623
|
+
params: {
|
|
624
|
+
method: "get",
|
|
625
|
+
server: "/village",
|
|
626
|
+
url: "/project/layer/all",
|
|
627
|
+
extra: {
|
|
628
|
+
build_id: build.id,
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
success: (res) => {
|
|
632
|
+
if (res.list.length) {
|
|
633
|
+
build.children = res.list.map((item) => ({
|
|
634
|
+
...item,
|
|
635
|
+
childType: "layer",
|
|
636
|
+
key: `${build.key}_layer_${item.id}`,
|
|
637
|
+
title: item.layer_name,
|
|
638
|
+
level: build.level + 1,
|
|
639
|
+
disableCheckbox: props.limitType == "room",
|
|
640
|
+
extra: {
|
|
641
|
+
...build.extra,
|
|
642
|
+
build_id: build.id,
|
|
643
|
+
build_number: build.build_number,
|
|
644
|
+
build_name: build.build_name,
|
|
645
|
+
},
|
|
646
|
+
isLeaf: props.checkType == "layer",
|
|
647
|
+
slots: {
|
|
648
|
+
icon: "layerIcon",
|
|
649
|
+
},
|
|
650
|
+
}));
|
|
651
|
+
} else {
|
|
652
|
+
build.isLeaf = true;
|
|
653
|
+
}
|
|
654
|
+
resolve(build.children);
|
|
655
|
+
},
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
};
|
|
659
|
+
// 获取房间列表
|
|
660
|
+
const getRoomList = (layer) => {
|
|
661
|
+
return new Promise((resolve) => {
|
|
662
|
+
if (layer.isLeaf || (layer.children && layer.children.length)) {
|
|
663
|
+
resolve(layer.children || []);
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
emit("request", {
|
|
667
|
+
params: {
|
|
668
|
+
method: "get",
|
|
669
|
+
server: "/village",
|
|
670
|
+
url: "/project/room/all",
|
|
671
|
+
extra: {
|
|
672
|
+
village_id: layer.extra.village_id,
|
|
673
|
+
layer_id: layer.id,
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
success: (res) => {
|
|
677
|
+
if (res.list.length) {
|
|
678
|
+
layer.children = res.list.map((item) => {
|
|
679
|
+
let newItem = {
|
|
680
|
+
...item,
|
|
681
|
+
childType: "room",
|
|
682
|
+
key: `${layer.key}_room_${item.id}`,
|
|
683
|
+
title: item.room_name,
|
|
684
|
+
level: layer.level + 1,
|
|
685
|
+
layer_id: layer.id,
|
|
686
|
+
layer_number: layer.layer_number,
|
|
687
|
+
layer_name: layer.layer_name,
|
|
688
|
+
property_area: item.charging_area,
|
|
689
|
+
lease_square: item.rental_area,
|
|
690
|
+
extra: {
|
|
691
|
+
...layer.extra,
|
|
692
|
+
layer_id: layer.id,
|
|
693
|
+
layer_number: layer.layer_number,
|
|
694
|
+
layer_name: layer.layer_name,
|
|
695
|
+
},
|
|
696
|
+
isLeaf: true,
|
|
697
|
+
slots: {
|
|
698
|
+
icon: "roomIcon",
|
|
699
|
+
title: "roomTitle",
|
|
700
|
+
},
|
|
701
|
+
};
|
|
702
|
+
// 展示的可租赁面积
|
|
703
|
+
newItem.showArea =
|
|
704
|
+
props.clauseType == "property" && newItem.charging_area
|
|
705
|
+
? Number(newItem.charging_area)
|
|
706
|
+
: Number(newItem.rental_area);
|
|
707
|
+
if (newItem.rent_area) {
|
|
708
|
+
const rentArea =
|
|
709
|
+
props.clauseType == "property" &&
|
|
710
|
+
newItem.rent_area.property_square
|
|
711
|
+
? newItem.rent_area.property_square
|
|
712
|
+
: newItem.rent_area.lease_square;
|
|
713
|
+
newItem.showArea = Number(
|
|
714
|
+
Number(newItem.showArea) - Number(rentArea)
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (props.includeAreaRoom[newItem.id]) {
|
|
719
|
+
newItem.rentedArea = props.includeAreaRoom[newItem.id];
|
|
720
|
+
newItem.showArea =
|
|
721
|
+
newItem.showArea + Number(newItem.rentedArea.lease);
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
// 禁用以及禁用提示
|
|
725
|
+
if (props.checkable) {
|
|
726
|
+
if (props.areaEmptyDisabled && !newItem.showArea) {
|
|
727
|
+
newItem.disabled = true;
|
|
728
|
+
newItem.disabledTip = "当前房间可租面积为0,请选择其他房间";
|
|
729
|
+
}
|
|
730
|
+
if (newItem.is_lock == 1) {
|
|
731
|
+
newItem.disabled = true;
|
|
732
|
+
newItem.disabledTip = newItem.lock_reason;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return newItem;
|
|
736
|
+
});
|
|
737
|
+
} else {
|
|
738
|
+
layer.isLeaf = true;
|
|
739
|
+
}
|
|
740
|
+
resolve(layer.children);
|
|
741
|
+
},
|
|
742
|
+
});
|
|
743
|
+
});
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
/************* 动态获取楼层、房间 --end **************/
|
|
747
|
+
|
|
748
|
+
/************* 根据项目类型筛选项目 --start **************/
|
|
749
|
+
watch(
|
|
750
|
+
() => props.villageType,
|
|
751
|
+
() => {
|
|
752
|
+
state.checkedKeys = [];
|
|
753
|
+
filterVillageByType();
|
|
754
|
+
}
|
|
755
|
+
);
|
|
756
|
+
const filterVillageByType = () => {
|
|
757
|
+
if (!state.originData || !state.treeList.length) {
|
|
758
|
+
return;
|
|
759
|
+
}
|
|
760
|
+
if (props.villageType) {
|
|
761
|
+
if (showDpt.value) {
|
|
762
|
+
state.treeList = filterDeptVillageByType(state.treeList);
|
|
763
|
+
} else {
|
|
764
|
+
let originData = JSON.parse(state.originData);
|
|
765
|
+
state.treeList = originData.filter(
|
|
766
|
+
(item) => item.type == props.villageType
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
} else {
|
|
770
|
+
state.treeList = JSON.parse(state.originData);
|
|
771
|
+
}
|
|
772
|
+
emitTreeList();
|
|
773
|
+
};
|
|
774
|
+
const filterDeptVillageByType = (list) => {
|
|
775
|
+
let result = [];
|
|
776
|
+
for (let item of list) {
|
|
777
|
+
if (item.childType != "village" || item.type == props.villageType) {
|
|
778
|
+
result.push(item);
|
|
779
|
+
if (item.children && item.children.length) {
|
|
780
|
+
item.children = filterDeptVillageByType(item.children);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
return result;
|
|
785
|
+
};
|
|
786
|
+
/************* 根据项目类型筛选项目 --end **************/
|
|
787
|
+
|
|
788
|
+
/************* 设置默认选中房源 --start **************/
|
|
789
|
+
watch(
|
|
790
|
+
() => props.defaultCheckedChanged,
|
|
791
|
+
() => {
|
|
792
|
+
reset();
|
|
793
|
+
setDefaultChecked();
|
|
794
|
+
}
|
|
795
|
+
);
|
|
796
|
+
|
|
797
|
+
watch(
|
|
798
|
+
() => props.defaultChecked,
|
|
799
|
+
() => {
|
|
800
|
+
if (!state.checkedKeys.length) {
|
|
801
|
+
setDefaultChecked(1);
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
);
|
|
805
|
+
|
|
806
|
+
watch(
|
|
807
|
+
() => props.defaultCheckedIds,
|
|
808
|
+
() => {
|
|
809
|
+
if (!state.checkedKeys.length) {
|
|
810
|
+
setDefaultChecked(2);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
);
|
|
814
|
+
|
|
815
|
+
// 默认选中参数是否为空
|
|
816
|
+
const defaultCheckedNotEmpty = (type = 1) => {
|
|
817
|
+
const checked =
|
|
818
|
+
type == 1 ? props.defaultChecked : props.defaultCheckedIds;
|
|
819
|
+
for (let key in checked) {
|
|
820
|
+
if (
|
|
821
|
+
(type == 1 && checked[key] && checked[key].length) ||
|
|
822
|
+
(type == 2 && checked[key])
|
|
823
|
+
) {
|
|
824
|
+
return true;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return false;
|
|
828
|
+
};
|
|
829
|
+
// 设置默认选中
|
|
830
|
+
const setDefaultChecked = (type = 0) => {
|
|
831
|
+
if (!state.treeList.length) {
|
|
832
|
+
return;
|
|
833
|
+
}
|
|
834
|
+
nextTick(() => {
|
|
835
|
+
if (!type || type == 1) {
|
|
836
|
+
setDefaultListChecked();
|
|
837
|
+
}
|
|
838
|
+
if (!type || type == 2) {
|
|
839
|
+
setDefaultIdsChecked();
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
};
|
|
843
|
+
// 根据房源列表选中房源
|
|
844
|
+
const setDefaultListChecked = () => {
|
|
845
|
+
if (!defaultCheckedNotEmpty(1)) {
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
const { defaultChecked } = props;
|
|
849
|
+
CL("setDefaultChecked defaultChecked", toRaw(defaultChecked));
|
|
850
|
+
CL("setDefaultChecked deptVillageMap", toRaw(state.deptVillageMap));
|
|
851
|
+
const checkedKeys = [];
|
|
852
|
+
const expandedKeys = [];
|
|
853
|
+
let loadedVillage = {};
|
|
854
|
+
for (let key in defaultChecked) {
|
|
855
|
+
if (defaultChecked[key].length) {
|
|
856
|
+
defaultChecked[key].forEach((dcItem) => {
|
|
857
|
+
if (dcItem.extra) {
|
|
858
|
+
dcItem = {
|
|
859
|
+
...dcItem,
|
|
860
|
+
...dcItem.extra,
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
let itemKey = "";
|
|
864
|
+
let villageId =
|
|
865
|
+
key == "villageList" ? dcItem.id : dcItem.village_id;
|
|
866
|
+
if (key == "buildList" && !dcItem.village_id) {
|
|
867
|
+
// 只知道楼宇id不知道项目id
|
|
868
|
+
villageId = getVillageByBuildId(dcItem.id);
|
|
869
|
+
}
|
|
870
|
+
if (!villageId) {
|
|
871
|
+
emitError();
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
let result = loadedVillage[villageId];
|
|
875
|
+
if (!result) {
|
|
876
|
+
result = loadedVillage[villageId] = getVillageById(villageId);
|
|
877
|
+
}
|
|
878
|
+
if (!result) {
|
|
879
|
+
emitError();
|
|
880
|
+
return;
|
|
881
|
+
}
|
|
882
|
+
itemKey = result.depId
|
|
883
|
+
? `department-${result.depId}-village_${villageId}`
|
|
884
|
+
: `village_${villageId}`;
|
|
885
|
+
if (key != "villageList") {
|
|
886
|
+
// 楼栋+
|
|
887
|
+
const buildId = key == "buildList" ? dcItem.id : dcItem.build_id;
|
|
888
|
+
itemKey = `${itemKey}_build_${buildId}`;
|
|
889
|
+
if (key != "buildList") {
|
|
890
|
+
// 楼层+
|
|
891
|
+
if (!expandedKeys.includes(itemKey)) {
|
|
892
|
+
expandedKeys.push(itemKey);
|
|
893
|
+
}
|
|
894
|
+
const layerId =
|
|
895
|
+
key == "layerList" ? dcItem.id : dcItem.layer_id;
|
|
896
|
+
itemKey = `${itemKey}_layer_${layerId}`;
|
|
897
|
+
if (key != "layerList") {
|
|
898
|
+
// 选中房间
|
|
899
|
+
if (!expandedKeys.includes(itemKey)) {
|
|
900
|
+
expandedKeys.push(itemKey);
|
|
901
|
+
}
|
|
902
|
+
const roomId = dcItem.id;
|
|
903
|
+
itemKey = `${itemKey}_room_${roomId}`;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
checkedKeys.push(itemKey);
|
|
908
|
+
});
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
if (checkedKeys.length) {
|
|
913
|
+
nextTick(() => {
|
|
914
|
+
if (props.getShowList) {
|
|
915
|
+
state.tempCheckedKeys = [...state.tempCheckedKeys, ...checkedKeys];
|
|
916
|
+
} else {
|
|
917
|
+
state.checkedKeys = [...checkedKeys];
|
|
918
|
+
state.expandedKeys = [...state.expandedKeys, ...expandedKeys];
|
|
919
|
+
}
|
|
920
|
+
CL("setDefaultChecked checkedKeys", toRaw(state.checkedKeys));
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
|
|
925
|
+
const emitError = (type = "notFound", msg = "未查找到该房源") => {
|
|
926
|
+
emit("error", {
|
|
927
|
+
type,
|
|
928
|
+
msg,
|
|
929
|
+
});
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
// 根据id选中房源
|
|
933
|
+
const setDefaultIdsChecked = () => {
|
|
934
|
+
if (!defaultCheckedNotEmpty(2)) {
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
const { defaultCheckedIds } = props;
|
|
938
|
+
const expandedKeys = [];
|
|
939
|
+
const checkedKeys = [];
|
|
940
|
+
if (defaultCheckedIds.villageId) {
|
|
941
|
+
let itemKey = "";
|
|
942
|
+
const result = getVillageById(defaultCheckedIds.villageId);
|
|
943
|
+
if (!result) {
|
|
944
|
+
emitError();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
itemKey = result.depId
|
|
948
|
+
? `department-${result.depId}-village_${defaultCheckedIds.villageId}`
|
|
949
|
+
: `village_${defaultCheckedIds.villageId}`;
|
|
950
|
+
if (defaultCheckedIds.buildId) {
|
|
951
|
+
itemKey = `${itemKey}_build_${defaultCheckedIds.buildId}`;
|
|
952
|
+
if (defaultCheckedIds.layerId) {
|
|
953
|
+
expandedKeys.push(itemKey);
|
|
954
|
+
itemKey = `${itemKey}_layer_${defaultCheckedIds.layerId}`;
|
|
955
|
+
if (defaultCheckedIds.roomId) {
|
|
956
|
+
expandedKeys.push(itemKey);
|
|
957
|
+
itemKey = `${itemKey}_room_${defaultCheckedIds.roomId}`;
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
checkedKeys.push(itemKey);
|
|
962
|
+
}
|
|
963
|
+
if (checkedKeys.length) {
|
|
964
|
+
nextTick(() => {
|
|
965
|
+
if (props.getShowList) {
|
|
966
|
+
state.tempCheckedKeys = [...state.tempCheckedKeys, ...checkedKeys];
|
|
967
|
+
} else {
|
|
968
|
+
state.checkedKeys = [...checkedKeys];
|
|
969
|
+
state.expandedKeys = [...state.expandedKeys, ...expandedKeys];
|
|
970
|
+
}
|
|
971
|
+
CL("setDefaultChecked checkedKeys", toRaw(state.checkedKeys));
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
// 根据项目id获取项目信息
|
|
976
|
+
const getVillageById = (villageId) => {
|
|
977
|
+
if (showDpt.value) {
|
|
978
|
+
for (let depId in state.deptVillageMap) {
|
|
979
|
+
const village = state.deptVillageMap[depId].find(
|
|
980
|
+
(item) => item.id == villageId
|
|
981
|
+
);
|
|
982
|
+
if (village) {
|
|
983
|
+
return {
|
|
984
|
+
village,
|
|
985
|
+
depId,
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
} else {
|
|
990
|
+
const village = state.treeList.find((item) => item.id == villageId);
|
|
991
|
+
return {
|
|
992
|
+
village,
|
|
993
|
+
depId: 0,
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
// 根据楼宇id查找项目id
|
|
998
|
+
const getVillageByBuildId = (buildId) => {
|
|
999
|
+
if (showDpt.value) {
|
|
1000
|
+
for (let depId in state.deptVillageMap) {
|
|
1001
|
+
const villageList = state.deptVillageMap[depId];
|
|
1002
|
+
if (villageList && villageList.length) {
|
|
1003
|
+
for (let village of villageList) {
|
|
1004
|
+
if (village.children && village.children.length) {
|
|
1005
|
+
const build = village.children.find((b) => b.id == buildId);
|
|
1006
|
+
if (build) {
|
|
1007
|
+
return village.id;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
} else {
|
|
1014
|
+
for (let village of state.treeList) {
|
|
1015
|
+
if (village.children && village.children.length) {
|
|
1016
|
+
const build = village.children.find((b) => b.id == buildId);
|
|
1017
|
+
if (build) {
|
|
1018
|
+
return village.id;
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
return 0;
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
/************* 设置默认选中房源 --end **************/
|
|
1027
|
+
|
|
1028
|
+
/************* 获取树数据 --start **************/
|
|
1029
|
+
const emitTreeList = () => {
|
|
1030
|
+
// 过滤treeList
|
|
1031
|
+
if (props.getShowList && getShowListLoadedTimes != props.getShowList) {
|
|
1032
|
+
getShowListLoadedTimes = props.getShowList;
|
|
1033
|
+
filterTreeListByShowList();
|
|
1034
|
+
}
|
|
1035
|
+
// 默认选中值
|
|
1036
|
+
setDefaultChecked();
|
|
1037
|
+
// 最终treeList
|
|
1038
|
+
emit("getTree", {
|
|
1039
|
+
list: state.treeList,
|
|
1040
|
+
oList: JSON.parse(state.originData),
|
|
1041
|
+
});
|
|
1042
|
+
CL("treeList", state.treeList);
|
|
1043
|
+
};
|
|
1044
|
+
|
|
1045
|
+
const setDeptVillageMap = () => {
|
|
1046
|
+
state.deptVillageMap = {};
|
|
1047
|
+
if (showDpt.value) {
|
|
1048
|
+
getDeptMap(state.treeList);
|
|
1049
|
+
}
|
|
1050
|
+
};
|
|
1051
|
+
const getDeptMap = (list) => {
|
|
1052
|
+
for (let item of list) {
|
|
1053
|
+
if (
|
|
1054
|
+
item.childType == "department" &&
|
|
1055
|
+
item.children &&
|
|
1056
|
+
item.children.length
|
|
1057
|
+
) {
|
|
1058
|
+
const villageList = item.children.filter(
|
|
1059
|
+
(it) => it.childType == "village"
|
|
1060
|
+
);
|
|
1061
|
+
if (villageList.length) {
|
|
1062
|
+
state.deptVillageMap[item.id] = villageList;
|
|
1063
|
+
}
|
|
1064
|
+
getDeptMap(item.children);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
};
|
|
1068
|
+
// ------case 1
|
|
1069
|
+
const getDeptAndVillageTree = (list) => {
|
|
1070
|
+
state.treeList = getDeptTreeList(list, 1);
|
|
1071
|
+
state.originData = JSON.stringify(state.treeList);
|
|
1072
|
+
filterVillageByType();
|
|
1073
|
+
};
|
|
1074
|
+
// 获取部门树列表
|
|
1075
|
+
const getDeptTreeList = (list, level) => {
|
|
1076
|
+
let result = [];
|
|
1077
|
+
for (let listItem of list) {
|
|
1078
|
+
// 非项目管理部门
|
|
1079
|
+
if (listItem.type !== 3) {
|
|
1080
|
+
listItem.childType = "department"; //listItem.type == 0 ? "topCompany" : "department";
|
|
1081
|
+
listItem.key = `${listItem.childType}-${listItem.id}`; // 部门用中划线,房源用下划线,方便整理选中房源key
|
|
1082
|
+
listItem.title = listItem.name;
|
|
1083
|
+
listItem.level = level;
|
|
1084
|
+
listItem.disableCheckbox = true;
|
|
1085
|
+
listItem.slots = {
|
|
1086
|
+
icon: `${listItem.childType}Icon`,
|
|
1087
|
+
};
|
|
1088
|
+
listItem.children = [];
|
|
1089
|
+
if (listItem.subcat && listItem.subcat.length) {
|
|
1090
|
+
listItem.children = getDeptTreeList(listItem.subcat, level + 1);
|
|
1091
|
+
}
|
|
1092
|
+
if (listItem.villageList && listItem.villageList.length) {
|
|
1093
|
+
const villageList = getVillageTreeList(
|
|
1094
|
+
listItem.villageList,
|
|
1095
|
+
level,
|
|
1096
|
+
listItem.key
|
|
1097
|
+
);
|
|
1098
|
+
state.deptVillageMap[listItem.id] = villageList;
|
|
1099
|
+
listItem.children = [...listItem.children, ...villageList];
|
|
1100
|
+
}
|
|
1101
|
+
listItem.isLeaf = listItem.children.length === 0;
|
|
1102
|
+
result.push(listItem);
|
|
1103
|
+
state.expandedKeys.push(listItem.key);
|
|
1104
|
+
state.initExpandKeys.push(listItem.key);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
return result;
|
|
1108
|
+
};
|
|
1109
|
+
// 获取项目树列表
|
|
1110
|
+
const getVillageTreeList = (villageList, level = 1, parentKey) => {
|
|
1111
|
+
return villageList.map((village) => {
|
|
1112
|
+
village.childType = "village";
|
|
1113
|
+
village.key = `${parentKey ? parentKey + "-" : ""}${
|
|
1114
|
+
village.childType
|
|
1115
|
+
}_${village.id}`;
|
|
1116
|
+
village.title = village.name;
|
|
1117
|
+
village.level = level;
|
|
1118
|
+
village.disableCheckbox = !!props.limitType;
|
|
1119
|
+
village.slots = {
|
|
1120
|
+
icon: `${village.childType}Icon`,
|
|
1121
|
+
};
|
|
1122
|
+
if (props.checkType == village.childType) {
|
|
1123
|
+
village.isLeaf = true;
|
|
1124
|
+
} else {
|
|
1125
|
+
if (village.buildList && village.buildList.length) {
|
|
1126
|
+
village.isLeaf = false;
|
|
1127
|
+
village.children = village.buildList.map((build) => ({
|
|
1128
|
+
...build,
|
|
1129
|
+
level,
|
|
1130
|
+
childType: "build",
|
|
1131
|
+
key: `${village.key}_build_${build.id}`,
|
|
1132
|
+
title: build.build_name,
|
|
1133
|
+
disableCheckbox:
|
|
1134
|
+
props.limitType == "layer" || props.limitType == "room",
|
|
1135
|
+
extra: {
|
|
1136
|
+
village_id: village.id,
|
|
1137
|
+
village_name: village.name,
|
|
1138
|
+
village_short_name: village.short_name,
|
|
1139
|
+
},
|
|
1140
|
+
slots: {
|
|
1141
|
+
icon: "buildIcon",
|
|
1142
|
+
},
|
|
1143
|
+
isLeaf: props.checkType == "build",
|
|
1144
|
+
}));
|
|
1145
|
+
} else {
|
|
1146
|
+
village.isLeaf = true;
|
|
1147
|
+
}
|
|
1148
|
+
state.expandedKeys.push(village.key);
|
|
1149
|
+
state.initExpandKeys.push(village.key);
|
|
1150
|
+
}
|
|
1151
|
+
return village;
|
|
1152
|
+
});
|
|
1153
|
+
};
|
|
1154
|
+
|
|
1155
|
+
// -------case 2
|
|
1156
|
+
const getVillageTree = (villageList) => {
|
|
1157
|
+
state.treeList = getVillageTreeList(villageList);
|
|
1158
|
+
state.originData = JSON.stringify(state.treeList);
|
|
1159
|
+
filterVillageByType();
|
|
1160
|
+
};
|
|
1161
|
+
|
|
1162
|
+
/************* 获取树数据 --end **************/
|
|
1163
|
+
|
|
1164
|
+
/** 获取接口数据 */
|
|
1165
|
+
const getVillageInfo = () => {
|
|
1166
|
+
emit("request", {
|
|
1167
|
+
params: {
|
|
1168
|
+
method: "get",
|
|
1169
|
+
server: "/org",
|
|
1170
|
+
url: "/build/villageAndBuildList/v2",
|
|
1171
|
+
extra: {
|
|
1172
|
+
checked: props.attachDpt ? 1 : props.userChecked,
|
|
1173
|
+
attach_department: props.attachDpt,
|
|
1174
|
+
},
|
|
1175
|
+
},
|
|
1176
|
+
success: (res) => {
|
|
1177
|
+
if (showDpt.value) {
|
|
1178
|
+
getDeptAndVillageTree(res.list);
|
|
1179
|
+
} else {
|
|
1180
|
+
getVillageTree(res.villageList);
|
|
1181
|
+
}
|
|
1182
|
+
},
|
|
1183
|
+
});
|
|
1184
|
+
};
|
|
1185
|
+
/************* 初始化 --start **************/
|
|
1186
|
+
const init = () => {
|
|
1187
|
+
getVillageInfo();
|
|
1188
|
+
};
|
|
1189
|
+
init();
|
|
1190
|
+
/************* 初始化 --end **************/
|
|
1191
|
+
|
|
1192
|
+
return {
|
|
1193
|
+
showDpt,
|
|
1194
|
+
...toRefs(state),
|
|
1195
|
+
onLoadTreeData,
|
|
1196
|
+
handleTreeCheck,
|
|
1197
|
+
};
|
|
1198
|
+
},
|
|
1199
|
+
});
|
|
1200
|
+
</script>
|
|
1201
|
+
|
|
1202
|
+
<style lang="less" scoped>
|
|
1203
|
+
.choose-housing {
|
|
1204
|
+
width: 100%;
|
|
1205
|
+
height: 100%;
|
|
1206
|
+
overflow: hidden auto;
|
|
1207
|
+
.tree-view {
|
|
1208
|
+
:deep(.ant-tree-checkbox-disabled) {
|
|
1209
|
+
display: none;
|
|
1210
|
+
}
|
|
1211
|
+
:deep(.ant-tree-treenode-disabled .ant-tree-checkbox-disabled) {
|
|
1212
|
+
display: inline-block;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
.tree-icon {
|
|
1216
|
+
font-size: 16px;
|
|
1217
|
+
width: 24px;
|
|
1218
|
+
height: 24px;
|
|
1219
|
+
line-height: 24px;
|
|
1220
|
+
text-align: center;
|
|
1221
|
+
vertical-align: middle;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
.room-title {
|
|
1225
|
+
display: inline-block;
|
|
1226
|
+
width: 100%;
|
|
1227
|
+
.title-show {
|
|
1228
|
+
display: flex;
|
|
1229
|
+
align-content: center;
|
|
1230
|
+
justify-content: space-between;
|
|
1231
|
+
padding-right: 20px;
|
|
1232
|
+
overflow: hidden;
|
|
1233
|
+
.title {
|
|
1234
|
+
flex: 1;
|
|
1235
|
+
margin-right: 6px;
|
|
1236
|
+
overflow: hidden;
|
|
1237
|
+
.locked {
|
|
1238
|
+
margin-right: 6px;
|
|
1239
|
+
color: @warning-color;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
.text-primary {
|
|
1246
|
+
color: @primary-color;
|
|
1247
|
+
}
|
|
1248
|
+
.text-gray {
|
|
1249
|
+
color: @disabled-color;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
</style>
|