@netang/quasar 0.0.107 → 0.1.9

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.
@@ -588,7 +588,6 @@ export default {
588
588
  * 加载已选数据
589
589
  */
590
590
  async function loadSelected() {
591
-
592
591
  if (
593
592
  // 如果值类型不是数组对象
594
593
  props.valueType !== 'objectArray'
@@ -600,7 +599,6 @@ export default {
600
599
  // 获取值数组
601
600
  const values = valueToSelected(props.modelValue, false, false)
602
601
  if (values.length) {
603
-
604
602
  // 初始的已选数据
605
603
  const _selected = await onRequestSelected(values)
606
604
  const _value = selectedToValue(_selected)
@@ -791,7 +789,7 @@ export default {
791
789
  }
792
790
  ),
793
791
  // 是否开启防抖(防止重复请求)
794
- debounce: false,
792
+ // debounce: false,
795
793
  }
796
794
 
797
795
  // 请求数据
@@ -56,6 +56,8 @@ export default {
56
56
  props: {
57
57
  // 组件标识
58
58
  name: String,
59
+ // 组件
60
+ component: Object,
59
61
  // 组件路径
60
62
  path: String,
61
63
  // 参数
@@ -86,8 +88,13 @@ export default {
86
88
 
87
89
  // 如果有组件标识
88
90
  } else if (props.name && $n_has(components, props.name)) {
89
- // 获取自定义组件
91
+ // 设置自定义组件
90
92
  comp = components[props.name]
93
+
94
+ // 如果有声明组件
95
+ } else if (props.component) {
96
+ // 设置声明组件
97
+ comp = props.component
91
98
  }
92
99
 
93
100
  // 如果没有组件
@@ -165,6 +165,7 @@
165
165
  :options="tableSearchOptions"
166
166
  :on-search="tableReload"
167
167
  :on-reset="tableSearchReset"
168
+ v-if="showSearch"
168
169
  >
169
170
  <!-- 插槽 -->
170
171
  <template
@@ -180,7 +181,7 @@
180
181
  </template>
181
182
 
182
183
  <script>
183
- import { ref, watch, computed, inject } from 'vue'
184
+ import { ref, watch, computed, inject, onMounted } from 'vue'
184
185
 
185
186
  import $n_isFunction from 'lodash/isFunction'
186
187
 
@@ -290,8 +291,6 @@ export default {
290
291
  // 获取表格注入
291
292
  const $table = inject(NTableKey)
292
293
 
293
- // console.log('----$table222---', $table, $table.tableSearchValue.value)
294
-
295
294
  // 获取对话框注入
296
295
  const $dialog = inject(NDialogKey)
297
296
  const inDialog = !! $dialog
@@ -327,6 +326,9 @@ export default {
327
326
  // 树选择数据
328
327
  const treeSelected = ref(null)
329
328
 
329
+ // 是否显示搜索
330
+ const showSearch = ref(false)
331
+
330
332
  // ==========【计算属性】==========================================================================================
331
333
 
332
334
  /**
@@ -432,6 +434,17 @@ export default {
432
434
  })
433
435
  }
434
436
 
437
+ // ==========【生命周期】=========================================================================================
438
+
439
+ /**
440
+ * 实例被挂载后调用
441
+ */
442
+ onMounted( async function() {
443
+
444
+ // 显示搜索
445
+ showSearch.value = true
446
+ })
447
+
435
448
  // ==========【返回】=============================================================================================
436
449
 
437
450
  return {
@@ -444,6 +457,8 @@ export default {
444
457
  treeFilterValue,
445
458
  // 树选择数据
446
459
  treeSelected,
460
+ // 是否显示搜索
461
+ showSearch,
447
462
 
448
463
  // 插槽 body 单元格标识
449
464
  slotNames,
@@ -1,360 +1,366 @@
1
- <template>
2
- <n-splitter
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"
11
- @update:after="setSelection"
12
- :hide-after-in-mobile="hideAfterInMobile"
13
- :cache="cache"
14
- >
15
- <!-- 表格 -->
16
- <template v-slot:before="{ after, toggleAfter }">
17
- <n-table
18
- v-bind="$attrs"
19
- >
20
- <!-- 工具栏右边插槽(手机端不显示) -->
21
- <template #toolbar-right v-if="isWatcher">
22
-
23
- <!-- 工具栏右边插槽 -->
24
- <slot name="toolbar-right" />
25
-
26
- <!-- 是否显示详情 -->
27
- <q-toggle
28
- icon="apps"
29
- :model-value="after"
30
- @click="toggleAfter"
31
- >
32
- <q-tooltip anchor="center left" self="center right" :offset="[10, 0]">{{tooltip}}</q-tooltip>
33
- </q-toggle>
34
-
35
- </template>
36
-
37
- <!-- 插槽 -->
38
- <template
39
- v-for="slotName in slotNames"
40
- v-slot:[slotName]="props"
41
- >
42
- <!-- 有传参的插槽 -->
43
- <slot
44
- :name="slotName"
45
- v-bind="props"
46
- v-if="props"
47
- />
48
-
49
- <!-- 无传参的插槽 -->
50
- <slot
51
- :name="slotName"
52
- v-else
53
- />
54
- </template>
55
-
56
- </n-table>
57
- </template>
58
-
59
- <!-- 渲染详情页面(手机端不显示) -->
60
- <template v-slot:after>
61
-
62
- <!-- 渲染 -->
63
- <n-render
64
- :path="renderPath"
65
- :query="currentQuery"
66
- v-if="currentQuery"
67
- />
68
-
69
- <!-- 空状态 -->
70
- <n-empty
71
- :description="renderDescription"
72
- fit
73
- v-else
74
- />
75
-
76
- </template>
77
-
78
- </n-splitter>
79
- </template>
80
-
81
- <script>
82
- import { nextTick, ref, watch, computed, inject } from 'vue'
83
- import { useQuasar } from 'quasar'
84
-
85
- import $n_isFunction from 'lodash/isFunction'
86
-
87
- import $n_isValidObject from '@netang/utils/isValidObject'
88
-
89
- import NSplitter from '../splitter'
90
- import NTable from '../table'
91
- import NRender from '../render'
92
- import NEmpty from '../empty'
93
-
94
- import { NTableKey } from '../../utils/symbols'
95
-
96
- export default {
97
-
98
- /**
99
- * 关闭组件 attribute 透传行为
100
- */
101
- inheritAttrs: false,
102
-
103
- /**
104
- * 标识
105
- */
106
- name: 'NTableSplitter',
107
-
108
- /**
109
- * 组件
110
- */
111
- components: {
112
- NSplitter,
113
- NTable,
114
- NRender,
115
- NEmpty,
116
- },
117
-
118
- /**
119
- * 声明属性
120
- */
121
- props: {
122
- // 值 v-model
123
- modelValue: {
124
- type: Number,
125
- default: 50,
126
- },
127
- // 反转插槽
128
- reverse: Boolean,
129
- // 模型的 CSS 单位
130
- unit: String,
131
- // 两个值的数组,表示两个面板的最小和最大分割大小
132
- limits: Array,
133
- // 是否水平拆分
134
- horizontal: Boolean,
135
-
136
- // 显示后置插槽 v-model:after
137
- // 注意: 如果非双向绑定, 如 :after 并不会影响内部值变化, 仅做初始值使用
138
- after: {
139
- type: Boolean,
140
- default: true,
141
- },
142
- // 手机模式隐藏后插槽
143
- hideAfterInMobile: {
144
- type: Boolean,
145
- default: true,
146
- },
147
- // 是否开启缓存
148
- cache: {
149
- type: [ Boolean, String ],
150
- default: true,
151
- },
152
-
153
- // 工具提示
154
- tooltip: {
155
- type: String,
156
- default: '是否显示详情',
157
- },
158
- // 渲染组件路径
159
- renderPath: {
160
- type: String,
161
- required: true,
162
- },
163
- // 格式化已选表格的数据并返回渲染组件参数
164
- renderQuery: Function,
165
- // 渲染空状态描述
166
- renderDescription: {
167
- type: String,
168
- default: '没有找到任何数据',
169
- },
170
- // 不需要加载渲染页面标识参数
171
- // 额外加载参数 { n_renderpage: 1 }
172
- noRendPageName: Boolean,
173
- },
174
-
175
- /**
176
- * 声明事件
177
- */
178
- emits: [
179
- 'update:modelValue',
180
- 'update:after',
181
- ],
182
-
183
- /**
184
- * 组合式
185
- */
186
- setup(props, { emit, slots }) {
187
-
188
- // ==========【计算属性】=========================================================================================
189
-
190
- /**
191
- * 插槽标识
192
- */
193
- const slotNames = computed(function() {
194
- return $n_isValidObject(slots) ? Object.keys(slots).filter(e => e !== 'toolbar-right') : []
195
- })
196
-
197
- /**
198
- * 是否监听
199
- */
200
- const isWatcher = computed(function () {
201
- return ! props.hideAfterInMobile || ! $q.platform.is.mobile
202
- })
203
-
204
- /**
205
- * 当前传参
206
- */
207
- const currentQuery = computed(function() {
208
-
209
- // 如果有已选数据
210
- if (
211
- currentSelectedItem.value
212
- && $n_isFunction(props.renderQuery)
213
- ) {
214
- const resQuery = props.renderQuery(currentSelectedItem.value)
215
- if ($n_isValidObject(resQuery)) {
216
-
217
- // 如果需要加载渲染页面标识参数
218
- if (! props.noRendPageName) {
219
- // 格式化已选数据, 并返回参数
220
- return Object.assign({}, resQuery, {
221
- // 是否为渲染页面
222
- n_renderpage: 1,
223
- })
224
- }
225
-
226
- return resQuery
227
- }
228
- }
229
-
230
- return null
231
- })
232
-
233
- // ==========【数据】=============================================================================================
234
-
235
- // quasar 对象
236
- const $q = useQuasar()
237
-
238
- // 获取表格注入
239
- const $table = inject(NTableKey)
240
-
241
- // 原始表格选择状态
242
- const rawTableSelection = $table.tableSelection.value
243
-
244
- // 当前已选单条数据
245
- const currentSelectedItem = ref(null)
246
-
247
- // 当前值
248
- const currentValue = ref(props.modelValue)
249
-
250
- // 当前显示前置插槽
251
- const currentAfter = ref(props.after)
252
-
253
- // ==========【监听数据】=========================================================================================
254
-
255
- /**
256
- * 监听声明值
257
- */
258
- watch(() => props.modelValue, function (val) {
259
- currentValue.value = val
260
- })
261
-
262
- /**
263
- * 监听声明显示前置插槽
264
- */
265
- watch(() => props.after, function (val) {
266
- currentAfter.value = val
267
- })
268
-
269
- /**
270
- * 监听当前值
271
- */
272
- watch(currentValue, function (val) {
273
- emit('update:modelValue', val)
274
- })
275
-
276
- /**
277
- * 监听当前显示前置插槽
278
- */
279
- watch(currentAfter, function (val) {
280
- emit('update:after', val)
281
- })
282
-
283
- /**
284
- * 监听表格已选数据(非手机端有效)
285
- */
286
- watch($table.tableSelected, async function (selected) {
287
-
288
- // 先清空当前已选单条数据
289
- currentSelectedItem.value = null
290
-
291
- // 如果不监听
292
- if (! isWatcher.value) {
293
-
294
- // 则无需任何操作
295
- return
296
- }
297
-
298
- // 下次 DOM 更新
299
- await nextTick()
300
-
301
- // 如果有已选单条数据
302
- if (selected.length === 1) {
303
-
304
- // 设置当前已选数据
305
- currentSelectedItem.value = selected[0]
306
- }
307
-
308
- }, {
309
- // 深度监听
310
- deep: true,
311
- })
312
-
313
- // ==========【方法】============================================================================================
314
-
315
- /**
316
- * 设置表格选择类型
317
- */
318
- function setSelection(showAfter) {
319
-
320
- // 如果不监听
321
- if (! isWatcher.value) {
322
-
323
- // 则无需任何操作
324
- return
325
- }
326
-
327
- const selection = showAfter ? 'single' : rawTableSelection
328
- if ($table.tableSelection.value !== selection) {
329
- $table.tableSelection.value = selection
330
-
331
- // 如果显示后置插槽
332
- if (showAfter && $table.tableSelected.value.length > 1) {
333
-
334
- // 如果有多条已选数据, 则只取第一条数据
335
- $table.tableSelected.value = [ $table.tableSelected.value[$table.tableSelected.value.length - 1] ]
336
- }
337
- }
338
- }
339
-
340
- // ==========【返回】=========================================================================================
341
-
342
- return {
343
- // 插槽标识
344
- slotNames,
345
- // 是否监听
346
- isWatcher,
347
- // 当前传参
348
- currentQuery,
349
-
350
- // 当前值
351
- currentValue,
352
- // 当前显示前置插槽
353
- currentAfter,
354
-
355
- // 设置表格选择类型
356
- setSelection,
357
- }
358
- }
359
- }
360
- </script>
1
+ <template>
2
+ <n-splitter
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"
11
+ @update:after="setSelection"
12
+ :hide-after-in-mobile="hideAfterInMobile"
13
+ :cache="cache"
14
+ >
15
+ <!-- 表格 -->
16
+ <template v-slot:before="{ after, toggleAfter }">
17
+ <n-table
18
+ v-bind="$attrs"
19
+ >
20
+ <!-- 工具栏右边插槽(手机端不显示) -->
21
+ <template #toolbar-right v-if="isWatcher">
22
+
23
+ <!-- 工具栏右边插槽 -->
24
+ <slot name="toolbar-right" />
25
+
26
+ <!-- 是否显示详情 -->
27
+ <q-toggle
28
+ icon="apps"
29
+ :model-value="after"
30
+ @click="toggleAfter"
31
+ >
32
+ <q-tooltip anchor="center left" self="center right" :offset="[10, 0]">{{tooltip}}</q-tooltip>
33
+ </q-toggle>
34
+
35
+ </template>
36
+
37
+ <!-- 插槽 -->
38
+ <template
39
+ v-for="slotName in slotNames"
40
+ v-slot:[slotName]="props"
41
+ >
42
+ <!-- 有传参的插槽 -->
43
+ <slot
44
+ :name="slotName"
45
+ v-bind="props"
46
+ v-if="props"
47
+ />
48
+
49
+ <!-- 无传参的插槽 -->
50
+ <slot
51
+ :name="slotName"
52
+ v-else
53
+ />
54
+ </template>
55
+
56
+ </n-table>
57
+ </template>
58
+
59
+ <!-- 渲染详情页面(手机端不显示) -->
60
+ <template v-slot:after>
61
+
62
+ <!-- 渲染 -->
63
+ <n-render
64
+ :name="renderName"
65
+ :path="renderPath"
66
+ :component="renderComponent"
67
+ :query="currentQuery"
68
+ :props="renderProps"
69
+ v-if="currentQuery"
70
+ />
71
+
72
+ <!-- 空状态 -->
73
+ <n-empty
74
+ :description="renderDescription"
75
+ fit
76
+ v-else
77
+ />
78
+
79
+ </template>
80
+
81
+ </n-splitter>
82
+ </template>
83
+
84
+ <script>
85
+ import { nextTick, ref, watch, computed, inject } from 'vue'
86
+ import { useQuasar } from 'quasar'
87
+
88
+ import $n_isFunction from 'lodash/isFunction'
89
+
90
+ import $n_isValidObject from '@netang/utils/isValidObject'
91
+
92
+ import NSplitter from '../splitter'
93
+ import NTable from '../table'
94
+ import NRender from '../render'
95
+ import NEmpty from '../empty'
96
+
97
+ import { NTableKey } from '../../utils/symbols'
98
+
99
+ export default {
100
+
101
+ /**
102
+ * 关闭组件 attribute 透传行为
103
+ */
104
+ inheritAttrs: false,
105
+
106
+ /**
107
+ * 标识
108
+ */
109
+ name: 'NTableSplitter',
110
+
111
+ /**
112
+ * 组件
113
+ */
114
+ components: {
115
+ NSplitter,
116
+ NTable,
117
+ NRender,
118
+ NEmpty,
119
+ },
120
+
121
+ /**
122
+ * 声明属性
123
+ */
124
+ props: {
125
+ // 值 v-model
126
+ modelValue: {
127
+ type: Number,
128
+ default: 50,
129
+ },
130
+ // 反转插槽
131
+ reverse: Boolean,
132
+ // 模型的 CSS 单位
133
+ unit: String,
134
+ // 两个值的数组,表示两个面板的最小和最大分割大小
135
+ limits: Array,
136
+ // 是否水平拆分
137
+ horizontal: Boolean,
138
+
139
+ // 显示后置插槽 v-model:after
140
+ // 注意: 如果非双向绑定, 如 :after 并不会影响内部值变化, 仅做初始值使用
141
+ after: {
142
+ type: Boolean,
143
+ default: true,
144
+ },
145
+ // 手机模式隐藏后插槽
146
+ hideAfterInMobile: {
147
+ type: Boolean,
148
+ default: true,
149
+ },
150
+ // 是否开启缓存
151
+ cache: {
152
+ type: [ Boolean, String ],
153
+ default: true,
154
+ },
155
+
156
+ // 工具提示
157
+ tooltip: {
158
+ type: String,
159
+ default: '是否显示详情',
160
+ },
161
+ // 渲染组件标识
162
+ renderName: String,
163
+ // 渲染组件路径
164
+ renderPath: String,
165
+ // 渲染组件的组件
166
+ renderComponent: Object,
167
+ // 格式化已选表格的数据并返回渲染组件参数
168
+ renderQuery: Function,
169
+ // 渲染组件的传参
170
+ renderProps: Object,
171
+ // 渲染空状态描述
172
+ renderDescription: {
173
+ type: String,
174
+ default: '没有找到任何数据',
175
+ },
176
+ // 不需要加载渲染页面标识参数
177
+ // 额外加载参数 { n_renderpage: 1 }
178
+ noRendPageName: Boolean,
179
+ },
180
+
181
+ /**
182
+ * 声明事件
183
+ */
184
+ emits: [
185
+ 'update:modelValue',
186
+ 'update:after',
187
+ ],
188
+
189
+ /**
190
+ * 组合式
191
+ */
192
+ setup(props, { emit, slots }) {
193
+
194
+ // ==========【计算属性】=========================================================================================
195
+
196
+ /**
197
+ * 插槽标识
198
+ */
199
+ const slotNames = computed(function() {
200
+ return $n_isValidObject(slots) ? Object.keys(slots).filter(e => e !== 'toolbar-right') : []
201
+ })
202
+
203
+ /**
204
+ * 是否监听
205
+ */
206
+ const isWatcher = computed(function () {
207
+ return ! props.hideAfterInMobile || ! $q.platform.is.mobile
208
+ })
209
+
210
+ /**
211
+ * 当前传参
212
+ */
213
+ const currentQuery = computed(function() {
214
+
215
+ // 如果有已选数据
216
+ if (
217
+ currentSelectedItem.value
218
+ && $n_isFunction(props.renderQuery)
219
+ ) {
220
+ const resQuery = props.renderQuery(currentSelectedItem.value)
221
+ if ($n_isValidObject(resQuery)) {
222
+
223
+ // 如果需要加载渲染页面标识参数
224
+ if (! props.noRendPageName) {
225
+ // 格式化已选数据, 并返回参数
226
+ return Object.assign({}, resQuery, {
227
+ // 是否为渲染页面
228
+ n_renderpage: 1,
229
+ })
230
+ }
231
+
232
+ return resQuery
233
+ }
234
+ }
235
+
236
+ return null
237
+ })
238
+
239
+ // ==========【数据】=============================================================================================
240
+
241
+ // quasar 对象
242
+ const $q = useQuasar()
243
+
244
+ // 获取表格注入
245
+ const $table = inject(NTableKey)
246
+
247
+ // 原始表格选择状态
248
+ const rawTableSelection = $table.tableSelection.value
249
+
250
+ // 当前已选单条数据
251
+ const currentSelectedItem = ref(null)
252
+
253
+ // 当前值
254
+ const currentValue = ref(props.modelValue)
255
+
256
+ // 当前显示前置插槽
257
+ const currentAfter = ref(props.after)
258
+
259
+ // ==========【监听数据】=========================================================================================
260
+
261
+ /**
262
+ * 监听声明值
263
+ */
264
+ watch(() => props.modelValue, function (val) {
265
+ currentValue.value = val
266
+ })
267
+
268
+ /**
269
+ * 监听声明显示前置插槽
270
+ */
271
+ watch(() => props.after, function (val) {
272
+ currentAfter.value = val
273
+ })
274
+
275
+ /**
276
+ * 监听当前值
277
+ */
278
+ watch(currentValue, function (val) {
279
+ emit('update:modelValue', val)
280
+ })
281
+
282
+ /**
283
+ * 监听当前显示前置插槽
284
+ */
285
+ watch(currentAfter, function (val) {
286
+ emit('update:after', val)
287
+ })
288
+
289
+ /**
290
+ * 监听表格已选数据(非手机端有效)
291
+ */
292
+ watch($table.tableSelected, async function (selected) {
293
+
294
+ // 先清空当前已选单条数据
295
+ currentSelectedItem.value = null
296
+
297
+ // 如果不监听
298
+ if (! isWatcher.value) {
299
+
300
+ // 则无需任何操作
301
+ return
302
+ }
303
+
304
+ // 下次 DOM 更新
305
+ await nextTick()
306
+
307
+ // 如果有已选单条数据
308
+ if (selected.length === 1) {
309
+
310
+ // 设置当前已选数据
311
+ currentSelectedItem.value = selected[0]
312
+ }
313
+
314
+ }, {
315
+ // 深度监听
316
+ deep: true,
317
+ })
318
+
319
+ // ==========【方法】============================================================================================
320
+
321
+ /**
322
+ * 设置表格选择类型
323
+ */
324
+ function setSelection(showAfter) {
325
+
326
+ // 如果不监听
327
+ if (! isWatcher.value) {
328
+
329
+ // 则无需任何操作
330
+ return
331
+ }
332
+
333
+ const selection = showAfter ? 'single' : rawTableSelection
334
+ if ($table.tableSelection.value !== selection) {
335
+ $table.tableSelection.value = selection
336
+
337
+ // 如果显示后置插槽
338
+ if (showAfter && $table.tableSelected.value.length > 1) {
339
+
340
+ // 如果有多条已选数据, 则只取第一条数据
341
+ $table.tableSelected.value = [ $table.tableSelected.value[$table.tableSelected.value.length - 1] ]
342
+ }
343
+ }
344
+ }
345
+
346
+ // ==========【返回】=========================================================================================
347
+
348
+ return {
349
+ // 插槽标识
350
+ slotNames,
351
+ // 是否监听
352
+ isWatcher,
353
+ // 当前传参
354
+ currentQuery,
355
+
356
+ // 当前值
357
+ currentValue,
358
+ // 当前显示前置插槽
359
+ currentAfter,
360
+
361
+ // 设置表格选择类型
362
+ setSelection,
363
+ }
364
+ }
365
+ }
366
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netang/quasar",
3
- "version": "0.0.107",
3
+ "version": "0.1.9",
4
4
  "description": "netang-quasar",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"