sadais-piui 1.2.7-beta36 → 1.2.7-beta39
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.
|
@@ -1,324 +1,493 @@
|
|
|
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[childrenField] && item[childrenField].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.
|
|
190
|
-
|
|
343
|
+
if (item[this.keyField] === ROOT_NODE) {
|
|
344
|
+
this.currentItem = cloneDeep(this.rootItem)
|
|
345
|
+
this.$nextTick(this.syncScrollLeft)
|
|
346
|
+
return
|
|
347
|
+
}
|
|
348
|
+
if (
|
|
349
|
+
item &&
|
|
350
|
+
item[this.childrenField]?.length &&
|
|
351
|
+
this.currentItem[this.keyField] !== item[this.keyField]
|
|
352
|
+
) {
|
|
353
|
+
this.currentItem = item
|
|
354
|
+
this.$nextTick(this.syncScrollLeft)
|
|
355
|
+
return
|
|
356
|
+
}
|
|
357
|
+
if (item && item[this.childrenField]?.length === 0) {
|
|
191
358
|
// 点击的是叶子节点
|
|
192
|
-
if (this.selectedIds.includes(item.
|
|
193
|
-
|
|
194
|
-
this.selectedIds = this.selectedIds.filter((i) => i !== item.uid);
|
|
359
|
+
if (this.selectedIds.includes(item[this.keyField])) {
|
|
360
|
+
this.handleRemoveItem(item[this.keyField])
|
|
195
361
|
} else {
|
|
196
362
|
// 选中
|
|
197
|
-
this.selectedIds.push(item.
|
|
363
|
+
this.selectedIds.push(item[this.keyField])
|
|
198
364
|
}
|
|
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
365
|
}
|
|
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
366
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
});
|
|
367
|
+
async syncScrollLeft() {
|
|
368
|
+
// 调用此方法的时候,必须使用$nextTick,因为column是动态变化的,需要等待界面更新渲染后,才能正确设置scrollLeft的位置
|
|
369
|
+
let scrollLeft = 0
|
|
370
|
+
if (this.cascaderWidth === 0) {
|
|
371
|
+
const srollWrapRect = await this.$pi.common.queryRect(this, '.pi-cascader', false)
|
|
372
|
+
if (srollWrapRect) {
|
|
373
|
+
this.cascaderWidth = srollWrapRect.width
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
if (this.columns.length > 2) {
|
|
377
|
+
scrollLeft = (this.columns.length - 2) * (this.cascaderWidth / 2)
|
|
378
|
+
}
|
|
379
|
+
this.scrollLeft = scrollLeft
|
|
232
380
|
},
|
|
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
|
-
});
|
|
381
|
+
handlePopupClose() {
|
|
382
|
+
this.val = false
|
|
383
|
+
// 关闭弹窗
|
|
384
|
+
this.$emit('close')
|
|
385
|
+
this.handleEmitChange()
|
|
247
386
|
},
|
|
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
|
-
});
|
|
387
|
+
/**
|
|
388
|
+
* @vuese
|
|
389
|
+
* 根据id获取item
|
|
390
|
+
*/
|
|
391
|
+
getItemByKeyField(keyField) {
|
|
392
|
+
return this.itemsMap[keyField]
|
|
270
393
|
},
|
|
271
|
-
|
|
272
|
-
|
|
394
|
+
/**
|
|
395
|
+
* @vuese
|
|
396
|
+
* 取消选择
|
|
397
|
+
*/
|
|
398
|
+
handleCancel() {
|
|
399
|
+
this.$emit('cancel')
|
|
400
|
+
this.getPopupSelect.onCancelClose && this.handlePopupClose()
|
|
401
|
+
},
|
|
402
|
+
/**
|
|
403
|
+
* @vuese
|
|
404
|
+
* 确认选择
|
|
405
|
+
*/
|
|
406
|
+
handleConfirm() {
|
|
407
|
+
this.$emit('confirm', this.selectedIds)
|
|
408
|
+
this.getPopupSelect.onConfirmClose && this.handlePopupClose()
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
273
412
|
</script>
|
|
274
413
|
|
|
275
414
|
<style lang="scss" scoped>
|
|
276
|
-
::-webkit-scrollbar {
|
|
277
|
-
width: 8rpx;
|
|
278
|
-
height: 8rpx;
|
|
279
|
-
}
|
|
280
|
-
::-webkit-scrollbar-thumb {
|
|
281
|
-
background: #00ff00;
|
|
282
|
-
}
|
|
283
415
|
.cascader-wrap {
|
|
284
416
|
width: 100%;
|
|
285
417
|
height: 100%;
|
|
418
|
+
background: #f4f2f6;
|
|
419
|
+
}
|
|
420
|
+
.scroll-view {
|
|
421
|
+
width: 100%;
|
|
422
|
+
flex: 1;
|
|
286
423
|
white-space: nowrap;
|
|
287
424
|
overflow: auto hidden;
|
|
288
|
-
background: #f4f2f6;
|
|
289
|
-
box-sizing: border-box;
|
|
290
|
-
font-size: 0;
|
|
291
425
|
.column {
|
|
292
426
|
display: inline-block;
|
|
293
427
|
height: 100%;
|
|
294
428
|
width: 50%;
|
|
295
429
|
overflow: hidden auto;
|
|
430
|
+
&:last-child {
|
|
431
|
+
background: #ffffff;
|
|
432
|
+
}
|
|
296
433
|
.column-item {
|
|
297
434
|
position: relative;
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
padding: 0
|
|
435
|
+
height: 100rpx;
|
|
436
|
+
width: 100%;
|
|
437
|
+
white-space: initial;
|
|
438
|
+
padding: 0 16rpx 0 32rpx;
|
|
302
439
|
font-size: 28rpx;
|
|
303
440
|
color: #333333;
|
|
441
|
+
overflow: hidden;
|
|
304
442
|
&.active {
|
|
305
|
-
color:
|
|
443
|
+
color: $pi-primary-color;
|
|
306
444
|
background: #ffffff;
|
|
307
445
|
}
|
|
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);
|
|
446
|
+
&.selected {
|
|
447
|
+
color: $pi-primary-color;
|
|
320
448
|
}
|
|
321
449
|
}
|
|
322
450
|
}
|
|
323
451
|
}
|
|
452
|
+
|
|
453
|
+
.node-breadcrumb {
|
|
454
|
+
width: 100%;
|
|
455
|
+
padding-left: 32rpx;
|
|
456
|
+
background: #ffffff;
|
|
457
|
+
white-space: nowrap;
|
|
458
|
+
.breadcrumb-item {
|
|
459
|
+
display: inline-flex;
|
|
460
|
+
align-items: center;
|
|
461
|
+
font-size: 14px;
|
|
462
|
+
padding: 32rpx 0;
|
|
463
|
+
|
|
464
|
+
.breadcrumb-item-title.active {
|
|
465
|
+
color: $pi-primary-color;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
.cascader-area {
|
|
471
|
+
background: #ffffff;
|
|
472
|
+
padding: 22rpx 24rpx;
|
|
473
|
+
color: #333333;
|
|
474
|
+
display: flex;
|
|
475
|
+
align-items: center;
|
|
476
|
+
white-space: nowrap;
|
|
477
|
+
|
|
478
|
+
.scroll-area {
|
|
479
|
+
width: calc(100% - 128rpx);
|
|
480
|
+
flex: 1;
|
|
481
|
+
white-space: nowrap;
|
|
482
|
+
}
|
|
483
|
+
.cascader-item {
|
|
484
|
+
display: inline-flex;
|
|
485
|
+
padding: 14rpx 24rpx;
|
|
486
|
+
background: rgba($pi-primary-color, 0.1);
|
|
487
|
+
align-items: center;
|
|
488
|
+
margin-left: 16rpx;
|
|
489
|
+
border-radius: 8rpx;
|
|
490
|
+
color: $pi-primary-color;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
324
493
|
</style>
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
|
+
import ValueSync from '../../mixin/value-sync'
|
|
9
10
|
import { getConfig } from '../../config'
|
|
10
11
|
const { collapse } = getConfig()
|
|
11
12
|
/**
|
|
@@ -17,6 +18,8 @@ const { collapse } = getConfig()
|
|
|
17
18
|
*/
|
|
18
19
|
export default {
|
|
19
20
|
name: 'PiCollapse',
|
|
21
|
+
// 混入v-model
|
|
22
|
+
mixins: [ValueSync],
|
|
20
23
|
props: {
|
|
21
24
|
// 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
|
|
22
25
|
value: {
|
|
@@ -110,7 +113,8 @@ export default {
|
|
|
110
113
|
})
|
|
111
114
|
})
|
|
112
115
|
// 触发change事件
|
|
113
|
-
this
|
|
116
|
+
this.val = changeArr
|
|
117
|
+
this.handleEmitChange()
|
|
114
118
|
this.$emit(target.expanded ? 'open' : 'close', target.name)
|
|
115
119
|
}
|
|
116
120
|
}
|
|
@@ -164,17 +164,18 @@ export default {
|
|
|
164
164
|
if (!this.parent) {
|
|
165
165
|
return console.error('pi-collapse-item必须要搭配pi-collapse组件使用')
|
|
166
166
|
}
|
|
167
|
-
const {
|
|
167
|
+
const { val, accordion } = this.parent
|
|
168
|
+
console.log('折叠面板item初始化', val, accordion)
|
|
168
169
|
if (accordion) {
|
|
169
|
-
if (this.$pi.lang.isArray(
|
|
170
|
+
if (this.$pi.lang.isArray(val)) {
|
|
170
171
|
return console.error('手风琴模式下,pi-collapse组件的value参数不能为数组')
|
|
171
172
|
}
|
|
172
|
-
this.expanded = this.name ==
|
|
173
|
+
this.expanded = this.name == val
|
|
173
174
|
} else {
|
|
174
|
-
if (!this.$pi.lang.isArray(
|
|
175
|
+
if (!this.$pi.lang.isArray(val) && val !== null) {
|
|
175
176
|
return console.error('非手风琴模式下,pi-collapse组件的value参数必须为数组')
|
|
176
177
|
}
|
|
177
|
-
this.expanded = (
|
|
178
|
+
this.expanded = (val || []).some(item => item == this.name)
|
|
178
179
|
}
|
|
179
180
|
// 设置组件的展开或收起状态
|
|
180
181
|
this.$nextTick(function() {
|
|
@@ -339,7 +340,7 @@ export default {
|
|
|
339
340
|
}
|
|
340
341
|
&__content {
|
|
341
342
|
overflow: hidden;
|
|
342
|
-
height:
|
|
343
|
+
height: auto;
|
|
343
344
|
|
|
344
345
|
&__text {
|
|
345
346
|
padding: 24rpx 30rpx;
|
|
@@ -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
|
+
}
|