ZaiZai 1 year ago
parent
commit
afdd2adb78
1 changed files with 37 additions and 6 deletions
  1. 37 6
      pages/image/form.vue

+ 37 - 6
pages/image/form.vue

@@ -158,7 +158,6 @@ const getInfoApi = async () => {
     })
     const res = getObjValue(data)
     formData.value = res
-    console.log(res)
     const {imageUrl, pdfUrl} = res
     fileList.value = imageUrl.toString().split(',')
     pdfList.value = pdfUrl.toString().split(',')
@@ -253,17 +252,23 @@ const formRules = {
     },
 }
 
-//提交保存
-const saveClick = async () => {
+const isFormValidate = async () => {
     if (fileList.value.length <= 0) {
         errorToast('请先上传文件')
         return false
     }
-    const isForm = formValidate(formRef.value)
+    const isForm = await formValidate(formRef.value)
     if (!isForm) {
         errorToast('请先完善表单')
         return false
     }
+    return true
+}
+
+//提交保存
+const saveClick = async () => {
+    const isForm = await isFormValidate()
+    if (!isForm) return false;
     //更新数据
     if (dataId.value) {
         await updateImageData()
@@ -299,18 +304,44 @@ const addImageData = async () => {
     uni.hideLoading();
     if (!error && code === 200) {
         successToast('新增成功')
+        return true
     } else {
         errorToast('新增失败: ' + msg)
+        return false
     }
 }
 
 //继续新增
 const continueAdd = async () => {
-    console.log(formData.value)
+    const isForm = await isFormValidate()
+    if (!isForm) return false;
+    const res = await addImageData()
+    if(!res) return false;
+    //清空表单
+    const {real_name} = userInfo.value
+    const { wbsId } = formData.value;
+    formData.value.uploadTime = dateEnd.value
+    formData.value.shootingTimeStr = dateEnd.value
+    formData.value.shootingUser = real_name
+    formData.value.title = ''
+    formData.value.textContent = ''
+    formData.value.photoCode = ''
+    formData.value.filmCode = ''
+    formData.value.seeAlsoCode = ''
+    fileList.value = []
+    pdfList.value = []
+    getFileTitleNamedata(wbsId).then()
 }
 
 //新增保存
 const saveAdd = async () => {
-
+    const isForm = await isFormValidate()
+    if (!isForm) return false;
+    const res = await addImageData()
+    if(!res) return false;
+    //返回上一页
+    setTimeout(() => {
+        uni.navigateBack()
+    }, 1500)
 }
 </script>