gy-app-shop/pages/home/wisdomElectricity/switchWarn.vue

391 lines
11 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<style lang="scss" scoped>
.switchWarn{
width: 100%;
background-color: #F9F9F9;
:not(not) {
box-sizing: border-box;
}
&-header{
position: fixed;
top: 0;
left: 0;
z-index: 100;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
border-bottom: 1px solid #eee;
background-color: #fff;
}
&-info-list{
background-color: #F9F9F9;
padding: $paddingTB $paddingLR;
margin-top: 72rpx;
}
.scrollbtm{
margin-bottom: 110rpx;
}
&-info-box{
width: 100%;
border-radius: $uni-border-radius-lg;
background-color: #fff;
box-shadow: $box-shadow;
margin-bottom: 20rpx;
font-size: 24rpx;
&:last-child{
margin-bottom: 0;
}
&-msg{
padding: 20rpx;
/* border-bottom: 2px dotted #A1A1A1; */
border-bottom: 1px dashed #A1A1A1;
position: relative;
}
.box-checkbox{
position: absolute;
right: 14rpx;
top: 14rpx;
z-index: 1;
}
.box-dealwith{
position: absolute;
right: 20rpx;
bottom: 20rpx;
z-index: 1;
padding-left: 50rpx;
padding-top: 50rpx;
}
.box-left-line{
width: 12rpx;
height: 180rpx;
background: #93CDFC;
position: absolute;
left: 40rpx;
top: 20rpx;
z-index: 1;
}
&-msg-row{
display: flex;
align-items: center;
margin-bottom: 20rpx;
&:last-child{
margin-bottom: 0;
}
.msg-row-icon{
border-radius: $uni-border-radius-circle;
/* padding: 10rpx; */
width: 50rpx;
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;
background-color: $main-color;
z-index: 10;
}
.msg-row-text{
color: #000;
}
}
&-bottom{
display: flex;
justify-content: space-between;
padding: 20rpx;
}
}
.bottom-btn-ctn{
position: fixed;
bottom: 0;
left: 0;
z-index: 100;
width: 100%;
display: flex;
justify-content: space-between;
align-items: center;
background-color: #FFFFFF;
padding: 20rpx 30rpx;
box-shadow: $box-shadow;
&-lf{
display: flex;
align-items: center;
}
}
.alarmInfo-content{
padding: 70rpx $paddingLR;
padding-bottom: 40rpx;
&-row{
padding-bottom: 10rpx;
}
&-bottom-btn{
padding: 0 30rpx;
padding-top: 20rpx;
}
}
}
</style>
<template>
<view class="switchWarn">
<view class="switchWarn-header">
<u-input :disabled="true" style="width: 240rpx;" input-align="center" v-model="beginDate" @click="beginDatePickerShow = true" />
<view class="">至</view>
<u-input :disabled="true" style="width: 240rpx;" input-align="center" v-model="endDate" @click="endDatePickerShow = true" />
<u-button type="primary" size="mini" :ripple="true" :disabled="toalLen === 0" @click="headerBtnHandleFn">{{checkboxShowFlag | checkBtnName}}</u-button>
</view>
<view class="switchWarn-info-list" :class="{'scrollbtm': checkboxShowFlag}">
<mescroll-body ref="mescrollRef" top="0" @init="mescrollInit" @down="downCallback" @up="upCallback">
<checkbox-group @change="checkboxChange">
<view class="switchWarn-info-box" v-for="(item,index) in lineRoadList" :key="index">
<view class="switchWarn-info-box-msg">
<!-- <u-checkbox class="box-checkbox" v-if="checkboxShowFlag" v-model="item.checkedFlag"></u-checkbox> -->
<view class="box-checkbox" v-if="checkboxShowFlag && item.processStatus == 'UNPROCESS'">
<checkbox :value="item.recordId" :checked="selCheck.includes(item.recordId)" color="#1C9AFF"/>
</view>
<view class="box-left-line"></view>
<view class="box-dealwith" @click="openDealwithFn(item)">
<tuiIcon :name="item.processStatus== 'UNPROCESS'?'weichuli':'yichuli'" size="80" :color="item.processStatus== 'UNPROCESS'?'#BE2D08':'#71B943'"></tuiIcon>
</view>
<view class="switchWarn-info-box-msg-row">
<view class="msg-row-icon">
<tui-icon color="#fff" name="xiangmu" size="26"></tui-icon>
</view>
<text class="msg-row-text pl20">项目:{{item.projectName}}</text>
</view>
<view class="switchWarn-info-box-msg-row">
<view class="msg-row-icon">
<tui-icon color="#fff" name="ditu2" size="26"></tui-icon>
</view>
<text class="msg-row-text pl20">地点:{{item.projectAddress}}</text>
</view>
<view class="switchWarn-info-box-msg-row">
<view class="msg-row-icon">
<tui-icon color="#fff" name="xinpian" size="26"></tui-icon>
</view>
<text class="msg-row-text pl20">线路:{{item.deviceName}}</text>
</view>
</view>
<view class="switchWarn-info-box-bottom">
<text>时间:{{item.alarmTime}}</text>
<text>报警类型:{{item.typeName}}</text>
</view>
</view>
</checkbox-group>
</mescroll-body>
</view>
<view class="bottom-btn-ctn" v-if="checkboxShowFlag">
<!-- <u-button type="warning" class="bottom-btn" @click="cancelDealWithFn">取消</u-button> -->
<view class="bottom-btn-ctn-lf">
<checkbox color="#1C9AFF" :checked="checkedAll" @click="checkedAllClick"/>
<text>全选</text>
<text style="margin-left: 20rpx;">{{chckLen}}/{{toalLen}}</text>
</view>
<u-button type="primary" size="medium" :ripple="true" class="bottom-btn" @click="handleNowFn">立即处理</u-button>
</view>
<u-popup v-model="alarmShowFlag" mode="center" :closeable="true" width="80%">
<view class="alarmInfo-content">
<view class="alarmInfo-content-row">项目:{{currentPickInfoData.projectName}}</view>
<view class="alarmInfo-content-row">地址:{{currentPickInfoData.projectAddress}}</view>
<view class="alarmInfo-content-row">线路:{{currentPickInfoData.deviceName}}</view>
<view class="alarmInfo-content-row">报警类型:{{currentPickInfoData.typeName}}</view>
<view class="alarmInfo-content-row">报警时间:{{currentPickInfoData.alarmTime}}</view>
<!-- <view class="alarmInfo-content-row">联系人:林工</view>
<view class="alarmInfo-content-row">联系电话15860886888</view> -->
<view class="alarmInfo-content-bottom-btn">
<u-button type="primary" shape="circle" :ripple="true" @click="projectHandleNowFn(currentPickInfoData)">立即处理</u-button>
<!-- <view class="pt20"></view>
<u-button type="primary" shape="circle" @click="fiilMaintenanceFn">填写维保</u-button> -->
</view>
</view>
</u-popup>
<u-picker mode="time" :params="params" v-model="beginDatePickerShow" @confirm="beginDateConfirmFn"></u-picker>
<u-picker mode="time" :params="params" v-model="endDatePickerShow" @confirm="endDateConfirmFn"></u-picker>
</view>
</template>
<script>
import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
export default {
data() {
return {
alarmShowFlag:false,
checkboxShowFlag:false,
params:{
year: true,
month: true,
day: true,
timestamp: true, // 1.3.7版本提供
},
beginDatePickerShow:false,
endDatePickerShow:false,
beginDate:"",
endDate:"",
deviceId:"",
lineRoadList:[],
currentPickInfoData: {},
selCheck: [],
checkedAll: false
}
},
mixins:[MescrollMixin],
onLoad(e) {
this.beginDate = this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd');
this.endDate = this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')
this.deviceId = e.deviceId;
},
methods: {
/*上拉加载的回调*/
upCallback(page) {
let pageNum = page.num; // 页码, 默认从1开始
let pageSize = page.size; // 页长, 默认每页10条
let obj = {
pageSize:pageSize,
pageNum:pageNum,
deviceId:this.deviceId,
beginTime:this.beginDate,
endTime:this.endDate,
typeCodes:"A001,A003,A002,A004,A005,A006,A007,A008,A009,E000,E001,E002,E003,E004,E005",
}
this.$get("/app/alarm/table",obj).then((res)=>{
// console.log(res,"ressssssssssss");
if (res.rows && res.rows.length>0) {
// 接口返回的当前页数据列表 (数组)
let curPageData = res.rows;
// 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
let curPageLen = curPageData.length;
//设置列表数据
if(pageNum == 1) this.lineRoadList = []; //如果是第一页需手动置空列表
this.lineRoadList = this.lineRoadList.concat(curPageData); //追加新数据
this.handleCheck(curPageData);
this.mescroll.endBySize(curPageLen, res.total); // 推荐
// this.mescroll.endByPage(curPageLen, res.data.total)
// this.mescroll.endSuccess(curPageData.length);
} else{
this.lineRoadList = [];
this.mescroll.endErr();
this.mescroll.showEmpty();
// this.mescroll.endUpScroll(true);
}
}).catch(()=>{
//联网失败, 结束加载
this.mescroll.endErr();
})
},
// 跳转维保
fiilMaintenanceFn(){
let queryDataStr = JSON.stringify(this.currentPickInfoData);
uni.navigateTo({
url:`/pages/home/wisdomElectricity/wbjl/addRecord?alrmData=${queryDataStr}`,
success: () => {
this.alarmShowFlag = false;
}
})
},
// 点击未处理
openDealwithFn(item){
// console.log(item,"item");
if(this.checkboxShowFlag) {
this.$tui.toast('当前为批处理,请先取消批处理', 3000);
return false;
}
if(item.processStatus == 'UNPROCESS'){
this.alarmShowFlag = true;
this.currentPickInfoData = item;
}
},
beginDateConfirmFn(e){
console.log(e,"e")
this.beginDate = this.$u.timeFormat(e.timestamp, 'yyyy-mm-dd')
this.mescroll.resetUpScroll();
},
endDateConfirmFn(e){
console.log(e,"e")
this.endDate = this.$u.timeFormat(e.timestamp, 'yyyy-mm-dd')
this.mescroll.resetUpScroll();
},
headerBtnHandleFn(){
if (this.checkboxShowFlag) {
this.checkboxShowFlag = false;
this.selCheck = [];
this.checkAll = false;
} else{
this.checkboxShowFlag = true;
}
},
checkboxChange(e) {
this.selCheck = e.detail.value;
},
checkedAllClick(){
const _this = this;
this.checkedAll = !this.checkedAll;
if(this.checkedAll){
this.selCheck = [];
this.lineRoadList.forEach(item => {
if(item.processStatus == 'UNPROCESS'){
if(!_this.selCheck.includes(item.recordId)){
_this.selCheck.push(item.recordId);
}
}
})
}else{
this.selCheck = [];
}
},
handleCheck(data) {
if(this.checkedAll){
data.forEach(item => {
if(item.processStatus == 'UNPROCESS'){
if(!this.selCheck.includes(item.recordId)){
this.selCheck.push(item.recordId);
}
}
})
}
},
handleNowFn() {
this.$post('/app/alarm/batch-update', {recordIds: this.selCheck}).then(res => {
if(res.code == 200) {
this.$tui.toast('处理成功', 3000, true);
this.updateState(this.selCheck);
this.selCheck = [];
this.checkboxShowFlag = false;
}
})
},
projectHandleNowFn(data) {
this.selCheck = [data.recordId];
this.handleNowFn();
this.alarmShowFlag = false;
},
updateState(selCheck) {
this.lineRoadList.forEach(item => {
if(selCheck.includes(item.recordId)) {
item.processStatus = 'PROCESSED';
}
})
}
},
computed: {
checkAll() {
return this.lineRoadList.every(item => {
return item.processStatus == 'UNPROCESS' && this.selCheck.includes(item.recordId);
});
},
toalLen() {
return this.lineRoadList.length || 0;
},
chckLen() {
return this.selCheck.length || 0;
}
},
filters: {
checkBtnName(flag) {
if(flag) {
return '取消批量处理';
} else {
return '批量处理';
}
}
}
}
</script>