detail.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="facilitystate-page">
  3. <custom-card>
  4. <block slot="backText">
  5. <view class="facilitystate-top__title">
  6. <text :class="devStatus == '1' ? 'online' : 'offline'">{{
  7. devStatus == '1' ? '在线' : '离线'
  8. }}</text>
  9. {{ devName }}
  10. </view>
  11. </block>
  12. </custom-card>
  13. <view class="facilitystate-top">
  14. <view
  15. class="facilitystate-top__item"
  16. v-for="(item, index) in deviceList"
  17. :key="index"
  18. @click="nativeTo(item)"
  19. >
  20. <image class="item-icon" :src="item.icon" />
  21. <view class="facilitystate-top__item-text">{{ item.title }}</view>
  22. </view>
  23. </view>
  24. <Base :dataList="dataList" />
  25. <facilitystate
  26. :ggbCurrent="ggbCurrent"
  27. :sfbCurrent="sfbCurrent"
  28. :irrigatedAreaList="irrigatedAreaList"
  29. :alreadyfertilizerBucketList="alreadyfertilizerBucketList"
  30. />
  31. </view>
  32. </template>
  33. <script>
  34. import manualControl from './assets/manualControl.png';
  35. import wheelIrrigation from './assets/wheelIrrigation.png';
  36. import timing from './assets/timing.png';
  37. import masterStop from './assets/masterStop.png';
  38. import fertilizationFormula from './assets/fertilizationFormula.png';
  39. import backwashControl from './assets/backwashControl.png';
  40. import basicSetting from './assets/basicSetting.png';
  41. import operatingRecord from './assets/operatingRecord.png';
  42. import Base from './components/base.vue';
  43. import facilitystate from './components/facilitystate.vue';
  44. export default {
  45. data() {
  46. return {
  47. title: '水肥一体机',
  48. manualControl,
  49. devBid: '',
  50. devName: '',
  51. devStatus: '1',
  52. dataList: [],
  53. irrigatedAreaList: [],
  54. alreadyfertilizerBucketList: [],
  55. deviceList: [
  56. {
  57. icon: manualControl,
  58. title: '手动控制',
  59. url: '/pages/cb/shuifeizs/control',
  60. },
  61. {
  62. icon: wheelIrrigation,
  63. title: '自动控制',
  64. url: '',
  65. },
  66. {
  67. icon: timing,
  68. title: '定时计划',
  69. url: '',
  70. },
  71. {
  72. icon: masterStop,
  73. title: '总停',
  74. url: '',
  75. },
  76. {
  77. icon: fertilizationFormula,
  78. title: '施肥配方',
  79. url: '',
  80. },
  81. {
  82. icon: backwashControl,
  83. title: '反冲洗控制',
  84. url: '',
  85. },
  86. {
  87. icon: basicSetting,
  88. title: '基础设置',
  89. url: '',
  90. },
  91. {
  92. icon: operatingRecord,
  93. title: '操作记录',
  94. url: '/pages/cb/shuifeizs/history',
  95. },
  96. ],
  97. ggbCurrent: {},
  98. sfbCurrent: {},
  99. };
  100. },
  101. components: {
  102. Base,
  103. facilitystate,
  104. },
  105. onLoad(options) {
  106. /*
  107. 0 水源 泵类 负责水源进入管道的总泵或者阀
  108. 1 肥料 泵类 负责肥料进入管道的总阀或者泵
  109. 2 吸肥 泵类 控制肥料桶出肥的阀或者泵,每个肥料桶一个
  110. 3 搅拌 泵类 肥料桶的搅拌电机或者泵 每个肥料桶一个
  111. 4 肥料桶 泵类 肥料桶,每个施肥机有多个或者没有,不一定真实存在,只是逻辑上的概念
  112. 5 电磁阀 无 管道最末端每个田地里控制出水的阀门
  113. 6 传感器 无 水肥机上的 温度,压力,流速,PH EC等监测类要素
  114. 7 灌区 无 逻辑区域,电磁阀的分组
  115. */
  116. const { devBid, devName, devStatus } = options;
  117. this.devBid = devBid;
  118. this.devName = devName;
  119. this.devStatus = devStatus;
  120. this.deviceList[0].url = `/pages/cb/shuifeizs/control?devBid=${options.devBid}`;
  121. this.deviceList[
  122. this.deviceList.length - 1
  123. ].url = `/pages/cb/shuifeizs/history?devBid=${options.devBid}`;
  124. if (devBid) {
  125. this.init();
  126. }
  127. },
  128. methods: {
  129. async init() {
  130. this.getdeviceSfStatus();
  131. await this.getpeifangRefresh();
  132. await this.getRunStatus();
  133. },
  134. // iot/mobile/device/sf/peifang/refresh/
  135. async getpeifangRefresh() {
  136. const res = await this.$myRequest({
  137. url: '/api/v2/iot/mobile/device/sf/peifang/refresh/',
  138. method: 'post',
  139. data: {
  140. devBid: this.devBid,
  141. },
  142. });
  143. },
  144. async getRunStatus() {
  145. const res = await this.$myRequest({
  146. url: '/api/v2/iot/mobile/device/sf/zsrf/task/run/status/',
  147. method: 'post',
  148. data: {
  149. devBid: this.devBid,
  150. },
  151. });
  152. const data = JSON.stringify(res || {});
  153. if (data == '{}') {
  154. this.isRun = true;
  155. this.deviceList[1].url = `/pages/cb/shuifeizs/automation?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`;
  156. } else {
  157. this.isRun = false;
  158. this.deviceList[1].url = `/pages/cb/shuifeizs/rotationflow?devBid=${this.devBid}&devName=${this.devName}&devStatus=${this.devStatus}`;
  159. }
  160. },
  161. async getdeviceSfStatus() {
  162. const res = await this.$myRequest({
  163. url: '/api/v2/iot/mobile/device/sf/status/',
  164. method: 'post',
  165. data: {
  166. devBid: this.devBid,
  167. },
  168. });
  169. this.dataList = [];
  170. this.irrigatedAreaList = [];
  171. this.alreadyfertilizerBucketList = [];
  172. res.forEach((item) => {
  173. if (item.sfType === '0') {
  174. this.ggbCurrent = item;
  175. } else if (item.sfType === '1') {
  176. this.sfbCurrent = item;
  177. } else if (item.sfType === '4') {
  178. this.alreadyfertilizerBucketList.push(item);
  179. } else if (item.sfType === '6') {
  180. this.dataList.push(item);
  181. } else if (item.sfType === '7') {
  182. this.irrigatedAreaList.push(item);
  183. }
  184. });
  185. },
  186. nativeTo(item) {
  187. uni.navigateTo({
  188. url: item.url,
  189. });
  190. },
  191. },
  192. };
  193. </script>
  194. <style scoped lang="scss">
  195. uni-page-body {
  196. position: relative;
  197. height: 100%;
  198. }
  199. .online {
  200. height: 32rpx;
  201. line-height: 32rpx;
  202. padding: 0 8rpx;
  203. border-radius: 4rpx;
  204. background: #14a478;
  205. color: #ffffff;
  206. font-family: 'Source Han Sans CN';
  207. font-size: 20rpx;
  208. font-weight: 500;
  209. margin-right: 8rpx;
  210. top: -4rpx;
  211. position: relative;
  212. }
  213. .offline {
  214. height: 32rpx;
  215. line-height: 32rpx;
  216. padding: 0 8rpx;
  217. border-radius: 4rpx;
  218. background: #ff4d4f;
  219. color: #ffffff;
  220. font-family: 'Source Han Sans CN';
  221. font-size: 20rpx;
  222. font-weight: 500;
  223. margin-right: 8rpx;
  224. top: -4rpx;
  225. position: relative;
  226. }
  227. .facilitystate-page {
  228. background: linear-gradient(180deg, #ffffff00 0%, #fff 23.64%, #fff 100%),
  229. linear-gradient(102deg, #bfeadd 6.77%, #b8f1e7 40.15%, #b9eef5 84.02%);
  230. height: 100%;
  231. width: 100%;
  232. overflow-x: hidden;
  233. overflow-y: scroll;
  234. .facilitystate-top {
  235. display: grid;
  236. grid-template-columns: repeat(4, 1fr);
  237. text-align: center;
  238. margin-top: 18rpx;
  239. &__item {
  240. margin-bottom: 32rpx;
  241. .item-icon {
  242. width: 96rpx;
  243. height: 96rpx;
  244. }
  245. }
  246. &__item-text {
  247. color: #042118;
  248. font-family: 'Source Han Sans CN VF';
  249. font-size: 28rpx;
  250. font-weight: 400;
  251. margin-top: 16rpx;
  252. }
  253. }
  254. }
  255. </style>