@netang/quasar 0.0.101 → 0.0.103
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/.editorconfig +12 -0
- package/_docs/docs/components/field-tree.md +21 -21
- package/components/field-tree/index.vue +761 -659
- package/components/select/index.vue +177 -177
- package/package.json +24 -24
- package/utils/useSearch.js +490 -496
|
@@ -1,177 +1,177 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-select
|
|
3
|
-
v-model="currentModelValue"
|
|
4
|
-
:options="currentOptions"
|
|
5
|
-
:option-label="optionLabel"
|
|
6
|
-
:multiple="multiple"
|
|
7
|
-
:use-input="filter"
|
|
8
|
-
@filter="onFilter"
|
|
9
|
-
v-bind="$attrs"
|
|
10
|
-
>
|
|
11
|
-
<!-- 占位符 -->
|
|
12
|
-
<template v-slot:selected v-if="! showValue && placeholder">
|
|
13
|
-
<div class="n-placeholder q-mr-xs">{{placeholder}}</div>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<!-- 插槽 -->
|
|
17
|
-
<template
|
|
18
|
-
v-for="slotName in slotNames"
|
|
19
|
-
v-slot:[slotName]="props"
|
|
20
|
-
>
|
|
21
|
-
<!-- 有传参的插槽 -->
|
|
22
|
-
<slot
|
|
23
|
-
:name="slotName"
|
|
24
|
-
v-bind="props"
|
|
25
|
-
v-if="props"
|
|
26
|
-
/>
|
|
27
|
-
|
|
28
|
-
<!-- 无传参的插槽 -->
|
|
29
|
-
<slot
|
|
30
|
-
:name="slotName"
|
|
31
|
-
v-else
|
|
32
|
-
/>
|
|
33
|
-
</template>
|
|
34
|
-
</q-select>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script>
|
|
38
|
-
import { ref, computed, watch } from 'vue'
|
|
39
|
-
|
|
40
|
-
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
41
|
-
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
42
|
-
import $n_collection from '@netang/utils/collection'
|
|
43
|
-
|
|
44
|
-
export default {
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* 标识
|
|
48
|
-
*/
|
|
49
|
-
name: 'NSelect',
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* 声明属性
|
|
53
|
-
*/
|
|
54
|
-
props: {
|
|
55
|
-
// 值
|
|
56
|
-
modelValue: {
|
|
57
|
-
required: true,
|
|
58
|
-
},
|
|
59
|
-
options: {
|
|
60
|
-
type: Array,
|
|
61
|
-
default: () => []
|
|
62
|
-
},
|
|
63
|
-
// 选项标签
|
|
64
|
-
optionLabel: {
|
|
65
|
-
type: String,
|
|
66
|
-
default: 'label',
|
|
67
|
-
},
|
|
68
|
-
// 是否多选
|
|
69
|
-
multiple: Boolean,
|
|
70
|
-
// 占位符
|
|
71
|
-
placeholder: String,
|
|
72
|
-
// 筛选
|
|
73
|
-
filter: Boolean,
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* 声明事件
|
|
78
|
-
*/
|
|
79
|
-
emits: [
|
|
80
|
-
'update:modelValue',
|
|
81
|
-
],
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* 组合式
|
|
85
|
-
*/
|
|
86
|
-
setup(props, { emit, slots }) {
|
|
87
|
-
|
|
88
|
-
// ==========【当前值】===========================================================================================
|
|
89
|
-
|
|
90
|
-
// 当前值
|
|
91
|
-
const currentModelValue = ref(props.modelValue)
|
|
92
|
-
|
|
93
|
-
// 原始选项
|
|
94
|
-
const rawOptions = props.options
|
|
95
|
-
|
|
96
|
-
// 当前选项
|
|
97
|
-
const currentOptions = ref(rawOptions)
|
|
98
|
-
|
|
99
|
-
// ==========【计算属性】=========================================================================================
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* 插槽标识
|
|
103
|
-
*/
|
|
104
|
-
const slotNames = computed(function() {
|
|
105
|
-
return $n_isValidObject(slots) ? Object.keys(slots) : []
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* 显示值
|
|
110
|
-
*/
|
|
111
|
-
const showValue = computed(function() {
|
|
112
|
-
|
|
113
|
-
// 如果是多选
|
|
114
|
-
if (props.multiple) {
|
|
115
|
-
return $n_isValidArray(currentModelValue.value) ? '1' : ''
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return currentModelValue.value
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// ==========【监听数据】=========================================================================================
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* 监听声明值
|
|
126
|
-
*/
|
|
127
|
-
watch(()=>props.modelValue, function (val) {
|
|
128
|
-
// 设置当前值
|
|
129
|
-
currentModelValue.value = val
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* 监听当前值
|
|
134
|
-
*/
|
|
135
|
-
watch(currentModelValue, function (val) {
|
|
136
|
-
// 更新值
|
|
137
|
-
emit('update:modelValue', val)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// ==========【方法】============================================================================================
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 筛选
|
|
144
|
-
*/
|
|
145
|
-
function onFilter(value, update) {
|
|
146
|
-
update(function() {
|
|
147
|
-
// 更新选项
|
|
148
|
-
currentOptions.value =
|
|
149
|
-
// 如果搜索值为空
|
|
150
|
-
value === '' ?
|
|
151
|
-
// 选项还原为初始值
|
|
152
|
-
rawOptions
|
|
153
|
-
// 否则筛选选项
|
|
154
|
-
: $n_collection(rawOptions)
|
|
155
|
-
.where(props.optionLabel, 'like', value)
|
|
156
|
-
.toArray()
|
|
157
|
-
})
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
// ==========【返回】=============================================================================================
|
|
161
|
-
|
|
162
|
-
return {
|
|
163
|
-
// 插槽标识
|
|
164
|
-
slotNames,
|
|
165
|
-
// 当前值
|
|
166
|
-
currentModelValue,
|
|
167
|
-
// 当前选项
|
|
168
|
-
currentOptions,
|
|
169
|
-
// 显示值
|
|
170
|
-
showValue,
|
|
171
|
-
|
|
172
|
-
// 筛选
|
|
173
|
-
onFilter,
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<q-select
|
|
3
|
+
v-model="currentModelValue"
|
|
4
|
+
:options="currentOptions"
|
|
5
|
+
:option-label="optionLabel"
|
|
6
|
+
:multiple="multiple"
|
|
7
|
+
:use-input="filter"
|
|
8
|
+
@filter="onFilter"
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
>
|
|
11
|
+
<!-- 占位符 -->
|
|
12
|
+
<template v-slot:selected v-if="! showValue && placeholder">
|
|
13
|
+
<div class="n-placeholder q-mr-xs">{{placeholder}}</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<!-- 插槽 -->
|
|
17
|
+
<template
|
|
18
|
+
v-for="slotName in slotNames"
|
|
19
|
+
v-slot:[slotName]="props"
|
|
20
|
+
>
|
|
21
|
+
<!-- 有传参的插槽 -->
|
|
22
|
+
<slot
|
|
23
|
+
:name="slotName"
|
|
24
|
+
v-bind="props"
|
|
25
|
+
v-if="props"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<!-- 无传参的插槽 -->
|
|
29
|
+
<slot
|
|
30
|
+
:name="slotName"
|
|
31
|
+
v-else
|
|
32
|
+
/>
|
|
33
|
+
</template>
|
|
34
|
+
</q-select>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
import { ref, computed, watch } from 'vue'
|
|
39
|
+
|
|
40
|
+
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
41
|
+
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
42
|
+
import $n_collection from '@netang/utils/collection'
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 标识
|
|
48
|
+
*/
|
|
49
|
+
name: 'NSelect',
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 声明属性
|
|
53
|
+
*/
|
|
54
|
+
props: {
|
|
55
|
+
// 值
|
|
56
|
+
modelValue: {
|
|
57
|
+
required: true,
|
|
58
|
+
},
|
|
59
|
+
options: {
|
|
60
|
+
type: Array,
|
|
61
|
+
default: () => []
|
|
62
|
+
},
|
|
63
|
+
// 选项标签
|
|
64
|
+
optionLabel: {
|
|
65
|
+
type: String,
|
|
66
|
+
default: 'label',
|
|
67
|
+
},
|
|
68
|
+
// 是否多选
|
|
69
|
+
multiple: Boolean,
|
|
70
|
+
// 占位符
|
|
71
|
+
placeholder: String,
|
|
72
|
+
// 筛选
|
|
73
|
+
filter: Boolean,
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 声明事件
|
|
78
|
+
*/
|
|
79
|
+
emits: [
|
|
80
|
+
'update:modelValue',
|
|
81
|
+
],
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 组合式
|
|
85
|
+
*/
|
|
86
|
+
setup(props, { emit, slots }) {
|
|
87
|
+
|
|
88
|
+
// ==========【当前值】===========================================================================================
|
|
89
|
+
|
|
90
|
+
// 当前值
|
|
91
|
+
const currentModelValue = ref(props.modelValue)
|
|
92
|
+
|
|
93
|
+
// 原始选项
|
|
94
|
+
const rawOptions = props.options
|
|
95
|
+
|
|
96
|
+
// 当前选项
|
|
97
|
+
const currentOptions = ref(rawOptions)
|
|
98
|
+
|
|
99
|
+
// ==========【计算属性】=========================================================================================
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 插槽标识
|
|
103
|
+
*/
|
|
104
|
+
const slotNames = computed(function() {
|
|
105
|
+
return $n_isValidObject(slots) ? Object.keys(slots) : []
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* 显示值
|
|
110
|
+
*/
|
|
111
|
+
const showValue = computed(function() {
|
|
112
|
+
|
|
113
|
+
// 如果是多选
|
|
114
|
+
if (props.multiple) {
|
|
115
|
+
return $n_isValidArray(currentModelValue.value) ? '1' : ''
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return currentModelValue.value
|
|
119
|
+
})
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
// ==========【监听数据】=========================================================================================
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 监听声明值
|
|
126
|
+
*/
|
|
127
|
+
watch(()=>props.modelValue, function (val) {
|
|
128
|
+
// 设置当前值
|
|
129
|
+
currentModelValue.value = val
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 监听当前值
|
|
134
|
+
*/
|
|
135
|
+
watch(currentModelValue, function (val) {
|
|
136
|
+
// 更新值
|
|
137
|
+
emit('update:modelValue', val)
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
// ==========【方法】============================================================================================
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 筛选
|
|
144
|
+
*/
|
|
145
|
+
function onFilter(value, update) {
|
|
146
|
+
update(function() {
|
|
147
|
+
// 更新选项
|
|
148
|
+
currentOptions.value =
|
|
149
|
+
// 如果搜索值为空
|
|
150
|
+
value === '' ?
|
|
151
|
+
// 选项还原为初始值
|
|
152
|
+
rawOptions
|
|
153
|
+
// 否则筛选选项
|
|
154
|
+
: $n_collection(rawOptions)
|
|
155
|
+
.where(props.optionLabel, 'like', value)
|
|
156
|
+
.toArray()
|
|
157
|
+
})
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ==========【返回】=============================================================================================
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
// 插槽标识
|
|
164
|
+
slotNames,
|
|
165
|
+
// 当前值
|
|
166
|
+
currentModelValue,
|
|
167
|
+
// 当前选项
|
|
168
|
+
currentOptions,
|
|
169
|
+
// 显示值
|
|
170
|
+
showValue,
|
|
171
|
+
|
|
172
|
+
// 筛选
|
|
173
|
+
onFilter,
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
</script>
|
package/package.json
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@netang/quasar",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "netang-quasar",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
-
},
|
|
8
|
-
"repository": {
|
|
9
|
-
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/netangsoft/netang-quasar.git"
|
|
11
|
-
},
|
|
12
|
-
"keywords": [
|
|
13
|
-
"netang-quasar"
|
|
14
|
-
],
|
|
15
|
-
"author": "Netang",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"bugs": {
|
|
18
|
-
"url": "https://github.com/netangsoft/netang-quasar/issues"
|
|
19
|
-
},
|
|
20
|
-
"homepage": "https://github.com/netangsoft/netang-quasar#readme",
|
|
21
|
-
"dependencies": {
|
|
22
|
-
"spark-md5": "^3.0.2"
|
|
23
|
-
}
|
|
24
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@netang/quasar",
|
|
3
|
+
"version": "0.0.103",
|
|
4
|
+
"description": "netang-quasar",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/netangsoft/netang-quasar.git"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"netang-quasar"
|
|
14
|
+
],
|
|
15
|
+
"author": "Netang",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/netangsoft/netang-quasar/issues"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/netangsoft/netang-quasar#readme",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"spark-md5": "^3.0.2"
|
|
23
|
+
}
|
|
24
|
+
}
|