@netang/quasar 0.1.64 → 0.1.66
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 +16 -6
- package/components/uploader-query/index.vue +64 -18
- package/package.json +1 -1
- package/utils/$power.js +32 -0
- package/utils/$table.js +20 -9
|
@@ -183,6 +183,7 @@ import $n_isFunction from 'lodash/isFunction'
|
|
|
183
183
|
import $n_findIndex from 'lodash/findIndex'
|
|
184
184
|
import $n_get from 'lodash/get'
|
|
185
185
|
|
|
186
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
186
187
|
import $n_forEach from '@netang/utils/forEach'
|
|
187
188
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
188
189
|
import $n_join from '@netang/utils/join'
|
|
@@ -406,14 +407,14 @@ export default {
|
|
|
406
407
|
// 刷新后清空已选数据
|
|
407
408
|
refreshResetSelected: false,
|
|
408
409
|
// 自定义请求方法
|
|
409
|
-
async request({ httpOptions }) {
|
|
410
|
+
async request({ httpOptions, props }) {
|
|
410
411
|
return $n_isFunction(props.request) ?
|
|
411
412
|
// 如果有自定义请求方法
|
|
412
413
|
await $n_runAsync(props.request)({
|
|
413
414
|
// http 请求参数
|
|
414
415
|
httpOptions,
|
|
415
416
|
// 对话框是否已显示
|
|
416
|
-
showDialog: showDialog.value,
|
|
417
|
+
showDialog: $n_get(props, 'showDialog') === 1 ? true : showDialog.value,
|
|
417
418
|
}) :
|
|
418
419
|
// 否则请求数据
|
|
419
420
|
await $n_http(httpOptions)
|
|
@@ -996,7 +997,6 @@ export default {
|
|
|
996
997
|
*/
|
|
997
998
|
let _dialogShowed = false
|
|
998
999
|
function onDialogShow() {
|
|
999
|
-
|
|
1000
1000
|
if ($n_isFunction(props.request)) {
|
|
1001
1001
|
|
|
1002
1002
|
if (_dialogShowed) {
|
|
@@ -1037,10 +1037,20 @@ export default {
|
|
|
1037
1037
|
isReload = false
|
|
1038
1038
|
}
|
|
1039
1039
|
|
|
1040
|
-
//
|
|
1041
|
-
|
|
1040
|
+
// 获取表格搜索值
|
|
1041
|
+
let searchValue = $table.getTableSearchValue()
|
|
1042
|
+
if (searchValue.length) {
|
|
1043
|
+
|
|
1044
|
+
// 如果有隐藏搜索字段数组
|
|
1045
|
+
if ($n_isValidArray(props.hideSearchKeys)) {
|
|
1046
|
+
// 从搜索值数组中去除隐藏搜索字段的数组
|
|
1047
|
+
searchValue = searchValue.filter(e => $n_indexOf(e.field, props.hideSearchKeys) === -1)
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1042
1050
|
// 表格搜索重置
|
|
1043
|
-
$table.tableSearchReset(isReload
|
|
1051
|
+
$table.tableSearchReset(isReload && searchValue.length, {
|
|
1052
|
+
showDialog: 1,
|
|
1053
|
+
})
|
|
1044
1054
|
}
|
|
1045
1055
|
}
|
|
1046
1056
|
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
@dragend="dragEnd"
|
|
78
78
|
>
|
|
79
79
|
<n-img
|
|
80
|
-
:src="
|
|
80
|
+
:src="currentQuery[fileItemIndex].src"
|
|
81
81
|
:spinner-size="toPx(currentSize / 2)"
|
|
82
82
|
:width="toPx(currentSize)"
|
|
83
83
|
:height="toPx(currentSize)"
|
|
@@ -146,9 +146,9 @@
|
|
|
146
146
|
name="search"
|
|
147
147
|
:size="settingsIconSize"
|
|
148
148
|
title="预览"
|
|
149
|
-
@click="
|
|
149
|
+
@click="previewImage(fileItemIndex)"
|
|
150
150
|
v-bind="settingsIconProps"
|
|
151
|
-
v-if="! noPreview &&
|
|
151
|
+
v-if="! noPreview && currentQuery[fileItemIndex].preview_src"
|
|
152
152
|
/>
|
|
153
153
|
|
|
154
154
|
<!-- 删除 -->
|
|
@@ -361,10 +361,12 @@ import $n_has from 'lodash/has'
|
|
|
361
361
|
import $n_get from 'lodash/get'
|
|
362
362
|
|
|
363
363
|
import $n_px from '@netang/utils/px'
|
|
364
|
+
import $n_forEach from '@netang/utils/forEach'
|
|
364
365
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
365
366
|
import $n_isValidString from '@netang/utils/isValidString'
|
|
366
367
|
|
|
367
368
|
import $n_getImage from '../../utils/getImage'
|
|
369
|
+
import $n_previewImage from '../../utils/previewImage'
|
|
368
370
|
|
|
369
371
|
import NDragger from '../dragger'
|
|
370
372
|
|
|
@@ -463,12 +465,55 @@ export default {
|
|
|
463
465
|
|
|
464
466
|
// ==========【计算属性】=========================================================================================
|
|
465
467
|
|
|
468
|
+
/**
|
|
469
|
+
* 当前上传文件队列
|
|
470
|
+
*/
|
|
471
|
+
const currentQuery = computed(function () {
|
|
472
|
+
|
|
473
|
+
// 如果不是图片
|
|
474
|
+
if (uploaderProps.type !== 'image') {
|
|
475
|
+
if ($n_isValidArray(query.value)) {
|
|
476
|
+
return query.value
|
|
477
|
+
}
|
|
478
|
+
return []
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
const lists = []
|
|
482
|
+
|
|
483
|
+
$n_forEach(query.value, function (fileItem) {
|
|
484
|
+
const newItem = Object.assign({}, fileItem)
|
|
485
|
+
|
|
486
|
+
let src = ''
|
|
487
|
+
let preview_src = ''
|
|
488
|
+
|
|
489
|
+
if ($n_has(fileItem, '__img')) {
|
|
490
|
+
src = fileItem.__img
|
|
491
|
+
preview_src = src
|
|
492
|
+
} else if ($n_isValidString(fileItem.hash)) {
|
|
493
|
+
src = $n_getImage(fileItem.hash, { w: $q.platform.is.mobile ? currentSize.value * 2 : currentSize.value })
|
|
494
|
+
if (src) {
|
|
495
|
+
// 预览地址
|
|
496
|
+
preview_src = fileItem.hash
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
lists.push(Object.assign(newItem, {
|
|
501
|
+
// 图片地址
|
|
502
|
+
src,
|
|
503
|
+
// 预览地址
|
|
504
|
+
preview_src,
|
|
505
|
+
}))
|
|
506
|
+
})
|
|
507
|
+
|
|
508
|
+
return lists
|
|
509
|
+
})
|
|
510
|
+
|
|
511
|
+
|
|
466
512
|
/**
|
|
467
513
|
* 当前是否开启拖拽
|
|
468
514
|
*/
|
|
469
515
|
const currentDrag = computed(function() {
|
|
470
516
|
return props.drag
|
|
471
|
-
&& $n_isValidArray(query.value)
|
|
472
517
|
&& query.value.length > 1
|
|
473
518
|
&& ! props.readonly
|
|
474
519
|
&& ! props.disable
|
|
@@ -500,8 +545,8 @@ export default {
|
|
|
500
545
|
const showSquareButton = computed(function () {
|
|
501
546
|
// 自动显示方块按钮 && 有上传文件限制数量
|
|
502
547
|
return props.autoShowSquareButton && uploaderProps.count > 0 ?
|
|
503
|
-
// 如果
|
|
504
|
-
|
|
548
|
+
// 如果 当前上传文件队列数量 < 上传文件限制数量
|
|
549
|
+
currentQuery.value.length < uploaderProps.count
|
|
505
550
|
// 始终显示
|
|
506
551
|
: true
|
|
507
552
|
})
|
|
@@ -509,16 +554,15 @@ export default {
|
|
|
509
554
|
// ==========【方法】=============================================================================================
|
|
510
555
|
|
|
511
556
|
/**
|
|
512
|
-
*
|
|
557
|
+
* 预览图片
|
|
513
558
|
*/
|
|
514
|
-
function
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
: (
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
)
|
|
559
|
+
function previewImage(startPosition) {
|
|
560
|
+
$n_previewImage({
|
|
561
|
+
// 需要预览的图片 URL 数组
|
|
562
|
+
images: currentQuery.value.map(e => e.preview_src),
|
|
563
|
+
// 图片预览起始位置索引
|
|
564
|
+
startPosition,
|
|
565
|
+
})
|
|
522
566
|
}
|
|
523
567
|
|
|
524
568
|
/**
|
|
@@ -538,8 +582,10 @@ export default {
|
|
|
538
582
|
type: uploaderProps.type,
|
|
539
583
|
// 上传文件数量(0:不限)
|
|
540
584
|
count: uploaderProps.count,
|
|
541
|
-
//
|
|
585
|
+
// 文件队列
|
|
542
586
|
query,
|
|
587
|
+
// 当前上传文件队列
|
|
588
|
+
currentQuery,
|
|
543
589
|
|
|
544
590
|
// 当前是否开启拖拽
|
|
545
591
|
currentDrag,
|
|
@@ -553,8 +599,8 @@ export default {
|
|
|
553
599
|
// 上传器
|
|
554
600
|
uploader,
|
|
555
601
|
|
|
556
|
-
//
|
|
557
|
-
|
|
602
|
+
// 预览图片
|
|
603
|
+
previewImage,
|
|
558
604
|
// 获取文件名称
|
|
559
605
|
getFileName,
|
|
560
606
|
|
package/package.json
CHANGED
package/utils/$power.js
CHANGED
|
@@ -1358,6 +1358,36 @@ function getPageData($route) {
|
|
|
1358
1358
|
})
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
|
+
/**
|
|
1362
|
+
* 新窗口
|
|
1363
|
+
*/
|
|
1364
|
+
function routerPush({ path, query, pageTitle, fromPage }) {
|
|
1365
|
+
|
|
1366
|
+
if (! $n_isValidObject(query)) {
|
|
1367
|
+
query = {}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// 如果有标题
|
|
1371
|
+
pageTitle = $n_trimString(pageTitle)
|
|
1372
|
+
if (pageTitle) {
|
|
1373
|
+
query.n_page_title = pageTitle
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
// 来源页面
|
|
1377
|
+
if (fromPage) {
|
|
1378
|
+
if (fromPage === true) {
|
|
1379
|
+
fromPage = $n_router.getRoute().fullPath
|
|
1380
|
+
}
|
|
1381
|
+
// 来源页面是指定路由的完整路径
|
|
1382
|
+
query.n_from_page = encodeURIComponent(fromPage)
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
$n_router.push({
|
|
1386
|
+
path,
|
|
1387
|
+
query,
|
|
1388
|
+
})
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1361
1391
|
/**
|
|
1362
1392
|
* 权限业务
|
|
1363
1393
|
*/
|
|
@@ -1374,6 +1404,8 @@ const $power = {
|
|
|
1374
1404
|
formatBtns,
|
|
1375
1405
|
// 请求
|
|
1376
1406
|
request,
|
|
1407
|
+
// 新窗口
|
|
1408
|
+
routerPush,
|
|
1377
1409
|
}
|
|
1378
1410
|
|
|
1379
1411
|
export default $power
|
package/utils/$table.js
CHANGED
|
@@ -733,7 +733,7 @@ function create(options) {
|
|
|
733
733
|
/**
|
|
734
734
|
* 表格重新加载
|
|
735
735
|
*/
|
|
736
|
-
async function tableReload() {
|
|
736
|
+
async function tableReload(params = null) {
|
|
737
737
|
|
|
738
738
|
// 表格已加载
|
|
739
739
|
_isTableLoaded = true
|
|
@@ -751,9 +751,10 @@ function create(options) {
|
|
|
751
751
|
// $tableRef?.requestServerInteraction({
|
|
752
752
|
// pagination: o.pagination,
|
|
753
753
|
// })
|
|
754
|
-
|
|
754
|
+
|
|
755
|
+
await tableRequest(Object.assign({
|
|
755
756
|
pagination: o.pagination,
|
|
756
|
-
})
|
|
757
|
+
}, params))
|
|
757
758
|
|
|
758
759
|
// 清空表格已选数据
|
|
759
760
|
if (o.refreshResetSelected) {
|
|
@@ -790,7 +791,7 @@ function create(options) {
|
|
|
790
791
|
/**
|
|
791
792
|
* 表格搜索重置
|
|
792
793
|
*/
|
|
793
|
-
function tableSearchReset(reload = true) {
|
|
794
|
+
function tableSearchReset(reload = true, params = null) {
|
|
794
795
|
|
|
795
796
|
const newValue = []
|
|
796
797
|
|
|
@@ -809,7 +810,8 @@ function create(options) {
|
|
|
809
810
|
|
|
810
811
|
// 表格重新加载
|
|
811
812
|
if (reload) {
|
|
812
|
-
tableReload()
|
|
813
|
+
tableReload(params)
|
|
814
|
+
.finally()
|
|
813
815
|
}
|
|
814
816
|
}
|
|
815
817
|
|
|
@@ -1059,12 +1061,19 @@ function create(options) {
|
|
|
1059
1061
|
}
|
|
1060
1062
|
|
|
1061
1063
|
/**
|
|
1062
|
-
*
|
|
1064
|
+
* 获取表格搜索值
|
|
1063
1065
|
*/
|
|
1064
|
-
function
|
|
1065
|
-
return
|
|
1066
|
+
function getTableSearchValue() {
|
|
1067
|
+
return formatValue(rawSearchOptions, tableSearchValue.value)
|
|
1066
1068
|
}
|
|
1067
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
* 是否有表格搜索值
|
|
1072
|
+
*/
|
|
1073
|
+
// function hasTableSearchValue() {
|
|
1074
|
+
// return !! formatValue(rawSearchOptions, tableSearchValue.value).length
|
|
1075
|
+
// }
|
|
1076
|
+
|
|
1068
1077
|
// ==========【返回】=================================================================================================
|
|
1069
1078
|
|
|
1070
1079
|
const resTable = {
|
|
@@ -1136,8 +1145,10 @@ function create(options) {
|
|
|
1136
1145
|
// 设置表格搜索参数
|
|
1137
1146
|
setTableSearchOptions,
|
|
1138
1147
|
|
|
1148
|
+
// 获取表格搜索值
|
|
1149
|
+
getTableSearchValue,
|
|
1139
1150
|
// 是否有表格搜索值
|
|
1140
|
-
hasTableSearchValue,
|
|
1151
|
+
// hasTableSearchValue,
|
|
1141
1152
|
|
|
1142
1153
|
// 获取当前路由
|
|
1143
1154
|
getRoute() {
|