Bladeren bron

app填报

ZaiZai 2 jaren geleden
bovenliggende
commit
bc47abcd3b
2 gewijzigde bestanden met toevoegingen van 122 en 7 verwijderingen
  1. 12 1
      index.html
  2. 110 6
      src/views/uni-app/table-form.vue

+ 12 - 1
index.html

@@ -8,11 +8,22 @@
         <link rel="stylesheet" href="/plugins/element-plus/theme-chalk/dark/css-vars.css"/>
         <link rel="stylesheet" href="/plugins/remixicon/remixicon.css"/>
         <link rel="stylesheet" href="/plugins/fonts/index.css"/>
-        <script type="text/javascript" src="/plugins/uni.webview.1.5.5.js"></script>
         <title></title>
     </head>
     <body>
         <div id="app"></div>
+        <script type="text/javascript" src="/plugins/uni.webview.1.5.5.js"></script>
+        <script>
+            //监听uni-app的事件
+            document.addEventListener('UniAppJSBridgeReady', () => {
+                //接受子页面传递过来的消息数据
+                window.addEventListener('message', (event) => {
+                    uni.postMessage({
+                        data: event.data
+                    });
+                });
+            });
+        </script>
         <script type="module" src="/src/main.js"></script>
     </body>
 </html>

+ 110 - 6
src/views/uni-app/table-form.vue

@@ -1,19 +1,19 @@
 <template>
-    <div class="hc-uni-app-table-form" :class="[editType]">
+    <div v-loading="loading" class="hc-uni-app-table-form" :class="[editType]">
         <div class="title-bar">
             <el-button v-if="editType === 'form'" color="#EBF9F4" @click="editTypeClick('auto')">切换</el-button>
             <el-button v-if="editType === 'auto'" color="#EBF9F4" @click="editTypeClick('table')">切换</el-button>
             <el-button v-if="editType === 'table'" color="#EBF9F4" @click="editTypeClick('form')">切换</el-button>
-            <el-button color="#EBF9F4">复制</el-button>
-            <el-button color="#EBF9F4">隐藏</el-button>
-            <el-button color="#EBF9F4">预览</el-button>
+            <el-button color="#EBF9F4" @click="toCopyClick">复制</el-button>
+            <el-button color="#EBF9F4" @click="toHideClick">隐藏</el-button>
+            <el-button color="#EBF9F4" @click="previewClick">预览</el-button>
             <el-button color="#EBF9F4">上传</el-button>
         </div>
         <div class="hc-app-table-form" :style="tableWidth > 0 ? `width: ${tableWidth}px;` : ''">
-            <hc-table-form ref="tableFormRef" :form="tableFormInfo" :html="excelHtml" :scroll="false" :loading="loading" :pkey="appItem.pkeyId" @render="tableFormRender" />
+            <hc-table-form ref="tableFormRef" :form="tableFormInfo" :html="excelHtml" :scroll="false" :pkey="appItem.pkeyId" @render="tableFormRender" />
         </div>
         <div class="action-bar">
-            <el-button hc-btn type="primary" size="large">保 存</el-button>
+            <el-button hc-btn type="primary" size="large" @click="toSaveClick">保 存</el-button>
         </div>
     </div>
 </template>
@@ -41,8 +41,10 @@ onMounted(() => {
 
 const getDataApi = async () => {
     if (appItem.pkeyId) {
+        loading.value = true
         await getTableFormInfo()
         await getExcelHtml()
+        loading.value = false
     }
 }
 
@@ -121,6 +123,108 @@ const editTypeClick = (type) => {
     }
     editType.value = type
 }
+
+//复制表
+const toCopyClick = async () => {
+    const { pkeyId, status } = appItem
+    if (!pkeyId) {
+        window?.$message?.warning('pkeyId为空')
+        return
+    } else if (status === '3') {
+        window?.$message?.warning('已上报的资料,不允许复制')
+        return
+    }
+    loading.value = true
+    const { error, code, msg } = await wbsApi.copeBussTab({
+        pkeyId: pkeyId,
+    }, false)
+    loading.value = false
+    if (!error && code === 200) {
+        window?.$message?.success('操作成功')
+        //通知 uni-app,该刷新列表了
+        window?.postMessage({
+            type: 'back',
+        })
+    } else {
+        window?.$message?.error(msg)
+    }
+}
+
+//隐藏表单
+const toHideClick = async () => {
+    const { pkeyId, status } = appItem
+    if (!pkeyId) {
+        window?.$message?.warning('pkeyId为空')
+        return
+    } else if (status === '3') {
+        window?.$message?.warning('已上报的资料,不允许隐藏示')
+        return
+    }
+    loading.value = true
+    const { error, code, msg } = await wbsApi.showBussTab({
+        pkeyId: pkeyId,
+        status: 2,
+    })
+    loading.value = false
+    if (!error && code === 200) {
+        window?.$message?.success('操作成功')
+        //通知 uni-app,该刷新列表了
+        window?.postMessage({
+            type: 'back',
+        })
+    } else {
+        window?.$message?.error(msg)
+    }
+}
+
+//预览表单
+const previewClick = async () => {
+    const { pkeyId } = appItem, { isBussShow, isTabPdf, pdfUrl } = wbsInfo.value
+    if (!pkeyId) {
+        window?.$message?.warning('pkeyId为空')
+        return
+    } else if (isBussShow === 2 || isTabPdf === 1 || pdfUrl === '') {
+        window?.$message?.warning('当前状态无法预览')
+        return
+    }
+    loading.value = true
+    const { error, code, data, msg } = await wbsApi.getBussPdfInfo({
+        pkeyId: pkeyId,
+    })
+    loading.value = false
+    if (!error && code === 200) {
+        if (data) {
+            console.log(data)
+            //window.open(data, '_blank')
+        } else {
+            window?.$message?.warning('PDF错误')
+        }
+    } else {
+        window?.$message?.error(msg)
+    }
+}
+
+//保存表单
+const toSaveClick = async () => {
+    const { pkeyId, status } = appItem
+    if (!pkeyId) {
+        window?.$message?.warning('pkeyId为空')
+        return
+    } else if (status === '3') {
+        window?.$message?.warning('已上报的资料,不允许保存。')
+        return
+    }
+    loading.value = true
+    const formData = tableFormRef.value?.getFormData()
+    const { error, code, msg } = await wbsApi.saveExcelBussData(formData, false)
+    loading.value = false
+    if (!error && code === 200) {
+        //window?.$message?.success('保存成功')
+        previewClick().then()
+    } else {
+        window?.$message?.error(msg)
+    }
+}
 </script>
 
 <style lang="scss">