Browse Source

修改app表单

ZaiZai 1 year ago
parent
commit
abf4ffe59e

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20230825155726"
+  "value": "20230825174334"
 }

+ 27 - 13
src/views/uni-app/components/data-form.vue

@@ -1,5 +1,5 @@
 <template>
-    <div v-loading="loading" class="hc-uni-app-table-form" :class="[editType]">
+    <div class="hc-uni-app-table-form" :class="[editType]">
         <hc-table-form ref="tableFormRef" :form="tableFormInfo" :html="excelHtml" :scroll="false" :pkey="appItem.pkeyId" @render="tableFormRender" />
     </div>
 </template>
@@ -24,7 +24,6 @@ const useAppState = useAppStore()
 const appItem = ref(props.option)
 const tableFormRef = ref(null)
 const editType = ref('form')
-const loading = ref(false)
 
 //深度监听
 watch(() => [
@@ -64,10 +63,8 @@ const getInitData = () => {
 
 const getDataApi = async () => {
     if (appItem.value.pkeyId) {
-        loading.value = true
         await getTableFormInfo()
         await getExcelHtml()
-        loading.value = false
     }
 }
 
@@ -120,7 +117,7 @@ const getExcelHtml = async () => {
     } else {
         excelHtml.value = ''
         tableFormInfo.value.isRenderForm = false
-        window?.$message?.warning('暂无表单')
+        postMsg('暂无表单', 'error')
     }
 }
 
@@ -153,25 +150,42 @@ const editTypeClick = (type) => {
 const toSaveClick = async () => {
     const { pkeyId, status } = appItem.value
     if (!pkeyId) {
-        window?.$message?.warning('pkeyId为空')
+        postMsg('pkeyId为空', 'error')
         return
     } else if (status === '3') {
-        window?.$message?.warning('已上报的资料,不允许保存。')
+        postMsg('已上报的资料,不允许保存。', 'error')
         return
     }
     const formData = tableFormRef.value?.getFormData()
     const { error, code, msg } = await wbsApi.saveExcelBussData(formData, false)
     if (!error && code === 200) {
-        window?.$message?.success('保存成功')
-        window?.postMessage({
-            type: 'saveSuccess',
-            source: 'web',
-            data: {},
-        })
+        postForm('saveSuccess')
+        postMsg('保存成功', 'success')
     } else {
         window?.$message?.error(msg)
     }
 }
+
+//发送消息
+const postForm = (name, data = {}) => {
+    window?.postMessage({
+        type: name,
+        source: 'web',
+        data: data,
+    })
+}
+
+//弹出提示
+const postMsg = (title, icon) => {
+    window?.postMessage({
+        type: 'msg',
+        source: 'web',
+        data: {
+            title: title,
+            icon: icon,
+        },
+    })
+}
 </script>
 
 <style lang="scss">

+ 22 - 14
src/views/uni-app/components/log-form.vue

@@ -1,5 +1,5 @@
 <template>
-    <div v-loading="loading" class="hc-uni-app-table-form" :class="[editType]">
+    <div class="hc-uni-app-table-form" :class="[editType]">
         <hc-table-form ref="tableFormRef" :form="tableFormInfo" :html="excelHtml" :scroll="false" :pkey="appItem.excelId" @render="tableFormRender" />
     </div>
 </template>
@@ -24,7 +24,6 @@ const useAppState = useAppStore()
 const appItem = ref(props.option)
 const tableFormRef = ref(null)
 const editType = ref('form')
-const loading = ref(false)
 
 //深度监听
 watch(() => [
@@ -75,12 +74,9 @@ const setMessage = ({ data, type }) => {
 
 const getDataApi = async () => {
     const { excelId } = appItem.value
-    console.log('appItem', appItem.value)
     if (excelId) {
-        loading.value = true
         await getTableFormInfo()
         await getExcelHtml()
-        loading.value = false
     }
 }
 
@@ -165,11 +161,11 @@ const getExcelHtml = async () => {
         } else {
             excelHtml.value = ''
             isTableForm.value = false
-            window?.$message?.warning('暂无表单')
+            postMsg('暂无表单', 'error')
         }
     } else {
         isTableForm.value = false
-        window?.$message?.error(`excelId: ${excelId || '-1 或 空'}`)
+        postMsg('参数异常', 'error')
     }
 }
 
@@ -190,7 +186,7 @@ const addTableFormClick = () => {
     const index = formLogDataList.value.length - 1
     setFormLength()
     getBussDataInfo(index)
-    window?.$message?.success('新增成功')
+    postMsg('新增成功', 'success')
 }
 
 //删除当前页
@@ -201,7 +197,7 @@ const delTableFormClick = () => {
     formLogIndex.value = logIndex
     setFormLength()
     getBussDataInfo(logIndex)
-    window?.$message?.success('删除成功')
+    postMsg('删除成功', 'success')
 }
 
 //复制当前表格及内容
@@ -216,7 +212,7 @@ const copyTableFormClick = () => {
     })
     setFormLength()
     getBussDataInfo(formLogDataList.value.length - 1)
-    window?.$message?.success('复制成功')
+    postMsg('复制成功', 'success')
 }
 
 //更新表单数量
@@ -283,22 +279,22 @@ const toSaveClick = async () => {
         return
     }
     //发起请求
-    const { error, code, msg } = await queryApi.saveExcelBussData({
+    const { error, code } = await queryApi.saveExcelBussData({
         dataInfo: { orderList: formLog },
     }, false)
     if (!error && code === 200) {
-        window?.$message?.success('保存成功')
         postMessage({
             type: 'saveRes',
             data: true,
         })
+        postMsg('保存成功', 'success')
         getBussPdfInfo().then()
     } else {
-        window?.$message?.error(msg)
         postMessage({
             type: 'saveRes',
             data: false,
         })
+        postMsg('保存失败', 'error')
     }
 }
 
@@ -313,7 +309,7 @@ const isLinkTabIds = async (data) => {
         if (isLink) {
             return true
         } else {
-            window?.$message?.warning('请先关联工序')
+            postMsg('请先关联工序', 'error')
             return false
         }
     } else {
@@ -329,6 +325,18 @@ const postMessage = ({ type, data = {} }) => {
         data: data,
     })
 }
+
+//弹出提示
+const postMsg = (title, icon) => {
+    window?.postMessage({
+        type: 'msg',
+        source: 'web',
+        data: {
+            title: title,
+            icon: icon,
+        },
+    })
+}
 </script>
 
 <style lang="scss">

+ 27 - 9
src/views/uni-app/table-form.vue

@@ -1,5 +1,5 @@
 <template>
-    <div v-if="isType === ''" v-loading="loading" class="hc-body-loading" element-loading-text="加载数据中...">
+    <div v-if="isType === ''" class="hc-body-loading">
         <div v-if="isErrorShow" class="error-page">
             <div class="img" :style="`background-image: url(${svg403});`" />
             <div class="content">
@@ -27,7 +27,6 @@ const useRoutes = useRoute()
 const store = useAppStore()
 
 //变量
-const loading = ref(true)
 const isErrorShow = ref(false)
 const isType = ref('')
 const formNode = ref({})
@@ -40,14 +39,14 @@ onMounted(() => {
         store.setIsSource(source)
         useAppLoginApi(userInfo)
     } else {
-        loading.value = false
+        formRender()
         isErrorShow.value = true
+        postMsg('参数异常', 'error')
     }
 })
 
 //请求授权登录
 const useAppLoginApi = async (form) => {
-    loading.value = true
     const { error, status, res } = await userLogin(form)
     if (!error && status === 200) {
         //设置token和用户信息
@@ -61,23 +60,42 @@ const useAppLoginApi = async (form) => {
         //处理其他数据
         setTimeout(() => {
             setFormType()
-            loading.value = false
             isErrorShow.value = false
         }, 1000)
     } else {
-        window.$message?.error('身份验证异常')
+        formRender()
         isErrorShow.value = true
-        loading.value = false
+        postMsg('身份验证异常', 'error')
     }
 }
 
+const formRender = () => {
+    window?.postMessage({
+        type: 'formRender',
+        source: 'web',
+        data: {},
+    })
+}
+
+//弹出提示
+const postMsg = (title, icon) => {
+    window?.postMessage({
+        type: 'msg',
+        source: 'web',
+        data: {
+            title: title,
+            icon: icon,
+        },
+    })
+}
+
 //处理数据
 const setFormType = () => {
     const { type, node } = useRoutes.query
     if (isNullES(type)) {
-        window.$message?.error('身份验证异常')
+        formRender()
         isErrorShow.value = true
-        loading.value = false
+        postMsg('身份验证异常', 'error')
         return
     }
     //处理其他数据