fix: 新增列表数据更新,修改数据更新 hook 函数

This commit is contained in:
奔跑的面条
2022-04-02 11:34:54 +08:00
parent 2c2aaaac67
commit 6ae0cd55e6
14 changed files with 210 additions and 135 deletions
@@ -20,13 +20,15 @@
<help-outline-icon></help-outline-icon>
</n-icon>
</template>
<span>
开发环境使用 mock 数据请输入
<n-text type="info">
{{ mockDataUrl }}
</n-text>
</span>
<ul>
开发环境使用 mock 数据请输入
<li>
<n-text type="info"> 图表{{ chartDataUrl }} </n-text>
</li>
<li>
<n-text type="info"> 表格{{ rankListUrl }} </n-text>
</li>
</ul>
</n-tooltip>
</template>
<n-input
@@ -63,7 +65,7 @@ import { ref, toRefs } from 'vue'
import { icon } from '@/plugins'
import { SettingItemBox } from '@/components/ChartItemSetting/index'
import { RequestHttpEnum } from '@/enums/httpEnum'
import { mockDataUrl } from '@/api/mock'
import { chartDataUrl, rankListUrl } from '@/api/mock'
import { http } from '@/api/http'
import { SelectHttpType } from '../../index.d'
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
@@ -82,12 +84,12 @@ const showMatching = ref(false)
const selectOptions: SelectHttpType[] = [
{
label: RequestHttpEnum.GET,
value: RequestHttpEnum.GET
value: RequestHttpEnum.GET,
},
{
label: RequestHttpEnum.POST,
value: RequestHttpEnum.POST
}
value: RequestHttpEnum.POST,
},
]
// 发送请求
@@ -1,6 +1,10 @@
<template>
<n-timeline class="go-chart-configurations-timeline">
<n-timeline-item type="info" :title="TimelineTitleEnum.MAPPING">
<n-timeline-item
v-if="isCharts"
type="info"
:title="TimelineTitleEnum.MAPPING"
>
<n-table striped>
<thead>
<tr>
@@ -17,7 +21,10 @@
<n-text></n-text>
</n-space>
<n-space v-else>
<n-badge dot :type="item.result === 1 ? 'success' : 'error'"></n-badge>
<n-badge
dot
:type="item.result === 1 ? 'success' : 'error'"
></n-badge>
<n-text>匹配{{ item.result === 1 ? '成功' : '失败' }}</n-text>
</n-space>
</td>
@@ -27,7 +34,7 @@
</n-timeline-item>
<n-timeline-item type="success" :title="TimelineTitleEnum.CONTENT">
<n-space vertical>
<n-text depth="3">数据需要符合 ECharts-setdata 规范</n-text>
<n-text depth="3">ECharts 图表需符合 ECharts-setdata 数据规范</n-text>
<n-space class="source-btn-box">
<n-upload
v-model:file-list="uploadFileListRef"
@@ -65,7 +72,7 @@
<script setup lang="ts">
import { ref, computed, watch } from 'vue'
import { CreateComponentType } from '@/packages/index.d'
import { CreateComponentType, PackagesCategoryEnum } from '@/packages/index.d'
import { icon } from '@/plugins'
import { DataResultEnum, TimelineTitleEnum } from '../../index.d'
import { useFile } from '../../hooks/useFile.hooks'
@@ -89,6 +96,11 @@ const dimensionsAndSource = ref()
const { uploadFileListRef, customRequest, beforeUpload, download} = useFile(targetData)
// 是图表类型
const isCharts = computed(()=> {
return targetData.value.chartConfig.package === PackagesCategoryEnum.CHARTS
})
// 获取数据
const getSource = computed(() => {
return JSON.stringify(source.value)
@@ -128,17 +140,20 @@ const dimensionsAndSourceHandle = () => {
watch(() => targetData.value?.option?.dataset, (newData) => {
if (newData) {
source.value = newData.source
dimensions.value = newData.dimensions
dimensionsAndSource.value = dimensionsAndSourceHandle()
// 只有 Echarts 数据才有对应的格式
source.value = isCharts.value ? newData.source : newData
if(isCharts.value) {
dimensions.value = newData.dimensions
dimensionsAndSource.value = dimensionsAndSourceHandle()
}
}
}, {
},{
immediate: true
})
</script>
<style lang="scss" scoped>
@include go("chart-configurations-timeline") {
@include go('chart-configurations-timeline') {
@include deep() {
pre {
white-space: pre-wrap;