123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794 |
- <template>
- <view>
- <u-navbar :title="title" title-color="#101010">
- <view slot="right" @click="submitApi">
- <img src="@/assets/img/riLine-check-line 1.svg" alt="" />
- </view>
- </u-navbar>
- <view class="time-group">
- <view class="time-item" @click="typeShow=true">
- <view class="time">
- <view class="time-slot">
- 重复
- </view>
- <view class="type weeklistclass" v-if="typeShowIndex==2">
- <template v-for="(item,i) in weekdaysList">
- <template v-if="item==1">
- <span :key="i">
- {{weeklist[i]}}
- </span>
- <span class="weeklistclassSpan" :key="i+'a'" >
- ,
- </span>
- </template>
-
- </template>
-
- </view>
- <view class="type" v-else >
-
- {{typeShowIndex==0?'执行一次':''}}
- {{typeShowIndex==1?'每天':''}}
- </view>
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
- </view>
- <view class="time-item" v-show="switchStatus==2"
- @click="pickerShow4=true">
- <view class="time">
- <view class="time-slot" >
- 定时供电时间段
-
- </view>
- <view class="type">
-
- {{startTime?startTimeStr(startTime)+'-':'未设置'}}
- {{showjp2time(startTime,endTime)?'次日':''}}
- {{endTime?startTimeStr(endTime):''}}
- </view>
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
-
- </view>
- <view class="time-item" v-show="switchStatus==3"
- @click="pickerShow3=true">
-
- <view class="time">
- <view class="time-slot" >
- 智能停电时间段
-
- </view>
- <view class="type">
-
- {{startTime?startTimeStr(startTime)+'-':'未设置'}}
- {{showjp2time(startTime,endTime)?'次日':''}}
- {{endTime?startTimeStr(endTime):''}}
- </view>
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
- </view>
- <view class="time-item" v-show="switchStatus==1"
- @click="pickerShow1=true">
- <view class="time">
-
- <view class="time-slot" >
- 定时送电时间
-
- </view>
-
-
- <view class="type">
- {{startTime?startTimeStr(startTime):'未设置'}}
- </view>
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
- </view>
-
- <view class="time-item" v-show="switchStatus==0"
- @click="pickerShow2=true">
- <view class="time">
-
- <view class="time-slot" v-show="switchStatus==0">
- 定时停电时间
- </view>
-
- <view class="type">
-
-
- {{endTime?startTimeStr(endTime):'未设置'}}
- </view>
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
- </view>
- <view class="time-item" v-show="switchStatus==3"
- @click="thresholdsPopup=true" >
- <view class="time">
- <view class="time-slot">
- 最大功率阈值
- </view>
- <view class="type">
- {{formData.maxPower!=''?formData.maxPower+'kW':'未设置'}}
- </view>
-
-
- </view>
- <view class="more">
- <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
- </view>
- </view>
- <view class="time-item" v-show="switchStatus==3"
- >
- <view class="time">
-
- <view class="type">
- 1.功率达到最大阈值时“自动停电”;<br/>
- 2.关闭自动停电时,如果处于停电状态将“开启供电”;
- </view>
- </view>
-
-
-
- </view>
- </view>
- <!-- 重复类型 -->
- <view class="repeatType" v-if="typeShow">
- <u-popup v-model="typeShow" mode="bottom">
- <view>
- <view class="headline">
- 重复类型
- </view>
- <view class="type-group">
- <view class="item" :class="{
- 'item-title-checked':typeShowIndex==0
- }" @click="typeShowIndex=0,typeShow=false">
- <view class="item-title " >
- 执行一次
- </view>
- <view class="item-icon item-icon1">
- <img src="@/assets/img/riLine-check-line.svg" alt="" />
- </view>
- <view class="item-icon item-icon2">
- <img src="" alt="" />
- </view>
- </view>
- <view class="item" :class="{
- 'item-title-checked':typeShowIndex==1
- }" @click="typeShowIndex=1,typeShow=false">
- <view class="item-title " > 每天
- </view>
- <view class="item-icon item-icon1">
- <img src="@/assets/img/riLine-check-line.svg" alt="" />
- </view>
- <view class="item-icon item-icon2">
- <img src="" alt="" />
- </view>
- </view>
- <view class="item" :class="{
- 'item-title-checked':typeShowIndex==2
- }" @click="customPopup=true,weekdaysListTemp=weekdaysList">
- <view class="item-title" >
- 自定义
-
- </view>
- <view class="item-icon item-icon1">
- <img src="@/assets/img/riLine-check-line.svg" alt="" />
- </view>
- <view class="item-icon item-icon2">
- <img src="" alt="" />
- </view>
-
- </view>
- </view>
- </view>
- </u-popup>
- </view>
- <!-- 关闭时间 -->
- <ujpPicker mode="time" jp="1" :default-time="startTime?'2024-1-1 '+startTime+':1':''"
- v-model="pickerShow1" :params="params" @confirm="pickerShow1confirm" ></ujpPicker>
-
- <ujpPicker mode="time" jp="2" :default-time="endTime?'2024-1-1 '+endTime+':1':''" :defaultStartTime="startTime"
- v-model="pickerShow2" :params="params" @confirm="pickerShow2confirm" ></ujpPicker>
- <!-- 自定义重复 -->
- <ujpPicker2 :texts="['开启"智能停电"','停止"智能停电"']"
- :defaultTime="startTime?'2024-1-1 '+startTime+':1':''"
- :defaultTime2="endTime?'2024-1-1 '+endTime+':1':''"
-
- v-model="pickerShow3" @confirm="pickerShow1confirm2" ></ujpPicker2>
-
- <ujpPicker2 :texts="['供电时间','停电时间']"
- :defaultTime="startTime?'2024-1-1 '+startTime+':1':''"
- :defaultTime2="endTime?'2024-1-1 '+endTime+':1':''"
-
- v-model="pickerShow4" @confirm="pickerShow1confirm2" ></ujpPicker2>
-
-
- <u-popup v-model="customPopup" mode="bottom">
- <view class="custom">
- <view class="headline">
- 自定义重复
- </view>
- <view class="radio-group">
- <checkbox-group @change="checkboxChange" >
- <view class="radio-item" v-for="(item,i) in weekdaysListTemp" :key="i">
- <view class="item-title" >
- {{weeklist[i]}}
- </view>
- <view class="item-value">
- <checkbox
- :value="''+i"
- :checked="item?true:false"
-
-
- ></checkbox>
- </view>
- </view>
- </checkbox-group>
-
- </view>
- <view class="btn-group">
- <view class="btn cancel" @click="customPopup=false">
- 取消
- </view>
- <view class="btn confirm" @click="customPopupApi" >
- 确认
- </view>
- </view>
- </view>
- </u-popup>
- <!-- 最大功率阈值 -->
- <u-popup v-model="thresholdsPopup" mode="bottom">
- <view class="thresholds">
- <view class="headline">
- 最大功率阈值(kW)
- </view>
- <view class="input" style=" padding: 0 24rpx;">
- <u-input type="digit" min="1"
- v-model="maxPower" placeholder="填写触发智能停电的功率数值" />
- </view>
- <view class="btn-group">
- <view class="btn cancel" @click="thresholdsPopup=false" >
- 取消
- </view>
- <view class="btn confirm" @click="thresholdsPopupApi">
- 确认
- </view>
- </view>
-
- </view>
-
-
- </u-popup>
- </view>
- </template>
- <script>
- import ujpPicker from '@/components/u-picker.vue'
- import ujpPicker2 from '@/components/u-picker2.vue'
-
- import * as API from '@/apis/pagejs/meterTimer.js'
- export default {
- components: {
- ujpPicker,ujpPicker2
- },
- data() {
- return {
- typeShow: true,
- pickerShow1: false,
- pickerShow2: false,
- pickerShow3: false,
- pickerShow4: false,
- typeShow: false,
- customPopup: false,
- thresholdsPopup: false,
- listtemp: [3,2,1,0],
- list: [
- {
- text:'智能停电',
- value:3
- },{
- text: '供电时间',
- value:2
-
- }, {
- text: '定时送电',
- value:1
- }, {
- text: '定时停电' ,
- value:0
- }],
- params: {
- year: false,
- month: false,
- day: false,
- hour: true,
- minute: true,
- second: false,
- },
- id:"",
- type:"",
- meterId:"",
- title:"",
- weekdaysListTemp:[0,0,0,0,0,0,0],
- weekdaysList:[0,0,0,0,0,0,0],
- weeklist:[
- '周一','周二','周三','周四','周五','周六','周日'
- ],
- typeShowIndex:0,
- startTime:"",
- endTime:"",
-
- maxPower:"",
- timerSwitch:{},
- switchStatus:"",
- formData:{
- meterId:"",
- weekdays:"",
- startTime:"",
- type:"",
- switchStatus:"",
- status:true,
- id:"",
- endTime:"",
- maxPower:"",
- }
- }
- },
- onLoad(op) {
- if(op.meterId){
- this.meterId=op.meterId;
- this.formData.meterId=this.meterId
- }
- if(op.type){
- this.type=op.type;
- this.title=this.list[this.type].text
- this.switchStatus=this.list[this.type].value
- }
- if(op.id){
- this.id=op.id;
- this.getMeterTimerDetails()
- }
- },
- methods: {
- showjp2time(time1,time2){
-
- if(time1&&time2){
- var num1=parseInt(time1.replace(":",''))
- var num2=parseInt(time2.replace(":",''))
- return num1>num2
- }else{
- return false
- }
-
- },
- getMeterTimerDetails(){
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.meterTimerDetails({
- id:this.id
- }).then((response) => {
- uni.hideLoading();
- var timerSwitch=response.data.timerSwitch;
- this.formData=timerSwitch
- this.meterId=timerSwitch.meterId
- this.type=this.listtemp[timerSwitch.switchStatus]
- this.switchStatus=this.list[this.type].value
- this.title=this.list[this.type].text
- if(timerSwitch.type==1){
- this.typeShowIndex=0;
- }else{
- if(timerSwitch.weekdays=="1,2,3,4,5,6,7"){
- this.typeShowIndex=1;
- }else{
- this.typeShowIndex=2;
- var sz=timerSwitch.weekdays.split(',');
- for(var i in sz){
- var num= parseInt(sz[i])-1
- this.weekdaysListTemp[num]=1
- }
- this.weekdaysList=this.weekdaysListTemp
- }
- }
- this.startTime=timerSwitch.startTime
- this.endTime=timerSwitch.endTime
-
- if(this.switchStatus==0){
- this.endTime=timerSwitch.startTime
- }
- this.maxPower=this.formData.maxPower
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- },
- thresholdsPopupApi(){
- if(this.maxPower!=''){
- if(this.maxPower<=0){
- uni.showToast({
- title: "请输入大于0的功率阈值(kw)",
- icon: "none"
- })
- }else{
- this.thresholdsPopup=false
- this.formData.maxPower=this.maxPower
- }
-
- }else{
- uni.showToast({
- title: "请填写最大功率阈值(kw)",
- icon: "none"
- })
- }
- },
- pickerShow1confirm2(e){
- console.log(e)
- this.startTime=e.hour+":"+e.minute+""
-
- this.endTime=e.hour2+":"+e.minute2+""
-
- },
- pickerShow1confirm(e){
-
-
- this.startTime=e.hour+":"+e.minute+""
- //this.startTimeStr=e.hour+"时"+e.minute+"分"
- },
- startTimeStr(str){
- if(str){
- return str.replace(":","时")+"分"
- }else{
- return ''
- }
-
- },
- pickerShow2confirm(e){
-
- this.endTime=e.hour+":"+e.minute+""
- //this.endTimeStr=e.hour+"时"+e.minute+"分"
- },
- customPopupApi(){
- var str1=[0,0,0,0,0,0,0].join()
- var str2=this.weekdaysListTemp.join()
-
- if(str1!=str2){
- this.typeShowIndex=2;
- this.customPopup=false
- this.typeShow=false;
- this.weekdaysList=this.weekdaysListTemp;
- }else{
- uni.showToast({
- title: "请至少勾选一项",
- icon: "none"
- })
- }
-
-
- },
- checkboxChange(e){
- var sz=e.detail.value;
- this.weekdaysListTemp=[0,0,0,0,0,0,0]
- for(var i in sz){
- var k=sz[i]
- this.weekdaysListTemp[k]=1
- }
- console.log(this.weekdaysListTemp)
- },
- submitApi(){
- this.formData.weekdays=""
- this.formData.switchStatus=this.list[this.type].value
- if(!this.startTime){
-
- if(this.formData.switchStatus==1){
- uni.showToast({
- title: "请设置定时送电时间",
- icon: "none"
- })
- return
- }
- if(this.formData.switchStatus==2){
- uni.showToast({
- title: "请设置定时供电时间段",
- icon: "none"
- })
- return
- }
- if(this.formData.switchStatus==3){
-
-
- uni.showToast({
- title: "请设置智能停电时间段",
- icon: "none"
- })
- return
- }
-
- }
- if(!this.endTime){
-
-
- if(this.formData.switchStatus==0){
- uni.showToast({
- title: "请设置定时停电时间",
- icon: "none"
- })
- return
- }
-
- }
-
-
-
-
-
- if(this.formData.switchStatus==0){
- this.formData.startTime=this.endTime
- }else{
- this.formData.startTime=this.startTime
- this.formData.endTime=this.endTime
- }
- if(!this.formData.endTime){
- this.formData.endTime=""
- }
- if(this.typeShowIndex==0){
- this.formData.type="1"
- }else{
- this.formData.type="2"
- var weekdaysList=this.weekdaysList
- if(this.typeShowIndex==1){
- this.formData.weekdays='1,2,3,4,5,6,7'
- }
- if(this.typeShowIndex==2){
- for(var i in weekdaysList){
- var day=weekdaysList[i]
- if(day==1){
- if(this.formData.weekdays!=""){
- this.formData.weekdays+=","
- }
- this.formData.weekdays+=(parseInt(i)+1)
- }
- }
- }
-
- }
- if(this.formData.switchStatus==3&&this.maxPower==''){
- uni.showToast({
- title: "请填写最大功率阈值(kw)",
- icon: "none"
- })
- return
- }else{
- this.formData.maxPower=this.maxPower;
- if(!this.formData.maxPower){
- this.formData.maxPower=''
- }
- }
-
-
- uni.showLoading({
- title: "加载中",
- mask: true,
- })
- API.saveSwitch(this.formData).then((response) => {
- //uni.hideLoading();
- //this.getMeterTimerListReady=true
- //this.timerSwitchList=response.data.timerSwitchList;
- uni.navigateBack();
-
- }).catch(error => {
- uni.showToast({
- title: error,
- icon: "none"
- })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/.u-slot-right {
- margin-right: 32rpx;
- img {
- width: 48rpx;
- height: 48rpx;
- }
- }
- .time-group {
- background-color: #fff;
- .time-item {
- padding: 24rpx 0;
- margin: 0 32rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- border-bottom: 1px solid rgba(221, 221, 221, 1);
- .time {
- .time-slot {
- color: rgba(16, 16, 16, 1);
- font-size: 32rpx;
- }
- .type {
- color: rgba(119, 119, 119, 1);
- }
- }
- }
- .time-item:last-of-type {
- border: none;
- }
- }
- .weeklistclassSpan:last-child{
- display: none;
- }
- // 重复类型
- .repeatType {
- .headline {
- color: rgba(16, 16, 16, 1);
- font-size: 36rpx;
- margin-top: 32rpx;
- font-weight: bold;
- text-align: center;
- }
- .type-group {
- margin-top: 24rpx;
- .item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 96rpx;
- line-height: 96rpx;
- border-bottom: 1px solid rgba(245,245,245,1);
- padding: 0 32rpx;
- }
- .time-item:last-of-type{
- border: none;
- }
- .item-title {
- color: rgb(16, 16, 16);
- font-size: 32rpx;
- }
- .item-icon1{
-
- display: none;
- }
- .item-icon2{
- display: block;
- }
- .item-title-checked {
- color: rgba(22, 119, 255, 1);
- .item-title {
- color: rgba(22, 119, 255, 1);
- font-size: 32rpx;
- }
- .item-icon1{
- display: block;
- }
- .item-icon2{
- display: none;
- }
- }
- }
- }
- // 自定义重复
- .custom,
- .thresholds {
- padding: 32rpx 0;
-
-
- .headline {
- color: rgba(16, 16, 16, 1);
- font-size: 36rpx;
- margin-bottom: 32rpx;
- font-weight: bold;
- text-align: center;
- }
- .radio-group {
- .radio-item {
- padding: 0 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- height: 96rpx;
- line-height: 96rpx;
- border-bottom: 1px solid rgba(245,245,245,1);
- .item-title {
- color: rgba(16, 16, 16, 1);
- font-size: 32rpx;
- }
- }
- }
- .btn-group {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 32rpx;
- .btn {
- width: 328rpx;
- height: 80rpx;
- line-height: 80rpx;
- font-size: 32rpx;
- border-radius: 4px;
- text-align: center;
- margin-top: 24rpx;
- }
- .cancel {
- background-color: rgba(222, 225, 228, 1);
- color: rgba(51, 51, 51, 1);
- }
- .confirm {
- background-color: rgba(22, 119, 255, 1);
- color: rgba(255, 255, 255, 1);
- }
- }
- }
- /deep/.u-drawer-content-visible {
- border-radius: 12px 12px 0 0;
- }
- /deep/uni-input{
- background-color: rgba(241,242,245,1);
- color: rgba(119,119,119,1);
- font-size: 36rpx;
- height: 80rpx;
- padding-left: 16rpx;
- }
- </style>
|