@netang/quasar 0.1.65 → 0.1.67
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.
|
@@ -156,7 +156,7 @@ const $table = $n.$table.create({
|
|
|
156
156
|
| tableSelected | 表格已选数据 | `ref(Array)` | v-model:selected="tableSelected" |
|
|
157
157
|
| tableFixedPowerBtns | 固定在右边的权限按钮列表 | `computed` | - |
|
|
158
158
|
| showTableFixed | 是否显示固定在右边的权限按钮列表 | `computed` | - |
|
|
159
|
-
|
|
|
159
|
+
| tableImgs | 表格图片 | `ref(Object)` | 可在插槽中使用 |
|
|
160
160
|
| tableGrid | 表格宫格 | `ref(Boolean)` | :grid="tableGrid" |
|
|
161
161
|
| tableSummary | 表格合计 | `ref(Object)` | 可在插槽中使用 |
|
|
162
162
|
| tableSearchValue | 表格搜索数据 | `ref(Array)` | - |
|
|
@@ -119,16 +119,26 @@
|
|
|
119
119
|
>
|
|
120
120
|
<!-- 图片 -->
|
|
121
121
|
<template
|
|
122
|
-
v-for="
|
|
123
|
-
v-slot:[`body-cell-${
|
|
122
|
+
v-for="imgItem in tableImgs"
|
|
123
|
+
v-slot:[`body-cell-${imgItem.name}`]="props"
|
|
124
124
|
>
|
|
125
|
-
<
|
|
125
|
+
<n-data
|
|
126
|
+
:data="formatImg(props.row[imgItem.name], imgItem)"
|
|
127
|
+
v-slot="{ data }"
|
|
128
|
+
>
|
|
126
129
|
<!-- 缩略图 -->
|
|
127
130
|
<n-thumbnail
|
|
128
|
-
|
|
131
|
+
v-for="(item, index) in data"
|
|
132
|
+
:key="`thumbnail-item-${item}`"
|
|
133
|
+
class="n-table__thumbnail"
|
|
134
|
+
:src="item"
|
|
129
135
|
preview
|
|
136
|
+
:preview-props="{
|
|
137
|
+
startPosition: index,
|
|
138
|
+
images: data,
|
|
139
|
+
}"
|
|
130
140
|
/>
|
|
131
|
-
</
|
|
141
|
+
</n-data>
|
|
132
142
|
</template>
|
|
133
143
|
|
|
134
144
|
<!-- 插槽 -->
|
|
@@ -183,6 +193,7 @@ import $n_isFunction from 'lodash/isFunction'
|
|
|
183
193
|
import $n_findIndex from 'lodash/findIndex'
|
|
184
194
|
import $n_get from 'lodash/get'
|
|
185
195
|
|
|
196
|
+
import $n_indexOf from '@netang/utils/indexOf'
|
|
186
197
|
import $n_forEach from '@netang/utils/forEach'
|
|
187
198
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
188
199
|
import $n_join from '@netang/utils/join'
|
|
@@ -200,6 +211,8 @@ import $n_$table from '../../utils/$table'
|
|
|
200
211
|
|
|
201
212
|
import { configs } from '../../utils/config'
|
|
202
213
|
|
|
214
|
+
import $n_getImage from '../../utils/getImage'
|
|
215
|
+
|
|
203
216
|
const {
|
|
204
217
|
// 字典常量
|
|
205
218
|
dicts,
|
|
@@ -406,14 +419,14 @@ export default {
|
|
|
406
419
|
// 刷新后清空已选数据
|
|
407
420
|
refreshResetSelected: false,
|
|
408
421
|
// 自定义请求方法
|
|
409
|
-
async request({ httpOptions }) {
|
|
422
|
+
async request({ httpOptions, props: httpProps }) {
|
|
410
423
|
return $n_isFunction(props.request) ?
|
|
411
424
|
// 如果有自定义请求方法
|
|
412
425
|
await $n_runAsync(props.request)({
|
|
413
426
|
// http 请求参数
|
|
414
427
|
httpOptions,
|
|
415
428
|
// 对话框是否已显示
|
|
416
|
-
showDialog: showDialog.value,
|
|
429
|
+
showDialog: $n_get(httpProps, 'showDialog') === 1 ? true : showDialog.value,
|
|
417
430
|
}) :
|
|
418
431
|
// 否则请求数据
|
|
419
432
|
await $n_http(httpOptions)
|
|
@@ -996,7 +1009,6 @@ export default {
|
|
|
996
1009
|
*/
|
|
997
1010
|
let _dialogShowed = false
|
|
998
1011
|
function onDialogShow() {
|
|
999
|
-
|
|
1000
1012
|
if ($n_isFunction(props.request)) {
|
|
1001
1013
|
|
|
1002
1014
|
if (_dialogShowed) {
|
|
@@ -1037,10 +1049,20 @@ export default {
|
|
|
1037
1049
|
isReload = false
|
|
1038
1050
|
}
|
|
1039
1051
|
|
|
1040
|
-
//
|
|
1041
|
-
|
|
1052
|
+
// 获取表格搜索值
|
|
1053
|
+
let searchValue = $table.getTableSearchValue()
|
|
1054
|
+
if (searchValue.length) {
|
|
1055
|
+
|
|
1056
|
+
// 如果有隐藏搜索字段数组
|
|
1057
|
+
if ($n_isValidArray(props.hideSearchKeys)) {
|
|
1058
|
+
// 从搜索值数组中去除隐藏搜索字段的数组
|
|
1059
|
+
searchValue = searchValue.filter(e => $n_indexOf(e.field, props.hideSearchKeys) === -1)
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1042
1062
|
// 表格搜索重置
|
|
1043
|
-
$table.tableSearchReset(isReload
|
|
1063
|
+
$table.tableSearchReset(isReload && searchValue.length, {
|
|
1064
|
+
showDialog: 1,
|
|
1065
|
+
})
|
|
1044
1066
|
}
|
|
1045
1067
|
}
|
|
1046
1068
|
|
|
@@ -1127,6 +1149,32 @@ export default {
|
|
|
1127
1149
|
}
|
|
1128
1150
|
}
|
|
1129
1151
|
|
|
1152
|
+
/**
|
|
1153
|
+
* 格式化图片
|
|
1154
|
+
*/
|
|
1155
|
+
function formatImg(img, { count }) {
|
|
1156
|
+
|
|
1157
|
+
// 图片数组
|
|
1158
|
+
const imgs = []
|
|
1159
|
+
|
|
1160
|
+
// 转为图片数组
|
|
1161
|
+
const arr = $n_split(img, ',')
|
|
1162
|
+
for (const item of arr) {
|
|
1163
|
+
const src = $n_getImage(item)
|
|
1164
|
+
if (src) {
|
|
1165
|
+
imgs.push(item)
|
|
1166
|
+
if (
|
|
1167
|
+
count > 0
|
|
1168
|
+
&& imgs.length === count
|
|
1169
|
+
) {
|
|
1170
|
+
break
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
return imgs
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1130
1178
|
// ==========【生命周期】=========================================================================================
|
|
1131
1179
|
|
|
1132
1180
|
/**
|
|
@@ -1200,6 +1248,8 @@ export default {
|
|
|
1200
1248
|
|
|
1201
1249
|
// 触发更新值
|
|
1202
1250
|
emitModelValue,
|
|
1251
|
+
// 格式化图片
|
|
1252
|
+
formatImg,
|
|
1203
1253
|
}
|
|
1204
1254
|
},
|
|
1205
1255
|
}
|
|
@@ -109,15 +109,26 @@
|
|
|
109
109
|
>
|
|
110
110
|
<!-- 图片 -->
|
|
111
111
|
<template
|
|
112
|
-
v-for="
|
|
113
|
-
v-slot:[`body-cell-${
|
|
112
|
+
v-for="imgItem in tableImgs"
|
|
113
|
+
v-slot:[`body-cell-${imgItem.name}`]="props"
|
|
114
114
|
>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
115
|
+
<n-data
|
|
116
|
+
:data="formatImg(props.row[imgItem.name], imgItem)"
|
|
117
|
+
v-slot="{ data }"
|
|
118
|
+
>
|
|
119
|
+
<!-- 缩略图 -->
|
|
120
|
+
<n-thumbnail
|
|
121
|
+
v-for="(item, index) in data"
|
|
122
|
+
:key="`thumbnail-item-${item}`"
|
|
123
|
+
class="n-table__thumbnail"
|
|
124
|
+
:src="item"
|
|
125
|
+
preview
|
|
126
|
+
:preview-props="{
|
|
127
|
+
startPosition: index,
|
|
128
|
+
images: data,
|
|
129
|
+
}"
|
|
130
|
+
/>
|
|
131
|
+
</n-data>
|
|
121
132
|
</template>
|
|
122
133
|
|
|
123
134
|
<!-- 插槽 -->
|
|
@@ -194,6 +205,7 @@ import { ref, watch, computed, inject, onMounted } from 'vue'
|
|
|
194
205
|
import $n_isFunction from 'lodash/isFunction'
|
|
195
206
|
import $n_isNil from 'lodash/isNil'
|
|
196
207
|
|
|
208
|
+
import $n_split from '@netang/utils/split'
|
|
197
209
|
import $n_isValidObject from '@netang/utils/isValidObject'
|
|
198
210
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
199
211
|
import $n_isValidValue from '@netang/utils/isValidValue'
|
|
@@ -209,6 +221,8 @@ import NTableSummary from '../table-summary'
|
|
|
209
221
|
import NTablePagination from '../table-pagination'
|
|
210
222
|
import NSearch from '../search'
|
|
211
223
|
|
|
224
|
+
import $n_getImage from '../../utils/getImage'
|
|
225
|
+
|
|
212
226
|
export default {
|
|
213
227
|
|
|
214
228
|
/**
|
|
@@ -451,6 +465,32 @@ export default {
|
|
|
451
465
|
})
|
|
452
466
|
}
|
|
453
467
|
|
|
468
|
+
/**
|
|
469
|
+
* 格式化图片
|
|
470
|
+
*/
|
|
471
|
+
function formatImg(img, { count }) {
|
|
472
|
+
|
|
473
|
+
// 图片数组
|
|
474
|
+
const imgs = []
|
|
475
|
+
|
|
476
|
+
// 转为图片数组
|
|
477
|
+
const arr = $n_split(img, ',')
|
|
478
|
+
for (const item of arr) {
|
|
479
|
+
const src = $n_getImage(item)
|
|
480
|
+
if (src) {
|
|
481
|
+
imgs.push(item)
|
|
482
|
+
if (
|
|
483
|
+
count > 0
|
|
484
|
+
&& imgs.length === count
|
|
485
|
+
) {
|
|
486
|
+
break
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return imgs
|
|
492
|
+
}
|
|
493
|
+
|
|
454
494
|
// ==========【生命周期】=========================================================================================
|
|
455
495
|
|
|
456
496
|
/**
|
|
@@ -484,6 +524,8 @@ export default {
|
|
|
484
524
|
|
|
485
525
|
// 当前双击表格行
|
|
486
526
|
currentTableRowDblclick,
|
|
527
|
+
// 格式化图片
|
|
528
|
+
formatImg,
|
|
487
529
|
}
|
|
488
530
|
},
|
|
489
531
|
}
|
|
@@ -123,6 +123,7 @@ import $n_get from 'lodash/get'
|
|
|
123
123
|
import $n_isFunction from 'lodash/isFunction'
|
|
124
124
|
import $n_findIndex from 'lodash/findIndex'
|
|
125
125
|
|
|
126
|
+
import $n_trimString from '@netang/utils/trimString'
|
|
126
127
|
import $n_isValidArray from '@netang/utils/isValidArray'
|
|
127
128
|
import $n_indexOf from '@netang/utils/indexOf'
|
|
128
129
|
import $n_on from '@netang/utils/on'
|
|
@@ -342,8 +343,8 @@ export default {
|
|
|
342
343
|
props.filterMethod !== void 0
|
|
343
344
|
? props.filterMethod
|
|
344
345
|
: function (node, filter) {
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
const label = $n_trimString(node[ props.labelKey ])
|
|
347
|
+
return label && label.toLowerCase().indexOf(filter.toLowerCase()) > -1
|
|
347
348
|
}
|
|
348
349
|
))
|
|
349
350
|
|
package/package.json
CHANGED
package/sass/quasar/table.scss
CHANGED
package/utils/$table.js
CHANGED
|
@@ -145,7 +145,7 @@ function create(options) {
|
|
|
145
145
|
let isCache
|
|
146
146
|
let cacheName
|
|
147
147
|
let tableColumns
|
|
148
|
-
let
|
|
148
|
+
let tableImgs
|
|
149
149
|
|
|
150
150
|
// 是否显示可见列
|
|
151
151
|
let tableShowVisibleColumns
|
|
@@ -279,11 +279,11 @@ function create(options) {
|
|
|
279
279
|
})
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
//
|
|
282
|
+
// 表格图片
|
|
283
283
|
if (_isCreated) {
|
|
284
|
-
|
|
284
|
+
tableImgs.value = []
|
|
285
285
|
} else {
|
|
286
|
-
|
|
286
|
+
tableImgs = ref([])
|
|
287
287
|
}
|
|
288
288
|
|
|
289
289
|
// 设置表格列数据
|
|
@@ -318,8 +318,11 @@ function create(options) {
|
|
|
318
318
|
item.format = val => $n_dict(item.dict, val)
|
|
319
319
|
|
|
320
320
|
// 如果有图片
|
|
321
|
-
} else if ($n_has(item, 'img')
|
|
322
|
-
|
|
321
|
+
} else if ($n_has(item, 'img')) {
|
|
322
|
+
tableImgs.value.push({
|
|
323
|
+
name: item.name,
|
|
324
|
+
count: item.img === true ? 1 : item.img,
|
|
325
|
+
})
|
|
323
326
|
|
|
324
327
|
// 如果有价格
|
|
325
328
|
} else if ($n_has(item, 'price')) {
|
|
@@ -733,7 +736,7 @@ function create(options) {
|
|
|
733
736
|
/**
|
|
734
737
|
* 表格重新加载
|
|
735
738
|
*/
|
|
736
|
-
async function tableReload() {
|
|
739
|
+
async function tableReload(params = null) {
|
|
737
740
|
|
|
738
741
|
// 表格已加载
|
|
739
742
|
_isTableLoaded = true
|
|
@@ -751,9 +754,10 @@ function create(options) {
|
|
|
751
754
|
// $tableRef?.requestServerInteraction({
|
|
752
755
|
// pagination: o.pagination,
|
|
753
756
|
// })
|
|
754
|
-
|
|
757
|
+
|
|
758
|
+
await tableRequest(Object.assign({
|
|
755
759
|
pagination: o.pagination,
|
|
756
|
-
})
|
|
760
|
+
}, params))
|
|
757
761
|
|
|
758
762
|
// 清空表格已选数据
|
|
759
763
|
if (o.refreshResetSelected) {
|
|
@@ -790,7 +794,7 @@ function create(options) {
|
|
|
790
794
|
/**
|
|
791
795
|
* 表格搜索重置
|
|
792
796
|
*/
|
|
793
|
-
function tableSearchReset(reload = true) {
|
|
797
|
+
function tableSearchReset(reload = true, params = null) {
|
|
794
798
|
|
|
795
799
|
const newValue = []
|
|
796
800
|
|
|
@@ -809,7 +813,8 @@ function create(options) {
|
|
|
809
813
|
|
|
810
814
|
// 表格重新加载
|
|
811
815
|
if (reload) {
|
|
812
|
-
tableReload()
|
|
816
|
+
tableReload(params)
|
|
817
|
+
.finally()
|
|
813
818
|
}
|
|
814
819
|
}
|
|
815
820
|
|
|
@@ -1059,12 +1064,19 @@ function create(options) {
|
|
|
1059
1064
|
}
|
|
1060
1065
|
|
|
1061
1066
|
/**
|
|
1062
|
-
*
|
|
1067
|
+
* 获取表格搜索值
|
|
1063
1068
|
*/
|
|
1064
|
-
function
|
|
1065
|
-
return
|
|
1069
|
+
function getTableSearchValue() {
|
|
1070
|
+
return formatValue(rawSearchOptions, tableSearchValue.value)
|
|
1066
1071
|
}
|
|
1067
1072
|
|
|
1073
|
+
/**
|
|
1074
|
+
* 是否有表格搜索值
|
|
1075
|
+
*/
|
|
1076
|
+
// function hasTableSearchValue() {
|
|
1077
|
+
// return !! formatValue(rawSearchOptions, tableSearchValue.value).length
|
|
1078
|
+
// }
|
|
1079
|
+
|
|
1068
1080
|
// ==========【返回】=================================================================================================
|
|
1069
1081
|
|
|
1070
1082
|
const resTable = {
|
|
@@ -1101,8 +1113,8 @@ function create(options) {
|
|
|
1101
1113
|
tableFixedPowerBtns,
|
|
1102
1114
|
// 是否显示固定在右边的权限按钮列表
|
|
1103
1115
|
showTableFixed,
|
|
1104
|
-
//
|
|
1105
|
-
|
|
1116
|
+
// 表格图片
|
|
1117
|
+
tableImgs,
|
|
1106
1118
|
|
|
1107
1119
|
// 表格宫格
|
|
1108
1120
|
tableGrid,
|
|
@@ -1136,8 +1148,10 @@ function create(options) {
|
|
|
1136
1148
|
// 设置表格搜索参数
|
|
1137
1149
|
setTableSearchOptions,
|
|
1138
1150
|
|
|
1151
|
+
// 获取表格搜索值
|
|
1152
|
+
getTableSearchValue,
|
|
1139
1153
|
// 是否有表格搜索值
|
|
1140
|
-
hasTableSearchValue,
|
|
1154
|
+
// hasTableSearchValue,
|
|
1141
1155
|
|
|
1142
1156
|
// 获取当前路由
|
|
1143
1157
|
getRoute() {
|