|
@@ -0,0 +1,265 @@
|
|
|
+<script setup>
|
|
|
+import {reactive, ref} from 'vue'
|
|
|
+import {apiPubChartList} from '@/api/chart'
|
|
|
+import {apiFutureSearchChartList} from '@/api/futureChart'
|
|
|
+import {apiCorrelationChartList} from '@/api/correlationChart'
|
|
|
+import {apiMyClassifyList,apiMyChartAdd,apiAddClassify} from '@/api/myETA'
|
|
|
+import { showToast } from 'vant';
|
|
|
+
|
|
|
+const keyword=ref('')
|
|
|
+
|
|
|
+const typeOpt=[
|
|
|
+ {
|
|
|
+ name:"ETA图库",
|
|
|
+ type:1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:"商品价格曲线",
|
|
|
+ type:2,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name:"相关性图表",
|
|
|
+ type:3,
|
|
|
+ }
|
|
|
+]
|
|
|
+let type=ref(1)
|
|
|
+const isShowMe=ref(false)
|
|
|
+
|
|
|
+const listState=reactive({
|
|
|
+ list:[],
|
|
|
+ page:0,
|
|
|
+ pageSize:20,
|
|
|
+ loading:false,
|
|
|
+ finished:false,
|
|
|
+})
|
|
|
+
|
|
|
+async function getChartList(){
|
|
|
+ const params={
|
|
|
+ PageSize: listState.pageSize,
|
|
|
+ CurrentIndex: listState.page,
|
|
|
+ ChartClassifyId: 0,
|
|
|
+ KeyWord: keyword.value,
|
|
|
+ IsShowMe:isShowMe.value
|
|
|
+ }
|
|
|
+ let res
|
|
|
+ if(type.value==1){
|
|
|
+ res=await apiPubChartList(params)
|
|
|
+ }else if(type.value==2){
|
|
|
+ res=await apiFutureSearchChartList(params)
|
|
|
+ }else if(type.value==3){
|
|
|
+ res=await apiCorrelationChartList(params)
|
|
|
+ }
|
|
|
+
|
|
|
+ if(res.Ret==200){
|
|
|
+ listState.loading=false
|
|
|
+ if(!res.Data){
|
|
|
+ listState.finished=true
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ listState.finished=res.Data.Paging.IsEnd
|
|
|
+ const arr=res.Data.List||[]
|
|
|
+ listState.list=[...listState.list,...arr]
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function onLoad(){
|
|
|
+ listState.page++
|
|
|
+ getChartList()
|
|
|
+}
|
|
|
+
|
|
|
+function refreshList(){
|
|
|
+ listState.list=[]
|
|
|
+ listState.page=1
|
|
|
+ listState.finished=false
|
|
|
+ getChartList()
|
|
|
+}
|
|
|
+
|
|
|
+// 切换图类型
|
|
|
+function handleTypeChange(item){
|
|
|
+ type.value=item.type
|
|
|
+ isShowMe.value=false
|
|
|
+ refreshList()
|
|
|
+}
|
|
|
+
|
|
|
+// 搜索
|
|
|
+function onSearch(){
|
|
|
+ refreshList()
|
|
|
+}
|
|
|
+// 清除搜索关键词
|
|
|
+function onClearSearch(){
|
|
|
+ console.log('aaa');
|
|
|
+ keyword.value=''
|
|
|
+ refreshList()
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+// 获取我的分类数据
|
|
|
+let classifyList=ref([])
|
|
|
+async function getMyClassifyList(){
|
|
|
+ const res=await apiMyClassifyList()
|
|
|
+ if(res.Ret===200){
|
|
|
+ const arr=res.Data.List||[]
|
|
|
+ classifyList.value=arr.map(item=>{
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ isSelect:false//用于选择的时候
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+getMyClassifyList()
|
|
|
+// 显示选择分类弹窗
|
|
|
+let showSelect=ref(false)
|
|
|
+let selectChartId=ref(0)
|
|
|
+
|
|
|
+// 确认将图加入选择的分类
|
|
|
+function handleConfirmAddChart(){
|
|
|
+ let arr=[]
|
|
|
+ classifyList.value.forEach(item=>{
|
|
|
+ if(item.isSelect){
|
|
|
+ arr.push(item.MyChartClassifyId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if(arr.length===0){
|
|
|
+ showToast('请选择分类')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ apiMyChartAdd({
|
|
|
+ ChartInfoId:selectChartId.value,
|
|
|
+ MyChartClassifyId:arr
|
|
|
+ }).then(res=>{
|
|
|
+ if(res.Ret===200){
|
|
|
+ showToast('添加成功!')
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="choose-chart-list-page">
|
|
|
+ <div class="search-box">
|
|
|
+ <van-search
|
|
|
+ shape="round"
|
|
|
+ placeholder="请输入图表名称"
|
|
|
+ v-model="keyword"
|
|
|
+ @search="onSearch"
|
|
|
+ @clear="onClearSearch"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="type-box">
|
|
|
+ <span
|
|
|
+ class="opt"
|
|
|
+ v-for="item in typeOpt"
|
|
|
+ :key="item.type"
|
|
|
+ @click="handleTypeChange(item)"
|
|
|
+ >{{item.name}}</span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <van-list
|
|
|
+ v-model:loading="listState.loading"
|
|
|
+ :finished="listState.finished"
|
|
|
+ finished-text="没有更多了"
|
|
|
+ @load="onLoad"
|
|
|
+ >
|
|
|
+ <ul class="list-wrap">
|
|
|
+ <li class="item" v-for="item in listState.list" :key="item.ChartInfoId">
|
|
|
+ <div class="van-multi-ellipsis--l2 name">{{item.ChartName}}</div>
|
|
|
+ <van-image
|
|
|
+ fit="contain"
|
|
|
+ lazy-load
|
|
|
+ class="img"
|
|
|
+ :src="item.ChartImage"
|
|
|
+ />
|
|
|
+ <div>
|
|
|
+ <span class="time">最新更新:{{item.ModifyTime.substr(0,10)}}</span>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ </van-list>
|
|
|
+ </div>
|
|
|
+ <!-- 选择分类弹窗 -->
|
|
|
+ <van-popup
|
|
|
+ v-model:show="showSelect"
|
|
|
+ position="bottom"
|
|
|
+ round
|
|
|
+ >
|
|
|
+ <div class="select-classify-wrap">
|
|
|
+ <div class="top-box">
|
|
|
+ <span class="title">选择分类</span>
|
|
|
+ <span class="confirm-btn" @click="handleConfirmAddChart">确定</span>
|
|
|
+ </div>
|
|
|
+ <ul class="classify-list">
|
|
|
+ <li
|
|
|
+ :class="['item',item.isSelect?'active':'']"
|
|
|
+ v-for="item in classifyList"
|
|
|
+ :key="item.MyChartClassifyId"
|
|
|
+ @click="item.isSelect=!item.isSelect"
|
|
|
+ >{{item.MyChartClassifyName}}</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ </van-popup>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.type-box{
|
|
|
+ .opt{
|
|
|
+ display: inline-block;
|
|
|
+ margin-right: 20px;
|
|
|
+ }
|
|
|
+}
|
|
|
+.list-wrap{
|
|
|
+ padding: $page-padding;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ justify-content: space-between;
|
|
|
+ .item{
|
|
|
+ box-sizing: border-box;
|
|
|
+ border: 1px solid $border-color;
|
|
|
+ padding: 20px;
|
|
|
+ width: 48%;
|
|
|
+ margin-bottom: 30px;
|
|
|
+ .name{
|
|
|
+ min-height: 60px;
|
|
|
+ }
|
|
|
+ .img{
|
|
|
+ width: 100%;
|
|
|
+ height: 200px;
|
|
|
+ margin: 20px 0;
|
|
|
+ }
|
|
|
+ .time{
|
|
|
+ font-size: 12px;
|
|
|
+ color: $font-grey;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+.select-classify-wrap{
|
|
|
+ .top-box{
|
|
|
+ padding: 20px 0;
|
|
|
+ text-align: center;
|
|
|
+ border-bottom: 1px solid $border-color;
|
|
|
+ position: relative;
|
|
|
+ .confirm-btn{
|
|
|
+ position: absolute;
|
|
|
+ right: 34px;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ color: $theme-color;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .classify-list{
|
|
|
+ height: 40vh;
|
|
|
+ overflow-y: auto;
|
|
|
+ .item{
|
|
|
+ padding: 20px 24px;
|
|
|
+ border-bottom: 1px solid $border-color;
|
|
|
+ }
|
|
|
+ .active{
|
|
|
+ color: $theme-color;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|