Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let orderPrpo = order
if (params) {
let filterProps = XEUtils.keys(params).filter(key => !['sort', 'order'].includes(key) && params[key])
if (filterProps) {
rest = rest.filter(data => filterProps.every(key => String(data[key] || '').indexOf(params[key]) > -1))
}
if (params.order) {
orderPrpo = params.order
}
if (params.sort) {
sortProp = params.sort.split(',')
}
}
if (pathVariable) {
pageSize = XEUtils.toNumber(pathVariable[page && page.size ? page.size : 'pageSize']) || pageSize
currentPage = XEUtils.toNumber(pathVariable[page && page.current ? page.current : 'currentPage']) || currentPage
}
let totalResult = rest.length
rest = XEUtils.sortBy(rest, sortProp)
if (orderPrpo === 'desc') {
rest = rest.reverse()
}
response.body = {
page: { pageSize, currentPage, totalResult },
result: rest.slice((currentPage - 1) * pageSize, currentPage * pageSize)
}
return response
}
}
let isRequired = rule.required === true
if ((type === 'all' || !rule.trigger || type === rule.trigger) && (isRequired || value || rule.validator)) {
if (XEUtils.isFunction(rule.validator)) {
rule.validator(rule, value, e => {
if (XEUtils.isError(e)) {
let cusRule = { type: 'custom', message: e.message, rule }
return reject(cusRule)
}
return resolve(rule)
}, { rules, row, column })
} else {
let restVal
let isNumber = rule.type === 'number'
let isEmpty = value === null || value === undefined || value === ''
if (isNumber) {
restVal = XEUtils.toNumber(value)
} else {
restVal = isEmpty ? '' : '' + value
}
if (isRequired && isEmpty) {
reject(rule)
} else if (value &&
((isNumber && isNaN(value)) ||
(XEUtils.isRegExp(rule.pattern) && !rule.pattern.test(value)) ||
(XEUtils.isNumber(rule.min) && (isNumber ? restVal < rule.min : restVal.length < rule.min)) ||
(XEUtils.isNumber(rule.max) && (isNumber ? restVal > rule.max : restVal.length > rule.max)))
) {
reject(rule)
} else {
resolve(rule)
}
}
let sortProp = sort
let orderPrpo = order
if (params) {
let filterProps = XEUtils.keys(params).filter(key => !['sort', 'order'].includes(key) && params[key])
if (filterProps) {
rest = rest.filter(data => filterProps.every(key => String(data[key] || '').indexOf(params[key]) > -1))
}
if (params.order) {
orderPrpo = params.order
}
if (params.sort) {
sortProp = params.sort.split(',')
}
}
if (pathVariable) {
pageSize = XEUtils.toNumber(pathVariable[page && page.size ? page.size : 'pageSize']) || pageSize
currentPage = XEUtils.toNumber(pathVariable[page && page.current ? page.current : 'currentPage']) || currentPage
}
let totalResult = rest.length
rest = XEUtils.sortBy(rest, sortProp)
if (orderPrpo === 'desc') {
rest = rest.reverse()
}
response.body = {
page: { pageSize, currentPage, totalResult },
result: rest.slice((currentPage - 1) * pageSize, currentPage * pageSize)
}
return response
}
}
let sortProp = sort
let orderPrpo = order
if (params) {
let filterProps = XEUtils.keys(params).filter(key => !['sort', 'order'].includes(key) && params[key])
if (filterProps) {
rest = rest.filter(data => filterProps.every(key => String(data[key] || '').indexOf(params[key]) > -1))
}
if (params.order) {
orderPrpo = params.order
}
if (params.sort) {
sortProp = params.sort.split(',')
}
}
if (pathVariable) {
pageSize = XEUtils.toNumber(pathVariable[page && page.size ? page.size : 'pageSize']) || pageSize
currentPage = XEUtils.toNumber(pathVariable[page && page.current ? page.current : 'currentPage']) || currentPage
}
let totalResult = rest.length
rest = XEUtils.sortBy(rest, sortProp)
if (orderPrpo === 'desc') {
rest = rest.reverse()
}
response.body = {
page: { pageSize, currentPage, totalResult, total: totalResult },
result: rest.slice((currentPage - 1) * pageSize, currentPage * pageSize)
}
return response
}
}
countAmount (row) {
return XEUtils.toNumber(row.amount) * XEUtils.toNumber(row.number)
},
countAllAmount (data) {
formatColumnSize (row, column, cellValue, index) {
if (XEUtils.isNumber(cellValue)) {
let units = ['B', 'KB', 'MB', 'GB', 'TB']
let unit = ''
let size = XEUtils.toNumber(cellValue)
for (let index = 0; index < units.length; index++) {
unit = units[index]
if (size >= 1024) {
size = XEUtils.toFixedNumber(size / 1024, 2)
} else {
break
}
}
return `${size} ${unit}`
}
return ''
},
customMenuLinkEvent1 (code, row, column, cell) {
formatColumnSize (row, column, cellValue, index) {
cellValue = XEUtils.toNumber(cellValue)
if (cellValue) {
let units = ['B', 'KB', 'MB', 'GB', 'TB']
let unit = ''
let size = XEUtils.toNumber(cellValue)
for (let index = 0; index < units.length; index++) {
unit = units[index]
if (size >= 1024) {
size = XEUtils.toFixedNumber(size / 1024, 2)
} else {
break
}
}
return `${size} ${unit}`
}
return ''
},
height,
containerHeight,
vSize,
headerHeight,
footerHeight,
showHeader,
showFooter,
tableHeight,
scrollYWidth,
scrollXHeight,
scrollRightToLeft,
scrollLeftToRight,
columnStore,
footerData
} = $table
let customHeight = height === 'auto' ? containerHeight : XEUtils.toNumber(height)
let isRightFixed = fixedType === 'right'
let fixedColumn = columnStore[`${fixedType}List`]
let style = {
height: `${(customHeight > 0 ? customHeight - headerHeight - footerHeight : tableHeight) + headerHeight + footerHeight - scrollXHeight * (showFooter ? 2 : 1)}px`,
width: `${fixedColumn.reduce((previous, column) => previous + column.renderWidth, isRightFixed ? scrollYWidth : 0)}px`
}
return h('div', {
class: [`vxe-table--fixed-${fixedType}-wrapper`, {
'scrolling--middle': isRightFixed ? scrollRightToLeft : scrollLeftToRight
}],
style,
ref: `fixedTable`
}, [
showHeader ? h('vxe-table-header', {
props: {
fixedType,
formatterSize ({ cellValue }) {
let size = XEUtils.toNumber(cellValue)
if (size > 1024) {
if (size > 1048576) {
return `${XEUtils.toFixedNumber(size / 1048576, 2)}M`
}
return `${XEUtils.toFixedNumber(size / 1024, 2)}KB`
}
return `${size}B`
},
clickEvent () {
formatColumnSize (row, column, cellValue, index) {
if (XEUtils.isNumber(cellValue)) {
let units = ['B', 'KB', 'MB', 'GB', 'TB']
let unit = ''
let size = XEUtils.toNumber(cellValue)
for (let index = 0; index < units.length; index++) {
unit = units[index]
if (size >= 1024) {
size = XEUtils.toFixedNumber(size / 1024, 2)
} else {
break
}
}
return `${size} ${unit}`
}
return ''
},
formatterDate (row, column, cellValue, index) {