xytSk-App/pages/rainDetail/jcsj/jcsj.vue

166 lines
4.5 KiB
Vue
Raw Normal View History

2024-06-05 16:16:58 +08:00
<template>
<view class="jcsj-box">
<view class="time-ranger">
2024-06-14 17:47:32 +08:00
<view class="start-time">
<text>开始时间</text>
<text @click="showTime=true" style="margin-left:15%;color:#3399ef">{{stm}}</text>
</view>
<view class="end-time">
<text>结束时间</text>
<text @click="showTime1=true" style="margin:0 15%;color:#3399ef">{{etm}}</text>
<view class="search-btn" @click="searchHandle">
搜索
</view>
</view>
<!-- <uni-datetime-picker type="datetimerange" v-model="tm" @change="handleRanger"></uni-datetime-picker>
2024-06-05 16:16:58 +08:00
<view class="search-btn" @click="searchHandle">
搜索
2024-06-14 17:47:32 +08:00
</view> -->
2024-06-05 16:16:58 +08:00
</view>
<!-- <view class="" style="width: 100%; height: 3px; background-color: #dfdfdf; margin-bottom: 2px;">
</view> -->
<view class="jcsj-charts">
2024-06-14 17:47:32 +08:00
<qiun-data-charts :chartData="chartData.chartData" :echartsApp="true" :eopts="chartData.eopts" />
2024-06-05 16:16:58 +08:00
</view>
<view class="jcsj-table">
<JcsjTable :tableData="tableData" />
</view>
2024-06-14 17:47:32 +08:00
<u-datetime-picker
:show="showTime"
v-model="startTime"
mode="datetime"
@confirm="handleStartTime"
@cancel="showTime=false"
></u-datetime-picker>
<u-datetime-picker
:show="showTime1"
v-model="endTime"
mode="datetime"
@confirm="handleEndTime"
@cancel="showTime1=false"
></u-datetime-picker>
2024-06-05 16:16:58 +08:00
</view>
</template>
<script>
import moment from "moment"
import JcsjTable from "./jcsjTable"
import drpOption from "./chartOption.js"
const stm = moment().subtract(7, 'days').add(1, 'hour').set({minute: 0, second: 0}).format("YYYY-MM-DD HH:mm");
2024-06-14 17:47:32 +08:00
const etm = moment().add(1, 'hour').set({minute: 0, second: 0}).format("YYYY-MM-DD HH:mm");
2024-06-05 16:16:58 +08:00
export default {
props:{
stcd:String,
default:''
},
data() {
return {
2024-06-14 17:47:32 +08:00
startTime:stm,
endTime:etm,
stm,
etm,
2024-06-05 16:16:58 +08:00
tableData:[],
2024-06-14 17:47:32 +08:00
chartData: {chartData:{},eopts:{}},
2024-06-05 16:16:58 +08:00
rainChartData:{},
2024-06-14 17:47:32 +08:00
showTime:false,
showTime1:false
2024-06-05 16:16:58 +08:00
}
},
components:{
JcsjTable
},
watch:{
2024-06-14 17:47:32 +08:00
rainChartData:{
handler(newV){
2024-06-05 16:16:58 +08:00
this.chartData = {...drpOption(newV)}
2024-06-14 17:47:32 +08:00
},
deep:true
2024-06-05 16:16:58 +08:00
}
},
methods: {
2024-06-14 17:47:32 +08:00
handleStartTime(e){
let time = moment(e.value).format("YYYY-MM-DD HH:mm")
this.stm = time
this.showTime = false
},
handleEndTime(e){
let time = moment(e.value).format("YYYY-MM-DD HH:mm")
this.etm = time;
this.showTime1 = false
},
2024-06-05 16:16:58 +08:00
handleRanger(e){
console.log(e);
this.tm = [...e]
},
// 搜索
async getJcsjData(){
try{
const {data} = await uni.$http.post(
"/gunshiApp/xfflood/attResBase/rainBasinDivision/queryStStbprpPerHour/StcdAndStartTimeAndEndTime",
{
stcd:this.stcd,
2024-06-14 17:47:32 +08:00
startTime:moment(this.stm).format("YYYY-MM-DD HH:mm:ss"),
endTime:moment(this.etm).format("YYYY-MM-DD HH:mm:ss"),
2024-06-05 16:16:58 +08:00
})
if(data.code == 200){
this.tableData = [...data.data]
}
}catch(e){
uni.$showMsg()
}
},
// 获取图表数据
async getRainChartData(){
try{
const {data} = await uni.$http.post(
"/gunshiApp/xfflood/attResBase/rainBasinDivision/queryStStbprpPerHourChart/StcdAndStartTimeAndEndTime",
{
stcd:this.stcd,
2024-06-14 17:47:32 +08:00
startTime:moment(this.stm).format("YYYY-MM-DD HH:mm:ss"),
endTime:moment(this.etm).format("YYYY-MM-DD HH:mm:ss"),
2024-06-05 16:16:58 +08:00
})
if(data.code == 200){
this.rainChartData = {...data.data}
}
}catch(e){
uni.$showMsg()
}
},
// 搜索
searchHandle(){
this.getJcsjData();
this.getRainChartData()
}
},
mounted() {
this.getJcsjData()
this.getRainChartData()
},
}
</script>
<style lang="scss" scoped>
.jcsj-box{
.time-ranger{
2024-06-14 17:47:32 +08:00
// display: flex;
// align-items: center;
2024-06-05 16:16:58 +08:00
margin-bottom: 10px;
2024-06-14 17:47:32 +08:00
.start-time, .end-time{
display: flex;
align-items: center;
padding: 10px 0;
border-bottom: 1px solid #dfdfdf;
}
2024-06-05 16:16:58 +08:00
.search-btn{
margin: 3px 0 0 5px;
2024-06-14 17:47:32 +08:00
// color: #3399ef;
2024-06-05 16:16:58 +08:00
}
}
.jcsj-charts{
width:100%;
height: 300px;
}
}
</style>