@netang/quasar 0.0.45 → 0.0.47
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/field-table/index.vue +18 -9
- package/components/field-tree/index.vue +2 -0
- package/components/input-format/index.vue +21 -12
- package/components/splitter/index.vue +1 -4
- package/components/{splitter-table → table-splitter}/index.vue +96 -14
- package/components/value-format/index.vue +240 -0
- package/package.json +1 -1
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
</template>
|
|
13
13
|
|
|
14
14
|
<!--:class="fieldFocused ? 'q-field--float q-field--focused q-field--highlighted' : ''"-->
|
|
15
|
+
<!--:clearable="clearable && (! multiple || collapseTags)"-->
|
|
15
16
|
<q-field
|
|
16
17
|
class="n-field-table"
|
|
17
18
|
:model-value="showValue"
|
|
18
19
|
:disable="disable"
|
|
19
20
|
:readonly="readonly"
|
|
20
|
-
:clearable="clearable
|
|
21
|
+
:clearable="clearable"
|
|
21
22
|
@focus="onFieldFocus"
|
|
22
23
|
@blur="onFieldBlur"
|
|
23
24
|
@clear="onFieldClear"
|
|
@@ -203,12 +204,12 @@ export default {
|
|
|
203
204
|
// 标签字段
|
|
204
205
|
labelKey: String,
|
|
205
206
|
// 值类型
|
|
206
|
-
// string:
|
|
207
|
-
//
|
|
208
|
-
//
|
|
207
|
+
// string: 字符串或数字
|
|
208
|
+
// stringArray: 普通数组(包含字符串或数字的一维数组)
|
|
209
|
+
// objectArray: 对象数组(包含对象的一维数组)
|
|
209
210
|
valueType: {
|
|
210
211
|
type: String,
|
|
211
|
-
default: '
|
|
212
|
+
default: 'objectArray'
|
|
212
213
|
},
|
|
213
214
|
// 值分隔符(值类型为 string 有效)
|
|
214
215
|
valueSeparator: {
|
|
@@ -602,12 +603,16 @@ export default {
|
|
|
602
603
|
* 当前格式化显示标签
|
|
603
604
|
*/
|
|
604
605
|
function currentFormatLabel(item) {
|
|
606
|
+
|
|
605
607
|
// 如果有格式化显示标签方法
|
|
606
|
-
|
|
608
|
+
if (_.isFunction(props.formatLabel)) {
|
|
607
609
|
// 执行格式化显示标签方法
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
610
|
+
return props.formatLabel(item)
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
// 否则显示该值的标签字段
|
|
614
|
+
const val = item[currentlabelKey.value]
|
|
615
|
+
return utils.isValidValue(val) ? val : item[props.valueKey]
|
|
611
616
|
}
|
|
612
617
|
|
|
613
618
|
/**
|
|
@@ -841,6 +846,8 @@ export default {
|
|
|
841
846
|
// 停止冒泡
|
|
842
847
|
e.stopPropagation()
|
|
843
848
|
|
|
849
|
+
console.log('onFieldBluronFieldBlur', props.filter, showPopup.value)
|
|
850
|
+
|
|
844
851
|
if (
|
|
845
852
|
// 如果开启筛选
|
|
846
853
|
props.filter
|
|
@@ -1071,6 +1078,8 @@ export default {
|
|
|
1071
1078
|
popupRef,
|
|
1072
1079
|
// 是否显示对话框
|
|
1073
1080
|
showDialog,
|
|
1081
|
+
// 是否显示弹出层
|
|
1082
|
+
showPopup,
|
|
1074
1083
|
// 当前已选数据
|
|
1075
1084
|
selected,
|
|
1076
1085
|
// 当前表格列数据
|
|
@@ -45,7 +45,6 @@ export default {
|
|
|
45
45
|
*/
|
|
46
46
|
emits: [
|
|
47
47
|
'update:modelValue',
|
|
48
|
-
'blur',
|
|
49
48
|
],
|
|
50
49
|
|
|
51
50
|
/**
|
|
@@ -84,6 +83,14 @@ export default {
|
|
|
84
83
|
|
|
85
84
|
// ==========【方法】=============================================================================================
|
|
86
85
|
|
|
86
|
+
/**
|
|
87
|
+
* 触发更新值
|
|
88
|
+
*/
|
|
89
|
+
function emitModelValue(val) {
|
|
90
|
+
// 触发更新值
|
|
91
|
+
emit('update:modelValue', val)
|
|
92
|
+
}
|
|
93
|
+
|
|
87
94
|
/**
|
|
88
95
|
* 格式化声明值
|
|
89
96
|
*/
|
|
@@ -117,7 +124,7 @@ export default {
|
|
|
117
124
|
}
|
|
118
125
|
}
|
|
119
126
|
|
|
120
|
-
return val
|
|
127
|
+
return Array.isArray(val) ? val.join(',') : val
|
|
121
128
|
}
|
|
122
129
|
|
|
123
130
|
/**
|
|
@@ -219,28 +226,30 @@ export default {
|
|
|
219
226
|
*/
|
|
220
227
|
function onBlur() {
|
|
221
228
|
|
|
222
|
-
|
|
229
|
+
const val = currentValue.value
|
|
223
230
|
|
|
224
231
|
// 如果修改值
|
|
225
232
|
if (props.formatAfter) {
|
|
226
233
|
|
|
227
234
|
// 如果是方法
|
|
228
235
|
if (_.isFunction(props.formatAfter)) {
|
|
229
|
-
|
|
236
|
+
|
|
237
|
+
// 触发更新值
|
|
238
|
+
emitModelValue(props.formatAfter(val))
|
|
239
|
+
return
|
|
240
|
+
}
|
|
230
241
|
|
|
231
242
|
// 如果是参数
|
|
232
|
-
|
|
243
|
+
if (props.formatAfter === true || utils.isValidObject(props.formatAfter)) {
|
|
233
244
|
|
|
234
|
-
//
|
|
235
|
-
|
|
245
|
+
// 触发更新值
|
|
246
|
+
emitModelValue(formatStringValue(val, props.formatAfter === true ? {} : props.formatAfter, props.valueArray))
|
|
247
|
+
return
|
|
236
248
|
}
|
|
237
249
|
}
|
|
238
250
|
|
|
239
|
-
//
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
// 失去焦点触发
|
|
243
|
-
emit('blur', val)
|
|
251
|
+
// 触发更新值
|
|
252
|
+
emitModelValue(props.valueArray ? utils.split(val, ',') : val)
|
|
244
253
|
}
|
|
245
254
|
|
|
246
255
|
// ==========【返回】=============================================================================================
|
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<n-splitter
|
|
3
3
|
class="absolute-full"
|
|
4
|
+
v-model="currentValue"
|
|
5
|
+
:reverse="reverse"
|
|
6
|
+
:unit="unit"
|
|
7
|
+
:limits="limits"
|
|
8
|
+
:horizontal="horizontal"
|
|
9
|
+
|
|
10
|
+
v-model:after="currentAfter"
|
|
4
11
|
@update:after="setSelection"
|
|
5
12
|
:hide-after-in-mobile="hideAfterInMobile"
|
|
6
|
-
|
|
13
|
+
:cache="cache"
|
|
7
14
|
>
|
|
8
15
|
<!-- 表格 -->
|
|
9
16
|
<template v-slot:before="{ after, toggleAfter }">
|
|
10
17
|
<n-table
|
|
11
|
-
v-bind="
|
|
18
|
+
v-bind="$attrs"
|
|
12
19
|
>
|
|
13
20
|
<!-- 工具栏右边插槽(手机端不显示) -->
|
|
14
21
|
<template #toolbar-right v-if="isWatcher">
|
|
15
22
|
|
|
23
|
+
<!-- 工具栏右边插槽 -->
|
|
24
|
+
<slot name="toolbar-right" />
|
|
25
|
+
|
|
16
26
|
<!-- 是否显示详情 -->
|
|
17
27
|
<q-toggle
|
|
18
28
|
icon="apps"
|
|
@@ -58,7 +68,7 @@
|
|
|
58
68
|
|
|
59
69
|
<!-- 空状态 -->
|
|
60
70
|
<n-empty
|
|
61
|
-
:description="
|
|
71
|
+
:description="renderDescription"
|
|
62
72
|
v-else
|
|
63
73
|
/>
|
|
64
74
|
|
|
@@ -75,26 +85,51 @@ import { NTableKey } from '../../utils/symbols'
|
|
|
75
85
|
|
|
76
86
|
export default {
|
|
77
87
|
|
|
88
|
+
/**
|
|
89
|
+
* 关闭组件 attribute 透传行为
|
|
90
|
+
*/
|
|
91
|
+
inheritAttrs: false,
|
|
92
|
+
|
|
78
93
|
/**
|
|
79
94
|
* 标识
|
|
80
95
|
*/
|
|
81
|
-
name: '
|
|
96
|
+
name: 'NTableSplitter',
|
|
82
97
|
|
|
83
98
|
/**
|
|
84
99
|
* 声明属性
|
|
85
100
|
*/
|
|
86
101
|
props: {
|
|
87
|
-
//
|
|
88
|
-
|
|
102
|
+
// 值 v-model
|
|
103
|
+
modelValue: {
|
|
104
|
+
type: Number,
|
|
105
|
+
default: 50,
|
|
106
|
+
},
|
|
107
|
+
reverse: Boolean,
|
|
108
|
+
unit: String,
|
|
109
|
+
limits: Array,
|
|
110
|
+
horizontal: Boolean,
|
|
111
|
+
|
|
112
|
+
// 显示后置插槽 v-model:after
|
|
113
|
+
// 注意: 如果非双向绑定, 如 :after 并不会影响内部值变化, 仅做初始值使用
|
|
114
|
+
after: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: true,
|
|
117
|
+
},
|
|
89
118
|
// 手机模式隐藏后插槽
|
|
90
119
|
hideAfterInMobile: {
|
|
91
120
|
type: Boolean,
|
|
92
121
|
default: true,
|
|
93
122
|
},
|
|
94
|
-
//
|
|
95
|
-
|
|
123
|
+
// 是否开启缓存
|
|
124
|
+
cache: {
|
|
125
|
+
type: [ Boolean, String ],
|
|
126
|
+
default: true,
|
|
127
|
+
},
|
|
128
|
+
|
|
129
|
+
// 工具提示
|
|
130
|
+
tooltip: {
|
|
96
131
|
type: String,
|
|
97
|
-
default: '
|
|
132
|
+
default: '是否显示详情',
|
|
98
133
|
},
|
|
99
134
|
// 渲染组件路径
|
|
100
135
|
renderPath: {
|
|
@@ -103,17 +138,25 @@ export default {
|
|
|
103
138
|
},
|
|
104
139
|
// 格式化已选表格的数据并返回渲染组件参数
|
|
105
140
|
renderQuery: Function,
|
|
106
|
-
//
|
|
107
|
-
|
|
141
|
+
// 渲染空状态描述
|
|
142
|
+
renderDescription: {
|
|
108
143
|
type: String,
|
|
109
|
-
default: '
|
|
144
|
+
default: '没有找到任何数据',
|
|
110
145
|
},
|
|
111
146
|
},
|
|
112
147
|
|
|
148
|
+
/**
|
|
149
|
+
* 声明事件
|
|
150
|
+
*/
|
|
151
|
+
emits: [
|
|
152
|
+
'update:modelValue',
|
|
153
|
+
'update:after',
|
|
154
|
+
],
|
|
155
|
+
|
|
113
156
|
/**
|
|
114
157
|
* 组合式
|
|
115
158
|
*/
|
|
116
|
-
setup(props, { slots }) {
|
|
159
|
+
setup(props, { emit, slots }) {
|
|
117
160
|
|
|
118
161
|
// ==========【计算属性】=========================================================================================
|
|
119
162
|
|
|
@@ -121,7 +164,7 @@ export default {
|
|
|
121
164
|
* 插槽标识
|
|
122
165
|
*/
|
|
123
166
|
const slotNames = computed(function() {
|
|
124
|
-
return utils.isValidObject(slots) ? Object.keys(slots) : []
|
|
167
|
+
return utils.isValidObject(slots) ? Object.keys(slots).filter(e => e !== 'toolbar-right') : []
|
|
125
168
|
})
|
|
126
169
|
|
|
127
170
|
/**
|
|
@@ -166,8 +209,42 @@ export default {
|
|
|
166
209
|
// 当前已选单条数据
|
|
167
210
|
const currentSelectedItem = ref(null)
|
|
168
211
|
|
|
212
|
+
// 当前值
|
|
213
|
+
const currentValue = ref(props.modelValue)
|
|
214
|
+
|
|
215
|
+
// 当前显示前置插槽
|
|
216
|
+
const currentAfter = ref(props.after)
|
|
217
|
+
|
|
169
218
|
// ==========【监听数据】=========================================================================================
|
|
170
219
|
|
|
220
|
+
/**
|
|
221
|
+
* 监听声明值
|
|
222
|
+
*/
|
|
223
|
+
watch(() => props.modelValue, function (val) {
|
|
224
|
+
currentValue.value = val
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* 监听声明显示前置插槽
|
|
229
|
+
*/
|
|
230
|
+
watch(() => props.after, function (val) {
|
|
231
|
+
currentAfter.value = val
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* 监听当前值
|
|
236
|
+
*/
|
|
237
|
+
watch(currentValue, function (val) {
|
|
238
|
+
emit('update:modelValue', val)
|
|
239
|
+
})
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* 监听当前显示前置插槽
|
|
243
|
+
*/
|
|
244
|
+
watch(currentAfter, function (val) {
|
|
245
|
+
emit('update:after', val)
|
|
246
|
+
})
|
|
247
|
+
|
|
171
248
|
/**
|
|
172
249
|
* 监听表格已选数据(非手机端有效)
|
|
173
250
|
*/
|
|
@@ -235,6 +312,11 @@ export default {
|
|
|
235
312
|
// 当前传参
|
|
236
313
|
currentQuery,
|
|
237
314
|
|
|
315
|
+
// 当前值
|
|
316
|
+
currentValue,
|
|
317
|
+
// 当前显示前置插槽
|
|
318
|
+
currentAfter,
|
|
319
|
+
|
|
238
320
|
// 设置表格选择类型
|
|
239
321
|
setSelection,
|
|
240
322
|
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot
|
|
3
|
+
:value="currentValue"
|
|
4
|
+
:emitValue="emitValue"
|
|
5
|
+
/>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script>
|
|
9
|
+
import { ref, watch } from 'vue'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 标识
|
|
15
|
+
*/
|
|
16
|
+
name: 'NValueFormat',
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 声明属性
|
|
20
|
+
*/
|
|
21
|
+
props: {
|
|
22
|
+
// 值 v-model
|
|
23
|
+
modelValue: {
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
// 修改前值
|
|
27
|
+
before: [ Function, Object, Boolean ],
|
|
28
|
+
// 修改后值
|
|
29
|
+
after: [ Function, Object, Boolean ],
|
|
30
|
+
// 不自动触发更新
|
|
31
|
+
noEmit: Boolean,
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 声明事件
|
|
36
|
+
*/
|
|
37
|
+
emits: [
|
|
38
|
+
'update:modelValue',
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 组合式
|
|
43
|
+
*/
|
|
44
|
+
setup(props, { emit }) {
|
|
45
|
+
|
|
46
|
+
// ==========【数据】============================================================================================
|
|
47
|
+
|
|
48
|
+
// 当前值
|
|
49
|
+
const currentValue = ref(formatModelValue(props.modelValue))
|
|
50
|
+
|
|
51
|
+
// ==========【监听数据】=========================================================================================
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 监听声明值
|
|
55
|
+
*/
|
|
56
|
+
watch(() => props.modelValue, function (val) {
|
|
57
|
+
|
|
58
|
+
// 格式化声明值
|
|
59
|
+
currentValue.value = formatModelValue(val)
|
|
60
|
+
|
|
61
|
+
}, {
|
|
62
|
+
// 深度监听
|
|
63
|
+
deep: true,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 监听当前值
|
|
68
|
+
*/
|
|
69
|
+
watch(currentValue, function (value) {
|
|
70
|
+
|
|
71
|
+
// 如果是不自动触发更新
|
|
72
|
+
if (props.noEmit) {
|
|
73
|
+
|
|
74
|
+
// 则无任何操作
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 立即执行触发更新值
|
|
79
|
+
emitValue(value)
|
|
80
|
+
|
|
81
|
+
}, {
|
|
82
|
+
// 深度监听
|
|
83
|
+
deep: true,
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// ==========【方法】=============================================================================================
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 格式化声明值
|
|
90
|
+
*/
|
|
91
|
+
function formatModelValue(value) {
|
|
92
|
+
return _.isFunction(props.before)
|
|
93
|
+
// 如果有修改前值方法
|
|
94
|
+
? props.before({ value, formatArray, formatString })
|
|
95
|
+
// 返回值
|
|
96
|
+
: value
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 触发更新值
|
|
101
|
+
*/
|
|
102
|
+
function emitValue(value) {
|
|
103
|
+
|
|
104
|
+
// 触发更新值
|
|
105
|
+
emit(
|
|
106
|
+
'update:modelValue',
|
|
107
|
+
_.isFunction(props.after) ?
|
|
108
|
+
// 如果有修改提交值方法
|
|
109
|
+
props.after({ value, formatArray, formatString })
|
|
110
|
+
// 否则返回当前值
|
|
111
|
+
: value
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* 格式化数组
|
|
117
|
+
*/
|
|
118
|
+
function formatArray(val, params) {
|
|
119
|
+
|
|
120
|
+
const o = Object.assign({
|
|
121
|
+
// 是否去重
|
|
122
|
+
unique: true,
|
|
123
|
+
// 分隔符
|
|
124
|
+
separator: ',',
|
|
125
|
+
// 是否给每个值去除首位空格
|
|
126
|
+
trim: true,
|
|
127
|
+
// 验证每个值是否为有效字符串/数字
|
|
128
|
+
isValidValue: true,
|
|
129
|
+
// 是否转字符串
|
|
130
|
+
toString: false,
|
|
131
|
+
}, params)
|
|
132
|
+
|
|
133
|
+
val = utils.isValidArray(val) ? val : []
|
|
134
|
+
|
|
135
|
+
// 如果数组有值
|
|
136
|
+
if (val.length) {
|
|
137
|
+
|
|
138
|
+
// 是否给每个值去除首位空格
|
|
139
|
+
if (o.trim) {
|
|
140
|
+
val = val.map(e => utils.trimString(e))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 是否验证每个值是否为有效字符串/数字
|
|
144
|
+
if (o.isValidValue) {
|
|
145
|
+
val = val.filter(val => utils.isValidValue(val))
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// 去重
|
|
149
|
+
if (o.unique) {
|
|
150
|
+
val = _.uniq(val)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 如果转字符串
|
|
155
|
+
if (o.toString) {
|
|
156
|
+
// 合并为字符串
|
|
157
|
+
return val.join(o.separator)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return []
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* 格式化字符串
|
|
165
|
+
*/
|
|
166
|
+
function formatString(val, params) {
|
|
167
|
+
|
|
168
|
+
const o = Object.assign({
|
|
169
|
+
// 是否给每个值去除首位空格
|
|
170
|
+
trim: true,
|
|
171
|
+
// 替换内容
|
|
172
|
+
replace: /\n|\,|\s+/g,
|
|
173
|
+
// 是否去重
|
|
174
|
+
unique: true,
|
|
175
|
+
// 分隔符
|
|
176
|
+
separator: ',',
|
|
177
|
+
// 验证每个值是否为有效字符串/数字
|
|
178
|
+
isValidValue: true,
|
|
179
|
+
// 是否转数组
|
|
180
|
+
toArray: false,
|
|
181
|
+
}, params)
|
|
182
|
+
|
|
183
|
+
// 是否去除首尾空格
|
|
184
|
+
if (o.trim) {
|
|
185
|
+
// 去除首尾空格
|
|
186
|
+
val = utils.trimString(val)
|
|
187
|
+
|
|
188
|
+
// 否则转字符串
|
|
189
|
+
} else {
|
|
190
|
+
val = utils.isValidValue(val) ? String(val) : ''
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// 如果有分割符
|
|
194
|
+
if (utils.isValidValue(o.separator, true)) {
|
|
195
|
+
|
|
196
|
+
// 分隔符
|
|
197
|
+
o.separator = utils.trimString(o.separator)
|
|
198
|
+
|
|
199
|
+
// 是否替换
|
|
200
|
+
if (o.replace) {
|
|
201
|
+
val = val.replace(o.replace, o.separator)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 分隔成数组
|
|
205
|
+
val = utils.split(val, o.separator)
|
|
206
|
+
|
|
207
|
+
// 如果去重
|
|
208
|
+
if (o.unique) {
|
|
209
|
+
val = _.uniq(val)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// 如果验证每个值是否为有效字符串/数字
|
|
213
|
+
if (o.isValidValue) {
|
|
214
|
+
val = val.filter(val => utils.isValidValue(val))
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// 如果转数组
|
|
218
|
+
if (o.toArray) {
|
|
219
|
+
// 则直接返回
|
|
220
|
+
return val
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// 返回分隔符隔开的字符串
|
|
224
|
+
return val.join(o.separator)
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return o.toArray ? [ val ] : ''
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ==========【返回】=============================================================================================
|
|
231
|
+
|
|
232
|
+
return {
|
|
233
|
+
// 当前值
|
|
234
|
+
currentValue,
|
|
235
|
+
// 触发更新值
|
|
236
|
+
emitValue,
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</script>
|