@netang/quasar 0.0.20
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/LICENSE +21 -0
- package/README.md +17 -0
- package/components/column-title/index.vue +32 -0
- package/components/dialog/components/index.js +6 -0
- package/components/dialog/components/move-to-tree/index.vue +150 -0
- package/components/dialog/index.vue +330 -0
- package/components/dialog-table/index.vue +92 -0
- package/components/dragger/index.vue +202 -0
- package/components/drawer/index.vue +262 -0
- package/components/field-date/index.vue +844 -0
- package/components/field-date/methods.js +100 -0
- package/components/field-table/index.vue +468 -0
- package/components/field-text/index.vue +167 -0
- package/components/field-tree/index.vue +435 -0
- package/components/input-number/index.vue +324 -0
- package/components/input-number/number.js +67 -0
- package/components/input-price-cent/index.vue +213 -0
- package/components/input-price-yuan/index.vue +179 -0
- package/components/layout/index.vue +119 -0
- package/components/list-menu/index.vue +137 -0
- package/components/list-menu-item/index.vue +79 -0
- package/components/power-data/index.vue +667 -0
- package/components/search/index.vue +176 -0
- package/components/search-item/index.vue +219 -0
- package/components/select/index.vue +71 -0
- package/components/select-filter/index.vue +75 -0
- package/components/table/index.vue +347 -0
- package/components/table-column-fixed/index.vue +68 -0
- package/components/table-pagination/index.vue +83 -0
- package/components/table-summary/index.vue +91 -0
- package/components/thumbnail/index.vue +87 -0
- package/components/toolbar/container.vue +31 -0
- package/components/toolbar/index.vue +405 -0
- package/components/uploader/index.vue +157 -0
- package/components/uploader-query/index.vue +731 -0
- package/package.json +21 -0
- package/sass/common.scss +165 -0
- package/sass/index.scss +14 -0
- package/sass/line.scss +39 -0
- package/sass/quasar/btn.scss +46 -0
- package/sass/quasar/common.scss +3 -0
- package/sass/quasar/dialog.scss +7 -0
- package/sass/quasar/drawer.scss +6 -0
- package/sass/quasar/field.scss +210 -0
- package/sass/quasar/loading.scss +6 -0
- package/sass/quasar/menu.scss +8 -0
- package/sass/quasar/table.scss +112 -0
- package/sass/quasar/toolbar.scss +22 -0
- package/store/index.js +32 -0
- package/utils/$area.js +387 -0
- package/utils/$auth.js +135 -0
- package/utils/$dialog.js +43 -0
- package/utils/$role.js +807 -0
- package/utils/$rule.js +17 -0
- package/utils/$search.js +336 -0
- package/utils/$table.js +802 -0
- package/utils/$tree.js +620 -0
- package/utils/$uploader.js +1029 -0
- package/utils/alert.js +10 -0
- package/utils/bus.js +6 -0
- package/utils/config.js +22 -0
- package/utils/confrim.js +11 -0
- package/utils/dict.js +44 -0
- package/utils/getData.js +61 -0
- package/utils/getFile.js +30 -0
- package/utils/getImage.js +136 -0
- package/utils/getTime.js +94 -0
- package/utils/http.js +251 -0
- package/utils/loading.js +13 -0
- package/utils/notify.js +13 -0
- package/utils/previewImage.js +8 -0
- package/utils/symbols.js +3 -0
- package/utils/timestamp.js +18 -0
- package/utils/toast.js +13 -0
- package/utils/uploader/aliyun.js +6 -0
- package/utils/uploader/local.js +8 -0
- package/utils/uploader/qiniu.js +311 -0
- package/utils/useAuth.js +26 -0
- package/utils/useRouter.js +36 -0
- package/utils/useUploader.js +58 -0
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex column absolute-full" v-if="utils.isValidArray(options)">
|
|
3
|
+
<q-scroll-area class="n-flex-1">
|
|
4
|
+
|
|
5
|
+
<div class="n-search q-pa-sm q-pt-md q-gutter-md">
|
|
6
|
+
|
|
7
|
+
<template
|
|
8
|
+
v-for="(item, itemIndex) in options"
|
|
9
|
+
>
|
|
10
|
+
<!-- 如果有 name 插槽 -->
|
|
11
|
+
<slot
|
|
12
|
+
:name="`name-${item.name}`"
|
|
13
|
+
:item="item"
|
|
14
|
+
:item-index="itemIndex"
|
|
15
|
+
v-if="$slots[`name-${item.name}`]"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<!-- 否则自定义组件 -->
|
|
19
|
+
<n-search-item
|
|
20
|
+
:data="item"
|
|
21
|
+
v-model="modelValue[itemIndex]"
|
|
22
|
+
v-slot="{ label, index, multiple }"
|
|
23
|
+
v-else
|
|
24
|
+
>
|
|
25
|
+
<!-- 日期 -->
|
|
26
|
+
<template v-if="item.type === 'date'">
|
|
27
|
+
|
|
28
|
+
<!-- 日期 -->
|
|
29
|
+
<n-field-date
|
|
30
|
+
class="n-field-fieldset n-flex-1"
|
|
31
|
+
:label="label"
|
|
32
|
+
v-model="modelValue[itemIndex][index].value"
|
|
33
|
+
:type="modelValue[itemIndex][0].dateType"
|
|
34
|
+
dense
|
|
35
|
+
:end-date="index === 1"
|
|
36
|
+
outlined
|
|
37
|
+
clearable
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
<!-- 日期类型 -->
|
|
41
|
+
<q-select
|
|
42
|
+
v-model="modelValue[itemIndex][0].dateType"
|
|
43
|
+
:options="[
|
|
44
|
+
{ label: '年', value: 'year' },
|
|
45
|
+
{ label: '月', value: 'month' },
|
|
46
|
+
{ label: '日', value: 'day' },
|
|
47
|
+
{ label: '时', value: 'datetime' },
|
|
48
|
+
]"
|
|
49
|
+
map-options
|
|
50
|
+
emit-value
|
|
51
|
+
outlined
|
|
52
|
+
dense
|
|
53
|
+
options-dense
|
|
54
|
+
v-if="index === 0"
|
|
55
|
+
/>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<!-- 输入框 价格 -->
|
|
59
|
+
<n-input-price
|
|
60
|
+
class="n-field-fieldset"
|
|
61
|
+
:label="label"
|
|
62
|
+
v-model="modelValue[itemIndex][index].value"
|
|
63
|
+
dense
|
|
64
|
+
outlined
|
|
65
|
+
clearable
|
|
66
|
+
v-else-if="item.type === 'price'"
|
|
67
|
+
>
|
|
68
|
+
<!--<template v-slot:append>-->
|
|
69
|
+
<!-- <q-btn round dense flat icon="search" />-->
|
|
70
|
+
<!--</template>-->
|
|
71
|
+
</n-input-price>
|
|
72
|
+
|
|
73
|
+
<!-- 输入框 文字 -->
|
|
74
|
+
<q-input
|
|
75
|
+
class="n-field-fieldset"
|
|
76
|
+
:label="label"
|
|
77
|
+
v-model="modelValue[itemIndex][index].value"
|
|
78
|
+
dense
|
|
79
|
+
outlined
|
|
80
|
+
clearable
|
|
81
|
+
v-else-if="item.searchType === 'input'"
|
|
82
|
+
>
|
|
83
|
+
<!--<template v-slot:append>-->
|
|
84
|
+
<!-- <q-btn round dense flat icon="search" />-->
|
|
85
|
+
<!--</template>-->
|
|
86
|
+
</q-input>
|
|
87
|
+
|
|
88
|
+
<!-- 下拉列表 -->
|
|
89
|
+
<q-select
|
|
90
|
+
class="n-field-fieldset"
|
|
91
|
+
:label="label"
|
|
92
|
+
v-model="modelValue[itemIndex][index].value"
|
|
93
|
+
map-options
|
|
94
|
+
emit-value
|
|
95
|
+
outlined
|
|
96
|
+
dense
|
|
97
|
+
:multiple="multiple"
|
|
98
|
+
:use-chips="multiple"
|
|
99
|
+
options-dense
|
|
100
|
+
clearable
|
|
101
|
+
v-bind="item.select"
|
|
102
|
+
v-else-if="item.searchType === 'select'"
|
|
103
|
+
/>
|
|
104
|
+
|
|
105
|
+
<!-- 下拉树 -->
|
|
106
|
+
<n-field-tree
|
|
107
|
+
class="n-field-fieldset"
|
|
108
|
+
:label="label"
|
|
109
|
+
v-model="modelValue[itemIndex][index].value"
|
|
110
|
+
dense
|
|
111
|
+
outlined
|
|
112
|
+
clearable
|
|
113
|
+
accordion
|
|
114
|
+
:multiple="multiple"
|
|
115
|
+
v-bind="item.tree"
|
|
116
|
+
v-else-if="item.searchType === 'tree'"
|
|
117
|
+
/>
|
|
118
|
+
|
|
119
|
+
</n-search-item>
|
|
120
|
+
</template>
|
|
121
|
+
</div>
|
|
122
|
+
</q-scroll-area>
|
|
123
|
+
|
|
124
|
+
<!-- 底部 -->
|
|
125
|
+
<q-toolbar
|
|
126
|
+
class="q-footer q-footer--bordered"
|
|
127
|
+
:class="{
|
|
128
|
+
'bg-grey-2': ! $q.dark.isActive,
|
|
129
|
+
}"
|
|
130
|
+
>
|
|
131
|
+
<div class="row n-flex-1 q-gutter-sm">
|
|
132
|
+
<q-btn
|
|
133
|
+
class="n-flex-1"
|
|
134
|
+
color="default"
|
|
135
|
+
outline
|
|
136
|
+
label="搜索"
|
|
137
|
+
icon="search"
|
|
138
|
+
@click="onSearch"
|
|
139
|
+
unelevated
|
|
140
|
+
/>
|
|
141
|
+
<q-btn
|
|
142
|
+
class="q-pl-md"
|
|
143
|
+
color="default"
|
|
144
|
+
outline
|
|
145
|
+
label="重置"
|
|
146
|
+
@click="onReset"
|
|
147
|
+
unelevated
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</q-toolbar>
|
|
151
|
+
</div>
|
|
152
|
+
</template>
|
|
153
|
+
|
|
154
|
+
<script>
|
|
155
|
+
export default {
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 标识
|
|
159
|
+
*/
|
|
160
|
+
name: 'NSearch',
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 声明属性
|
|
164
|
+
*/
|
|
165
|
+
props: {
|
|
166
|
+
// 值
|
|
167
|
+
modelValue: Array,
|
|
168
|
+
// 参数
|
|
169
|
+
options: Array,
|
|
170
|
+
// 搜索
|
|
171
|
+
onSearch: Function,
|
|
172
|
+
// 重置
|
|
173
|
+
onReset: Function,
|
|
174
|
+
},
|
|
175
|
+
}
|
|
176
|
+
</script>
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="n-search__item n-field-group">
|
|
3
|
+
|
|
4
|
+
<!-- 比较1 -->
|
|
5
|
+
<div class="n-field-group row">
|
|
6
|
+
|
|
7
|
+
<!-- 比较类型1 -->
|
|
8
|
+
<q-select
|
|
9
|
+
v-model="modelValue[0].type"
|
|
10
|
+
:options="compareOptions1"
|
|
11
|
+
map-options
|
|
12
|
+
emit-value
|
|
13
|
+
outlined
|
|
14
|
+
stack-label
|
|
15
|
+
dense
|
|
16
|
+
options-dense
|
|
17
|
+
/>
|
|
18
|
+
|
|
19
|
+
<q-input
|
|
20
|
+
class="n-field-fieldset"
|
|
21
|
+
:label="data.label"
|
|
22
|
+
dense
|
|
23
|
+
outlined
|
|
24
|
+
disable
|
|
25
|
+
v-if="data.type === 'date' && modelValue[0].type >= 20"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<!-- 多选(类型为 in / not in)-->
|
|
29
|
+
<slot
|
|
30
|
+
:label="data.label"
|
|
31
|
+
:index="0"
|
|
32
|
+
:multiple="utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], modelValue[0].type) > -1"
|
|
33
|
+
v-else
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
<!-- 比较2(类型为 > / >=) -->
|
|
38
|
+
<div
|
|
39
|
+
class="n-field-group row"
|
|
40
|
+
v-if="utils.indexOf([dicts.SEARCH_TYPE__GT, dicts.SEARCH_TYPE__GTE], modelValue[0].type) > -1"
|
|
41
|
+
>
|
|
42
|
+
<!-- 比较类型2 -->
|
|
43
|
+
<q-select
|
|
44
|
+
v-model="modelValue[1].type"
|
|
45
|
+
:options="[
|
|
46
|
+
{ label: '<', value: dicts.SEARCH_TYPE__LT },
|
|
47
|
+
{ label: '≤', value: dicts.SEARCH_TYPE__LTE },
|
|
48
|
+
]"
|
|
49
|
+
map-options
|
|
50
|
+
emit-value
|
|
51
|
+
outlined
|
|
52
|
+
dense
|
|
53
|
+
options-dense
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
<slot
|
|
57
|
+
:label="undefined"
|
|
58
|
+
:multiple="false"
|
|
59
|
+
:index="1"
|
|
60
|
+
/>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script>
|
|
66
|
+
import { computed, watch } from 'vue'
|
|
67
|
+
import { quickRange } from '../field-date/methods'
|
|
68
|
+
|
|
69
|
+
export default {
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 标识
|
|
73
|
+
*/
|
|
74
|
+
name: 'NSearchItem',
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 声明属性
|
|
78
|
+
*/
|
|
79
|
+
props: {
|
|
80
|
+
// 值
|
|
81
|
+
modelValue: Array,
|
|
82
|
+
// 数据
|
|
83
|
+
data: Object,
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 声明事件
|
|
88
|
+
*/
|
|
89
|
+
emits: [
|
|
90
|
+
'update:modelValue',
|
|
91
|
+
],
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 组合式
|
|
95
|
+
*/
|
|
96
|
+
setup(props, { emit }) {
|
|
97
|
+
|
|
98
|
+
// ==========【计算属性】=========================================================================================
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 比较下拉列表1
|
|
102
|
+
* 1: =
|
|
103
|
+
* 2: !=
|
|
104
|
+
* 3: >
|
|
105
|
+
* 4: >=
|
|
106
|
+
* 5: <
|
|
107
|
+
* 6: <=
|
|
108
|
+
* 7: LIKE
|
|
109
|
+
* 8: NOT LIKE
|
|
110
|
+
* 9: IN
|
|
111
|
+
* 10: NOT IN
|
|
112
|
+
*/
|
|
113
|
+
const compareOptions1 = computed(function () {
|
|
114
|
+
|
|
115
|
+
// 如果类型为 文字
|
|
116
|
+
// --------------------------------------------------
|
|
117
|
+
if (props.data.type === 'text') {
|
|
118
|
+
|
|
119
|
+
// 相同 不同 包含 不含
|
|
120
|
+
return [
|
|
121
|
+
{ label: '相同', value: dicts.SEARCH_TYPE__EQUAL },
|
|
122
|
+
{ label: '不同', value: dicts.SEARCH_TYPE__NOT_EQUAL },
|
|
123
|
+
{ label: '包含', value: dicts.SEARCH_TYPE__LIKE },
|
|
124
|
+
{ label: '不含', value: dicts.SEARCH_TYPE__NOT_LIKE },
|
|
125
|
+
{ label: 'IN', value: dicts.SEARCH_TYPE__IN },
|
|
126
|
+
{ label: 'NOT IN', value: dicts.SEARCH_TYPE__NOT_IN },
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 否则为数字
|
|
131
|
+
// --------------------------------------------------
|
|
132
|
+
const opts = [
|
|
133
|
+
{ label: '=', value: dicts.SEARCH_TYPE__EQUAL },
|
|
134
|
+
{ label: '!=', value: dicts.SEARCH_TYPE__NOT_EQUAL },
|
|
135
|
+
{ label: '>', value: dicts.SEARCH_TYPE__GT },
|
|
136
|
+
{ label: '≥', value: dicts.SEARCH_TYPE__GTE },
|
|
137
|
+
]
|
|
138
|
+
|
|
139
|
+
// 如果类型为日期
|
|
140
|
+
if (props.data.type === 'date') {
|
|
141
|
+
// 添加日期快捷选项
|
|
142
|
+
utils.forEach(quickRange, function(label, key) {
|
|
143
|
+
opts.push({ label, value: key + 20 })
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
// 否则类型为 数字
|
|
147
|
+
} else {
|
|
148
|
+
opts.push(
|
|
149
|
+
{ label: 'IN', value: dicts.SEARCH_TYPE__IN },
|
|
150
|
+
{ label: 'NOT IN', value: dicts.SEARCH_TYPE__NOT_IN },
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return opts
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
// ==========【监听数据】=========================================================================================
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 监听声明值
|
|
161
|
+
*/
|
|
162
|
+
if (utils.indexOf(['select', 'tree'], props.data.searchType) > -1) {
|
|
163
|
+
|
|
164
|
+
watch(()=>props.modelValue[0].type, function(val) {
|
|
165
|
+
|
|
166
|
+
const modelValue = _.cloneDeep(props.modelValue)
|
|
167
|
+
|
|
168
|
+
// 如果类型为 in / not in, 则为多选
|
|
169
|
+
if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], val) > -1) {
|
|
170
|
+
|
|
171
|
+
// 如果值不为数组
|
|
172
|
+
if (! Array.isArray(modelValue[0].value)) {
|
|
173
|
+
modelValue[0].value = utils.isValidValue(modelValue[0].value) ? [modelValue[0].value] : []
|
|
174
|
+
emit('update:modelValue', modelValue)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// 否则为单选, 并且如果值为数组
|
|
178
|
+
} else if (Array.isArray(modelValue[0].value)) {
|
|
179
|
+
modelValue[0].value = utils.isValidValue(modelValue[0].value[0]) ? modelValue[0].value[0] : ''
|
|
180
|
+
emit('update:modelValue', modelValue)
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ==========【返回】=============================================================================================
|
|
186
|
+
|
|
187
|
+
return {
|
|
188
|
+
// 比较下拉列表1
|
|
189
|
+
compareOptions1,
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
}
|
|
193
|
+
</script>
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
<style lang="scss">
|
|
197
|
+
@import "@/assets/sass/var.scss";
|
|
198
|
+
|
|
199
|
+
.n-search__item {
|
|
200
|
+
.n-field-group {
|
|
201
|
+
> .q-field--outlined {
|
|
202
|
+
|
|
203
|
+
// 第一个子节点
|
|
204
|
+
&:first-child,
|
|
205
|
+
// 第三个子节点
|
|
206
|
+
&:nth-child(3) {
|
|
207
|
+
.q-field__control {
|
|
208
|
+
background-color: rgba(var(--n-reverse-color-rgb), 0.04);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 第二个子节点
|
|
213
|
+
&:nth-child(2) {
|
|
214
|
+
flex: 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
</style>
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<q-select
|
|
3
|
+
|
|
4
|
+
>
|
|
5
|
+
|
|
6
|
+
</q-select>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 标识
|
|
14
|
+
*/
|
|
15
|
+
name: 'NSelect',
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 声明属性
|
|
19
|
+
*/
|
|
20
|
+
props: {
|
|
21
|
+
// 值
|
|
22
|
+
modelValue: {
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 声明事件
|
|
29
|
+
*/
|
|
30
|
+
emits: [
|
|
31
|
+
'update:modelValue',
|
|
32
|
+
],
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 组合式
|
|
36
|
+
*/
|
|
37
|
+
setup(props, { emit }) {
|
|
38
|
+
|
|
39
|
+
// ==========【当前值】===========================================================================================
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 原始值
|
|
43
|
+
*/
|
|
44
|
+
const rawModelValue = props.modelValue
|
|
45
|
+
|
|
46
|
+
// ==========【方法】============================================================================================
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 筛选
|
|
50
|
+
*/
|
|
51
|
+
function filter(value, update) {
|
|
52
|
+
update(function() {
|
|
53
|
+
// 更新值
|
|
54
|
+
emit(
|
|
55
|
+
'update:modelValue',
|
|
56
|
+
value === '' ? rawModelValue : utils.collection(rawModelValue)
|
|
57
|
+
.where(props.optionLabel, 'like', value)
|
|
58
|
+
.toArray()
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ==========【返回】=============================================================================================
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
// 筛选
|
|
67
|
+
filter,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</script>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot
|
|
3
|
+
:filter="filter"
|
|
4
|
+
:optionLabel="optionLabel"
|
|
5
|
+
/>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
export default {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 标识
|
|
13
|
+
*/
|
|
14
|
+
name: 'NSelectFilter',
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 声明属性
|
|
18
|
+
*/
|
|
19
|
+
props: {
|
|
20
|
+
// 值
|
|
21
|
+
modelValue: {
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
// 选项标签
|
|
25
|
+
optionLabel: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'label',
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 声明事件
|
|
33
|
+
*/
|
|
34
|
+
emits: [
|
|
35
|
+
'update:modelValue',
|
|
36
|
+
],
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 组合式
|
|
40
|
+
*/
|
|
41
|
+
setup(props, { emit }) {
|
|
42
|
+
|
|
43
|
+
// ==========【当前值】===========================================================================================
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 原始值
|
|
47
|
+
*/
|
|
48
|
+
const rawModelValue = props.modelValue
|
|
49
|
+
|
|
50
|
+
// ==========【方法】============================================================================================
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 筛选
|
|
54
|
+
*/
|
|
55
|
+
function filter(value, update) {
|
|
56
|
+
update(function() {
|
|
57
|
+
// 更新值
|
|
58
|
+
emit(
|
|
59
|
+
'update:modelValue',
|
|
60
|
+
value === '' ? rawModelValue : utils.collection(rawModelValue)
|
|
61
|
+
.where(props.optionLabel, 'like', value)
|
|
62
|
+
.toArray()
|
|
63
|
+
)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ==========【返回】=============================================================================================
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
// 筛选
|
|
71
|
+
filter,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
</script>
|