@netang/quasar 0.0.47 → 0.0.48
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 +5 -7
- package/components/field-tree/index.vue +1 -1
- package/components/table-splitter/index.vue +20 -9
- package/components/value-format/index.vue +54 -27
- package/package.json +1 -1
- package/utils/$power.js +7 -0
- package/components/input-format/index.vue +0 -268
|
@@ -423,7 +423,7 @@ export default {
|
|
|
423
423
|
let newSelected = valueToSelected(val, false, false)
|
|
424
424
|
|
|
425
425
|
// 如果值类型是数组对象
|
|
426
|
-
if (props.valueType === '
|
|
426
|
+
if (props.valueType === 'objectArray') {
|
|
427
427
|
|
|
428
428
|
// 设置已选数据
|
|
429
429
|
setSelected(newSelected)
|
|
@@ -542,7 +542,7 @@ export default {
|
|
|
542
542
|
|
|
543
543
|
if (
|
|
544
544
|
// 如果值类型不是数组对象
|
|
545
|
-
props.valueType !== '
|
|
545
|
+
props.valueType !== 'objectArray'
|
|
546
546
|
// 如果初始加载已选数据
|
|
547
547
|
&& ! props.noFirstLoadSelected
|
|
548
548
|
// 如果有请求路由路径
|
|
@@ -631,7 +631,7 @@ export default {
|
|
|
631
631
|
function valueToSelected(val, isFirst, toSelected) {
|
|
632
632
|
|
|
633
633
|
// 如果值类型是数组对象
|
|
634
|
-
if (props.valueType === '
|
|
634
|
+
if (props.valueType === 'objectArray') {
|
|
635
635
|
|
|
636
636
|
// 如果是有效数组
|
|
637
637
|
if (utils.isValidArray(val)) {
|
|
@@ -678,7 +678,7 @@ export default {
|
|
|
678
678
|
function selectedToValue(val) {
|
|
679
679
|
|
|
680
680
|
// 如果值类型是数组对象
|
|
681
|
-
if (props.valueType === '
|
|
681
|
+
if (props.valueType === 'objectArray') {
|
|
682
682
|
|
|
683
683
|
// 则直接返回
|
|
684
684
|
return val
|
|
@@ -698,7 +698,7 @@ export default {
|
|
|
698
698
|
: []
|
|
699
699
|
|
|
700
700
|
// 如果值类型是数组
|
|
701
|
-
if (props.valueType === '
|
|
701
|
+
if (props.valueType === 'stringArray') {
|
|
702
702
|
|
|
703
703
|
// 直接返回数组
|
|
704
704
|
return values
|
|
@@ -846,8 +846,6 @@ export default {
|
|
|
846
846
|
// 停止冒泡
|
|
847
847
|
e.stopPropagation()
|
|
848
848
|
|
|
849
|
-
console.log('onFieldBluronFieldBlur', props.filter, showPopup.value)
|
|
850
|
-
|
|
851
849
|
if (
|
|
852
850
|
// 如果开启筛选
|
|
853
851
|
props.filter
|
|
@@ -143,6 +143,9 @@ export default {
|
|
|
143
143
|
type: String,
|
|
144
144
|
default: '没有找到任何数据',
|
|
145
145
|
},
|
|
146
|
+
// 不需要加载渲染页面标识参数
|
|
147
|
+
// 额外加载参数 { n_renderpage: 1 }
|
|
148
|
+
noRendPageName: Boolean,
|
|
146
149
|
},
|
|
147
150
|
|
|
148
151
|
/**
|
|
@@ -184,14 +187,19 @@ export default {
|
|
|
184
187
|
currentSelectedItem.value
|
|
185
188
|
&& _.isFunction(props.renderQuery)
|
|
186
189
|
) {
|
|
187
|
-
const
|
|
188
|
-
if (utils.isValidObject(
|
|
189
|
-
|
|
190
|
-
//
|
|
191
|
-
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
const resQuery = props.renderQuery(currentSelectedItem.value)
|
|
191
|
+
if (utils.isValidObject(resQuery)) {
|
|
192
|
+
|
|
193
|
+
// 如果需要加载渲染页面标识参数
|
|
194
|
+
if (! props.noRendPageName) {
|
|
195
|
+
// 格式化已选数据, 并返回参数
|
|
196
|
+
return Object.assign({}, resQuery, {
|
|
197
|
+
// 是否为渲染页面
|
|
198
|
+
n_renderpage: 1,
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return resQuery
|
|
195
203
|
}
|
|
196
204
|
}
|
|
197
205
|
|
|
@@ -206,6 +214,9 @@ export default {
|
|
|
206
214
|
// 获取表格注入
|
|
207
215
|
const $table = inject(NTableKey)
|
|
208
216
|
|
|
217
|
+
// 原始表格选择状态
|
|
218
|
+
const rawTableSelection = $table.tableSelection.value
|
|
219
|
+
|
|
209
220
|
// 当前已选单条数据
|
|
210
221
|
const currentSelectedItem = ref(null)
|
|
211
222
|
|
|
@@ -289,7 +300,7 @@ export default {
|
|
|
289
300
|
return
|
|
290
301
|
}
|
|
291
302
|
|
|
292
|
-
const selection = showAfter ? 'single' :
|
|
303
|
+
const selection = showAfter ? 'single' : rawTableSelection
|
|
293
304
|
if ($table.tableSelection.value !== selection) {
|
|
294
305
|
$table.tableSelection.value = selection
|
|
295
306
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot
|
|
3
|
-
:
|
|
4
|
-
:
|
|
3
|
+
:scope="current"
|
|
4
|
+
:emit="emitValue"
|
|
5
5
|
/>
|
|
6
6
|
</template>
|
|
7
7
|
|
|
@@ -10,6 +10,11 @@ import { ref, watch } from 'vue'
|
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* 关闭组件 attribute 透传行为
|
|
15
|
+
*/
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* 标识
|
|
15
20
|
*/
|
|
@@ -46,7 +51,16 @@ export default {
|
|
|
46
51
|
// ==========【数据】============================================================================================
|
|
47
52
|
|
|
48
53
|
// 当前值
|
|
49
|
-
const
|
|
54
|
+
const current = ref({
|
|
55
|
+
value: formatModelValue(props.modelValue),
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
// 如果是自动触发更新
|
|
59
|
+
if (! props.noEmit) {
|
|
60
|
+
// 触发更新值
|
|
61
|
+
// 此处用于判断声明值是否有改变
|
|
62
|
+
emitValue()
|
|
63
|
+
}
|
|
50
64
|
|
|
51
65
|
// ==========【监听数据】=========================================================================================
|
|
52
66
|
|
|
@@ -56,7 +70,7 @@ export default {
|
|
|
56
70
|
watch(() => props.modelValue, function (val) {
|
|
57
71
|
|
|
58
72
|
// 格式化声明值
|
|
59
|
-
|
|
73
|
+
current.value.value = formatModelValue(val)
|
|
60
74
|
|
|
61
75
|
}, {
|
|
62
76
|
// 深度监听
|
|
@@ -66,18 +80,15 @@ export default {
|
|
|
66
80
|
/**
|
|
67
81
|
* 监听当前值
|
|
68
82
|
*/
|
|
69
|
-
watch(
|
|
83
|
+
watch(current, function (value) {
|
|
70
84
|
|
|
71
|
-
//
|
|
72
|
-
if (props.noEmit) {
|
|
85
|
+
// 如果是自动触发更新
|
|
86
|
+
if (! props.noEmit) {
|
|
73
87
|
|
|
74
|
-
//
|
|
75
|
-
|
|
88
|
+
// 立即执行触发更新值
|
|
89
|
+
emitValue(value.value)
|
|
76
90
|
}
|
|
77
91
|
|
|
78
|
-
// 立即执行触发更新值
|
|
79
|
-
emitValue(value)
|
|
80
|
-
|
|
81
92
|
}, {
|
|
82
93
|
// 深度监听
|
|
83
94
|
deep: true,
|
|
@@ -99,17 +110,36 @@ export default {
|
|
|
99
110
|
/**
|
|
100
111
|
* 触发更新值
|
|
101
112
|
*/
|
|
102
|
-
function emitValue(
|
|
113
|
+
function emitValue() {
|
|
114
|
+
|
|
115
|
+
// if (
|
|
116
|
+
// value !== void 0
|
|
117
|
+
// && typeof value === 'object'
|
|
118
|
+
// && value instanceof Event
|
|
119
|
+
// ) {
|
|
120
|
+
// // 停止冒泡
|
|
121
|
+
// value.stopPropagation()
|
|
122
|
+
//
|
|
123
|
+
// // 获取当前值
|
|
124
|
+
// value = current.value.value
|
|
125
|
+
// }
|
|
126
|
+
|
|
127
|
+
// 获取当前值
|
|
128
|
+
const value = current.value.value
|
|
129
|
+
|
|
130
|
+
// 获取新值
|
|
131
|
+
const newValue = _.isFunction(props.after) ?
|
|
132
|
+
// 如果有修改提交值方法
|
|
133
|
+
props.after({ value, formatArray, formatString })
|
|
134
|
+
// 否则返回当前值
|
|
135
|
+
: value
|
|
103
136
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
// 否则返回当前值
|
|
111
|
-
: value
|
|
112
|
-
)
|
|
137
|
+
// 如果值有改变
|
|
138
|
+
if (newValue !== props.modelValue) {
|
|
139
|
+
|
|
140
|
+
// 触发更新值
|
|
141
|
+
emit('update:modelValue', newValue)
|
|
142
|
+
}
|
|
113
143
|
}
|
|
114
144
|
|
|
115
145
|
/**
|
|
@@ -169,7 +199,7 @@ export default {
|
|
|
169
199
|
// 是否给每个值去除首位空格
|
|
170
200
|
trim: true,
|
|
171
201
|
// 替换内容
|
|
172
|
-
replace: /\n
|
|
202
|
+
replace: /\n|,|,|\s+/g,
|
|
173
203
|
// 是否去重
|
|
174
204
|
unique: true,
|
|
175
205
|
// 分隔符
|
|
@@ -193,9 +223,6 @@ export default {
|
|
|
193
223
|
// 如果有分割符
|
|
194
224
|
if (utils.isValidValue(o.separator, true)) {
|
|
195
225
|
|
|
196
|
-
// 分隔符
|
|
197
|
-
o.separator = utils.trimString(o.separator)
|
|
198
|
-
|
|
199
226
|
// 是否替换
|
|
200
227
|
if (o.replace) {
|
|
201
228
|
val = val.replace(o.replace, o.separator)
|
|
@@ -231,7 +258,7 @@ export default {
|
|
|
231
258
|
|
|
232
259
|
return {
|
|
233
260
|
// 当前值
|
|
234
|
-
|
|
261
|
+
current,
|
|
235
262
|
// 触发更新值
|
|
236
263
|
emitValue,
|
|
237
264
|
}
|
package/package.json
CHANGED
package/utils/$power.js
CHANGED
|
@@ -1010,6 +1010,13 @@ async function request(params) {
|
|
|
1010
1010
|
// 关闭窗口、跳转并刷新页面
|
|
1011
1011
|
case 'closePushRefresh':
|
|
1012
1012
|
|
|
1013
|
+
// 如果是渲染页面
|
|
1014
|
+
// 说明该页面在 <table-splitter> 组件内部被渲染, 则不需要关闭当前窗口
|
|
1015
|
+
if (_.has($route.query, 'n_renderpage') && $route.query.n_renderpage === 1) {
|
|
1016
|
+
// 则无任何操作
|
|
1017
|
+
return
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1013
1020
|
const opts = {
|
|
1014
1021
|
type: 'closeCurrentTab',
|
|
1015
1022
|
}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<q-input
|
|
3
|
-
v-model="currentValue"
|
|
4
|
-
@blur="onBlur"
|
|
5
|
-
v-bind="$attrs"
|
|
6
|
-
>
|
|
7
|
-
<!-- 插槽 -->
|
|
8
|
-
<template
|
|
9
|
-
v-for="slotName in slotNames"
|
|
10
|
-
v-slot:[slotName]
|
|
11
|
-
>
|
|
12
|
-
<slot :name="slotName" />
|
|
13
|
-
</template>
|
|
14
|
-
</q-input>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script>
|
|
18
|
-
import { computed, ref, watch } from 'vue'
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* 标识
|
|
24
|
-
*/
|
|
25
|
-
name: 'NInputFormat',
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 声明属性
|
|
29
|
-
*/
|
|
30
|
-
props: {
|
|
31
|
-
// 值 v-model
|
|
32
|
-
modelValue: {
|
|
33
|
-
required: true,
|
|
34
|
-
},
|
|
35
|
-
// 值是否为数组
|
|
36
|
-
valueArray: Boolean,
|
|
37
|
-
// 修改前值
|
|
38
|
-
formatBefore: [ Function, Object, Boolean ],
|
|
39
|
-
// 修改后值
|
|
40
|
-
formatAfter: [ Function, Object, Boolean ],
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* 声明事件
|
|
45
|
-
*/
|
|
46
|
-
emits: [
|
|
47
|
-
'update:modelValue',
|
|
48
|
-
],
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 组合式
|
|
52
|
-
*/
|
|
53
|
-
setup(props, { emit, slots }) {
|
|
54
|
-
|
|
55
|
-
// ==========【计算属性】=========================================================================================
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 插槽标识
|
|
59
|
-
*/
|
|
60
|
-
const slotNames = computed(function() {
|
|
61
|
-
return utils.isValidObject(slots) ? Object.keys(slots) : []
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
// ==========【数据】============================================================================================
|
|
65
|
-
|
|
66
|
-
// 当前值
|
|
67
|
-
const currentValue = ref(formatModelValue(props.modelValue))
|
|
68
|
-
|
|
69
|
-
// ==========【监听数据】=========================================================================================
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* 监听声明值
|
|
73
|
-
*/
|
|
74
|
-
watch(() => props.modelValue, function (val) {
|
|
75
|
-
|
|
76
|
-
// 格式化声明值
|
|
77
|
-
currentValue.value = formatModelValue(val)
|
|
78
|
-
|
|
79
|
-
}, {
|
|
80
|
-
// 深度监听
|
|
81
|
-
deep: true,
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
// ==========【方法】=============================================================================================
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 触发更新值
|
|
88
|
-
*/
|
|
89
|
-
function emitModelValue(val) {
|
|
90
|
-
// 触发更新值
|
|
91
|
-
emit('update:modelValue', val)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 格式化声明值
|
|
96
|
-
*/
|
|
97
|
-
function formatModelValue(val) {
|
|
98
|
-
|
|
99
|
-
if (props.formatBefore) {
|
|
100
|
-
|
|
101
|
-
// 如果是方法
|
|
102
|
-
if (_.isFunction(props.formatBefore)) {
|
|
103
|
-
return props.formatBefore(val)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
// 如果是参数
|
|
107
|
-
if (props.formatBefore === true || utils.isValidObject(props.formatBefore)) {
|
|
108
|
-
|
|
109
|
-
// 如果值是数组
|
|
110
|
-
if (Array.isArray(val)) {
|
|
111
|
-
|
|
112
|
-
// 格式化数组值
|
|
113
|
-
return formatArrayValue(val, props.formatBefore === true ? {} : props.formatBefore)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// 如果是有效值
|
|
117
|
-
if (utils.isValidValue(val)) {
|
|
118
|
-
|
|
119
|
-
// 格式化字符串值
|
|
120
|
-
return formatStringValue(val, props.formatBefore === true ? {} : props.formatBefore, false)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return ''
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return Array.isArray(val) ? val.join(',') : val
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 格式化数组值
|
|
132
|
-
*/
|
|
133
|
-
function formatArrayValue(val, params) {
|
|
134
|
-
|
|
135
|
-
// 如果数组有值
|
|
136
|
-
if (val.length) {
|
|
137
|
-
|
|
138
|
-
const o = Object.assign({
|
|
139
|
-
// 是否去重
|
|
140
|
-
unique: true,
|
|
141
|
-
// 分隔符
|
|
142
|
-
separator: ',',
|
|
143
|
-
// 是否给每个值去除首位空格
|
|
144
|
-
trim: true,
|
|
145
|
-
// 验证每个值是否为有效字符串/数字
|
|
146
|
-
isValidValue: true,
|
|
147
|
-
}, params)
|
|
148
|
-
|
|
149
|
-
// 是否给每个值去除首位空格
|
|
150
|
-
if (o.trim) {
|
|
151
|
-
val = val.map(e => utils.trimString(e))
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// 是否验证每个值是否为有效字符串/数字
|
|
155
|
-
if (o.isValidValue) {
|
|
156
|
-
val = val.filter(val => utils.isValidValue(val))
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// 去重
|
|
160
|
-
if (o.unique) {
|
|
161
|
-
val = _.uniq(val)
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// 合并为字符串
|
|
165
|
-
return val.join(o.separator)
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
return ''
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* 格式化字符串值
|
|
173
|
-
*/
|
|
174
|
-
function formatStringValue(val, params, valueArray) {
|
|
175
|
-
|
|
176
|
-
const o = Object.assign({
|
|
177
|
-
// 替换内容
|
|
178
|
-
replace: /\n|\,|\s+/g,
|
|
179
|
-
// 是否去重
|
|
180
|
-
unique: true,
|
|
181
|
-
// 分隔符
|
|
182
|
-
separator: ',',
|
|
183
|
-
// 验证每个值是否为有效字符串/数字
|
|
184
|
-
isValidValue: true,
|
|
185
|
-
}, params)
|
|
186
|
-
|
|
187
|
-
// 去除首位空格
|
|
188
|
-
val = utils.trimString(val)
|
|
189
|
-
|
|
190
|
-
// 如果有分割符
|
|
191
|
-
if (utils.isValidValue(o.separator, true)) {
|
|
192
|
-
|
|
193
|
-
o.separator = String(o.separator)
|
|
194
|
-
|
|
195
|
-
// 是否替换
|
|
196
|
-
if (o.replace) {
|
|
197
|
-
val = val.replace(o.replace, o.separator)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
// 分隔成数组
|
|
201
|
-
val = utils.split(val, o.separator)
|
|
202
|
-
|
|
203
|
-
// 去重
|
|
204
|
-
if (o.unique) {
|
|
205
|
-
val = _.uniq(val)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
// 如果验证每个值是否为有效字符串/数字
|
|
209
|
-
if (o.isValidValue) {
|
|
210
|
-
val = val.filter(val => utils.isValidValue(val))
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
// 如果值不是数组
|
|
214
|
-
if (! valueArray) {
|
|
215
|
-
val = val.join(o.separator)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return val
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
return valueArray ? [ val ] : ''
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
/**
|
|
225
|
-
* 失去焦点触发
|
|
226
|
-
*/
|
|
227
|
-
function onBlur() {
|
|
228
|
-
|
|
229
|
-
const val = currentValue.value
|
|
230
|
-
|
|
231
|
-
// 如果修改值
|
|
232
|
-
if (props.formatAfter) {
|
|
233
|
-
|
|
234
|
-
// 如果是方法
|
|
235
|
-
if (_.isFunction(props.formatAfter)) {
|
|
236
|
-
|
|
237
|
-
// 触发更新值
|
|
238
|
-
emitModelValue(props.formatAfter(val))
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// 如果是参数
|
|
243
|
-
if (props.formatAfter === true || utils.isValidObject(props.formatAfter)) {
|
|
244
|
-
|
|
245
|
-
// 触发更新值
|
|
246
|
-
emitModelValue(formatStringValue(val, props.formatAfter === true ? {} : props.formatAfter, props.valueArray))
|
|
247
|
-
return
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// 触发更新值
|
|
252
|
-
emitModelValue(props.valueArray ? utils.split(val, ',') : val)
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
// ==========【返回】=============================================================================================
|
|
256
|
-
|
|
257
|
-
return {
|
|
258
|
-
// 插槽标识
|
|
259
|
-
slotNames,
|
|
260
|
-
// 当前值
|
|
261
|
-
currentValue,
|
|
262
|
-
|
|
263
|
-
// 失去焦点触发
|
|
264
|
-
onBlur,
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
</script>
|