@netang/quasar 0.0.46 → 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.
@@ -1,23 +1,23 @@
1
- <template>
2
- <slot :data="data" />
3
- </template>
4
-
5
- <script>
6
- export default {
7
- /**
8
- * 标识
9
- */
10
- name: 'NData',
11
-
12
- /**
13
- * 传参
14
- */
15
- props: {
16
- // 数据
17
- data: {},
18
- },
19
- }
20
- </script>
21
-
22
- <style>
23
- </style>
1
+ <template>
2
+ <slot :data="data" />
3
+ </template>
4
+
5
+ <script>
6
+ export default {
7
+ /**
8
+ * 标识
9
+ */
10
+ name: 'NData',
11
+
12
+ /**
13
+ * 传参
14
+ */
15
+ props: {
16
+ // 数据
17
+ data: {},
18
+ },
19
+ }
20
+ </script>
21
+
22
+ <style>
23
+ </style>
@@ -12,12 +12,13 @@
12
12
  </template>
13
13
 
14
14
  <!--:class="fieldFocused ? 'q-field&#45;&#45;float q-field&#45;&#45;focused q-field&#45;&#45;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 && (! multiple || collapseTags)"
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
- // array: 数组
208
- // arrayObject: 数组对象
207
+ // string: 字符串或数字
208
+ // stringArray: 普通数组(包含字符串或数字的一维数组)
209
+ // objectArray: 对象数组(包含对象的一维数组)
209
210
  valueType: {
210
211
  type: String,
211
- default: 'arrayObject'
212
+ default: 'objectArray'
212
213
  },
213
214
  // 值分隔符(值类型为 string 有效)
214
215
  valueSeparator: {
@@ -422,7 +423,7 @@ export default {
422
423
  let newSelected = valueToSelected(val, false, false)
423
424
 
424
425
  // 如果值类型是数组对象
425
- if (props.valueType === 'arrayObject') {
426
+ if (props.valueType === 'objectArray') {
426
427
 
427
428
  // 设置已选数据
428
429
  setSelected(newSelected)
@@ -541,7 +542,7 @@ export default {
541
542
 
542
543
  if (
543
544
  // 如果值类型不是数组对象
544
- props.valueType !== 'arrayObject'
545
+ props.valueType !== 'objectArray'
545
546
  // 如果初始加载已选数据
546
547
  && ! props.noFirstLoadSelected
547
548
  // 如果有请求路由路径
@@ -602,12 +603,16 @@ export default {
602
603
  * 当前格式化显示标签
603
604
  */
604
605
  function currentFormatLabel(item) {
606
+
605
607
  // 如果有格式化显示标签方法
606
- return _.isFunction(props.formatLabel)
608
+ if (_.isFunction(props.formatLabel)) {
607
609
  // 执行格式化显示标签方法
608
- ? props.formatLabel(item)
609
- // 否则显示该值的标签字段
610
- : item[currentlabelKey.value]
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
  /**
@@ -626,7 +631,7 @@ export default {
626
631
  function valueToSelected(val, isFirst, toSelected) {
627
632
 
628
633
  // 如果值类型是数组对象
629
- if (props.valueType === 'arrayObject') {
634
+ if (props.valueType === 'objectArray') {
630
635
 
631
636
  // 如果是有效数组
632
637
  if (utils.isValidArray(val)) {
@@ -673,7 +678,7 @@ export default {
673
678
  function selectedToValue(val) {
674
679
 
675
680
  // 如果值类型是数组对象
676
- if (props.valueType === 'arrayObject') {
681
+ if (props.valueType === 'objectArray') {
677
682
 
678
683
  // 则直接返回
679
684
  return val
@@ -693,7 +698,7 @@ export default {
693
698
  : []
694
699
 
695
700
  // 如果值类型是数组
696
- if (props.valueType === 'array') {
701
+ if (props.valueType === 'stringArray') {
697
702
 
698
703
  // 直接返回数组
699
704
  return values
@@ -1071,6 +1076,8 @@ export default {
1071
1076
  popupRef,
1072
1077
  // 是否显示对话框
1073
1078
  showDialog,
1079
+ // 是否显示弹出层
1080
+ showPopup,
1074
1081
  // 当前已选数据
1075
1082
  selected,
1076
1083
  // 当前表格列数据
@@ -3,7 +3,7 @@
3
3
  class="n-field-tree"
4
4
  :model-value="showValue"
5
5
  :readonly="readonly"
6
- :clearable="clearable && (! multiple || collapseTags)"
6
+ :clearable="clearable"
7
7
  @focus="onFieldFocus"
8
8
  @blur="onFieldBlur"
9
9
  @clear="onFieldClear"
@@ -592,6 +592,8 @@ export default {
592
592
  inputValue,
593
593
  // 弹出层节点
594
594
  popupRef,
595
+ // 是否显示弹出层
596
+ showPopup,
595
597
  // 树节点
596
598
  treeRef,
597
599
  // 树选择数据
@@ -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 res = props.renderQuery(currentSelectedItem.value)
188
- if (utils.isValidObject(res)) {
189
-
190
- // 格式化已选数据, 并返回参数
191
- return Object.assign({
192
- // 是否为渲染页面
193
- n_render_page: 1,
194
- }, res)
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' : 'multiple'
303
+ const selection = showAfter ? 'single' : rawTableSelection
293
304
  if ($table.tableSelection.value !== selection) {
294
305
  $table.tableSelection.value = selection
295
306
 
@@ -0,0 +1,267 @@
1
+ <template>
2
+ <slot
3
+ :scope="current"
4
+ :emit="emitValue"
5
+ />
6
+ </template>
7
+
8
+ <script>
9
+ import { ref, watch } from 'vue'
10
+
11
+ export default {
12
+
13
+ /**
14
+ * 关闭组件 attribute 透传行为
15
+ */
16
+ inheritAttrs: false,
17
+
18
+ /**
19
+ * 标识
20
+ */
21
+ name: 'NValueFormat',
22
+
23
+ /**
24
+ * 声明属性
25
+ */
26
+ props: {
27
+ // 值 v-model
28
+ modelValue: {
29
+ required: true,
30
+ },
31
+ // 修改前值
32
+ before: [ Function, Object, Boolean ],
33
+ // 修改后值
34
+ after: [ Function, Object, Boolean ],
35
+ // 不自动触发更新
36
+ noEmit: Boolean,
37
+ },
38
+
39
+ /**
40
+ * 声明事件
41
+ */
42
+ emits: [
43
+ 'update:modelValue',
44
+ ],
45
+
46
+ /**
47
+ * 组合式
48
+ */
49
+ setup(props, { emit }) {
50
+
51
+ // ==========【数据】============================================================================================
52
+
53
+ // 当前值
54
+ const current = ref({
55
+ value: formatModelValue(props.modelValue),
56
+ })
57
+
58
+ // 如果是自动触发更新
59
+ if (! props.noEmit) {
60
+ // 触发更新值
61
+ // 此处用于判断声明值是否有改变
62
+ emitValue()
63
+ }
64
+
65
+ // ==========【监听数据】=========================================================================================
66
+
67
+ /**
68
+ * 监听声明值
69
+ */
70
+ watch(() => props.modelValue, function (val) {
71
+
72
+ // 格式化声明值
73
+ current.value.value = formatModelValue(val)
74
+
75
+ }, {
76
+ // 深度监听
77
+ deep: true,
78
+ })
79
+
80
+ /**
81
+ * 监听当前值
82
+ */
83
+ watch(current, function (value) {
84
+
85
+ // 如果是自动触发更新
86
+ if (! props.noEmit) {
87
+
88
+ // 立即执行触发更新值
89
+ emitValue(value.value)
90
+ }
91
+
92
+ }, {
93
+ // 深度监听
94
+ deep: true,
95
+ })
96
+
97
+ // ==========【方法】=============================================================================================
98
+
99
+ /**
100
+ * 格式化声明值
101
+ */
102
+ function formatModelValue(value) {
103
+ return _.isFunction(props.before)
104
+ // 如果有修改前值方法
105
+ ? props.before({ value, formatArray, formatString })
106
+ // 返回值
107
+ : value
108
+ }
109
+
110
+ /**
111
+ * 触发更新值
112
+ */
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
136
+
137
+ // 如果值有改变
138
+ if (newValue !== props.modelValue) {
139
+
140
+ // 触发更新值
141
+ emit('update:modelValue', newValue)
142
+ }
143
+ }
144
+
145
+ /**
146
+ * 格式化数组
147
+ */
148
+ function formatArray(val, params) {
149
+
150
+ const o = Object.assign({
151
+ // 是否去重
152
+ unique: true,
153
+ // 分隔符
154
+ separator: ',',
155
+ // 是否给每个值去除首位空格
156
+ trim: true,
157
+ // 验证每个值是否为有效字符串/数字
158
+ isValidValue: true,
159
+ // 是否转字符串
160
+ toString: false,
161
+ }, params)
162
+
163
+ val = utils.isValidArray(val) ? val : []
164
+
165
+ // 如果数组有值
166
+ if (val.length) {
167
+
168
+ // 是否给每个值去除首位空格
169
+ if (o.trim) {
170
+ val = val.map(e => utils.trimString(e))
171
+ }
172
+
173
+ // 是否验证每个值是否为有效字符串/数字
174
+ if (o.isValidValue) {
175
+ val = val.filter(val => utils.isValidValue(val))
176
+ }
177
+
178
+ // 去重
179
+ if (o.unique) {
180
+ val = _.uniq(val)
181
+ }
182
+ }
183
+
184
+ // 如果转字符串
185
+ if (o.toString) {
186
+ // 合并为字符串
187
+ return val.join(o.separator)
188
+ }
189
+
190
+ return []
191
+ }
192
+
193
+ /**
194
+ * 格式化字符串
195
+ */
196
+ function formatString(val, params) {
197
+
198
+ const o = Object.assign({
199
+ // 是否给每个值去除首位空格
200
+ trim: true,
201
+ // 替换内容
202
+ replace: /\n|,|,|\s+/g,
203
+ // 是否去重
204
+ unique: true,
205
+ // 分隔符
206
+ separator: ',',
207
+ // 验证每个值是否为有效字符串/数字
208
+ isValidValue: true,
209
+ // 是否转数组
210
+ toArray: false,
211
+ }, params)
212
+
213
+ // 是否去除首尾空格
214
+ if (o.trim) {
215
+ // 去除首尾空格
216
+ val = utils.trimString(val)
217
+
218
+ // 否则转字符串
219
+ } else {
220
+ val = utils.isValidValue(val) ? String(val) : ''
221
+ }
222
+
223
+ // 如果有分割符
224
+ if (utils.isValidValue(o.separator, true)) {
225
+
226
+ // 是否替换
227
+ if (o.replace) {
228
+ val = val.replace(o.replace, o.separator)
229
+ }
230
+
231
+ // 分隔成数组
232
+ val = utils.split(val, o.separator)
233
+
234
+ // 如果去重
235
+ if (o.unique) {
236
+ val = _.uniq(val)
237
+ }
238
+
239
+ // 如果验证每个值是否为有效字符串/数字
240
+ if (o.isValidValue) {
241
+ val = val.filter(val => utils.isValidValue(val))
242
+ }
243
+
244
+ // 如果转数组
245
+ if (o.toArray) {
246
+ // 则直接返回
247
+ return val
248
+ }
249
+
250
+ // 返回分隔符隔开的字符串
251
+ return val.join(o.separator)
252
+ }
253
+
254
+ return o.toArray ? [ val ] : ''
255
+ }
256
+
257
+ // ==========【返回】=============================================================================================
258
+
259
+ return {
260
+ // 当前值
261
+ current,
262
+ // 触发更新值
263
+ emitValue,
264
+ }
265
+ }
266
+ }
267
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.46",
3
+ "version": "0.0.48",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
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
  }
package/utils/price.js CHANGED
@@ -1,13 +1,13 @@
1
- /**
2
- * 换算金额
3
- */
4
- utils.price = function(value, params) {
5
- return utils.decimal(value, Object.assign({
6
- // 最小值
7
- min: 0,
8
- // 小数点位数
9
- decimalLength: 2,
10
- // 是否开启人民币分转元(如值 189 -> 1.89)
11
- centToYuan: utils.config('priceCent') === true,
12
- }, params))
13
- }
1
+ /**
2
+ * 换算金额
3
+ */
4
+ utils.price = function(value, params) {
5
+ return utils.decimal(value, Object.assign({
6
+ // 最小值
7
+ min: 0,
8
+ // 小数点位数
9
+ decimalLength: 2,
10
+ // 是否开启人民币分转元(如值 189 -> 1.89)
11
+ centToYuan: utils.config('priceCent') === true,
12
+ }, params))
13
+ }
@@ -1,259 +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
- 'blur',
49
- ],
50
-
51
- /**
52
- * 组合式
53
- */
54
- setup(props, { emit, slots }) {
55
-
56
- // ==========【计算属性】=========================================================================================
57
-
58
- /**
59
- * 插槽标识
60
- */
61
- const slotNames = computed(function() {
62
- return utils.isValidObject(slots) ? Object.keys(slots) : []
63
- })
64
-
65
- // ==========【数据】============================================================================================
66
-
67
- // 当前值
68
- const currentValue = ref(formatModelValue(props.modelValue))
69
-
70
- // ==========【监听数据】=========================================================================================
71
-
72
- /**
73
- * 监听声明值
74
- */
75
- watch(() => props.modelValue, function (val) {
76
-
77
- // 格式化声明值
78
- currentValue.value = formatModelValue(val)
79
-
80
- }, {
81
- // 深度监听
82
- deep: true,
83
- })
84
-
85
- // ==========【方法】=============================================================================================
86
-
87
- /**
88
- * 格式化声明值
89
- */
90
- function formatModelValue(val) {
91
-
92
- if (props.formatBefore) {
93
-
94
- // 如果是方法
95
- if (_.isFunction(props.formatBefore)) {
96
- return props.formatBefore(val)
97
- }
98
-
99
- // 如果是参数
100
- if (props.formatBefore === true || utils.isValidObject(props.formatBefore)) {
101
-
102
- // 如果值是数组
103
- if (Array.isArray(val)) {
104
-
105
- // 格式化数组值
106
- return formatArrayValue(val, props.formatBefore === true ? {} : props.formatBefore)
107
- }
108
-
109
- // 如果是有效值
110
- if (utils.isValidValue(val)) {
111
-
112
- // 格式化字符串值
113
- return formatStringValue(val, props.formatBefore === true ? {} : props.formatBefore, false)
114
- }
115
-
116
- return ''
117
- }
118
- }
119
-
120
- return val
121
- }
122
-
123
- /**
124
- * 格式化数组值
125
- */
126
- function formatArrayValue(val, params) {
127
-
128
- // 如果数组有值
129
- if (val.length) {
130
-
131
- const o = Object.assign({
132
- // 是否去重
133
- unique: true,
134
- // 分隔符
135
- separator: ',',
136
- // 是否给每个值去除首位空格
137
- trim: true,
138
- // 验证每个值是否为有效字符串/数字
139
- isValidValue: true,
140
- }, params)
141
-
142
- // 是否给每个值去除首位空格
143
- if (o.trim) {
144
- val = val.map(e => utils.trimString(e))
145
- }
146
-
147
- // 是否验证每个值是否为有效字符串/数字
148
- if (o.isValidValue) {
149
- val = val.filter(val => utils.isValidValue(val))
150
- }
151
-
152
- // 去重
153
- if (o.unique) {
154
- val = _.uniq(val)
155
- }
156
-
157
- // 合并为字符串
158
- return val.join(o.separator)
159
- }
160
-
161
- return ''
162
- }
163
-
164
- /**
165
- * 格式化字符串值
166
- */
167
- function formatStringValue(val, params, valueArray) {
168
-
169
- const o = Object.assign({
170
- // 替换内容
171
- replace: /\n|\,|\s+/g,
172
- // 是否去重
173
- unique: true,
174
- // 分隔符
175
- separator: ',',
176
- // 验证每个值是否为有效字符串/数字
177
- isValidValue: true,
178
- }, params)
179
-
180
- // 去除首位空格
181
- val = utils.trimString(val)
182
-
183
- // 如果有分割符
184
- if (utils.isValidValue(o.separator, true)) {
185
-
186
- o.separator = String(o.separator)
187
-
188
- // 是否替换
189
- if (o.replace) {
190
- val = val.replace(o.replace, o.separator)
191
- }
192
-
193
- // 分隔成数组
194
- val = utils.split(val, o.separator)
195
-
196
- // 去重
197
- if (o.unique) {
198
- val = _.uniq(val)
199
- }
200
-
201
- // 如果验证每个值是否为有效字符串/数字
202
- if (o.isValidValue) {
203
- val = val.filter(val => utils.isValidValue(val))
204
- }
205
-
206
- // 如果值不是数组
207
- if (! valueArray) {
208
- val = val.join(o.separator)
209
- }
210
-
211
- return val
212
- }
213
-
214
- return valueArray ? [ val ] : ''
215
- }
216
-
217
- /**
218
- * 失去焦点触发
219
- */
220
- function onBlur() {
221
-
222
- let val = currentValue.value
223
-
224
- // 如果修改值
225
- if (props.formatAfter) {
226
-
227
- // 如果是方法
228
- if (_.isFunction(props.formatAfter)) {
229
- val = props.formatAfter(val)
230
-
231
- // 如果是参数
232
- } else if (props.formatAfter === true || utils.isValidObject(props.formatAfter)) {
233
-
234
- // 格式化字符串值
235
- val = formatStringValue(val, props.formatAfter === true ? {} : props.formatAfter, props.valueArray)
236
- }
237
- }
238
-
239
- // 更新值
240
- emit('update:modelValue', val)
241
-
242
- // 失去焦点触发
243
- emit('blur', val)
244
- }
245
-
246
- // ==========【返回】=============================================================================================
247
-
248
- return {
249
- // 插槽标识
250
- slotNames,
251
- // 当前值
252
- currentValue,
253
-
254
- // 失去焦点触发
255
- onBlur,
256
- }
257
- }
258
- }
259
- </script>