Переглянути джерело

Merge branch 'main' of github.com:le5le-com/visualization-design

Alsmile 1 рік тому
батько
коміт
36a9c832a6

+ 138 - 80
src/services/echarts.ts

@@ -64,25 +64,28 @@ export const charts = [
           realTimes: [
             {
               key: 'echarts.option.series.0.data.0',
-              label: '一月数据',
-              type: 'object',
+              label: '一月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
             },
             {
               key: 'echarts.option.series.0.data.1',
-              label: '二月数据',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
-            },
-            {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
+              label: '二月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
             },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
       {
@@ -127,30 +130,43 @@ export const charts = [
           },
           realTimes: [
             {
-              key: 'echarts.option.series.0.data',
-              label: '数据1',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option.series.1.data',
-              label: '数据2',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
+              key: 'echarts.option.series.0.data.0',
+              label: '折线一1月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
             },
             {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
-            },
+              key: 'echarts.option.series.1.data.0',
+              label: '折线二1月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
+            },
+            // {
+            //   key: 'echarts.option',
+            //   label: 'echarts',
+            //   type: 'object',
+            // },
+            // {
+            //   key: 'echarts.max',
+            //   label: '最大数量',
+            //   type: 'number',
+            // },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
       {
-        name: '时间动态数据折线图',
+        name: '动态趋势折线图',
         icon: 'l-line-chart',
         data: {
           name: 'echarts',
@@ -168,7 +184,7 @@ export const charts = [
               },
               xAxis: {
                 type: 'category',
-                data: ['1月', '2月', '3月', '4月', '5月', '6月'],
+                data: [],
               },
               yAxis: {
                 type: 'value',
@@ -176,7 +192,7 @@ export const charts = [
               series: [
                 {
                   type: 'line',
-                  data: [40, 20, 90, 60, 70, 80],
+                  data: [],
                 },
               ],
             },
@@ -184,27 +200,38 @@ export const charts = [
             max: 100,
           },
           realTimes: [
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
-            },
+            // {
+            //   key: 'echarts.option',
+            //   label: 'echarts',
+            //   type: 'object',
+            // },
             {
               key: 'echarts.option.series.0.data',
               label: '实时数据',
-              type: 'object',
-            },
-            {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
-            },
-            {
-              key: 'echarts.replaceMode',
-              label: '模式',
-              type: 'number',
-            },
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
+            },
+            // {
+            //   key: 'echarts.max',
+            //   label: '最大数量',
+            //   type: 'number',
+            // },
+            // {
+            //   key: 'echarts.replaceMode',
+            //   label: '模式',
+            //   type: 'number',
+            // },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
     ],
@@ -268,21 +295,39 @@ export const charts = [
           },
           realTimes: [
             {
-              key: 'echarts.option.series.0.data',
-              label: '数据',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
+              key: 'echarts.option.series.0.data.0',
+              label: '一月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
             },
             {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
-            },
+              key: 'echarts.option.series.0.data.0',
+              label: '二月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
+            },
+            // {
+            //   key: 'echarts.option',
+            //   label: 'echarts',
+            //   type: 'object',
+            // },
+            // {
+            //   key: 'echarts.max',
+            //   label: '最大数量',
+            //   type: 'number',
+            // },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
       {
@@ -327,26 +372,39 @@ export const charts = [
           },
           realTimes: [
             {
-              key: 'echarts.option.series.0.data',
-              label: '数据1',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option.series.1.data',
-              label: '数据2',
-              type: 'object',
-            },
-            {
-              key: 'echarts.option',
-              label: 'echarts',
-              type: 'object',
+              key: 'echarts.option.series.0.data.0',
+              label: '柱状一1月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
             },
             {
-              key: 'echarts.max',
-              label: '最大数量',
-              type: 'number',
-            },
+              key: 'echarts.option.series.1.data.0',
+              label: '柱状二1月',
+              type: 'float',
+              enableMock: true,
+              mock: '0-100',
+            },
+            // {
+            //   key: 'echarts.option',
+            //   label: 'echarts',
+            //   type: 'object',
+            // },
+            // {
+            //   key: 'echarts.max',
+            //   label: '最大数量',
+            //   type: 'number',
+            // },
           ],
+          props: {
+            custom: [
+              {
+                key: 'echarts',
+                label: 'echarts',
+                type: 'code',
+              },
+            ],
+          },
         },
       },
     ],

+ 6 - 0
src/views/components/PenProps.vue

@@ -1014,6 +1014,7 @@
             <div class="py-8">
               <CodeEditor
                 :json="true"
+                :language="'json'"
                 v-model="propsDialog.value"
                 style="height: 300px"
               />
@@ -1055,6 +1056,7 @@ import { getCookie } from '@/services/cookie';
 import { useSelection } from '@/services/selections';
 import { autoSave, fonts, inTreePanel } from '@/services/common';
 import { updatePen } from './pen';
+import { MessagePlugin } from 'tdesign-vue-next';
 
 const headers = {
   Authorization: 'Bearer ' + (localStorage.token || getCookie('token') || ''),
@@ -1261,6 +1263,10 @@ const showPropsEdit = (item: any) => {
 };
 
 const onOkPropsEdit = () => {
+  if (!propsDialog.value) {
+    MessagePlugin.error('数据不满足json格式');
+    return;
+  }
   data.pen[propsDialog.key] = propsDialog.value;
   updatePen(data.pen, propsDialog.key);
   propsDialog.show = false;

+ 7 - 2
src/views/components/View.vue

@@ -526,7 +526,7 @@
         </div>
         <div v-else class="flex middle">
           <div class="flex-grow"></div>
-          <t-button @click="dataDialog.show = false"> 完成 </t-button>
+          <t-button @click="onFinishDataDialog"> 完成 </t-button>
         </div>
       </template>
     </t-dialog>
@@ -830,7 +830,7 @@ const open = async (flag: boolean = false) => {
       meta2d.open(JSON.parse(data));
     }
   } else if (!sessionStorage.getItem('opening')) {
-    meta2d.open({ name: '新建项目', pens: [] } as any);
+    meta2d.open({ name: '新建项目', pens: [], enableMock: true } as any);
   }
   sessionStorage.removeItem('opening');
   !meta2d.store.data.x && (meta2d.store.data.x = meta2d.store.options.x || 0);
@@ -1195,6 +1195,11 @@ const onShowDataDialog = async () => {
   onSelDataset(true);
 };
 
+const onFinishDataDialog = () => {
+  dataDialog.show = false;
+  meta2d.connectNetwork();
+};
+
 const onChangeMock = () => {
   // @ts-ignore
   meta2d.store.data.enableMock = dataDialog.enableMock;

+ 4 - 0
src/views/components/common/CodeEditor.vue

@@ -112,6 +112,10 @@ onMounted(() => {
       emit('change', currenValue);
     }
   });
+
+  setTimeout(() => {
+    editor.getAction('editor.action.formatDocument').run();
+  }, 300);
 });
 
 watch(