|
@@ -13,6 +13,8 @@ import TreeSelectPop from './components/TreeSelectPop.vue'
|
|
|
import AddChartToMyETA from './components/AddChartToMyETA.vue'
|
|
|
import SetChartEnName from './components/SetChartEnName.vue'
|
|
|
import {useCachedViewsStore} from '@/store/modules/cachedViews'
|
|
|
+import { setExtremumDate } from '@/hooks/chart/commonFun.js'
|
|
|
+
|
|
|
import _ from 'lodash';
|
|
|
|
|
|
|
|
@@ -42,11 +44,14 @@ async function getChartDetail(e){
|
|
|
DateType: chartState.yearVal,
|
|
|
StartDate: chartState.startTime,
|
|
|
EndDate: chartState.endTime,
|
|
|
+ StartYear:chartState.startYear
|
|
|
}:{
|
|
|
ChartInfoId:Number(routeQueryData.id),
|
|
|
Calendar: chartState.calendarType,//this.calendar_type
|
|
|
- SeasonStartDate: chartState.startTime,
|
|
|
- SeasonEndDate:chartState.endTime ,
|
|
|
+ DateType: chartState.yearVal,
|
|
|
+ StartDate: chartState.startTime,
|
|
|
+ EndDate:chartState.endTime,
|
|
|
+ StartYear:chartState.startYear
|
|
|
}
|
|
|
const res=await apiChart.chartInfoById(params)
|
|
|
if(res.Ret!==200) return
|
|
@@ -62,6 +67,16 @@ async function getChartDetail(e){
|
|
|
chartState.yearVal=res.Data.ChartInfo.DateType
|
|
|
}
|
|
|
|
|
|
+ // 设置 起始日期 和 最新日期
|
|
|
+ const extremumDate= setExtremumDate(edbList.value)
|
|
|
+
|
|
|
+ minDate = new Date(extremumDate.earliestDate)
|
|
|
+ earliestDate.value = extremumDate.earliestDate
|
|
|
+
|
|
|
+ latestDate.value = extremumDate.latestDate
|
|
|
+
|
|
|
+ setDateAppear()
|
|
|
+
|
|
|
nextTick(()=>{
|
|
|
highChart.value = chartRender({
|
|
|
data:{
|
|
@@ -79,24 +94,38 @@ async function getChartDetail(e){
|
|
|
})
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+function setDateAppear() {
|
|
|
+ if(chartState.yearVal == 20){
|
|
|
+ let latestYear = parseInt(latestDate.value.substring(0,4))
|
|
|
+ chartState.startTime = `${latestYear-chartState.startYear+1}-01-01`
|
|
|
+ chartState.endTime = `${latestYear}-12-31`
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
currentLang.value = localStorage.getItem('chartETALange')==='EN'?'en':'zh'
|
|
|
initChartState(route.query)
|
|
|
getChartDetail('init')
|
|
|
})
|
|
|
|
|
|
-const minDate=new Date(1970, 0, 1)
|
|
|
+let minDate=new Date(1970, 0, 1)
|
|
|
const maxDate=new Date(2050, 11, 31)
|
|
|
const cYear=moment().format('YYYY')
|
|
|
const cMonth=moment().format('MM')
|
|
|
-let temStartTime=ref([cYear,cMonth])
|
|
|
-let temEndTime=ref([cYear,cMonth])
|
|
|
+const cDay=moment().format('dd')
|
|
|
+let temStartTime=ref([cYear,cMonth,cDay])
|
|
|
+let temEndTime=ref([cYear,cMonth,cDay])
|
|
|
+const latestDate = ref('')
|
|
|
+const earliestDate = ref('')
|
|
|
+
|
|
|
let chartState=reactive({
|
|
|
showTimePop:false,
|
|
|
startTime:'',
|
|
|
endTime:'',
|
|
|
yearVal:'',
|
|
|
- calendarType:'公历'
|
|
|
+ calendarType:'公历',
|
|
|
+ startYear:5
|
|
|
})
|
|
|
// 切换年份选项
|
|
|
function handleYearChange(item){
|
|
@@ -468,6 +497,40 @@ function initChartState(data){
|
|
|
chartState.endTime=sameOptionType.includes(Number(data.chartType))?data.EndDate:data.SeasonEndDate
|
|
|
chartState.yearVal=data.DateType
|
|
|
chartState.calendarType=data.Calendar
|
|
|
+ chartState.startYear=Number(data.StartYear)
|
|
|
+}
|
|
|
+
|
|
|
+function openDateSelect(){
|
|
|
+ // 回显
|
|
|
+
|
|
|
+ switch (chartState.yearVal) {
|
|
|
+ case 3:
|
|
|
+ temStartTime.value = [2015,1,1]
|
|
|
+ temEndTime.value = latestDate.value.split('-')
|
|
|
+ break;
|
|
|
+ case 9:
|
|
|
+ temStartTime.value = [2020,1,1]
|
|
|
+ temEndTime.value = latestDate.value.split('-')
|
|
|
+ break;
|
|
|
+ case 4:
|
|
|
+ temStartTime.value = [2021,1,1]
|
|
|
+ temEndTime.value = latestDate.value.split('-')
|
|
|
+ break;
|
|
|
+ case 11:
|
|
|
+ temStartTime.value = [2022,1,1]
|
|
|
+ temEndTime.value = latestDate.value.split('-')
|
|
|
+ break;
|
|
|
+ case '':
|
|
|
+ temStartTime.value = earliestDate.value.split('-')
|
|
|
+ temEndTime.value = latestDate.value.split('-')
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ temStartTime.value = chartState.startTime.split('-')
|
|
|
+ temEndTime.value = chartState.endTime.split('-')
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ chartState.showTimePop=true
|
|
|
}
|
|
|
|
|
|
|
|
@@ -481,7 +544,7 @@ function initChartState(data){
|
|
|
<div
|
|
|
class="select-time-box"
|
|
|
v-if="sameOptionType.includes(chartInfo.ChartType)||chartInfo.ChartType===2"
|
|
|
- @click="chartState.showTimePop=true"
|
|
|
+ @click="openDateSelect"
|
|
|
>
|
|
|
<img class="left-icon" src="@/assets/imgs/icon_calendar.png" alt="">
|
|
|
<span :class="['val-box',!chartState.startTime?'val-box_grey':'']">{{chartState.startTime||'开始日期'}} ~ {{chartState.endTime||'结束日期'}}</span>
|
|
@@ -502,7 +565,7 @@ function initChartState(data){
|
|
|
<span
|
|
|
class="time-box"
|
|
|
v-if="sameOptionType.includes(chartInfo.ChartType)||chartInfo.ChartType===2"
|
|
|
- @click="chartState.showTimePop=true"
|
|
|
+ @click="openDateSelect"
|
|
|
>
|
|
|
{{chartState.startTime?`${chartState.startTime} ~ ${chartState.endTime||'至今'}`:'请选择时间段'}}
|
|
|
</span>
|
|
@@ -595,13 +658,13 @@ function initChartState(data){
|
|
|
v-model="temStartTime"
|
|
|
:min-date="minDate"
|
|
|
:max-date="maxDate"
|
|
|
- :columns-type="chartInfo.ChartType==2?['year']:['year','month']"
|
|
|
+ :columns-type="['year','month','day']"
|
|
|
/>
|
|
|
<van-date-picker
|
|
|
v-model="temEndTime"
|
|
|
:min-date="minDate"
|
|
|
:max-date="maxDate"
|
|
|
- :columns-type="chartInfo.ChartType==2?['year']:['year','month']"
|
|
|
+ :columns-type="['year','month','day']"
|
|
|
/>
|
|
|
</van-picker-group>
|
|
|
</div>
|