sadais-piui 1.2.7-beta36 → 1.2.7-beta37
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/components/pi-cascader/index.vue +392 -227
- package/config/cascader.js +21 -0
- package/package.json +1 -1
|
@@ -1,324 +1,489 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
<pi-popup-select
|
|
3
|
+
:value="val"
|
|
4
|
+
:custom-style="getPopupSelect.customStyle"
|
|
5
|
+
:custom-class="getPopupSelect.customClass"
|
|
6
|
+
:height="getPopupSelect.height"
|
|
7
|
+
:show-title="getPopupSelect.showTitle"
|
|
8
|
+
:title="getPopupSelect.title"
|
|
9
|
+
:title-padding="getPopupSelect.titlePadding"
|
|
10
|
+
:toolbar-position="getPopupSelect.toolbarPosition"
|
|
11
|
+
:on-confirm-close="getPopupSelect.onConfirmClose"
|
|
12
|
+
:on-cancel-close="getPopupSelect.onCancelClose"
|
|
13
|
+
:confirm-btn="getConfirmBtn"
|
|
14
|
+
:cancel-btn="getCancelBtn"
|
|
15
|
+
:popup="getPopup"
|
|
16
|
+
@close="handlePopupClose"
|
|
17
|
+
@cancel="handleCancel"
|
|
18
|
+
@confirm="handleConfirm"
|
|
19
|
+
>
|
|
20
|
+
<view
|
|
21
|
+
class="pi-cascader pi-h-100P pi-flex-column"
|
|
22
|
+
:style="[customStyle]"
|
|
23
|
+
:class="[customClass]"
|
|
24
|
+
>
|
|
25
|
+
<slot name="header" />
|
|
26
|
+
<view class="cascader-wrap pi-flex-sub pi-flex-column">
|
|
27
|
+
<!-- 顶部面包屑 -->
|
|
28
|
+
<scroll-view class="node-breadcrumb pi-solid-bottom-1" scroll-x>
|
|
29
|
+
<view
|
|
30
|
+
v-for="(item, index) in pathItems"
|
|
31
|
+
:key="index"
|
|
32
|
+
class="breadcrumb-item"
|
|
33
|
+
@click="handleClickItem(item)"
|
|
34
|
+
>
|
|
35
|
+
<pi-icon v-if="item[keyField] !== ROOT_NODE" name="right" custom-class="pi-mg-lr-6" />
|
|
36
|
+
<view
|
|
37
|
+
class="breadcrumb-item-title"
|
|
38
|
+
:class="{
|
|
39
|
+
active: currentItem && currentItem[keyField] === item[keyField]
|
|
40
|
+
}"
|
|
41
|
+
>
|
|
42
|
+
{{ item[displayField] }}
|
|
43
|
+
</view>
|
|
44
|
+
</view>
|
|
45
|
+
</scroll-view>
|
|
46
|
+
<!-- 选择区域 -->
|
|
47
|
+
<scroll-view class="scroll-view" :scroll-left="scrollLeft" scroll-x scroll-with-animation>
|
|
48
|
+
<scroll-view
|
|
49
|
+
v-for="(col, index) of columns"
|
|
50
|
+
:key="index"
|
|
51
|
+
scroll-y
|
|
52
|
+
class="column"
|
|
53
|
+
:style="[{ width: isOnlyColumn ? '100%' : '50%' }]"
|
|
54
|
+
>
|
|
55
|
+
<view
|
|
56
|
+
v-for="item in col"
|
|
57
|
+
:key="item[keyField]"
|
|
58
|
+
class="column-item pi-align-center"
|
|
59
|
+
:class="{
|
|
60
|
+
active: activeIds.includes(item[keyField]),
|
|
61
|
+
selected: selectedIds.includes(item[keyField])
|
|
62
|
+
}"
|
|
63
|
+
@click="handleClickItem(item)"
|
|
64
|
+
>
|
|
65
|
+
<view class="pi-flex-sub pi-lh-36">
|
|
66
|
+
<slot name="item" :item="item">
|
|
67
|
+
{{ item[displayField] || '' }}
|
|
68
|
+
</slot>
|
|
69
|
+
</view>
|
|
70
|
+
<pi-icon v-if="selectedIds.includes(item[keyField])" name="blod-check" />
|
|
71
|
+
<pi-icon v-if="item.children && item.children.length > 0" name="right" />
|
|
72
|
+
</view>
|
|
73
|
+
</scroll-view>
|
|
74
|
+
</scroll-view>
|
|
75
|
+
<!-- 已选区域 -->
|
|
76
|
+
<view class="cascader-area">
|
|
77
|
+
<text>{{ `已选(${selectedIds.length})` }}</text>
|
|
78
|
+
<scroll-view class="scroll-area" scroll-x>
|
|
79
|
+
<view
|
|
80
|
+
v-for="id in selectedIds"
|
|
81
|
+
:key="id"
|
|
82
|
+
class="cascader-item"
|
|
83
|
+
@tap="handleRemoveItem(id)"
|
|
84
|
+
>
|
|
85
|
+
<text class="pi-mg-right-12">{{ itemsMap[id][displayField] }}</text>
|
|
86
|
+
<pi-icon name="close" />
|
|
87
|
+
</view>
|
|
88
|
+
</scroll-view>
|
|
89
|
+
</view>
|
|
15
90
|
</view>
|
|
91
|
+
<slot name="footer" />
|
|
16
92
|
</view>
|
|
17
|
-
</
|
|
93
|
+
</pi-popup-select>
|
|
18
94
|
</template>
|
|
19
95
|
|
|
20
96
|
<script>
|
|
97
|
+
import ValueSync from '../../mixin/value-sync'
|
|
98
|
+
import cloneDeep from 'lodash/cloneDeep'
|
|
99
|
+
import { getConfig } from '../../config'
|
|
100
|
+
|
|
101
|
+
const TAG = 'PiCascader'
|
|
102
|
+
const ROOT_NODE = 'ROOT'
|
|
103
|
+
const { cascader } = getConfig()
|
|
104
|
+
|
|
21
105
|
export default {
|
|
22
|
-
name:
|
|
23
|
-
model
|
|
24
|
-
|
|
25
|
-
event: "input",
|
|
26
|
-
},
|
|
106
|
+
name: 'PiCascader',
|
|
107
|
+
// 混入v-model
|
|
108
|
+
mixins: [ValueSync],
|
|
27
109
|
props: {
|
|
28
|
-
//
|
|
110
|
+
// 初始值
|
|
111
|
+
value: {
|
|
112
|
+
required: false
|
|
113
|
+
},
|
|
114
|
+
// 自定义样式
|
|
29
115
|
customStyle: {
|
|
30
116
|
type: Object,
|
|
117
|
+
// {}
|
|
31
118
|
default() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
119
|
+
return cascader.customStyle
|
|
120
|
+
}
|
|
35
121
|
},
|
|
36
|
-
//
|
|
122
|
+
// 自定义样式类
|
|
37
123
|
customClass: {
|
|
38
124
|
type: String,
|
|
39
125
|
// ''
|
|
40
126
|
default() {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
127
|
+
return cascader.customClass
|
|
128
|
+
}
|
|
43
129
|
},
|
|
44
130
|
// 数据源
|
|
45
|
-
|
|
131
|
+
items: {
|
|
46
132
|
type: Array,
|
|
47
133
|
default() {
|
|
48
|
-
return []
|
|
49
|
-
}
|
|
134
|
+
return []
|
|
135
|
+
}
|
|
50
136
|
},
|
|
51
|
-
|
|
137
|
+
defaultValue: {
|
|
52
138
|
type: Array,
|
|
53
|
-
default: () => []
|
|
139
|
+
default: () => []
|
|
54
140
|
},
|
|
55
|
-
//
|
|
56
|
-
|
|
141
|
+
// 列表选项的唯一标识
|
|
142
|
+
keyField: {
|
|
143
|
+
type: String,
|
|
144
|
+
// 'id'
|
|
145
|
+
default: cascader.keyField
|
|
146
|
+
},
|
|
147
|
+
// 选项显示字段
|
|
148
|
+
displayField: {
|
|
149
|
+
type: String,
|
|
150
|
+
// 'text'
|
|
151
|
+
default: cascader.displayField
|
|
152
|
+
},
|
|
153
|
+
// children字段,默认为desc
|
|
154
|
+
childrenField: {
|
|
155
|
+
type: String,
|
|
156
|
+
// 'children'
|
|
157
|
+
default: cascader.childrenField
|
|
158
|
+
},
|
|
159
|
+
// 弹窗选择参数设置
|
|
160
|
+
popupSelect: {
|
|
57
161
|
type: Object,
|
|
58
162
|
default() {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
children: "children",
|
|
63
|
-
id: "id",
|
|
64
|
-
expandTrigger: true,
|
|
65
|
-
};
|
|
66
|
-
},
|
|
163
|
+
// 参照popupSelect
|
|
164
|
+
return cascader.popupSelect
|
|
165
|
+
}
|
|
67
166
|
},
|
|
167
|
+
// 确认按钮配置
|
|
168
|
+
confirmBtn: {
|
|
169
|
+
type: Object,
|
|
170
|
+
default() {
|
|
171
|
+
return cascader.confirmBtn
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
// 取消按钮配置
|
|
175
|
+
cancelBtn: {
|
|
176
|
+
type: Object,
|
|
177
|
+
default() {
|
|
178
|
+
return cascader.cancelBtn
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
// 弹窗参数设置
|
|
182
|
+
popup: {
|
|
183
|
+
type: Object,
|
|
184
|
+
default() {
|
|
185
|
+
// 参照popup
|
|
186
|
+
return cascader.popup
|
|
187
|
+
}
|
|
188
|
+
}
|
|
68
189
|
},
|
|
69
190
|
data() {
|
|
191
|
+
const rootItem = {
|
|
192
|
+
[this.displayField]: '全部',
|
|
193
|
+
[this.keyField]: ROOT_NODE
|
|
194
|
+
}
|
|
70
195
|
return {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
196
|
+
rootItem,
|
|
197
|
+
currentItem: cloneDeep(rootItem),
|
|
198
|
+
innerItems: [],
|
|
199
|
+
itemsMap: {}, // 已选数据id索引
|
|
200
|
+
selectedIds: [], // 已选数据
|
|
201
|
+
cascaderWidth: 0, // 容器宽度
|
|
202
|
+
scrollLeft: 0 // 视图左侧滚动区域,自动对齐到选择的栏目
|
|
203
|
+
}
|
|
77
204
|
},
|
|
78
205
|
computed: {
|
|
206
|
+
ROOT_NODE() {
|
|
207
|
+
return ROOT_NODE
|
|
208
|
+
},
|
|
209
|
+
getPopupSelect() {
|
|
210
|
+
const popupSelect = this.$pi.lang.mergeDeep(cascader.popupSelect, this.popupSelect)
|
|
211
|
+
if (!this.singleCancel && this.singleConfirm) {
|
|
212
|
+
popupSelect.toolbarPosition = 'none'
|
|
213
|
+
}
|
|
214
|
+
return popupSelect
|
|
215
|
+
},
|
|
216
|
+
getConfirmBtn() {
|
|
217
|
+
const cascaderConfirmBtn = this.$pi.lang.mergeDeep(
|
|
218
|
+
cascader.confirmBtn,
|
|
219
|
+
this.popupSelect.confirmBtn
|
|
220
|
+
)
|
|
221
|
+
return this.$pi.lang.mergeDeep(cascaderConfirmBtn, this.confirmBtn)
|
|
222
|
+
},
|
|
223
|
+
getCancelBtn() {
|
|
224
|
+
const cascaderCancelBtn = this.$pi.lang.mergeDeep(
|
|
225
|
+
cascader.cancelBtn,
|
|
226
|
+
this.popupSelect.cancelBtn
|
|
227
|
+
)
|
|
228
|
+
return this.$pi.lang.mergeDeep(cascaderCancelBtn, this.cancelBtn)
|
|
229
|
+
},
|
|
230
|
+
getPopup() {
|
|
231
|
+
const cascaderPopup = this.$pi.lang.mergeDeep(cascader.popup, this.popupSelect.popup)
|
|
232
|
+
return this.$pi.lang.mergeDeep(cascaderPopup, this.popup)
|
|
233
|
+
},
|
|
234
|
+
getItemStyle() {
|
|
235
|
+
return {
|
|
236
|
+
height: this.$pi.common.addUnit(this.itemHeight)
|
|
237
|
+
}
|
|
238
|
+
},
|
|
79
239
|
columns() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
240
|
+
let columns = []
|
|
241
|
+
if (this.currentItem) {
|
|
242
|
+
// 如果有当前显示的节点,往上找父节点下的所有children放到数组的前面
|
|
243
|
+
let p = this.currentItem
|
|
83
244
|
while (p) {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
|
|
245
|
+
const children = p[this.childrenField] || []
|
|
246
|
+
if (children.length > 0) {
|
|
247
|
+
columns.unshift(children)
|
|
87
248
|
}
|
|
88
|
-
p = this.
|
|
249
|
+
p = p.pid ? this.itemsMap[p.pid] : undefined
|
|
89
250
|
}
|
|
90
|
-
|
|
91
|
-
|
|
251
|
+
columns.unshift(this.innerItems)
|
|
252
|
+
} else {
|
|
253
|
+
columns = [this.innerItems]
|
|
92
254
|
}
|
|
93
|
-
return
|
|
255
|
+
return columns
|
|
256
|
+
},
|
|
257
|
+
isOnlyColumn() {
|
|
258
|
+
return this.columns.length === 1
|
|
94
259
|
},
|
|
95
260
|
activeIds() {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
261
|
+
return this.pathItems.map(i => i[this.keyField])
|
|
262
|
+
},
|
|
263
|
+
pathItems() {
|
|
264
|
+
const pathItems = []
|
|
265
|
+
if (this.currentItem[this.keyField] !== ROOT_NODE) {
|
|
266
|
+
// 往上找构建完整路径
|
|
267
|
+
let p = this.currentItem
|
|
99
268
|
while (p) {
|
|
100
|
-
|
|
101
|
-
p = this.
|
|
269
|
+
pathItems.unshift(p)
|
|
270
|
+
p = this.itemsMap[p.pid]
|
|
102
271
|
}
|
|
103
|
-
return arr;
|
|
104
272
|
}
|
|
105
|
-
return [
|
|
273
|
+
return [
|
|
274
|
+
{
|
|
275
|
+
[this.displayField]: '全部',
|
|
276
|
+
[this.keyField]: 'ROOT'
|
|
277
|
+
}
|
|
278
|
+
].concat(pathItems)
|
|
106
279
|
},
|
|
107
280
|
syncIds() {
|
|
108
|
-
return this.
|
|
109
|
-
}
|
|
281
|
+
return `${this.innerItems.length}-${this.defaultValue.length}`
|
|
282
|
+
}
|
|
110
283
|
},
|
|
111
284
|
watch: {
|
|
112
|
-
|
|
285
|
+
items: {
|
|
113
286
|
immediate: true,
|
|
114
287
|
handler() {
|
|
115
|
-
this.
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
syncIds: {
|
|
119
|
-
handler() {
|
|
120
|
-
this.initSelectedIds();
|
|
121
|
-
},
|
|
122
|
-
},
|
|
288
|
+
this.rebuildItems()
|
|
289
|
+
}
|
|
290
|
+
}
|
|
123
291
|
},
|
|
292
|
+
|
|
124
293
|
methods: {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
return c.toString(16);
|
|
137
|
-
});
|
|
138
|
-
},
|
|
139
|
-
initSelectedIds() {
|
|
140
|
-
let curs = [...this.innerOptions];
|
|
141
|
-
const items = Object.values(this.optMap);
|
|
142
|
-
const results = [];
|
|
143
|
-
for (const val of this.value) {
|
|
144
|
-
const item = items.filter((i) => i[this.props.value] === val)[0];
|
|
145
|
-
if (item) {
|
|
146
|
-
results.push(item.uid);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
this.selectedIds = results;
|
|
150
|
-
},
|
|
151
|
-
rebuildOptions() {
|
|
152
|
-
// 以非递归的方式 深度拷贝options 且建立父子节点关系
|
|
153
|
-
// 目的为了不影响外部传入的prop: options
|
|
154
|
-
const newOptions = [];
|
|
155
|
-
// 初始化堆栈 为options的根节点
|
|
156
|
-
const stack = [...this.options];
|
|
157
|
-
const optMap = {};
|
|
294
|
+
rebuildItems() {
|
|
295
|
+
/**
|
|
296
|
+
* 以非递归的方式 深度拷贝items 且建立父子节点关系
|
|
297
|
+
* 目的为了不影响外部传入的prop: items
|
|
298
|
+
* 写成非递归的目的 是为了防止树的层次太深,
|
|
299
|
+
* 递归调用太多次,导致栈溢出
|
|
300
|
+
*/
|
|
301
|
+
const innerItems = []
|
|
302
|
+
// 初始化堆栈 为items的根节点
|
|
303
|
+
const stack = [...this.items]
|
|
304
|
+
const itemsMap = {}
|
|
158
305
|
while (stack.length > 0) {
|
|
159
|
-
|
|
306
|
+
// 将栈顶元素出栈进行处理
|
|
307
|
+
let item = stack.shift()
|
|
160
308
|
if (!item.pid) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
309
|
+
item = {
|
|
310
|
+
...item,
|
|
311
|
+
level: 0
|
|
312
|
+
}
|
|
313
|
+
innerItems.push(item)
|
|
164
314
|
}
|
|
165
|
-
const children = item[this.
|
|
166
|
-
const newChilds = []
|
|
315
|
+
const children = item[this.childrenField] || []
|
|
316
|
+
const newChilds = []
|
|
167
317
|
for (let i = children.length - 1; i >= 0; i--) {
|
|
168
|
-
//
|
|
318
|
+
// 浅拷贝子孩子
|
|
169
319
|
const subItem = {
|
|
170
320
|
...children[i],
|
|
171
|
-
level: item.level + 1
|
|
172
|
-
|
|
173
|
-
};
|
|
321
|
+
level: item.level + 1
|
|
322
|
+
}
|
|
174
323
|
// 建立父子关系
|
|
175
|
-
subItem.pid = item.
|
|
324
|
+
subItem.pid = item[this.keyField]
|
|
176
325
|
// 放置到新数组中
|
|
177
|
-
newChilds.unshift(subItem)
|
|
178
|
-
// 入栈 模拟递归效果
|
|
179
|
-
stack.unshift(subItem)
|
|
326
|
+
newChilds.unshift(subItem)
|
|
327
|
+
// 入栈 模拟递归效果 等待之后的while循环出栈进行处理
|
|
328
|
+
stack.unshift(subItem)
|
|
180
329
|
}
|
|
181
330
|
// 更新children 为新的数组
|
|
182
|
-
item[this.
|
|
183
|
-
|
|
331
|
+
item[this.childrenField] = newChilds
|
|
332
|
+
itemsMap[item[this.keyField]] = item
|
|
184
333
|
}
|
|
185
|
-
|
|
186
|
-
this.
|
|
334
|
+
// 此时的innerItems无论怎么修改 均不影响items
|
|
335
|
+
this.innerItems = innerItems
|
|
336
|
+
// 方便通过节点的id 为key快速定位到对应的节点dto
|
|
337
|
+
this.itemsMap = itemsMap
|
|
338
|
+
},
|
|
339
|
+
handleRemoveItem(id) {
|
|
340
|
+
this.selectedIds = this.selectedIds.filter(i => i !== id)
|
|
187
341
|
},
|
|
188
342
|
handleClickItem(item) {
|
|
189
|
-
this.
|
|
343
|
+
if (item[this.keyField] === ROOT_NODE) {
|
|
344
|
+
this.currentItem = cloneDeep(this.rootItem)
|
|
345
|
+
this.$nextTick(this.syncScrollLeft)
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
if (item?.children?.length && this.currentItem[this.keyField] !== item[this.keyField]) {
|
|
349
|
+
this.currentItem = item
|
|
350
|
+
this.$nextTick(this.syncScrollLeft)
|
|
351
|
+
return
|
|
352
|
+
}
|
|
190
353
|
if (item?.children?.length === 0) {
|
|
191
354
|
// 点击的是叶子节点
|
|
192
|
-
if (this.selectedIds.includes(item.
|
|
193
|
-
|
|
194
|
-
this.selectedIds = this.selectedIds.filter((i) => i !== item.uid);
|
|
355
|
+
if (this.selectedIds.includes(item[this.keyField])) {
|
|
356
|
+
this.handleRemoveItem(item[this.keyField])
|
|
195
357
|
} else {
|
|
196
358
|
// 选中
|
|
197
|
-
this.selectedIds.push(item.
|
|
359
|
+
this.selectedIds.push(item[this.keyField])
|
|
198
360
|
}
|
|
199
|
-
// 根据选中的uid转换为对应的value
|
|
200
|
-
const values = this.selectedIds.reduce((prev, i) => {
|
|
201
|
-
const item = this.optMap[i];
|
|
202
|
-
if (item) {
|
|
203
|
-
prev.push(item[this.props.value]);
|
|
204
|
-
}
|
|
205
|
-
return prev;
|
|
206
|
-
}, []);
|
|
207
|
-
this.$emit("input", values);
|
|
208
|
-
this.$emit("change", values);
|
|
209
361
|
}
|
|
210
|
-
this.$nextTick(async () => {
|
|
211
|
-
const maxx = await this.getMaxX();
|
|
212
|
-
const containerWidth = await this.getViewport();
|
|
213
|
-
const left = await this.getScrollLeft();
|
|
214
|
-
const diff = maxx - (left + containerWidth);
|
|
215
|
-
this.scrollLeft = left + diff;
|
|
216
|
-
});
|
|
217
362
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
});
|
|
363
|
+
async syncScrollLeft() {
|
|
364
|
+
// 调用此方法的时候,必须使用$nextTick,因为column是动态变化的,需要等待界面更新渲染后,才能正确设置scrollLeft的位置
|
|
365
|
+
let scrollLeft = 0
|
|
366
|
+
if (this.cascaderWidth === 0) {
|
|
367
|
+
const srollWrapRect = await this.$pi.common.queryRect(this, '.pi-cascader', false)
|
|
368
|
+
if (srollWrapRect) {
|
|
369
|
+
this.cascaderWidth = srollWrapRect.width
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (this.columns.length > 2) {
|
|
373
|
+
scrollLeft = (this.columns.length - 2) * (this.cascaderWidth / 2)
|
|
374
|
+
}
|
|
375
|
+
this.scrollLeft = scrollLeft
|
|
232
376
|
},
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
//#endif
|
|
239
|
-
const columns = ctx
|
|
240
|
-
.select(".cascader-wrap")
|
|
241
|
-
.scrollOffset((res) => {
|
|
242
|
-
console.log(res);
|
|
243
|
-
resolve(res?.scrollLeft || 0);
|
|
244
|
-
})
|
|
245
|
-
.exec();
|
|
246
|
-
});
|
|
377
|
+
handlePopupClose() {
|
|
378
|
+
this.val = false
|
|
379
|
+
// 关闭弹窗
|
|
380
|
+
this.$emit('close')
|
|
381
|
+
this.handleEmitChange()
|
|
247
382
|
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const columns = ctx
|
|
255
|
-
.selectAll(".column")
|
|
256
|
-
.boundingClientRect((res) => {
|
|
257
|
-
console.log(res);
|
|
258
|
-
if (res?.length > 0) {
|
|
259
|
-
const x = res.reduce((prev, i) => {
|
|
260
|
-
prev += i.width;
|
|
261
|
-
return prev;
|
|
262
|
-
}, 0);
|
|
263
|
-
resolve(x);
|
|
264
|
-
} else {
|
|
265
|
-
resolve(0);
|
|
266
|
-
}
|
|
267
|
-
})
|
|
268
|
-
.exec();
|
|
269
|
-
});
|
|
383
|
+
/**
|
|
384
|
+
* @vuese
|
|
385
|
+
* 根据id获取item
|
|
386
|
+
*/
|
|
387
|
+
getItemByKeyField(keyField) {
|
|
388
|
+
return this.itemsMap[keyField]
|
|
270
389
|
},
|
|
271
|
-
|
|
272
|
-
|
|
390
|
+
/**
|
|
391
|
+
* @vuese
|
|
392
|
+
* 取消选择
|
|
393
|
+
*/
|
|
394
|
+
handleCancel() {
|
|
395
|
+
this.$emit('cancel')
|
|
396
|
+
this.getPopupSelect.onCancelClose && this.handlePopupClose()
|
|
397
|
+
},
|
|
398
|
+
/**
|
|
399
|
+
* @vuese
|
|
400
|
+
* 确认选择
|
|
401
|
+
*/
|
|
402
|
+
handleConfirm() {
|
|
403
|
+
this.$emit('confirm', this.selectedIds)
|
|
404
|
+
this.getPopupSelect.onConfirmClose && this.handlePopupClose()
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
273
408
|
</script>
|
|
274
409
|
|
|
275
410
|
<style lang="scss" scoped>
|
|
276
|
-
::-webkit-scrollbar {
|
|
277
|
-
width: 8rpx;
|
|
278
|
-
height: 8rpx;
|
|
279
|
-
}
|
|
280
|
-
::-webkit-scrollbar-thumb {
|
|
281
|
-
background: #00ff00;
|
|
282
|
-
}
|
|
283
411
|
.cascader-wrap {
|
|
284
412
|
width: 100%;
|
|
285
413
|
height: 100%;
|
|
414
|
+
background: #f4f2f6;
|
|
415
|
+
}
|
|
416
|
+
.scroll-view {
|
|
417
|
+
width: 100%;
|
|
418
|
+
flex: 1;
|
|
286
419
|
white-space: nowrap;
|
|
287
420
|
overflow: auto hidden;
|
|
288
|
-
background: #f4f2f6;
|
|
289
|
-
box-sizing: border-box;
|
|
290
|
-
font-size: 0;
|
|
291
421
|
.column {
|
|
292
422
|
display: inline-block;
|
|
293
423
|
height: 100%;
|
|
294
424
|
width: 50%;
|
|
295
425
|
overflow: hidden auto;
|
|
426
|
+
&:last-child {
|
|
427
|
+
background: #ffffff;
|
|
428
|
+
}
|
|
296
429
|
.column-item {
|
|
297
430
|
position: relative;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
padding: 0
|
|
431
|
+
height: 100rpx;
|
|
432
|
+
width: 100%;
|
|
433
|
+
white-space: initial;
|
|
434
|
+
padding: 0 16rpx 0 32rpx;
|
|
302
435
|
font-size: 28rpx;
|
|
303
436
|
color: #333333;
|
|
437
|
+
overflow: hidden;
|
|
304
438
|
&.active {
|
|
305
|
-
color:
|
|
439
|
+
color: $pi-primary-color;
|
|
306
440
|
background: #ffffff;
|
|
307
441
|
}
|
|
308
|
-
&.
|
|
309
|
-
|
|
310
|
-
content: "";
|
|
311
|
-
width: 16rpx;
|
|
312
|
-
height: 16rpx;
|
|
313
|
-
border: 2rpx solid #333333;
|
|
314
|
-
border-top: none;
|
|
315
|
-
border-left: none;
|
|
316
|
-
position: absolute;
|
|
317
|
-
right: 8rpx;
|
|
318
|
-
top: 50%;
|
|
319
|
-
transform: translateY(-50%) rotate(-45deg);
|
|
442
|
+
&.selected {
|
|
443
|
+
color: $pi-primary-color;
|
|
320
444
|
}
|
|
321
445
|
}
|
|
322
446
|
}
|
|
323
447
|
}
|
|
448
|
+
|
|
449
|
+
.node-breadcrumb {
|
|
450
|
+
width: 100%;
|
|
451
|
+
padding-left: 32rpx;
|
|
452
|
+
background: #ffffff;
|
|
453
|
+
white-space: nowrap;
|
|
454
|
+
.breadcrumb-item {
|
|
455
|
+
display: inline-flex;
|
|
456
|
+
align-items: center;
|
|
457
|
+
font-size: 14px;
|
|
458
|
+
padding: 32rpx 0;
|
|
459
|
+
|
|
460
|
+
.breadcrumb-item-title.active {
|
|
461
|
+
color: $pi-primary-color;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
.cascader-area {
|
|
467
|
+
background: #ffffff;
|
|
468
|
+
padding: 22rpx 24rpx;
|
|
469
|
+
color: #333333;
|
|
470
|
+
display: flex;
|
|
471
|
+
align-items: center;
|
|
472
|
+
white-space: nowrap;
|
|
473
|
+
|
|
474
|
+
.scroll-area {
|
|
475
|
+
width: calc(100% - 128rpx);
|
|
476
|
+
flex: 1;
|
|
477
|
+
white-space: nowrap;
|
|
478
|
+
}
|
|
479
|
+
.cascader-item {
|
|
480
|
+
display: inline-flex;
|
|
481
|
+
padding: 14rpx 24rpx;
|
|
482
|
+
background: rgba($pi-primary-color, 0.1);
|
|
483
|
+
align-items: center;
|
|
484
|
+
margin-left: 16rpx;
|
|
485
|
+
border-radius: 8rpx;
|
|
486
|
+
color: $pi-primary-color;
|
|
487
|
+
}
|
|
488
|
+
}
|
|
324
489
|
</style>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import popupSelect from './popupSelect'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
customClass: '', // 自定义样式类,字符串形式('')
|
|
5
|
+
customStyle: {}, // 自定义样式,对象形式(默认值:{})
|
|
6
|
+
items: [], // 选项列表,默认([])
|
|
7
|
+
keyField: 'id', // 选项id字段,默认为id
|
|
8
|
+
displayField: 'text', // 选项显示字段,默认为text
|
|
9
|
+
childrenField: 'children', // 描述显示字段,默认为children
|
|
10
|
+
defaultValue: null, // 默认值,单选是传Object,多选时传Array,默认null
|
|
11
|
+
itemHeight: 110, // 行高(默认:'110rpx')
|
|
12
|
+
showItemBottomBorder: false, // 是否显示item下边框(默认:'true')
|
|
13
|
+
itemStyle: {}, // 行样式(默认:'{}')
|
|
14
|
+
popupSelect: popupSelect, // popupSelect配置
|
|
15
|
+
popup: popupSelect.popup, // 弹窗的配置,默认选项请参照popup
|
|
16
|
+
confirmBtn: popupSelect.confirmBtn, // 确认按钮配置
|
|
17
|
+
cancelBtn: {
|
|
18
|
+
...popupSelect.cancelBtn,
|
|
19
|
+
show: true
|
|
20
|
+
} // 取消按钮配置
|
|
21
|
+
}
|