Browse Source

修改app表单

ZaiZai 1 year ago
parent
commit
0234dced73
2 changed files with 78 additions and 13 deletions
  1. 10 0
      public/plugins/app.js
  2. 68 13
      src/views/uni-app/components/log-form.vue

+ 10 - 0
public/plugins/app.js

@@ -84,3 +84,13 @@ function copyFormData()
         data: {},
     })
 }
+
+//获取PDF地址
+function getPdfUrl()
+{
+    window?.postMessage({
+        type: 'getPdfUrl',
+        source: 'app',
+        data: {},
+    })
+}

+ 68 - 13
src/views/uni-app/components/log-form.vue

@@ -6,7 +6,6 @@
 
 <script setup>
 import { onMounted, ref, watch } from 'vue'
-import wbsApi from '~api/data-fill/wbs'
 import { useAppStore } from '~src/store'
 import queryApi from '~api/ledger/query'
 import { getArrValue, getObjVal, getObjValue, isString } from 'js-fast-way'
@@ -69,6 +68,8 @@ const setMessage = ({ data, type }) => {
         linkTableFormClick(ids)
     } else if (type === 'copyFormData') {
         copyTableFormClick()
+    } else if (type === 'getPdfUrl') {
+        getBussPdfInfo()
     }
 }
 
@@ -237,6 +238,25 @@ const linkTableFormClick = (data) => {
     tableFormInfo.value.linkTabIds = data
 }
 
+//预览PDF
+const getBussPdfInfo = async () => {
+    const { contractId, excelId, pkeyId, date } = appItem.value
+    const { data } = await queryApi.getBussPdfInfo({
+        contractId: contractId,
+        pkeyId: excelId,
+        nodePrimaryKeyId: pkeyId,
+        recordTime: date,
+        theLogId: '',
+    }, false)
+    //处理数据
+    const resData = isString(data) ? data ?? '' : ''
+    window?.postMessage({
+        type: 'formPdfUrl',
+        source: 'web',
+        data: resData,
+    })
+}
+
 //切换显示模式
 const tableWidth = ref(0)
 const editTypeClick = (type) => {
@@ -253,27 +273,62 @@ const editTypeClick = (type) => {
 
 //保存表单
 const toSaveClick = async () => {
-    const { pkeyId, status } = appItem.value
-    if (!pkeyId) {
-        window?.$message?.warning('pkeyId为空')
-        return
-    } else if (status === '3') {
-        window?.$message?.warning('已上报的资料,不允许保存。')
+    const formLog = formLogDataList.value
+    let isLink = await isLinkTabIds(formLog)
+    if (!isLink) {
+        postMessage({
+            type: 'saveRes',
+            data: false,
+        })
         return
     }
-    const formData = tableFormRef.value?.getFormData()
-    const { error, code, msg } = await wbsApi.saveExcelBussData(formData, false)
+    //发起请求
+    const { error, code, msg } = await queryApi.saveExcelBussData({
+        dataInfo: { orderList: formLog },
+    }, false)
     if (!error && code === 200) {
         window?.$message?.success('保存成功')
-        window?.postMessage({
-            type: 'saveSuccess',
-            source: 'web',
-            data: {},
+        postMessage({
+            type: 'saveRes',
+            data: true,
         })
+        getBussPdfInfo().then()
     } else {
         window?.$message?.error(msg)
+        postMessage({
+            type: 'saveRes',
+            data: false,
+        })
+    }
+}
+
+//判断工序节点
+const isLinkTabIds = async (data) => {
+    const { nodeType } = appItem.value
+    if (nodeType === 7 || nodeType === 11) {
+        const isLink = data.some(({ linkTabIds }) => {
+            const linkIds = getArrValue(linkTabIds)
+            return linkIds.length > 0
+        })
+        if (isLink) {
+            return true
+        } else {
+            window?.$message?.warning('请先关联工序')
+            return false
+        }
+    } else {
+        return true
     }
 }
+
+//发送消息
+const postMessage = ({ type, data = {} }) => {
+    window?.postMessage({
+        type: type,
+        source: 'web',
+        data: data,
+    })
+}
 </script>
 
 <style lang="scss">