Commit 25e84c88 authored by zhengke's avatar zhengke

优化数据源更新

parent d980bc80
...@@ -13,7 +13,8 @@ export interface ScreenState { ...@@ -13,7 +13,8 @@ export interface ScreenState {
CoverImg: any, CoverImg: any,
isCoverImg: boolean, isCoverImg: boolean,
dataLoading: number, dataLoading: number,
FeatureImg: any FeatureImg: any,
SourceLoading: boolean,
} }
...@@ -31,6 +32,7 @@ export const useScreenStore = defineStore('screen', { ...@@ -31,6 +32,7 @@ export const useScreenStore = defineStore('screen', {
isCoverImg: false, // 封面 isCoverImg: false, // 封面
dataLoading: 0, // 记录保存是否成功 dataLoading: 0, // 记录保存是否成功
FeatureImg: [], // 行程特色图 FeatureImg: [], // 行程特色图
SourceLoading: false, // 记录数据源是否更改
}), }),
actions: { actions: {
...@@ -72,6 +74,9 @@ export const useScreenStore = defineStore('screen', { ...@@ -72,6 +74,9 @@ export const useScreenStore = defineStore('screen', {
}, },
setFeatureImg(FeatureImg: any) { setFeatureImg(FeatureImg: any) {
this.FeatureImg = FeatureImg this.FeatureImg = FeatureImg
},
setSourceLoading(SourceLoading: boolean) {
this.SourceLoading = SourceLoading
} }
}, },
}) })
\ No newline at end of file
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<div v-if="datas.DataSource.DataSourceOverlay"> <div v-if="datas.DataSource.DataSourceOverlay">
<div class="DataaSourceOverlay" @click="OffDataSource"></div> <div class="DataaSourceOverlay" @click="OffDataSource"></div>
<div class="DataaSource"> <div class="DataaSource">
<div class="DataaSourceButtom"> <!-- <div class="DataaSourceButtom">
<el-button type="primary" <el-button type="primary"
style="color: #ffff;" style="color: #ffff;"
@click="setNewDatas()">暂存选择</el-button> @click="setNewDatas()">暂存选择</el-button>
</div> </div> -->
<div class="DataaSourceList"> <div class="DataaSourceList">
<el-table <el-table
:data="datas.DataSource.DataSourceList" :data="datas.DataSource.DataSourceList"
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { computed, nextTick, ref, watch, reactive, inject } from 'vue' import { computed, nextTick, ref, watch, reactive, inject } from 'vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useSlidesStore } from '@/store' import { useSlidesStore, useScreenStore } from '@/store'
import { injectKeyDataSource } from '@/types/injectKey' import { injectKeyDataSource } from '@/types/injectKey'
import { getHtmlPlainText } from '@/utils/common' import { getHtmlPlainText } from '@/utils/common'
...@@ -89,14 +89,17 @@ ...@@ -89,14 +89,17 @@
} }
datas.DataSource = inject(injectKeyDataSource) datas.DataSource = inject(injectKeyDataSource)
const slidesStore = useSlidesStore() const slidesStore = useSlidesStore()
const sourceLoadingStore = useScreenStore()
const { slides, slideIndex } = storeToRefs(slidesStore) const { slides, slideIndex } = storeToRefs(slidesStore)
watch(() => datas.DataSource.DataSourceOverlay, (n,o) => { watch(() => datas.DataSource.DataSourceOverlay, (n,o) => {
if(n){ if(n){
datas.loading= false datas.loading= false
sourceLoadingStore.setSourceLoading(false)
} }
if(!n&&datas.loading){ if(!n&&datas.loading){
setNewDatas() setNewDatas()
sourceLoadingStore.setSourceLoading(true)
} }
}) })
const setType = (x) =>{ const setType = (x) =>{
......
...@@ -77,7 +77,7 @@ const { slidesLoadLimit } = useLoadSlides() ...@@ -77,7 +77,7 @@ const { slidesLoadLimit } = useLoadSlides()
const TemplateTypeStore = useScreenStore() const TemplateTypeStore = useScreenStore()
const CoverImgStore = useScreenStore() const CoverImgStore = useScreenStore()
const dataLoadingStore = useScreenStore() const dataLoadingStore = useScreenStore()
const { ConfigId, TemplateDataSource, TemplateType, dataLoading, TempId } = storeToRefs(TemplateTypeStore) const { ConfigId, TemplateDataSource, TemplateType, dataLoading, TempId, SourceLoading } = storeToRefs(TemplateTypeStore)
const selectedSlidesIndex = computed(() => [..._selectedSlidesIndex.value, slideIndex.value]) const selectedSlidesIndex = computed(() => [..._selectedSlidesIndex.value, slideIndex.value])
const presetLayoutPopoverVisible = ref(false) const presetLayoutPopoverVisible = ref(false)
...@@ -128,6 +128,13 @@ watch(() => dataLoading.value, (n,o) =>{ ...@@ -128,6 +128,13 @@ watch(() => dataLoading.value, (n,o) =>{
} }
}) })
// 监听数据源是否更新
watch(() => SourceLoading.value, (n,o) =>{
if(n){
setNewDatas()
}
})
queryObj.value = inject(injectKeyDataSource).queryObj queryObj.value = inject(injectKeyDataSource).queryObj
...@@ -186,6 +193,7 @@ const GetTripFiledData = async () =>{ ...@@ -186,6 +193,7 @@ const GetTripFiledData = async () =>{
cursors.push(temp) cursors.push(temp)
} }
if(y.TemplateDataSource.index!=null&&y.TemplateDataSource.index>=0){ if(y.TemplateDataSource.index!=null&&y.TemplateDataSource.index>=0){
console.log(value[oo],'-------')
if(value[oo].length>temp.index) value=value[oo][y.TemplateDataSource.index] if(value[oo].length>temp.index) value=value[oo][y.TemplateDataSource.index]
}else{ }else{
if(value[oo].length>temp.index) value=value[oo][temp.index] if(value[oo].length>temp.index) value=value[oo][temp.index]
...@@ -291,6 +299,37 @@ const GetTripTemplate = async () =>{ ...@@ -291,6 +299,37 @@ const GetTripTemplate = async () =>{
} }
} }
// 切换页面前保存数据源
const setNewDatas = () => {
const slidesData = slides.value
// 更新Slides数据
const savelides = []
const newSlides = []
let obj = slidesData.find((x,index)=>{
return slideIndex.value == index
})
if(obj){
obj.elements.forEach(x=>{
let dataObj = datas.DataSource.DataSourceList.find(y=>{
return y.id == x.id
})
if(dataObj){
x = dataObj
}
savelides.push(x)
})
obj.elements = JSON.parse(JSON.stringify(savelides))
slidesData.forEach((x,index)=>{
if(slideIndex.value == index){
x.pgaeType = datas.DataSource.pgaeType
x.elements = obj.elements
}
newSlides.push(x)
})
slidesStore.setSlides(JSON.parse(JSON.stringify(newSlides)))
}
}
// 页面被切换时 // 页面被切换时
const thumbnailsRef = ref<InstanceType<typeof Draggable>>() const thumbnailsRef = ref<InstanceType<typeof Draggable>>()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment