lot_data.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="物联数据"
  8. @clickLeft="back"
  9. >
  10. </uni-nav-bar>
  11. <uni-section title="物联数据" type="line">
  12. <view class="mainBox-toinfo">
  13. <view class="info-left" v-if="realData.status_m">
  14. 运行状态
  15. <view class="toinfo-status">{{ realData.status_m.value }}</view>
  16. <view
  17. class="toinfo-set text-primary"
  18. @click="toSet"
  19. v-if="Object.keys(realData).length == 1"
  20. >设置</view
  21. >
  22. </view>
  23. <template v-if="realData.running_time">
  24. <view class="info-time">{{ realData.running_time.time }}</view>
  25. <view class="info-time"
  26. >{{ realData.running_time.value
  27. }}{{ parentClassId == '57' ? '' : '分钟' }}</view
  28. >
  29. </template>
  30. </view>
  31. <!-- 挤压机 65 -->
  32. <InternetExtruder
  33. :info="info"
  34. :realData.sync="realData"
  35. :key="Object.entries(realData).length + 1"
  36. v-if="parentClassId == '65'"
  37. />
  38. <!-- 干燥箱 57 -->
  39. <InternetDryingBox
  40. :info="info"
  41. :realData.sync="realData"
  42. :key="Object.entries(realData).length"
  43. v-else-if="parentClassId == '57'"
  44. />
  45. <view class="info-view">
  46. <view
  47. class="items"
  48. v-for="[key, obj] in Object.entries(realData)"
  49. :key="key"
  50. >
  51. <!-- 过滤掉运行状态 -->
  52. <template v-if="!['status', 'status_m'].includes(key)">
  53. <text class="label">{{ obj.name }}</text
  54. >{{ obj.value }}{{ obj.unit }}
  55. </template>
  56. </view>
  57. </view>
  58. </uni-section>
  59. <!-- 设置弹窗 -->
  60. <Popu ref="popuRef" @change="changeStatus" />
  61. </view>
  62. </template>
  63. <script>
  64. import InternetDryingBox from './components/InternetDryingBox'
  65. import InternetExtruder from './components/InternetExtruder'
  66. import Popu from '@/pages/equipment_ledger/components/Popu.vue'
  67. import { get, postJ } from '@/utils/api.js'
  68. export default {
  69. components: {
  70. Popu,
  71. InternetExtruder,
  72. InternetDryingBox
  73. },
  74. data () {
  75. return {
  76. status: '运行',
  77. chartData: {
  78. categories: [],
  79. series: []
  80. },
  81. info: {},
  82. dict: {
  83. // 运行状态
  84. status: {
  85. //0-停止,1-启动,2-定值停止,3-定值启动
  86. 0: '停止',
  87. 1: '启动',
  88. 2: '定值停止',
  89. 3: '定值启动'
  90. }
  91. },
  92. // 实时数据
  93. realData: {}
  94. }
  95. },
  96. onLoad (option) {
  97. this.info = JSON.parse(decodeURIComponent(option.info))
  98. this.getRealData()
  99. },
  100. computed: {
  101. parentClassId () {
  102. const data = JSON.parse(this.info.information.classificationUrlId) || []
  103. return data[1]
  104. }
  105. },
  106. methods: {
  107. toSet () {
  108. this.$refs.popuRef.open()
  109. },
  110. changeStatus (item) {
  111. let par = {
  112. id: this.info.id,
  113. status: item.value
  114. }
  115. postJ(
  116. this.apiUrl + `/asset/updateStatus?id=${par.id}&status=${par.status}`,
  117. par
  118. ).then(res => {
  119. if (res?.success) {
  120. uni.showToast({
  121. title: '设置成功!',
  122. icon: 'success'
  123. })
  124. this.getRealData()
  125. }
  126. })
  127. },
  128. // 请求实时数据
  129. async getRealData () {
  130. await get(this.apiUrl + `/asset/getRealEqu/${this.info.id}`).then(res => {
  131. let order = [
  132. 'temp',
  133. 'o_temp',
  134. 'temp1',
  135. 'temp2',
  136. 'temp3',
  137. 'temp4',
  138. 'running_time',
  139. 'remain_time'
  140. ]
  141. let data = res.data.sort((a, b) => {
  142. return order.indexOf(a.identifier) - order.indexOf(b.identifier)
  143. })
  144. for (const item of data) {
  145. this.$set(this.realData, item.identifier, item)
  146. }
  147. })
  148. }
  149. }
  150. }
  151. </script>
  152. <style scoped lang="scss">
  153. .mainBox {
  154. .mainBox-toinfo {
  155. display: flex;
  156. align-items: center;
  157. justify-content: space-between;
  158. margin: 0 auto;
  159. background: #ccc;
  160. padding: 16rpx 10rpx;
  161. .info-left {
  162. display: flex;
  163. align-items: center;
  164. justify-content: flex-start;
  165. color: #000;
  166. font-weight: bold;
  167. font-size: 28rpx;
  168. line-height: 40rpx;
  169. .toinfo-status {
  170. width: 80rpx;
  171. height: 40rpx;
  172. line-height: 40rpx;
  173. background: #47975a;
  174. border-radius: 18rpx;
  175. color: #fff;
  176. text-align: center;
  177. font-weight: normal;
  178. font-size: 20rpx;
  179. margin: 0 10rpx;
  180. }
  181. }
  182. .info-time {
  183. font-size: 30rpx;
  184. }
  185. }
  186. .info-view {
  187. display: flex;
  188. flex-wrap: wrap;
  189. padding: 20rpx 30rpx;
  190. .items {
  191. width: 50%;
  192. font-size: $uni-font-size-sm;
  193. color: #3e3e3e;
  194. margin-bottom: 20rpx;
  195. display: flex;
  196. .label {
  197. display: inline-block;
  198. width: 180rpx;
  199. text-align: right;
  200. padding-right: 15rpx;
  201. font-weight: bold;
  202. color: #6e6e6e;
  203. }
  204. }
  205. }
  206. }
  207. </style>