Jelajahi Sumber

更换插件

ZaiZai 2 tahun lalu
induk
melakukan
f0b4f6f7cd

+ 6 - 6
src/components/table-form/index.vue

@@ -15,7 +15,7 @@
 </template>
 
 <script setup>
-import {ref, watch, onMounted, nextTick, onUnmounted} from "vue"
+import {ref, watch, onMounted, nextTick} from "vue"
 import HTableForm from "~src/plugins/HTableForm"
 import notableform from '~src/assets/view/notableform.svg'
 import {getStoreValue, setStoreValue, delStoreValue} from "~uti/storage";
@@ -102,6 +102,7 @@ watch(() => [
     props.form
 ], ([val]) => {
     excelForm.value = val
+    console.log('表单数据变动', val)
     setPickerKey()
     setFormData(val)
 }, {
@@ -165,13 +166,15 @@ const getExcelHtml = () => {
     if (temp && pkeyId) {
         //渲染表单
         isTableForm.value = true
-        tableFormApp.value = HTableForm.createForm(excelForm.value, {
+        tableFormApp.value = HTableForm.createForm({
             pid: pid,
             template: temp,
             keys: colsKeys.value,
+            tableForm: excelForm.value,
             appId: `#table-form-${pkeyId}`,
             onFormDataChange: (form) => {
                 excelForm.value = form
+                emit('render', form)
             },
             onRight: (event, KeyName) => {
                 onRightClick(pkeyId, event, KeyName, pid)
@@ -351,10 +354,7 @@ const getFormData = () => {
 
 //设置表单数据
 const setFormData = (data) => {
-    excelForm.value = deepClone(data)
-    //console.log(tableFormApp.value)
-    //tableFormApp.value?.setFormData(data)
-    //setExcelHtml()
+    excelForm.value = data
 }
 
 //获取表单效验数据

+ 2 - 2
src/plugins/HTableForm.js

@@ -30,7 +30,7 @@ export default class HTableForm {
 
     static tableFormApp = null
 
-    static createForm(tableForm, {template, keys, appId, pid, onRight, onBlur, onLeftClick, onFormDataChange}) {
+    static createForm({template, tableForm, keys, appId, pid, onRight, onBlur, onLeftClick, onFormDataChange}) {
         const _this = this;
         const app = createApp({
             data() {
@@ -49,7 +49,7 @@ export default class HTableForm {
                     handler(obj) {
                         this.formData = obj
                     },
-                    deep: true,
+                    deep: true
                 },
                 formData: {
                     handler(obj) {

+ 4 - 5
src/views/data-fill/collapse-form/index.vue

@@ -479,10 +479,9 @@ const setFormDataNum = (datas) => {
 
 //渲染完成
 const tableFormRender = (form, item, index) => {
-    formDataList.value[index] = {
-        ...form,
-        isCollapseLoad: form.isRenderForm
-    }
+    console.log(form)
+    formDataList.value[index] = form
+    formDataList.value[index].isCollapseLoad = form.isRenderForm
     item.isTableForm = form.isRenderForm
 }
 
@@ -1228,7 +1227,7 @@ const getFormData = async () => {
         const form = refs?.getFormData()
         newArr.push({...form})
     }
-    //console.log('表单数据', newArr)
+    console.log('表单数据', newArr)
     return newArr
 }
 

+ 8 - 4
src/views/data-fill/collapse-form/table-form-item.vue

@@ -20,7 +20,7 @@ import {ref, watch, onMounted} from "vue"
 import {useAppStore} from "~src/store";
 import wbsApi from "~api/data-fill/wbs";
 import HcTableForm from "~com/table-form/index.vue"
-import {getArrValue, getObjVal, isString} from "js-fast-way"
+import {deepClone, getArrValue, getObjVal, isString} from "js-fast-way"
 
 //初始
 const props = defineProps({
@@ -218,6 +218,7 @@ const getExcelHtml = async (pkeyId) => {
 
 //渲染完成
 const tableFormRender = (form) => {
+    tableFormInfo.value = form
     emit('render', form)
 }
 
@@ -228,16 +229,19 @@ const tableFormRightTap = (item) => {
 
 //设置数据
 const setFormChangeData = (data) => {
-    const form = tableFormInfo.value
+    const form = deepClone(tableFormInfo.value)
     tableFormInfo.value = {...form, ...data}
+    console.log('设置数据', {...form, ...data})
 }
 
 const getFormData = () => {
-    return tableFormRef.value?.getFormData()
+    return tableFormInfo.value
+    //return tableFormRef.value?.getFormData()
 }
 
 const setFormData = (data) => {
-    tableFormRef.value?.setFormData(data)
+    setFormChangeData(data)
+    tableFormRef.value?.setFormData(tableFormInfo.value)
 }
 
 const getRegExpJson = () => {

+ 1 - 1
src/views/data-fill/wbs.vue

@@ -1713,7 +1713,7 @@ const tableFormSaveClick = async () => {
         setFormRegExpJson(FormRegExpJson)
     } else if (FormData.length > 0) {
         tableFormSaveLoading.value = true
-        //console.log('FormData', FormData)
+        console.log('FormData', FormData)
         const {error, code} = await wbsApi.saveExcelBussData({
             dataInfo: {orderList: FormData}
         })