【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
+31 -33
View File
@@ -11,13 +11,13 @@ const FormTypes = {
upload: 'upload',
file: 'file',
image: 'image',
popup:'popup',
list_multi:"list_multi",
sel_search:"sel_search",
sel_search_async:"sel_search_async",
radio:'radio',
checkbox_meta:"checkbox_meta",
input_pop:'input_pop',
popup: 'popup',
list_multi: 'list_multi',
sel_search: 'sel_search',
sel_search_async: 'sel_search_async',
radio: 'radio',
checkbox_meta: 'checkbox_meta',
input_pop: 'input_pop',
sel_depart: 'sel_depart',
sel_user: 'sel_user',
slot: 'slot',
@@ -32,10 +32,10 @@ export { FormTypes, VALIDATE_NO_PASSED }
* 这个方法可以等待挂载完成之后再返回 $refs 的对象,避免报错
* @author sunjianlei
**/
export function getRefPromise(vm, name) {
export function getRefPromise (vm, name) {
return new Promise((resolve) => {
(function next() {
let ref = vm.$refs[name]
(function next () {
const ref = vm.$refs[name]
if (ref) {
resolve(ref)
} else {
@@ -54,13 +54,12 @@ export function getRefPromise(vm, name) {
* @returns {Promise<any>}
* @author sunjianlei
*/
export function validateFormAndTables(form, cases) {
export function validateFormAndTables (form, cases) {
if (!(form && typeof form.validateFields === 'function')) {
throw `form 参数需要的是一个form对象而传入的却是${typeof form}`
}
let options = {}
const options = {}
return new Promise((resolve, reject) => {
// 验证主表表单
form.validateFields((err, values) => {
@@ -76,7 +75,6 @@ export function validateFormAndTables(form, cases) {
}).catch(error => {
return Promise.reject(error)
})
}
/**
@@ -86,16 +84,15 @@ export function validateFormAndTables(form, cases) {
* @returns {Promise<any>}
* @author sunjianlei
*/
export function validateFormModelAndTables(form,values, cases) {
export function validateFormModelAndTables (form, values, cases) {
if (!(form && typeof form.validate === 'function')) {
throw `form 参数需要的是一个form对象而传入的却是${typeof form}`
}
let options = {}
const options = {}
return new Promise((resolve, reject) => {
// 验证主表表单
form.validate((valid,obj) => {
valid ?resolve(values):reject({ error: VALIDATE_NO_PASSED })
form.validate((valid, obj) => {
valid ? resolve(values) : reject({ error: VALIDATE_NO_PASSED })
})
}).then(values => {
Object.assign(options, { formValue: values })
@@ -107,7 +104,6 @@ export function validateFormModelAndTables(form,values, cases) {
}).catch(error => {
return Promise.reject(error)
})
}
/**
@@ -116,39 +112,41 @@ export function validateFormModelAndTables(form,values, cases) {
* @param deleteTempId 是否删除临时ID,如果设为true,行编辑就不返回新增行的ID,ID需要后台生成
* @author sunjianlei
*/
export function validateTables(cases, deleteTempId) {
export function validateTables (cases, deleteTempId) {
if (!(cases instanceof Array)) {
throw `'validateTables'函数的'cases'参数需要的是一个数组而传入的却是${typeof cases}`
}
return new Promise((resolve, reject) => {
let tables = []
let index = 0;
if(!cases || cases.length === 0){
const tables = []
let index = 0
if (!cases || cases.length === 0) {
resolve()
}
(function next() {
let vm = cases[index]
(function next () {
const vm = cases[index]
vm.getAll(true, deleteTempId).then(all => {
tables[index] = all
// 判断校验是否全部完成,完成返回成功,否则继续进行下一步校验
if (++index === cases.length) {
resolve(tables)
} else (
next()
)
} else {
(
next()
)
}
}, error => {
// 出现未验证通过的表单,不再进行下一步校验,直接返回失败并跳转到该表格
if (error === VALIDATE_NO_PASSED) {
// 尝试获取tabKey,如果在ATab组件内即可获取
let paneKey;
let tabPane = getVmParentByName(vm, 'ATabPane')
let paneKey
const tabPane = getVmParentByName(vm, 'ATabPane')
if (tabPane) {
paneKey = tabPane.$vnode.key
}
reject({error: VALIDATE_NO_PASSED, index, paneKey})
reject({ error: VALIDATE_NO_PASSED, index, paneKey })
}
reject(error)
})
})()
})
}
}