bl-common-vue3 0.2.48 → 0.2.49
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_20230310155615.json +54 -0
- package/.history/src/components/VillageTree/index_20230308114633.vue +342 -0
- package/.history/src/components/VillageTree/index_20230308114634.vue +342 -0
- package/lib/vue3common.common.js +87 -75
- package/lib/vue3common.umd.js +87 -75
- package/lib/vue3common.umd.min.js +7 -7
- package/package.json +1 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bl-common-vue3",
|
|
3
|
+
"version": "0.2.49",
|
|
4
|
+
"main": "lib/vue3common.umd.min.js",
|
|
5
|
+
"description": "bailing vue3 common components lib",
|
|
6
|
+
"private": false,
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lib": "vue-cli-service build --target lib --name vue3common --dest lib index.js",
|
|
9
|
+
"serve": "vue-cli-service serve",
|
|
10
|
+
"build": "vue-cli-service build",
|
|
11
|
+
"lint": "vue-cli-service lint",
|
|
12
|
+
"publish": "npm publish --access public"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@ant-design/icons-vue": "^6.0.1",
|
|
16
|
+
"ant-design-vue": "^2.2.8",
|
|
17
|
+
"axios": "^0.21.4",
|
|
18
|
+
"core-js": "^3.6.5",
|
|
19
|
+
"less": "^4.1.1",
|
|
20
|
+
"less-loader": "^6.0.0",
|
|
21
|
+
"moment": "^2.29.1",
|
|
22
|
+
"qrcode.vue": "^3.3.3",
|
|
23
|
+
"style-resources-loader": "^1.5.0",
|
|
24
|
+
"vue": "^3.0.4"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@vue/cli-plugin-babel": "~4.5.13",
|
|
28
|
+
"@vue/cli-plugin-eslint": "~4.5.13",
|
|
29
|
+
"@vue/cli-service": "~4.5.13",
|
|
30
|
+
"@vue/compiler-sfc": "^3.0.0",
|
|
31
|
+
"babel-eslint": "^10.1.0",
|
|
32
|
+
"eslint": "^6.7.2",
|
|
33
|
+
"eslint-plugin-vue": "^7.0.0"
|
|
34
|
+
},
|
|
35
|
+
"eslintConfig": {
|
|
36
|
+
"root": true,
|
|
37
|
+
"env": {
|
|
38
|
+
"node": true
|
|
39
|
+
},
|
|
40
|
+
"extends": [
|
|
41
|
+
"plugin:vue/vue3-essential",
|
|
42
|
+
"eslint:recommended"
|
|
43
|
+
],
|
|
44
|
+
"parserOptions": {
|
|
45
|
+
"parser": "babel-eslint"
|
|
46
|
+
},
|
|
47
|
+
"rules": {}
|
|
48
|
+
},
|
|
49
|
+
"browserslist": [
|
|
50
|
+
"> 1%",
|
|
51
|
+
"last 2 versions",
|
|
52
|
+
"not dead"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
@@ -0,0 +1,342 @@
|
|
|
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
|
+
<template #roomTitle="{ dataRef }">
|
|
34
|
+
<span style="display: inline-block">
|
|
35
|
+
<span>{{ dataRef.title }}</span>
|
|
36
|
+
<template
|
|
37
|
+
v-if="
|
|
38
|
+
showRentIcon &&
|
|
39
|
+
dataRef.contract_info &&
|
|
40
|
+
dataRef.contract_info.length
|
|
41
|
+
"
|
|
42
|
+
>
|
|
43
|
+
<bl-icon
|
|
44
|
+
type="zukehuaxiang"
|
|
45
|
+
style="margin-left: 10px; color: #52c41a; font-size: 16px"
|
|
46
|
+
@click.stop="onRentIconClick(dataRef)"
|
|
47
|
+
/>
|
|
48
|
+
</template>
|
|
49
|
+
</span>
|
|
50
|
+
</template>
|
|
51
|
+
</a-tree>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
import { defineComponent, reactive, toRefs } from "vue";
|
|
57
|
+
import BlIcon from "../BLIcon/index.js";
|
|
58
|
+
import { GoldenFilled } from "@ant-design/icons-vue";
|
|
59
|
+
import { Tree } from "ant-design-vue";
|
|
60
|
+
export default defineComponent({
|
|
61
|
+
name: "VillageTree",
|
|
62
|
+
props: {
|
|
63
|
+
userChecked: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 1,
|
|
66
|
+
},
|
|
67
|
+
attachDpt: {
|
|
68
|
+
type: Number,
|
|
69
|
+
default: 1,
|
|
70
|
+
},
|
|
71
|
+
// 是否展示租客画像
|
|
72
|
+
showRentIcon: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
components: {
|
|
78
|
+
GoldenFilled,
|
|
79
|
+
"bl-icon": BlIcon,
|
|
80
|
+
"a-tree": Tree,
|
|
81
|
+
},
|
|
82
|
+
setup(props, { emit }) {
|
|
83
|
+
const state = reactive({
|
|
84
|
+
treeList: [],
|
|
85
|
+
expandedKeys: [],
|
|
86
|
+
selectedKeys: [],
|
|
87
|
+
selected: {},
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
/** 点击选中当前项 */
|
|
91
|
+
const onTreeSelect = (value, e) => {
|
|
92
|
+
const current = e.node.dataRef;
|
|
93
|
+
if (current.childType == "department") {
|
|
94
|
+
// 部门不允许选中
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
setSelected(current);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** 点击租客画像 */
|
|
101
|
+
const onRentIconClick = (current) => {
|
|
102
|
+
if (state.selectedKeys.length && state.selectedKeys[0] == current.key) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
state.selectedKeys = [current.key];
|
|
106
|
+
state.selected = current;
|
|
107
|
+
emit("rentClick", {
|
|
108
|
+
current,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** 设置选中 */
|
|
113
|
+
const setSelected = (current) => {
|
|
114
|
+
if (state.selectedKeys.length && state.selectedKeys[0] == current.key) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
state.selectedKeys = [current.key];
|
|
118
|
+
state.selected = current;
|
|
119
|
+
emit("getCurrent", { current });
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/** 动态加载树数据 */
|
|
123
|
+
const onLoadTreeData = (treeNode) => {
|
|
124
|
+
return new Promise((resolve) => {
|
|
125
|
+
const { dataRef } = treeNode;
|
|
126
|
+
if (dataRef.isLeaf || (dataRef.children && dataRef.children.length)) {
|
|
127
|
+
resolve();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (dataRef.childType === "build") {
|
|
131
|
+
getLayerList(dataRef).then(() => {
|
|
132
|
+
resolve();
|
|
133
|
+
});
|
|
134
|
+
} else if (dataRef.childType === "layer") {
|
|
135
|
+
getRoomList(dataRef).then(() => {
|
|
136
|
+
resolve();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
// 获取楼层列表
|
|
142
|
+
const getLayerList = (build) => {
|
|
143
|
+
return new Promise((resolve) => {
|
|
144
|
+
if (build.isLeaf || (build.children && build.children.length)) {
|
|
145
|
+
resolve(build.children || []);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
emit("request", {
|
|
149
|
+
params: {
|
|
150
|
+
method: "get",
|
|
151
|
+
server: "/village",
|
|
152
|
+
url: "/project/layer/all",
|
|
153
|
+
extra: {
|
|
154
|
+
build_id: build.id,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
success: (res) => {
|
|
158
|
+
if (res.list.length) {
|
|
159
|
+
build.children = res.list.map((item) => ({
|
|
160
|
+
...item,
|
|
161
|
+
childType: "layer",
|
|
162
|
+
key: `${build.key}_layer_${item.id}`,
|
|
163
|
+
title: item.layer_name,
|
|
164
|
+
level: build.level + 1,
|
|
165
|
+
extra: {
|
|
166
|
+
...build.extra,
|
|
167
|
+
build_id: build.id,
|
|
168
|
+
build_number: build.build_number,
|
|
169
|
+
build_name: build.build_name,
|
|
170
|
+
},
|
|
171
|
+
isLeaf: false,
|
|
172
|
+
slots: {
|
|
173
|
+
icon: "layerIcon",
|
|
174
|
+
},
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
resolve(build.children);
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
// 获取房间列表
|
|
183
|
+
const getRoomList = (layer) => {
|
|
184
|
+
return new Promise((resolve) => {
|
|
185
|
+
if (layer.isLeaf || (layer.children && layer.children.length)) {
|
|
186
|
+
resolve(layer.children || []);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
emit("request", {
|
|
190
|
+
params: {
|
|
191
|
+
method: "get",
|
|
192
|
+
server: "/village",
|
|
193
|
+
url: "/project/room/all",
|
|
194
|
+
extra: {
|
|
195
|
+
village_id: layer.extra.village_id,
|
|
196
|
+
layer_id: layer.id,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
success: (res) => {
|
|
200
|
+
if (res.list.length) {
|
|
201
|
+
layer.children = res.list.map((item) => {
|
|
202
|
+
let newItem = {
|
|
203
|
+
...item,
|
|
204
|
+
childType: "room",
|
|
205
|
+
key: `${layer.key}_room_${item.id}`,
|
|
206
|
+
title: item.room_name,
|
|
207
|
+
level: layer.level + 1,
|
|
208
|
+
layer_id: layer.id,
|
|
209
|
+
layer_number: layer.layer_number,
|
|
210
|
+
layer_name: layer.layer_name,
|
|
211
|
+
property_area: item.charging_area,
|
|
212
|
+
lease_square: item.rental_area,
|
|
213
|
+
extra: {
|
|
214
|
+
...layer.extra,
|
|
215
|
+
layer_id: layer.id,
|
|
216
|
+
layer_number: layer.layer_number,
|
|
217
|
+
layer_name: layer.layer_name,
|
|
218
|
+
},
|
|
219
|
+
isLeaf: true,
|
|
220
|
+
slots: {
|
|
221
|
+
icon: "roomIcon",
|
|
222
|
+
title: "roomTitle",
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
return newItem;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
resolve(layer.children);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/** 获取树数据 */
|
|
235
|
+
// 获取部门树列表
|
|
236
|
+
const getDeptTreeList = (list, level) => {
|
|
237
|
+
let result = [];
|
|
238
|
+
for (let listItem of list) {
|
|
239
|
+
// 非项目管理部门
|
|
240
|
+
if (listItem.type !== 3) {
|
|
241
|
+
listItem.childType = "department"; //listItem.type == 0 ? "topCompany" : "department";
|
|
242
|
+
listItem.key = `${listItem.childType}-${listItem.id}`; // 部门用中划线,房源用下划线,方便整理选中房源key
|
|
243
|
+
listItem.title = listItem.name;
|
|
244
|
+
listItem.level = level;
|
|
245
|
+
listItem.slots = {
|
|
246
|
+
icon: `${listItem.childType}Icon`,
|
|
247
|
+
};
|
|
248
|
+
listItem.children = [];
|
|
249
|
+
if (listItem.subcat && listItem.subcat.length) {
|
|
250
|
+
listItem.children = getDeptTreeList(listItem.subcat, level + 1);
|
|
251
|
+
}
|
|
252
|
+
if (listItem.villageList && listItem.villageList.length) {
|
|
253
|
+
const villageList = getVillageTreeList(
|
|
254
|
+
listItem.villageList,
|
|
255
|
+
level,
|
|
256
|
+
listItem.key
|
|
257
|
+
);
|
|
258
|
+
listItem.children = [...listItem.children, ...villageList];
|
|
259
|
+
}
|
|
260
|
+
listItem.isLeaf = listItem.children.length === 0;
|
|
261
|
+
result.push(listItem);
|
|
262
|
+
state.expandedKeys.push(listItem.key);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
// 获取项目树列表
|
|
268
|
+
const getVillageTreeList = (villageList, level = 1, parentKey) => {
|
|
269
|
+
return villageList.map((village) => {
|
|
270
|
+
village.childType = "village";
|
|
271
|
+
village.key = `${parentKey ? parentKey + "-" : ""}${
|
|
272
|
+
village.childType
|
|
273
|
+
}_${village.id}`;
|
|
274
|
+
|
|
275
|
+
village.title = village.name;
|
|
276
|
+
village.level = level;
|
|
277
|
+
village.slots = {
|
|
278
|
+
icon: `${village.childType}Icon`,
|
|
279
|
+
};
|
|
280
|
+
if (village.buildList && village.buildList.length) {
|
|
281
|
+
village.isLeaf = false;
|
|
282
|
+
village.children = village.buildList.map((build) => ({
|
|
283
|
+
...build,
|
|
284
|
+
level,
|
|
285
|
+
childType: "build",
|
|
286
|
+
key: `${village.key}_build_${build.id}`,
|
|
287
|
+
title: build.build_name,
|
|
288
|
+
extra: {
|
|
289
|
+
village_id: village.id,
|
|
290
|
+
village_name: village.name,
|
|
291
|
+
village_short_name: village.short_name,
|
|
292
|
+
},
|
|
293
|
+
slots: {
|
|
294
|
+
icon: "buildIcon",
|
|
295
|
+
},
|
|
296
|
+
isLeaf: false,
|
|
297
|
+
}));
|
|
298
|
+
} else {
|
|
299
|
+
village.isLeaf = true;
|
|
300
|
+
}
|
|
301
|
+
state.expandedKeys.push(village.key);
|
|
302
|
+
if (!state.selectedKeys.length) {
|
|
303
|
+
setSelected(village);
|
|
304
|
+
}
|
|
305
|
+
return village;
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const getVillageInfo = () => {
|
|
310
|
+
emit("request", {
|
|
311
|
+
params: {
|
|
312
|
+
method: "get",
|
|
313
|
+
server: "/org",
|
|
314
|
+
url: "/build/villageAndBuildList/v2",
|
|
315
|
+
extra: {
|
|
316
|
+
checked: props.attachDpt ? 1 : props.userChecked,
|
|
317
|
+
attach_department: props.attachDpt,
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
success: (res) => {
|
|
321
|
+
state.treeList = res.list
|
|
322
|
+
? getDeptTreeList(res.list, 1)
|
|
323
|
+
: getVillageTreeList(res.villageList);
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
const init = () => {
|
|
329
|
+
getVillageInfo();
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
init();
|
|
333
|
+
|
|
334
|
+
return {
|
|
335
|
+
...toRefs(state),
|
|
336
|
+
onRentIconClick,
|
|
337
|
+
onLoadTreeData,
|
|
338
|
+
onTreeSelect,
|
|
339
|
+
};
|
|
340
|
+
},
|
|
341
|
+
});
|
|
342
|
+
</script>
|