@netang/quasar 0.0.32 → 0.0.34

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.
@@ -54,7 +54,7 @@ import { useDialogPluginComponent, useQuasar } from 'quasar'
54
54
 
55
55
  import routers from '@/router/routers'
56
56
 
57
- import components from './components'
57
+ import components from '../private/components'
58
58
  import { NDialogKey } from '../../utils/symbols'
59
59
 
60
60
  export default {
@@ -109,7 +109,7 @@ export default {
109
109
  const $q = useQuasar()
110
110
 
111
111
  // 获取当前路由
112
- const $route = useRoute()
112
+ let fullPath = ''
113
113
 
114
114
  // 获取权限注入数据
115
115
  const $power = inject(NPowerKey)
@@ -124,10 +124,18 @@ export default {
124
124
  } else {
125
125
  currentModelValue.value = props.modelValue
126
126
  }
127
+ // 权限路由路径
128
+ fullPath = $power.routeFullPath
129
+
127
130
  } else {
128
131
  currentModelValue = ref(props.modelValue)
132
+ // 当前路由路径
133
+ fullPath = useRoute().fullPath
129
134
  }
130
135
 
136
+ // 创建防抖睡眠方法
137
+ const sleep = utils.debounceSleep()
138
+
131
139
  // 缓存名
132
140
  let cacheName = ''
133
141
 
@@ -159,7 +167,7 @@ export default {
159
167
  } else if (props.drag && props.cache) {
160
168
 
161
169
  // 设置缓存名
162
- cacheName = `drawer_${props.side}_${props.cache === true ? $route.fullPath : props.cache}`
170
+ cacheName = `drawer_${props.side}_${props.cache === true ? fullPath : props.cache}`
163
171
 
164
172
  // 从缓存获取宽度
165
173
  const cache = utils.storage.get(cacheName)
@@ -237,14 +245,19 @@ export default {
237
245
  // }
238
246
  // }
239
247
 
248
+ // 设置当前宽度
249
+ currentWidth.value = newWidth
250
+
240
251
  // 如果开启缓存
241
252
  if (props.cache) {
242
- // 设置缓存(永久缓存)
243
- utils.storage.set(cacheName, newWidth, 0)
244
- }
245
253
 
246
- // 设置当前宽度
247
- currentWidth.value = newWidth
254
+ // 延迟执行
255
+ sleep(500)
256
+ .then(function () {
257
+ // 设置缓存(永久缓存)
258
+ utils.storage.set(cacheName, newWidth, 0)
259
+ })
260
+ }
248
261
  }
249
262
 
250
263
  // ==========【返回】=============================================================================================
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="q-pa-lg flex flex-center absolute-full">
3
- {{emptyDescription || '发生未知错误'}}
3
+ {{description || '发生未知错误'}}
4
4
  </div>
5
5
  </template>
6
6
 
@@ -17,7 +17,7 @@ export default {
17
17
  */
18
18
  props: {
19
19
  // 空状态描述
20
- emptyDescription: String,
20
+ description: String,
21
21
  },
22
22
  }
23
23
  </script>
@@ -160,6 +160,7 @@
160
160
 
161
161
  <script>
162
162
  import { ref, computed, watch, onMounted, onUpdated } from 'vue'
163
+ import { NRenderKey } from '../../utils/symbols'
163
164
 
164
165
  export default {
165
166
 
@@ -4,7 +4,7 @@
4
4
  >
5
5
  <!-- 空数据 -->
6
6
  <n-empty
7
- :empty-description="emptyDescription"
7
+ :description="emptyDescription"
8
8
  v-if="pageStatus === false"
9
9
  />
10
10
 
@@ -1,22 +1,30 @@
1
1
  <template>
2
- <slot
3
- :query="query"
4
- v-bind="props"
5
- v-if="$slots.default"
6
- />
7
- <component
8
- :is="comp"
9
- :query="query"
10
- v-bind="props"
11
- v-else
12
- />
2
+ <q-layout
3
+ class="absolute-full"
4
+ view="hHh lpr fFf"
5
+ container
6
+ >
7
+ <q-page-container>
8
+ <slot
9
+ :query="query"
10
+ v-bind="props"
11
+ v-if="$slots.default"
12
+ />
13
+ <component
14
+ :is="comp"
15
+ :query="query"
16
+ v-bind="props"
17
+ v-else
18
+ />
19
+ </q-page-container>
20
+ </q-layout>
13
21
  </template>
14
22
 
15
23
  <script>
16
24
  import { computed, defineAsyncComponent, provide } from 'vue'
17
25
 
18
26
  import routers from '@/router/routers'
19
- import components from './components'
27
+ import components from '../private/components'
20
28
 
21
29
  import { NRenderKey } from '../../utils/symbols'
22
30
 
@@ -83,17 +91,39 @@ export default {
83
91
 
84
92
  // ==========【注入】============================================================================================
85
93
 
86
- // 向后代注入数据
87
- provide(NRenderKey, {
94
+ // 注入数据
95
+ const data = {
88
96
  // 组件标识
89
97
  name: props.name,
90
- // 路由路径
91
- path: utils.isValidString(props.path) ? utils.slash(props.path, 'start', true) : '',
92
98
  // 参数
93
99
  query: utils.isValidObject(props.query) ? props.query : {},
94
100
  // 组件传参
95
101
  props: props.props,
96
- })
102
+ }
103
+
104
+ // 如果有路由路径
105
+ if (utils.isValidString(props.path)) {
106
+
107
+ // 获取页面路由
108
+ const $route = utils.router.resolve({
109
+ path: props.path,
110
+ query: data.query,
111
+ })
112
+
113
+ Object.assign(data, {
114
+ // 当前路由全路径
115
+ routeFullPath: $route.fullPath,
116
+ // 当前路由路径
117
+ routePath: $route.path,
118
+ // 当前路由参数
119
+ routeQuery: $route.query,
120
+ // 当前路由,
121
+ $route,
122
+ })
123
+ }
124
+
125
+ // 向后代注入数据
126
+ provide(NRenderKey, data)
97
127
 
98
128
  // ==========【返回】=============================================================================================
99
129
 
@@ -74,18 +74,6 @@
74
74
 
75
75
  <!-- 输入框 -->
76
76
  <template v-else-if="item.searchType === 'input'">
77
- <!-- 输入框 数字 -->
78
- <n-input-number
79
- class="n-field-fieldset"
80
- :label="label"
81
- v-model="modelValue[itemIndex][index].value"
82
- dense
83
- outlined
84
- clearable
85
- v-bind="item.input"
86
- v-if="item.type === 'number'"
87
- />
88
- <!-- 输入框 文字 -->
89
77
  <q-input
90
78
  class="n-field-fieldset"
91
79
  :label="label"
@@ -94,7 +82,6 @@
94
82
  outlined
95
83
  clearable
96
84
  v-bind="item.input"
97
- v-else
98
85
  />
99
86
  </template>
100
87
 
@@ -176,8 +163,6 @@
176
163
  </template>
177
164
 
178
165
  <script>
179
- import { computed } from 'vue'
180
-
181
166
  export default {
182
167
 
183
168
  /**
@@ -161,28 +161,20 @@ export default {
161
161
  /**
162
162
  * 监听声明值
163
163
  */
164
- if (utils.indexOf(['select', 'tree'], props.data.searchType) > -1) {
165
-
166
- watch(()=>props.modelValue[0].type, function(val) {
167
-
168
- const modelValue = _.cloneDeep(props.modelValue)
169
-
170
- // 如果类型为 in / not in, 则为多选
171
- if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], val) > -1) {
172
-
173
- // 如果值不为数组
174
- if (! Array.isArray(modelValue[0].value)) {
175
- modelValue[0].value = utils.isValidValue(modelValue[0].value) ? [modelValue[0].value] : []
176
- emit('update:modelValue', modelValue)
177
- }
178
-
179
- // 否则为单选, 并且如果值为数组
180
- } else if (Array.isArray(modelValue[0].value)) {
181
- modelValue[0].value = utils.isValidValue(modelValue[0].value[0]) ? modelValue[0].value[0] : ''
182
- emit('update:modelValue', modelValue)
164
+ watch(()=>props.modelValue[0].type, function(val) {
165
+ // 如果类型不为 in / not in, 为单选
166
+ if (utils.indexOf([dicts.SEARCH_TYPE__IN, dicts.SEARCH_TYPE__NOT_IN], val) === -1) {
167
+ const arr = utils.split(props.modelValue[0].value, ',')
168
+ if (arr.length !== 1) {
169
+ // 克隆值
170
+ const _modelValue = _.cloneDeep(props.modelValue)
171
+
172
+ // 更新值
173
+ _modelValue[0].value = arr.length > 1 ? arr[0] : ''
174
+ emit('update:modelValue', _modelValue)
183
175
  }
184
- })
185
- }
176
+ }
177
+ })
186
178
 
187
179
  // ==========【返回】=============================================================================================
188
180
 
@@ -1,9 +1,10 @@
1
1
  <template>
2
2
  <!-- 拆分器 -->
3
3
  <q-splitter
4
+ class="n-splitter"
5
+ :class="currentClass"
4
6
  v-model="currentValue"
5
7
  v-bind="$attrs"
6
- v-if="$slots.before && $slots.after"
7
8
  >
8
9
  <!-- 插槽 -->
9
10
  <template
@@ -13,23 +14,11 @@
13
14
  <slot :name="slotName" />
14
15
  </template>
15
16
  </q-splitter>
16
-
17
- <!-- before 插槽 -->
18
- <slot
19
- name="before"
20
- v-else-if="$slots.before"
21
- />
22
-
23
- <!-- after 插槽 -->
24
- <slot
25
- name="after"
26
- v-else-if="$slots.after"
27
- />
28
-
29
17
  </template>
30
18
 
31
19
  <script>
32
- import { computed, ref, watch } from 'vue'
20
+ import { computed, ref, watch, inject } from 'vue'
21
+ import { NPowerKey } from '../../utils/symbols'
33
22
 
34
23
  export default {
35
24
 
@@ -47,6 +36,21 @@ export default {
47
36
  type: Number,
48
37
  required: true,
49
38
  },
39
+ // 显示前置插槽
40
+ showBefore: {
41
+ type: Boolean,
42
+ default: true,
43
+ },
44
+ // 显示后置插槽
45
+ showAfter: {
46
+ type: Boolean,
47
+ default: true,
48
+ },
49
+ // 是否开启缓存
50
+ cache: {
51
+ type: [Boolean, String],
52
+ default: true,
53
+ },
50
54
  },
51
55
 
52
56
  /**
@@ -67,13 +71,81 @@ export default {
67
71
  * 插槽标识
68
72
  */
69
73
  const slotNames = computed(function() {
70
- return utils.isValidObject(slots) ? Object.keys(slots) : []
74
+
75
+ const keys = []
76
+
77
+ if (utils.isValidObject(slots)) {
78
+ for (const key in slots) {
79
+ if (key === 'before') {
80
+ if (props.showBefore) {
81
+ keys.push(key)
82
+ }
83
+
84
+ } else if (key === 'after') {
85
+ if (props.showAfter) {
86
+ keys.push(key)
87
+ }
88
+
89
+ } else {
90
+ keys.push(key)
91
+ }
92
+ }
93
+ }
94
+
95
+ return keys
96
+ })
97
+
98
+ /**
99
+ * 当前样式
100
+ */
101
+ const currentClass = computed(function () {
102
+
103
+ if (props.showBefore) {
104
+ if (! props.showAfter) {
105
+ return 'n-splitter--hide-before'
106
+ }
107
+
108
+ } else if (props.showAfter) {
109
+ if (! props.showBefore) {
110
+ return 'n-splitter--hide-after'
111
+ }
112
+
113
+ } else {
114
+ return 'n-splitter--hide'
115
+ }
71
116
  })
72
117
 
73
118
  // ==========【数据】============================================================================================
74
119
 
120
+ // 获取权限注入
121
+ const $power = inject(NPowerKey)
122
+
123
+ // 当前路由完整路径
124
+ const fullPath = $power ? $power.routeFullPath : utils.router.getRoute('fullPath')
125
+
126
+ // 缓存名
127
+ let cacheName = ''
128
+
129
+ // 初始值
130
+ let rawValue = props.modelValue
131
+
132
+ // 如果开启缓存
133
+ if (props.cache) {
134
+ // 设置缓存名
135
+ cacheName = `splitter_value_${props.cache === true ? fullPath : props.cache}`
136
+
137
+ // 从缓存获取初始值
138
+ const cache = utils.storage.get(cacheName)
139
+ if (cache) {
140
+ rawValue = cache
141
+ }
142
+ }
143
+
75
144
  // 当前值
76
- const currentValue = ref(props.modelValue)
145
+ const currentValue = ref(rawValue)
146
+
147
+ // 创建防抖睡眠方法
148
+ const sleep = utils.debounceSleep()
77
149
 
78
150
  // ==========【监听数据】=========================================================================================
79
151
 
@@ -81,10 +153,8 @@ export default {
81
153
  * 监听声明值
82
154
  */
83
155
  watch(()=>props.modelValue, function (val) {
84
-
85
156
  // 如果值有变化
86
157
  if (val !== currentValue.value) {
87
-
88
158
  // 更新当前值
89
159
  currentValue.value = val
90
160
  }
@@ -97,6 +167,17 @@ export default {
97
167
 
98
168
  // 更新值
99
169
  emit('update:modelValue', val)
170
+
171
+ // 如果开启缓存
172
+ if (props.cache) {
173
+
174
+ // 延迟执行
175
+ sleep(500)
176
+ .then(function () {
177
+ // 设置缓存(永久缓存)
178
+ utils.storage.set(cacheName, val, 0)
179
+ })
180
+ }
100
181
  })
101
182
 
102
183
  // ==========【返回】=============================================================================================
@@ -106,7 +187,68 @@ export default {
106
187
  slotNames,
107
188
  // 当前值
108
189
  currentValue,
190
+ // 当前样式
191
+ currentClass,
109
192
  }
110
193
  }
111
194
  }
112
195
  </script>
196
+
197
+ <style lang="scss">
198
+ @import "@/assets/sass/var.scss";
199
+
200
+ .n-splitter {
201
+
202
+ // 分离器激活背景色
203
+ &.q-splitter--active .q-splitter__separator ,
204
+ .q-splitter__separator:hover {
205
+ background-color: var(--q-primary);
206
+ }
207
+
208
+ // 隐藏前置插槽
209
+ &--hide-before {
210
+ &.q-splitter--horizontal {
211
+ .q-splitter__before {
212
+ height: 100% !important;
213
+ }
214
+ }
215
+ &.q-splitter--vertical {
216
+ .q-splitter__before {
217
+ width: 100% !important;
218
+ }
219
+ }
220
+ .q-splitter__after,
221
+ .q-splitter__separator {
222
+ display: none !important;
223
+ }
224
+ }
225
+
226
+ // 隐藏后置插槽
227
+ &--hide-after {
228
+ &.q-splitter--horizontal {
229
+ .q-splitter__after {
230
+ height: 100% !important;
231
+ }
232
+ }
233
+ &.q-splitter--vertical {
234
+ .q-splitter__after {
235
+ width: 100% !important;
236
+ }
237
+ }
238
+ .q-splitter__before,
239
+ .q-splitter__separator {
240
+ display: none !important;
241
+ }
242
+ }
243
+
244
+ // 隐藏前后置插槽
245
+ &--hide {
246
+ .q-splitter__before,
247
+ .q-splitter__after,
248
+ .q-splitter__separator {
249
+ display: none !important;
250
+ }
251
+ }
252
+ }
253
+ </style>
254
+
@@ -11,18 +11,28 @@
11
11
  <n-toolbar
12
12
  :dense="dense"
13
13
  header
14
- />
14
+ >
15
+ <!-- 插槽 -->
16
+ <template
17
+ v-for="slotName in slotNames.toolbar"
18
+ v-slot:[slotName]
19
+ >
20
+ <slot :name="`toolbar-${slotName}`"/>
21
+ </template>
22
+ </n-toolbar>
15
23
 
16
24
  <!-- 左侧分类 -->
25
+ <slot name="left-drawer" v-if="slotNames.leftDrawer" />
17
26
  <n-drawer
18
- :model-value="true"
27
+ :model-value="! hideLeftDrawer"
19
28
  :side="treeSide"
20
29
  :width="200"
21
30
  :min-width="150"
22
31
  bordered
23
32
  drag
24
33
  cache
25
- v-if="treeNodes.length"
34
+ v-bind="leftDrawerProps"
35
+ v-else-if="treeNodes.length"
26
36
  >
27
37
  <q-scroll-area class="absolute-full">
28
38
 
@@ -50,6 +60,7 @@
50
60
  v-model:selected="treeSelected"
51
61
  no-selection-unset
52
62
  default-expand-all
63
+ v-bind="treeProps"
53
64
  />
54
65
 
55
66
  </q-scroll-area>
@@ -79,6 +90,7 @@
79
90
  flat
80
91
  virtual-scroll
81
92
  :dense="dense"
93
+ v-bind="tableProps"
82
94
  >
83
95
  <!-- 图片 -->
84
96
  <template
@@ -96,7 +108,7 @@
96
108
 
97
109
  <!-- 插槽 -->
98
110
  <template
99
- v-for="slotName in slotNames"
111
+ v-for="slotName in slotNames.table"
100
112
  v-slot:[slotName]="props"
101
113
  >
102
114
  <q-td :props="props">
@@ -132,14 +144,16 @@
132
144
  </q-page-container>
133
145
 
134
146
  <!-- 右侧搜索 -->
147
+ <slot name="right-drawer" v-if="slotNames.rightDrawer" />
135
148
  <n-drawer
136
- :model-value="true"
149
+ :model-value="! hideRightDrawer"
137
150
  :side="searchSide"
138
151
  :min-width="320"
139
152
  bordered
140
153
  drag
141
154
  cache
142
- v-if="! noSearch && tableSearchValue.length"
155
+ v-bind="rightDrawerProps"
156
+ v-else-if="! noSearch && tableSearchValue.length"
143
157
  >
144
158
  <!-- 搜索 -->
145
159
  <n-search
@@ -147,8 +161,17 @@
147
161
  :options="tableSearchOptions"
148
162
  :on-search="tableReload"
149
163
  :on-reset="tableSearchReset"
150
- />
164
+ >
165
+ <!-- 插槽 -->
166
+ <template
167
+ v-for="slotName in slotNames.search"
168
+ v-slot:[slotName]
169
+ >
170
+ <slot :name="`search-${slotName}`"/>
171
+ </template>
172
+ </n-search>
151
173
  </n-drawer>
174
+
152
175
  </q-layout>
153
176
  </template>
154
177
 
@@ -170,6 +193,10 @@ export default {
170
193
  props: {
171
194
  // 表格请求地址
172
195
  url: String,
196
+ // 表格声明属性
197
+ tableProps: Object,
198
+ // 树声明属性
199
+ treeProps: Object,
173
200
  // 树节点唯一键值
174
201
  treeNodeKey: {
175
202
  type: String,
@@ -189,13 +216,13 @@ export default {
189
216
  treeNodeClick: Function,
190
217
  // 显示树筛选
191
218
  treeFilter: Boolean,
192
- // 不显示搜索
193
- noSearch: Boolean,
194
219
  // 树位置
195
220
  treeSide: {
196
221
  type: String,
197
222
  default: 'left',
198
223
  },
224
+ // 不显示搜索
225
+ noSearch: Boolean,
199
226
  // 搜索位置
200
227
  searchSide: {
201
228
  type: String,
@@ -206,6 +233,14 @@ export default {
206
233
  type: Boolean,
207
234
  default: true,
208
235
  },
236
+ // 隐藏左边侧滑菜单
237
+ hideLeftDrawer: Boolean,
238
+ // 左边侧滑菜单声明属性
239
+ leftDrawerProps: Object,
240
+ // 隐藏右边侧滑菜单
241
+ hideRightDrawer: Boolean,
242
+ // 右边侧滑菜单声明属性
243
+ rightDrawerProps: Object,
209
244
  },
210
245
 
211
246
  /**
@@ -259,7 +294,37 @@ export default {
259
294
  * 插槽标识
260
295
  */
261
296
  const slotNames = computed(function() {
262
- return utils.isValidObject(slots) ? Object.keys(slots) : []
297
+
298
+ const toolbar = []
299
+ const search = []
300
+ const table = []
301
+ let leftDrawer = false
302
+ let rightDrawer = false
303
+
304
+ // 如果有插槽
305
+ if (utils.isValidObject(slots)) {
306
+ for (const key in slots) {
307
+ if (key.startsWith('toolbar-')) {
308
+ toolbar.push(key.replace('toolbar-', ''))
309
+ } else if (key.startsWith('search-')) {
310
+ search.push(key.replace('search-', ''))
311
+ } else if (key === 'left-drawer') {
312
+ leftDrawer = true
313
+ } else if (key === 'right-drawer') {
314
+ rightDrawer = true
315
+ } else {
316
+ table.push(key)
317
+ }
318
+ }
319
+ }
320
+
321
+ return {
322
+ toolbar,
323
+ search,
324
+ table,
325
+ leftDrawer,
326
+ rightDrawer,
327
+ }
263
328
  })
264
329
 
265
330
  // ==========【监听数据】=========================================================================================
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/utils/$power.js CHANGED
@@ -2,7 +2,7 @@ import { provide, inject, ref, computed } from 'vue'
2
2
  import { useQuasar } from 'quasar'
3
3
 
4
4
  import { statePower } from '../store'
5
- import { NPowerKey, NFormKey, NTableKey } from './symbols'
5
+ import { NRenderKey, NPowerKey, NFormKey, NTableKey } from './symbols'
6
6
 
7
7
  /**
8
8
  * 创建权限实例
@@ -23,6 +23,10 @@ function create(params) {
23
23
  emptyDescription: '',
24
24
  // 是否开启权限
25
25
  power: true,
26
+ // 是否显示权限按钮
27
+ showPowerBtns: true,
28
+ // 是否显示工具栏权限按钮
29
+ showToolbarPowerBtns: true,
26
30
  // 左边侧滑菜单图标
27
31
  leftDrawerIcon: 'format_list_bulleted',
28
32
  // 右边侧滑菜单图标
@@ -38,25 +42,51 @@ function create(params) {
38
42
  requestAfter: null,
39
43
  }, params)
40
44
 
41
- // 获取权限路由
42
- const $route = o.path === false
43
- // 如果没有路由
44
- ? {
45
+ // 获取渲染注入
46
+ const $render = inject(NRenderKey)
47
+
48
+ // 如果有渲染注入
49
+ const hasRender = !! $render
50
+ if (hasRender) {
51
+ // 如果有权限传参, 则合并参数
52
+ const powerProps = _.get($render, 'props.powerProps')
53
+ if (utils.isValidObject(powerProps)) {
54
+ _.merge(o, powerProps)
55
+ }
56
+ }
57
+
58
+ // 权限路由
59
+ let $route
60
+
61
+ // 如果没有路由
62
+ if (o.path === false) {
63
+
64
+ // 设为空路由
65
+ $route = {
45
66
  fullPath: '',
46
67
  path: '',
47
68
  query: utils.isValidObject(o.query) ? o.query : {},
48
69
  }
49
- // 否则获取路由
50
- : (
51
- utils.isValidString(o.path) ?
52
- // 如果为自定义路由
53
- utils.router.resolve({
54
- path: o.path,
55
- query: utils.isValidObject(o.query) ? o.query : {},
56
- })
57
- // 否则获取当前路由
58
- : utils.router.getRoute()
59
- )
70
+
71
+ // 如果有自定义路径
72
+ } else if (utils.isValidString(o.path)) {
73
+
74
+ // 获取自定义路由
75
+ $route = utils.router.resolve({
76
+ path: o.path,
77
+ query: utils.isValidObject(o.query) ? o.query : {},
78
+ })
79
+
80
+ // 如果在渲染组件内 && 该渲染组件有自定义路由
81
+ } else if (hasRender && _.has($render, '$route')) {
82
+
83
+ // 设为渲染组件的路由
84
+ $route = $render.$route
85
+
86
+ // 否则获取当前路由
87
+ } else {
88
+ $route = utils.router.getRoute()
89
+ }
60
90
 
61
91
  // quasar 对象
62
92
  const $q = useQuasar()
@@ -165,12 +195,16 @@ function create(params) {
165
195
  // 当前页面权限
166
196
  data.powerPage = res.page
167
197
  // 当前页面权限按钮
168
- data.powerBtns = ref(res.btns)
198
+ data.powerBtns = ref(o.showPowerBtns ? res.btns : [])
169
199
  // 当前页面工具栏权限按钮
170
200
  data.toolbarPowerBtns = computed(function() {
171
201
 
172
- // 有权限按钮数据
173
- if (utils.isValidArray(data.powerBtns.value)) {
202
+ if (
203
+ // 如果显示工具栏权限按钮
204
+ o.showToolbarPowerBtns
205
+ // 有权限按钮数据
206
+ && utils.isValidArray(data.powerBtns.value)
207
+ ) {
174
208
 
175
209
  const lists = _.filter(formatBtns(data.powerBtns.value), e => e.type > 2)
176
210
 
@@ -673,7 +707,7 @@ function getRequestQuery(o) {
673
707
  }
674
708
  }
675
709
 
676
- return _.merge({}, query)
710
+ return _.cloneDeep(utils.numberDeep(query))
677
711
  }
678
712
 
679
713
  /**
@@ -696,15 +730,25 @@ function formatQuery(query, isJoinArr) {
696
730
 
697
731
  // 如果是数组
698
732
  } else if (utils.isValidArray(value)) {
733
+
699
734
  const arr = []
700
735
  for (const val of value) {
701
- // 如果是数字
702
- if (utils.isNumeric(val)) {
703
- arr.push(_.isNumber(val) ? val : Number(val))
704
736
 
705
- // 如果是字符串
706
- } else if (utils.isValidString(val)) {
707
- arr.push(utils.trimString(val))
737
+ // 如果为有效值
738
+ if (utils.isRequired(val)) {
739
+
740
+ // 如果是数字
741
+ if (utils.isNumeric(val)) {
742
+ arr.push(_.isNumber(val) ? val : Number(val))
743
+
744
+ // 如果是字符串
745
+ } else if (utils.isValidString(val)) {
746
+ arr.push(utils.trimString(val))
747
+
748
+ // 否则为数组或对象
749
+ } else {
750
+ arr.push(val)
751
+ }
708
752
  }
709
753
  }
710
754
  if (arr.length) {
package/utils/$search.js CHANGED
@@ -25,7 +25,14 @@ export function setItemValue(value, val) {
25
25
  // 比较类型为 in
26
26
  value[0].type = dicts.SEARCH_TYPE__IN
27
27
  // 设置值为将数组转为逗号分隔的字符串
28
- value[0].value = val.join(',')
28
+ value[0].value = utils.join(val, ',')
29
+
30
+ // 如果值是逗号隔开
31
+ } else if (utils.split(val, ',').length > 1) {
32
+ // 比较类型为 in
33
+ value[0].type = dicts.SEARCH_TYPE__IN
34
+ // 设置值为将数组转为逗号分隔的字符串
35
+ value[0].value = val
29
36
 
30
37
  // 否则为单个值
31
38
  } else {
package/utils/$table.js CHANGED
@@ -9,7 +9,7 @@ import {
9
9
  setItemValue,
10
10
  } from './$search'
11
11
 
12
- import { NPowerKey, NTableKey } from './symbols'
12
+ import { NRenderKey, NPowerKey, NTableKey } from './symbols'
13
13
 
14
14
  /**
15
15
  * 创建表格
@@ -90,6 +90,18 @@ function create(params) {
90
90
  rowDblClick: null,
91
91
  }, params)
92
92
 
93
+ // 获取渲染注入
94
+ const $render = inject(NRenderKey)
95
+
96
+ // 如果有渲染注入
97
+ if (!! $render) {
98
+ // 如果有表格传参, 则合并参数
99
+ const tableProps = _.get($render, 'props.tableProps')
100
+ if (utils.isValidObject(tableProps)) {
101
+ _.merge(o, tableProps)
102
+ }
103
+ }
104
+
93
105
  // 获取权限注入
94
106
  const $power = _.has(params, '$power') ? params.$power : inject(NPowerKey)
95
107
  const hasPowr = !! $power
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
+ }