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