mirror of
https://gitee.com/dromara/go-view.git
synced 2025-04-06 03:58:04 +08:00
fix: 新增列表数据更新,修改数据更新 hook 函数
This commit is contained in:
parent
2c2aaaac67
commit
6ae0cd55e6
@ -3,14 +3,22 @@ import { MockMethod } from 'vite-plugin-mock'
|
|||||||
import { RequestHttpEnum } from '@/enums/httpEnum'
|
import { RequestHttpEnum } from '@/enums/httpEnum'
|
||||||
|
|
||||||
// 单个X数据
|
// 单个X数据
|
||||||
export const mockDataUrl = '/mock/mockData'
|
export const chartDataUrl = '/mock/chartData'
|
||||||
|
export const rankListUrl = '/mock/RankList'
|
||||||
|
|
||||||
const mockObject: MockMethod[] =[{
|
const mockObject: MockMethod[] = [
|
||||||
|
{
|
||||||
// 正则
|
// 正则
|
||||||
// url: /\/mock\/mockData(|\?\S*)$/,
|
// url: /\/mock\/mockData(|\?\S*)$/,
|
||||||
url: '/mock/mockData',
|
url: '/mock/chartData',
|
||||||
method: RequestHttpEnum.GET,
|
method: RequestHttpEnum.GET,
|
||||||
response: () => test.featchMockData
|
response: () => test.fetchMockData,
|
||||||
}]
|
},
|
||||||
|
{
|
||||||
|
url: '/mock/rankList',
|
||||||
|
method: RequestHttpEnum.GET,
|
||||||
|
response: () => test.fetchRankList,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
export default mockObject
|
export default mockObject
|
@ -1,42 +1,62 @@
|
|||||||
export default {
|
export default {
|
||||||
// 轮播图
|
// 图表
|
||||||
featchMockData: {
|
fetchMockData: {
|
||||||
status: 200,
|
status: 200,
|
||||||
msg: "请求成功",
|
msg: '请求成功',
|
||||||
data: {
|
data: {
|
||||||
dimensions: ["product", "dataOne", "dataTwo"],
|
dimensions: ['product', 'dataOne', 'dataTwo'],
|
||||||
source: [
|
source: [
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'product': '@name',
|
product: '@name',
|
||||||
'dataOne|100-900': 3,
|
'dataOne|100-900': 3,
|
||||||
'dataTwo|100-900': 3,
|
'dataTwo|100-900': 3,
|
||||||
},
|
},
|
||||||
]
|
],
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
|
// 排名列表
|
||||||
|
fetchRankList: {
|
||||||
|
status: 200,
|
||||||
|
msg: '请求成功',
|
||||||
|
data: [
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
{ name: '@name', 'value|100-900': 5 },
|
||||||
|
],
|
||||||
|
},
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import LoadingComponent from './index.vue'
|
import GoLoading from './index.vue'
|
||||||
import AsyncLoading from './index.vue'
|
import AsyncLoading from './index.vue'
|
||||||
import AsyncSkeletonLoading from './LoadingSkeleton.vue'
|
import AsyncSkeletonLoading from './LoadingSkeleton.vue'
|
||||||
|
|
||||||
// 正常组件
|
// 正常组件
|
||||||
export { LoadingComponent }
|
export { GoLoading }
|
||||||
|
|
||||||
// 异步
|
// 异步
|
||||||
AsyncLoading.install = (app: App): void => {
|
AsyncLoading.install = (app: App): void => {
|
@ -1,22 +1,30 @@
|
|||||||
import { ref, toRefs, watchEffect, nextTick } from 'vue'
|
import { ref, toRefs, watchEffect, nextTick } from 'vue'
|
||||||
import type VChart from 'vue-echarts'
|
import type VChart from 'vue-echarts'
|
||||||
import { http } from '@/api/http'
|
import { http } from '@/api/http'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType, PackagesCategoryEnum } from '@/packages/index.d'
|
||||||
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
import { RequestDataTypeEnum } from '@/enums/httpEnum'
|
||||||
import { isPreview } from '@/utils'
|
import { isPreview } from '@/utils'
|
||||||
|
|
||||||
|
// 获取类型
|
||||||
type ChartEditStoreType = typeof useChartEditStore
|
type ChartEditStoreType = typeof useChartEditStore
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图表针对 setdata 数据监听与更改
|
* setdata 数据监听与更改
|
||||||
* @param chartConfig
|
* @param targetComponent
|
||||||
|
* @param useChartEditStore 若直接引会报错,只能动态传递
|
||||||
|
* @param updateCallback 自定义更新函数
|
||||||
*/
|
*/
|
||||||
export const useChartDataFetch = (chartConfig: CreateComponentType, useChartEditStore: ChartEditStoreType) => {
|
export const useChartDataFetch = (
|
||||||
|
targetComponent: CreateComponentType,
|
||||||
|
useChartEditStore: ChartEditStoreType,
|
||||||
|
updateCallback?: (...args: any) => any
|
||||||
|
) => {
|
||||||
const vChartRef = ref<typeof VChart | null>(null)
|
const vChartRef = ref<typeof VChart | null>(null)
|
||||||
let fetchInterval: any = 0
|
let fetchInterval: any = 0
|
||||||
|
|
||||||
isPreview() && watchEffect(() => {
|
isPreview() &&
|
||||||
|
watchEffect(() => {
|
||||||
clearInterval(fetchInterval)
|
clearInterval(fetchInterval)
|
||||||
|
|
||||||
const chartEditStore = useChartEditStore()
|
const chartEditStore = useChartEditStore()
|
||||||
@ -24,7 +32,7 @@ export const useChartDataFetch = (chartConfig: CreateComponentType, useChartEdit
|
|||||||
chartEditStore.getRequestGlobalConfig
|
chartEditStore.getRequestGlobalConfig
|
||||||
)
|
)
|
||||||
const { requestDataType, requestHttpType, requestUrl } = toRefs(
|
const { requestDataType, requestHttpType, requestUrl } = toRefs(
|
||||||
chartConfig.data
|
targetComponent.data
|
||||||
)
|
)
|
||||||
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
if (requestDataType.value !== RequestDataTypeEnum.AJAX) return
|
||||||
// 处理地址
|
// 处理地址
|
||||||
@ -35,13 +43,30 @@ export const useChartDataFetch = (chartConfig: CreateComponentType, useChartEdit
|
|||||||
if (!completePath) return
|
if (!completePath) return
|
||||||
|
|
||||||
fetchInterval = setInterval(async () => {
|
fetchInterval = setInterval(async () => {
|
||||||
const res = await http(requestHttpType.value)(completePath || '', {})
|
const res:any = await http(requestHttpType.value)(completePath || '', {})
|
||||||
if (res.data) {
|
if (res.data) {
|
||||||
|
// 是否是 Echarts
|
||||||
|
const isECharts =
|
||||||
|
targetComponent.chartConfig.package ===
|
||||||
|
PackagesCategoryEnum.CHARTS
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isECharts) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if(vChartRef.value) {
|
if (vChartRef.value) {
|
||||||
vChartRef.value.setOption({dataset: res.data})
|
vChartRef.value.setOption({ dataset: res.data })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
} else {
|
||||||
|
// 若遵守规范使用 datase 作为数据 key,则省自动赋值数据
|
||||||
|
targetComponent.option.dataset = res.data
|
||||||
|
}
|
||||||
|
if (updateCallback) {
|
||||||
|
updateCallback(res.data)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, requestInterval.value * 1000)
|
}, requestInterval.value * 1000)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import cloneDeep from 'lodash/cloneDeep'
|
|||||||
import dataJson from './data.json'
|
import dataJson from './data.json'
|
||||||
|
|
||||||
export const option = {
|
export const option = {
|
||||||
data: dataJson,
|
// 数据
|
||||||
|
dataset: dataJson,
|
||||||
// 表行数
|
// 表行数
|
||||||
rowNum: 5,
|
rowNum: 5,
|
||||||
// 轮播时间
|
// 轮播时间
|
||||||
@ -15,7 +16,7 @@ export const option = {
|
|||||||
// 自动排序
|
// 自动排序
|
||||||
sort: true,
|
sort: true,
|
||||||
color: '#1370fb',
|
color: '#1370fb',
|
||||||
textColor: '#ffffff',
|
textColor: '#CDD2F8FF',
|
||||||
borderColor: '#1370fb80',
|
borderColor: '#1370fb80',
|
||||||
carousel: 'single',
|
carousel: 'single',
|
||||||
// 格式化
|
// 格式化
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
placeholder="数值单位"
|
placeholder="数值单位"
|
||||||
></n-input>
|
></n-input>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
<SettingItem>
|
|
||||||
<n-space>
|
|
||||||
<n-switch v-model:value="optionData.sort" size="small" />
|
|
||||||
<n-text>自动排序</n-text>
|
|
||||||
</n-space>
|
|
||||||
</SettingItem>
|
|
||||||
</SettingItemBox>
|
</SettingItemBox>
|
||||||
|
|
||||||
<SettingItemBox name="样式">
|
<SettingItemBox name="样式">
|
||||||
|
@ -15,11 +15,14 @@
|
|||||||
? status.mergedConfig.valueFormatter(item)
|
? status.mergedConfig.valueFormatter(item)
|
||||||
: item.value
|
: item.value
|
||||||
}}
|
}}
|
||||||
{{unit}}
|
{{ unit }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="ranking-column" :style="`border-color: ${borderColor}`">
|
<div class="ranking-column" :style="`border-color: ${borderColor}`">
|
||||||
<div class="inside-column" :style="`width: ${item.percent}%;background-color: ${color}`">
|
<div
|
||||||
|
class="inside-column"
|
||||||
|
:style="`width: ${item.percent}%;background-color: ${color}`"
|
||||||
|
>
|
||||||
<div class="shine" />
|
<div class="shine" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -32,6 +35,8 @@ import { PropType, onUnmounted, reactive, ref, toRefs, watch } from 'vue'
|
|||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType } from '@/packages/index.d'
|
||||||
import cloneDeep from 'lodash/cloneDeep'
|
import cloneDeep from 'lodash/cloneDeep'
|
||||||
import merge from 'lodash/merge'
|
import merge from 'lodash/merge'
|
||||||
|
import { useChartDataFetch } from '@/hooks'
|
||||||
|
import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
chartConfig: {
|
chartConfig: {
|
||||||
@ -39,9 +44,10 @@ const props = defineProps({
|
|||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { w, h } = toRefs(props.chartConfig.attr)
|
const { w, h } = toRefs(props.chartConfig.attr)
|
||||||
const { rowNum, unit, color, textColor, borderColor } = toRefs(props.chartConfig.option)
|
const { rowNum, unit, color, textColor, borderColor } = toRefs(
|
||||||
|
props.chartConfig.option
|
||||||
|
)
|
||||||
|
|
||||||
const status = reactive({
|
const status = reactive({
|
||||||
mergedConfig: props.chartConfig.option,
|
mergedConfig: props.chartConfig.option,
|
||||||
@ -53,41 +59,15 @@ const status = reactive({
|
|||||||
updater: 0,
|
updater: 0,
|
||||||
})
|
})
|
||||||
|
|
||||||
const onResize = () => {
|
|
||||||
if (!status.mergedConfig) return
|
|
||||||
stopAnimation()
|
|
||||||
calcHeights(true)
|
|
||||||
animation(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => w.value,
|
|
||||||
() => {
|
|
||||||
onResize()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
watch(
|
|
||||||
() => h.value,
|
|
||||||
() => {
|
|
||||||
onResize()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
watch(
|
|
||||||
() => rowNum.value,
|
|
||||||
() => {
|
|
||||||
onResize()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const calcRowsData = () => {
|
const calcRowsData = () => {
|
||||||
let { data, rowNum, sort } = status.mergedConfig
|
let { dataset, rowNum, sort } = status.mergedConfig
|
||||||
sort &&
|
sort &&
|
||||||
data.sort(({ value: a }, { value: b }) => {
|
dataset.sort(({ value: a }, { value: b }) => {
|
||||||
if (a > b) return -1
|
if (a > b) return -1
|
||||||
if (a < b) return 1
|
if (a < b) return 1
|
||||||
if (a === b) return 0
|
if (a === b) return 0
|
||||||
})
|
})
|
||||||
const value = data.map(({ value }) => value)
|
const value = dataset.map(({ value }) => value)
|
||||||
const min = Math.min(...value) || 0
|
const min = Math.min(...value) || 0
|
||||||
// abs of min
|
// abs of min
|
||||||
const minAbs = Math.abs(min)
|
const minAbs = Math.abs(min)
|
||||||
@ -95,25 +75,25 @@ const calcRowsData = () => {
|
|||||||
// abs of max
|
// abs of max
|
||||||
const maxAbs = Math.abs(max)
|
const maxAbs = Math.abs(max)
|
||||||
const total = max + minAbs
|
const total = max + minAbs
|
||||||
data = data.map((row, i) => ({
|
dataset = dataset.map((row, i) => ({
|
||||||
...row,
|
...row,
|
||||||
ranking: i + 1,
|
ranking: i + 1,
|
||||||
percent: ((row.value + minAbs) / total) * 100,
|
percent: ((row.value + minAbs) / total) * 100,
|
||||||
}))
|
}))
|
||||||
const rowLength = data.length
|
const rowLength = dataset.length
|
||||||
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
if (rowLength > rowNum && rowLength < 2 * rowNum) {
|
||||||
data = [...data, ...data]
|
dataset = [...dataset, ...dataset]
|
||||||
}
|
}
|
||||||
data = data.map((d, i) => ({ ...d, scroll: i }))
|
dataset = dataset.map((d, i) => ({ ...d, scroll: i }))
|
||||||
status.rowsData = data
|
status.rowsData = dataset
|
||||||
status.rows = data
|
status.rows = dataset
|
||||||
}
|
}
|
||||||
|
|
||||||
const calcHeights = (onresize = false) => {
|
const calcHeights = (onresize = false) => {
|
||||||
const { rowNum, data } = status.mergedConfig
|
const { rowNum, dataset } = status.mergedConfig
|
||||||
const avgHeight = h.value / rowNum
|
const avgHeight = h.value / rowNum
|
||||||
status.avgHeight = avgHeight
|
status.avgHeight = avgHeight
|
||||||
if (!onresize) status.heights = new Array(data.length).fill(avgHeight)
|
if (!onresize) status.heights = new Array(dataset.length).fill(avgHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
const animation = async (start = false) => {
|
const animation = async (start = false) => {
|
||||||
@ -147,13 +127,46 @@ const stopAnimation = () => {
|
|||||||
clearTimeout(status.animationHandler)
|
clearTimeout(status.animationHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
const init = () => {
|
const onRestart = async () => {
|
||||||
|
if (!status.mergedConfig) return
|
||||||
|
stopAnimation()
|
||||||
calcRowsData()
|
calcRowsData()
|
||||||
calcHeights()
|
calcHeights(true)
|
||||||
animation(true)
|
animation(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
init()
|
onRestart()
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => w.value,
|
||||||
|
() => {
|
||||||
|
onRestart()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => h.value,
|
||||||
|
() => {
|
||||||
|
onRestart()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => rowNum.value,
|
||||||
|
() => {
|
||||||
|
onRestart()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// 数据更新
|
||||||
|
watch(
|
||||||
|
() => props.chartConfig.option.dataset,
|
||||||
|
() => {
|
||||||
|
onRestart()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
useChartDataFetch(props.chartConfig, useChartEditStore)
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
stopAnimation()
|
stopAnimation()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { App } from 'vue'
|
import type { App } from 'vue'
|
||||||
import { GoSkeleton } from '@/components/GoSkeleton'
|
import { GoSkeleton } from '@/components/GoSkeleton'
|
||||||
import { LoadingComponent } from '@/components/LoadingComponent'
|
import { GoLoading } from '@/components/GoLoading'
|
||||||
import { SketchRule } from 'vue3-sketch-ruler'
|
import { SketchRule } from 'vue3-sketch-ruler'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,6 +9,6 @@ import { SketchRule } from 'vue3-sketch-ruler'
|
|||||||
*/
|
*/
|
||||||
export function setupCustomComponents(app: App) {
|
export function setupCustomComponents(app: App) {
|
||||||
app.component('GoSkeleton', GoSkeleton)
|
app.component('GoSkeleton', GoSkeleton)
|
||||||
app.component('LoadingComponent', LoadingComponent)
|
app.component('GoLoading', GoLoading)
|
||||||
app.component('SketchRule', SketchRule)
|
app.component('SketchRule', SketchRule)
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,5 @@
|
|||||||
"color": "#B9B8CE"
|
"color": "#B9B8CE"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"dataset": {
|
"dataset": null
|
||||||
"dimensions": [""],
|
|
||||||
"source": [{}]
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { defineAsyncComponent, AsyncComponentLoader } from 'vue'
|
import { defineAsyncComponent, AsyncComponentLoader } from 'vue'
|
||||||
import { AsyncLoading, AsyncSkeletonLoading } from '@/components/LoadingComponent'
|
import { AsyncLoading, AsyncSkeletonLoading } from '@/components/GoLoading'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 动态注册组件
|
* * 动态注册组件
|
||||||
|
@ -20,13 +20,15 @@
|
|||||||
<help-outline-icon></help-outline-icon>
|
<help-outline-icon></help-outline-icon>
|
||||||
</n-icon>
|
</n-icon>
|
||||||
</template>
|
</template>
|
||||||
<span>
|
<ul>
|
||||||
开发环境使用 mock 数据,请输入【
|
开发环境使用 mock 数据,请输入
|
||||||
<n-text type="info">
|
<li>
|
||||||
{{ mockDataUrl }}
|
<n-text type="info"> 【图表】{{ chartDataUrl }} </n-text>
|
||||||
</n-text>
|
</li>
|
||||||
】
|
<li>
|
||||||
</span>
|
<n-text type="info"> 【表格】{{ rankListUrl }} </n-text>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<n-input
|
<n-input
|
||||||
@ -63,7 +65,7 @@ import { ref, toRefs } from 'vue'
|
|||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { SettingItemBox } from '@/components/ChartItemSetting/index'
|
import { SettingItemBox } from '@/components/ChartItemSetting/index'
|
||||||
import { RequestHttpEnum } from '@/enums/httpEnum'
|
import { RequestHttpEnum } from '@/enums/httpEnum'
|
||||||
import { mockDataUrl } from '@/api/mock'
|
import { chartDataUrl, rankListUrl } from '@/api/mock'
|
||||||
import { http } from '@/api/http'
|
import { http } from '@/api/http'
|
||||||
import { SelectHttpType } from '../../index.d'
|
import { SelectHttpType } from '../../index.d'
|
||||||
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
import { ChartDataMatchingAndShow } from '../ChartDataMatchingAndShow'
|
||||||
@ -82,12 +84,12 @@ const showMatching = ref(false)
|
|||||||
const selectOptions: SelectHttpType[] = [
|
const selectOptions: SelectHttpType[] = [
|
||||||
{
|
{
|
||||||
label: RequestHttpEnum.GET,
|
label: RequestHttpEnum.GET,
|
||||||
value: RequestHttpEnum.GET
|
value: RequestHttpEnum.GET,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: RequestHttpEnum.POST,
|
label: RequestHttpEnum.POST,
|
||||||
value: RequestHttpEnum.POST
|
value: RequestHttpEnum.POST,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// 发送请求
|
// 发送请求
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-timeline class="go-chart-configurations-timeline">
|
<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>
|
<n-table striped>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -17,7 +21,10 @@
|
|||||||
<n-text>无</n-text>
|
<n-text>无</n-text>
|
||||||
</n-space>
|
</n-space>
|
||||||
<n-space v-else>
|
<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-text>匹配{{ item.result === 1 ? '成功' : '失败' }}</n-text>
|
||||||
</n-space>
|
</n-space>
|
||||||
</td>
|
</td>
|
||||||
@ -27,7 +34,7 @@
|
|||||||
</n-timeline-item>
|
</n-timeline-item>
|
||||||
<n-timeline-item type="success" :title="TimelineTitleEnum.CONTENT">
|
<n-timeline-item type="success" :title="TimelineTitleEnum.CONTENT">
|
||||||
<n-space vertical>
|
<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-space class="source-btn-box">
|
||||||
<n-upload
|
<n-upload
|
||||||
v-model:file-list="uploadFileListRef"
|
v-model:file-list="uploadFileListRef"
|
||||||
@ -65,7 +72,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch } from 'vue'
|
import { ref, computed, watch } from 'vue'
|
||||||
import { CreateComponentType } from '@/packages/index.d'
|
import { CreateComponentType, PackagesCategoryEnum } from '@/packages/index.d'
|
||||||
import { icon } from '@/plugins'
|
import { icon } from '@/plugins'
|
||||||
import { DataResultEnum, TimelineTitleEnum } from '../../index.d'
|
import { DataResultEnum, TimelineTitleEnum } from '../../index.d'
|
||||||
import { useFile } from '../../hooks/useFile.hooks'
|
import { useFile } from '../../hooks/useFile.hooks'
|
||||||
@ -89,6 +96,11 @@ const dimensionsAndSource = ref()
|
|||||||
|
|
||||||
const { uploadFileListRef, customRequest, beforeUpload, download} = useFile(targetData)
|
const { uploadFileListRef, customRequest, beforeUpload, download} = useFile(targetData)
|
||||||
|
|
||||||
|
// 是图表类型
|
||||||
|
const isCharts = computed(()=> {
|
||||||
|
return targetData.value.chartConfig.package === PackagesCategoryEnum.CHARTS
|
||||||
|
})
|
||||||
|
|
||||||
// 获取数据
|
// 获取数据
|
||||||
const getSource = computed(() => {
|
const getSource = computed(() => {
|
||||||
return JSON.stringify(source.value)
|
return JSON.stringify(source.value)
|
||||||
@ -128,17 +140,20 @@ const dimensionsAndSourceHandle = () => {
|
|||||||
|
|
||||||
watch(() => targetData.value?.option?.dataset, (newData) => {
|
watch(() => targetData.value?.option?.dataset, (newData) => {
|
||||||
if (newData) {
|
if (newData) {
|
||||||
source.value = newData.source
|
// 只有 Echarts 数据才有对应的格式
|
||||||
|
source.value = isCharts.value ? newData.source : newData
|
||||||
|
if(isCharts.value) {
|
||||||
dimensions.value = newData.dimensions
|
dimensions.value = newData.dimensions
|
||||||
dimensionsAndSource.value = dimensionsAndSourceHandle()
|
dimensionsAndSource.value = dimensionsAndSourceHandle()
|
||||||
}
|
}
|
||||||
}, {
|
}
|
||||||
|
},{
|
||||||
immediate: true
|
immediate: true
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
@include go("chart-configurations-timeline") {
|
@include go('chart-configurations-timeline') {
|
||||||
@include deep() {
|
@include deep() {
|
||||||
pre {
|
pre {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user