【modify】使用ESLint格式化代码

This commit is contained in:
zer0Black
2023-03-01 09:33:58 +08:00
parent 694855ae8b
commit 63369b8b87
400 changed files with 42942 additions and 43132 deletions
+35 -35
View File
@@ -1,17 +1,17 @@
import JEditableTable from '@/components/jero/JEditableTable'
import { VALIDATE_NO_PASSED, getRefPromise,validateFormModelAndTables} from '@/utils/JEditableTableUtil'
import { VALIDATE_NO_PASSED, getRefPromise, validateFormModelAndTables } from '@/utils/JEditableTableUtil'
import { httpAction, getAction } from '@/api/manage'
export const JEditableTableModelMixin = {
components: {
JEditableTable
},
data() {
data () {
return {
title: '操作',
visible: false,
confirmLoading: false,
model:{},
model: {},
labelCol: {
xs: { span: 24 },
sm: { span: 6 }
@@ -25,16 +25,16 @@ export const JEditableTableModelMixin = {
methods: {
/** 获取所有的editableTable实例 */
getAllTable() {
getAllTable () {
if (!(this.refKeys instanceof Array)) {
throw this.throwNotArray('refKeys')
}
let values = this.refKeys.map(key => getRefPromise(this, key))
const values = this.refKeys.map(key => getRefPromise(this, key))
return Promise.all(values)
},
/** 遍历所有的JEditableTable实例 */
eachAllTable(callback) {
eachAllTable (callback) {
// 开始遍历
this.getAllTable().then(tables => {
tables.forEach((item, index) => {
@@ -45,13 +45,13 @@ export const JEditableTableModelMixin = {
})
},
/** 当点击新增按钮时调用此方法 */
add() {
//update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
add () {
// update-begin-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
return new Promise((resolve) => {
this.tableReset();
resolve();
this.tableReset()
resolve()
}).then(() => {
if (typeof this.addBefore === 'function'){
if (typeof this.addBefore === 'function') {
this.addBefore()
}
// 默认新增空数据
@@ -66,12 +66,12 @@ export const JEditableTableModelMixin = {
if (typeof this.addAfter === 'function') this.addAfter(this.model)
this.edit(this.model)
})
//update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
// update-end-author:lvdandan date:20201113 for:LOWCOD-1049 JEditaTable,子表默认添加一条数据,addDefaultRowNum设置无效 #1930
},
/** 当点击了编辑(修改)按钮时调用此方法 */
edit(record) {
if(record && '{}'!=JSON.stringify(record)&&record.id){
this.tableReset();
edit (record) {
if (record && JSON.stringify(record) != '{}' && record.id) {
this.tableReset()
}
if (typeof this.editBefore === 'function') this.editBefore(record)
this.visible = true
@@ -81,21 +81,21 @@ export const JEditableTableModelMixin = {
if (typeof this.editAfter === 'function') this.editAfter(this.model)
},
/** 关闭弹窗,并将所有JEditableTable实例回归到初始状态 */
close() {
close () {
this.visible = false
this.$emit('close')
},
//清空子表table的数据
tableReset(){
// 清空子表table的数据
tableReset () {
this.eachAllTable((item) => {
item.clearRow()
})
},
/** 查询某个tab的数据 */
requestSubTableData(url, params, tab, success) {
requestSubTableData (url, params, tab, success) {
tab.loading = true
getAction(url, params).then(res => {
let { result } = res
const { result } = res
let dataSource = []
if (result) {
if (Array.isArray(result)) {
@@ -111,8 +111,8 @@ export const JEditableTableModelMixin = {
})
},
/** 发起请求,自动判断是执行新增还是修改操作 */
request(formData) {
let url = this.url.add, method = 'post'
request (formData) {
let url = this.url.add; let method = 'post'
if (this.model.id) {
url = this.url.edit
method = 'put'
@@ -134,22 +134,22 @@ export const JEditableTableModelMixin = {
/* --- handle 事件 --- */
/** ATab 选项卡切换事件 */
handleChangeTabs(key) {
handleChangeTabs (key) {
// 自动重置scrollTop状态,防止出现白屏
getRefPromise(this, key).then(editableTable => {
editableTable.resetScrollTop()
})
},
/** 关闭按钮点击事件 */
handleCancel() {
handleCancel () {
this.close()
},
/** 确定按钮点击事件 */
handleOk() {
handleOk () {
/** 触发表单验证 */
this.getAllTable().then(tables => {
/** 一次性验证主表和所有的次表 */
return validateFormModelAndTables(this.$refs.form,this.model, tables)
return validateFormModelAndTables(this.$refs.form, this.model, tables)
}).then(allValues => {
/** 一次性验证一对一的所有子表 */
return this.validateSubForm(allValues)
@@ -157,22 +157,22 @@ export const JEditableTableModelMixin = {
if (typeof this.classifyIntoFormData !== 'function') {
throw this.throwNotFunction('classifyIntoFormData')
}
let formData = this.classifyIntoFormData(allValues)
const formData = this.classifyIntoFormData(allValues)
// 发起请求
return this.request(formData)
}).catch(e => {
if (e.error === VALIDATE_NO_PASSED) {
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab
//update--begin--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
this.activeKey = e.index == null ? this.activeKey : (e.paneKey?e.paneKey:this.refKeys[e.index])
//update--end--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
// update--begin--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
this.activeKey = e.index == null ? this.activeKey : (e.paneKey ? e.paneKey : this.refKeys[e.index])
// update--end--autor:liusq-----date:20210316------for:未通过表单验证跳转tab问题------
} else {
console.error(e)
}
})
},
//校验所有子表表单
validateSubForm(allValues){
// 校验所有子表表单
validateSubForm (allValues) {
return new Promise((resolve) => {
resolve(allValues)
})
@@ -180,14 +180,14 @@ export const JEditableTableModelMixin = {
/* --- throw --- */
/** not a function */
throwNotFunction(name) {
throwNotFunction (name) {
return `${name} 未定义或不是一个函数`
},
/** not a array */
throwNotArray(name) {
throwNotArray (name) {
return `${name} 未定义或不是一个数组`
}
}
}
}