@netang/quasar 0.0.34 → 0.0.36

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.
@@ -0,0 +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>
@@ -22,7 +22,6 @@
22
22
  <script>
23
23
  import { ref, inject, nextTick, watch } from 'vue'
24
24
  import { useQuasar } from 'quasar'
25
- import { useRoute } from 'vue-router'
26
25
 
27
26
  import { layoutKey, emptyRenderFn } from 'quasar/src/utils/private/symbols.js'
28
27
 
@@ -108,9 +107,6 @@ export default {
108
107
  // quasar 对象
109
108
  const $q = useQuasar()
110
109
 
111
- // 获取当前路由
112
- let fullPath = ''
113
-
114
110
  // 获取权限注入数据
115
111
  const $power = inject(NPowerKey)
116
112
 
@@ -124,13 +120,9 @@ export default {
124
120
  } else {
125
121
  currentModelValue.value = props.modelValue
126
122
  }
127
- // 权限路由路径
128
- fullPath = $power.routeFullPath
129
123
 
130
124
  } else {
131
125
  currentModelValue = ref(props.modelValue)
132
- // 当前路由路径
133
- fullPath = useRoute().fullPath
134
126
  }
135
127
 
136
128
  // 创建防抖睡眠方法
@@ -167,7 +159,7 @@ export default {
167
159
  } else if (props.drag && props.cache) {
168
160
 
169
161
  // 设置缓存名
170
- cacheName = `drawer_${props.side}_${props.cache === true ? fullPath : props.cache}`
162
+ cacheName = `drawer:${props.side}:${props.cache === true ? ($power && $power.routePath ? $power.routePath : utils.router.getRoute('path')) : props.cache}`
171
163
 
172
164
  // 从缓存获取宽度
173
165
  const cache = utils.storage.get(cacheName)
@@ -249,7 +241,7 @@ export default {
249
241
  currentWidth.value = newWidth
250
242
 
251
243
  // 如果开启缓存
252
- if (props.cache) {
244
+ if (props.drag && props.cache && cacheName) {
253
245
 
254
246
  // 延迟执行
255
247
  sleep(500)
@@ -3,6 +3,7 @@
3
3
  <q-field
4
4
  class="n-field-table"
5
5
  :model-value="showValue"
6
+ :disable="disable"
6
7
  :readonly="readonly"
7
8
  :clearable="clearable && (! multiple || collapseTags)"
8
9
  @focus="onFieldFocus"
@@ -37,7 +38,7 @@
37
38
  :key="`options-${index}`"
38
39
  :label="currentFormatLabel(item)"
39
40
  dense
40
- removable
41
+ :removable="! readonly && ! disable"
41
42
  @remove="onRemoveSelected(index)"
42
43
  />
43
44
  </template>
@@ -58,13 +59,13 @@
58
59
  ref="inputRef"
59
60
  class="q-field__input q-placeholder col q-field__input--padding"
60
61
  v-model="inputValue"
61
- v-if="filter"
62
+ v-if="filter && ! readonly && ! disable"
62
63
  />
63
64
 
64
65
  </template>
65
66
 
66
67
  <!-- 弹出对话框图标 -->
67
- <template v-slot:append v-if="! noDialog">
68
+ <template v-slot:append v-if="! noDialog && ! readonly && ! disable">
68
69
  <q-icon
69
70
  class="cursor-pointer"
70
71
  name="search"
@@ -85,8 +86,7 @@
85
86
  >
86
87
  <!-- 快捷表格 -->
87
88
  <q-table
88
- class="n-table"
89
- style="min-width:500px;max-width:90vw;height: 300px;"
89
+ class="n-table n-field-table__popup-table"
90
90
  v-model:pagination="tablePagination"
91
91
  v-model:selected="selected"
92
92
  :row-key="tableRowKey"
@@ -160,7 +160,6 @@
160
160
 
161
161
  <script>
162
162
  import { ref, computed, watch, onMounted, onUpdated } from 'vue'
163
- import { NRenderKey } from '../../utils/symbols'
164
163
 
165
164
  export default {
166
165
 
@@ -224,6 +223,8 @@ export default {
224
223
  placeholder: String,
225
224
  // 是否可清除
226
225
  clearable: Boolean,
226
+ // 是否禁用
227
+ disable: Boolean,
227
228
  // 是否只读
228
229
  readonly: Boolean,
229
230
  // 输入防抖(毫秒)
@@ -506,7 +507,7 @@ export default {
506
507
  n_search[currentFilterKey.value] = [
507
508
  {
508
509
  // 比较类型
509
- type: dicts.SEARCH_TYPE__LIKE,
510
+ compare: dicts.SEARCH_COMPARE_TYPE__LIKE,
510
511
  // 值
511
512
  value: val || '',
512
513
  }
@@ -1073,4 +1074,15 @@ export default {
1073
1074
  cursor: text;
1074
1075
  }
1075
1076
  }
1077
+
1078
+ /**
1079
+ * 桌面
1080
+ */
1081
+ body.desktop {
1082
+ .n-field-table {
1083
+ &__popup-table {
1084
+ height: 300px;
1085
+ }
1086
+ }
1087
+ }
1076
1088
  </style>
@@ -32,8 +32,12 @@ export default {
32
32
  modelValue: {
33
33
  required: false,
34
34
  },
35
- // 格式化值
36
- format: [Function, String],
35
+ // 值是否为数组
36
+ valueArray: Boolean,
37
+ // 修改前值
38
+ formatBefore: [Function, Object, Boolean],
39
+ // 修改后值
40
+ formatAfter: [Function, Object, Boolean],
37
41
  },
38
42
 
39
43
  /**
@@ -61,7 +65,7 @@ export default {
61
65
  // ==========【数据】============================================================================================
62
66
 
63
67
  // 当前值
64
- const currentValue = ref(props.modelValue)
68
+ const currentValue = ref(formatModelValue(props.modelValue))
65
69
 
66
70
  // ==========【监听数据】=========================================================================================
67
71
 
@@ -69,11 +73,143 @@ export default {
69
73
  * 监听声明值
70
74
  */
71
75
  watch(()=>props.modelValue, function (val) {
72
- currentValue.value = val
76
+ currentValue.value = formatModelValue(val)
73
77
  })
74
78
 
75
79
  // ==========【方法】=============================================================================================
76
80
 
81
+ /**
82
+ * 格式化声明值
83
+ */
84
+ function formatModelValue(val) {
85
+
86
+ if (props.formatBefore) {
87
+
88
+ // 如果是方法
89
+ if (_.isFunction(props.formatBefore)) {
90
+ return props.formatBefore(val)
91
+ }
92
+
93
+ // 如果是参数
94
+ if (props.formatBefore === true || utils.isValidObject(props.formatBefore)) {
95
+
96
+ // 如果值是数组
97
+ if (Array.isArray(val)) {
98
+
99
+ // 格式化数组值
100
+ return formatArrayValue(val, props.formatBefore === true ? {} : props.formatBefore)
101
+ }
102
+
103
+ // 如果是有效值
104
+ if (utils.isValidValue(val)) {
105
+
106
+ // 格式化字符串值
107
+ return formatStringValue(val, props.formatBefore === true ? {} : props.formatBefore, false)
108
+ }
109
+
110
+ return ''
111
+ }
112
+ }
113
+
114
+ return val
115
+ }
116
+
117
+ /**
118
+ * 格式化数组值
119
+ */
120
+ function formatArrayValue(val, params) {
121
+
122
+ // 如果数组有值
123
+ if (val.length) {
124
+
125
+ const o = Object.assign({
126
+ // 是否去重
127
+ unique: true,
128
+ // 分隔符
129
+ separator: ',',
130
+ // 是否给每个值去除首位空格
131
+ trim: true,
132
+ // 验证每个值是否为有效字符串/数字
133
+ isValidValue: true,
134
+ }, params)
135
+
136
+ // 是否给每个值去除首位空格
137
+ if (o.trim) {
138
+ val = val.map(e => utils.trimString(e))
139
+ }
140
+
141
+ // 是否验证每个值是否为有效字符串/数字
142
+ if (o.isValidValue) {
143
+ val = val.filter(val => utils.isValidValue(val))
144
+ }
145
+
146
+ // 去重
147
+ if (o.unique) {
148
+ val = _.uniq(val)
149
+ }
150
+
151
+ // 合并为字符串
152
+ return val.join(o.separator)
153
+ }
154
+
155
+ return ''
156
+ }
157
+
158
+ /**
159
+ * 格式化字符串值
160
+ */
161
+ function formatStringValue(val, params, valueArray) {
162
+
163
+ console.log(val, params, valueArray)
164
+
165
+ const o = Object.assign({
166
+ // 替换内容
167
+ replace: /\n|\,|\s+/g,
168
+ // 是否去重
169
+ unique: true,
170
+ // 分隔符
171
+ separator: ',',
172
+ // 验证每个值是否为有效字符串/数字
173
+ isValidValue: true,
174
+ }, params)
175
+
176
+ // 去除首位空格
177
+ val = utils.trimString(val)
178
+
179
+ // 如果有分割符
180
+ if (utils.isValidValue(o.separator, true)) {
181
+
182
+ o.separator = String(o.separator)
183
+
184
+ // 是否替换
185
+ if (o.replace) {
186
+ val = val.replace(o.replace, o.separator)
187
+ }
188
+
189
+ // 分隔成数组
190
+ val = utils.split(val, o.separator)
191
+
192
+ // 去重
193
+ if (o.unique) {
194
+ val = _.uniq(val)
195
+ }
196
+
197
+ // 如果验证每个值是否为有效字符串/数字
198
+ if (o.isValidValue) {
199
+ val = val.filter(val => utils.isValidValue(val))
200
+ }
201
+
202
+ // 如果值不是数组
203
+ if (! valueArray) {
204
+ val = val.join(o.separator)
205
+ }
206
+
207
+ return val
208
+ }
209
+
210
+ return valueArray ? [ val ] : ''
211
+ }
212
+
77
213
  /**
78
214
  * 失去焦点触发
79
215
  */
@@ -81,11 +217,19 @@ export default {
81
217
 
82
218
  let val = currentValue.value
83
219
 
84
- if (
85
- props.format
86
- && _.isFunction(props.format)
87
- ) {
88
- val = props.format(val)
220
+ // 如果修改值
221
+ if (props.formatAfter) {
222
+
223
+ // 如果是方法
224
+ if (_.isFunction(props.formatAfter)) {
225
+ val = props.formatAfter(val)
226
+
227
+ // 如果是参数
228
+ } else if (props.formatAfter === true || utils.isValidObject(props.formatAfter)) {
229
+
230
+ // 格式化字符串值
231
+ val = formatStringValue(val, props.formatAfter === true ? {} : props.formatAfter, props.valueArray)
232
+ }
89
233
  }
90
234
 
91
235
  // 更新值
@@ -7,8 +7,9 @@
7
7
  <!-- 比较类型1 -->
8
8
  <q-select
9
9
  class="n-field-group__select"
10
- v-model="modelValue[0].type"
11
- :options="compareOptions1"
10
+ v-model="modelValue[0].compare"
11
+ :options="data.compareOptions1"
12
+ :disable="data.compareOptions1.length === 1"
12
13
  map-options
13
14
  emit-value
14
15
  outlined
@@ -23,14 +24,14 @@
23
24
  dense
24
25
  outlined
25
26
  disable
26
- v-if="data.type === 'date' && modelValue[0].type >= 20"
27
+ v-if="data.type === 'date' && modelValue[0].compare >= 20"
27
28
  />
28
29
 
29
30
  <!-- 多选(类型为 in / not in)-->
30
31
  <slot
31
32
  :label="data.label"
32
33
  :index="0"
33
- :multiple="utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], modelValue[0].type) > -1"
34
+ :multiple="utils.indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], modelValue[0].compare) > -1"
34
35
  v-else
35
36
  />
36
37
  </div>
@@ -38,16 +39,14 @@
38
39
  <!-- 比较2(类型为 > / >=) -->
39
40
  <div
40
41
  class="n-field-group row"
41
- v-if="utils.indexOf([dicts.SEARCH_TYPE__GT, dicts.SEARCH_TYPE__GTE], modelValue[0].type) > -1"
42
+ v-if="data.compareOptions2.length"
42
43
  >
43
44
  <!-- 比较类型2 -->
44
45
  <q-select
45
46
  class="n-field-group__select"
46
- v-model="modelValue[1].type"
47
- :options="[
48
- { label: '<', value: dicts.SEARCH_TYPE__LT },
49
- { label: '≤', value: dicts.SEARCH_TYPE__LTE },
50
- ]"
47
+ v-model="modelValue[1].compare"
48
+ :options="data.compareOptions2"
49
+ :disable="data.compareOptions2.length === 1"
51
50
  map-options
52
51
  emit-value
53
52
  outlined
@@ -65,8 +64,7 @@
65
64
  </template>
66
65
 
67
66
  <script>
68
- import { computed, watch } from 'vue'
69
- import { quickRange } from '../field-date/methods'
67
+ import { watch } from 'vue'
70
68
 
71
69
  export default {
72
70
 
@@ -97,73 +95,14 @@ export default {
97
95
  */
98
96
  setup(props, { emit }) {
99
97
 
100
- // ==========【计算属性】=========================================================================================
101
-
102
- /**
103
- * 比较下拉列表1
104
- * 1: =
105
- * 2: !=
106
- * 3: >
107
- * 4: >=
108
- * 5: <
109
- * 6: <=
110
- * 7: LIKE
111
- * 8: NOT LIKE
112
- * 9: IN
113
- * 10: NOT IN
114
- */
115
- const compareOptions1 = computed(function () {
116
-
117
- // 如果类型为 文字
118
- // --------------------------------------------------
119
- if (props.data.type === 'text') {
120
-
121
- // 相同 不同 包含 不含
122
- return [
123
- { label: '相同', value: dicts.SEARCH_TYPE__EQUAL },
124
- { label: '不同', value: dicts.SEARCH_TYPE__NOT_EQUAL },
125
- { label: '包含', value: dicts.SEARCH_TYPE__LIKE },
126
- { label: '不含', value: dicts.SEARCH_TYPE__NOT_LIKE },
127
- { label: 'IN', value: dicts.SEARCH_TYPE__IN },
128
- { label: 'NOT IN', value: dicts.SEARCH_TYPE__NOT_IN },
129
- ]
130
- }
131
-
132
- // 否则为数字
133
- // --------------------------------------------------
134
- const opts = [
135
- { label: '=', value: dicts.SEARCH_TYPE__EQUAL },
136
- { label: '!=', value: dicts.SEARCH_TYPE__NOT_EQUAL },
137
- { label: '>', value: dicts.SEARCH_TYPE__GT },
138
- { label: '≥', value: dicts.SEARCH_TYPE__GTE },
139
- ]
140
-
141
- // 如果类型为日期
142
- if (props.data.type === 'date') {
143
- // 添加日期快捷选项
144
- utils.forEach(quickRange, function(label, key) {
145
- opts.push({ label, value: key + 20 })
146
- })
147
-
148
- // 否则类型为 数字
149
- } else {
150
- opts.push(
151
- { label: 'IN', value: dicts.SEARCH_TYPE__IN },
152
- { label: 'NOT IN', value: dicts.SEARCH_TYPE__NOT_IN },
153
- )
154
- }
155
-
156
- return opts
157
- })
158
-
159
98
  // ==========【监听数据】=========================================================================================
160
99
 
161
100
  /**
162
- * 监听声明值
101
+ * 监听值的比较类型
163
102
  */
164
- watch(()=>props.modelValue[0].type, function(val) {
103
+ watch(()=>props.modelValue[0].compare, function(val) {
165
104
  // 如果类型不为 in / not in, 为单选
166
- if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], val) === -1) {
105
+ if (utils.indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], val) === -1) {
167
106
  const arr = utils.split(props.modelValue[0].value, ',')
168
107
  if (arr.length !== 1) {
169
108
  // 克隆值
@@ -175,13 +114,6 @@ export default {
175
114
  }
176
115
  }
177
116
  })
178
-
179
- // ==========【返回】=============================================================================================
180
-
181
- return {
182
- // 比较下拉列表1
183
- compareOptions1,
184
- }
185
117
  },
186
118
  }
187
119
  </script>
@@ -120,9 +120,6 @@ export default {
120
120
  // 获取权限注入
121
121
  const $power = inject(NPowerKey)
122
122
 
123
- // 当前路由完整路径
124
- const fullPath = $power ? $power.routeFullPath : utils.router.getRoute('fullPath')
125
-
126
123
  // 缓存名
127
124
  let cacheName = ''
128
125
 
@@ -131,8 +128,9 @@ export default {
131
128
 
132
129
  // 如果开启缓存
133
130
  if (props.cache) {
131
+
134
132
  // 设置缓存名
135
- cacheName = `splitter_value_${props.cache === true ? fullPath : props.cache}`
133
+ cacheName = `splitter:value:${props.cache === true ? ($power && $power.routePath ? $power.routePath : utils.router.getRoute('path')) : props.cache}`
136
134
 
137
135
  // 从缓存获取初始值
138
136
  const cache = utils.storage.get(cacheName)
@@ -81,6 +81,7 @@
81
81
  :columns="tableColumns"
82
82
  :visible-columns="tableVisibleColumns"
83
83
  :selection="tableSelection"
84
+ :separator="tableSeparator"
84
85
  :loading="tableLoading"
85
86
  :rows-per-page-options="tableRowsPerPageOptions"
86
87
  :grid="tableGrid"
@@ -268,7 +269,7 @@ export default {
268
269
  // 对话框中的表格双击表格行
269
270
  currentTableRowDblclick = function (e, row) {
270
271
  // 如果不是多选
271
- if ($table.tableSelection !== 'multiple') {
272
+ if ($table.tableSelection.value !== 'multiple') {
272
273
  $table.tableSelected.value = [ row ]
273
274
  $dialog.confirm()
274
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/$power.js CHANGED
@@ -55,6 +55,9 @@ function create(params) {
55
55
  }
56
56
  }
57
57
 
58
+ // 获取当前路由
59
+ const $currentRoute = utils.router.getRoute()
60
+
58
61
  // 权限路由
59
62
  let $route
60
63
 
@@ -85,7 +88,7 @@ function create(params) {
85
88
 
86
89
  // 否则获取当前路由
87
90
  } else {
88
- $route = utils.router.getRoute()
91
+ $route = $currentRoute
89
92
  }
90
93
 
91
94
  // quasar 对象
@@ -255,8 +258,10 @@ function create(params) {
255
258
  await request({
256
259
  // 按钮数据
257
260
  data,
258
- // 当前路由参数
261
+ // 权限路由参数
259
262
  $route,
263
+ // 当前路由参数
264
+ $currentRoute,
260
265
  // 表格选中数据
261
266
  tableSelected,
262
267
  // 表格实例
@@ -784,7 +789,10 @@ async function request(params) {
784
789
  }, params)
785
790
 
786
791
  const {
792
+ // 权限路由参数
787
793
  $route,
794
+ // 当前路由参数
795
+ $currentRoute,
788
796
  } = params
789
797
 
790
798
  o.query = $route.query
@@ -802,6 +810,9 @@ async function request(params) {
802
810
  return
803
811
  }
804
812
 
813
+ // 克隆 data
814
+ o.data = _.cloneDeep(o.data)
815
+
805
816
  // 判断 url
806
817
  o.data.url = _.toLower(utils.trimString(o.data.url))
807
818
  if (! o.data.url) {
@@ -844,7 +855,8 @@ async function request(params) {
844
855
 
845
856
  // 如果有增加来源页面参数
846
857
  if (_.get(o.data, 'addFromPageQuery') === true) {
847
- query.n_frompage = encodeURIComponent($route.fullPath)
858
+ // 来源页面是当前路由的完整路径
859
+ query.n_frompage = encodeURIComponent($currentRoute.fullPath)
848
860
  }
849
861
 
850
862
  utils.router.push({
@@ -953,10 +965,17 @@ async function request(params) {
953
965
  })
954
966
 
955
967
  // 返回结果数据
956
- const resultData = Object.assign({}, res, {
957
- params: o,
968
+ const resultData = Object.assign({
969
+ // 参数
970
+ options: o,
971
+ // 请求数据
958
972
  requestData,
959
- })
973
+ }, res)
974
+
975
+ // 请求后执行
976
+ if (await utils.runAsync(o.requestAfter)(resultData) === false) {
977
+ return
978
+ }
960
979
 
961
980
  // 如果请求成功
962
981
  if (res.status) {
@@ -1025,8 +1044,7 @@ async function request(params) {
1025
1044
  }
1026
1045
 
1027
1046
  // 请求成功执行
1028
- const res = await utils.runAsync(o.requestSuccess)(Object.assign({ next }, resultData))
1029
- if (res === false) {
1047
+ if (await utils.runAsync(o.requestSuccess)(Object.assign({ next }, resultData)) === false) {
1030
1048
  return
1031
1049
  }
1032
1050
 
@@ -1037,9 +1055,6 @@ async function request(params) {
1037
1055
  // 请求失败执行
1038
1056
  utils.run(o.requestFail)(resultData)
1039
1057
  }
1040
-
1041
- // 请求后执行
1042
- utils.run(o.requestAfter)(resultData)
1043
1058
  }
1044
1059
  }
1045
1060
 
package/utils/$search.js CHANGED
@@ -1,18 +1,96 @@
1
1
  import { date as quasarDate } from 'quasar'
2
- import { getQuickRange } from '../components/field-date/methods'
2
+ import { getQuickRange, quickRange } from '../components/field-date/methods'
3
3
 
4
4
  /**
5
5
  * 比较类型默认值
6
6
  */
7
7
  const COMPARE_TYPE_MAPS = {
8
8
  // 数字
9
- number: [dicts.SEARCH_TYPE__EQUAL, dicts.SEARCH_TYPE__LT],
9
+ number: dicts.SEARCH_COMPARE_TYPE__EQUAL,
10
10
  // 文字
11
- text: [dicts.SEARCH_TYPE__LIKE, dicts.SEARCH_TYPE__LT],
11
+ text: dicts.SEARCH_COMPARE_TYPE__LIKE,
12
12
  // 价格
13
- price: [dicts.SEARCH_TYPE__EQUAL, dicts.SEARCH_TYPE__LT],
13
+ price: dicts.SEARCH_COMPARE_TYPE__EQUAL,
14
14
  // 日期
15
- date: [dicts.SEARCH_TYPE__GTE, dicts.SEARCH_TYPE__LTE],
15
+ date: dicts.SEARCH_COMPARE_TYPE__EQUAL,
16
+ }
17
+
18
+ /**
19
+ * 设置单个比较条件
20
+ */
21
+ function setItemCompare(item) {
22
+
23
+ // 初始比较条件数组
24
+ let opts1 = item.type === 'text'
25
+ // 如果类型为 文字
26
+ ? [
27
+ { label: '相同', value: dicts.SEARCH_COMPARE_TYPE__EQUAL },
28
+ { label: '不同', value: dicts.SEARCH_COMPARE_TYPE__NOT_EQUAL },
29
+ { label: '包含', value: dicts.SEARCH_COMPARE_TYPE__LIKE },
30
+ { label: '不含', value: dicts.SEARCH_COMPARE_TYPE__NOT_LIKE },
31
+ ]
32
+ // 否则为数字
33
+ : [
34
+ { label: '=', value: dicts.SEARCH_COMPARE_TYPE__EQUAL },
35
+ { label: '!=', value: dicts.SEARCH_COMPARE_TYPE__NOT_EQUAL },
36
+ { label: '>', value: dicts.SEARCH_COMPARE_TYPE__GT },
37
+ { label: '≥', value: dicts.SEARCH_COMPARE_TYPE__GTE },
38
+ ]
39
+
40
+ // 如果类型为日期
41
+ if (item.type === 'date') {
42
+ // 添加日期快捷选项
43
+ utils.forEach(quickRange, function(label, key) {
44
+ opts1.push({ label, value: key + 20 })
45
+ })
46
+
47
+ // 否则为其他
48
+ } else {
49
+ opts1.push(
50
+ { label: 'IN', value: dicts.SEARCH_COMPARE_TYPE__IN },
51
+ { label: 'NOT IN', value: dicts.SEARCH_COMPARE_TYPE__NOT_IN },
52
+ )
53
+ }
54
+
55
+ // 如果有比较类型
56
+ if (
57
+ _.has(item, 'compare')
58
+ && utils.isValidArray(item.compare)
59
+ ) {
60
+ const {
61
+ compare,
62
+ compareIgnore
63
+ } = item
64
+
65
+ // 如果有筛选比较条件
66
+ // 筛选比较条件
67
+ opts1 = opts1.filter(
68
+ compareIgnore === true
69
+ // 如果为忽略比较条件
70
+ ? e => compare.indexOf(e.value) === -1
71
+ // 否则为限制比较条件
72
+ : e => compare.indexOf(e.value) > -1
73
+ )
74
+ }
75
+
76
+ // 如果没有比较选项, 则设置相同为默认
77
+ if (! opts1.length) {
78
+ opts1.push({ label: type === 'text' ? '相同' : '=', value: dicts.SEARCH_COMPARE_TYPE__EQUAL })
79
+ }
80
+
81
+ // 值1 比较类型条件
82
+ item.compareOptions1 = opts1
83
+ // 值2 比较类型条件
84
+ item.compareOptions2 = []
85
+
86
+ // 如果比较类型有 >
87
+ if (_.findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GT }) > -1) {
88
+ item.compareOptions2.push({ label: '<', value: dicts.SEARCH_COMPARE_TYPE__LT })
89
+
90
+ // 如果比较类型有 >=
91
+ } else if (_.findIndex(opts1, { value: dicts.SEARCH_COMPARE_TYPE__GTE }) > -1) {
92
+ item.compareOptions2.push({ label: '≤', value: dicts.SEARCH_COMPARE_TYPE__LTE })
93
+ }
16
94
  }
17
95
 
18
96
  /**
@@ -23,26 +101,61 @@ export function setItemValue(value, val) {
23
101
  // 如果值为数组
24
102
  if (Array.isArray(val)) {
25
103
  // 比较类型为 in
26
- value[0].type = dicts.SEARCH_TYPE__IN
104
+ value[0].compare = dicts.SEARCH_COMPARE_TYPE__IN
27
105
  // 设置值为将数组转为逗号分隔的字符串
28
106
  value[0].value = utils.join(val, ',')
29
107
 
30
108
  // 如果值是逗号隔开
31
109
  } else if (utils.split(val, ',').length > 1) {
32
110
  // 比较类型为 in
33
- value[0].type = dicts.SEARCH_TYPE__IN
111
+ value[0].compare = dicts.SEARCH_COMPARE_TYPE__IN
34
112
  // 设置值为将数组转为逗号分隔的字符串
35
113
  value[0].value = val
36
114
 
37
115
  // 否则为单个值
38
116
  } else {
39
117
  // 比较类型为 ==
40
- value[0].type = dicts.SEARCH_TYPE__EQUAL
118
+ value[0].compare = dicts.SEARCH_COMPARE_TYPE__EQUAL
41
119
  // 设置值为当前值
42
120
  value[0].value = val
43
121
  }
44
122
  }
45
123
 
124
+ /**
125
+ * 格式化单个比较条件
126
+ */
127
+ function formatItemValueCompare(value, { compareOptions1 }) {
128
+
129
+ // 获取第一个值
130
+ const value1 = value[0]
131
+
132
+ // 如果值1 的比较条件不在值1 的限制范围内
133
+ if (_.findIndex(compareOptions1, { value: value1.compare }) === -1) {
134
+ // 则取比较条件中的第一个
135
+ value1.compare = compareOptions1[0].value
136
+ }
137
+
138
+ // 如果比较类型不为 in / not in
139
+ if (utils.indexOf([ dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN ], value1.compare) === -1) {
140
+ // 如果值中含有逗号
141
+ const arr = utils.split(value1.value, ',')
142
+ if (arr.length > 1) {
143
+ value1.value = arr[0]
144
+ }
145
+ }
146
+
147
+ // 如果值1 比较类型为 >
148
+ if (value1.compare === dicts.SEARCH_COMPARE_TYPE__GT) {
149
+ // 则修改值2 类型为 <
150
+ value[1].compare = dicts.SEARCH_COMPARE_TYPE__LT
151
+
152
+ // 如果值1 比较类型为 >=
153
+ } else if (value1.compare === dicts.SEARCH_COMPARE_TYPE__GTE) {
154
+ // 则修改值2 类型为 <=
155
+ value[1].compare = dicts.SEARCH_COMPARE_TYPE__LTE
156
+ }
157
+ }
158
+
46
159
  /**
47
160
  * 从表格列获取原始值
48
161
  */
@@ -80,6 +193,9 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
80
193
  newItem.dict = item.dict
81
194
  }
82
195
 
196
+ // 设置单个比较条件
197
+ setItemCompare(newItem)
198
+
83
199
  // 原始表格搜索参数
84
200
  rawSearchOptions.push(newItem)
85
201
 
@@ -90,21 +206,21 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
90
206
  // 值1
91
207
  {
92
208
  // 比较类型
93
- type: COMPARE_TYPE_MAPS[item.search.type][0],
209
+ compare: COMPARE_TYPE_MAPS[newItem.type],
94
210
  // 值
95
211
  value: '',
96
212
  },
97
213
  // 值2
98
214
  {
99
215
  // 比较类型
100
- type: COMPARE_TYPE_MAPS[item.search.type][1],
216
+ compare: dicts.SEARCH_COMPARE_TYPE__LT,
101
217
  // 值
102
218
  value: '',
103
219
  },
104
220
  ]
105
221
 
106
222
  // 如果是日期
107
- if (item.search.type === 'date') {
223
+ if (newItem.type === 'date') {
108
224
  // 设置日期类型
109
225
  value[0].dateType = 'day'
110
226
  }
@@ -128,10 +244,16 @@ function getRawData(tableColumns, query, searchFromQuery = true) {
128
244
  searchQueryKey.push(newItem.name)
129
245
 
130
246
  // 否则, 如果表格参数中有设置初始值
131
- } else if (_.has(item, 'search.value') && utils.isValidArray(item.search.value)) {
132
- value = _.merge([], value, item.search.value)
247
+ } else if (
248
+ _.has(newItem, 'value')
249
+ && utils.isValidArray(newItem.value)
250
+ ) {
251
+ value = _.merge([], value, newItem.value)
133
252
  }
134
253
 
254
+ // 格式化单个值的比较条件
255
+ formatItemValueCompare(value, newItem)
256
+
135
257
  // 首次初始表格搜索值
136
258
  firstTableSearchValue.push(value)
137
259
  }
@@ -257,7 +379,7 @@ function formatValue(rawSearchOptions, searchValue) {
257
379
  if (utils.isValidValue(value1.value)) {
258
380
 
259
381
  // 如果值1 类型为 in / not in
260
- if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], value1.type) > -1) {
382
+ if (utils.indexOf([dicts.SEARCH_COMPARE_TYPE__IN, dicts.SEARCH_COMPARE_TYPE__NOT_IN], value1.compare) > -1) {
261
383
  const vals = []
262
384
  utils.forEach(utils.split(utils.trimString(value1.value).replaceAll(',', ','), ','), function (item) {
263
385
  item = utils.numberDeep(item)
@@ -268,7 +390,7 @@ function formatValue(rawSearchOptions, searchValue) {
268
390
  if (vals.length) {
269
391
  lists.push({
270
392
  field: name,
271
- type: value1.type,
393
+ compare: value1.compare,
272
394
  value: vals,
273
395
  })
274
396
  }
@@ -278,7 +400,7 @@ function formatValue(rawSearchOptions, searchValue) {
278
400
  // 否则添加值1
279
401
  lists.push({
280
402
  field: name,
281
- type: value1.type,
403
+ compare: value1.compare,
282
404
  value: utils.numberDeep(value1.value),
283
405
  })
284
406
  }
@@ -299,9 +421,9 @@ function formatValue(rawSearchOptions, searchValue) {
299
421
  // 如果是日期
300
422
  type === 'date'
301
423
  // 如果类型为快捷日期
302
- && value1.type >= 20
424
+ && value1.compare >= 20
303
425
  ) {
304
- const res = getQuickRange(value1.type - 20, true)
426
+ const res = getQuickRange(value1.compare - 20, true)
305
427
  if (res) {
306
428
 
307
429
  lists.push(
@@ -309,14 +431,14 @@ function formatValue(rawSearchOptions, searchValue) {
309
431
  {
310
432
  field: name,
311
433
  // ≥
312
- type: dicts.SEARCH_TYPE__GTE,
434
+ compare: dicts.SEARCH_COMPARE_TYPE__GTE,
313
435
  value: utils.numberDeep(quasarDate.formatDate(utils.toDate(`${res.date.from} ${res.time.from}`), 'X')),
314
436
  },
315
437
  // 日期止
316
438
  {
317
439
  field: name,
318
440
  // ≤
319
- type: dicts.SEARCH_TYPE__LTE,
441
+ compare: dicts.SEARCH_COMPARE_TYPE__LTE,
320
442
  value: utils.numberDeep(quasarDate.formatDate(utils.toDate(`${res.date.to} ${res.time.to}`), 'X')),
321
443
  }
322
444
  )
@@ -328,12 +450,12 @@ function formatValue(rawSearchOptions, searchValue) {
328
450
  addValue1(value1)
329
451
 
330
452
  // 只有值1 类型为 > / ≥ 值2才有效
331
- if (utils.indexOf([dicts.SEARCH_TYPE__GT, dicts.SEARCH_TYPE__GTE], value1.type) > -1) {
453
+ if (utils.indexOf([dicts.SEARCH_COMPARE_TYPE__GT, dicts.SEARCH_COMPARE_TYPE__GTE], value1.compare) > -1) {
332
454
  const value2 = searchValue[itemIndex][1]
333
455
  if (utils.isValidValue(value2.value)) {
334
456
  lists.push({
335
457
  field: name,
336
- type: value2.type,
458
+ compare: value2.compare,
337
459
  value: utils.numberDeep(value2.value),
338
460
  })
339
461
  }
package/utils/$table.js CHANGED
@@ -37,6 +37,8 @@ function create(params) {
37
37
  rowKey: 'id',
38
38
  // 选择类型, 可选值 single multiple none
39
39
  selection: 'multiple',
40
+ // 分隔栏, 可选值 horizontal vertical cell none
41
+ separator: 'cell',
40
42
  // 已选数据
41
43
  selected: [],
42
44
  // 表格加载状态
@@ -198,7 +200,7 @@ function create(params) {
198
200
  })
199
201
 
200
202
  // 获取可见列缓存
201
- const visibleColumnsCache = o.showVisibleColumns && isCache ? utils.storage.get('table_visible_columns_' + cacheName) : []
203
+ const visibleColumnsCache = o.showVisibleColumns && isCache ? utils.storage.get('table:visible_columns:' + cacheName) : []
202
204
 
203
205
  // 表格可见列
204
206
  const tableVisibleColumns = ref(Array.isArray(visibleColumnsCache) ? visibleColumnsCache : _.uniq([...o.visibleColumns]))
@@ -213,7 +215,7 @@ function create(params) {
213
215
  const tablePagination = ref($route.fullPath ? o.pagination : {})
214
216
 
215
217
  // 表格宫格
216
- const tableGrid = ref(o.showGrid && isCache ? utils.storage.get('table_grid_' + cacheName) === true : false)
218
+ const tableGrid = ref(o.showGrid && isCache ? utils.storage.get('table:grid:' + cacheName) === true : false)
217
219
 
218
220
  // 表格传参
219
221
  const tableQuery = ref({})
@@ -227,6 +229,12 @@ function create(params) {
227
229
  // 表格合计
228
230
  const tableSummary = ref(null)
229
231
 
232
+ // 表格选择类型
233
+ const tableSelection = ref(o.selection)
234
+
235
+ // 表格分隔栏
236
+ const tableSeparator = ref(o.separator)
237
+
230
238
  const {
231
239
  // 原始参数
232
240
  rawQuery,
@@ -304,7 +312,7 @@ function create(params) {
304
312
 
305
313
  // 设置宫格模式缓存(永久缓存)
306
314
  // #if ! IS_DEV
307
- utils.storage.set('table_grid_' + cacheName, val, 0)
315
+ utils.storage.set('table:grid:' + cacheName, val, 0)
308
316
  // #endif
309
317
  })
310
318
  }
@@ -317,7 +325,7 @@ function create(params) {
317
325
 
318
326
  // 设置可见列缓存(永久缓存)
319
327
  // #if ! IS_DEV
320
- utils.storage.set('table_visible_columns_' + cacheName, val, 0)
328
+ utils.storage.set('table:visible_columns:' + cacheName, val, 0)
321
329
  // #endif
322
330
  })
323
331
  }
@@ -402,11 +410,11 @@ function create(params) {
402
410
  if (hasNSearch && _.has(query.n_search, item.name)) {
403
411
  const newSearchItem = query.n_search[item.name]
404
412
  if (utils.isValidArray(newSearchItem)) {
405
- valueItem[0].type = newSearchItem[0].type
413
+ valueItem[0].compare = newSearchItem[0].compare
406
414
  valueItem[0].value = newSearchItem[0].value
407
415
 
408
416
  if (newSearchItem.length > 1) {
409
- valueItem[1].type = newSearchItem[1].type
417
+ valueItem[1].compare = newSearchItem[1].compare
410
418
  valueItem[1].value = newSearchItem[1].value
411
419
  }
412
420
  }
@@ -750,7 +758,7 @@ function create(params) {
750
758
  function _tableRowClick(e, row) {
751
759
 
752
760
  // 如果选择类型为无
753
- if (o.selection === 'none') {
761
+ if (tableSelection.value === 'none') {
754
762
  // 则无任何操作
755
763
  return
756
764
  }
@@ -765,7 +773,7 @@ function create(params) {
765
773
  if (itemIndex === -1) {
766
774
 
767
775
  // 如果选择类型为单选
768
- if (o.selection === 'single') {
776
+ if (tableSelection.value === 'single') {
769
777
  tableSelected.value = [ row ]
770
778
 
771
779
  // 否则为多选
@@ -795,7 +803,7 @@ function create(params) {
795
803
  function _tableRowDblclick(e, row) {
796
804
 
797
805
  // 如果选择类型为无
798
- if (o.selection === 'none') {
806
+ if (tableSelection.value === 'none') {
799
807
  // 则无任何操作
800
808
  return
801
809
  }
@@ -860,7 +868,9 @@ function create(params) {
860
868
  // 表格 id key
861
869
  tableRowKey: o.rowKey,
862
870
  // 表格选择类型
863
- tableSelection: o.selection,
871
+ tableSelection,
872
+ // 表格分隔栏
873
+ tableSeparator,
864
874
  // 表格每页显示行数选项
865
875
  tableRowsPerPageOptions: rowsPerPageOptions,
866
876
  // 表格列数据(对象数组)
package/utils/$tree.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isRef, watch } from 'vue'
2
+
2
3
  import { NPowerKey } from './symbols'
3
4
 
4
5
  /**
@@ -280,8 +281,8 @@ function create(params) {
280
281
  utils.$dialog.create({
281
282
  // 标题
282
283
  title: `移动至节点的${o.type === 'moveUp' ? '上方' : (o.type === 'moveDown' ? '下方' : '内部')}`,
284
+ // 宽度
283
285
  width: 500,
284
- minWidth: 500,
285
286
  // 组件标识
286
287
  name: 'moveToTree',
287
288
  // 组件参数
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
+ }