【fix ESLint】src/components/jero/JVxeTable

This commit is contained in:
zhaoxiao
2023-03-06 09:04:16 +08:00
parent d1f4133963
commit d0048f4c5f
11 changed files with 190 additions and 190 deletions
+1
View File
@@ -29,6 +29,7 @@
"lodash.get": "^4.4.2",
"lodash.pick": "^4.4.0",
"md5": "^2.2.1",
"moment": "^2.29.4",
"nprogress": "^0.2.0",
"tinymce": "5.4.1",
"viser-vue": "^2.4.8",
@@ -89,7 +89,7 @@ export default {
const clientHeight = tr.clientHeight
this.$refs.div.style.width = clientWidth + 'px'
this.$refs.div.style.height = clientHeight + 'px'
this.overlayStyle.width = Number.parseInt((clientWidth - clientWidth * 0.04)) + 'px'
this.overlayStyle.width = Number.parseInt((clientWidth - clientWidth * 0.04) + '') + 'px'
this.overlayStyle.maxWidth = this.overlayStyle.width
// update-begin-author:taoyan date:20200921 for: 子表弹出位置存在现实位置问题。
// let realTable = getParentNodeByTagName(tr, 'table')
@@ -204,7 +204,7 @@ export default {
// update--begin--autor:lvdandan-----date:20201019------for:LOWCOD-882 【新行编辑】列表上带按钮的遮挡问题
if (column.$type === JVXETypes.file || column.$type === JVXETypes.image) {
if (column.width && column.width.endsWith('px')) {
column.width = Number.parseInt(column.width.substr(0, column.width.length - 2)) + Number.parseInt(1) + 'px'
column.width = Number.parseInt(column.width.substr(0, column.width.length - 2)) + Number.parseInt('1') + 'px'
}
}
// update--begin--autor:lvdandan-----date:20201019------for:LOWCOD-882 【新行编辑】列表上带按钮的遮挡问题
@@ -373,7 +373,8 @@ export default {
// 防止和vxeTable自带的type起冲突
col.$type = col.type
delete col.type
let renderName = 'cellRender'; const renderOptions = { name: JVXETypes._prefix + type }
let renderName = 'cellRender'
const renderOptions = { name: JVXETypes._prefix + type }
if (type) {
// hidden 是特殊的组件
if (type === JVXETypes.hidden) {
@@ -482,7 +483,14 @@ export default {
if (this.statistics.has) {
width = 60
}
let col = { type: JVXETypes.rowDragSort, title: '', width, fixed: 'left', align: 'center', cellRender: { name: JVXETypes._prefix + JVXETypes.rowDragSort } }
let col = {
type: JVXETypes.rowDragSort,
title: '',
width,
fixed: 'left',
align: 'center',
cellRender: { name: JVXETypes._prefix + JVXETypes.rowDragSort }
}
if (dragSortColumn) {
col = Object.assign(col, dragSortColumn, { type: JVXETypes.rowDragSort })
}
@@ -565,8 +573,9 @@ export default {
// 记录滚动条的位置
scroll.top = event.scrollTop
scroll.left = event.scrollLeft
$refs.subPopover ? $refs.subPopover.close() : null
if ($refs.subPopover) {
$refs.subPopover.close()
}
this.scrolling = true
this.closeScrolling()
},
@@ -615,15 +624,21 @@ export default {
// 点击了可编辑的
if (column.editRender) {
$refs.subPopover ? $refs.subPopover.close() : null
if ($refs.subPopover) {
$refs.subPopover.close()
}
return
}
// 显示详细信息
if (column.own.showDetails) {
// 两个如果同时存在的话会出现死循环
$refs.subPopover ? $refs.subPopover.close() : null
$refs.detailsModal ? $refs.detailsModal.open(event) : null
if ($refs.subPopover) {
$refs.subPopover.close()
}
if ($refs.detailsModal) {
$refs.detailsModal.open(event)
}
} else if ($refs.subPopover) {
$refs.subPopover.toggle(event)
} else if (this.clickSelectRow) {
@@ -764,7 +779,7 @@ export default {
console.warn(`JVxeTable.setValues必须传递数组`)
return
}
values.forEach((item, idx) => {
values.forEach((item) => {
const { rowKey, values: record } = item
const { row } = this.getIfRowById(rowKey)
if (!row) {
@@ -833,12 +848,12 @@ export default {
},
/** 仅获取新增的数据,带有id */
getNewDataWithId () {
const newData = cloneObject(this.$refs.vxe.getInsertRecords())
return newData
return cloneObject(this.$refs.vxe.getInsertRecords())
},
/** 根据ID获取行,新增的行也能查出来 */
getIfRowById (id) {
let row = this.getRowById(id); let isNew = false
let row = this.getRowById(id)
let isNew = false
if (!row) {
row = this.getNewRowById(id)
if (!row) {
@@ -1090,8 +1105,9 @@ export default {
for (const row of rows) {
const item = cloneObject(row)
if (insertRecords.includes(row)) {
handler ? handler({ item, row, insertRecords }) : null
if (handler) {
handler({ item, row, insertRecords })
}
if (remove) {
continue
}
@@ -1198,7 +1214,9 @@ export default {
async _recalcSortNumber () {
const xTable = this.$refs.vxe.$refs.xTable
if (this.dragSort) {
xTable.tableFullData.forEach((data, idx) => data[this.dragSortKey] = (idx + 1))
xTable.tableFullData.forEach((data, idx) => {
data[this.dragSortKey] = (idx + 1)
})
}
await xTable.updateCache(true)
return await xTable.updateData()
@@ -1218,7 +1236,7 @@ export default {
// 遍历插入的行
// update--begin--autor:lvdandan-----date:20201117------for:LOWCOD-987 【新行编辑】js增强附表内置方法调用问题 #1819
// online js增强时以传过来值为准,不再赋默认值
if (isOnlJs != true) {
if (isOnlJs !== true) {
for (let i = 0; i < result.rows.length; i++) {
const row = result.rows[i]
this.trigger(triggerName, {
@@ -1365,7 +1383,7 @@ export default {
return null
},
loadExcludeCode () {
if (!this.authPre || this.authPre.length == 0) {
if (!this.authPre || this.authPre.length === 0) {
this.excludeCode = []
} else {
let pre = this.authPre
@@ -14,7 +14,7 @@
<script>
import moment from 'moment'
import { JVXETypes } from '@/components/jero/JVxeTable/index'
import { JVXETypes } from '@comp/jero/JVxeTable'
import JVxeCellMixins, { dispatchEvent } from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
export default {
@@ -26,7 +26,7 @@
</template>
<script>
import JVxeCellMixins, { dispatchEvent } from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
import JVxeCellMixins from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
import JSelectDepartModal from '@/components/jerobiz/modal/JSelectDepartModal'
export default {
@@ -55,10 +55,7 @@ export default {
}
},
componentDisabled () {
if (this.cellProps.disabled == true) {
return true
}
return false
return this.cellProps.disabled === true
},
modalWidth () {
if (this.cellProps.modalWidth) {
@@ -68,18 +65,11 @@ export default {
}
},
multi () {
if (this.cellProps.multi == false) {
return false
} else {
return true
}
console.log(this.cellProps)
return this.cellProps.multi !== false
},
rootOpened () {
if (this.cellProps.open == false) {
return false
} else {
return true
}
return this.cellProps.open !== false
}
},
watch: {
@@ -102,12 +92,12 @@ export default {
this.handleOK('')
},
handleOK (rows, idstr) {
let value = ''
// let value = ''
if (!rows && rows.length <= 0) {
this.departNames = ''
this.departIds = ''
} else {
value = rows.map(row => row[this.customReturnField]).join(',')
// value = rows.map(row => row[this.customReturnField]).join(',')
this.departNames = rows.map(row => row.departName).join(',')
this.departIds = idstr
}
@@ -132,7 +122,7 @@ export default {
</script>
<style scoped>
/deep/ .jvxe-select-input .ant-input{
border: none !important;
}
/deep/ .jvxe-select-input .ant-input {
border: none !important;
}
</style>
@@ -1,8 +1,8 @@
<template>
<a-dropdown :trigger="['click']">
<div class="j-vxe-ds-icons">
<a-icon type="align-left"/>
<a-icon type="align-right"/>
<a-icon type="align-left" />
<a-icon type="align-right" />
</div>
<!-- <div class="j-vxe-ds-btns">-->
@@ -13,7 +13,7 @@
<a-menu slot="overlay">
<a-menu-item key="0" :disabled="disabledMoveUp" @click="handleRowMoveUp">向上移</a-menu-item>
<a-menu-item key="1" :disabled="disabledMoveDown" @click="handleRowMoveDown">向下移</a-menu-item>
<a-menu-divider/>
<a-menu-divider />
<a-menu-item key="3" @click="handleRowInsertDown">插入一行</a-menu-item>
</a-menu>
</a-dropdown>
@@ -39,14 +39,14 @@ export default {
},
methods: {
/** 向上移 */
handleRowMoveUp (event) {
handleRowMoveUp () {
// event.target.blur()
if (!this.disabledMoveUp) {
this.trigger('rowMoveUp', this.rowIndex)
}
},
/** 向下移 */
handleRowMoveDown (event) {
handleRowMoveDown () {
// event.target.blur()
if (!this.disabledMoveDown) {
this.trigger('rowMoveDown', this.rowIndex)
@@ -68,71 +68,71 @@ export default {
</script>
<style lang="less">
.j-vxe-ds-icons {
position: relative;
/*cursor: move;*/
cursor: pointer;
width: 14px;
height: 100%;
display: inline-block;
.j-vxe-ds-icons {
position: relative;
/*cursor: move;*/
cursor: pointer;
width: 14px;
height: 100%;
display: inline-block;
.anticon-align-left,
.anticon-align-right {
position: absolute;
top: 30%;
}
.anticon-align-left {
left: 0;
}
.anticon-align-right {
right: 0;
}
.anticon-align-left,
.anticon-align-right {
position: absolute;
top: 30%;
}
.j-vxe-ds-btns {
position: relative;
cursor: pointer;
width: 24px;
height: 100%;
display: flex;
justify-content: center;
flex-direction: column;
align-content: center;
.anticon-align-left {
left: 0;
}
.ant-btn {
border: none;
.anticon-align-right {
right: 0;
}
}
z-index: 0;
padding: 0;
width: 100%;
/*height: 30%;*/
height: 40%;
display: block;
border-radius: 0;
.j-vxe-ds-btns {
position: relative;
cursor: pointer;
width: 24px;
height: 100%;
display: flex;
justify-content: center;
flex-direction: column;
align-content: center;
&:hover {
z-index: 1;
/* height: 40%;*/
.ant-btn {
border: none;
/* & .anticon-caret-up,*/
/* & .anticon-caret-down {*/
/* top: 2px;*/
/* }*/
}
z-index: 0;
padding: 0;
width: 100%;
/*height: 30%;*/
height: 40%;
display: block;
border-radius: 0;
&:last-child {
margin-top: -1px;
}
&:hover {
z-index: 1;
/* height: 40%;*/
& .anticon-caret-up,
& .anticon-caret-down {
vertical-align: top;
position: relative;
top: 0;
transition: top 0.3s;
}
/* & .anticon-caret-up,*/
/* & .anticon-caret-down {*/
/* top: 2px;*/
/* }*/
}
&:last-child {
margin-top: -1px;
}
& .anticon-caret-up,
& .anticon-caret-down {
vertical-align: top;
position: relative;
top: 0;
transition: top 0.3s;
}
}
}
</style>
@@ -12,13 +12,13 @@
>
<div v-if="loading" slot="notFoundContent">
<a-icon type="loading" />
<a-icon type="loading" />
<span>&nbsp;加载中</span>
</div>
<template v-for="option of selectOptions">
<a-select-option :key="option.value" :value="option.value" :disabled="option.disabled">
<span>{{option.text || option.label || option.title|| option.value}}</span>
<span>{{ option.text || option.label || option.title || option.value }}</span>
</a-select-option>
</template>
@@ -27,7 +27,7 @@
<script>
import JVxeCellMixins, { dispatchEvent } from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
import { JVXETypes } from '@comp/jero/JVxeTable/index'
import { JVXETypes } from '@comp/jero/JVxeTable'
import { filterDictText } from '@comp/dict/JDictSelectUtil'
export default {
@@ -41,6 +41,17 @@ export default {
}
},
computed: {
selectOptions () {
if (this.asyncOptions) {
return this.asyncOptions
}
const { linkage } = this.renderOptions
if (linkage) {
this.handleComputedSelectOptions(linkage)
}
return this.originColumn.options
},
// 下拉选项
selectProps () {
const props = { ...this.cellProps }
// 判断select是否允许输入
@@ -49,32 +60,6 @@ export default {
props.showSearch = true
}
return props
},
// 下拉选项
selectOptions () {
if (this.asyncOptions) {
return this.asyncOptions
}
const { linkage } = this.renderOptions
if (linkage) {
const { getLinkageOptionsSibling, config } = linkage
const res = getLinkageOptionsSibling(this.row, this.originColumn, config, true)
// 当返回Promise时,说明是多级联动
if (res instanceof Promise) {
this.loading = true
res.then(opt => {
this.asyncOptions = opt
this.loading = false
}).catch(e => {
console.error(e)
this.loading = false
})
} else {
this.asyncOptions = null
return res
}
}
return this.originColumn.options
}
},
created () {
@@ -155,8 +140,25 @@ export default {
options.push({ title: value, value: value, searchAdd: true })
}
}
},
handleComputedSelectOptions (linkage) {
const { getLinkageOptionsSibling, config } = linkage
const res = getLinkageOptionsSibling(this.row, this.originColumn, config, true)
// 当返回Promise时,说明是多级联动
if (res instanceof Promise) {
this.loading = true
res.then(opt => {
this.asyncOptions = opt
this.loading = false
}).catch(e => {
console.error(e)
this.loading = false
})
} else {
this.asyncOptions = null
return res
}
}
},
// 【组件增强】注释详见:JVxeCellMixins.js
enhanced: {
@@ -1,48 +1,44 @@
<template>
<div>
<template v-if="hasFile" v-for="(file, fileKey) of [innerFile || {}]">
<a-input
:key="fileKey"
:readOnly="true"
:value="file.name"
>
<template v-if="hasFile">
<template v-for="(file, fileKey) of [innerFile || {}]">
<a-input :key="fileKey" :readOnly="true" :value="file.name">
<template slot="addonBefore" style="width: 30px">
<a-tooltip v-if="file.status === 'uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
<a-icon type="loading"/>
</a-tooltip>
<a-tooltip v-else-if="file.status === 'done'" title="上传完成">
<a-icon type="check-circle" style="color:#00DB00;"/>
</a-tooltip>
<a-tooltip v-else :title="file.message||'上传失败'">
<a-icon type="exclamation-circle" style="color:red;"/>
</a-tooltip>
</template>
<span v-if="file.status === 'uploading'" slot="addonAfter">{{ Math.floor(file.percent) }}%</span>
<template v-else-if="originColumn.allowDownload !== false || originColumn.allowRemove !== false" slot="addonAfter">
<a-dropdown :trigger="['click']" placement="bottomRight">
<a-tooltip title="操作">
<a-icon
type="setting"
style="cursor: pointer;"/>
<template slot="addonBefore" style="width: 30px">
<a-tooltip v-if="file.status === 'uploading'" :title="`上传中(${Math.floor(file.percent)}%)`">
<a-icon type="loading" />
</a-tooltip>
<a-tooltip v-else-if="file.status === 'done'" title="上传完成">
<a-icon type="check-circle" style="color:#00DB00;" />
</a-tooltip>
<a-tooltip v-else :title="file.message||'上传失败'">
<a-icon type="exclamation-circle" style="color:red;" />
</a-tooltip>
</template>
<a-menu slot="overlay">
<!-- <a-menu-item @click="handleClickPreviewFile">-->
<!-- <span><a-icon type="eye"/>&nbsp;预览</span>-->
<!-- </a-menu-item>-->
<a-menu-item v-if="originColumn.allowDownload !== false" @click="handleClickDownloadFile">
<span><a-icon type="download"/>&nbsp;下载</span>
</a-menu-item>
<a-menu-item v-if="originColumn.allowRemove !== false" @click="handleClickDeleteFile">
<span><a-icon type="delete"/>&nbsp;删除</span>
</a-menu-item>
</a-menu>
</a-dropdown>
</template>
<span v-if="file.status === 'uploading'" slot="addonAfter">{{ Math.floor(file.percent) }}%</span>
<template v-else-if="originColumn.allowDownload !== false || originColumn.allowRemove !== false" slot="addonAfter">
<a-dropdown :trigger="['click']" placement="bottomRight">
<a-tooltip title="操作">
<a-icon type="setting" style="cursor: pointer;" />
</a-tooltip>
</a-input>
<a-menu slot="overlay">
<!-- <a-menu-item @click="handleClickPreviewFile">-->
<!-- <span><a-icon type="eye"/>&nbsp;预览</span>-->
<!-- </a-menu-item>-->
<a-menu-item v-if="originColumn.allowDownload !== false" @click="handleClickDownloadFile">
<span><a-icon type="download" />&nbsp;下载</span>
</a-menu-item>
<a-menu-item v-if="originColumn.allowRemove !== false" @click="handleClickDeleteFile">
<span><a-icon type="delete" />&nbsp;删除</span>
</a-menu-item>
</a-menu>
</a-dropdown>
</template>
</a-input>
</template>
</template>
<a-upload
v-show="!hasFile"
@@ -55,7 +51,7 @@
v-bind="cellProps"
@change="handleChangeUpload"
>
<a-button icon="upload">{{originColumn.btnText || '点击上传'}}</a-button>
<a-button icon="upload">{{ originColumn.btnText || '点击上传' }}</a-button>
</a-upload>
</div>
</template>
@@ -105,7 +101,7 @@ export default {
methods: {
handleChangeUpload (info) {
const { row, originColumn: col } = this
const { originColumn: col } = this
const { file } = info
const value = {
name: file.name,
@@ -139,7 +135,7 @@ export default {
// this.$message.info('尚未实现')
// },
handleClickDownloadFile (id) {
handleClickDownloadFile () {
const { path } = this.value || {}
if (path) {
const url = getFileAccessHttpUrl(path)
@@ -31,7 +31,7 @@
</template>
<script>
import JVxeCellMixins, { dispatchEvent } from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
import JVxeCellMixins from '@/components/jero/JVxeTable/mixins/JVxeCellMixins'
import JSelectUserByDepModal from '@/components/jerobiz/modal/JSelectUserByDepModal'
export default {
@@ -59,10 +59,7 @@ export default {
},
componentDisabled () {
console.log('333', this.cellProps)
if (this.cellProps.disabled == true) {
return true
}
return false
return this.cellProps.disabled === true
},
modalWidth () {
if (this.cellProps.modalWidth) {
@@ -72,11 +69,7 @@ export default {
}
},
multi () {
if (this.cellProps.multi == false) {
return false
} else {
return true
}
return this.cellProps.multi !== false
}
},
watch: {
@@ -1,5 +1,4 @@
// 组件类型
export default JVXETypes
export const JVXETypes = {
// 为了防止和 vxe 内置的类型冲突,所以加上一个前缀
// 前缀是自动加的,代码中直接用就行(JVXETypes.input
@@ -1,5 +1,5 @@
import { getVmParentByName } from '@/utils/util'
import { JVXETypes } from '@comp/jero/JVxeTable/index'
import { JVXETypes } from '@comp/jero/JVxeTable'
export const VALIDATE_FAILED = Symbol()
@@ -50,7 +50,7 @@ export function getInputNumberMaxValue (col, rowsValues) {
*
* @param dom 一级dom节点
* @param tagName 标签名,不区分大小写
* @return {HTMLElement | NULL}
* @return {HTMLElement}
*/
export function getParentNodeByTagName (dom, tagName = 'body') {
if (tagName === 'body') {
@@ -103,7 +103,7 @@ export function vxePackageToSuperQuery (columns, handler) {
field.options = col.options
}
if (typeof handler === 'function') {
Object.assign(field, handler(col, idx))
Object.assign(field, handler(col))
}
fieldList.push(field)
}
@@ -124,7 +124,7 @@ export function vxePackageToSuperQuery (columns, handler) {
*/
export async function validateFormAndTables (form, cases, autoJumpTab) {
if (!(form && typeof form.validateFields === 'function')) {
throw `form 参数需要的是一个form对象而传入的却是${typeof form}`
throw new Error(`form 参数需要的是一个form对象而传入的却是${typeof form}`)
}
let dataMap = {}
const values = await new Promise((resolve, reject) => {
@@ -144,6 +144,7 @@ export async function validateFormAndTables (form, cases, autoJumpTab) {
/**
* 一次性验证主表单和所有的次表单
* @param form 主表单 form 对象
* @param formData
* @param cases 接收一个数组,每项都是一个JVxeTable实例
* @param autoJumpTab
* @returns {Promise<any>}
@@ -151,12 +152,12 @@ export async function validateFormAndTables (form, cases, autoJumpTab) {
*/
export async function validateFormModelAndTables (form, formData, cases, autoJumpTab) {
if (!(form && typeof form.validate === 'function')) {
throw `form 参数需要的是一个form对象而传入的却是${typeof form}`
throw new Error(`form 参数需要的是一个form对象而传入的却是${typeof form}`)
}
let dataMap = {}
const values = await new Promise((resolve, reject) => {
// 验证主表表单
form.validate((valid, obj) => {
form.validate((valid) => {
valid ? resolve(formData) : reject({ error: VALIDATE_FAILED, originError: valid })
})
})
@@ -176,7 +177,7 @@ export async function validateFormModelAndTables (form, formData, cases, autoJum
*/
export function validateTables (cases, autoJumpTab = true) {
if (!Array.isArray(cases)) {
throw `'validateTables'函数的'cases'参数需要的是一个数组而传入的却是${typeof cases}`
throw new Error(`'validateTables'函数的'cases'参数需要的是一个数组而传入的却是${typeof cases}`)
}
return new Promise((resolve, reject) => {
const tablesData = []