timing.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <view>
  3. <u-navbar title="定时" title-color="#101010">
  4. <view slot="right" @click="deleteShow=!deleteShow" >
  5. <img v-if="deleteShow==true" src="@/assets/img/arcoDesign-select-all.svg" alt="" />
  6. <img v-else src="@/assets/img/riLine-list-settings-line.svg" alt="" />
  7. </view>
  8. </u-navbar>
  9. <view class="time-group">
  10. <checkbox-group @change="checkboxChange" >
  11. <view class="time-item" v-for="(item,i) in timerSwitchList"
  12. >
  13. <view class="time" @click="clicksheetInfo(item)" >
  14. <view class="time-slot">
  15. {{item.startTime}}{{item.switchStatus==2||item.switchStatus==3?'-'+(showjp2time(item.startTime,item.endTime)?'次日':'')+item.endTime:''}}
  16. </view>
  17. <view class="type">
  18. {{item.switchStatusN}} | {{item.type==1?'执行一次':''}}
  19. <template v-if="item.type!=1">
  20. <template v-if="item.weekdays=='1,2,3,4,5,6,7'">
  21. 每天
  22. </template>
  23. <template v-else >
  24. <template v-for="(item,i) in item.weekdays.split(',')">
  25. <span :key="i">
  26. {{weeklist[item]}}
  27. </span>
  28. <span class="weeklistclassSpan" :key="i+'a'" >
  29. ,
  30. </span>
  31. </template>
  32. </template>
  33. </template>
  34. <template v-if="item.switchStatus==3">
  35. <span style="margin-left: 8rpx;">| {{item.maxPower}}kW</span>
  36. </template>
  37. </view>
  38. </view>
  39. <!-- 开关 -->
  40. <view class="switch" v-if="!deleteShow" >
  41. <u-switch @change="switchBtn(item,$event)"
  42. v-model="item.status" size="40" ></u-switch>
  43. </view>
  44. <!-- 单选框 -->
  45. <view class="radio" v-if="deleteShow" >
  46. <checkbox
  47. :value="item.id" ></checkbox>
  48. </view>
  49. </view>
  50. </checkbox-group >
  51. </view>
  52. <u-divider :isnone="timerSwitchList.length==0" nonetext="无记录"
  53. border-color="#CFD2D5">已经到底了</u-divider>
  54. <!-- 添加按钮 -->
  55. <view class="add" @click="show=true" v-if="deleteShow==false" >
  56. <img src="@/assets/img/riLine-add-line 1.svg" alt="" />
  57. </view>
  58. <!-- 新增弹窗 -->
  59. <view class="add-popup">
  60. <u-action-sheet :list="list" @click="clicksheet" v-model="show" border-radius="16" ></u-action-sheet>
  61. </view>
  62. <!-- 删除 -->
  63. <view class="delete" v-if="deleteShow" @click="deletePopupQuery" >
  64. <view class="icon">
  65. <img src="@/assets/img/riLine-delete-bin-7-line 1.svg" alt="" />
  66. </view>
  67. <view class="text">
  68. 删除
  69. </view>
  70. </view>
  71. <!-- 删除确认弹框 -->
  72. <u-popup v-model="deletePopup" mode="bottom" border-radius="12" >
  73. <view class="popup">
  74. <view class="headline">
  75. 删除定时
  76. </view>
  77. <view class="hint">
  78. 要删除选中的定时吗?
  79. </view>
  80. <view class="btn-box">
  81. <view class="cancel" @click="deletePopup=false" >
  82. 取消
  83. </view>
  84. <view class="confirm" @click="deletePopupApi" >
  85. 确认删除
  86. </view>
  87. </view>
  88. </view>
  89. </u-popup>
  90. </view>
  91. </template>
  92. <script>
  93. import * as API from '@/apis/pagejs/meterTimer.js'
  94. export default {
  95. data() {
  96. return {
  97. checked:false,
  98. show: false,
  99. popShow:false,
  100. deleteShow:false,
  101. deletePopup:false,
  102. weeklist:[
  103. '','周一','周二','周三','周四','周五','周六','周日'
  104. ],
  105. list: [{
  106. text: '时间段定时',
  107. }, {
  108. text: '定时送电'
  109. }, {
  110. text: '定时停电'
  111. },{
  112. text:'智能停电'
  113. }],
  114. timerSwitchList:[],
  115. getMeterTimerListReady:false,
  116. deleteIds:"",
  117. }
  118. },
  119. onLoad(op) {
  120. if(op.id){
  121. this.meterId=op.id;
  122. this.getMeterTimerList()
  123. }
  124. },
  125. onShow() {
  126. if(this.meterId){
  127. this.getMeterTimerList()
  128. }
  129. },
  130. methods: {
  131. switchBtn(node,key){
  132. uni.showLoading({
  133. title: "加载中",
  134. mask: true,
  135. })
  136. API.changeStatus({
  137. id:node.id,
  138. //enabled:key
  139. }).then((res) => {
  140. uni.hideLoading();
  141. node.status=res.data.status
  142. }).catch(error => {
  143. uni.showToast({
  144. title: error,
  145. icon: "none"
  146. })
  147. })
  148. },
  149. showjp2time(time1,time2){
  150. if(time1&&time2){
  151. var num1=parseInt(time1.replace(":",''))
  152. var num2=parseInt(time2.replace(":",''))
  153. return num1>=num2
  154. }else{
  155. return false
  156. }
  157. },
  158. deletePopupQuery(){
  159. if(this.deleteIds!=''){
  160. this.deletePopup=true
  161. }else{
  162. uni.showToast({
  163. title: "请至少勾选一项",
  164. icon: "none"
  165. })
  166. }
  167. },
  168. deletePopupApi(){
  169. uni.showLoading({
  170. title: "加载中",
  171. mask: true,
  172. })
  173. API.deleteSwitch({
  174. ids:this.deleteIds
  175. }).then((response) => {
  176. uni.hideLoading();
  177. this.deletePopup=false
  178. this.deleteShow=false
  179. this.deleteIds=""
  180. this.getMeterTimerList()
  181. }).catch(error => {
  182. uni.showToast({
  183. title: error,
  184. icon: "none"
  185. })
  186. })
  187. },
  188. checkboxChange(e){
  189. var sz=e.detail.value;
  190. this.deleteIds=sz.join()
  191. },
  192. clicksheetInfo(item){
  193. if(!this.deleteShow){
  194. var url=`/pages/timing/autoOff?id=${item.id}`
  195. uni.navigateTo({
  196. url:url
  197. })
  198. }
  199. },
  200. clicksheet(index){
  201. var url=`/pages/timing/autoOff?meterId=${this.meterId}&type=${index}`
  202. uni.navigateTo({
  203. url:url
  204. })
  205. },
  206. getMeterTimerList(){
  207. uni.showLoading({
  208. title: "加载中",
  209. mask: true,
  210. })
  211. API.meterTimerList({
  212. meterId:this.meterId
  213. }).then((response) => {
  214. uni.hideLoading();
  215. this.getMeterTimerListReady=true
  216. this.timerSwitchList=response.data.timerSwitchList;
  217. }).catch(error => {
  218. uni.showToast({
  219. title: error,
  220. icon: "none"
  221. })
  222. })
  223. }
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .weeklistclassSpan:last-child{
  229. display: none;
  230. }
  231. /deep/.u-slot-right{
  232. margin-right:32rpx;
  233. img{
  234. width: 48rpx;
  235. height: 48rpx;
  236. }
  237. }
  238. .time-group{
  239. background-color: #fff;
  240. .time-item{
  241. padding: 24rpx 0;
  242. margin: 0 32rpx;
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. border-bottom: 1px solid rgba(221,221,221,1);
  247. .time{
  248. width: 100%;
  249. .time-slot{
  250. color: rgba(16,16,16,1);
  251. font-size: 32rpx;
  252. }
  253. .type{
  254. color: rgba(119,119,119,1);
  255. }
  256. }
  257. }
  258. .time-item:last-of-type{
  259. border: none;
  260. }
  261. }
  262. // 添加按钮
  263. .add{
  264. z-index: 99;
  265. width: 128rpx;
  266. height: 128rpx;
  267. background-color: rgba(22,119,255,1);
  268. border-radius: 999px;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. position: fixed;
  273. bottom: 80rpx;
  274. right: 40rpx;
  275. img{
  276. width: 80rpx;
  277. height: 80rpx;
  278. }
  279. }
  280. .add-popup{
  281. /deep/.u-drawer{
  282. left: 24rpx;
  283. right: 24rpx;
  284. bottom: 24rpx;
  285. border-radius: 8px;
  286. }
  287. /deep/.u-action-sheet-item{
  288. color: #101010;
  289. }
  290. }
  291. // 删除
  292. .delete{
  293. position: fixed;
  294. left: 0;
  295. right: 0;
  296. bottom: 0;
  297. background-color:#fff;
  298. display: flex;
  299. flex-direction: column;
  300. align-items: center;
  301. justify-content: center;
  302. // padding: 20rpx 0;
  303. height: 120rpx;
  304. img{
  305. width: 48rpx;
  306. height: 48rpx;
  307. }
  308. .text{
  309. color: rgba(51,51,51,1);
  310. font-size: 20rpx;
  311. }
  312. }
  313. // 删除确认弹框
  314. .popup{
  315. padding: 32rpx;
  316. text-align: center;
  317. .headline{
  318. color: rgba(16,16,16,1);
  319. font-size: 36rpx;
  320. font-weight: bold;
  321. }
  322. .hint{
  323. color: rgba(16,16,16,1);
  324. font-size: 32rpx;
  325. margin-top: 40rpx;
  326. }
  327. .btn-box{
  328. margin-top: 82rpx;
  329. display: flex;
  330. justify-content: space-between;
  331. .cancel{
  332. width: 328rpx;
  333. line-height: 80rpx;
  334. border-radius: 4px;
  335. background-color: rgba(222,225,228,1);
  336. color: rgba(51,51,51,1);
  337. font-size: 32rpx;
  338. }
  339. .confirm{
  340. width: 328rpx;
  341. line-height: 80rpx;
  342. border-radius: 4px;
  343. background-color: rgba(255,68,68,1);
  344. color: rgba(255,255,255,1);
  345. font-size: 32rpx;
  346. }
  347. }
  348. }
  349. </style>