海信交通一体化小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

617 lines
23 KiB

<template>
<!-- 公交投入数据表单 -->
<view class="form_warp">
<view class="form_item_box">
<view class="form_item_title">基本信息</view>
<view class="form_item">
<view class="form_item_label">统计日期</view>
<view class="form_item_input picker">
<picker mode="date" :value="form.reportDate" @change="bindDateChange">
<text class="picker_select"
:style="form.reportDate?'color:#333;':''">{{form.reportDate?form.reportDate:'请选择统计日期'}}</text>
<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
</picker>
</view>
</view>
<view class="form_item">
<view class="form_item_label">统计时段</view>
<view class="form_item_input picker">
<picker :value="index" :range="timeArray" range-key="dictLabel" @change="bindtimeChange">
<text class="picker_select"
:style="index>-1?'color:#333;':''">{{timeName ? timeName :'请选择统计时段'}}</text>
<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
</picker>
</view>
</view>
</view>
<view class="form_item_box bottom">
<view class="form_item_li" v-for="(item,index) in form.bizBusDataDetailVOList" :key="index">
<view class="form_item"
style="display:flex; justify-content: space-between; font-size: 30rpx;color:#333;font-weight: bold;margin-top: 30rpx;">
运行数据-{{index+1}}
<uni-icons type="trash" color="red" @click="delRow(index)" size="18"></uni-icons>
</view>
<view class="form_item">
<view class="form_item_label">名称</view>
<view class="form_item_input picker">
<picker :value="item.busIndex" :range="busArray" range-key="stationId"
@change="e => changeBusway(e, 'bizBusDataDetailVOList', index)">
<text class="picker_select"
:style="item.busUnit?'color:#333;':''">{{item.busUnit ? item.busUnit : '请选择'}}</text>
<uni-icons type="right" size="16" color="#D4D4D4"></uni-icons>
</picker>
</view>
</view>
<view class="form_item">
<view class="form_item_label">投入车辆</view>
<view class="form_item_input form_input"><!-- digit -->
<uni-easyinput type="digit" v-model="item.vehicleInput" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('vehicleInput','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item_rate" v-if="item.vehicleInputMom || item.vehicleInputYoy" :class="item.vehicleInputMom == 0 ? 'danger' : '' ">
<view class="rate_item">
<view class="rate_item_label" :style="item.vehicleInputMom == 0 ? 'color: #EB4747' : ''">投入车辆环比(%)</view>
<view class="rate_item_input" :style="item.vehicleInputMom == 0 ? 'color: #EB4747' : ''">
{{item.vehicleInputMom === 0 ? item.vehicleInputMom : item.vehicleInputMom ? item.vehicleInputMom.toFixed(2) : ''}}
</view>
</view>
<view class="line"></view>
<view class="rate_item">
<view class="rate_item_label">投入车辆同比(%)</view>
<view class="rate_item_input">
{{item.vehicleInputYoy === 0 ? item.vehicleInputYoy : item.vehicleInputYoy ? item.vehicleInputYoy.toFixed(2) : ''}}
</view>
</view>
</view>
<view class="form_item">
<view class="form_item_label">运行班次:</view>
<view class="form_item_input form_input"><!-- digit -->
<uni-easyinput type="number" v-model="item.operatingShifts" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('operatingShifts','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item_rate" v-if="item.operatingShiftsMom || item.operatingShiftsYoy" :class="item.operatingShiftsMom == 0 ? 'danger' : '' ">
<view class="rate_item">
<view class="rate_item_label" :style="item.operatingShiftsMom == 0 ? 'color: #EB4747' : ''">运行班次环比(%)</view>
<view class="rate_item_input" :style="item.operatingShiftsMom == 0 ? 'color: #EB4747' : ''">
{{item.operatingShiftsMom === 0 ? item.operatingShiftsMom : item.operatingShiftsMom ? item.operatingShiftsMom.toFixed(2) : ''}}
</view>
</view>
<view class="line"></view>
<view class="rate_item">
<view class="rate_item_label">运行班次同比(%)</view>
<view class="rate_item_input">
{{item.operatingShiftsYoy === 0 ? item.operatingShiftsYoy : item.operatingShiftsYoy ? item.operatingShiftsYoy.toFixed(2) : ''}}
</view>
</view>
</view>
<view class="form_item">
<view class="form_item_label">人数(万人):</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.passengerCount" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('passengerCount','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item_rate" v-if="item.passengerCountMom || item.passengerCountYoy" :class="item.passengerCountMom == 0 ? 'danger' : '' ">
<view class="rate_item">
<view class="rate_item_label" :style="item.passengerCountMom == 0 ? 'color: #EB4747' : ''">人数环比(%)</view>
<view class="rate_item_input" :style="item.passengerCountMom == 0 ? 'color: #EB4747' : ''">
{{item.passengerCountMom === 0 ? item.passengerCountMom : item.passengerCountMom ? item.passengerCountMom.toFixed(2) : ''}}
</view>
</view>
<view class="line"></view>
<view class="rate_item">
<view class="rate_item_label">人数同比(%)</view>
<view class="rate_item_input">
{{item.passengerCountYoy === 0 ? item.passengerCountYoy : item.passengerCountYoy ? item.passengerCountYoy.toFixed(2) : ''}}
</view>
</view>
</view>
<view class="form_item">
<view class="form_item_label">昨日投入车辆:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.yestVehicleInput" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('yestVehicleInput','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item">
<view class="form_item_label">昨日运行班次:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.yestOperatingShifts" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('yestOperatingShifts','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item">
<view class="form_item_label">昨日人数:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.yestPassengerCount" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('yestPassengerCount','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item">
<view class="form_item_label">去年投入车辆:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.lyVehicleInput" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('lyVehicleInput','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item">
<view class="form_item_label">去年运行班次:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.lyOperatingShifts" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('lyOperatingShifts','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="form_item">
<view class="form_item_label">去年人数:</view>
<view class="form_item_input form_input">
<uni-easyinput type="digit" v-model="item.lyPassengerCount" placeholderStyle="color: #D4D4D4;font-size:28rpx;"
placeholder="请输入" @blur="checkNumber('lyPassengerCount','bizBusDataDetailVOList',index)"></uni-easyinput>
</view>
</view>
<view class="line"></view>
</view>
<view class="add_btn" @click="addRow()">增行</view>
</view>
<view class="foot_btn">
<view class="act_btn" @click="doCancel">取消</view>
<view class="act_btn blue" @click="doSubmit">确认</view>
</view>
</view>
</template>
<script>
import { getDateStr } from '../../../common/util'
export default {
data() {
return {
timeArray:[],
pageType:'',
form:{
reportDate:'',
bizBusDataDetailVOList:[
{
busUnit:'',
busIndex:'',
vehicleInput:'',
vehicleInputMom:0,
vehicleInputYoy:0,
operatingShiftsMom:0,
operatingShiftsYoy:0,
passengerCount:'',
passengerCountMom:0,
passengerCountYoy:0,
yestVehicleInput:'',
yestOperatingShifts:'',
yestPassengerCount:'',
lyVehicleInput:'',
lyOperatingShifts:'',
lyPassengerCount:''
}
],
bizBusDataBodySaveOrUpdateDTOList:[]
},
index:'',
timeName:'',
busArray:[],
yoyMom:{},
}
},
onLoad(options) {
console.log(options)
this.getRoadTime();
// this.getBusData();
this.getPermiss()
if(options.type == 'add'){
this.pageType = 'add';
let now = new Date();
this.form.reportDate = getDateStr(now,0)
}else if(options.type == 'edit'){
this.pageType == 'edit';
this.form = JSON.parse(options.item)
}
},
methods: {
// 获取权限
getPermiss(){
this.$request(getApp().globalData.baseUrl + '/api/biz/bizBusAuthority/findList',{},"GET").then(res =>{
console.log('数据权限==>',res)
this.busArray = res.data
})
},
// 获取时段
getRoadTime(){
this.$request(getApp().globalData.baseUrl + '/api/dict/dictList?dictType=airport_time&_t=' + Date.parse(new Date()),"GET").then(res =>{
this.timeArray = res.data;
if(this.pageType == 'edit'){
this.index = this.timeArray.findIndex(item => item.dictValue == this.form.statPeriod)
this.timeName = this.timeArray.find(item => item.dictValue == this.form.statPeriod).dictLabel
}else if(this.pageType == 'add'){
let now = new Date();
let dateStr = getDateStr(now,0);
if(new Date(dateStr + ' 11:00').getTime() < new Date().getTime() && new Date().getTime() < new Date(dateStr + ' 13:30').getTime()) {
this.form.statPeriod = "0012";
this.index = this.timeArray.findIndex(item => item.dictValue == "0012")
this.timeName = this.timeArray.find(item => item.dictValue == "0012").dictLabel
}else{
this.form.statPeriod = "03";
this.index = this.timeArray.findIndex(item => item.dictValue == "03")
this.timeName = this.timeArray.find(item => item.dictValue == "03").dictLabel
}
}
})
},
// 获取同比环比
getYoyMom(item,index){
let params = {
busUnit:item.busUnit,
statDate:this.form.reportDate
}
// console.log(params)
this.$request(getApp().globalData.baseUrl + '/api/biz/busdata/getYoyMom', params,"GET").then(res =>{
console.log('同比环比数据===>',res)
this.yoyMom = res.data;
this.checkYoyMom(index)
})
},
// 点击确定按钮
doSubmit(){
this.form.bizBusDataBodySaveOrUpdateDTOList = this.form.bizBusDataDetailVOList
console.log(this.form)
let params = this.form;
if(!this.form.reportDate){
uni.showToast({
title:"请选择统计日期",
icon:"none"
})
}else if(!this.form.statPeriod){
uni.showToast({
title:"请选择统计时段",
icon:"none"
})
}else{
uni.showModal({
title:'提示',
content:"确认保存当前报送数据吗?",
success: (res) => {
if(res.confirm){
uni.showLoading({
title: '提交中...',
mask: true
})
this.$request(getApp().globalData.baseUrl + '/api/biz/busdata/saveOrUpdate',params,"POST").then(res =>{
console.log(res)
if(res.code == 200){
uni.hideLoading();
uni.showToast({
title: '报送提交成功',
icon: 'none',
success: () => {
if(!this.form.id) {
uni.redirectTo({
url:"/pages/bus/busDataInfo/list"
})
}
else {
uni.navigateBack();
}
}
})
}
})
}
}
})
}
},
// 计算同比环比
checkYoyMom(index){
// 环比
if(this.yoyMom.yesterdayData){
// this.form.bizBusDataDetailVOList[index].operatingShiftsMom = this.form.bizBusDataDetailVOList[index].operatingShifts && this.yoyMom.yesterdayData.operatingShifts ?
// (this.form.bizBusDataDetailVOList[index].operatingShifts - this.yoyMom.yesterdayData.operatingShifts) / this.yoyMom.yesterdayData.operatingShifts * 100 : '';
this.form.bizBusDataDetailVOList[index].operatingShiftsMom = !checkNotEmpty(this.yoyMom.yesterdayData.operatingShifts) || this.yoyMom.yesterdayData.operatingShifts === 0 ? 100 : this.form.bizBusDataDetailVOList[index].operatingShifts ? (parseInt(this
.form.bizBusDataDetailVOList[index].operatingShifts) - this.yoyMom.yesterdayData.operatingShifts) / this.yoyMom.yesterdayData.operatingShifts *
100 : '';
// this.form.bizBusDataDetailVOList[index].passengerCountMom = this.form.bizBusDataDetailVOList[index].passengerCount && this.yoyMom.yesterdayData.passengerCount ?
// (this.form.bizBusDataDetailVOList[index].passengerCount - this.yoyMom.yesterdayData.passengerCount) / this.yoyMom.yesterdayData.passengerCount * 100 : '';
this.form.bizBusDataDetailVOList[index].passengerCountMom = !checkNotEmpty(this.yoyMom.yesterdayData.passengerCount) || this.yoyMom.yesterdayData.passengerCount === 0 ? 100 : this.form.bizBusDataDetailVOList[index].passengerCount ? (parseInt(this
.form.bizBusDataDetailVOList[index].passengerCount) - this.yoyMom.yesterdayData.passengerCount) / this.yoyMom.yesterdayData.passengerCount *
100 : '';
// this.form.bizBusDataDetailVOList[index].vehicleInputMom = this.form.bizBusDataDetailVOList[index].vehicleInput && this.yoyMom.yesterdayData.vehicleInput ?
// (this.form.bizBusDataDetailVOList[index].vehicleInput - this.yoyMom.yesterdayData.vehicleInput) / this.yoyMom.yesterdayData.vehicleInput * 100 : '';
this.form.bizBusDataDetailVOList[index].vehicleInputMom = !checkNotEmpty(this.yoyMom.yesterdayData.vehicleInput) || this.yoyMom.yesterdayData.vehicleInput === 0 ? 100 : this.form.bizBusDataDetailVOList[index].vehicleInput ? (parseInt(this
.form.bizBusDataDetailVOList[index].vehicleInput) - this.yoyMom.yesterdayData.vehicleInput) / this.yoyMom.yesterdayData.vehicleInput *
100 : '';
}
// 同比
if(this.yoyMom.lastYearData){
// this.form.bizBusDataDetailVOList[index].operatingShiftsYoy = this.form.bizBusDataDetailVOList[index].operatingShifts && this.yoyMom.lastYearData.operatingShifts ?
// (this.form.bizBusDataDetailVOList[index].operatingShifts - this.yoyMom.lastYearData.operatingShifts) / this.yoyMom.lastYearData.operatingShifts * 100 : '';
this.form.bizBusDataDetailVOList[index].operatingShiftsYoy = !checkNotEmpty(this.yoyMom.lastYearData.operatingShifts) || this.yoyMom.lastYearData.operatingShifts === 0 ? 100 : this.form.bizBusDataDetailVOList[index].operatingShifts ? (parseInt(this
.form.bizBusDataDetailVOList[index].operatingShifts) - this.yoyMom.lastYearData.operatingShifts) / this.yoyMom.lastYearData.operatingShifts *
100 : '';
// this.form.bizBusDataDetailVOList[index].passengerCountYoy = this.form.bizBusDataDetailVOList[index].passengerCount && this.yoyMom.lastYearData.passengerCount ?
// (this.form.bizBusDataDetailVOList[index].passengerCount - this.yoyMom.lastYearData.passengerCount) / this.yoyMom.lastYearData.passengerCount * 100 : '';
this.form.bizBusDataDetailVOList[index].passengerCountYoy = !checkNotEmpty(this.yoyMom.lastYearData.passengerCount) || this.yoyMom.lastYearData.passengerCount === 0 ? 100 : this.form.bizBusDataDetailVOList[index].passengerCount ? (parseInt(this
.form.bizBusDataDetailVOList[index].passengerCount) - this.yoyMom.lastYearData.passengerCount) / this.yoyMom.lastYearData.passengerCount *
100 : '';
// this.form.bizBusDataDetailVOList[index].vehicleInputYoy = this.form.bizBusDataDetailVOList[index].vehicleInput && this.yoyMom.lastYearData.vehicleInput ?
// (this.form.bizBusDataDetailVOList[index].vehicleInput - this.yoyMom.lastYearData.vehicleInput) / this.yoyMom.lastYearData.vehicleInput * 100 : '';
this.form.bizBusDataDetailVOList[index].vehicleInputYoy = !checkNotEmpty(this.yoyMom.lastYearData.vehicleInput) || this.yoyMom.lastYearData.vehicleInput === 0 ? 100 : this.form.bizBusDataDetailVOList[index].vehicleInput ? (parseInt(this
.form.bizBusDataDetailVOList[index].vehicleInput) - this.yoyMom.lastYearData.vehicleInput) / this.yoyMom.lastYearData.vehicleInput *
100 : '';
}
},
// 获取公交车
// getBusData(){
// this.$request(getApp().globalData.baseUrl + '/api/dict/dictList?dictType=bus_unit&_t=' + Date.parse(new Date()),{},"GET").then(res =>{
// this.busArray = res.data
// })
// },
//选择统计日期
bindDateChange(e) {
this.form.reportDate = e.detail.value;
},
//选择时段
bindtimeChange(e){
let index = e.target.value;
var selected = this.timeArray[index];
this.form.statPeriod = selected.dictValue;
this.timeName = selected.dictLabel
},
// 切换公交车
changeBusway(e,key,index){
this.form[key][index].busIndex = e.detail.value;
this.form[key][index].busUnit = this.busArray[e.detail.value].stationId;
this.getYoyMom(this.form[key][index],index)
},
// 验证格式为数字且最多只有一个小数点
checkNumber(val,key,index){ // 值允许输入一个小数点和数字
if(this.form[key][index][val]){
if(val == 'operatingShifts' || val == 'passengerCount' || val == 'vehicleInput'){
console.log(this.form[key][index])
this.getYoyMom(this.form[key][index])
}
this.form[key][index][val] = this.form[key][index][val].replace(/[^\d.]/g,""); //先把非数字的都替换掉,除了数字和.
this.form[key][index][val] = this.form[key][index][val].replace(/^\./g,""); //必须保证第一个为数字而不是.
this.form[key][index][val] = this.form[key][index][val].replace(/\.{2,}/g,"."); //保证只有出现一个.而没有多个.
this.form[key][index][val] = this.form[key][index][val].replace(".","$#$").replace(/\./g,"").replace("$#$","."); //保证.只出现一次,而不能出现两次以上
}
},
// 点击增行按钮
addRow(){
this.form.bizBusDataDetailVOList.push(
{
busUnit:'',
busIndex:'',
vehicleInput:'',
vehicleInputMom:0,
vehicleInputYoy:0,
operatingShiftsMom:0,
operatingShiftsYoy:0,
passengerCount:'',
passengerCountMom:0,
passengerCountYoy:0,
yestVehicleInput:'',
yestOperatingShifts:'',
yestPassengerCount:'',
lyVehicleInput:'',
lyOperatingShifts:'',
lyPassengerCount:''
}
)
},
// 点击删行按钮
delRow(index){
this.form.bizBusDataDetailVOList.splice(index, 1);
},
}
}
</script>
<style lang="scss" scoped>
.form_warp {
padding: 30rpx 30rpx 195rpx;
.form_intro {
color: #666;
font-size: 26rpx;
font-family: PingFang SC-Bold, PingFang SC;
line-height: 48rpx;
text-align: center;
margin-bottom: 20rpx;
.tel {
color: #2D8CF0;
font-weight: bold;
}
}
.form_item_box {
padding: 30rpx 20rpx 30rpx 30rpx;
background-color: #fff;
border-radius: 30rpx;
&.bottom{
margin-top: 30rpx;
}
//环比同比
.form_item_rate{
background: #F6F6F6;
border: 1px solid #F6F6F6;
padding: 30rpx;
margin-bottom: 30rpx;
border-radius: 30rpx;
.line{
height: 1px;
background-color: #dfdfdf;
margin: 30rpx 0;
}
.rate_item{
display: flex;
justify-content: space-between;
font-size: 24rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
.rate_item_label{
color: #666;
font-size: 24rpx;
}
.rate_item_input{
color: #333;
font-size: 28rpx;
}
}
&.danger{
background-color: #FEF6F3;
border-color: #F0622D;
}
}
.form_item_title {
color: #333;
line-height: 42rpx;
font-size: 30rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
margin-bottom: 30rpx;
}
.form_item_remark{
margin-bottom: 30rpx;
.form_item_label{
color: #333333;
line-height: 42rpx;
font-size: 30rpx;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
margin-bottom: 30rpx;
}
}
.form_item {
display: flex;
align-items: center;
justify-content: space-between;
line-height: 37rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
margin-bottom: 30rpx;
.form_item_label {
width: 300rpx;
color: #666666;
font-size: 26rpx;
word-break: break-all;
}
.form_item_input {
color: #333;
text-align: right;
word-break: break-all;
&.picker {
flex: 1;
display: flex;
justify-content: space-between;
/deep/ picker {
flex: 1;
}
.picker_select {
color: #D4D4D4;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
text-align: right;
}
}
//纯展示
&.text{
color: #333333;
line-height: 40rpx;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
}
//输入框
&.form_input{
/deep/ .is-input-border{
border: 0 !important;
.uni-easyinput__content-input{
text-align: right;
}
}
}
}
}
}
}
//增行
.line {
height: 1px;
background-color: #E1E1E1;
}
.add_btn {
height: 90rpx;
line-height: 90rpx;
color: #2D8CF0;
font-size: 28rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
text-align: center;
background: #ECF5FF;
border-radius: 30rpx;
border: 2rpx solid #2D8CF0;
margin-top: 30rpx;
}
.foot_btn {
position: fixed;
left: 0;
right: 0;
bottom: 0;
display: flex;
justify-content: space-between;
padding: 40rpx 30rpx;
background-color: #f5f5f5;
z-index: 11;
.act_btn {
width: 329rpx;
height: 90rpx;
color: #666666;
font-size: 28rpx;
line-height: 90rpx;
font-family: PingFang SC-Regular, PingFang SC;
font-weight: 400;
text-align: center;
background: #F6F6F6;
border-radius: 100rpx;
border: 1rpx solid #C1C1C1;
&.blue {
color: #fff;
background: #2D8CF0;
border-color: #2D8CF0;
}
}
}
</style>