mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
Merge branch 'dev' of gitee.com:dromara/go-view into dev
Signed-off-by: 潘潘 <97274247@qq.com>
This commit is contained in:
+3
-2
@@ -127,8 +127,9 @@ const sendHandle = async () => {
|
||||
try {
|
||||
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
|
||||
loading.value = false
|
||||
if (res && res.data) {
|
||||
targetData.value.option.dataset = newFunctionHandle(res.data, targetData.value.filter)
|
||||
if (res) {
|
||||
if(!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')
|
||||
targetData.value.option.dataset = newFunctionHandle(res?.data, res, targetData.value.filter)
|
||||
showMatching.value = true
|
||||
return
|
||||
}
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
</n-timeline-item>
|
||||
<n-timeline-item v-show="filterShow" color="#97846c" :title="TimelineTitleEnum.FILTER">
|
||||
<n-space :size="18" vertical>
|
||||
<n-text depth="3">过滤器将处理接口返回值的「data」字段</n-text>
|
||||
<n-text depth="3">过滤器默认处理接口返回值的「data」字段</n-text>
|
||||
<chart-data-monaco-editor></chart-data-monaco-editor>
|
||||
</n-space>
|
||||
</n-timeline-item>
|
||||
|
||||
+17
-10
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<template v-if="targetData.filter">
|
||||
<n-card>
|
||||
<p><span class="func-keyword">function</span> filter(data) {</p>
|
||||
<p><span class="func-keyword">function</span> filter(data, res) {</p>
|
||||
<!-- 函数体 -->
|
||||
<div class="go-ml-4">
|
||||
<n-code :code="targetData.filter" language="typescript"></n-code>
|
||||
@@ -47,7 +47,7 @@
|
||||
<div>
|
||||
<n-space vertical>
|
||||
<n-tag type="info">
|
||||
<span class="func-keyword">function</span> filter(data) {
|
||||
<span class="func-keyword">function</span> filter(data, res) {
|
||||
</n-tag>
|
||||
<monaco-editor v-model:modelValue="filter" width="460px" height="380px" language="javascript" />
|
||||
<n-tag type="info">}</n-tag>
|
||||
@@ -58,14 +58,20 @@
|
||||
<n-space :size="15" vertical>
|
||||
<div class="editor-data-show">
|
||||
<n-space>
|
||||
<n-text depth="3">目标数据:</n-text>
|
||||
<n-code :code="toString(sourceData)" language="json" :word-wrap="true"></n-code>
|
||||
<n-text depth="3">默认过滤数据(data):</n-text>
|
||||
<n-code :code="toString(sourceData?.data) || '暂无'" language="json" :word-wrap="true"></n-code>
|
||||
</n-space>
|
||||
</div>
|
||||
<div class="editor-data-show">
|
||||
<n-space>
|
||||
<n-text depth="3">接口返回数据(res):</n-text>
|
||||
<n-code :code="toString(sourceData) || '暂无'" language="json" :word-wrap="true"></n-code>
|
||||
</n-space>
|
||||
</div>
|
||||
<div class="editor-data-show">
|
||||
<n-space>
|
||||
<n-text depth="3">过滤器结果:</n-text>
|
||||
<n-code :code="filterRes" language="json" :word-wrap="true"></n-code>
|
||||
<n-code :code="filterRes || '暂无'" language="json" :word-wrap="true"></n-code>
|
||||
</n-space>
|
||||
</div>
|
||||
</n-space>
|
||||
@@ -81,7 +87,7 @@
|
||||
</template>
|
||||
规则
|
||||
</n-tag>
|
||||
<n-text class="go-ml-2" depth="2">过滤器将处理接口返回值的「data」字段</n-text>
|
||||
<n-text class="go-ml-2" depth="2">过滤器默认处理接口返回值的「data」字段</n-text>
|
||||
</div>
|
||||
|
||||
<n-space>
|
||||
@@ -123,8 +129,8 @@ const sourceData = ref<any>('')
|
||||
const fetchTargetData = async () => {
|
||||
try {
|
||||
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.requestGlobalConfig))
|
||||
if (res && res.data) {
|
||||
sourceData.value = res.data
|
||||
if (res) {
|
||||
sourceData.value = res
|
||||
return
|
||||
}
|
||||
window['$message'].warning('数据异常,请检查参数!')
|
||||
@@ -136,8 +142,9 @@ const fetchTargetData = async () => {
|
||||
// 过滤结果
|
||||
const filterRes = computed(() => {
|
||||
try {
|
||||
const fn = new Function('data', filter.value)
|
||||
const res = fn(cloneDeep(sourceData.value))
|
||||
const fn = new Function('data', 'res', filter.value)
|
||||
const response = cloneDeep(sourceData.value)
|
||||
const res = fn(response?.data, response)
|
||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||
errorFlag.value = false
|
||||
return toString(res)
|
||||
|
||||
+5
-1
@@ -76,7 +76,8 @@ import {
|
||||
scatterBasicUrl,
|
||||
mapUrl,
|
||||
wordCloudUrl,
|
||||
treemapUrl
|
||||
treemapUrl,
|
||||
threeEarth01Url
|
||||
} from '@/api/mock'
|
||||
|
||||
const { HelpOutlineIcon } = icon.ionicons5
|
||||
@@ -127,6 +128,9 @@ const apiList = [
|
||||
{
|
||||
value: `【树图】${treemapUrl}`
|
||||
},
|
||||
{
|
||||
value: `【三维地球】${threeEarth01Url}`
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user