|
@@ -18,7 +18,7 @@ import { Message } from 'element-ui'
|
|
|
* @param {Object} config
|
|
|
* @return {Array}
|
|
|
*/
|
|
|
-export function mergeTableRow(config) {
|
|
|
+export function mergeTableRow (config) {
|
|
|
let data = config.data
|
|
|
const { mergeColNames, firstMergeColNames, firstMerge } = config
|
|
|
if (!mergeColNames || mergeColNames.length === 0) {
|
|
@@ -70,7 +70,7 @@ export function mergeTableRow(config) {
|
|
|
}
|
|
|
|
|
|
// 表格单元格class设置
|
|
|
-export function commonTableCellClass({ row, column, rowIndex, columnIndex }) {
|
|
|
+export function commonTableCellClass ({ row, column, rowIndex, columnIndex }) {
|
|
|
const classes = []
|
|
|
if (['actualDepartureTime', 'actualLandingTime'].includes(column.property)) {
|
|
|
classes.push('pre-line')
|
|
@@ -79,7 +79,7 @@ export function commonTableCellClass({ row, column, rowIndex, columnIndex }) {
|
|
|
}
|
|
|
|
|
|
// 获取对应时区的时间
|
|
|
-export function timeInZone(date, timeZone = 0, local = 8) {
|
|
|
+export function timeInZone (date, timeZone = 0, local = 8) {
|
|
|
if (!(date instanceof Date)) {
|
|
|
if (typeof date === 'string' && date.length) {
|
|
|
date = new Date(date)
|
|
@@ -88,7 +88,7 @@ export function timeInZone(date, timeZone = 0, local = 8) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function formatDate(num) {
|
|
|
+ function formatDate (num) {
|
|
|
return num < 10 ? '0' + num : num
|
|
|
}
|
|
|
const time = date.getTime() + (timeZone - local) * 60 * 60 * 1000
|
|
@@ -127,14 +127,14 @@ export function timeInZone(date, timeZone = 0, local = 8) {
|
|
|
// }
|
|
|
|
|
|
// 表格添加过滤条件
|
|
|
-export function setTableFilters(tableData, filters) {
|
|
|
+export function setTableFilters (tableData, filters) {
|
|
|
const tempSets = {}
|
|
|
Object.keys(filters).forEach(key => {
|
|
|
tempSets[key] = new Set()
|
|
|
})
|
|
|
tableData.forEach(item => {
|
|
|
Object.keys(tempSets).forEach(key => {
|
|
|
- ;(item[key] ?? '') !== '' && tempSets[key].add(String(item[key]))
|
|
|
+ ; (item[key] ?? '') !== '' && tempSets[key].add(String(item[key]))
|
|
|
})
|
|
|
})
|
|
|
Object.keys(tempSets).forEach(key => {
|
|
@@ -148,7 +148,7 @@ export function setTableFilters(tableData, filters) {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function devideGroup(cellName) {
|
|
|
+function devideGroup (cellName) {
|
|
|
const stringArray = cellName.split('')
|
|
|
const length = stringArray.length
|
|
|
let index = 0
|
|
@@ -164,7 +164,7 @@ function devideGroup(cellName) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-export function exportToExcel(table, tableName, fileName, headerRowNumber = 1) {
|
|
|
+export function exportToExcel (table, tableName, fileName, headerRowNumber = 1) {
|
|
|
try {
|
|
|
// 设置了列的fixed属性后会有两个table元素,导出数据会重复,需要去掉一个table
|
|
|
const fixedTable = table.querySelector('.el-table__fixed')
|
|
@@ -174,7 +174,9 @@ export function exportToExcel(table, tableName, fileName, headerRowNumber = 1) {
|
|
|
'.table-header-cell-popover'
|
|
|
)
|
|
|
tableHeaderCellPopovers.forEach(node => {
|
|
|
- node.removeChild(node.querySelector('.el-popover'))
|
|
|
+ if (node.querySelector('.el-popover')) {
|
|
|
+ node.removeChild(node.querySelector('.el-popover'))
|
|
|
+ }
|
|
|
})
|
|
|
// 生成要导出的xlsx数据,raw: true表示不使用excel的格式解析,输出为纯文本,sheet设置xlsx这一页的标题
|
|
|
const tableBook = XLSX.utils.table_to_book(table, {
|
|
@@ -242,7 +244,7 @@ export function exportToExcel(table, tableName, fileName, headerRowNumber = 1) {
|
|
|
}
|
|
|
} else {
|
|
|
cellStyle.alignment.horizontal = 'left'
|
|
|
-
|
|
|
+
|
|
|
const isNumber = /^[^0]/.test(cellValue) && !isNaN(parseFloat(cellValue)) && isFinite(cellValue)
|
|
|
if (isNumber) {
|
|
|
xlsxDatas[cellName] = {
|