Browse Source

修改app表单

ZaiZai 1 year ago
parent
commit
20f14999d6
2 changed files with 55 additions and 26 deletions
  1. 20 0
      public/plugins/app.js
  2. 35 26
      src/views/uni-app/components/log-form.vue

+ 20 - 0
public/plugins/app.js

@@ -43,3 +43,23 @@ function pageTap(index)
         data: index,
     })
 }
+
+//日志填报,新增表格
+function addFormTap()
+{
+    window?.postMessage({
+        type: 'addForm',
+        source: 'app',
+        data: {},
+    })
+}
+
+//日志填报,删除当前表格
+function delFormTap()
+{
+    window?.postMessage({
+        type: 'delForm',
+        source: 'app',
+        data: {},
+    })
+}

+ 35 - 26
src/views/uni-app/components/log-form.vue

@@ -59,11 +59,14 @@ const setMessage = ({ data, type }) => {
     } else if (type === 'formSave') {
         toSaveClick()
     } else if (type === 'pageTap') {
-        console.log(data)
+        getBussDataInfo(data)
+    } else if (type === 'addForm') {
+        addTableFormClick()
+    } else if (type === 'delForm') {
+        delTableFormClick()
     }
 }
 
-
 const getDataApi = async () => {
     const { excelId } = appItem.value
     console.log('appItem', appItem.value)
@@ -103,11 +106,6 @@ const getTableFormInfo = async () => {
         theLogId: '',
     }, false)
     let res = getArrValue(data), formArrData = []
-    window?.postMessage({
-        type: 'formLength',
-        source: 'web',
-        data: res.length,
-    })
     if (res.length > 0) {
         for (let i = 0; i < res.length; i++) {
             formArrData.push(getFormDataInit(res[i]))
@@ -116,6 +114,7 @@ const getTableFormInfo = async () => {
         formArrData.push(getFormDataInit())
     }
     formLogDataList.value = formArrData
+    setFormLength()
     getBussDataInfo()
 }
 
@@ -139,25 +138,6 @@ const getBussDataInfo = (index = 0) => {
             page: index + 1,
         },
     })
-    //tableFormRef.value?.setExcelHtml()
-    //queryCurrentLogSelectProcessList(info?.id ?? '')
-}
-
-//获取当前日志资料关联的工序节点信息
-const queryCurrentLogSelectProcessList = async (bid) => {
-    const index = formLogIndex.value
-    if (bid) {
-        const { contractId } = appItem.value
-        const { data } = await queryApi.queryCurrentLogSelectProcessList({
-            contractId: contractId,
-            businessId: bid ?? '',
-        }, false)
-        //处理数据
-        formLogDataList.value[index]['linkTabIds'] = getArrValue(data)
-    } else {
-        //const formData = formLogDataList.value[index]
-        //processDataList.value = getArrValue(formData?.linkTabIds)
-    }
 }
 
 //获取模板标签数据
@@ -192,6 +172,35 @@ const tableFormRender = (form) => {
     tableFormInfo.value = form
 }
 
+//新增表格
+const addTableFormClick = () => {
+    const defaultData = getFormDataInit()
+    formLogDataList.value.push(defaultData)
+    const index = formLogDataList.value.length - 1
+    setFormLength()
+    getBussDataInfo(index)
+}
+
+
+//删除当前页
+const delTableFormClick = () => {
+    const index = formLogIndex.value
+    formLogDataList.value.splice(index, 1)
+    const logIndex = index <= 0 ? 0 : index - 1
+    formLogIndex.value = logIndex
+    setFormLength()
+    getBussDataInfo(logIndex)
+}
+
+//更新表单数量
+const setFormLength = () => {
+    window?.postMessage({
+        type: 'formLength',
+        source: 'web',
+        data: formLogDataList.value.length,
+    })
+}
+
 //切换显示模式
 const tableWidth = ref(0)
 const editTypeClick = (type) => {