【fix ESLint】src/components/jero/JEditableTable

This commit is contained in:
zhaoxiao
2023-03-06 09:07:41 +08:00
parent d0048f4c5f
commit 3e8bfe2f4e
+44 -40
View File
@@ -201,7 +201,7 @@
</template>
<!-- select -->
<template v-else-if="col.type === formTypes.select">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<a-select
v-if="isEditRow(row, col)"
:id="id"
@@ -230,7 +230,7 @@
<!-- 部门选择 -->
<template v-else-if="col.type === formTypes.sel_depart">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-select-depart
v-if="isEditRow(row, col)"
:id="id"
@@ -254,7 +254,7 @@
<!-- 用户选择 -->
<template v-else-if="col.type === formTypes.sel_user">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-select-user-by-dep
v-if="isEditRow(row, col)"
:id="id"
@@ -278,7 +278,7 @@
<!-- date -->
<template v-else-if="col.type === formTypes.date || col.type === formTypes.datetime">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-date
v-if="isEditRow(row, col)"
:id="id"
@@ -304,7 +304,7 @@
</template>
<!-- input_pop -->
<template v-else-if="col.type === formTypes.input_pop">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-input-pop
v-if="isEditRow(row, col)"
:id="id"
@@ -329,8 +329,9 @@
</template>
<!-- upload -->
<div v-else-if="col.type === formTypes.upload" :key="i">
<template v-if="uploadValues[id] != null" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
<template v-if="uploadValues[id] != null">
<a-input
v-for="(file,fileKey) of [(uploadValues[id]||{})]"
:key="fileKey"
:readOnly="true"
:value="file.name"
@@ -392,7 +393,7 @@
<!-- update-begin-author:taoyan date:0827 forpopup -->
<template v-else-if="col.type === formTypes.popup">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-popup
v-if="isEditRow(row, col)"
:id="id"
@@ -422,8 +423,8 @@
<!-- update-beign-author:taoyan date:0827 for:文件/图片逻辑新增 -->
<div v-else-if="col.type === formTypes.file" :key="i">
<template v-if="uploadValues[id] != null" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
<div :key="fileKey" style="position: relative;">
<template v-if="uploadValues[id] != null">
<div :key="fileKey" style="position: relative;" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
<a-tooltip v-if="file.status==='uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
<a-icon type="loading" style="color:red;" />
<span style="color:red;margin-left:5px">{{ file.status }}</span>
@@ -440,7 +441,8 @@
</a-tooltip>
<template style="width: 30px">
<a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer" style="margin-left: 10px;">
<a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer"
style="margin-left: 10px;">
<a-tooltip title="操作" :getPopupContainer="getParentContainer">
<a-icon v-if="file.status!=='uploading'" type="setting" style="cursor: pointer;" />
</a-tooltip>
@@ -481,8 +483,8 @@
</div>
<div v-else-if="col.type === formTypes.image" :key="i">
<template v-if="uploadValues[id] != null" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
<div :key="fileKey" style="position: relative;">
<template v-if="uploadValues[id] != null">
<div :key="fileKey" style="position: relative;" v-for="(file,fileKey) of [(uploadValues[id]||{})]">
<template v-if="!uploadValues[id] || !(uploadValues[id]['url'] || uploadValues[id]['path'] || uploadValues[id]['message'])">
<a-icon type="loading" />
</template>
@@ -494,7 +496,8 @@
</a-tooltip>
<template style="width: 30px">
<a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer" style="margin-left: 10px;">
<a-dropdown :trigger="['click']" placement="bottomRight" :getPopupContainer="getParentContainer"
style="margin-left: 10px;">
<a-tooltip title="操作" :getPopupContainer="getParentContainer">
<a-icon
v-if="file.status!=='uploading'"
@@ -541,7 +544,7 @@
<!-- radio-begin -->
<template v-else-if="col.type === formTypes.radio">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<a-radio-group
:id="id"
:key="i"
@@ -556,7 +559,7 @@
<!-- select多选 -begin -->
<template v-else-if="col.type === formTypes.list_multi">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<a-select
v-if="isEditRow(row, col)"
:id="id"
@@ -584,7 +587,7 @@
<!-- select搜索 -begin -->
<template v-else-if="col.type === formTypes.sel_search">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<a-select
v-if="isEditRow(row, col)"
:id="id"
@@ -613,7 +616,7 @@
<!-- select异步搜索 -begin -->
<template v-else-if="col.type === formTypes.sel_search_async">
<a-tooltip v-bind="buildTooltipProps(row, col, id)">
<a-tooltip :key="i" v-bind="buildTooltipProps(row, col, id)">
<j-search-select-tag
v-if="isEditRow(row, col)"
:id="id"
@@ -658,7 +661,8 @@
</div>
<!-- else (normal) -->
<span class="comp-normal" v-else :key="i" :title="inputValues[rowIndex][col.key]" v-bind="buildProps(row,col)">{{ inputValues[rowIndex][col.key] }}</span>
<span class="comp-normal" v-else :key="i" :title="inputValues[rowIndex][col.key]"
v-bind="buildProps(row,col)">{{ inputValues[rowIndex][col.key] }}</span>
</template>
</div>
</div>
@@ -952,7 +956,7 @@ export default {
realTrWidth () {
const splice = ' + '
let calcWidth = 'calc('
this.columns.forEach((column, i) => {
this.columns.forEach((column) => {
const { type, width } = column
// 隐藏字段不参与计算
if (type !== FormTypes.hidden) {
@@ -1292,7 +1296,7 @@ export default {
}
} else if (column.type === FormTypes.upload || column.type === FormTypes.file || column.type === FormTypes.image) {
if (sourceValue) {
let fileName = ''
let fileName
if (sourceValue.indexOf(',') > 0) {
const sourceValue2 = sourceValue.split(',')[0]
fileName = sourceValue2.substring(sourceValue2.lastIndexOf('/') + 1)
@@ -1389,7 +1393,8 @@ export default {
getInputNumberMaxValue (column) {
let maxNum = 0
this.inputValues.forEach((item, index) => {
const val = item[column.key]; let num
const val = item[column.key]
let num
try {
num = parseInt(val)
} catch {
@@ -1429,9 +1434,6 @@ export default {
target: this
})
// 设置滚动条位置
const tbody = this.getElement('tbody')
const offsetHeight = tbody.offsetHeight
const realScrollTop = tbody.scrollTop + offsetHeight
if (forceScrollToBottom) {
this.$nextTick(() => {
this.resetScrollTop(this.$refs.scrollView.scrollHeight)
@@ -1442,6 +1444,7 @@ export default {
* 在指定位置添加一行
* @param insertIndex 添加位置下标
* @param num 添加的行数,默认1
* @param forceScrollToBottom
*/
insert (insertIndex, num = 1, forceScrollToBottom = false) {
if (this.checkTooFastClick('insert', 1500)) {
@@ -1491,7 +1494,7 @@ export default {
if (typeof id === 'string') {
ids = [id]
} else {
throw `JEditableTable.removeRows() 函数需要的参数可以是string或Array类型,但提供的却是${typeof id}`
throw new Error(`JEditableTable.removeRows() 函数需要的参数可以是string或Array类型,但提供的却是${typeof id}`)
}
}
@@ -1929,7 +1932,8 @@ export default {
/** 通过规则验证值是否正确 */
validateValue (column, value) {
const rules = column.validateRules
let passed = true; let message = ''
let passed = true
let message = ''
// 判断有没有验证规则或验证规则格式正不正确,若条件不符合则默认通过
if (rules instanceof Array) {
for (const rule of rules) {
@@ -1939,8 +1943,7 @@ export default {
if (rule.required === true && isNull) {
passed = false
} else // 使用 else-if 是为了防止一个 rule 中出现两个规则
// 验证规则:唯一校验
if (rule.unique === true || rule.pattern === 'only') {
if (rule.unique === true || rule.pattern === 'only') { // 验证规则:唯一校验
const { values } = this.getValuesSync({ validate: false })
let findCount = 0
for (const val of values) {
@@ -1951,15 +1954,17 @@ export default {
}
}
}
} else
// 验证规则:正则表达式
if (!!rule.pattern && !isNull) {
} else if (!!rule.pattern && !isNull) { // 验证规则:正则表达式
// 兼容 online 的规则
const foo = [
{ title: '6到16位数字', value: 'n6-16', pattern: /^\d{6,16}$/ },
{ title: '6到16位任意字符', value: '*6-16', pattern: /^.{6,16}$/ },
{ title: '6到18位字母', value: 's6-18', pattern: /^[a-z|A-Z]{6,18}$/ },
{ title: '网址', value: 'url', pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/ },
{
title: '网址',
value: 'url',
pattern: /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/
},
{ title: '电子邮件', value: 'e', pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/ },
{ title: '手机号码', value: 'm', pattern: /^1[3456789]\d{9}$/ },
{ title: '邮政编码', value: 'p', pattern: /^[1-9]\d{5}$/ },
@@ -1978,9 +1983,7 @@ export default {
}
}
if (!flag) passed = new RegExp(rule.pattern).test(value)
} else
// 校验规则:自定义函数校验
if (typeof rule.handler === 'function') {
} else if (typeof rule.handler === 'function') { // 校验规则:自定义函数校验
return [rule.handler, rule.message]
}
// 如果没有通过验证,则跳出循环。如果通过了验证,则继续验证下一条规则
@@ -2217,7 +2220,9 @@ export default {
recalcSortNumber () {
if (this.dragSort) {
// 重置排序字段
this.inputValues.forEach((val, idx) => val[this.dragSortKey] = (idx + 1))
this.inputValues.forEach((val, idx) => {
val[this.dragSortKey] = (idx + 1)
})
}
},
@@ -2624,9 +2629,8 @@ export default {
// 找到了带有 hidden 的标签,判断它的父级是否还有 hidden,直到遇到完全没有 hidden 或 body 的时候才停止递归
const temp = ifParent(child.parentNode)
return temp != null ? temp : child.parentNode
} else
} else if (child.parentNode && child.parentNode.tagName.toLocaleLowerCase() !== 'body') {
// 当前标签没有 hidden ,如果有父级并且父级不是 body 的话就继续递归判断父级
if (child.parentNode && child.parentNode.tagName.toLocaleLowerCase() !== 'body') {
return ifParent(child.parentNode)
} else {
// 直到 body 都没有遇到有 hidden 的标签
@@ -2924,7 +2928,7 @@ export default {
// 获取没有授权的按钮编码
loadExcludeCode () {
if (!this.authPre || this.authPre.length == 0) {
if (!this.authPre || this.authPre.length === 0) {
this.excludeCode = []
} else {
let pre = this.authPre
@@ -2936,7 +2940,7 @@ export default {
},
// 判断button是否显示
buttonPermission (code) {
if (!this.excludeCode || this.excludeCode.length == 0) {
if (!this.excludeCode || this.excludeCode.length === 0) {
return true
} else {
return this.excludeCode.indexOf(code) < 0