rotationflow.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. <template>
  2. <view class="rotationflow">
  3. <custom-card>
  4. <block slot="backText">自动控制</block>
  5. </custom-card>
  6. <view class="rotationflow-top">
  7. <view class="rotationflow-top-list">
  8. <image :src="autoBtn" class="rotate-autoBtn" />
  9. <image :src="rotate" class="rotate-rotate" />
  10. <image :src="water" class="rotate-water" />
  11. <view class="rotationflow-time">
  12. <view class="rotationflow-time-title" style="font-size: 28px">{{
  13. currentFq.name || '--'
  14. }}</view>
  15. <!-- <view class="rotationflow-time-content"> {{ time }}</view> -->
  16. <view class="rotationflow-time-label">{{ label }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="rotationflow-middle">
  21. <view
  22. class="rotationflow-middle-item"
  23. v-for="item in list"
  24. :key="item.label"
  25. >
  26. <view class="rotationflow-middle-item-value">{{ item.value }}</view>
  27. <view class="rotationflow-middle-item-title">{{
  28. item.sfDisplayname || item.sfName
  29. }}</view>
  30. </view>
  31. </view>
  32. <view class="rotationflow-content">
  33. <view class="rotationflow-content-top">
  34. <view
  35. :class="
  36. tktype == '1'
  37. ? 'rotationflow-content-top-title'
  38. : 'rotationflow-content-top-title-rever'
  39. "
  40. >
  41. {{ tktype == '1' ? '灌溉' : '水肥' }}
  42. </view>
  43. <view class="rotationflow-content-top-desc">已选灌区</view>
  44. </view>
  45. <view class="rotationflow-content-list">
  46. <view class="rotationflow-content-list-wrapper" v-if="tktype == 1">
  47. <view class="rotationflow-content-num">
  48. <view class="rotationflow-content-num-title"
  49. >轮灌次数:{{ currentFq.lgcs || 0 }}</view
  50. >
  51. <view class="rotationflow-content-num-title"
  52. >轮灌间隔:{{ currentFq.lgjg || 0 }} 分钟</view
  53. >
  54. </view>
  55. </view>
  56. <view class="rotationflow-content-list-wrapper" v-else>
  57. <view class="rotationflow-content-num">
  58. <view class="rotationflow-content-num-title"
  59. >轮灌次数:{{ currentFq.lgcs || 0 }}</view
  60. >
  61. <view class="rotationflow-content-num-title"
  62. >肥前水:{{ currentFq.fqcx || 0 }} 分钟</view
  63. > </view
  64. ><view class="rotationflow-content-num">
  65. <view class="rotationflow-content-num-title"
  66. >轮灌间隔:{{ currentFq.lgjg || 0 }} 分钟</view
  67. >
  68. <view class="rotationflow-content-num-title"
  69. >肥后水:{{ currentFq.fhcx || 0 }} 分钟</view
  70. > </view
  71. ><view class="rotationflow-content-num">
  72. <view class="rotationflow-content-num-title"
  73. >模式选择:{{ getsfmode(currentFq.sfmode) }}</view
  74. >
  75. <view class="rotationflow-content-num-title"></view>
  76. </view>
  77. </view>
  78. <view
  79. class="rotationflow-content-list-item"
  80. v-for="(item, index) in fqList"
  81. :class="item.value === '2' ? 'haveYet' : ''"
  82. :key="index"
  83. >
  84. <view
  85. class="rotationflow-content-list-item-title"
  86. :class="
  87. item.value === '1' ? 'rotationflow-content-list-item-current' : ''
  88. "
  89. >{{ item.name }}</view
  90. >
  91. <view
  92. class="rotationflow-content-list-item-desc"
  93. :class="
  94. item.value === '1' ? 'rotationflow-content-list-item-current' : ''
  95. "
  96. >{{ item.value == '2' ? '已灌溉' : item.ggsj + '分钟' }}</view
  97. >
  98. </view>
  99. </view>
  100. </view>
  101. <view class="rotationflow-footer">
  102. <view class="rotationflow-footer-item" @click="rotationflowEnd"
  103. >结束灌溉</view
  104. >
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. export default {
  110. name: 'rotationflow',
  111. data() {
  112. return {
  113. rotate: 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/deviceIcons/shuifei/rotate.png',
  114. water: 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/deviceIcons/shuifei/water.png',
  115. autoBtn: 'https://s3.hnyfwlw.com/webstaticimg/bigdata_app/deviceIcons/shuifei/autoBtn.png',
  116. time: '-',
  117. list: [],
  118. timer: null,
  119. devBid: '',
  120. tktype: 1,
  121. lgcs: 0,
  122. lgjg: 0,
  123. fqList: [],
  124. currentFq: {},
  125. label: '灌溉中.',
  126. devName: '',
  127. devStatus: '',
  128. };
  129. },
  130. components: {},
  131. methods: {
  132. formartTime(time) {
  133. if (!time) {
  134. return '-';
  135. }
  136. let hours = time * 60 * 1000;
  137. let h = Math.floor(hours / (60 * 60 * 1000));
  138. let m = Math.floor((hours % (60 * 60 * 1000)) / (60 * 1000));
  139. let s = Math.floor(((hours % (60 * 60 * 1000)) % (60 * 1000)) / 1000);
  140. this.time = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}:${
  141. s < 10 ? '0' + s : s
  142. }`;
  143. },
  144. setTime(time) {
  145. if (!time) {
  146. return '-';
  147. }
  148. let hours = time * 60 * 1000;
  149. this.timer = setInterval(() => {
  150. if (hours <= 0) {
  151. clearInterval(this.timer);
  152. return;
  153. }
  154. hours -= 1000;
  155. let h = Math.floor(hours / (60 * 60 * 1000));
  156. let m = Math.floor((hours % (60 * 60 * 1000)) / (60 * 1000));
  157. let s = Math.floor(((hours % (60 * 60 * 1000)) % (60 * 1000)) / 1000);
  158. this.time = `${h < 10 ? '0' + h : h}:${m < 10 ? '0' + m : m}:${
  159. s < 10 ? '0' + s : s
  160. }`;
  161. }, 1000);
  162. },
  163. getsfmode(m) {
  164. const mode = String(m);
  165. switch (mode) {
  166. case '1':
  167. return '定时';
  168. case '2':
  169. return '定量';
  170. case '3':
  171. return 'EC调配';
  172. case '4':
  173. return '混肥比例';
  174. default:
  175. return '-';
  176. }
  177. },
  178. async getRunStatus() {
  179. const res = await this.$myRequest({
  180. url: '/api/v2/iot/mobile/device/sf/zsrf/task/run/status/',
  181. method: 'post',
  182. data: {
  183. devBid: this.devBid,
  184. },
  185. });
  186. const data = res || {};
  187. if (data.status === undefined || data.status / 1 !== 1) {
  188. clearInterval(this.timer);
  189. clearInterval(this.labelTimer);
  190. clearInterval(this.taskTimer);
  191. uni.showLoading({
  192. title: '灌溉任务已结束',
  193. });
  194. setTimeout(() => {
  195. uni.hideLoading();
  196. uni.redirectTo({
  197. url: `/pages/cb/shuifeizs/detail?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  198. });
  199. }, 1000);
  200. return;
  201. }
  202. this.list = data?.sensorList || [];
  203. this.tktype = data?.tktype;
  204. this.lgjg = data?.lgjg || 0;
  205. this.lgcs = data?.lgcs || 0;
  206. this.fqList = data?.fqList || [];
  207. // value 0 未灌溉 1 灌溉中 2 灌溉完成
  208. this.fqList.forEach((item) => {
  209. if (item.value === '1') {
  210. this.currentFq = item;
  211. }
  212. });
  213. this.formartTime(this.currentFq.lgjg);
  214. // this.setTime(this.currentFq.lgjg);
  215. },
  216. rotationflowEnd() {
  217. const payload = {
  218. devBid: this.devBid,
  219. tkid: 0,
  220. status: 0,
  221. tktype: this.tktype,
  222. };
  223. this.postTaskCtl(payload);
  224. },
  225. async postTaskCtl(payload) {
  226. uni.showLoading({
  227. title: '正在执行',
  228. });
  229. const res = await this.$myRequest({
  230. url: '/api/v2/iot/mobile/device/sf/zsrf/task/ctl/',
  231. method: 'post',
  232. data: payload,
  233. header: {
  234. 'Content-Type': 'application/json',
  235. },
  236. });
  237. uni.hideLoading();
  238. if (res.code === '000000') {
  239. uni.showToast({
  240. title: '操作成功',
  241. });
  242. setTimeout(() => {
  243. uni.navigateTo({
  244. url: `/pages/cb/shuifeizs/detail?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`,
  245. });
  246. }, 1000);
  247. } else {
  248. uni.showToast({
  249. icon: 'none',
  250. title: res.msg,
  251. });
  252. }
  253. },
  254. },
  255. onLoad(options) {
  256. const { devBid, devName, devStatus } = options;
  257. this.devBid = devBid;
  258. this.devName = devName;
  259. this.devStatus = devStatus;
  260. this.getRunStatus();
  261. this.labelTimer = setInterval(() => {
  262. if (this.label === '灌溉中.') {
  263. this.label = '灌溉中..';
  264. } else if (this.label === '灌溉中..') {
  265. this.label = '灌溉中...';
  266. } else {
  267. this.label = '灌溉中.';
  268. }
  269. }, 500);
  270. this.taskTimer = setInterval(() => {
  271. this.getRunStatus();
  272. }, 30000);
  273. },
  274. onUnload() {
  275. clearInterval(this.timer);
  276. clearInterval(this.labelTimer);
  277. clearInterval(this.taskTimer);
  278. },
  279. beforeDestroy() {
  280. if (this.timer) {
  281. clearInterval(this.timer);
  282. }
  283. if (this.taskTimer) {
  284. clearInterval(this.taskTimer);
  285. }
  286. if (this.labelTimer) {
  287. clearInterval(this.labelTimer);
  288. }
  289. },
  290. };
  291. </script>
  292. <style scoped lang="scss">
  293. uni-page-body,
  294. uni-page-wrapper {
  295. position: relative;
  296. height: 100%;
  297. }
  298. @keyframes rotate {
  299. 0% {
  300. transform: rotate(0deg);
  301. }
  302. 100% {
  303. transform: rotate(360deg);
  304. }
  305. }
  306. .rotationflow {
  307. background: linear-gradient(
  308. 180deg,
  309. #f5f6fa00 0%,
  310. #f5f6fa 23.64%,
  311. #f5f6fa 100%
  312. ),
  313. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  314. width: 100%;
  315. height: calc(100vh - 100rpx);
  316. overflow: hidden;
  317. overflow-y: scroll;
  318. margin-bottom: 140rpx;
  319. position: relative;
  320. .rotationflow-top {
  321. height: 500rpx;
  322. width: 100%;
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. .rotationflow-top-list {
  327. display: flex;
  328. position: relative;
  329. align-items: center;
  330. justify-content: center;
  331. width: 100%;
  332. height: 100%;
  333. .rotate-autoBtn {
  334. position: absolute;
  335. width: 360rpx;
  336. height: 360rpx;
  337. z-index: 1;
  338. }
  339. .rotate-rotate {
  340. position: absolute;
  341. width: 320rpx;
  342. height: 320rpx;
  343. left: 215rpx;
  344. top: 92rpx;
  345. z-index: 2;
  346. // 循环滚动
  347. animation: rotate 20s linear infinite;
  348. }
  349. .rotate-water {
  350. position: absolute;
  351. width: 550rpx;
  352. height: 600rpx;
  353. margin-left: 220rpx;
  354. margin-top: 100rpx;
  355. }
  356. .rotationflow-time {
  357. display: flex;
  358. flex-direction: column;
  359. align-items: center;
  360. justify-content: center;
  361. position: relative;
  362. z-index: 3;
  363. top: -5rpx;
  364. .rotationflow-time-title {
  365. width: 200rpx;
  366. color: #042118;
  367. text-align: center;
  368. font-family: 'Source Han Sans CN VF';
  369. font-size: 32rpx;
  370. font-weight: 500;
  371. }
  372. .rotationflow-time-content {
  373. width: 200rpx;
  374. color: #042118;
  375. font-family: 'Source Han Sans CN VF';
  376. font-size: 40rpx;
  377. font-weight: 700;
  378. margin: 8rpx 0;
  379. text-align: center;
  380. }
  381. .rotationflow-time-label {
  382. width: 140rpx;
  383. color: #687a74;
  384. text-align: left;
  385. font-family: 'Source Han Sans CN VF';
  386. font-size: 32rpx;
  387. font-weight: 400;
  388. }
  389. }
  390. }
  391. }
  392. .rotationflow-middle {
  393. display: flex;
  394. padding: 0 48rpx;
  395. margin: 32rpx 0;
  396. .rotationflow-middle-item {
  397. width: 25%;
  398. text-align: center;
  399. .rotationflow-middle-item-value {
  400. color: #042118;
  401. font-family: 'Source Han Sans CN VF';
  402. font-size: 32rpx;
  403. font-weight: 500;
  404. }
  405. .rotationflow-middle-item-title {
  406. color: #687a74;
  407. font-family: 'Source Han Sans CN VF';
  408. font-size: 28rpx;
  409. font-style: normal;
  410. font-weight: 400;
  411. line-height: normal;
  412. // 超出隐藏
  413. white-space: nowrap;
  414. text-overflow: ellipsis;
  415. overflow: hidden;
  416. }
  417. }
  418. }
  419. .rotationflow-content {
  420. border-bottom: none;
  421. position: relative;
  422. overflow: hidden;
  423. background-color: #fff;
  424. border-radius: 16rpx;
  425. padding: 32rpx;
  426. width: calc(100% - 128rpx);
  427. margin-left: 32rpx;
  428. margin-bottom: 140rpx;
  429. &::before {
  430. position: absolute;
  431. content: '';
  432. top: 0;
  433. left: 0;
  434. right: 0;
  435. bottom: 0;
  436. background-size: cover;
  437. }
  438. .rotationflow-content-top {
  439. display: flex;
  440. .rotationflow-content-top-title {
  441. border-radius: 8rpx;
  442. background: #1890ff1a;
  443. color: #1890ff;
  444. font-family: 'Source Han Sans CN VF';
  445. font-size: 28rpx;
  446. font-style: normal;
  447. font-weight: 400;
  448. line-height: normal;
  449. padding: 4rpx 16rpx;
  450. }
  451. .rotationflow-content-top-title-rever {
  452. border-radius: 8rpx;
  453. background: #f3a72f1a;
  454. color: #f3a72f;
  455. font-family: 'Source Han Sans CN VF';
  456. font-size: 28rpx;
  457. font-style: normal;
  458. font-weight: 400;
  459. line-height: normal;
  460. padding: 4rpx 16rpx;
  461. }
  462. .rotationflow-content-top-desc {
  463. color: #333333;
  464. font-family: 'Source Han Sans CN VF';
  465. font-size: 28rpx;
  466. font-weight: 700;
  467. margin-left: 16rpx;
  468. }
  469. }
  470. .rotationflow-content-list {
  471. width: 100%;
  472. .rotationflow-content-list-wrapper {
  473. width: 100%;
  474. border-radius: 8rpx;
  475. background: #f5f6fa;
  476. padding: 8rpx 0;
  477. margin-top: 16rpx;
  478. }
  479. .rotationflow-content-num {
  480. display: flex;
  481. padding: 8rpx 16rpx;
  482. .rotationflow-content-num-title {
  483. width: 50%;
  484. color: #687a74;
  485. font-family: 'Source Han Sans CN VF';
  486. font-size: 28rpx;
  487. font-style: normal;
  488. font-weight: 400;
  489. margin: 0 8rpx;
  490. }
  491. }
  492. .rotationflow-content-list-item {
  493. display: flex;
  494. justify-content: space-between;
  495. margin: 16rpx 0;
  496. color: #042118;
  497. text-align: right;
  498. font-family: 'Source Han Sans CN VF';
  499. font-size: 28rpx;
  500. font-weight: 400;
  501. .rotationflow-content-list-item-desc {
  502. }
  503. .rotationflow-content-list-item-current {
  504. color: #14a478;
  505. }
  506. }
  507. .haveYet {
  508. color: #9ba6a3;
  509. text-align: right;
  510. font-family: 'Source Han Sans CN VF';
  511. font-size: 28rpx;
  512. font-weight: 400;
  513. }
  514. .currentYet {
  515. color: #14a478;
  516. text-align: right;
  517. font-family: 'Source Han Sans CN VF';
  518. font-size: 28rpx;
  519. font-weight: 400;
  520. }
  521. }
  522. }
  523. .rotationflow-footer {
  524. position: fixed;
  525. width: 100%;
  526. bottom: 0;
  527. left: 0;
  528. display: flex;
  529. height: 128rpx;
  530. align-items: center;
  531. background: #fff;
  532. box-shadow: 0 -4rpx 8rpx 0 #00000026;
  533. z-index: 9999;
  534. .rotationflow-footer-item {
  535. width: calc(100% - 64rpx);
  536. margin: 0 32rpx;
  537. text-align: center;
  538. font-size: 32rpx;
  539. height: 80rpx;
  540. line-height: 80rpx;
  541. color: #ffffff;
  542. font-family: 'PingFang SC';
  543. font-size: 32rpx;
  544. font-weight: 500;
  545. border-radius: 16rpx;
  546. background: #ff3546;
  547. }
  548. }
  549. }
  550. </style>