|
@@ -179,12 +179,14 @@
|
|
|
class="flex justify-center items-center"
|
|
|
>
|
|
|
<el-button
|
|
|
+ :loading="auditLoading"
|
|
|
type="danger"
|
|
|
@click="audit(2)"
|
|
|
>
|
|
|
驳回
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
+ :loading="auditLoading"
|
|
|
type="primary"
|
|
|
@click="audit(1)"
|
|
|
>
|
|
@@ -281,7 +283,7 @@ watch(
|
|
|
if (value === 1) {
|
|
|
// 创建 的状态是 通过 的.
|
|
|
form.value.status = 1
|
|
|
- } else if (value === 2) {
|
|
|
+ } else if ([2, 3].includes(value)) {
|
|
|
form.value = cloneDeep(itemData)
|
|
|
|
|
|
delete form.value.admin_name
|
|
@@ -291,50 +293,65 @@ watch(
|
|
|
}
|
|
|
},
|
|
|
)
|
|
|
-
|
|
|
+let loading = ref(false)
|
|
|
const formRef = ref<FormInstance>()
|
|
|
const checkForm = () => {
|
|
|
if (!formRef.value) return
|
|
|
+ if (loading.value === true) return
|
|
|
|
|
|
formRef.value.validate((valid: boolean) => {
|
|
|
if (valid) {
|
|
|
const p = cloneDeep(form.value)
|
|
|
-
|
|
|
+ loading.value = true
|
|
|
if (visible === 1) {
|
|
|
delete p.feedback
|
|
|
create(p)
|
|
|
} else if (visible === 2) {
|
|
|
delete p.feedback
|
|
|
edit(p)
|
|
|
+ } else if (visible === 3) {
|
|
|
+ delete p.feedback
|
|
|
+ edit(p)
|
|
|
+ setTimeout(() => {
|
|
|
+ auditLoading.value = false
|
|
|
+ }, 1000)
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
const create = (p: any) => {
|
|
|
- createSupplier(p).then((res: any) => {
|
|
|
- if (res.code === 1) {
|
|
|
- ElNotification({
|
|
|
- title: '创建成功',
|
|
|
- message: '正在刷新数据',
|
|
|
- duration: 3000,
|
|
|
- })
|
|
|
- resetData()
|
|
|
- close()
|
|
|
- }
|
|
|
- })
|
|
|
+ createSupplier(p)
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res.code === 1) {
|
|
|
+ ElNotification({
|
|
|
+ title: '创建成功',
|
|
|
+ message: '正在刷新数据',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ resetData()
|
|
|
+ close()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
}
|
|
|
const edit = (p: any) => {
|
|
|
- updateSupplier(p).then((res: any) => {
|
|
|
- if (res.code === 1) {
|
|
|
- ElNotification({
|
|
|
- title: '编辑成功',
|
|
|
- message: '正在刷新数据',
|
|
|
- duration: 3000,
|
|
|
- })
|
|
|
- resetData()
|
|
|
- close()
|
|
|
- }
|
|
|
- })
|
|
|
+ updateSupplier(p)
|
|
|
+ .then((res: any) => {
|
|
|
+ if (res.code === 1) {
|
|
|
+ ElNotification({
|
|
|
+ title: '操作成功',
|
|
|
+ message: '正在刷新数据',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ resetData()
|
|
|
+ close()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
}
|
|
|
const resetData = () => {
|
|
|
form.value = {
|
|
@@ -366,6 +383,7 @@ let close = (done = {} as any) => {
|
|
|
$emit('update:visible', 0)
|
|
|
if (typeof done === 'function') done()
|
|
|
}
|
|
|
+let auditLoading = ref(false)
|
|
|
const audit = (status: number = 2) => {
|
|
|
const d = {
|
|
|
status,
|
|
@@ -373,13 +391,21 @@ const audit = (status: number = 2) => {
|
|
|
feedback: form.value.feedback || '',
|
|
|
}
|
|
|
console.log(d, 'd')
|
|
|
- saveExamine(d).then(() => {
|
|
|
- ElNotification({
|
|
|
- title: '操作成功',
|
|
|
- message: '正在刷新数据',
|
|
|
- duration: 3000,
|
|
|
- })
|
|
|
- close()
|
|
|
+ if (auditLoading.value) return
|
|
|
+ auditLoading.value = true
|
|
|
+ saveExamine(d).then((res: any) => {
|
|
|
+ form.value.status = 1
|
|
|
+ // 审核通过后保存编辑的内容.
|
|
|
+ if (res.result == 1) {
|
|
|
+ checkForm()
|
|
|
+ } else {
|
|
|
+ auditLoading.value = false
|
|
|
+ ElNotification({
|
|
|
+ title: '操作失败',
|
|
|
+ message: '请刷新稍后再试或者联系管理员',
|
|
|
+ duration: 3000,
|
|
|
+ })
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
</script>
|