feat: 新增数据池配置页面

This commit is contained in:
奔跑的面条 2022-12-15 19:37:43 +08:00
parent 7f1c001c99
commit eaab8d1d49
25 changed files with 968 additions and 5342 deletions

View File

@ -3074,7 +3074,7 @@ packages:
source-map: 0.6.1
wordwrap: 1.0.0
optionalDependencies:
uglify-js: 3.16.0
uglify-js: 3.17.4
dev: true
/hard-rejection/2.1.0:
@ -5014,8 +5014,8 @@ packages:
hasBin: true
dev: true
/uglify-js/3.16.0:
resolution: {integrity: sha512-FEikl6bR30n0T3amyBh3LoiBdqHRy/f4H80+My34HOesOKyHfOsxAPAxOoqC0JUnC1amnO0IwkYC3sko51caSw==}
/uglify-js/3.17.4:
resolution: {integrity: sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==}
engines: {node: '>=0.8.0'}
hasBin: true
requiresBuild: true

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -42,15 +42,21 @@
</template>
<script lang="ts" setup>
import { ref, watch } from 'vue'
import { icon } from '@/plugins'
const { HelpOutlineIcon, CloseIcon } = icon.ionicons5
const emit = defineEmits(['update:modelShow'])
defineProps({
const props = defineProps({
modelShow: Boolean
})
const emit = defineEmits(['update:modelShow'])
const { HelpOutlineIcon, CloseIcon } = icon.ionicons5
const modelShow = ref(false)
watch(() => props.modelShow, (newValue) => {
modelShow.value = newValue
})
const closeHandle = () => {
emit('update:modelShow', false)
}

View File

@ -69,21 +69,20 @@
</template>
<script script lang="ts" setup>
import { reactive } from 'vue'
import { reactive, ref, watch } from 'vue'
import { ListType } from './index.d'
import { useSettingStore } from '@/store/modules/settingStore/settingStore'
import { SettingStoreEnums, ToolsStatusEnum } from '@/store/modules/settingStore/settingStore.d'
import { icon } from '@/plugins'
const { HelpOutlineIcon, CloseIcon } = icon.ionicons5
const emit = defineEmits(['update:modelShow'])
defineProps({
const props = defineProps({
modelShow: Boolean
})
const emit = defineEmits(['update:modelShow'])
const { HelpOutlineIcon, CloseIcon } = icon.ionicons5
const settingStore = useSettingStore()
const modelShow = ref(false)
const list = reactive<ListType[]>([
{
@ -168,6 +167,10 @@ const list = reactive<ListType[]>([
}
])
watch(() => props.modelShow, (newValue) => {
modelShow.value = newValue
})
const closeHandle = () => {
emit('update:modelShow', false)
}

View File

@ -64,7 +64,7 @@ export const useChartDataPondFetch = () => {
const { requestDataPond } = chartEditStore.getRequestGlobalConfig
// 组件对应的数据池 Id
const requestDataPondId = '111' || (targetComponent.request.requestDataPondId as string)
const requestDataPondId = targetComponent.request.requestDataPondId as string
// 新增数据项
const mittPondIdArr = mittDataPondMap.get(requestDataPondId) || []
mittPondIdArr.push({

View File

@ -20,7 +20,7 @@ import { chartInitConfig } from '@/settings/designSetting'
import cloneDeep from 'lodash/cloneDeep'
// 请求基础属性
const requestConfig: RequestConfigType = {
export const requestConfig: RequestConfigType = {
requestDataType: RequestDataTypeEnum.STATIC,
requestHttpType: RequestHttpEnum.GET,
requestUrl: '',

View File

@ -7,6 +7,7 @@ import {
NH2,
NH3,
NH4,
NH5,
NCode,
NCountdown,
NText,
@ -109,6 +110,7 @@ const naive = create({
NH2,
NH3,
NH4,
NH5,
NCode,
NCountdown,
NText,

View File

@ -113,7 +113,94 @@ export const useChartEditStore = defineStore({
},
// 数据请求处理(需存储给后端)
requestGlobalConfig: {
requestDataPond: [],
requestDataPond: [{
dataPondId: '1',
dataPondName: '我是数据池1',
dataPondRequestConfig: {
requestUrl: '',
requestContentType: 0,
requestDataType: 0,
// @ts-ignore
requestHttpType: 'get',
// @ts-ignore
requestParamsBodyType: 'json',
requestSQLContent: {
sql: 'select *'
},
requestParams: {
Body: {
'form-data': {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
'x-www-form-urlencoded': {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
json: '{}',
xml: '{}'
},
Header: {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
},
Params: {
xxx: '23123',
xxx1: '23123',
xxx2: '23123',
xxx3: '23123',
xxx4: '23123',
xxx5: '23123',
}
}
}
},
{
dataPondId: '2',
dataPondName: '我是数据池2',
dataPondRequestConfig: {
requestUrl: '',
requestContentType: 0,
requestDataType: 0,
// @ts-ignore
requestHttpType: 'get',
// @ts-ignore
requestParamsBodyType: 'none',
requestSQLContent: {
sql: 'select *'
},
requestParams: {
Body: {
'form-data': {
xxx: '23123'
},
'x-www-form-urlencoded': {
xxx: '23123'
},
json: '{}',
xml: '{}'
},
Header: {
xxx: '23123'
},
Params: {
xxx: '23123'
}
}
}
}],
requestOriginUrl: '',
requestInterval: requestInterval,
requestIntervalUnit: requestIntervalUnit,

View File

@ -12,7 +12,7 @@
<n-input size="small" :placeholder="targetData.request.requestHttpType || '暂无'" :disabled="true"></n-input>
</setting-item>
<setting-item name="组件间隔(高级)">
<setting-item name="组件间隔">
<n-input size="small" :placeholder="`${targetData.request.requestInterval || '暂无'}`" :disabled="true">
<template #suffix> {{ SelectHttpTimeNameObj[targetData.request.requestIntervalUnit] }} </template>
</n-input>
@ -75,7 +75,11 @@
<!-- 骨架图 -->
<go-skeleton :load="loading" :repeat="3"></go-skeleton>
<!-- 请求配置model -->
<chart-data-request v-model:modelShow="requestShow" @sendHandle="sendHandle"></chart-data-request>
<chart-data-request
v-model:modelShow="requestShow"
:targetData="targetData"
@sendHandle="sendHandle"
></chart-data-request>
</div>
</template>
@ -124,7 +128,7 @@ const sendHandle = async () => {
const res = await customizeHttp(toRaw(targetData.value.request), toRaw(chartEditStore.getRequestGlobalConfig))
loading.value = false
if (res) {
if(!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')
if (!res?.data && !targetData.value.filter) window['$message'].warning('您的数据不符合默认格式,请配置过滤器!')
targetData.value.option.dataset = newFunctionHandle(res?.data, res, targetData.value.filter)
showMatching.value = true
return

View File

@ -0,0 +1,64 @@
<template>
<n-table
:bordered="false"
:single-line="false"
size="small"
style="border-bottom-right-radius: 7px; border-bottom-left-radius: 7px"
>
<thead>
<tr>
<th>key</th>
<th>value</th>
</tr>
</thead>
<tbody>
<tr v-for="(item, index) in tableArray.content" :key="index">
<td>
{{ item.key || '暂无'}}
</td>
<td>
{{ item.value || '暂无'}}
</td>
</tr>
</tbody>
</n-table>
</template>
<script setup lang="ts">
import { PropType, reactive, ref, toRefs, watch } from 'vue'
import { RequestParamsObjType } from '@/enums/httpEnum'
import noData from '@/assets/images/canvas/noData.png'
const props = defineProps({
target: Object as PropType<RequestParamsObjType>
})
//
const defaultItem = {
key: '',
value: ''
}
const tableArray = reactive<{
content: typeof defaultItem[]
}>({ content: [] })
//
watch(
() => props.target as RequestParamsObjType,
(target: RequestParamsObjType) => {
tableArray.content = []
for (const k in target) {
tableArray.content.push({
key: k,
value: target[k]
})
}
//
if (!tableArray.content.length) tableArray.content = [JSON.parse(JSON.stringify(defaultItem))]
},
{
immediate: true,
deep: true
}
)
</script>

View File

@ -0,0 +1,3 @@
import ChartDataDisplay from './index.vue'
export { ChartDataDisplay }

View File

@ -0,0 +1,192 @@
<template>
<div class="go-chart-data-display">
<n-scrollbar style="max-height: 570px">
<div class="go-mr-3">
<div>
<setting-item-box name="主体信息">
<setting-item name="接口名称">
<n-input size="small" :placeholder="targetData?.dataPondName || '暂无'" :disabled="true"> </n-input>
</setting-item>
<setting-item name="接口类型">
<n-input
size="small"
:placeholder="targetData?.dataPondRequestConfig.requestHttpType || '暂无'"
:disabled="true"
></n-input>
</setting-item>
</setting-item-box>
<setting-item-box>
<setting-item name="组件间隔">
<n-input
size="small"
:placeholder="`${targetData?.dataPondRequestConfig.requestInterval || '暂无'}`"
:disabled="true"
>
<template #suffix>
{{ targetData && SelectHttpTimeNameObj[targetData.dataPondRequestConfig.requestIntervalUnit] }}
</template>
</n-input>
</setting-item>
<setting-item name="全局间隔(默认)">
<n-input size="small" :placeholder="`${globalData?.requestInterval || '暂无'}`" :disabled="true">
<template #suffix> {{ globalData && SelectHttpTimeNameObj[globalData.requestIntervalUnit] }} </template>
</n-input>
</setting-item>
</setting-item-box>
<setting-item-box name="源地址" :alone="true">
<n-input size="small" :placeholder="globalData?.requestOriginUrl || '暂无'" :disabled="true">
<template #prefix>
<n-icon :component="PulseIcon" />
</template>
</n-input>
</setting-item-box>
<setting-item-box name="接口地址" :alone="true">
<n-input
size="small"
:placeholder="targetData?.dataPondRequestConfig.requestUrl || '暂无'"
:disabled="true"
>
<template #prefix>
<n-icon :component="FlashIcon" />
</template>
</n-input>
</setting-item-box>
</div>
<n-divider />
<setting-item-box name="类型">
<setting-item name="配置类型">
<n-input
size="small"
:placeholder="targetData && requestContentTypeObj[targetData?.dataPondRequestConfig.requestContentType]"
:disabled="true"
></n-input>
</setting-item>
<setting-item name="body 类型">
<n-input size="small" :placeholder="targetData && requestParamsBodyType" :disabled="true"></n-input>
</setting-item>
</setting-item-box>
<div v-if="targetData?.dataPondRequestConfig.requestContentType === RequestContentTypeEnum.DEFAULT">
<n-tabs type="line" animated v-model:value="tabValue">
<n-tab v-for="item in RequestParamsTypeEnum" :key="item" :name="item" :tab="item"> {{ item }} </n-tab>
</n-tabs>
<!-- 各个页面 -->
<div class="go-mt-3">
<div v-if="tabValue !== RequestParamsTypeEnum.BODY">
<display-table class="go-my-3" :target="requestParams[tabValue]"> </display-table>
</div>
<!-- 选择了 body -->
<div v-else>
<!-- none -->
<n-card class="go-mt-3 go-pb-3" v-if="requestParamsBodyType === RequestBodyEnum['NONE']">
<n-text depth="3">该接口没有 Body </n-text>
</n-card>
<!-- 具有对象属性时 -->
<template
v-else-if="
requestParamsBodyType === RequestBodyEnum['FORM_DATA'] ||
requestParamsBodyType === RequestBodyEnum['X_WWW_FORM_URLENCODED']
"
>
<display-table
class="go-my-3"
:target="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType]"
></display-table>
</template>
<!-- json -->
<template v-else-if="requestParamsBodyType === RequestBodyEnum['JSON']">
<n-card size="small" style="padding-bottom: 7px">
<n-code
:code="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType] || '暂无内容'"
language="json"
></n-code>
</n-card>
</template>
<!-- xml -->
<template v-else-if="requestParamsBodyType === RequestBodyEnum['XML']">
<n-code
:code="requestParams[RequestParamsTypeEnum.BODY][requestParamsBodyType] || ''"
language="html"
></n-code>
</template>
</div>
</div>
</div>
<!-- SQL 请求 -->
<div v-else>
<setting-item-box name="键名">
<n-text>sql</n-text>
</setting-item-box>
<setting-item-box name="键值">
<n-code :code="targetData?.dataPondRequestConfig.requestSQLContent.sql || ''" language="sql"></n-code>
</setting-item-box>
</div>
</div>
</n-scrollbar>
</div>
</template>
<script setup lang="ts">
import { PropType, ref, toRefs } from 'vue'
import { icon } from '@/plugins'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { RequestDataPondItemType, RequestGlobalConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import displayTable from './displayTable.vue'
import {
RequestBodyEnum,
RequestParamsTypeEnum,
SelectHttpTimeNameObj,
RequestContentTypeEnum,
RequestBodyEnumList,
RequestParamsObjType
} from '@/enums/httpEnum'
const props = defineProps({
globalData: Object as PropType<RequestGlobalConfigType>,
targetData: Object as PropType<RequestDataPondItemType>
})
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
const { requestHttpType, requestContentType, requestSQLContent, requestParams, requestParamsBodyType } = toRefs(
(props.targetData as RequestDataPondItemType).dataPondRequestConfig
)
const tabs = [RequestParamsTypeEnum.HEADER]
const requestContentTypeObj = {
[RequestContentTypeEnum.DEFAULT]: '普通请求',
[RequestContentTypeEnum.SQL]: 'SQL 请求'
}
const tabValue = ref<RequestParamsTypeEnum>(RequestParamsTypeEnum.PARAMS)
//
const updateRequestParams = (paramsObj: RequestParamsObjType) => {
if (tabValue.value !== RequestParamsTypeEnum.BODY) {
requestParams.value[tabValue.value] = paramsObj
}
}
//
const updateRequestBodyTable = (paramsObj: RequestParamsObjType) => {
if (
tabValue.value === RequestParamsTypeEnum.BODY &&
// body
(requestParamsBodyType.value === RequestBodyEnum.FORM_DATA ||
requestParamsBodyType.value === RequestBodyEnum.X_WWW_FORM_URLENCODED)
) {
requestParams.value[RequestParamsTypeEnum.BODY][requestParamsBodyType.value] = paramsObj
}
}
</script>
<style lang="scss" scoped>
@include go('chart-data-display') {
flex: 1;
}
</style>

View File

@ -0,0 +1,3 @@
import ChartDataPondControl from './index.vue'
export { ChartDataPondControl }

View File

@ -0,0 +1,210 @@
<template>
<n-modal class="go-chart-data-pond-control" v-model:show="modelShow" :mask-closable="false">
<n-card :bordered="false" role="dialog" size="small" aria-modal="true" style="width: 900px; height: 650px">
<template #header></template>
<template #header-extra> </template>
<div class="pond-content">
<!-- 展示区域 -->
<chart-data-display
v-if="pondData && !loading"
:targetData="pondData"
:globalData="chartEditStore.getRequestGlobalConfig"
></chart-data-display>
<!-- 无数据 -->
<div v-else class="no-data go-flex-center">
<img :src="noData" alt="暂无数据" />
<n-text :depth="3">暂未选择公共接口</n-text>
</div>
<!-- 左侧列表 -->
<chart-data-pond-list @createPond="createPond" @deletePond="deletePond"></chart-data-pond-list>
</div>
<!-- 底部 -->
<template #action>
<n-space justify="space-between">
<n-button type="info" secondary :disabled="!pondData" @click="openPond(true)">
编辑内容
<template #icon>
<n-icon>
<pencil-icon />
</n-icon>
</template>
</n-button>
<n-button type="primary" @click="closeHandle">保存 & 发送请求</n-button>
</n-space>
</template>
</n-card>
</n-modal>
<!-- 请求配置model -->
<pond-data-request
v-if="requestShow"
v-model:modelShow="requestShow"
:targetDataRequest="editData"
:isEdit="isEdit"
@editSaveHandle="saveHandle"
></pond-data-request>
</template>
<script setup lang="ts">
import { ref, toRefs, computed, nextTick, watch } from 'vue'
import noData from '@/assets/images/canvas/noData.png'
import { ChartDataPondList } from '../ChartDataPondList'
import { PondDataRequest } from '../../../ChartDataRequest'
import { ChartDataDisplay } from '../ChartDataDisplay'
import { requestConfig } from '@/packages/public/publicConfig'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { icon } from '@/plugins'
import { getUUID, goDialog } from '@/utils'
import { cloneDeep } from 'lodash'
defineProps({
modelShow: Boolean
})
const emit = defineEmits(['update:modelShow', 'sendHandle'])
const { PencilIcon } = icon.ionicons5
const { chartEditStore, targetData } = useTargetData()
const { requestDataPond } = toRefs(chartEditStore.getRequestGlobalConfig)
const requestShow = ref(false)
const loading = ref(false)
const isEdit = ref(false)
const editData = ref<RequestDataPondItemType>()
//
const pondData = computed(() => {
const selectId = targetData?.value?.request?.requestDataPondId
if (!selectId) return undefined
const data = requestDataPond.value.filter(item => {
return selectId === item.dataPondId
})
return data[0]
})
watch(
() => pondData.value,
newValue => {
loading.value = true
editData.value = newValue
nextTick(() => {
loading.value = false
})
},
{
immediate: true
}
)
// /
const openPond = (isEditFlag: boolean = false) => {
isEdit.value = !!isEditFlag
requestShow.value = true
}
//
const createPond = () => {
const id = getUUID()
editData.value = {
dataPondId: id,
dataPondName: id,
dataPondRequestConfig: cloneDeep(requestConfig)
}
openPond()
}
// /
const saveHandle = (newData: RequestDataPondItemType) => {
//
if (isEdit.value) {
editSaveHandle(newData)
} else {
console.log(editData.value)
createSaveHandle(newData)
}
isEdit.value = false
requestShow.value = false
}
//
const editSaveHandle = (newData: RequestDataPondItemType) => {
try {
const targetIndex = requestDataPond.value.findIndex(item => item.dataPondId === newData.dataPondId)
if (targetIndex !== -1) {
requestDataPond.value.splice(targetIndex, 1, newData)
} else {
window.$message.error('编辑失败,请稍后重试!')
}
} catch (error) {
window.$message.error('编辑失败,请稍后重试!')
}
}
//
const createSaveHandle = (newData: RequestDataPondItemType) => {
try {
if (editData.value) {
requestDataPond.value.unshift(newData)
window.$message.success('创建成功!')
} else {
window.$message.error('创建失败,请稍后重试!')
}
} catch (error) {
window.$message.error('创建失败,请稍后重试!')
}
}
//
const deletePond = (targetData: RequestDataPondItemType) => {
goDialog({
message: '删除数据后,需手动处理使用改接口的组件,是否继续?',
isMaskClosable: true,
transformOrigin: 'center',
onPositiveCallback: () => {
const targetIndex = requestDataPond.value.findIndex(item => item.dataPondId === targetData.dataPondId)
if (targetIndex !== -1) {
requestDataPond.value.splice(targetIndex, 1)
window.$message.success('删除成功!')
} else {
window.$message.error('删除失败,请稍后重试!')
}
}
})
}
//
const closeHandle = () => {
emit('update:modelShow', false)
emit('sendHandle')
}
</script>
<style lang="scss" scoped>
@include go('chart-data-pond-control') {
/* 中间 */
.pond-content {
display: flex;
}
.no-data {
flex-direction: column;
width: 100%;
img {
width: 200px;
}
}
&.n-card.n-modal,
.n-card {
@extend .go-background-filter;
}
.n-card-shallow {
background-color: rgba(0, 0, 0, 0) !important;
}
@include deep() {
& > .n-card__content {
padding-right: 0;
}
.n-card__content {
padding-bottom: 5px;
}
}
}
</style>

View File

@ -0,0 +1,3 @@
import ChartDataPondList from './index.vue'
export { ChartDataPondList }

View File

@ -0,0 +1,202 @@
<template>
<div class="go-chart-data-pond-list">
<n-timeline style="width: 20px">
<n-timeline-item type="info"> </n-timeline-item>
<n-timeline-item type="success"></n-timeline-item>
</n-timeline>
<div class="pond-item-box">
<n-space v-if="!requestDataPond.length" justify="center">
<n-text class="not-layer-text" :depth="3">
暂无数据内容
<n-a @click="createPond">立即创建</n-a>
</n-text>
</n-space>
<!-- 新增 -->
<n-button class="create-btn go-py-4" ghost @click="createPond">
<span> 创建 </span>
<template #icon>
<n-icon>
<DuplicateOutlineIcon></DuplicateOutlineIcon>
</n-icon>
</template>
</n-button>
<n-divider style="margin: 10px 0"></n-divider>
<n-scrollbar style="max-height: 490px">
<div
v-for="item in requestDataPond"
:key="item.dataPondId"
:class="{ select: item.dataPondId === selectPondId }"
class="pond-item"
@click="clickHandle(item)"
>
<div class="item-content">
<div class="item-content-body">
<div>
<n-tag class="go-mr-1" :type="item.dataPondId === selectPondId ? 'warning' : ''" :bordered="false">
名称
</n-tag>
<n-ellipsis style="max-width: 180px">
{{ item.dataPondName || '暂无' }}
</n-ellipsis>
</div>
<div>
<n-tag class="go-mr-1" :type="item.dataPondId === selectPondId ? 'warning' : ''" :bordered="false">
地址
</n-tag>
<n-ellipsis style="max-width: 180px">
{{ item.dataPondRequestConfig.requestUrl || '暂无' }}
</n-ellipsis>
</div>
</div>
<div class="item-content-icon go-transition-quick" @click="deletePond($event, item)">
<n-icon>
<trash-icon></trash-icon>
</n-icon>
</div>
</div>
<div :class="{ 'select-modal': item.dataPondId === selectPondId }"></div>
</div>
</n-scrollbar>
</div>
</div>
</template>
<script setup lang="ts">
import { toRefs, computed } from 'vue'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { icon } from '@/plugins'
const emit = defineEmits(['createPond', 'deletePond'])
const { DuplicateOutlineIcon, TrashIcon } = icon.ionicons5
const designStore = useDesignStore()
const { chartEditStore, targetData } = useTargetData()
const { requestDataPond } = toRefs(chartEditStore.getRequestGlobalConfig)
//
const selectPondId = computed(() => {
return targetData.value.request.requestDataPondId
})
//
const themeColor = computed(() => {
return designStore.getAppTheme
})
//
const createPond = () => {
emit('createPond', true)
}
//
const deletePond = (target: Event, targetData: RequestDataPondItemType) => {
target.stopPropagation()
target.preventDefault()
emit('deletePond', targetData)
}
//
const clickHandle = (item: RequestDataPondItemType) => {
targetData.value.request.requestDataPondId = item.dataPondId
}
</script>
<style scoped lang="scss">
$height: 530px;
$listWidth: 280px;
$centerHeight: 60px;
$centerMiniHeight: 28px;
$textSize: 10px;
@include go('chart-data-pond-list') {
padding-top: 10px;
padding-bottom: 5px;
margin-right: 5px;
display: flex;
@include deep() {
.n-timeline > .n-timeline-item {
&:first-child {
height: $height;
}
}
}
.pond-item-box {
width: $listWidth;
position: relative;
.create-btn {
width: calc(#{$listWidth - 15px});
margin-right: 15px;
}
.pond-item {
position: relative;
height: $centerHeight;
padding: 5px;
margin-bottom: 10px;
margin-right: 15px;
border-radius: 5px;
cursor: pointer;
border: 1px solid rgba(0, 0, 0, 0);
@include fetch-bg-color('background-color3');
@extend .go-transition-quick;
&.hover,
&:hover {
@include fetch-bg-color('background-color4');
}
&:hover {
@include deep() {
.icon-item {
opacity: 1;
}
}
.item-content-icon {
opacity: 1 !important;
}
}
&.select {
border: 1px solid v-bind('themeColor');
background-color: rgba(0, 0, 0, 0);
.item-content-icon {
display: none;
}
}
.select-modal,
.item-content {
position: absolute;
top: 0;
left: 0;
}
.item-content {
z-index: 1;
display: flex;
justify-content: space-between;
align-items: center;
padding: 5px;
.item-content-body {
width: 230px;
display: flex;
flex-direction: column;
gap: 5px;
}
.item-content-icon {
opacity: 0;
height: $centerHeight;
line-height: $centerHeight;
padding-left: 5px;
}
}
.select-modal {
width: 100%;
height: 100%;
opacity: 0.3;
background-color: v-bind('themeColor');
}
}
}
}
</style>

View File

@ -1,83 +1,64 @@
<template>
<!-- 选中内容 -->
<div class="go-chart-data-pond">
<n-card class="n-card-shallow">
<setting-item-box name="请求配置">
<setting-item name="类型">
<n-tag :bordered="false" type="primary" style="border-radius: 5px">
{{ targetData.request.requestContentType === RequestContentTypeEnum.DEFAULT ? '普通请求' : 'SQL请求' }}
</n-tag>
</setting-item>
<setting-item name="方式">
<n-input size="small" :placeholder="targetData.request.requestHttpType || '暂无'" :disabled="true"></n-input>
</setting-item>
<setting-item name="组件间隔(高级)">
<n-input size="small" :placeholder="`${targetData.request.requestInterval || '暂无'}`" :disabled="true">
<template #suffix> {{ SelectHttpTimeNameObj[targetData.request.requestIntervalUnit] }} </template>
</n-input>
</setting-item>
<setting-item name="全局间隔(默认)">
<n-input size="small" :placeholder="`${GlobalRequestInterval || '暂无'} `" :disabled="true">
<template #suffix> {{ SelectHttpTimeNameObj[GlobalRequestIntervalUnit] }} </template>
</n-input>
</setting-item>
</setting-item-box>
<setting-item-box name="源地址" :alone="true">
<n-input size="small" :placeholder="requestOriginUrl || '暂无'" :disabled="true">
<setting-item-box name="请求名称" :alone="true">
<n-input size="small" :placeholder="pondData?.dataPondName || '暂无'" :disabled="true">
<template #prefix>
<n-icon :component="PulseIcon" />
<n-icon :component="FishIcon" />
</template>
</n-input>
</setting-item-box>
<setting-item-box name="组件地址" :alone="true">
<n-input size="small" :placeholder="targetData.request.requestUrl || '暂无'" :disabled="true">
<setting-item-box name="接口地址" :alone="true">
<n-input size="small" :placeholder="pondData?.dataPondRequestConfig.requestUrl || '暂无'" :disabled="true">
<template #prefix>
<n-icon :component="FlashIcon" />
</template>
</n-input>
</setting-item-box>
<div class="edit-text" @click="requestModelHandle">
<div class="edit-text" @click="controlModelHandle">
<div class="go-absolute-center">
<n-button type="primary" secondary>编辑配置</n-button>
</div>
</div>
</n-card>
<!-- 列表 -->
<div class="pond-list-box">
<div v-for="(item, index) in requestDataPond" :key="index">
{{ item }}
</div>
</div>
</div>
<!-- 编辑 / 新增弹窗 -->
<chart-data-pond-control v-model:modelShow="controlModel"></chart-data-pond-control>
</template>
<script setup lang="ts">
import { ref, toRefs, computed } from 'vue'
import { icon } from '@/plugins'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { ChartDataPondControl } from './components/ChartDataPondControl'
import { useDesignStore } from '@/store/modules/designStore/designStore'
import { useTargetData } from '../../../hooks/useTargetData.hook'
import { SelectHttpTimeNameObj, RequestContentTypeEnum } from '@/enums/httpEnum'
const designStore = useDesignStore()
const { HelpOutlineIcon, FlashIcon, PulseIcon } = icon.ionicons5
const { HelpOutlineIcon, FlashIcon, PulseIcon, FishIcon } = icon.ionicons5
const { targetData, chartEditStore } = useTargetData()
const {
requestOriginUrl,
requestDataPond,
requestInterval: GlobalRequestInterval,
requestIntervalUnit: GlobalRequestIntervalUnit
} = toRefs(chartEditStore.getRequestGlobalConfig)
const requestShow = ref(false)
const controlModel = ref(false)
//
const pondData = computed(() => {
const selectId = targetData.value.request.requestDataPondId
if (!selectId) return undefined
const data = requestDataPond.value.filter(item => {
return selectId === item.dataPondId
})
return data[0]
})
//
const themeColor = computed(() => {
@ -85,8 +66,8 @@ const themeColor = computed(() => {
})
// model
const requestModelHandle = () => {
requestShow.value = true
const controlModelHandle = () => {
controlModel.value = true
}
</script>
@ -110,7 +91,7 @@ const requestModelHandle = () => {
top: 0px;
left: 0px;
width: 325px;
height: 270px;
height: 136px;
cursor: pointer;
opacity: 0;
transition: all 0.3s;
@ -124,10 +105,5 @@ const requestModelHandle = () => {
}
}
}
/* 列表 */
.pond-list-box {
}
}
</style>

View File

@ -1,7 +1,7 @@
<template>
<!-- 全局配置 -->
<n-card class="n-card-shallow">
<n-tag type="info" :bordered="false" style="border-radius: 5px"> 全局配置 </n-tag>
<n-tag type="info" :bordered="false" style="border-radius: 5px"> 全局公共配置 </n-tag>
<setting-item-box
name="服务"
:itemRightStyle="{

View File

@ -29,7 +29,7 @@
<!-- none -->
<n-card class="go-mt-3 go-pb-3" v-if="requestParamsBodyType === RequestBodyEnum['NONE']">
<n-text depth="3">请求没有 Body </n-text>
<n-text depth="3">接口没有 Body </n-text>
</n-card>
<!-- 具有对象属性时 -->
@ -86,13 +86,12 @@
</template>
<script setup lang="ts">
import { ref, toRefs } from 'vue'
import { ref, toRefs, PropType } from 'vue'
import { MonacoEditor } from '@/components/Pages/MonacoEditor'
import { RequestHeaderTable } from '../RequestHeaderTable/index'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
import { RequestHeaderTable } from '../RequestHeaderTable/index'
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import {
RequestParamsTypeEnum,
RequestContentTypeEnum,
@ -102,9 +101,13 @@ import {
RequestHttpEnum
} from '@/enums/httpEnum'
const { targetData } = useTargetData()
const props = defineProps({
targetDataRequest: Object as PropType<RequestConfigType>
})
const { requestHttpType, requestContentType, requestSQLContent, requestParams, requestParamsBodyType } = toRefs(targetData.value.request)
const { requestHttpType, requestContentType, requestSQLContent, requestParams, requestParamsBodyType } = toRefs(
props.targetDataRequest as RequestConfigType
)
const tabValue = ref<RequestParamsTypeEnum>(RequestParamsTypeEnum.PARAMS)

View File

@ -5,7 +5,7 @@
:itemRightStyle="{
gridTemplateColumns: '6fr 2fr'
}"
style="padding-right: 25px;"
style="padding-right: 25px"
>
<template #name>
地址
@ -51,15 +51,16 @@
</setting-item>
</setting-item-box>
<setting-item-box name="选择方式" class="go-mt-0">
<request-header></request-header>
<request-header :targetDataRequest="targetDataRequest"></request-header>
</setting-item-box>
</template>
<script setup lang="ts">
import { ref, toRefs } from 'vue'
import { PropType, toRefs } from 'vue'
import { SettingItemBox, SettingItem } from '@/components/Pages/ChartItemSetting'
import { useTargetData } from '@/views/chart/ContentConfigurations/components/hooks/useTargetData.hook'
import { selectTypeOptions, selectTimeOptions } from '@/views/chart/ContentConfigurations/components/ChartData/index.d'
import { RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { RequestHeader } from '../RequestHeader'
import { isDev } from '@/utils'
import { icon } from '@/plugins'
@ -82,10 +83,16 @@ import {
threeEarth01Url
} from '@/api/mock'
const props = defineProps({
targetDataRequest: Object as PropType<RequestConfigType>
})
const { HelpOutlineIcon } = icon.ionicons5
const { targetData, chartEditStore } = useTargetData()
const { chartEditStore } = useTargetData()
const { requestOriginUrl } = toRefs(chartEditStore.getRequestGlobalConfig)
const { requestInterval, requestIntervalUnit, requestHttpType, requestUrl } = toRefs(targetData.value.request)
const { requestInterval, requestIntervalUnit, requestHttpType, requestUrl } = toRefs(
props.targetDataRequest as RequestConfigType
)
const apiList = [
{

View File

@ -1,3 +1,4 @@
import ChartDataRequest from './index.vue'
import PondDataRequest from './pondIndex.vue'
export { ChartDataRequest }
export { ChartDataRequest, PondDataRequest }

View File

@ -7,7 +7,7 @@
<div class="go-pr-3">
<n-space vertical>
<request-global-config></request-global-config>
<request-target-config></request-target-config>
<request-target-config :target-data-request="targetData?.request"></request-target-config>
</n-space>
</div>
</n-scrollbar>
@ -17,9 +17,11 @@
<div>
<n-text> {{ chartConfig.categoryName }} </n-text>
<n-text> </n-text>
<n-tag type="primary" :bordered="false" style="border-radius: 5px"> {{ requestContentTypeObj[requestContentType] }} </n-tag>
<n-tag type="primary" :bordered="false" style="border-radius: 5px">
{{ requestContentTypeObj[requestContentType] }}
</n-tag>
</div>
<n-button type="primary" @click="closeHandle">保存 & 发送请求</n-button>
<n-button type="primary" @click="closeAndSendHandle"> {{ saveBtnText || '保存 & 发送请求' }}</n-button>
</n-space>
</template>
</n-card>
@ -27,29 +29,34 @@
</template>
<script script lang="ts" setup>
import { toRefs } from 'vue'
import { toRefs, PropType } from 'vue'
import { RequestContentTypeEnum } from '@/enums/httpEnum'
import { useTargetData } from '../../../hooks/useTargetData.hook'
import { RequestGlobalConfig } from './components/RequestGlobalConfig'
import { RequestTargetConfig } from './components/RequestTargetConfig'
import { CreateComponentType, CreateComponentGroupType } from '@/packages/index.d'
const props = defineProps({
modelShow: Boolean,
targetData: Object as PropType<CreateComponentType>,
saveBtnText: String || null
})
const emit = defineEmits(['update:modelShow', 'sendHandle'])
const { targetData } = useTargetData()
//
const { chartConfig } = toRefs(targetData.value)
const { requestContentType } = toRefs(targetData.value.request)
const { chartConfig } = toRefs(props.targetData as CreateComponentType)
const { requestContentType } = toRefs((props.targetData as CreateComponentType).request)
const requestContentTypeObj = {
[RequestContentTypeEnum.DEFAULT]: '普通请求',
[RequestContentTypeEnum.SQL]: 'SQL 请求'
}
defineProps({
modelShow: Boolean
})
const closeHandle = () => {
emit('update:modelShow', false)
}
const closeAndSendHandle = () => {
emit('update:modelShow', false)
emit('sendHandle')
}
</script>

View File

@ -0,0 +1,102 @@
<template>
<n-modal class="go-chart-data-request" v-model:show="modelShow" :mask-closable="false">
<n-card :bordered="false" role="dialog" size="small" aria-modal="true" style="width: 1000px; height: 800px">
<template #header></template>
<template #header-extra> </template>
<n-scrollbar style="max-height: 718px">
<div class="go-pr-3">
<n-space vertical>
<request-global-config></request-global-config>
<request-target-config
:target-data-request="targetDataRequest?.dataPondRequestConfig"
></request-target-config>
</n-space>
</div>
</n-scrollbar>
<!-- 底部 -->
<template #action>
<n-space justify="space-between">
<n-space v-if="targetDataRequest">
<n-tag :bordered="false" type="primary">名称</n-tag>
<n-input
v-model:value="targetDataRequest.dataPondName"
ref="inputInstRef"
type="text"
size="small"
:autofocus="true"
:clearable="true"
:minlength="1"
:maxlength="16"
placeholder="请输入名称"
></n-input>
</n-space>
<span v-else></span>
<n-space>
<n-button @click="closeHandle">取消</n-button>
<n-button type="primary" @click="closeAndSendHandle">保存</n-button>
</n-space>
</n-space>
</template>
</n-card>
</n-modal>
</template>
<script script lang="ts" setup>
import { PropType, ref, watchEffect } from 'vue'
import { RequestContentTypeEnum } from '@/enums/httpEnum'
import { useTargetData } from '../../../hooks/useTargetData.hook'
import { RequestGlobalConfig } from './components/RequestGlobalConfig'
import { RequestTargetConfig } from './components/RequestTargetConfig'
import { RequestDataPondItemType } from '@/store/modules/chartEditStore/chartEditStore.d'
import { goDialog } from '@/utils'
const props = defineProps({
modelShow: Boolean,
targetDataRequest: Object as PropType<RequestDataPondItemType>
})
const emit = defineEmits(['update:modelShow', 'editSaveHandle'])
const pondName = ref()
const inputInstRef = ref()
const closeHandle = () => {
emit('update:modelShow', false)
}
const closeAndSendHandle = () => {
if (!props.targetDataRequest?.dataPondName) {
window.$message.warning('请在左下角输入名称!')
inputInstRef.value?.focus()
return
}
goDialog({
message: '是否保存内容?',
isMaskClosable: true,
transformOrigin: 'center',
onPositiveCallback: () => {
emit('update:modelShow', false)
emit('editSaveHandle', props.targetDataRequest)
}
})
}
</script>
<style lang="scss" scoped>
@include go('chart-data-request') {
&.n-card.n-modal,
.n-card {
@extend .go-background-filter;
}
.n-card-shallow {
background-color: rgba(0, 0, 0, 0) !important;
}
@include deep() {
& > .n-card__content {
padding-right: 0;
}
.n-card__content {
padding-bottom: 5px;
}
}
}
</style>

View File

@ -142,7 +142,6 @@ $textSize: 10px;
/* 选中样式 */
&.select {
border: 1px solid v-bind('themeColor');
/* 需要设置最高级,覆盖 hover 的颜色 */
background-color: rgba(0, 0, 0, 0);
}

5248
yarn.lock

File diff suppressed because it is too large Load Diff