cleanRule.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <template>
  2. <view class="content">
  3. <view class="box-title">{{ title }}</view>
  4. <timeSelector showType="time" @btnConfirm="btnConfirm0" @btnCancel="btnCancel0">
  5. <view class="box-time">
  6. <input type="text" class="input" :value="time0" />
  7. </view>
  8. </timeSelector>
  9. <timeSelector showType="time" @btnConfirm="btnConfirm1" @btnCancel="btnCancel1">
  10. <view class="box-time">
  11. <input type="text" class="input" :value="time1" />
  12. </view>
  13. </timeSelector>
  14. <timeSelector showType="time" @btnConfirm="btnConfirm2" @btnCancel="btnCancel2">
  15. <view class="box-time">
  16. <input type="text" class="input" :value="time2" />
  17. </view>
  18. </timeSelector>
  19. <timeSelector showType="time" @btnConfirm="btnConfirm3" @btnCancel="btnCancel3">
  20. <view class="box-time">
  21. <input type="text" class="input" :value="time3" />
  22. </view>
  23. </timeSelector>
  24. <timeSelector showType="time" @btnConfirm="btnConfirm4" @btnCancel="btnCancel4">
  25. <view class="box-time">
  26. <input type="text" class="input" :value="time4" />
  27. </view>
  28. </timeSelector>
  29. <timeSelector showType="time" @btnConfirm="btnConfirm5" @btnCancel="btnCancel5">
  30. <view class="box-time">
  31. <input type="text" class="input" :value="time5" />
  32. </view>
  33. </timeSelector>
  34. <timeSelector showType="time" @btnConfirm="btnConfirm6" @btnCancel="btnCancel6">
  35. <view class="box-time">
  36. <input type="text" class="input" :value="time6" />
  37. </view>
  38. </timeSelector>
  39. <timeSelector showType="time" @btnConfirm="btnConfirm7" @btnCancel="btnCancel7">
  40. <view class="box-time">
  41. <input type="text" class="input" :value="time7" />
  42. </view>
  43. </timeSelector>
  44. <timeSelector showType="time" @btnConfirm="btnConfirm8" @btnCancel="btnCancel8">
  45. <view class="box-time">
  46. <input type="text" class="input" :value="time8" />
  47. </view>
  48. </timeSelector>
  49. <timeSelector showType="time" @btnConfirm="btnConfirm9" @btnCancel="btnCancel9">
  50. <view class="box-time">
  51. <input type="text" class="input" :value="time9" />
  52. </view>
  53. </timeSelector>
  54. <view class="bu">
  55. <button type="primary" @click="submit()" class="button">
  56. <p class="p">提交</p>
  57. </button>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. mapState,
  64. mapActions,
  65. mapMutations
  66. } from 'vuex';
  67. import timeSelector from '@/components/wing-time-selector/wing-time-selector.vue';
  68. export default {
  69. components: {
  70. timeSelector
  71. },
  72. data() {
  73. return {
  74. title: '当前定时清洗时间',
  75. time0: '',
  76. time1: '',
  77. time2: '',
  78. time3: '',
  79. time4: '',
  80. time5: '',
  81. time6: '',
  82. time7: '',
  83. time8: '',
  84. time9: ''
  85. };
  86. },
  87. onLoad() {
  88. var rule = uni.getStorageSync("nowEquipmentRule");
  89. var rules = rule.split(",");
  90. if(rules.length>0){
  91. for(var i=0;i<rules.length;i++){
  92. switch (i) {
  93. case 0:
  94. this.time0=rules[i];
  95. break;
  96. case 1:
  97. this.time1=rules[i];
  98. break;
  99. case 2:
  100. this.time2=rules[i];
  101. break;
  102. case 3:
  103. this.time3=rules[i];
  104. break;
  105. case 4:
  106. this.time4=rules[i];
  107. break;
  108. case 5:
  109. this.time5=rules[i];
  110. break;
  111. case 6:
  112. this.time6=rules[i];
  113. break;
  114. case 7:
  115. this.time7=rules[i];
  116. break;
  117. case 8:
  118. this.time8=rules[i];
  119. break;
  120. case 9:
  121. this.time9=rules[i];
  122. break;
  123. }
  124. }
  125. }
  126. },
  127. onShow() {
  128. },
  129. methods: {
  130. ...mapActions('chart', ['updateRule']),
  131. btnConfirm0(e) {
  132. console.log('确定时间为:', e);
  133. this.time0 = e.key;
  134. },
  135. btnCancel0() {
  136. this.time0 = '';
  137. },
  138. btnConfirm1(e) {
  139. this.time1 = e.key;
  140. },
  141. btnCancel1() {
  142. this.time1 = '';
  143. },
  144. btnConfirm2(e) {
  145. this.time2 = e.key;
  146. },
  147. btnCancel2() {
  148. this.time2 = '';
  149. },
  150. btnConfirm3(e) {
  151. this.time3 = e.key;
  152. },
  153. btnCancel3() {
  154. this.time3 = '';
  155. },
  156. btnConfirm4(e) {
  157. this.time4 = e.key;
  158. },
  159. btnCancel4() {
  160. this.time4 = '';
  161. },
  162. btnConfirm5(e) {
  163. this.time5 = e.key;
  164. },
  165. btnCancel5() {
  166. this.time5 = '';
  167. },
  168. btnConfirm6(e) {
  169. this.time6 = e.key;
  170. },
  171. btnCancel6() {
  172. this.time6 = '';
  173. },
  174. btnConfirm7(e) {
  175. this.time7 = e.key;
  176. },
  177. btnCancel7() {
  178. this.time7 = '';
  179. },
  180. btnConfirm8(e) {
  181. this.time8 = e.key;
  182. },
  183. btnCancel8() {
  184. this.time8 = '';
  185. },
  186. btnConfirm9(e) {
  187. this.time9 = e.key;
  188. },
  189. btnCancel9() {
  190. this.time9 = '';
  191. },
  192. submit() {
  193. var rules = [];
  194. if (this.time0 != '') {
  195. rules.push(this.time0);
  196. }
  197. if (this.time1 != '') {
  198. rules.push(this.time1);
  199. }
  200. if (this.time2 != '') {
  201. rules.push(this.time2);
  202. }
  203. if (this.time3 != '') {
  204. rules.push(this.time3);
  205. }
  206. if (this.time4 != '') {
  207. rules.push(this.time4);
  208. }
  209. if (this.time5 != '') {
  210. rules.push(this.time5);
  211. }
  212. if (this.time6 != '') {
  213. rules.push(this.time6);
  214. }
  215. if (this.time7 != '') {
  216. rules.push(this.time7);
  217. }
  218. if (this.time8 != '') {
  219. rules.push(this.time8);
  220. }
  221. if (this.time9 != '') {
  222. rules.push(this.time9);
  223. }
  224. var rule;
  225. if (rules.length > 0) {
  226. rule = rules.join(",");
  227. }
  228. const param = {};
  229. var equipmentId = uni.getStorageSync("nowEquipmentId");
  230. if (equipmentId != '') {
  231. param['equipmentId'] = equipmentId;
  232. }
  233. if (rule != '') {
  234. param['rule'] = rule;
  235. }
  236. return this.updateRule(param)
  237. .then(data => {
  238. if (data == "SUCCESS") {
  239. uni.showToast({
  240. title: "修改成功",
  241. icon: 'none',
  242. duration: 1000
  243. });
  244. }
  245. if (data == "ERROR") {
  246. uni.showToast({
  247. title: "修改失败",
  248. icon: 'none',
  249. duration: 1000
  250. });
  251. }
  252. if (data == "") {
  253. uni.showToast({
  254. title: "修改异常",
  255. icon: 'none',
  256. duration: 1000
  257. });
  258. }
  259. }, _ => void uni.stopPullDownRefresh());
  260. },
  261. }
  262. };
  263. </script>
  264. <style>
  265. .box-title {
  266. margin: 24rpx;
  267. font-size: 40rpx;
  268. font-weight: bold;
  269. color: #333333;
  270. padding-left: 40upx;
  271. }
  272. .box-time {
  273. margin: 24rpx;
  274. font-size: 30rpx;
  275. color: #3496fb;
  276. padding-top: 10upx;
  277. padding-left: 40upx;
  278. }
  279. .input {
  280. /* padding: 10upx 20upx 10upx 0upx; */
  281. padding-left: 20upx;
  282. padding-top: 10upx;
  283. background-color: #FFFFFF;
  284. width: 600upx;
  285. height: 50upx;
  286. box-shadow: 0upx 0upx 20upx #D3D3D3;
  287. border-radius: 5upx;
  288. }
  289. .bu {
  290. font-size: 50upx
  291. }
  292. .button {
  293. width: 220upx;
  294. height: 100upx;
  295. }
  296. .p {
  297. /* transform: translateY(-8upx); */
  298. font-size: 50upx
  299. }
  300. </style>