diff --git a/pages/components/pages/customer/add.vue b/pages/components/pages/customer/add.vue index 1fb96fb..acc0e27 100644 --- a/pages/components/pages/customer/add.vue +++ b/pages/components/pages/customer/add.vue @@ -157,7 +157,8 @@ const tagVal = ref('') const tagList = ref([]) const form = ref({ - name: '' + name: '', + repeatConfirmationFlag: 0 //重复客户依旧添加 0否 1是 }) const type = ref('add') const errorType = ref('message') @@ -355,19 +356,47 @@ }) }) } - // 提交 - const onSubmit = async () => { - if (type.value == 'add') { - await customerCreate(form.value) - if (prePage().route == 'pages/customer/index') { - prePage().$vm.isRefresh = true - } - uni.navigateBack() - } else { - await customerUpdate(form.value) - uni.navigateBack() - } + // 提交 + const onSubmit = () => { + if (type.value == 'add') { + customerCreate(form.value).then(res => { + if (prePage().route == 'pages/customer/index') { + prePage().$vm.isRefresh = true + } + uni.navigateBack() + }).catch(e => { + if (e.data.code == 200012) { + uni.showModal({ + title: '提示', + content: e.data.msg, + success: (res) => { + if (res.confirm) { + form.value.repeatConfirmationFlag = 1 + onSubmit() + } + } + }); + } + }) + } else { + customerUpdate(form.value).then(res => { + uni.navigateBack() + }).catch(e => { + if (e.data.code == 200012) { + uni.showModal({ + title: '提示', + content: e.data.msg, + success: (res) => { + if (res.confirm) { + form.value.repeatConfirmationFlag = 1 + onSubmit() + } + } + }); + } + }) + } }