@netang/quasar 0.1.66 → 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
|
<!-- 插槽 -->
|
|
@@ -201,6 +211,8 @@ import $n_$table from '../../utils/$table'
|
|
|
201
211
|
|
|
202
212
|
import { configs } from '../../utils/config'
|
|
203
213
|
|
|
214
|
+
import $n_getImage from '../../utils/getImage'
|
|
215
|
+
|
|
204
216
|
const {
|
|
205
217
|
// 字典常量
|
|
206
218
|
dicts,
|
|
@@ -407,14 +419,14 @@ export default {
|
|
|
407
419
|
// 刷新后清空已选数据
|
|
408
420
|
refreshResetSelected: false,
|
|
409
421
|
// 自定义请求方法
|
|
410
|
-
async request({ httpOptions, props }) {
|
|
422
|
+
async request({ httpOptions, props: httpProps }) {
|
|
411
423
|
return $n_isFunction(props.request) ?
|
|
412
424
|
// 如果有自定义请求方法
|
|
413
425
|
await $n_runAsync(props.request)({
|
|
414
426
|
// http 请求参数
|
|
415
427
|
httpOptions,
|
|
416
428
|
// 对话框是否已显示
|
|
417
|
-
showDialog: $n_get(
|
|
429
|
+
showDialog: $n_get(httpProps, 'showDialog') === 1 ? true : showDialog.value,
|
|
418
430
|
}) :
|
|
419
431
|
// 否则请求数据
|
|
420
432
|
await $n_http(httpOptions)
|
|
@@ -1137,6 +1149,32 @@ export default {
|
|
|
1137
1149
|
}
|
|
1138
1150
|
}
|
|
1139
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
|
+
|
|
1140
1178
|
// ==========【生命周期】=========================================================================================
|
|
1141
1179
|
|
|
1142
1180
|
/**
|
|
@@ -1210,6 +1248,8 @@ export default {
|
|
|
1210
1248
|
|
|
1211
1249
|
// 触发更新值
|
|
1212
1250
|
emitModelValue,
|
|
1251
|
+
// 格式化图片
|
|
1252
|
+
formatImg,
|
|
1213
1253
|
}
|
|
1214
1254
|
},
|
|
1215
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')) {
|
|
@@ -1110,8 +1113,8 @@ function create(options) {
|
|
|
1110
1113
|
tableFixedPowerBtns,
|
|
1111
1114
|
// 是否显示固定在右边的权限按钮列表
|
|
1112
1115
|
showTableFixed,
|
|
1113
|
-
//
|
|
1114
|
-
|
|
1116
|
+
// 表格图片
|
|
1117
|
+
tableImgs,
|
|
1115
1118
|
|
|
1116
1119
|
// 表格宫格
|
|
1117
1120
|
tableGrid,
|