优化增加请求时loading
This commit is contained in:
parent
885b616c71
commit
ace08af8ca
|
|
@ -39,7 +39,7 @@ export default {
|
|||
// 防抖延迟时间(毫秒)
|
||||
debounceTime: {
|
||||
type: Number,
|
||||
default: 800,
|
||||
default: 500,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
|
|
@ -80,7 +80,7 @@ export default {
|
|||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('按钮点击事件执行失败:', error)
|
||||
// console.error('按钮点击事件执行失败:', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,13 +145,13 @@
|
|||
>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button
|
||||
<ComButton
|
||||
size="medium"
|
||||
type="primary"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
</el-button>
|
||||
</ComButton>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
|
|
@ -212,6 +212,7 @@
|
|||
<script>
|
||||
import TableModel from '@/components/TableModel'
|
||||
import DialogModel from '@/components/DialogModel'
|
||||
import ComButton from '@/components/ComButton'
|
||||
|
||||
import { formLabel, columnsList, dialogConfig } from './config'
|
||||
import {
|
||||
|
|
@ -226,6 +227,7 @@ export default {
|
|||
components: {
|
||||
TableModel,
|
||||
DialogModel,
|
||||
ComButton,
|
||||
},
|
||||
|
||||
data() {
|
||||
|
|
@ -336,31 +338,37 @@ export default {
|
|||
|
||||
// 确定按钮
|
||||
onHandleConfirmAddOrEdit() {
|
||||
this.$refs.addOrEditFormRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
const params = {
|
||||
...this.addOrEditForm,
|
||||
}
|
||||
if (this.dialogConfig.outerTitle === '新增总工程') {
|
||||
delete params.id
|
||||
}
|
||||
const res = await addAndEditAllProjectAPI(params)
|
||||
return new Promise(async (resolve, reject) => {
|
||||
this.$refs.addOrEditFormRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
const params = {
|
||||
...this.addOrEditForm,
|
||||
}
|
||||
if (this.dialogConfig.outerTitle === '新增总工程') {
|
||||
delete params.id
|
||||
}
|
||||
const res = await addAndEditAllProjectAPI(params)
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess(
|
||||
this.dialogConfig.outerTitle === '新增总工程'
|
||||
? '新增成功'
|
||||
: '修改成功',
|
||||
)
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.allProjectTableRef.getTableList() // 更新列表
|
||||
resolve()
|
||||
|
||||
// 更新store中的总包工程列表
|
||||
this.$store.dispatch('getMainProjectList')
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess(
|
||||
this.dialogConfig.outerTitle === '新增总工程'
|
||||
? '新增成功'
|
||||
: '修改成功',
|
||||
)
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.allProjectTableRef.getTableList() // 更新列表
|
||||
|
||||
// 更新store中的总包工程列表
|
||||
this.$store.dispatch('getMainProjectList')
|
||||
} else {
|
||||
this.$modal.msgError(res.msg)
|
||||
}
|
||||
} else {
|
||||
this.$modal.msgError(res.msg)
|
||||
reject()
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ export default {
|
|||
|
||||
// 确定按钮
|
||||
async onHandleConfirmAddOrEdit() {
|
||||
return new Promise(async (resolve) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
this.$refs.addOrEditFormRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
const params = {
|
||||
|
|
@ -343,6 +343,7 @@ export default {
|
|||
}
|
||||
|
||||
const res = await addAndEditDeptProjectAPI(params)
|
||||
resolve()
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess(
|
||||
this.dialogConfig.outerTitle === '新增项目部'
|
||||
|
|
@ -353,7 +354,8 @@ export default {
|
|||
this.$refs.deptProjectTableRef.getTableList() // 更新列表
|
||||
this.$store.dispatch('getSubCompanySelectList') // 更新store中的分公司列表
|
||||
}
|
||||
resolve()
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -94,13 +94,13 @@
|
|||
<el-button size="medium" @click="handleCloseDialogOuter">
|
||||
取消
|
||||
</el-button>
|
||||
<el-button
|
||||
<ComButton
|
||||
size="medium"
|
||||
type="primary"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
</el-button>
|
||||
</ComButton>
|
||||
</el-row>
|
||||
</template>
|
||||
</DialogModel>
|
||||
|
|
@ -111,6 +111,7 @@
|
|||
import TableModel from '@/components/TableModel'
|
||||
import DialogModel from '@/components/DialogModel'
|
||||
import AddOrEditForm from './add-or-edit-form'
|
||||
import ComButton from '@/components/ComButton'
|
||||
import { formLabel, columnsList, dialogConfig } from './config'
|
||||
import {
|
||||
deleteLotLotProjectAPI,
|
||||
|
|
@ -131,6 +132,7 @@ export default {
|
|||
TableModel,
|
||||
DialogModel,
|
||||
AddOrEditForm,
|
||||
ComButton,
|
||||
},
|
||||
|
||||
data() {
|
||||
|
|
@ -286,13 +288,17 @@ export default {
|
|||
|
||||
// 确定按钮
|
||||
async onHandleConfirmAddOrEdit() {
|
||||
try {
|
||||
await this.$refs.addOrEditLotProjectFormRef.onHandleConfirmAddOrEditFun()
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.lotProjectTableRef.getTableList() // 更新列表
|
||||
} catch (error) {
|
||||
// console.log('表单提交失败', error)
|
||||
}
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
await this.$refs.addOrEditLotProjectFormRef.onHandleConfirmAddOrEditFun()
|
||||
resolve()
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.lotProjectTableRef.getTableList() // 更新列表
|
||||
} catch (error) {
|
||||
// console.log('表单提交失败', error)
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 关闭弹框
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@
|
|||
<el-button
|
||||
size="medium"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
|
|
@ -148,6 +149,7 @@
|
|||
import TableModel from '@/components/TableModel'
|
||||
import DialogModel from '@/components/DialogModel'
|
||||
import AddAndBindForm from './add-and-bind.form.vue'
|
||||
|
||||
import { formLabel, columnsList, dialogConfig } from './config'
|
||||
import {
|
||||
editAttendanceMachineAPI,
|
||||
|
|
@ -164,6 +166,7 @@ export default {
|
|||
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
formType: 1,
|
||||
formLabel,
|
||||
columnsList,
|
||||
|
|
@ -248,12 +251,15 @@ export default {
|
|||
|
||||
// 确定按钮
|
||||
async onHandleConfirmAddOrEdit() {
|
||||
this.loading = true
|
||||
try {
|
||||
await this.$refs.addOrEditSubBaseInfoRef.onHandleConfirmAddOrEditFun()
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.attendanceMachineTableRef.getTableList()
|
||||
} catch (error) {
|
||||
// console.log('表单提交失败', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -305,11 +305,15 @@ export default {
|
|||
// }, 300),
|
||||
|
||||
onHandleConfirmAddOrEdit() {
|
||||
return new Promise(async (resolve) => {
|
||||
await this.$refs.addOrEditFormContentRef.onHandleConfirmAddOrEditFun()
|
||||
this.$refs.personEntryTableRef.getTableList()
|
||||
this.handleCloseDialogOuter()
|
||||
resolve()
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
await this.$refs.addOrEditFormContentRef.onHandleConfirmAddOrEditFun()
|
||||
this.$refs.personEntryTableRef.getTableList()
|
||||
this.handleCloseDialogOuter()
|
||||
resolve()
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
// await this.$refs.addOrEditFormContentRef.onHandleConfirmAddOrEditFun()
|
||||
// this.$refs.personEntryTableRef.getTableList()
|
||||
|
|
|
|||
|
|
@ -691,7 +691,7 @@ export default {
|
|||
const res = await this.addShanghaiProEin()
|
||||
if (res) {
|
||||
this.$emit('closeDialogOuter')
|
||||
resolve()
|
||||
// resolve()
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -702,7 +702,7 @@ export default {
|
|||
this.$refs.addEntryProjectFormRef.resetFields()
|
||||
this.dialogConfig.outerVisible = false
|
||||
this.getShanghaiProList()
|
||||
resolve()
|
||||
// resolve()
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@
|
|||
<el-button
|
||||
size="medium"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
|
|
@ -170,6 +171,7 @@ export default {
|
|||
formType: 1, // 表单类型
|
||||
workerId: '', // 人员id
|
||||
proId: '', // 标段工程id
|
||||
loading: false,
|
||||
|
||||
slots: {
|
||||
businessLicense: 'businessLicense',
|
||||
|
|
@ -254,6 +256,7 @@ export default {
|
|||
onHandleConfirmAddOrEdit: debounce(function () {
|
||||
// 在这里定义异步操作
|
||||
const handleAsync = async () => {
|
||||
this.loading = true
|
||||
try {
|
||||
const res =
|
||||
await this.$refs.uploadContractContentRef.onHandleConfirmAddOrEditFun()
|
||||
|
|
@ -264,12 +267,14 @@ export default {
|
|||
} catch (error) {
|
||||
// 错误处理
|
||||
console.error('表单提交失败', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
|
||||
// 执行异步函数
|
||||
handleAsync()
|
||||
}, 1000),
|
||||
}, 500),
|
||||
|
||||
// 关闭弹框
|
||||
handleCloseDialogOuter() {
|
||||
|
|
|
|||
|
|
@ -322,13 +322,13 @@
|
|||
>
|
||||
取消
|
||||
</el-button>
|
||||
<el-button
|
||||
<ComButton
|
||||
size="medium"
|
||||
type="primary"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
</el-button>
|
||||
</ComButton>
|
||||
</el-row>
|
||||
</template>
|
||||
|
||||
|
|
@ -364,6 +364,7 @@
|
|||
import TableModel from '@/components/TableModel'
|
||||
import DialogModel from '@/components/DialogModel'
|
||||
import UploadFileFormData from '@/components/UploadFileFormData'
|
||||
import ComButton from '@/components/ComButton'
|
||||
import { formLabel, columnsList, dialogConfig } from './config'
|
||||
import {
|
||||
getSubSelectListCommonFun,
|
||||
|
|
@ -385,6 +386,7 @@ export default {
|
|||
TableModel,
|
||||
DialogModel,
|
||||
UploadFileFormData,
|
||||
ComButton,
|
||||
},
|
||||
|
||||
data() {
|
||||
|
|
@ -530,62 +532,70 @@ export default {
|
|||
},
|
||||
|
||||
onHandleConfirmAddOrEdit() {
|
||||
this.$refs.addDishonestyPersonFormRef.validate(async (valid) => {
|
||||
if (valid) {
|
||||
// 组装参数
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$refs.addDishonestyPersonFormRef.validate(
|
||||
async (valid) => {
|
||||
if (valid) {
|
||||
// 组装参数
|
||||
|
||||
const {
|
||||
name, // 姓名
|
||||
idNumber, // 身份证
|
||||
postName, // 工种名称
|
||||
proName, // 工程名称
|
||||
subName, // 所属分包单位
|
||||
reason, // 事件
|
||||
endTime, // 结束日期
|
||||
startTime, // 开始日期
|
||||
remark, // 备注
|
||||
fileList,
|
||||
} = this.addDishonestyPersonForm
|
||||
const {
|
||||
name, // 姓名
|
||||
idNumber, // 身份证
|
||||
postName, // 工种名称
|
||||
proName, // 工程名称
|
||||
subName, // 所属分包单位
|
||||
reason, // 事件
|
||||
endTime, // 结束日期
|
||||
startTime, // 开始日期
|
||||
remark, // 备注
|
||||
fileList,
|
||||
} = this.addDishonestyPersonForm
|
||||
|
||||
const params = {
|
||||
name, // 姓名
|
||||
idNumber, // 身份证
|
||||
postName, // 工种名称
|
||||
proName, // 工程名称
|
||||
subName, // 所属分包单位
|
||||
reason, // 事件
|
||||
endTime, // 结束日期
|
||||
startTime, // 开始日期
|
||||
remark, // 备注
|
||||
}
|
||||
const formData = new FormData()
|
||||
const fileMsg = []
|
||||
const params = {
|
||||
name, // 姓名
|
||||
idNumber, // 身份证
|
||||
postName, // 工种名称
|
||||
proName, // 工程名称
|
||||
subName, // 所属分包单位
|
||||
reason, // 事件
|
||||
endTime, // 结束日期
|
||||
startTime, // 开始日期
|
||||
remark, // 备注
|
||||
}
|
||||
const formData = new FormData()
|
||||
const fileMsg = []
|
||||
|
||||
if (fileList.length > 0) {
|
||||
fileList.forEach((e) => {
|
||||
formData.append('files', e.raw)
|
||||
fileMsg.push({
|
||||
type: 1,
|
||||
name: '附件',
|
||||
})
|
||||
})
|
||||
}
|
||||
formData.append('params', JSON.stringify(params))
|
||||
formData.append('fileMsg', JSON.stringify(fileMsg))
|
||||
if (fileList.length > 0) {
|
||||
fileList.forEach((e) => {
|
||||
formData.append('files', e.raw)
|
||||
fileMsg.push({
|
||||
type: 1,
|
||||
name: '附件',
|
||||
})
|
||||
})
|
||||
}
|
||||
formData.append('params', JSON.stringify(params))
|
||||
formData.append('fileMsg', JSON.stringify(fileMsg))
|
||||
|
||||
const res = await addDishonestyPersonAPI(formData)
|
||||
const res = await addDishonestyPersonAPI(formData)
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.isForever = false
|
||||
this.addDishonestyPersonForm.endTime = ''
|
||||
this.$refs.addDishonestyPersonFormRef.resetFields()
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.dishonestyPersonTableRef.getTableList()
|
||||
} else {
|
||||
this.$modal.msgError(res.msg)
|
||||
}
|
||||
}
|
||||
resolve()
|
||||
|
||||
if (res.code === 200) {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.isForever = false
|
||||
this.addDishonestyPersonForm.endTime = ''
|
||||
this.$refs.addDishonestyPersonFormRef.resetFields()
|
||||
this.handleCloseDialogOuter()
|
||||
this.$refs.dishonestyPersonTableRef.getTableList()
|
||||
} else {
|
||||
this.$modal.msgError(res.msg)
|
||||
}
|
||||
} else {
|
||||
reject()
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
<el-button
|
||||
size="medium"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="onHandleConfirmAddOrEdit"
|
||||
>
|
||||
确定
|
||||
|
|
@ -151,6 +152,7 @@ export default {
|
|||
workerId: '', // 人员id
|
||||
contractImgList: [], // 合同图片列表
|
||||
proId: '', // 标段工程id
|
||||
loading: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -213,6 +215,7 @@ export default {
|
|||
// 确定按钮
|
||||
onHandleConfirmAddOrEdit: debounce(function () {
|
||||
const handleAsync = async () => {
|
||||
this.loading = true
|
||||
try {
|
||||
const res =
|
||||
await this.$refs.uploadContractContentRef.onHandleConfirmAddOrEditFun()
|
||||
|
|
@ -223,10 +226,12 @@ export default {
|
|||
this.handleCloseDialogOuter()
|
||||
} catch (error) {
|
||||
// console.log('表单提交失败', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
handleAsync()
|
||||
}, 1000),
|
||||
}, 500),
|
||||
|
||||
// 关闭弹框
|
||||
handleCloseDialogOuter() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue