sadais-piui 1.2.7-beta96 → 1.2.7-beta98
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/.prettierrc
ADDED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2022-05-18 11:08:49
|
|
4
|
-
* @LastEditTime:
|
|
4
|
+
* @LastEditTime: 2024-03-19 18:23:46
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 日历输入
|
|
7
|
-
* @FilePath:
|
|
7
|
+
* @FilePath: /piui-awesome/src/piui/components/pi-regions-select-input/index.vue
|
|
8
8
|
-->
|
|
9
9
|
|
|
10
10
|
<template>
|
|
11
11
|
<view class="pi-regions-select-input">
|
|
12
12
|
<!-- 输入框 -->
|
|
13
|
-
<view
|
|
13
|
+
<view
|
|
14
|
+
v-if="$slots.default || $slots.$default"
|
|
15
|
+
class="pi-w-100P"
|
|
16
|
+
@click="show = true"
|
|
17
|
+
>
|
|
14
18
|
<slot />
|
|
15
19
|
</view>
|
|
16
20
|
<pi-input
|
|
@@ -149,7 +153,13 @@ export default {
|
|
|
149
153
|
return this.$pi.lang.mergeDeep(regionsSelectInput.input, this.input)
|
|
150
154
|
},
|
|
151
155
|
getRegionsSelect() {
|
|
152
|
-
return
|
|
156
|
+
return {
|
|
157
|
+
...this.$pi.lang.mergeDeep(
|
|
158
|
+
regionsSelectInput.regionsSelect,
|
|
159
|
+
this.regionsSelect
|
|
160
|
+
),
|
|
161
|
+
regionsData: this.regionsSelect.regionsData
|
|
162
|
+
}
|
|
153
163
|
},
|
|
154
164
|
getInputValue() {
|
|
155
165
|
const parseValueFn = this.parseValueFn[PI_DEFAULT_FN_FLAG]
|
|
@@ -164,7 +174,10 @@ export default {
|
|
|
164
174
|
const code = this.getRegionsSelect.keyDefaultValue
|
|
165
175
|
? this.val
|
|
166
176
|
: this.val[this.getRegionsSelect.keyField]
|
|
167
|
-
const regions = this.$pi.regions.parseRegions(
|
|
177
|
+
const regions = this.$pi.regions.parseRegions(
|
|
178
|
+
code,
|
|
179
|
+
this.getRegionsSelect.regionsData
|
|
180
|
+
)
|
|
168
181
|
return this.generateRegionsName(regions)
|
|
169
182
|
}
|
|
170
183
|
},
|
|
@@ -20,7 +20,11 @@
|
|
|
20
20
|
@show="handleShowEvent"
|
|
21
21
|
@showed="$emit('showed', $event)"
|
|
22
22
|
>
|
|
23
|
-
<view
|
|
23
|
+
<view
|
|
24
|
+
class="pi-select pi-h-100P pi-flex-column"
|
|
25
|
+
:style="[customStyle]"
|
|
26
|
+
:class="[customClass]"
|
|
27
|
+
>
|
|
24
28
|
<slot name="header" />
|
|
25
29
|
<view
|
|
26
30
|
v-if="showSelectAll"
|
|
@@ -39,7 +43,10 @@
|
|
|
39
43
|
/>
|
|
40
44
|
</view>
|
|
41
45
|
</view>
|
|
42
|
-
<view
|
|
46
|
+
<view
|
|
47
|
+
v-if="getRemoteSearchConfig.enable && getRemoteSearchConfig.filter"
|
|
48
|
+
class="pi-pd-lr-24"
|
|
49
|
+
>
|
|
43
50
|
<pi-search
|
|
44
51
|
v-model="keyword"
|
|
45
52
|
:placeholder="getRemoteSearchConfig.filterPlaceholder"
|
|
@@ -70,10 +77,18 @@
|
|
|
70
77
|
@tap.stop="handleSelectItem(item)"
|
|
71
78
|
>
|
|
72
79
|
<!-- 自定义列表项 -->
|
|
73
|
-
<slot
|
|
80
|
+
<slot
|
|
81
|
+
name="item"
|
|
82
|
+
:item="item"
|
|
83
|
+
:selected="item.isSelected"
|
|
84
|
+
class="pi-w-100P"
|
|
85
|
+
>
|
|
74
86
|
<view>
|
|
75
87
|
<view class="select-item-title">{{ item[displayField] }}</view>
|
|
76
|
-
<view
|
|
88
|
+
<view
|
|
89
|
+
v-if="item[descField]"
|
|
90
|
+
class="pi-light-gray pi-fz-24 pi-mg-top-10 pi-lh-30"
|
|
91
|
+
>
|
|
77
92
|
{{ item[descField] }}
|
|
78
93
|
</view>
|
|
79
94
|
</view>
|
|
@@ -298,6 +313,11 @@ export default {
|
|
|
298
313
|
fn: select.parseRemoteSearchResult
|
|
299
314
|
}
|
|
300
315
|
}
|
|
316
|
+
},
|
|
317
|
+
// 兼容微信小程序无法属性传递function的问题 传递方法名进来
|
|
318
|
+
remoteMethod: {
|
|
319
|
+
type: String,
|
|
320
|
+
default: ''
|
|
301
321
|
}
|
|
302
322
|
},
|
|
303
323
|
data() {
|
|
@@ -316,13 +336,22 @@ export default {
|
|
|
316
336
|
return this.$pi.lang.mergeDeep(select.selectedImg, this.selectedImg)
|
|
317
337
|
},
|
|
318
338
|
getSelectedCheckbox() {
|
|
319
|
-
return this.$pi.lang.mergeDeep(
|
|
339
|
+
return this.$pi.lang.mergeDeep(
|
|
340
|
+
select.selectedCheckbox,
|
|
341
|
+
this.selectedCheckbox
|
|
342
|
+
)
|
|
320
343
|
},
|
|
321
344
|
getRemoteSearchConfig() {
|
|
322
|
-
return this.$pi.lang.mergeDeep(
|
|
345
|
+
return this.$pi.lang.mergeDeep(
|
|
346
|
+
select.remoteSearchConfig,
|
|
347
|
+
this.remoteSearchConfig
|
|
348
|
+
)
|
|
323
349
|
},
|
|
324
350
|
getPopupSelect() {
|
|
325
|
-
const popupSelect = this.$pi.lang.mergeDeep(
|
|
351
|
+
const popupSelect = this.$pi.lang.mergeDeep(
|
|
352
|
+
select.popupSelect,
|
|
353
|
+
this.popupSelect
|
|
354
|
+
)
|
|
326
355
|
if (!this.singleCancel && this.singleConfirm) {
|
|
327
356
|
popupSelect.toolbarPosition = 'none'
|
|
328
357
|
}
|
|
@@ -336,11 +365,17 @@ export default {
|
|
|
336
365
|
return this.$pi.lang.mergeDeep(selectConfirmBtn, this.confirmBtn)
|
|
337
366
|
},
|
|
338
367
|
getCancelBtn() {
|
|
339
|
-
const selectCancelBtn = this.$pi.lang.mergeDeep(
|
|
368
|
+
const selectCancelBtn = this.$pi.lang.mergeDeep(
|
|
369
|
+
select.cancelBtn,
|
|
370
|
+
this.popupSelect.cancelBtn
|
|
371
|
+
)
|
|
340
372
|
return this.$pi.lang.mergeDeep(selectCancelBtn, this.cancelBtn)
|
|
341
373
|
},
|
|
342
374
|
getPopup() {
|
|
343
|
-
const selectPopup = this.$pi.lang.mergeDeep(
|
|
375
|
+
const selectPopup = this.$pi.lang.mergeDeep(
|
|
376
|
+
select.popup,
|
|
377
|
+
this.popupSelect.popup
|
|
378
|
+
)
|
|
344
379
|
return this.$pi.lang.mergeDeep(selectPopup, this.popup)
|
|
345
380
|
},
|
|
346
381
|
getItemStyle() {
|
|
@@ -349,13 +384,17 @@ export default {
|
|
|
349
384
|
}
|
|
350
385
|
},
|
|
351
386
|
getItems() {
|
|
352
|
-
const targetItems = this.remoteSearchConfig.enable
|
|
387
|
+
const targetItems = this.remoteSearchConfig.enable
|
|
388
|
+
? this.remoteItems
|
|
389
|
+
: this.items
|
|
353
390
|
return targetItems.map(item => {
|
|
354
391
|
let isSelected = false
|
|
355
392
|
if (this.isMulti) {
|
|
356
393
|
isSelected =
|
|
357
394
|
this.$pi.lang.isArray(this.selected) &&
|
|
358
|
-
this.selected.findIndex(
|
|
395
|
+
this.selected.findIndex(
|
|
396
|
+
s => s[this.keyField] === item[this.keyField]
|
|
397
|
+
) !== -1
|
|
359
398
|
} else {
|
|
360
399
|
isSelected = this.selected[this.keyField] === item[this.keyField]
|
|
361
400
|
}
|
|
@@ -389,24 +428,40 @@ export default {
|
|
|
389
428
|
return this.$pi.lang.isObject(item)
|
|
390
429
|
})
|
|
391
430
|
if (this.keyDefaultValue && isArrayObject) {
|
|
392
|
-
console.error(
|
|
431
|
+
console.error(
|
|
432
|
+
TAG,
|
|
433
|
+
'keyDefaultValue模式下defaultValue不能为对象数组类型'
|
|
434
|
+
)
|
|
393
435
|
return false
|
|
394
436
|
}
|
|
395
437
|
if (!this.keyDefaultValue && !isArrayObject) {
|
|
396
|
-
console.error(
|
|
438
|
+
console.error(
|
|
439
|
+
TAG,
|
|
440
|
+
'非keyDefaultValue模式下defaultValue必须为对象数组类型'
|
|
441
|
+
)
|
|
397
442
|
return false
|
|
398
443
|
}
|
|
399
444
|
}
|
|
400
445
|
if (!this.isMulti) {
|
|
401
|
-
if (
|
|
402
|
-
|
|
446
|
+
if (
|
|
447
|
+
this.keyDefaultValue &&
|
|
448
|
+
this.$pi.lang.isObject(this.defaultValue)
|
|
449
|
+
) {
|
|
450
|
+
console.error(
|
|
451
|
+
TAG,
|
|
452
|
+
'keyDefaultValue模式下defaultValue不能为对象类型'
|
|
453
|
+
)
|
|
403
454
|
return false
|
|
404
455
|
}
|
|
405
456
|
if (
|
|
406
457
|
!this.keyDefaultValue &&
|
|
407
|
-
(!this.$pi.lang.isObject(this.defaultValue) ||
|
|
458
|
+
(!this.$pi.lang.isObject(this.defaultValue) ||
|
|
459
|
+
this.$pi.lang.isArray(this.defaultValue))
|
|
408
460
|
) {
|
|
409
|
-
console.error(
|
|
461
|
+
console.error(
|
|
462
|
+
TAG,
|
|
463
|
+
'非keyDefaultValue模式下defaultValue必须为对象类型'
|
|
464
|
+
)
|
|
410
465
|
return false
|
|
411
466
|
}
|
|
412
467
|
}
|
|
@@ -468,9 +523,13 @@ export default {
|
|
|
468
523
|
}
|
|
469
524
|
// 多选
|
|
470
525
|
const hasSelected =
|
|
471
|
-
this.selected.findIndex(
|
|
526
|
+
this.selected.findIndex(
|
|
527
|
+
s => s[this.keyField] === item[this.keyField]
|
|
528
|
+
) !== -1
|
|
472
529
|
if (hasSelected) {
|
|
473
|
-
this.selected = this.selected.filter(
|
|
530
|
+
this.selected = this.selected.filter(
|
|
531
|
+
s => s[this.keyField] !== item[this.keyField]
|
|
532
|
+
)
|
|
474
533
|
} else {
|
|
475
534
|
this.selected.push(item)
|
|
476
535
|
}
|
|
@@ -491,7 +550,10 @@ export default {
|
|
|
491
550
|
const toggleSelect = this.items.filter(item => {
|
|
492
551
|
let toggleNode = true
|
|
493
552
|
if (nodes.length) {
|
|
494
|
-
toggleNode =
|
|
553
|
+
toggleNode =
|
|
554
|
+
nodes.findIndex(
|
|
555
|
+
node => node[this.keyField] === item[this.keyField]
|
|
556
|
+
) !== -1
|
|
495
557
|
}
|
|
496
558
|
return toggleNode && !item.disabled
|
|
497
559
|
})
|
|
@@ -553,17 +615,36 @@ export default {
|
|
|
553
615
|
},
|
|
554
616
|
async handleRemoteSearch() {
|
|
555
617
|
if (this.remoteLoading) return
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
618
|
+
let parseRemoteSearchResult = null
|
|
619
|
+
if (this.remoteMethod) {
|
|
620
|
+
let node = this.$parent
|
|
621
|
+
while (node && !node[this.remoteMethod]) {
|
|
622
|
+
node = node.$parent
|
|
623
|
+
}
|
|
624
|
+
parseRemoteSearchResult = node?.[this.remoteMethod]
|
|
625
|
+
if (!parseRemoteSearchResult) {
|
|
626
|
+
console.error(`pi-select 找不到remoteMethod=${this.remoteMethod}`)
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
if (!parseRemoteSearchResult) {
|
|
630
|
+
parseRemoteSearchResult = this.parseRemoteSearchResult[
|
|
631
|
+
PI_DEFAULT_FN_FLAG
|
|
632
|
+
]
|
|
633
|
+
? this.parseRemoteSearchResult.fn
|
|
634
|
+
: this.parseRemoteSearchResult
|
|
635
|
+
if (!parseRemoteSearchResult) {
|
|
636
|
+
console.error(`pi-select parseRemoteSearchResult不存在`)
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (!parseRemoteSearchResult) {
|
|
640
|
+
return
|
|
641
|
+
}
|
|
642
|
+
this.remoteLoading = false
|
|
561
643
|
const items = await parseRemoteSearchResult(
|
|
562
644
|
this.pageNo,
|
|
563
645
|
this.getRemoteSearchConfig.pageSize,
|
|
564
646
|
this.keyword
|
|
565
647
|
)
|
|
566
|
-
this.remoteLoading = false
|
|
567
648
|
this.$hideLoading()
|
|
568
649
|
if (!this.$pi.lang.isArray(items)) {
|
|
569
650
|
console.error(TAG, items, '远程搜索结果必须为数组类型')
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
* @Author: zhangzhenfei
|
|
3
3
|
* @Date: 2022-05-18 11:08:49
|
|
4
|
-
* @LastEditTime: 2024-01-15
|
|
4
|
+
* @LastEditTime: 2024-01-29 15:44:16
|
|
5
5
|
* @LastEditors: zhangzhenfei
|
|
6
6
|
* @Description: 选择输入
|
|
7
7
|
* @FilePath: /piui/components/pi-select-input/index.vue
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
<template>
|
|
11
11
|
<view class="pi-select-input">
|
|
12
12
|
<!-- 输入框 -->
|
|
13
|
-
<view
|
|
13
|
+
<view
|
|
14
|
+
v-if="$slots.default || $slots.$default"
|
|
15
|
+
class="pi-w-100P"
|
|
16
|
+
@click="show = true"
|
|
17
|
+
>
|
|
14
18
|
<slot />
|
|
15
19
|
</view>
|
|
16
20
|
<pi-input
|
|
@@ -71,6 +75,7 @@
|
|
|
71
75
|
:cancel-btn="getSelect.cancelBtn"
|
|
72
76
|
:remote-search-config="getSelect.remoteSearchConfig"
|
|
73
77
|
:parse-remote-search-result="getSelect.parseRemoteSearchResult"
|
|
78
|
+
:remote-method="getSelect.remoteMethod"
|
|
74
79
|
@confirm="handleSelectConfirm"
|
|
75
80
|
@close="$emit('close', $event)"
|
|
76
81
|
@closed="$emit('closed', $event)"
|
|
@@ -169,13 +174,9 @@ export default {
|
|
|
169
174
|
},
|
|
170
175
|
methods: {
|
|
171
176
|
initRemoteSelectData() {
|
|
172
|
-
// 如果开启了远程搜索 则在创建之初 先触发一次搜索 让代码触发到用户自定义的parseRemoteSearchResult方法中
|
|
177
|
+
// 如果开启了远程搜索 则在创建之初 先触发一次搜索 让代码触发到用户自定义的remoteMethod or parseRemoteSearchResult方法中
|
|
173
178
|
// 目的为了回显数据
|
|
174
|
-
if (
|
|
175
|
-
this.getSelect.remoteSearchConfig.enable &&
|
|
176
|
-
this.getSelect.parseRemoteSearchResult &&
|
|
177
|
-
this.val
|
|
178
|
-
) {
|
|
179
|
+
if (this.getSelect.remoteSearchConfig.enable && this.val) {
|
|
179
180
|
this.$nextTick(async () => {
|
|
180
181
|
await this.$refs['pi-select'].handleRemoteSearch()
|
|
181
182
|
this.remoteVal = this.handleGetInputValue()
|
|
@@ -191,7 +192,8 @@ export default {
|
|
|
191
192
|
return parseValue
|
|
192
193
|
}
|
|
193
194
|
if (this.$pi.lang.isEmpty(this.val)) return ''
|
|
194
|
-
const getItems =
|
|
195
|
+
const getItems =
|
|
196
|
+
this.$refs['pi-select']?.getItems || this.getSelect.items || []
|
|
195
197
|
if (this.getSelect.keyDefaultValue) {
|
|
196
198
|
if (this.getSelect.isMulti) {
|
|
197
199
|
return getItems
|
|
@@ -199,7 +201,9 @@ export default {
|
|
|
199
201
|
.map(item => item[this.getSelect.displayField])
|
|
200
202
|
.join(this.rangeSplit)
|
|
201
203
|
} else {
|
|
202
|
-
const val = getItems.find(
|
|
204
|
+
const val = getItems.find(
|
|
205
|
+
item => item[this.getSelect.keyField] === this.val
|
|
206
|
+
)
|
|
203
207
|
return val ? val[this.getSelect.displayField] : ''
|
|
204
208
|
}
|
|
205
209
|
} else {
|
|
@@ -207,13 +211,18 @@ export default {
|
|
|
207
211
|
if (this.getSelect.isMulti) {
|
|
208
212
|
return getItems
|
|
209
213
|
.filter(item =>
|
|
210
|
-
this.val.some(
|
|
214
|
+
this.val.some(
|
|
215
|
+
v =>
|
|
216
|
+
v[this.getSelect.keyField] === item[this.getSelect.keyField]
|
|
217
|
+
)
|
|
211
218
|
)
|
|
212
219
|
.map(item => item[this.getSelect.displayField])
|
|
213
220
|
.join(this.rangeSplit)
|
|
214
221
|
} else {
|
|
215
222
|
const val = getItems.find(
|
|
216
|
-
item =>
|
|
223
|
+
item =>
|
|
224
|
+
item[this.getSelect.keyField] ===
|
|
225
|
+
this.val[this.getSelect.keyField]
|
|
217
226
|
)
|
|
218
227
|
return val ? val[this.getSelect.displayField] : ''
|
|
219
228
|
}
|