vxe-table 3.12.0-beta.11 → 3.12.0-beta.13
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/es/style.css +1 -1
- package/es/table/module/export/mixin.js +173 -118
- package/es/toolbar/src/toolbar.js +20 -2
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/ui/src/vn.js +3 -0
- package/lib/index.umd.js +239 -139
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/export/mixin.js +197 -135
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +36 -2
- package/lib/toolbar/src/toolbar.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/ui/src/vn.js +3 -0
- package/lib/ui/src/vn.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/module/export/mixin.ts +185 -128
- package/packages/toolbar/src/toolbar.ts +23 -5
- package/packages/ui/src/vn.ts +4 -1
- /package/es/{iconfont.1735528767577.ttf → iconfont.1735542540986.ttf} +0 -0
- /package/es/{iconfont.1735528767577.woff → iconfont.1735542540986.woff} +0 -0
- /package/es/{iconfont.1735528767577.woff2 → iconfont.1735542540986.woff2} +0 -0
- /package/lib/{iconfont.1735528767577.ttf → iconfont.1735542540986.ttf} +0 -0
- /package/lib/{iconfont.1735528767577.woff → iconfont.1735542540986.woff} +0 -0
- /package/lib/{iconfont.1735528767577.woff2 → iconfont.1735542540986.woff2} +0 -0
|
@@ -2,10 +2,11 @@ import XEUtils from 'xe-utils'
|
|
|
2
2
|
import { VxeUI } from '../../../ui'
|
|
3
3
|
import { isColumnInfo, mergeBodyMethod, getCellValue } from '../../src/util'
|
|
4
4
|
import { parseFile, formatText, eqEmptyValue } from '../../../ui/src/utils'
|
|
5
|
-
import { browse } from '../../../ui/src/dom'
|
|
6
5
|
import { createHtmlPage, getExportBlobByContent } from './util'
|
|
7
6
|
import { warnLog, errLog } from '../../../ui/src/log'
|
|
8
7
|
|
|
8
|
+
import type { VxeTablePropTypes, VxeGridConstructor, VxeTableDefines, VxeGridPropTypes, GridReactData } from '../../../../types'
|
|
9
|
+
|
|
9
10
|
const { getI18n, renderer } = VxeUI
|
|
10
11
|
|
|
11
12
|
let htmlCellElem: any
|
|
@@ -14,18 +15,9 @@ let htmlCellElem: any
|
|
|
14
15
|
let fileForm: any
|
|
15
16
|
let fileInput: any
|
|
16
17
|
|
|
17
|
-
// 打印
|
|
18
|
-
let printFrame: any
|
|
19
|
-
|
|
20
18
|
const csvBOM = '\ufeff'
|
|
21
19
|
const enterSymbol = '\r\n'
|
|
22
20
|
|
|
23
|
-
function createFrame () {
|
|
24
|
-
const frame = document.createElement('iframe')
|
|
25
|
-
frame.className = 'vxe-table--print-frame'
|
|
26
|
-
return frame
|
|
27
|
-
}
|
|
28
|
-
|
|
29
21
|
function hasTreeChildren ($xetable: any, row: any) {
|
|
30
22
|
const treeOpts = $xetable.treeOpts
|
|
31
23
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -611,17 +603,19 @@ function clearColumnConvert (columns: any) {
|
|
|
611
603
|
}, { children: 'children' })
|
|
612
604
|
}
|
|
613
605
|
|
|
614
|
-
function handleExport ($
|
|
606
|
+
function handleExport ($xeTable: any, opts: VxeTablePropTypes.ExportHandleOptions) {
|
|
607
|
+
const $xeGrid = $xeTable.$xeGrid
|
|
608
|
+
|
|
615
609
|
const { remote, columns, colgroups, exportMethod, afterExportMethod } = opts
|
|
616
610
|
return new Promise(resolve => {
|
|
617
611
|
if (remote) {
|
|
618
|
-
const params = { options: opts, $table: $
|
|
612
|
+
const params = { options: opts, $table: $xeTable, $grid: $xeGrid }
|
|
619
613
|
resolve(exportMethod ? exportMethod(params) : params)
|
|
620
614
|
} else {
|
|
621
|
-
const datas = getExportData($
|
|
615
|
+
const datas = getExportData($xeTable, opts)
|
|
622
616
|
resolve(
|
|
623
|
-
$
|
|
624
|
-
return downloadFile($
|
|
617
|
+
$xeTable.preventEvent(null, 'event.export', { options: opts, columns, colgroups, datas }, () => {
|
|
618
|
+
return downloadFile($xeTable, opts, getContent($xeTable, opts, columns, datas))
|
|
625
619
|
})
|
|
626
620
|
)
|
|
627
621
|
}
|
|
@@ -629,7 +623,7 @@ function handleExport ($xetable: any, opts: any) {
|
|
|
629
623
|
clearColumnConvert(columns)
|
|
630
624
|
if (!opts.print) {
|
|
631
625
|
if (afterExportMethod) {
|
|
632
|
-
afterExportMethod({ status: true, options: opts, $table: $
|
|
626
|
+
afterExportMethod({ status: true, options: opts, $table: $xeTable, $grid: $xeGrid })
|
|
633
627
|
}
|
|
634
628
|
}
|
|
635
629
|
return Object.assign({ status: true }, params)
|
|
@@ -637,7 +631,7 @@ function handleExport ($xetable: any, opts: any) {
|
|
|
637
631
|
clearColumnConvert(columns)
|
|
638
632
|
if (!opts.print) {
|
|
639
633
|
if (afterExportMethod) {
|
|
640
|
-
afterExportMethod({ status: false, options: opts, $table: $
|
|
634
|
+
afterExportMethod({ status: false, options: opts, $table: $xeTable, $grid: $xeGrid })
|
|
641
635
|
}
|
|
642
636
|
}
|
|
643
637
|
const params = { status: false }
|
|
@@ -987,60 +981,12 @@ export function readLocalFile (options: any = {}) {
|
|
|
987
981
|
})
|
|
988
982
|
}
|
|
989
983
|
|
|
990
|
-
function
|
|
991
|
-
|
|
992
|
-
if (printFrame.parentNode) {
|
|
993
|
-
try {
|
|
994
|
-
printFrame.contentDocument.write('')
|
|
995
|
-
} catch (e) { }
|
|
996
|
-
printFrame.parentNode.removeChild(printFrame)
|
|
997
|
-
}
|
|
998
|
-
printFrame = null
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
function appendPrintFrame () {
|
|
1003
|
-
if (!printFrame.parentNode) {
|
|
1004
|
-
document.body.appendChild(printFrame)
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
|
|
1008
|
-
function afterPrintEvent () {
|
|
1009
|
-
requestAnimationFrame(removePrintFrame)
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
export function handlePrint ($xetable: any, opts: any, content: any) {
|
|
1013
|
-
const { beforePrintMethod } = opts
|
|
1014
|
-
if (beforePrintMethod) {
|
|
1015
|
-
content = beforePrintMethod({ content, options: opts, $table: $xetable }) || ''
|
|
1016
|
-
}
|
|
1017
|
-
content = createHtmlPage(opts, content)
|
|
1018
|
-
const blob = getExportBlobByContent(content, opts)
|
|
1019
|
-
if (browse.msie) {
|
|
1020
|
-
removePrintFrame()
|
|
1021
|
-
printFrame = createFrame()
|
|
1022
|
-
appendPrintFrame()
|
|
1023
|
-
printFrame.contentDocument.write(content)
|
|
1024
|
-
printFrame.contentDocument.execCommand('print')
|
|
1025
|
-
} else {
|
|
1026
|
-
if (!printFrame) {
|
|
1027
|
-
printFrame = createFrame()
|
|
1028
|
-
printFrame.onload = (evnt: any) => {
|
|
1029
|
-
if (evnt.target.src) {
|
|
1030
|
-
evnt.target.contentWindow.onafterprint = afterPrintEvent
|
|
1031
|
-
evnt.target.contentWindow.print()
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
}
|
|
1035
|
-
appendPrintFrame()
|
|
1036
|
-
printFrame.src = URL.createObjectURL(blob as any)
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
984
|
+
function handleExportAndPrint ($xeTable: any, options: VxeTablePropTypes.ExportOpts | VxeTablePropTypes.ExportConfig, isPrint?: any) {
|
|
985
|
+
const $xeGrid = $xeTable.$xeGrid
|
|
1039
986
|
|
|
1040
|
-
|
|
1041
|
-
const
|
|
1042
|
-
const
|
|
1043
|
-
const selectRecords = $xetable.getCheckboxRecords()
|
|
987
|
+
const { initStore, customOpts, collectColumn, footerTableData, treeConfig, mergeList, isGroup, exportParams, exportOpts } = $xeTable
|
|
988
|
+
const proxyOpts = $xeGrid ? $xeGrid.computeProxyOpts : {} as VxeGridPropTypes.ProxyOpts
|
|
989
|
+
const selectRecords = $xeTable.getCheckboxRecords()
|
|
1044
990
|
const hasFooter = !!footerTableData.length
|
|
1045
991
|
const hasTree = treeConfig
|
|
1046
992
|
const hasMerge = !hasTree && mergeList.length
|
|
@@ -1056,7 +1002,7 @@ function handleExportAndPrint ($xetable: any, options: any, isPrint?: any) {
|
|
|
1056
1002
|
const exportColumns = collectColumn.slice(0)
|
|
1057
1003
|
const { columns } = defOpts
|
|
1058
1004
|
// 处理类型
|
|
1059
|
-
const typeList = types.map((value
|
|
1005
|
+
const typeList = types.map((value) => {
|
|
1060
1006
|
return {
|
|
1061
1007
|
value,
|
|
1062
1008
|
label: getI18n(`vxe.export.types.${value}`)
|
|
@@ -1106,7 +1052,7 @@ function handleExportAndPrint ($xetable: any, options: any, isPrint?: any) {
|
|
|
1106
1052
|
}
|
|
1107
1053
|
})
|
|
1108
1054
|
// 更新条件
|
|
1109
|
-
Object.assign($
|
|
1055
|
+
Object.assign($xeTable.exportStore, {
|
|
1110
1056
|
columns: exportColumns,
|
|
1111
1057
|
typeList,
|
|
1112
1058
|
modeList,
|
|
@@ -1121,14 +1067,37 @@ function handleExportAndPrint ($xetable: any, options: any, isPrint?: any) {
|
|
|
1121
1067
|
Object.assign(exportParams, {
|
|
1122
1068
|
mode: selectRecords.length ? 'selected' : 'current'
|
|
1123
1069
|
}, defOpts)
|
|
1124
|
-
|
|
1070
|
+
const { filename, sheetName, mode, type } = exportParams
|
|
1071
|
+
if (filename) {
|
|
1072
|
+
if (XEUtils.isFunction(filename)) {
|
|
1073
|
+
exportParams.filename = filename({
|
|
1074
|
+
options: defOpts,
|
|
1075
|
+
$table: $xeTable,
|
|
1076
|
+
$grid: $xeGrid
|
|
1077
|
+
})
|
|
1078
|
+
} else {
|
|
1079
|
+
exportParams.filename = `${filename}`
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
if (sheetName) {
|
|
1083
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1084
|
+
exportParams.sheetName = sheetName({
|
|
1085
|
+
options: defOpts,
|
|
1086
|
+
$table: $xeTable,
|
|
1087
|
+
$grid: $xeGrid
|
|
1088
|
+
})
|
|
1089
|
+
} else {
|
|
1090
|
+
exportParams.sheetName = `${sheetName}`
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
if (!modeList.some(item => item.value === mode)) {
|
|
1125
1094
|
exportParams.mode = modeList[0].value
|
|
1126
1095
|
}
|
|
1127
|
-
if (!typeList.some(
|
|
1096
|
+
if (!typeList.some(item => item.value === type)) {
|
|
1128
1097
|
exportParams.type = typeList[0].value
|
|
1129
1098
|
}
|
|
1130
1099
|
initStore.export = true
|
|
1131
|
-
return $
|
|
1100
|
+
return $xeTable.$nextTick()
|
|
1132
1101
|
}
|
|
1133
1102
|
|
|
1134
1103
|
const getConvertColumns = (columns: any[]) => {
|
|
@@ -1194,11 +1163,14 @@ export default {
|
|
|
1194
1163
|
/**
|
|
1195
1164
|
* 导出文件,支持 csv/html/xml/txt
|
|
1196
1165
|
* 如果是树表格,则默认是导出所有节点
|
|
1197
|
-
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod
|
|
1166
|
+
* 如果是启用了虚拟滚动,则只能导出数据源,可以配合 dataFilterMethod 函数转换数据
|
|
1198
1167
|
* @param {Object} options 参数
|
|
1199
1168
|
*/
|
|
1200
1169
|
_exportData (options: any) {
|
|
1201
|
-
const
|
|
1170
|
+
const $xeTable = this
|
|
1171
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor
|
|
1172
|
+
|
|
1173
|
+
const { isGroup, tableGroupColumn, tableFullColumn, afterFullData, treeConfig, treeOpts, exportOpts } = this
|
|
1202
1174
|
const opts = Object.assign({
|
|
1203
1175
|
// filename: '',
|
|
1204
1176
|
// sheetName: '',
|
|
@@ -1223,13 +1195,13 @@ export default {
|
|
|
1223
1195
|
}, exportOpts, {
|
|
1224
1196
|
print: false
|
|
1225
1197
|
}, options)
|
|
1226
|
-
const { type, mode, columns, original,
|
|
1198
|
+
const { filename, sheetName, type, mode, columns, original, columnFilterMethod, beforeExportMethod, includeFields, excludeFields } = opts
|
|
1227
1199
|
let groups = []
|
|
1228
1200
|
const customCols = columns && columns.length ? columns : null
|
|
1201
|
+
const handleOptions: VxeTablePropTypes.ExportHandleOptions = Object.assign({ }, opts, { filename: '', sheetName: '', colgroups: [], columns: [], data: [] })
|
|
1229
1202
|
// 如果设置源数据,则默认导出设置了字段的列
|
|
1230
|
-
let columnFilterMethod = opts.columnFilterMethod
|
|
1231
1203
|
if (!customCols && !columnFilterMethod) {
|
|
1232
|
-
columnFilterMethod = ({ column }
|
|
1204
|
+
handleOptions.columnFilterMethod = ({ column }) => {
|
|
1233
1205
|
if (excludeFields) {
|
|
1234
1206
|
if (XEUtils.includes(excludeFields, column.field)) {
|
|
1235
1207
|
return false
|
|
@@ -1245,27 +1217,27 @@ export default {
|
|
|
1245
1217
|
}
|
|
1246
1218
|
}
|
|
1247
1219
|
if (customCols) {
|
|
1248
|
-
|
|
1220
|
+
handleOptions._isCustomColumn = true
|
|
1249
1221
|
groups = XEUtils.searchTree(
|
|
1250
|
-
XEUtils.mapTree(customCols, item => {
|
|
1222
|
+
XEUtils.mapTree(customCols, (item) => {
|
|
1251
1223
|
let targetColumn
|
|
1252
1224
|
if (item) {
|
|
1253
1225
|
if (isColumnInfo(item)) {
|
|
1254
1226
|
targetColumn = item
|
|
1255
1227
|
} else if (XEUtils.isString(item)) {
|
|
1256
|
-
targetColumn =
|
|
1228
|
+
targetColumn = $xeTable.getColumnByField(item)
|
|
1257
1229
|
} else {
|
|
1258
1230
|
const colid = item.id || item.colId
|
|
1259
1231
|
const type = item.type
|
|
1260
1232
|
const field = item.field
|
|
1261
1233
|
if (colid) {
|
|
1262
|
-
targetColumn =
|
|
1234
|
+
targetColumn = $xeTable.getColumnById(colid)
|
|
1263
1235
|
} else if (field && type) {
|
|
1264
|
-
targetColumn = tableFullColumn.find((column:
|
|
1236
|
+
targetColumn = tableFullColumn.find((column: VxeTableDefines.ColumnInfo) => column.field === field && column.type === type)
|
|
1265
1237
|
} else if (field) {
|
|
1266
|
-
targetColumn =
|
|
1238
|
+
targetColumn = $xeTable.getColumnByField(field)
|
|
1267
1239
|
} else if (type) {
|
|
1268
|
-
targetColumn = tableFullColumn.find((column:
|
|
1240
|
+
targetColumn = tableFullColumn.find((column: VxeTableDefines.ColumnInfo) => column.type === type)
|
|
1269
1241
|
}
|
|
1270
1242
|
}
|
|
1271
1243
|
return targetColumn || {}
|
|
@@ -1274,7 +1246,7 @@ export default {
|
|
|
1274
1246
|
children: 'childNodes',
|
|
1275
1247
|
mapChildren: '_children'
|
|
1276
1248
|
}),
|
|
1277
|
-
(column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })),
|
|
1249
|
+
(column, index) => isColumnInfo(column) && (!columnFilterMethod || columnFilterMethod({ column: column as any, $columnIndex: index })),
|
|
1278
1250
|
{
|
|
1279
1251
|
children: '_children',
|
|
1280
1252
|
mapChildren: 'childNodes',
|
|
@@ -1285,7 +1257,7 @@ export default {
|
|
|
1285
1257
|
groups = XEUtils.searchTree(isGroup ? tableGroupColumn : tableFullColumn, (column, index) => column.visible && (!columnFilterMethod || columnFilterMethod({ column, $columnIndex: index })), { children: 'children', mapChildren: 'childNodes', original: true })
|
|
1286
1258
|
}
|
|
1287
1259
|
// 获取所有列
|
|
1288
|
-
const cols:
|
|
1260
|
+
const cols: VxeTableDefines.ColumnInfo[] = []
|
|
1289
1261
|
XEUtils.eachTree(groups, column => {
|
|
1290
1262
|
const isColGroup = column.children && column.children.length
|
|
1291
1263
|
if (!isColGroup) {
|
|
@@ -1293,17 +1265,40 @@ export default {
|
|
|
1293
1265
|
}
|
|
1294
1266
|
}, { children: 'childNodes' })
|
|
1295
1267
|
// 构建分组层级
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1268
|
+
handleOptions.columns = cols
|
|
1269
|
+
handleOptions.colgroups = convertToRows(groups)
|
|
1270
|
+
if (filename) {
|
|
1271
|
+
if (XEUtils.isFunction(filename)) {
|
|
1272
|
+
handleOptions.filename = filename({
|
|
1273
|
+
options: opts,
|
|
1274
|
+
$table: $xeTable,
|
|
1275
|
+
$grid: $xeGrid
|
|
1276
|
+
})
|
|
1277
|
+
} else {
|
|
1278
|
+
handleOptions.filename = `${filename}`
|
|
1279
|
+
}
|
|
1300
1280
|
}
|
|
1301
|
-
if (!
|
|
1302
|
-
|
|
1281
|
+
if (!handleOptions.filename) {
|
|
1282
|
+
handleOptions.filename = getI18n(handleOptions.original ? 'vxe.table.expOriginFilename' : 'vxe.table.expFilename', [XEUtils.toDateString(Date.now(), 'yyyyMMddHHmmss')])
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
if (sheetName) {
|
|
1286
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1287
|
+
handleOptions.sheetName = sheetName({
|
|
1288
|
+
options: opts,
|
|
1289
|
+
$table: $xeTable,
|
|
1290
|
+
$grid: $xeGrid
|
|
1291
|
+
})
|
|
1292
|
+
} else {
|
|
1293
|
+
handleOptions.sheetName = `${sheetName}`
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
if (!handleOptions.sheetName) {
|
|
1297
|
+
handleOptions.sheetName = document.title || ''
|
|
1303
1298
|
}
|
|
1304
1299
|
|
|
1305
1300
|
// 检查类型,如果为自定义导出,则不需要校验类型
|
|
1306
|
-
if (!
|
|
1301
|
+
if (!handleOptions.exportMethod && !XEUtils.includes(XEUtils.keys(exportOpts._typeMaps), type)) {
|
|
1307
1302
|
errLog('vxe.error.notType', [type])
|
|
1308
1303
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1309
1304
|
if (['xlsx', 'pdf'].includes(type)) {
|
|
@@ -1314,30 +1309,34 @@ export default {
|
|
|
1314
1309
|
return Promise.reject(params)
|
|
1315
1310
|
}
|
|
1316
1311
|
|
|
1317
|
-
if (!
|
|
1312
|
+
if (!handleOptions.print) {
|
|
1318
1313
|
if (beforeExportMethod) {
|
|
1319
|
-
beforeExportMethod({ options:
|
|
1314
|
+
beforeExportMethod({ options: handleOptions, $table: $xeTable, $grid: $xeGrid })
|
|
1320
1315
|
}
|
|
1321
1316
|
}
|
|
1322
1317
|
|
|
1323
1318
|
if (!opts.data) {
|
|
1324
|
-
|
|
1319
|
+
handleOptions.data = []
|
|
1325
1320
|
if (mode === 'selected') {
|
|
1326
|
-
const selectRecords =
|
|
1321
|
+
const selectRecords = $xeTable.getCheckboxRecords()
|
|
1327
1322
|
if (['html', 'pdf'].indexOf(type) > -1 && treeConfig) {
|
|
1328
|
-
opts.data = XEUtils.searchTree(
|
|
1323
|
+
opts.data = XEUtils.searchTree($xeTable.getTableData().fullData, item => $xeTable.findRowIndexOf(selectRecords, item) > -1, Object.assign({}, treeOpts, { data: '_row' }))
|
|
1329
1324
|
} else {
|
|
1330
1325
|
opts.data = selectRecords
|
|
1331
1326
|
}
|
|
1332
1327
|
} else if (mode === 'all') {
|
|
1333
1328
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1334
|
-
if (!$
|
|
1329
|
+
if (!$xeGrid) {
|
|
1335
1330
|
warnLog('vxe.error.errProp', ['all', 'mode=current,selected'])
|
|
1336
1331
|
}
|
|
1337
1332
|
}
|
|
1338
1333
|
|
|
1339
|
-
if ($
|
|
1340
|
-
const
|
|
1334
|
+
if ($xeGrid && !handleOptions.remote) {
|
|
1335
|
+
const gridReactData = $xeGrid as unknown as GridReactData
|
|
1336
|
+
const proxyOpts = $xeGrid.computeProxyOpts
|
|
1337
|
+
const { sortData } = gridReactData
|
|
1338
|
+
const { beforeQueryAll, afterQueryAll, ajax = {} } = proxyOpts
|
|
1339
|
+
const resConfigs = proxyOpts.response || proxyOpts.props || {}
|
|
1341
1340
|
const ajaxMethods = ajax.queryAll
|
|
1342
1341
|
const queryAllSuccessMethods = ajax.queryAllSuccess
|
|
1343
1342
|
const queryAllErrorMethods = ajax.queryAllError
|
|
@@ -1350,24 +1349,25 @@ export default {
|
|
|
1350
1349
|
|
|
1351
1350
|
if (ajaxMethods) {
|
|
1352
1351
|
const params = {
|
|
1353
|
-
$table:
|
|
1354
|
-
$grid: $
|
|
1355
|
-
sort:
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
options:
|
|
1352
|
+
$table: $xeTable,
|
|
1353
|
+
$grid: $xeGrid,
|
|
1354
|
+
sort: sortData.length ? sortData[0] : {} as any,
|
|
1355
|
+
sorts: sortData as any[],
|
|
1356
|
+
filters: gridReactData.filterData,
|
|
1357
|
+
form: gridReactData.formData,
|
|
1358
|
+
options: handleOptions
|
|
1360
1359
|
}
|
|
1361
1360
|
return Promise.resolve((beforeQueryAll || ajaxMethods)(params))
|
|
1362
1361
|
.then(rest => {
|
|
1363
|
-
|
|
1362
|
+
const listProp = resConfigs.list
|
|
1363
|
+
handleOptions.data = (listProp ? (XEUtils.isFunction(listProp) ? listProp({ data: rest, $grid: $xeGrid }) : XEUtils.get(rest, listProp)) : rest) || []
|
|
1364
1364
|
if (afterQueryAll) {
|
|
1365
1365
|
afterQueryAll(params)
|
|
1366
1366
|
}
|
|
1367
1367
|
if (queryAllSuccessMethods) {
|
|
1368
1368
|
queryAllSuccessMethods({ ...params, response: rest })
|
|
1369
1369
|
}
|
|
1370
|
-
return handleExport(
|
|
1370
|
+
return handleExport($xeTable, handleOptions)
|
|
1371
1371
|
})
|
|
1372
1372
|
.catch((rest) => {
|
|
1373
1373
|
if (queryAllErrorMethods) {
|
|
@@ -1377,10 +1377,10 @@ export default {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
}
|
|
1379
1379
|
} else if (mode === 'current') {
|
|
1380
|
-
|
|
1380
|
+
handleOptions.data = afterFullData
|
|
1381
1381
|
}
|
|
1382
1382
|
}
|
|
1383
|
-
return handleExport(
|
|
1383
|
+
return handleExport($xeTable, opts)
|
|
1384
1384
|
},
|
|
1385
1385
|
_importByFile (file: any, options: any) {
|
|
1386
1386
|
const opts = Object.assign({}, options)
|
|
@@ -1418,6 +1418,9 @@ export default {
|
|
|
1418
1418
|
return readLocalFile(options)
|
|
1419
1419
|
},
|
|
1420
1420
|
_print (options: any) {
|
|
1421
|
+
const $xeTable = this
|
|
1422
|
+
const $xeGrid = $xeTable.$xeGrid
|
|
1423
|
+
|
|
1421
1424
|
const opts = Object.assign({
|
|
1422
1425
|
original: false
|
|
1423
1426
|
// beforePrintMethod
|
|
@@ -1427,23 +1430,77 @@ export default {
|
|
|
1427
1430
|
remote: false,
|
|
1428
1431
|
print: true
|
|
1429
1432
|
})
|
|
1430
|
-
|
|
1431
|
-
|
|
1433
|
+
const { sheetName } = opts
|
|
1434
|
+
let printTitle = ''
|
|
1435
|
+
|
|
1436
|
+
if (sheetName) {
|
|
1437
|
+
if (XEUtils.isFunction(sheetName)) {
|
|
1438
|
+
printTitle = sheetName({
|
|
1439
|
+
options: opts,
|
|
1440
|
+
$table: $xeTable,
|
|
1441
|
+
$grid: $xeGrid
|
|
1442
|
+
})
|
|
1443
|
+
} else {
|
|
1444
|
+
printTitle = `${sheetName}`
|
|
1445
|
+
}
|
|
1432
1446
|
}
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1447
|
+
if (!printTitle) {
|
|
1448
|
+
printTitle = document.title || ''
|
|
1449
|
+
}
|
|
1450
|
+
|
|
1451
|
+
const beforePrintMethod = opts.beforePrintMethod
|
|
1452
|
+
const tableHtml = opts.html || opts.content
|
|
1453
|
+
return new Promise((resolve, reject) => {
|
|
1454
|
+
if (VxeUI.print) {
|
|
1455
|
+
if (tableHtml) {
|
|
1456
|
+
resolve(
|
|
1457
|
+
VxeUI.print({
|
|
1458
|
+
title: printTitle,
|
|
1459
|
+
html: tableHtml,
|
|
1460
|
+
customStyle: opts.style,
|
|
1461
|
+
beforeMethod: beforePrintMethod
|
|
1462
|
+
? ({ html }) => {
|
|
1463
|
+
return beforePrintMethod({
|
|
1464
|
+
html,
|
|
1465
|
+
content: html,
|
|
1466
|
+
options: opts,
|
|
1467
|
+
$table: $xeTable
|
|
1468
|
+
})
|
|
1469
|
+
}
|
|
1470
|
+
: undefined
|
|
1471
|
+
})
|
|
1472
|
+
)
|
|
1473
|
+
} else {
|
|
1474
|
+
resolve(
|
|
1475
|
+
$xeTable.exportData(opts).then(({ content }: any) => {
|
|
1476
|
+
return VxeUI.print({
|
|
1477
|
+
title: printTitle,
|
|
1478
|
+
html: content,
|
|
1479
|
+
customStyle: opts.style,
|
|
1480
|
+
beforeMethod: beforePrintMethod
|
|
1481
|
+
? ({ html }) => {
|
|
1482
|
+
return beforePrintMethod({
|
|
1483
|
+
html,
|
|
1484
|
+
content: html,
|
|
1485
|
+
options: opts,
|
|
1486
|
+
$table: $xeTable
|
|
1487
|
+
})
|
|
1488
|
+
}
|
|
1489
|
+
: undefined
|
|
1490
|
+
})
|
|
1491
|
+
})
|
|
1492
|
+
)
|
|
1493
|
+
}
|
|
1436
1494
|
} else {
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
return handlePrint(this, opts, content)
|
|
1440
|
-
})
|
|
1441
|
-
)
|
|
1495
|
+
const e = { status: false }
|
|
1496
|
+
reject(e)
|
|
1442
1497
|
}
|
|
1443
1498
|
})
|
|
1444
1499
|
},
|
|
1445
|
-
_getPrintHtml (options:
|
|
1446
|
-
const
|
|
1500
|
+
_getPrintHtml (options: VxeTablePropTypes.PrintConfig) {
|
|
1501
|
+
const $xeTable = this
|
|
1502
|
+
|
|
1503
|
+
const printOpts = $xeTable.computePrintOpts
|
|
1447
1504
|
const opts = Object.assign({
|
|
1448
1505
|
original: false
|
|
1449
1506
|
// beforePrintMethod
|
|
@@ -1453,7 +1510,7 @@ export default {
|
|
|
1453
1510
|
remote: false,
|
|
1454
1511
|
print: true
|
|
1455
1512
|
})
|
|
1456
|
-
return
|
|
1513
|
+
return $xeTable.exportData(opts).then(({ content }: any) => {
|
|
1457
1514
|
return {
|
|
1458
1515
|
html: content
|
|
1459
1516
|
}
|
|
@@ -5,7 +5,7 @@ import { VxeUI } from '../../ui'
|
|
|
5
5
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
6
6
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
7
7
|
|
|
8
|
-
import type { ValueOf, VxeButtonComponent, VxeComponentSizeType } from 'vxe-pc-ui'
|
|
8
|
+
import type { ValueOf, VxeButtonComponent, VxeComponentSizeType, VxeComponentSlotType } from 'vxe-pc-ui'
|
|
9
9
|
import type { VxeGridConstructor, GridPrivateMethods, ToolbarInternalData, VxeTablePrivateMethods, VxeTableDefines, VxeToolbarEmits, VxeToolbarPropTypes, VxeTableConstructor, VxeTablePropTypes, ToolbarReactData } from '../../../types'
|
|
10
10
|
|
|
11
11
|
const { getConfig, getIcon, getI18n, renderer, commands, createEvent, globalMixins, renderEmptyElement } = VxeUI
|
|
@@ -376,19 +376,25 @@ export default defineVxeComponent({
|
|
|
376
376
|
/**
|
|
377
377
|
* 渲染按钮
|
|
378
378
|
*/
|
|
379
|
-
|
|
379
|
+
renderLeftBtns (h: CreateElement): VxeComponentSlotType[] {
|
|
380
380
|
// 使用已安装的组件,如果未安装则不渲染
|
|
381
381
|
const VxeUIButtonComponent = VxeUI.getComponent<VxeButtonComponent>('VxeButton')
|
|
382
382
|
|
|
383
383
|
const $xeToolbar = this
|
|
384
384
|
const props = $xeToolbar
|
|
385
|
+
const slots = $xeToolbar.$scopedSlots
|
|
385
386
|
const internalData = $xeToolbar.internalData
|
|
386
387
|
const $xeGrid = $xeToolbar.$xeGrid
|
|
387
388
|
|
|
388
389
|
const { buttons } = props
|
|
389
390
|
const { connectTable } = internalData
|
|
390
391
|
const $table = connectTable
|
|
391
|
-
const
|
|
392
|
+
const buttonPrefixSlot = slots.buttonPrefix || slots['button-prefix']
|
|
393
|
+
const buttonSuffixSlot = slots.buttonSuffix || slots['button-suffix']
|
|
394
|
+
const btnVNs: VxeComponentSlotType[] = []
|
|
395
|
+
if (buttonPrefixSlot) {
|
|
396
|
+
btnVNs.push(...getSlotVNs(buttonPrefixSlot.call($xeToolbar, { buttons: buttons || [], $grid: $xeGrid, $table: $table })))
|
|
397
|
+
}
|
|
392
398
|
if (buttons) {
|
|
393
399
|
buttons.forEach((item) => {
|
|
394
400
|
const { dropdowns, buttonRender } = item
|
|
@@ -440,6 +446,9 @@ export default defineVxeComponent({
|
|
|
440
446
|
}
|
|
441
447
|
})
|
|
442
448
|
}
|
|
449
|
+
if (buttonSuffixSlot) {
|
|
450
|
+
btnVNs.push(...getSlotVNs(buttonSuffixSlot.call($xeToolbar, { buttons: buttons || [], $grid: $xeGrid, $table: $table })))
|
|
451
|
+
}
|
|
443
452
|
return btnVNs
|
|
444
453
|
},
|
|
445
454
|
/**
|
|
@@ -451,13 +460,19 @@ export default defineVxeComponent({
|
|
|
451
460
|
|
|
452
461
|
const $xeToolbar = this
|
|
453
462
|
const props = $xeToolbar
|
|
463
|
+
const slots = $xeToolbar.$scopedSlots
|
|
454
464
|
const internalData = $xeToolbar.internalData
|
|
455
465
|
const $xeGrid = $xeToolbar.$xeGrid
|
|
456
466
|
|
|
457
467
|
const { tools } = props
|
|
458
468
|
const { connectTable } = internalData
|
|
459
469
|
const $table = connectTable
|
|
460
|
-
const
|
|
470
|
+
const toolPrefixSlot = slots.toolPrefix || slots['tool-prefix']
|
|
471
|
+
const toolSuffixSlot = slots.toolSuffix || slots['tool-suffix']
|
|
472
|
+
const btnVNs: VxeComponentSlotType[] = []
|
|
473
|
+
if (toolPrefixSlot) {
|
|
474
|
+
btnVNs.push(...getSlotVNs(toolPrefixSlot.call($xeToolbar, { tools: tools || [], $grid: $xeGrid, $table: $table })))
|
|
475
|
+
}
|
|
461
476
|
if (tools) {
|
|
462
477
|
tools.forEach((item, tIndex) => {
|
|
463
478
|
const { dropdowns, toolRender } = item
|
|
@@ -512,6 +527,9 @@ export default defineVxeComponent({
|
|
|
512
527
|
}
|
|
513
528
|
})
|
|
514
529
|
}
|
|
530
|
+
if (toolSuffixSlot) {
|
|
531
|
+
btnVNs.push(...getSlotVNs(toolSuffixSlot.call($xeToolbar, { tools: tools || [], $grid: $xeGrid, $table: $table })))
|
|
532
|
+
}
|
|
515
533
|
return btnVNs
|
|
516
534
|
},
|
|
517
535
|
renderToolImport (h: CreateElement) {
|
|
@@ -680,7 +698,7 @@ export default defineVxeComponent({
|
|
|
680
698
|
}, [
|
|
681
699
|
h('div', {
|
|
682
700
|
class: 'vxe-buttons--wrapper'
|
|
683
|
-
}, buttonsSlot ? buttonsSlot({ $grid: $xeGrid, $table: $table }) : $xeToolbar.
|
|
701
|
+
}, buttonsSlot ? buttonsSlot({ $grid: $xeGrid, $table: $table }) : $xeToolbar.renderLeftBtns(h)),
|
|
684
702
|
h('div', {
|
|
685
703
|
class: 'vxe-tools--wrapper'
|
|
686
704
|
}, toolsSlot ? toolsSlot({ $grid: $xeGrid, $table: $table }) : $xeToolbar.renderRightTools(h)),
|
package/packages/ui/src/vn.ts
CHANGED
|
@@ -31,7 +31,10 @@ export function getChangeEvent (renderOpts: any) {
|
|
|
31
31
|
return 'change'
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function getSlotVNs (vns: VxeComponentSlotType | VxeComponentSlotType[]) {
|
|
34
|
+
export function getSlotVNs (vns: VxeComponentSlotType | VxeComponentSlotType[] | undefined) {
|
|
35
|
+
if (vns === null || vns === undefined) {
|
|
36
|
+
return []
|
|
37
|
+
}
|
|
35
38
|
if (XEUtils.isArray(vns)) {
|
|
36
39
|
return vns
|
|
37
40
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|