mirror of
https://github.com/dataease/dataease.git
synced 2025-02-24 11:32:57 +08:00
parent
6aff064fab
commit
76a4a23689
@ -3,13 +3,11 @@
|
|||||||
<div class="custom-split-line"></div>
|
<div class="custom-split-line"></div>
|
||||||
<span v-show="!searchText" class="custom-category">{{ label }}</span>
|
<span v-show="!searchText" class="custom-category">{{ label }}</span>
|
||||||
<span v-show="searchText" class="custom-search">{{ label }}</span>
|
<span v-show="searchText" class="custom-search">{{ label }}</span>
|
||||||
<span v-if="searchText" class="custom-search-result"
|
<span v-if="searchText" class="custom-search-result">的搜索结果是{{ searchResult }}个</span>
|
||||||
>的搜索结果是{{ fullTemplateShowList.length }}个</span
|
|
||||||
>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col
|
<el-col
|
||||||
v-for="(templateItem, index) in fullTemplateShowList"
|
v-for="(templateItem, index) in fullTemplateShowList"
|
||||||
v-show="templateItem.showFlag"
|
v-show="showFlagCheck(templateItem)"
|
||||||
:key="templateItem.id + label"
|
:key="templateItem.id + label"
|
||||||
style="float: left; padding: 24px 12px 0; text-align: center; flex: 0"
|
style="float: left; padding: 24px 12px 0; text-align: center; flex: 0"
|
||||||
:style="{ width: templateSpan }"
|
:style="{ width: templateSpan }"
|
||||||
@ -28,6 +26,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import TemplateMarketV2Item from '@/views/template-market/component/TemplateMarketV2Item.vue'
|
import TemplateMarketV2Item from '@/views/template-market/component/TemplateMarketV2Item.vue'
|
||||||
|
import { computed } from 'vue'
|
||||||
const emits = defineEmits(['templateApply', 'templatePreview'])
|
const emits = defineEmits(['templateApply', 'templatePreview'])
|
||||||
|
|
||||||
const templateApply = params => {
|
const templateApply = params => {
|
||||||
@ -38,6 +37,17 @@ const templatePreview = params => {
|
|||||||
emits('templatePreview', params)
|
emits('templatePreview', params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const searchResult = computed(
|
||||||
|
() => props.fullTemplateShowList.filter(item => showFlagCheck(item)).length
|
||||||
|
)
|
||||||
|
|
||||||
|
const showFlagCheck = template => {
|
||||||
|
if (!template.categoryNames) {
|
||||||
|
console.log('===templateTest' + JSON.stringify(template))
|
||||||
|
}
|
||||||
|
return template.showFlag && template.categoryNames?.includes(props.label)
|
||||||
|
}
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
searchText: {
|
searchText: {
|
||||||
type: String
|
type: String
|
@ -102,8 +102,8 @@
|
|||||||
id="template-show-area"
|
id="template-show-area"
|
||||||
class="template-right"
|
class="template-right"
|
||||||
>
|
>
|
||||||
<el-row style="display: inline" v-show="state.marketActiveTab !== '推荐'">
|
<el-row v-show="state.marketActiveTab !== '推荐'">
|
||||||
<category-template
|
<category-template-v2
|
||||||
:search-text="state.searchText"
|
:search-text="state.searchText"
|
||||||
:label="state.marketActiveTab"
|
:label="state.marketActiveTab"
|
||||||
:full-template-show-list="state.currentMarketTemplateShowList"
|
:full-template-show-list="state.currentMarketTemplateShowList"
|
||||||
@ -113,30 +113,28 @@
|
|||||||
:cur-position="state.curPosition"
|
:cur-position="state.curPosition"
|
||||||
@templateApply="templateApply"
|
@templateApply="templateApply"
|
||||||
@templatePreview="templatePreview"
|
@templatePreview="templatePreview"
|
||||||
></category-template>
|
></category-template-v2>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<el-row v-show="state.marketActiveTab === '推荐'">
|
||||||
<template v-if="state.marketActiveTab === '推荐'">
|
|
||||||
<el-row
|
<el-row
|
||||||
:key="'full-' + categoryItem.label"
|
style="display: inline; width: 100%; margin-bottom: 16px"
|
||||||
style="display: inline; margin-bottom: 16px"
|
v-for="(categoryItem, index) in categoriesComputed"
|
||||||
v-for="categoryItem in categoriesComputed.filter(
|
:key="index"
|
||||||
item => !['最近使用', '推荐'].includes(item['label'])
|
|
||||||
)"
|
|
||||||
>
|
>
|
||||||
<categoery-template
|
<category-template-v2
|
||||||
|
v-if="categoryItem.label !== '最近使用'"
|
||||||
:search-text="state.searchText"
|
:search-text="state.searchText"
|
||||||
:label="categoryItem.label"
|
:label="categoryItem.label"
|
||||||
:full-template-show-list="fullTemplateShowList(categoryItem.label)"
|
:full-template-show-list="state.currentMarketTemplateShowList"
|
||||||
:template-span="state.templateSpan"
|
:template-span="state.templateSpan"
|
||||||
:base-url="state.baseUrl"
|
:base-url="state.baseUrl"
|
||||||
:template-cur-width="state.templateCurWidth"
|
:template-cur-width="state.templateCurWidth"
|
||||||
:cur-position="state.curPosition"
|
:cur-position="state.curPosition"
|
||||||
@templateApply="templateApply"
|
@templateApply="templateApply"
|
||||||
@templatePreview="templatePreview"
|
@templatePreview="templatePreview"
|
||||||
></categoery-template>
|
></category-template-v2>
|
||||||
</el-row>
|
</el-row>
|
||||||
</template>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<el-row v-show="state.networkStatus && !state.hasResult" class="template-empty">
|
<el-row v-show="state.networkStatus && !state.hasResult" class="template-empty">
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
@ -154,18 +152,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { getCategoriesObject, searchMarket } from '@/api/templateMarket'
|
import { searchMarket } from '@/api/templateMarket'
|
||||||
import elementResizeDetectorMaker from 'element-resize-detector'
|
import elementResizeDetectorMaker from 'element-resize-detector'
|
||||||
import { nextTick, reactive, watch, onMounted, ref, computed } from 'vue'
|
import { nextTick, reactive, watch, onMounted, ref, computed } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useRoute } from 'vue-router'
|
|
||||||
import { ElMessage } from 'element-plus-secondary'
|
import { ElMessage } from 'element-plus-secondary'
|
||||||
import { decompression } from '@/api/visualization/dataVisualization'
|
import { decompression } from '@/api/visualization/dataVisualization'
|
||||||
import { useCache } from '@/hooks/web/useCache'
|
import { useCache } from '@/hooks/web/useCache'
|
||||||
import MarketPreviewV2 from '@/views/template-market/component/MarketPreviewV2.vue'
|
import MarketPreviewV2 from '@/views/template-market/component/MarketPreviewV2.vue'
|
||||||
import { imgUrlTrans } from '@/utils/imgUtils'
|
import { imgUrlTrans } from '@/utils/imgUtils'
|
||||||
import CategoryTemplate from '@/views/template-market/component/CategoryTemplate.vue'
|
|
||||||
import { deepCopy } from '@/utils/utils'
|
import { deepCopy } from '@/utils/utils'
|
||||||
|
import CategoryTemplateV2 from '@/views/template-market/component/CategoryTemplateV2.vue'
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const { wsCache } = useCache()
|
const { wsCache } = useCache()
|
||||||
|
|
||||||
@ -179,42 +176,6 @@ const close = () => {
|
|||||||
|
|
||||||
const title = computed(() => (state.curPosition === 'branch' ? '模板中心' : '使用模版新建'))
|
const title = computed(() => (state.curPosition === 'branch' ? '模板中心' : '使用模版新建'))
|
||||||
|
|
||||||
const categoriesComputed = computed(() => {
|
|
||||||
if (state.templateSourceType === 'all') {
|
|
||||||
return state.marketTabs
|
|
||||||
} else {
|
|
||||||
return state.marketTabs.filter(
|
|
||||||
category => category.source === 'public' || category.source === state.templateSourceType
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const curTemplateImg = computed(() => {
|
|
||||||
if (
|
|
||||||
state.curTemplate.thumbnail.indexOf('http') > -1 ||
|
|
||||||
state.curTemplate.thumbnail.indexOf('static-resource') > -1
|
|
||||||
) {
|
|
||||||
return imgUrlTrans(state.curTemplate.thumbnail)
|
|
||||||
} else {
|
|
||||||
return imgUrlTrans(state.baseUrl + state.curTemplate.thumbnail)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const outPaddingState = computed(() => {
|
|
||||||
return state.curPosition === 'branch' && previewModel.value !== 'marketPreview'
|
|
||||||
})
|
|
||||||
|
|
||||||
const optInit = params => {
|
|
||||||
state.initReady = false
|
|
||||||
state.curPosition = params.curPosition
|
|
||||||
state.templateType = params.templateType
|
|
||||||
previewModel.value = 'full'
|
|
||||||
state.pid = params.pid
|
|
||||||
nextTick(() => {
|
|
||||||
state.initReady = true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
initReady: true,
|
initReady: true,
|
||||||
curPosition: 'branch',
|
curPosition: 'branch',
|
||||||
@ -303,6 +264,44 @@ const state = reactive({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const categoriesComputed = computed(() => {
|
||||||
|
let result
|
||||||
|
if (state.templateSourceType === 'all') {
|
||||||
|
result = state.marketTabs
|
||||||
|
} else {
|
||||||
|
result = state.marketTabs.filter(
|
||||||
|
category => category.source === 'public' || category.source === state.templateSourceType
|
||||||
|
)
|
||||||
|
}
|
||||||
|
console.log('categoriesComputed=' + JSON.stringify(result))
|
||||||
|
return result
|
||||||
|
})
|
||||||
|
|
||||||
|
const curTemplateImg = computed(() => {
|
||||||
|
if (
|
||||||
|
state.curTemplate.thumbnail.indexOf('http') > -1 ||
|
||||||
|
state.curTemplate.thumbnail.indexOf('static-resource') > -1
|
||||||
|
) {
|
||||||
|
return imgUrlTrans(state.curTemplate.thumbnail)
|
||||||
|
} else {
|
||||||
|
return imgUrlTrans(state.baseUrl + state.curTemplate.thumbnail)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const outPaddingState = computed(() => {
|
||||||
|
return state.curPosition === 'branch' && previewModel.value !== 'marketPreview'
|
||||||
|
})
|
||||||
|
|
||||||
|
const optInit = params => {
|
||||||
|
state.initReady = false
|
||||||
|
state.curPosition = params.curPosition
|
||||||
|
state.templateType = params.templateType
|
||||||
|
previewModel.value = 'full'
|
||||||
|
state.pid = params.pid
|
||||||
|
nextTick(() => {
|
||||||
|
state.initReady = true
|
||||||
|
})
|
||||||
|
}
|
||||||
watch(
|
watch(
|
||||||
() => state.searchText,
|
() => state.searchText,
|
||||||
value => {
|
value => {
|
||||||
@ -329,10 +328,6 @@ watch(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const searchResultCount = computed(
|
|
||||||
() => state.currentMarketTemplateShowList.filter(template => template.showFlag).length
|
|
||||||
)
|
|
||||||
|
|
||||||
const nodeClick = data => {
|
const nodeClick = data => {
|
||||||
state.marketActiveTab = data.label
|
state.marketActiveTab = data.label
|
||||||
initTemplateShow()
|
initTemplateShow()
|
||||||
@ -428,10 +423,10 @@ const apply = () => {
|
|||||||
const handleClick = item => {
|
const handleClick = item => {
|
||||||
// do handleClick
|
// do handleClick
|
||||||
}
|
}
|
||||||
const initTemplateShow = (activeTab = state.marketActiveTab) => {
|
const initTemplateShow = () => {
|
||||||
let tempHasResult = false
|
let tempHasResult = false
|
||||||
state.currentMarketTemplateShowList.forEach(template => {
|
state.currentMarketTemplateShowList.forEach(template => {
|
||||||
template.showFlag = templateShow(template, activeTab)
|
template.showFlag = templateShow(template)
|
||||||
if (template.showFlag) {
|
if (template.showFlag) {
|
||||||
tempHasResult = true
|
tempHasResult = true
|
||||||
}
|
}
|
||||||
@ -441,34 +436,10 @@ const initTemplateShow = (activeTab = state.marketActiveTab) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fullTemplateShowList = curTab => {
|
const templateShow = templateItem => {
|
||||||
state.currentMarketTemplateShowList.forEach(template => {
|
|
||||||
template.showFlag = templateShow(template, curTab)
|
|
||||||
})
|
|
||||||
return deepCopy(state.currentMarketTemplateShowList.filter(ele => ele.showFlag))
|
|
||||||
}
|
|
||||||
|
|
||||||
const templateShow = (templateItem, activeTab) => {
|
|
||||||
let categoryMarch = false
|
|
||||||
let searchMarch = false
|
let searchMarch = false
|
||||||
let templateTypeMarch = false
|
let templateTypeMarch = false
|
||||||
let templateSourceTypeMarch = false
|
let templateSourceTypeMarch = false
|
||||||
if (activeTab === '最近使用') {
|
|
||||||
if (templateItem.recentUseTime) {
|
|
||||||
categoryMarch = true
|
|
||||||
}
|
|
||||||
} else if (activeTab === '推荐') {
|
|
||||||
if (templateItem.suggest === 'Y') {
|
|
||||||
categoryMarch = true
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
templateItem.categories.forEach(category => {
|
|
||||||
if (category.name === activeTab) {
|
|
||||||
categoryMarch = true
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!state.searchText || templateItem.title.indexOf(state.searchText) > -1) {
|
if (!state.searchText || templateItem.title.indexOf(state.searchText) > -1) {
|
||||||
searchMarch = true
|
searchMarch = true
|
||||||
}
|
}
|
||||||
@ -480,7 +451,7 @@ const templateShow = (templateItem, activeTab) => {
|
|||||||
if (state.templateSourceType === 'all' || templateItem.source === state.templateSourceType) {
|
if (state.templateSourceType === 'all' || templateItem.source === state.templateSourceType) {
|
||||||
templateSourceTypeMarch = true
|
templateSourceTypeMarch = true
|
||||||
}
|
}
|
||||||
return categoryMarch && searchMarch && templateTypeMarch && templateSourceTypeMarch
|
return searchMarch && templateTypeMarch && templateSourceTypeMarch
|
||||||
}
|
}
|
||||||
|
|
||||||
const templatePreview = previewId => {
|
const templatePreview = previewId => {
|
||||||
|
@ -4,6 +4,8 @@ import io.dataease.api.template.vo.MarketCategoryVO;
|
|||||||
import io.dataease.api.template.vo.MarketMetasVO;
|
import io.dataease.api.template.vo.MarketMetasVO;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -30,6 +32,8 @@ public class TemplateMarketDTO implements Comparable<TemplateMarketDTO> {
|
|||||||
private String source = "market";
|
private String source = "market";
|
||||||
private List<MarketCategoryVO> categories;
|
private List<MarketCategoryVO> categories;
|
||||||
|
|
||||||
|
private List<String> categoryNames;
|
||||||
|
|
||||||
private String mainCategory;
|
private String mainCategory;
|
||||||
private MarketMetasVO metas;
|
private MarketMetasVO metas;
|
||||||
|
|
||||||
@ -38,7 +42,8 @@ public class TemplateMarketDTO implements Comparable<TemplateMarketDTO> {
|
|||||||
this.id = manageDTO.getId();
|
this.id = manageDTO.getId();
|
||||||
this.title = manageDTO.getName();
|
this.title = manageDTO.getName();
|
||||||
this.mainCategory = manageDTO.getCategoryName();
|
this.mainCategory = manageDTO.getCategoryName();
|
||||||
this.categories = Arrays.asList(new MarketCategoryVO(manageDTO.getCategoryName()), new MarketCategoryVO("全部"));
|
this.categories = Arrays.asList(new MarketCategoryVO(manageDTO.getCategoryName()));
|
||||||
|
this.categoryNames = Arrays.asList(manageDTO.getCategoryName());
|
||||||
this.metas = new MarketMetasVO(manageDTO.getSnapshot());
|
this.metas = new MarketMetasVO(manageDTO.getSnapshot());
|
||||||
this.templateType = "dataV".equalsIgnoreCase("manageDTO.getTemplateType()") ? "SCREEN" : "PANEL";
|
this.templateType = "dataV".equalsIgnoreCase("manageDTO.getTemplateType()") ? "SCREEN" : "PANEL";
|
||||||
this.thumbnail = manageDTO.getSnapshot();
|
this.thumbnail = manageDTO.getSnapshot();
|
||||||
@ -51,15 +56,20 @@ public class TemplateMarketDTO implements Comparable<TemplateMarketDTO> {
|
|||||||
public TemplateMarketDTO(String id, String title, String themeRepo, String templateUrl, String categoryName, String templateType, Long recentUseTime, String suggest) {
|
public TemplateMarketDTO(String id, String title, String themeRepo, String templateUrl, String categoryName, String templateType, Long recentUseTime, String suggest) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.categories = Arrays.asList(new MarketCategoryVO(categoryName), new MarketCategoryVO("全部"));
|
|
||||||
this.metas = new MarketMetasVO(templateUrl);
|
this.metas = new MarketMetasVO(templateUrl);
|
||||||
this.thumbnail = themeRepo;
|
this.thumbnail = themeRepo;
|
||||||
this.templateType = templateType;
|
this.templateType = templateType;
|
||||||
|
this.categories = new ArrayList<>(Arrays.asList(new MarketCategoryVO(categoryName))) ;
|
||||||
|
this.categoryNames = new ArrayList<>(Arrays.asList(categoryName)) ;
|
||||||
if (recentUseTime != null) {
|
if (recentUseTime != null) {
|
||||||
this.recentUseTime = recentUseTime;
|
this.recentUseTime = recentUseTime;
|
||||||
|
this.categories.add(new MarketCategoryVO("最近使用"));
|
||||||
|
this.categoryNames.add("最近使用");
|
||||||
}
|
}
|
||||||
if ("Y".equalsIgnoreCase(suggest)) {
|
if ("Y".equalsIgnoreCase(suggest)) {
|
||||||
this.suggest = "Y";
|
this.suggest = "Y";
|
||||||
|
this.categories.add(new MarketCategoryVO("推荐"));
|
||||||
|
this.categoryNames.add("推荐");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user