xytSk-App/pages/rain/rain.vue

510 lines
18 KiB
Vue
Raw Normal View History

2024-05-30 13:53:09 +08:00
<template>
2024-05-31 09:31:56 +08:00
<view class="rain-box">
<view class="nav-bar">
2024-06-05 16:16:58 +08:00
<u-icon name="arrow-left" color="#000" size="28" @click="backTo"></u-icon>
2024-05-31 09:31:56 +08:00
<view class="">
雨情
</view>
<!-- <u-icon name="arrow-right" color="#000" size="28"></u-icon> -->
<cover-image
2024-06-05 16:16:58 +08:00
src="../../static/images/filter.png"
style="width: 20px; height: 20px; margin-right: 10px;"
@click="popupOpen = true"
v-show="!popupOpen"
2024-05-31 09:31:56 +08:00
>
</cover-image>
</view>
<!-- 搜索以及多级下拉 -->
<view class="search-box">
<view class="search-item">
2024-06-07 10:56:32 +08:00
<view style="display:flex" v-show="limit == 1">
2024-05-31 09:31:56 +08:00
<view class="" @click="handleClick" >
2024-06-05 16:16:58 +08:00
{{selecetItem.adnm == "全部" ? "咸丰县" : selecetItem.adnm || columns[0][0].adnm}}
2024-05-31 09:31:56 +08:00
</view>
<u-icon name="arrow-down-fill" color="#000" size="20" v-show="switchIcon"></u-icon>
<u-icon name="arrow-up-fill" color="#000" size="20" v-show="!switchIcon"></u-icon>
2024-06-07 10:56:32 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view class="rain-input" style="width: 50%;">
2024-05-31 09:31:56 +08:00
<u--input
placeholder="请输入站点"
prefixIcon="search"
prefixIconStyle="font-size: 22px;color: #909399"
2024-06-05 16:16:58 +08:00
@change="formData = {...formData,stArg:e}"
:value="formData.stArg"
2024-05-31 09:31:56 +08:00
></u--input>
</view>
2024-06-07 10:56:32 +08:00
<view style="display:flex" v-show="limit == 1">
2024-06-05 16:16:58 +08:00
<view class="" @click="handleClick1" >
{{selecetItem1.basName == "全部" ? "流域" : selecetItem1.basName || "流域"}}
2024-05-31 09:31:56 +08:00
</view>
<u-icon name="arrow-down-fill" color="#000" size="20" v-show="switchIcon1"></u-icon>
<u-icon name="arrow-up-fill" color="#000" size="20" v-show="!switchIcon1"></u-icon>
2024-06-07 10:56:32 +08:00
</view>
2024-05-31 09:31:56 +08:00
</view>
</view>
<!-- 单纯下拉 -->
<view class="time-select">
2024-06-05 16:16:58 +08:00
<view :class="{'jiangyu':true,'noClick':rainTime}" @click="handleJiangyu" >
<text>{{formData.orderType ? "按昨日降雨降序" :"按时段降雨降序"}}</text>
<u-icon name="arrow-down-fill" color="#000" size="20" v-show="!jiangyu"></u-icon>
<u-icon name="arrow-up-fill" color="#000" size="20" v-show="jiangyu"></u-icon>
2024-05-31 09:31:56 +08:00
<view class="jiangyu-dropdown" v-show="this.jiangyu">
2024-06-05 16:16:58 +08:00
<view :class="{'active': formData.orderType == 0}" @click="rainsort(0)" style="border-bottom: 1px solid #dfdfdf; border-top: 1px solid #dfdfdf; padding: 10px 0; display: flex; align-items: center;">
<text style="margin-right: 220px;">按时段降雨降序</text>
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.orderType == 0"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view :class="{'active':formData.orderType == 1}" @click="rainsort(1)" style="border-bottom: 1px solid #dfdfdf; padding-bottom: 10px; display: flex; align-items: center;">
<text style="margin-right: 220px;">按昨日降雨降序</text>
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.orderType == 1"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
</view>
</view>
2024-06-05 16:16:58 +08:00
<view class="rain-time" @click="handleTime">
<text>{{formData.timeType == 1 ? "1h" :
formData.timeType == 3 ? "3h" :
formData.timeType == 6 ? "6h" :
formData.timeType == 12 ? "12h" :
formData.timeType == 24 ? "24h" : ''
2024-05-31 09:31:56 +08:00
}}</text>
2024-06-05 16:16:58 +08:00
<u-icon name="arrow-down-fill" color="#000" size="20" v-show="!rainTime"></u-icon>
<u-icon name="arrow-up-fill" color="#000" size="20" v-show="rainTime"></u-icon>
2024-05-31 09:31:56 +08:00
<view class="rain-time-dropdown" v-show="rainTime">
2024-06-05 16:16:58 +08:00
<view class="" :class="{'active': formData.timeType == 1}" @click="timesort(1)" style="border-bottom: 1px solid #dfdfdf; border-top: 1px solid #dfdfdf; padding: 10px 0; display: flex; align-items: center;">
2024-05-31 09:31:56 +08:00
<text style="margin-right: 300px;">1h</text>
2024-06-05 16:16:58 +08:00
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.timeType == 1"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view class="" :class="{'active': formData.timeType == 3}" @click="timesort(3)" style="border-bottom: 1px solid #dfdfdf; padding-bottom: 10px; display: flex; align-items: center;">
2024-05-31 09:31:56 +08:00
<text style="margin-right: 300px;">3h</text>
2024-06-05 16:16:58 +08:00
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.timeType == 3"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view class="" :class="{'active': formData.timeType == 6}" @click="timesort(6)" style="border-bottom: 1px solid #dfdfdf; padding-bottom: 10px; display: flex; align-items: center;">
2024-05-31 09:31:56 +08:00
<text style="margin-right: 300px;">6h</text>
2024-06-05 16:16:58 +08:00
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.timeType == 6"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view class="" :class="{'active': formData.timeType == 12}" @click="timesort(12)" style="border-bottom: 1px solid #dfdfdf; padding-bottom: 10px; display: flex; align-items: center;">
2024-05-31 09:31:56 +08:00
<text style="margin-right: 300px;">12h</text>
2024-06-05 16:16:58 +08:00
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.timeType == 12"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
2024-06-05 16:16:58 +08:00
<view class="" :class="{'active': formData.timeType == 24}" @click="timesort(24)" style="border-bottom: 1px solid #dfdfdf; padding-bottom: 10px; display: flex; align-items: center;">
2024-05-31 09:31:56 +08:00
<text style="margin-right: 300px;">24h</text>
2024-06-05 16:16:58 +08:00
<u-icon name="checkmark" color="#02a7f0" size="20" v-show="formData.timeType == 24"></u-icon>
2024-05-31 09:31:56 +08:00
</view>
</view>
</view>
</view>
<!-- 内容部分 -->
<view style="width: 100%; height: 10px; background-color: #f7f7f7;">
</view>
<!-- 时间段 -->
<view style="padding: 5px 10px; text-align: center; color: #f7b156;">
2024-06-05 16:16:58 +08:00
统计时段{{tm.stm}}{{tm.etm}}
2024-05-31 09:31:56 +08:00
</view>
<view style="margin: 0 10px;">
2024-06-05 16:16:58 +08:00
<Table :list="rainList"/>
2024-05-31 09:31:56 +08:00
</view>
<u-picker
:show="show"
ref="uPicker"
:columns="columns"
@confirm="confirm"
@change="changeHandler"
@cancel="cancel"
2024-06-05 16:16:58 +08:00
keyName="adnm"
2024-05-31 09:31:56 +08:00
>
</u-picker>
<u-picker
:show="show1"
ref="uPicker1"
2024-06-05 16:16:58 +08:00
:columns="columns1"
2024-05-31 09:31:56 +08:00
@confirm="confirm1"
@cancel="cancel1"
2024-06-05 16:16:58 +08:00
keyName="basName"
2024-05-31 09:31:56 +08:00
>
</u-picker>
2024-06-05 16:16:58 +08:00
<u-popup :show="popupOpen" mode="right" @close="popupOpen=false" >
2024-05-31 09:31:56 +08:00
<view style="padding: 30px 20px;">
<text style="font-weight: bold;">按类型</text>
<view style="margin-bottom: 10px; margin-left: -5px;">
<u-checkbox-group
2024-06-05 16:16:58 +08:00
v-model="formData.source"
2024-05-31 09:31:56 +08:00
@change="checkboxChange"
>
<u-checkbox
:customStyle="{margin: '7px'}"
v-for="(item, index) in checkboxList1"
:key="index"
:label="item.name"
:name="item.value"
>
</u-checkbox>
</u-checkbox-group>
</view>
2024-06-05 16:16:58 +08:00
<!-- <text style="font-weight: bold;">按时间</text>
2024-05-31 09:31:56 +08:00
<view class="example-body" style="display: flex; align-items: center; margin-bottom: 10px; margin-top: 10px;">
2024-06-05 16:16:58 +08:00
<uni-datetime-picker type="datetime" v-model="stm" @change="(e) => this.stm = e" />
2024-05-31 09:31:56 +08:00
<text style="margin-left: 10px;"></text>
</view>
<view class="example-body" style="width: 92%;">
2024-06-05 16:16:58 +08:00
<uni-datetime-picker type="datetime" v-model="etm" @change="(e) => this.etm = e" />
2024-05-31 09:31:56 +08:00
</view>
<view style="display: flex; margin-top: 10px;">
<u-button class="first-btn" text="昨日08:00~当前时间"></u-button>
<u-button class="second-btn" text="今天08:00~当前时间"></u-button>
2024-06-05 16:16:58 +08:00
</view> -->
<view style="display: flex; margin-top: 240%;">
<u-button text="重置" class="bottom-btn1"
@click="formData = {...formData,source}"></u-button>
<u-button text="确认" color="#d9001b" class="bottom-btn2" @click="popupOpen = false"></u-button>
2024-05-31 09:31:56 +08:00
</view>
</view>
</u-popup>
</view>
2024-05-30 13:53:09 +08:00
</template>
<script>
2024-05-31 09:31:56 +08:00
import Table from "./Table"
import filter from "../../static/images/filter.png"
2024-06-05 16:16:58 +08:00
import moment from "moment"
2024-06-07 10:56:32 +08:00
import {disType} from "../utils/dicType.js"
const adcd = uni.getStorageSync('value').adcd
const type = disType(adcd)
2024-05-31 09:31:56 +08:00
export default {
data() {
return {
show: false,
show1:false,
switchIcon:true,
switchIcon1:true,
2024-06-05 16:16:58 +08:00
rainList:[],//雨情数据
selecetItem:{},
selecetItem1:{},
2024-05-31 09:31:56 +08:00
jiangyu:false, //显示下拉
rainTime:false, //显示下拉,
selectJyOne:1,//选中降雨最后一个元素,
selectTimeOne:4, //选中时间的最有一个元素
popupOpen:false, //抽屉打开
2024-06-05 16:16:58 +08:00
source:["SH","SW","QX","SK"],
// checkboxValue1:["SH","SW","QX","SK"],
2024-05-31 09:31:56 +08:00
// 基本案列数据
checkboxList1: [{
name: '山洪',
value: "SH"
},
{
name: '水文',
value: "SW"
},
{
name: '气象',
value: "QX"
},
{
name: '水库',
value: "SK"
}
],
2024-06-05 16:16:58 +08:00
stm: '', //开始时间,
etm:"",//结束时间
columns: //政区下拉
[
2024-06-07 10:56:32 +08:00
[{"adnm": "咸丰县", "adcd":adcd }],[]
2024-05-31 09:31:56 +08:00
],
2024-06-05 16:16:58 +08:00
columnData: [[]],
columns1:[[]], //流域选择,
formData:{ //表单数据
timeType:24,
orderType:1,
basCode:'',
source:["SH","SW","QX","SK"],
stArg:'',
2024-06-07 10:56:32 +08:00
adcd:type == 1 ? undefined :adcd,
2024-06-05 16:16:58 +08:00
etm:moment().set({ hour: 8, minute: 0, second: 0, millisecond: 0 }).format("YYYY-MM-DD HH:mm"),
stm:moment().subtract(1, 'day').set({ hour: 8, minute: 0, second: 0, millisecond: 0 }).format("YYYY-MM-DD HH:mm")
}
2024-05-31 09:31:56 +08:00
}
},
components:{
Table
2024-06-05 16:16:58 +08:00
},
computed:{
tm(){
return {
stm:moment().subtract(this.formData.timeType, 'hours').format("YYYY-MM-DD HH:mm"),
etm:moment().format("YYYY-MM-DD HH:mm")
}
2024-06-07 10:56:32 +08:00
},
limit(){
return disType(adcd)
2024-06-05 16:16:58 +08:00
}
},
watch:{
formData(newV, oldV){
console.log("www",newV)
this.getRainList()
}
2024-05-31 09:31:56 +08:00
},
methods: {
2024-06-05 16:16:58 +08:00
handleJiangyu(e){
if(this.rainTime){
e.stopPropagation();
return
}
this.jiangyu = !this.jiangyu
},
handleTime(e){
if(this.jiangyu){
e.stopPropagation();
return
}
this.rainTime = !this.rainTime
},
//按昨日降雨排序
rainsort(e){
this.formData = {...this.formData,orderType: e ? 1 : 0}
},
// 按小时排序
timesort(e){
this.formData = {
...this.formData,
stm:moment().subtract(e, 'hours').format("YYYY-MM-DD HH:mm"),
etm:moment().format("YYYY-MM-DD HH:mm"),
timeType:e
}
},
2024-05-31 09:31:56 +08:00
changeHandler(e) {
const {
columnIndex,
value,
values, // values为当前变化列的数组内容
index,
// 微信小程序无法将picker实例传出来只能通过ref操作
picker = this.$refs.uPicker
} = e
// 当第一列值发生变化时,变化第二列(后一列)对应的选项
if (columnIndex === 0) {
// picker为选择器this实例变化第二列对应的选项
picker.setColumnValues(1, this.columnData[index])
}
},
// 回调参数为包含columnIndex、value、values
confirm(e) {
console.log('confirm', e)
this.show = false
2024-06-05 16:16:58 +08:00
this.switchIcon=true;
this.selecetItem = e.value[1];
// this.formData.adcd = e.value[1].adcd;
this.formData = {...this.formData,adcd:e.value[1].adcd}
2024-05-31 09:31:56 +08:00
},
cancel(e) {
this.show = false
},
changeHandler1(e) {
const {
columnIndex,
value,
values, // values为当前变化列的数组内容
index,
// 微信小程序无法将picker实例传出来只能通过ref操作
picker = this.$refs.uPicker1
} = e
// 当第一列值发生变化时,变化第二列(后一列)对应的选项
if (columnIndex === 0) {
// picker为选择器this实例变化第二列对应的选项
picker.setColumnValues(1, this.columnData[index])
}
},
// 回调参数为包含columnIndex、value、values
confirm1(e) {
console.log('confirm', e)
this.show1 = false
2024-06-05 16:16:58 +08:00
this.switchIcon1=true;
this.selecetItem1 = e.value[0];
this.formData = {...this.formData,basCode:e.value[0].basCode};
2024-05-31 09:31:56 +08:00
},
cancel1(e) {
this.show1 = false
},
2024-06-05 16:16:58 +08:00
handleClick(e){
if(this.selecetItem1.basName && this.selecetItem1.basName != "全部"){
e.stopPropagation();
return
}
2024-05-31 09:31:56 +08:00
this.show = true;
this.switchIcon = !this.switchIcon
},
2024-06-05 16:16:58 +08:00
handleClick1(e){
if(this.selecetItem.adnm&&this.selecetItem.adnm != "全部"){
e.stopPropagation();
return
}
2024-05-31 09:31:56 +08:00
this.show1 = true;
this.switchIcon1 = !this.switchIcon1
},
checkboxChange(n) {
console.log('change', n);
2024-06-05 16:16:58 +08:00
this.formData = {...this.formData,source:n};
2024-05-31 09:31:56 +08:00
},
changeLog(e) {
console.log('change事件:', e);
},
2024-06-05 16:16:58 +08:00
// 获取行政区域选择
async adnmList(){
try{
const {data} = await uni.$http.get(
"/gunshiApp/xfflood/real/rain/adnmList"
)
if(data.code == 200){
const all = {
adnm:'全部',
adcd:''
}
this.columns = [[...this.columns[0]],[all,...data.data]];
this.columnData = [[all,...data.data]];
}
}catch(e){
uni.$showMsg()
}
},
// 获取流域
async basNameList(){
try{
const {data} = await uni.$http.get(
"/gunshiApp/xfflood/real/rain/basNameList"
)
if(data.code == 200){
const all = {
basName:'全部',
basCode:''
}
this.columns1 = [[all,...data.data]];
}
}catch(e){
uni.$showMsg()
}
},
// 获取雨情列表
async getRainList(){
try{
const {data} = await uni.$http.post(
"/gunshiApp/xfflood/real/rain/list",{...this.formData,timeType:undefined}
)
if(data.code == 200){
this.rainList = [...data.data];
}
}catch(e){
uni.$showMsg()
}
},
backTo(){
uni.navigateBack({delta:1})
}
},
onLoad() {
this.adnmList();
this.basNameList()
this.getRainList()
}
2024-05-31 09:31:56 +08:00
}
2024-05-30 13:53:09 +08:00
</script>
2024-05-31 09:31:56 +08:00
<style lang="scss" scoped>
.nav-bar{
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
margin-top: 30px;
padding-top: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #dfdfdf;
box-shadow: 0 5px 10px -8px #dfdfdf inset;
}
.search-box{
width: 100%;
display: flex;
justify-content: center;
.search-item{
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 20px;
width: 90%;
padding: 5px;
height: 30px;
background-color: #dddddd;
border-radius: 5px;
}
2024-06-05 16:16:58 +08:00
2024-05-31 09:31:56 +08:00
}
.time-select{
position: relative;
display: flex;
justify-content: center;
margin-top: 20px;
margin-bottom: 20px;
.noClick{
pointer-events: initial;
}
.jiangyu,.rain-time{
display: flex;
column-gap: 5px;
margin-right: 20px;
}
.jiangyu{
position: relative;
2024-06-05 16:16:58 +08:00
.jiangyu-dropdown{
2024-05-31 09:31:56 +08:00
position: absolute;
background-color: #fff;
width: 100vw;
left: -72px;
top: 35px;
.active{
color:#02a7f0
}
view{
margin-top: 10px;
}
}
}
.rain-time{
position: relative;
.rain-time-dropdown{
position: absolute;
background-color: #fff;
width: 100vw;
left: -230px;
top: 35px;
.active{
color:#02a7f0
}
view{
margin-top: 10px;
}
}
}
}
.first-btn{
margin-right: 5px;
background-color: #f2f2f2;
}
.second-btn{
background-color: #f2f2f2;
}
.bottom-btn1,.bottom-btn2{
width: 30%;
}
.bottom-btn1{
margin-left: 130px;
}
.bottom-btn2{
margin-right: -12px;
}
2024-05-30 13:53:09 +08:00
</style>