ZaiZai 2 éve
szülő
commit
281cb7b157

+ 4 - 1
src/plugins/HTableForm.js

@@ -28,7 +28,7 @@ export default class HTableForm {
     static tableFormApp = null
     static tableFormVM = null
 
-    static createForm({template, tableForm, keys, appId, pid, onRight, onBlur, onLeftClick, onFormDataChange})
+    static createForm({template, tableForm, keys, appId, pid, onRight, onBlur, onLeftClick, onFormDataChange, onChartRefs})
     {
         const _this = this;
         const app = createApp({
@@ -137,6 +137,9 @@ export default class HTableForm {
                         }
                     }, 100)
                 },
+                setChartRefs(el, pKeyId, key) {
+                    if (onChartRefs) onChartRefs(el, pKeyId, key)
+                }
             }
         })
         // 饿了么UI框架

+ 30 - 3
src/views/tentative/detect/components/ListItem.vue

@@ -190,7 +190,7 @@ import {
     deepClone,
     setPosInsert,
     setPosRange,
-    getObjValue
+    getObjValue, arrIndex
 } from "js-fast-way"
 
 const router = useRouter()
@@ -384,6 +384,9 @@ const getExcelHtml = async (item, index) => {
                 template: resData,
                 tableForm: formData.value[index],
                 appId: `#table-form-${pkeyIds}`,
+                onChartRefs: (el, pKeyId, key) => {
+                    setChartRefs(el, pKeyId, key)
+                },
                 onRight: (event, KeyName) => {
                     onRightClick(event, KeyName, index)
                 },
@@ -393,7 +396,7 @@ const getExcelHtml = async (item, index) => {
                     if (type === 'chart') {
                         getChartConfig(formData.value[index], index)
                     }
-                }
+                },
             })
             item.isTableFormRender = true
             item.isRenderTableForm = true
@@ -409,6 +412,31 @@ const getExcelHtml = async (item, index) => {
     }
 }
 
+//图表ref
+const chartRefs = ref([])
+const setChartRefs = (el, pKeyId, key) => {
+    if (el) {
+        const {index} = getChartRef(pKeyId, key)
+        if (index !== -1) {
+            chartRefs.value[index].ref = el
+        } else {
+            chartRefs.value.push({pKeyId: pKeyId, key: key, ref: el});
+        }
+    }
+}
+//获取图表的ref
+const getChartRef = (pKeyId, key) => {
+    let refs = chartRefs.value, refVal, index = -1;
+    for (let i = 0; i < refs.length; i++) {
+        if (refs[i].pKeyId === pKeyId && refs[i].key === key) {
+            refVal = refs[i].ref
+            index = i
+            break;
+        }
+    }
+    return {ref: refVal, index: index}
+}
+
 //图表信息
 const chartKey = ref('key_41__27_0')
 const getChartConfig = async (form = {}, index) => {
@@ -431,7 +459,6 @@ const getChartConfig = async (form = {}, index) => {
         form[chart_key] = getObjValue(data)
     }
     console.log(formData.value[index])
-
 }
 
 //正则效验