Browse Source

试验图表

ZaiZai 2 years ago
parent
commit
b8d65ed3f2

+ 1 - 0
src/components/plugins/table-form/echart.vue

@@ -42,6 +42,7 @@ watch(() => [
 
 //初始化图表
 const initChart = () => {
+    console.log('echarts', options.value)
     chart = echarts.init(echart.value)
     setOptions(options.value)
 }

+ 13 - 6
src/views/tentative/detect/components/ListItem.vue

@@ -356,7 +356,7 @@ const CollapseChange = async (name) => {
         }
         //渲染表单
         await getExcelHtml(item, index)
-        await getChartConfig()
+        await getChartConfig({}, index)
     } else {
         // await getExcelHtml(item,index)
         getOffsetTop()
@@ -391,7 +391,7 @@ const getExcelHtml = async (item, index) => {
                 onBlur: (event, key, reg, val, msg, type, c, d) => {
                     setTableFormBlurReg(pkeyIds, event, key, reg, val, msg, item, index)
                     if (type === 'chart') {
-                        getChartConfig(formData.value[index])
+                        getChartConfig(formData.value[index], index)
                     }
                 }
             })
@@ -411,11 +411,11 @@ const getExcelHtml = async (item, index) => {
 
 //图表信息
 const chartKey = ref('key_41__27_0')
-const getChartConfig = async (formData = {}) => {
-    let {formChartKey} = formData, {id} = baseData.value, formKeys = {}
+const getChartConfig = async (form = {}, index) => {
+    let {formChartKey} = form, {id} = baseData.value, formKeys = {}
     const chartKeys = formChartKey ? formChartKey.split(',') : []
     chartKeys.forEach((item) => {
-        formKeys[item] = formData[item] ?? ''
+        formKeys[item] = form[item] ?? ''
     })
     console.log('formKeys', formKeys)
     const {data} = await dataApi.getChartInit({
@@ -424,7 +424,14 @@ const getChartConfig = async (formData = {}) => {
         data: formKeys
     })
     //更新图表配置
-    formData[chartKey.value] = getObjValue(data)
+    const chart_key = chartKey.value
+    if (!getObjVal(form)) {
+        formData.value[index][chart_key] = getObjValue(data)
+    } else {
+        form[chart_key] = getObjValue(data)
+    }
+    console.log(formData.value[index])
+
 }
 
 //正则效验