autoOff.vue 24 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085
  1. <template>
  2. <view>
  3. <u-navbar :title="title" title-color="#101010">
  4. <view slot="right" @click="submitApi">
  5. <img src="@/assets/img/riLine-check-line 1.svg" alt="" />
  6. </view>
  7. </u-navbar>
  8. <view class="time-group">
  9. <view class="time-item" @click="typeShow=true">
  10. <view class="time">
  11. <view class="time-slot">
  12. 重复
  13. </view>
  14. <view class="type weeklistclass" v-if="typeShowIndex==2">
  15. <template v-for="(item,i) in weekdaysList">
  16. <template v-if="item==1">
  17. <span :key="i">
  18. {{weeklist[i]}}
  19. </span>
  20. <span class="weeklistclassSpan" :key="i+'a'" >
  21. ,
  22. </span>
  23. </template>
  24. </template>
  25. </view>
  26. <view class="type" v-else >
  27. {{typeShowIndex==0?'执行一次':''}}
  28. {{typeShowIndex==1?'每天':''}}
  29. </view>
  30. </view>
  31. <view class="more">
  32. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  33. </view>
  34. </view>
  35. <view class="time-item" v-show="switchStatus==2"
  36. @click="pickerShow4=true">
  37. <view class="time">
  38. <view class="time-slot" >
  39. 供电时间段
  40. </view>
  41. <view class="type">
  42. {{startTime?startTimeStr(startTime)+'-':'未设置'}}
  43. {{showjp2time(startTime,endTime)?'次日':''}}
  44. {{endTime?startTimeStr(endTime):''}}
  45. </view>
  46. </view>
  47. <view class="more">
  48. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  49. </view>
  50. </view>
  51. <view class="time-item" v-show="switchStatus==3"
  52. @click="pickerShow3=true">
  53. <view class="time">
  54. <view class="time-slot" >
  55. 智能停电时间区间
  56. </view>
  57. <view class="type">
  58. {{startTime?startTimeStr(startTime)+'-':'未设置'}}
  59. {{showjp2time(startTime,endTime)?'次日':''}}
  60. {{endTime?startTimeStr(endTime):''}}
  61. </view>
  62. </view>
  63. <view class="more">
  64. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  65. </view>
  66. </view>
  67. <view class="time-item" v-show="switchStatus==1"
  68. @click="pickerShow1=true">
  69. <view class="time">
  70. <view class="time-slot" >
  71. 供电时间
  72. </view>
  73. <view class="type">
  74. {{startTime?startTimeStr(startTime):'未设置'}}
  75. </view>
  76. </view>
  77. <view class="more">
  78. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  79. </view>
  80. </view>
  81. <view class="time-item" v-show="switchStatus==0"
  82. @click="pickerShow2=true">
  83. <view class="time">
  84. <view class="time-slot" v-show="switchStatus==0">
  85. 停电时间
  86. </view>
  87. <view class="type">
  88. {{endTime?startTimeStr(endTime):'未设置'}}
  89. </view>
  90. </view>
  91. <view class="more">
  92. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  93. </view>
  94. </view>
  95. <view class="time-item" v-show="switchStatus==3"
  96. @click="thresholdsPopup=true" >
  97. <view class="time">
  98. <view class="time-slot">
  99. 智能停电条件
  100. </view>
  101. <view class="type" v-if="maxPower">
  102. 功率阈值:{{maxPower}}kW,持续时间{{closeMinute}}分钟后“自动停电”
  103. </view>
  104. <view class="type" v-else>
  105. 未设置
  106. </view>
  107. </view>
  108. <view class="more">
  109. <u-icon name="arrow-right" color="#b2b2b2"></u-icon>
  110. </view>
  111. </view>
  112. <view class="time-item" v-show="switchStatus==3"
  113. >
  114. <view class="time">
  115. <view class="type">
  116. 1. 智能停电条件:智能停电是功率大于等于阈值持续达到设定时间后;<br/>
  117. 2. 达到智能停电条件后“自动停电”,1分钟后恢复电源供电;<br/>
  118. 3.“智能停电”结束时,如果处于停电状态将打开电源供电;
  119. </view>
  120. </view>
  121. </view>
  122. <view class="time-item" v-show="switchStatus==2">
  123. <view class="time">
  124. <view class="type">
  125. 在时间段开始时间开启电源供电,时间段结束时间停止供电。
  126. </view>
  127. </view>
  128. </view>
  129. <view class="time-item2" v-show="startTime||endTime" >
  130. <view class="time">
  131. <view class="time-slot" >
  132. 供电管理图示
  133. </view>
  134. </view>
  135. <view class="progressText" >
  136. <view class="progress1" v-if="progress1style.width!='0%'" :style="progress1style" >{{progress1style.text}}</view>
  137. <view class="progress2">&nbsp;</view>
  138. <view class="progress3" v-if="progress3style.width!='0%'"
  139. :style="progress3style">{{progress3style.text}}</view>
  140. </view>
  141. <view class="progress" :style="{
  142. backgroundColor:progressColor
  143. }" >
  144. <view class="progress1" :style="progress1style" ></view>
  145. <view class="progress2">&nbsp;</view>
  146. <view class="progress3" :style="progress3style"></view>
  147. </view>
  148. <view class="type" style=" color: #777777; margin-top: 16rpx;" >
  149. <view></view>
  150. </view>
  151. <view class="type" style=" color: #777777;" v-if="switchStatus!=3">
  152. <view v-if="switchStatus==1||switchStatus==2">设置生效后将在{{gethtml(startTime)}}供电</view>
  153. <view v-if="switchStatus==0||switchStatus==2">设置生效后将在{{gethtml(endTime)}}停电</view>
  154. </view>
  155. <view class="type" style=" color: #777777;" v-else >
  156. <view>设置生效后将在{{gethtml(startTime)}}开启“智能停电”</view>
  157. <view>设置生效后将在{{gethtml(endTime)}}关闭“智能停电”</view>
  158. </view>
  159. </view>
  160. </view>
  161. <!-- 重复类型 -->
  162. <view class="repeatType" v-if="typeShow">
  163. <u-popup v-model="typeShow" mode="bottom">
  164. <view>
  165. <view class="headline">
  166. 重复类型
  167. </view>
  168. <view class="type-group">
  169. <view class="item" :class="{
  170. 'item-title-checked':typeShowIndex==0
  171. }" @click="typeShowIndex=0,typeShow=false">
  172. <view class="item-title " >
  173. 执行一次
  174. </view>
  175. <view class="item-icon item-icon1">
  176. <img src="@/assets/img/riLine-check-line.svg" alt="" />
  177. </view>
  178. <view class="item-icon item-icon2">
  179. <img src="" alt="" />
  180. </view>
  181. </view>
  182. <view class="item" :class="{
  183. 'item-title-checked':typeShowIndex==1
  184. }" @click="typeShowIndex=1,typeShow=false">
  185. <view class="item-title " > 每天
  186. </view>
  187. <view class="item-icon item-icon1">
  188. <img src="@/assets/img/riLine-check-line.svg" alt="" />
  189. </view>
  190. <view class="item-icon item-icon2">
  191. <img src="" alt="" />
  192. </view>
  193. </view>
  194. <view class="item" :class="{
  195. 'item-title-checked':typeShowIndex==2
  196. }" @click="customPopup=true,weekdaysListTemp=weekdaysList">
  197. <view class="item-title" >
  198. 自定义
  199. </view>
  200. <view class="item-icon item-icon1">
  201. <img src="@/assets/img/riLine-check-line.svg" alt="" />
  202. </view>
  203. <view class="item-icon item-icon2">
  204. <img src="" alt="" />
  205. </view>
  206. </view>
  207. </view>
  208. </view>
  209. </u-popup>
  210. </view>
  211. <!-- 关闭时间 -->
  212. <ujpPicker mode="time" jp="1" :default-time="startTime?'2024-1-1 '+startTime+':1':''"
  213. v-model="pickerShow1" :params="params" @confirm="pickerShow1confirm" ></ujpPicker>
  214. <ujpPicker mode="time" jp="2" :default-time="endTime?'2024-1-1 '+endTime+':1':''" :defaultStartTime="startTime"
  215. v-model="pickerShow2" :params="params" @confirm="pickerShow2confirm" ></ujpPicker>
  216. <!-- 自定义重复 -->
  217. <ujpPicker2 :texts="['开启“智能停电”','停止“智能停电”']"
  218. :defaultTime="startTime?'2024-1-1 '+startTime+':1':''"
  219. :defaultTime2="endTime?'2024-1-1 '+endTime+':1':''"
  220. v-model="pickerShow3" @confirm="pickerShow1confirm2" ></ujpPicker2>
  221. <ujpPicker2 :texts="['供电时间','停电时间']"
  222. :defaultTime="startTime?'2024-1-1 '+startTime+':1':''"
  223. :defaultTime2="endTime?'2024-1-1 '+endTime+':1':''"
  224. v-model="pickerShow4" @confirm="pickerShow1confirm2" ></ujpPicker2>
  225. <u-popup v-model="customPopup" mode="bottom">
  226. <view class="custom">
  227. <view class="headline">
  228. 自定义重复
  229. </view>
  230. <view class="radio-group">
  231. <checkbox-group @change="checkboxChange" >
  232. <view class="radio-item" v-for="(item,i) in weekdaysListTemp" :key="i">
  233. <view class="item-title" >
  234. {{weeklist[i]}}
  235. </view>
  236. <view class="item-value">
  237. <checkbox
  238. :value="''+i"
  239. :checked="item?true:false"
  240. ></checkbox>
  241. </view>
  242. </view>
  243. </checkbox-group>
  244. </view>
  245. <view class="btn-group">
  246. <view class="btn cancel" @click="customPopup=false">
  247. 取消
  248. </view>
  249. <view class="btn confirm" @click="customPopupApi" >
  250. 确认
  251. </view>
  252. </view>
  253. </view>
  254. </u-popup>
  255. <u-popup v-model="thresholdsPopup" mode="bottom">
  256. <view class="thresholds">
  257. <view class="headline">
  258. 智能停电条件:功率(kW)
  259. </view>
  260. <view class="input" style=" padding: 0 24rpx;">
  261. <u-input type="digit" min="1" placeholderStyle="#777777"
  262. v-model="maxPower" placeholder="填写智能停电条件:功率数值" />
  263. </view>
  264. <view class="input" style=" padding: 24rpx 24rpx;">
  265. <u-input type="digit" min="1" placeholderStyle="#777777"
  266. v-model="closeMinute" placeholder="设置触发条件后多长时间自动断电(分钟)" />
  267. </view>
  268. <view class="btn-group">
  269. <view class="btn cancel" @click="thresholdsPopup=false" >
  270. 取消
  271. </view>
  272. <view class="btn confirm" @click="thresholdsPopupApi">
  273. 确认
  274. </view>
  275. </view>
  276. </view>
  277. </u-popup>
  278. </view>
  279. </template>
  280. <script>
  281. import ujpPicker from '@/components/u-picker.vue'
  282. import ujpPicker2 from '@/components/u-picker2.vue'
  283. import * as API from '@/apis/pagejs/meterTimer.js'
  284. import {
  285. hourDistanceArr,
  286. parseUnixTime,
  287. newDate
  288. } from '@/apis/utils/index.js'
  289. export default {
  290. components: {
  291. ujpPicker,ujpPicker2
  292. },
  293. data() {
  294. return {
  295. typeShow: true,
  296. pickerShow1: false,
  297. pickerShow2: false,
  298. pickerShow3: false,
  299. pickerShow4: false,
  300. typeShow: false,
  301. customPopup: false,
  302. thresholdsPopup: false,
  303. listtemp: [3,2,1,0],
  304. list: [
  305. {
  306. text:'智能停电',
  307. value:3
  308. },{
  309. text: '供电时间',
  310. value:2
  311. }, {
  312. text: '定时供电',
  313. value:1
  314. }, {
  315. text: '定时停电' ,
  316. value:0
  317. }],
  318. params: {
  319. year: false,
  320. month: false,
  321. day: false,
  322. hour: true,
  323. minute: true,
  324. second: false,
  325. },
  326. id:"",
  327. type:"",
  328. meterId:"",
  329. title:"",
  330. weekdaysListTemp:[0,0,0,0,0,0,0],
  331. weekdaysList:[0,0,0,0,0,0,0],
  332. weeklist:[
  333. '周一','周二','周三','周四','周五','周六','周日'
  334. ],
  335. typeShowIndex:0,
  336. startTime:"",
  337. endTime:"",
  338. maxPower:"",
  339. timerSwitch:{},
  340. switchStatus:"",
  341. formData:{
  342. meterId:"",
  343. weekdays:"",
  344. startTime:"",
  345. type:"",
  346. switchStatus:"",
  347. status:true,
  348. id:"",
  349. endTime:"",
  350. maxPower:"",
  351. closeMinute:"",
  352. },
  353. progressColor:"#53b56b",
  354. closeMinute:"",
  355. }
  356. },
  357. onLoad(op) {
  358. if(op.meterId){
  359. this.meterId=op.meterId;
  360. this.formData.meterId=this.meterId
  361. }
  362. if(op.type){
  363. this.type=op.type;
  364. this.title=this.list[this.type].text
  365. this.switchStatus=this.list[this.type].value
  366. }
  367. if(op.id){
  368. this.id=op.id;
  369. this.getMeterTimerDetails()
  370. }
  371. },
  372. computed:{
  373. progress1style(){
  374. var width=0;
  375. var color="red"
  376. this.progressColor="#53b56b"
  377. var text=""
  378. var textColor=""
  379. if(this.switchStatus==1||this.switchStatus==2||this.switchStatus==3){
  380. var startTime=this.startTime
  381. var endTime=this.endTime
  382. if(!startTime){
  383. startTime="9999"
  384. }
  385. if(!endTime){
  386. endTime="9999"
  387. }
  388. console.log(startTime,endTime)
  389. var num1=parseInt(startTime.replace(":",''))
  390. var num2=parseInt(endTime.replace(":",''))
  391. var num=parseInt(num1>num2?num2:num1)
  392. if(num1>num2){
  393. if(this.switchStatus!=1){
  394. color=" #53b56b"
  395. this.progressColor="red"
  396. }
  397. textColor=" red"
  398. if(this.switchStatus==3){
  399. text=`智能停电${endTime}`
  400. }else{
  401. text=`停电 (${endTime})`
  402. }
  403. }else{
  404. textColor="#53b56b"
  405. if(this.switchStatus==3){
  406. text=`智能停电${startTime}`
  407. }else{
  408. text+=`供电 (${startTime})`
  409. }
  410. }
  411. width=parseInt(num/2400*100)
  412. console.log(width)
  413. }else{
  414. }
  415. return {
  416. color:textColor,
  417. text:text,
  418. width: width+"%",
  419. backgroundColor:color
  420. }
  421. },
  422. progress3style(){
  423. var width=0;
  424. var color="red"
  425. var text=""
  426. var textColor=""
  427. if(this.switchStatus==0||this.switchStatus==2||this.switchStatus==3){
  428. var startTime=this.startTime
  429. var endTime=this.endTime
  430. if(!startTime){
  431. startTime="-1"
  432. }
  433. if(!endTime){
  434. endTime="-1"
  435. }
  436. var num1=parseInt(startTime.replace(":",''))
  437. var num2=parseInt(endTime.replace(":",''))
  438. if(num1<num2||this.switchStatus==0){
  439. textColor=" red"
  440. if(this.switchStatus==3){
  441. text=`智能停电${endTime}`
  442. }else{
  443. text=`停电(${endTime})`
  444. }
  445. }else{
  446. if(this.switchStatus!=0){
  447. color=" #53b56b"
  448. }
  449. textColor=" #53b56b"
  450. //this.progressColor="red"
  451. if(this.switchStatus==3){
  452. text=`智能停电${startTime}`
  453. }else{
  454. text+=`供电(${startTime})`
  455. }
  456. }
  457. var num=parseInt(num1<num2?num2:num1)
  458. width=parseInt((2400-num)/2400*100)
  459. }else{
  460. }
  461. return {
  462. color:textColor,
  463. text:text,
  464. width: width+"%",
  465. backgroundColor:color
  466. }
  467. }
  468. },
  469. methods: {
  470. gethtml(item) {
  471. var str = parseUnixTime(new Date().getTime(), '{y}-{m}-{d}');
  472. var time1 = new Date();
  473. var time2 = newDate(str + ' ' + item + ':00');
  474. var sz = []
  475. if (time1 > time2) {
  476. time2.setDate(time2.getDate() + 1)
  477. sz = hourDistanceArr(time1, time2)
  478. } else {
  479. sz = hourDistanceArr(time1, time2)
  480. }
  481. console.log(sz[0])
  482. return (sz[0] ? sz[0] + '小时' : '') + (sz[1] ? sz[1] + '分钟后' : '0分钟后')
  483. },
  484. showjp2time(time1,time2){
  485. if(time1&&time2){
  486. var num1=parseInt(time1.replace(":",''))
  487. var num2=parseInt(time2.replace(":",''))
  488. return num1>num2
  489. }else{
  490. return false
  491. }
  492. },
  493. getMeterTimerDetails(){
  494. uni.showLoading({
  495. title: "加载中",
  496. mask: true,
  497. })
  498. API.meterTimerDetails({
  499. id:this.id
  500. }).then((response) => {
  501. uni.hideLoading();
  502. var timerSwitch=response.data.timerSwitch;
  503. this.formData=timerSwitch
  504. this.meterId=timerSwitch.meterId
  505. this.type=this.listtemp[timerSwitch.switchStatus]
  506. this.switchStatus=this.list[this.type].value
  507. this.title=this.list[this.type].text
  508. if(timerSwitch.type==1){
  509. this.typeShowIndex=0;
  510. }else{
  511. if(timerSwitch.weekdays=="1,2,3,4,5,6,7"){
  512. this.typeShowIndex=1;
  513. }else{
  514. this.typeShowIndex=2;
  515. var sz=timerSwitch.weekdays.split(',');
  516. for(var i in sz){
  517. var num= parseInt(sz[i])-1
  518. this.weekdaysListTemp[num]=1
  519. }
  520. this.weekdaysList=this.weekdaysListTemp
  521. }
  522. }
  523. this.startTime=timerSwitch.startTime
  524. this.endTime=timerSwitch.endTime
  525. if(this.switchStatus==0){
  526. this.endTime=timerSwitch.startTime
  527. }
  528. this.maxPower=this.formData.maxPower
  529. this.closeMinute=this.formData.closeMinute
  530. }).catch(error => {
  531. uni.showToast({
  532. title: error,
  533. icon: "none"
  534. })
  535. })
  536. },
  537. thresholdsPopupApi(){
  538. if(this.maxPower!=''&&this.closeMinute!=''){
  539. this.maxPower=parseInt(this.maxPower)
  540. this.closeMinute=parseInt(this.closeMinute)
  541. if(this.maxPower<=0){
  542. uni.showToast({
  543. title: "请输入大于0的功率阈值(kW)",
  544. icon: "none"
  545. })
  546. }else if(this.closeMinute<=0){
  547. uni.showToast({
  548. title: "请输入大于0的自动断电时间(分钟)",
  549. icon: "none"
  550. })
  551. }else{
  552. this.thresholdsPopup=false
  553. this.formData.maxPower=this.maxPower
  554. }
  555. }else{
  556. if(this.maxPower==''){
  557. uni.showToast({
  558. title: "请填写智能停电条件:功率(kW)",
  559. icon: "none"
  560. })
  561. }
  562. if(this.closeMinute==''){
  563. uni.showToast({
  564. title: "设置触发条件后多长时间自动断电(分钟)",
  565. icon: "none"
  566. })
  567. }
  568. }
  569. },
  570. pickerShow1confirm2(e){
  571. if(e.hour+":"+e.minute+""==e.hour2+":"+e.minute2+""){
  572. this.pickerShow3=true
  573. uni.showToast({
  574. title: "请勿设置相同时间",
  575. icon: "none"
  576. })
  577. }else{
  578. this.startTime=e.hour+":"+e.minute+""
  579. this.endTime=e.hour2+":"+e.minute2+""
  580. }
  581. },
  582. pickerShow1confirm(e){
  583. this.startTime=e.hour+":"+e.minute+""
  584. //this.startTimeStr=e.hour+"时"+e.minute+"分"
  585. },
  586. startTimeStr(str){
  587. if(str){
  588. return str.replace(":","时")+"分"
  589. }else{
  590. return ''
  591. }
  592. },
  593. pickerShow2confirm(e){
  594. this.endTime=e.hour+":"+e.minute+""
  595. //this.endTimeStr=e.hour+"时"+e.minute+"分"
  596. },
  597. customPopupApi(){
  598. var str1=[0,0,0,0,0,0,0].join()
  599. var str2=this.weekdaysListTemp.join()
  600. if(str1!=str2){
  601. this.typeShowIndex=2;
  602. this.customPopup=false
  603. this.typeShow=false;
  604. this.weekdaysList=this.weekdaysListTemp;
  605. }else{
  606. uni.showToast({
  607. title: "请至少勾选一项",
  608. icon: "none"
  609. })
  610. }
  611. },
  612. checkboxChange(e){
  613. var sz=e.detail.value;
  614. this.weekdaysListTemp=[0,0,0,0,0,0,0]
  615. for(var i in sz){
  616. var k=sz[i]
  617. this.weekdaysListTemp[k]=1
  618. }
  619. console.log(this.weekdaysListTemp)
  620. },
  621. submitApi(){
  622. this.formData.weekdays=""
  623. this.formData.switchStatus=this.list[this.type].value
  624. if(!this.startTime){
  625. if(this.formData.switchStatus==1){
  626. uni.showToast({
  627. title: "请设置供电时间",
  628. icon: "none"
  629. })
  630. return
  631. }
  632. if(this.formData.switchStatus==2){
  633. uni.showToast({
  634. title: "请设置供电时间段",
  635. icon: "none"
  636. })
  637. return
  638. }
  639. if(this.formData.switchStatus==3){
  640. uni.showToast({
  641. title: "请设置智能停电时间区间",
  642. icon: "none"
  643. })
  644. return
  645. }
  646. }
  647. if(!this.endTime){
  648. if(this.formData.switchStatus==0){
  649. uni.showToast({
  650. title: "请设置停电时间",
  651. icon: "none"
  652. })
  653. return
  654. }
  655. }
  656. if(this.formData.switchStatus==0){
  657. this.formData.startTime=this.endTime
  658. }else{
  659. this.formData.startTime=this.startTime
  660. this.formData.endTime=this.endTime
  661. }
  662. if(!this.formData.endTime){
  663. this.formData.endTime=""
  664. }
  665. if(this.typeShowIndex==0){
  666. this.formData.type="1"
  667. }else{
  668. this.formData.type="2"
  669. var weekdaysList=this.weekdaysList
  670. if(this.typeShowIndex==1){
  671. this.formData.weekdays='1,2,3,4,5,6,7'
  672. }
  673. if(this.typeShowIndex==2){
  674. for(var i in weekdaysList){
  675. var day=weekdaysList[i]
  676. if(day==1){
  677. if(this.formData.weekdays!=""){
  678. this.formData.weekdays+=","
  679. }
  680. this.formData.weekdays+=(parseInt(i)+1)
  681. }
  682. }
  683. }
  684. }
  685. if(this.formData.switchStatus==3&&this.maxPower==''){
  686. uni.showToast({
  687. title: "请填写智能停电条件:功率(kW)",
  688. icon: "none"
  689. })
  690. return
  691. }else if(this.formData.switchStatus==3&&this.closeMinute==''){
  692. uni.showToast({
  693. title: "设置触发条件后多长时间自动断电(分钟)",
  694. icon: "none"
  695. })
  696. return
  697. }else{
  698. this.formData.maxPower=this.maxPower;
  699. this.formData.closeMinute=this.closeMinute;
  700. this.formData.openMinute=1;
  701. if(!this.formData.maxPower){
  702. this.formData.maxPower=''
  703. this.formData.closeMinute='';
  704. this.formData.openMinute='';
  705. }
  706. }
  707. uni.showLoading({
  708. title: "加载中",
  709. mask: true,
  710. })
  711. API.saveSwitch(this.formData).then((response) => {
  712. //uni.hideLoading();
  713. //this.getMeterTimerListReady=true
  714. //this.timerSwitchList=response.data.timerSwitchList;
  715. uni.navigateBack();
  716. }).catch(error => {
  717. uni.showToast({
  718. title: error,
  719. icon: "none"
  720. })
  721. })
  722. }
  723. }
  724. }
  725. </script>
  726. <style lang="scss" scoped>
  727. .progressText{
  728. margin-top: 16rpx;
  729. margin-bottom: 2rpx;
  730. display: flex;
  731. justify-content: space-between;
  732. .progress1,.progress3{
  733. white-space: pre;
  734. background-color: #fff !important;
  735. }
  736. .progress1{
  737. text-align: right;
  738. }
  739. .progress3{
  740. text-align: left;
  741. min-width: 25%;
  742. }
  743. }
  744. .progress{
  745. background-color: #53b56b;
  746. color: #53b56b;
  747. height: 60rpx;
  748. border-radius: 30px;
  749. display: flex;
  750. justify-content: space-between;
  751. .progress1{
  752. border-radius: 30px 0 0 30px;
  753. }
  754. .progress3{
  755. border-radius:0 30px 30px 0;
  756. }
  757. }
  758. /deep/.u-slot-right {
  759. padding-right: 32rpx;
  760. img {
  761. width: 48rpx;
  762. height: 48rpx;
  763. }
  764. }
  765. .time-group {
  766. background-color: #fff;
  767. .time-item2 {
  768. padding: 24rpx 0;
  769. margin: 0 32rpx;
  770. .time {
  771. .time-slot {
  772. color: rgba(16, 16, 16, 1);
  773. font-size: 32rpx;
  774. }
  775. .type {
  776. color: rgba(119, 119, 119, 1);
  777. }
  778. }
  779. }
  780. .time-item {
  781. padding: 24rpx 0;
  782. margin: 0 32rpx;
  783. display: flex;
  784. justify-content: space-between;
  785. align-items: center;
  786. border-bottom: 1px solid rgba(221, 221, 221, 1);
  787. .time {
  788. .time-slot {
  789. color: rgba(16, 16, 16, 1);
  790. font-size: 32rpx;
  791. }
  792. .type {
  793. color: rgba(119, 119, 119, 1);
  794. }
  795. }
  796. }
  797. .time-item:last-of-type {
  798. border: none;
  799. }
  800. }
  801. .weeklistclassSpan:last-child{
  802. display: none;
  803. }
  804. // 重复类型
  805. .repeatType {
  806. .headline {
  807. color: rgba(16, 16, 16, 1);
  808. font-size: 36rpx;
  809. margin-top: 32rpx;
  810. font-weight: bold;
  811. text-align: center;
  812. }
  813. .type-group {
  814. margin-top: 24rpx;
  815. .item {
  816. display: flex;
  817. align-items: center;
  818. justify-content: space-between;
  819. height: 96rpx;
  820. line-height: 96rpx;
  821. border-bottom: 1px solid rgba(245,245,245,1);
  822. padding: 0 32rpx;
  823. }
  824. .time-item:last-of-type{
  825. border: none;
  826. }
  827. .item-title {
  828. color: rgb(16, 16, 16);
  829. font-size: 32rpx;
  830. }
  831. .item-icon1{
  832. display: none;
  833. }
  834. .item-icon2{
  835. display: block;
  836. }
  837. .item-title-checked {
  838. color: rgba(22, 119, 255, 1);
  839. .item-title {
  840. color: rgba(22, 119, 255, 1);
  841. font-size: 32rpx;
  842. }
  843. .item-icon1{
  844. display: block;
  845. }
  846. .item-icon2{
  847. display: none;
  848. }
  849. }
  850. }
  851. }
  852. // 自定义重复
  853. .custom,
  854. .thresholds {
  855. padding: 32rpx 0;
  856. .headline {
  857. color: rgba(16, 16, 16, 1);
  858. font-size: 36rpx;
  859. margin-bottom: 32rpx;
  860. font-weight: bold;
  861. text-align: center;
  862. }
  863. .radio-group {
  864. .radio-item {
  865. padding: 0 32rpx;
  866. display: flex;
  867. align-items: center;
  868. justify-content: space-between;
  869. height: 96rpx;
  870. line-height: 96rpx;
  871. border-bottom: 1px solid rgba(245,245,245,1);
  872. .item-title {
  873. color: rgba(16, 16, 16, 1);
  874. font-size: 32rpx;
  875. }
  876. }
  877. }
  878. .btn-group {
  879. display: flex;
  880. align-items: center;
  881. justify-content: space-between;
  882. padding: 0 32rpx;
  883. .btn {
  884. width: 328rpx;
  885. height: 80rpx;
  886. line-height: 80rpx;
  887. font-size: 32rpx;
  888. border-radius: 4px;
  889. text-align: center;
  890. margin-top: 24rpx;
  891. }
  892. .cancel {
  893. background-color: rgba(222, 225, 228, 1);
  894. color: rgba(51, 51, 51, 1);
  895. }
  896. .confirm {
  897. background-color: rgba(22, 119, 255, 1);
  898. color: rgba(255, 255, 255, 1);
  899. }
  900. }
  901. }
  902. /deep/.u-drawer-content-visible {
  903. border-radius: 12px 12px 0 0;
  904. }
  905. /deep/uni-input{
  906. background-color: rgba(241,242,245,1);
  907. color: rgba(119,119,119,1);
  908. font-size: 36rpx;
  909. height: 80rpx;
  910. padding-left: 16rpx;
  911. }
  912. </style>