iotControl.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <view class="iotControl">
  3. <view class="device-type">
  4. <view v-for="(item,index) in deviceType" @click="deviceTypeFun(item)">
  5. <img :src="item.img">
  6. <view>{{item.name}}</view>
  7. <img src="@/images/basicsModules/icon_wdwg_gd.png">
  8. </view>
  9. </view>
  10. <!-- 传感器监测 -->
  11. <view class="small-title">
  12. <view></view>
  13. <view>传感器监测</view>
  14. </view>
  15. <view class="sensor">
  16. <view v-for="(item,index) in sensorData">
  17. <img :src="item.img">
  18. <veiw>{{item.name}}</veiw>
  19. </view>
  20. </view>
  21. <!-- 智能控制 -->
  22. <view class="small-title">
  23. <view></view>
  24. <view>智能控制</view>
  25. </view>
  26. <view class="intelligent-control">
  27. <view v-for="(item,index) in labHardwareVOList" :key="index">
  28. <view class="for-button-p">{{item.hardwareName}}
  29. <text v-if="item.state.code=='3'&& item.hardwareTypeEnum.hardwareTypeCode==2">({{item.dictLabel}})</text>
  30. </view>
  31. <img v-if="item.state.code=='3' && item.pcType != 1" src="@/images/basicsModules/icon_10.png" @click="buttonClick('switch',item,'close')">
  32. <img v-if="item.state.code=='4' && item.pcType != 1" src="@/images/basicsModules/icon_11.png" @click="buttonClick('switch',item,'open')">
  33. <view class="for-button-p" v-if="item.state.code=='0' && item.pcType != 1">离线</view>
  34. <view class="for-button-p" v-if="item.state.code=='2' && item.pcType != 1" style="color:#0183FA;">在线</view>
  35. <view v-if="item.pcType == 1" class="pcType-button" @click="buttonClick('operate',item,'')">操作</view>
  36. </view>
  37. </view>
  38. <!-- 智能终端 -->
  39. <view class="small-title">
  40. <view></view>
  41. <view>智能终端</view>
  42. </view>
  43. <view class="intelligent-control">
  44. <view v-for="(item,index) in terminalData" :key="index">
  45. <view class="for-button-p">{{item.name}}</view>
  46. <view class="for-button-p" v-if="item.pcType == 1">离线</view>
  47. <view class="for-button-p" v-if="item.pcType != 1" style="color:#0183FA;">在线</view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {} from '@/api/basicsModules/index.js'
  54. export default {
  55. name: "iotControl",
  56. props: {
  57. subjectData: {},
  58. },
  59. data() {
  60. return {
  61. deviceType:[
  62. {
  63. id:1,
  64. name:'视频监控',
  65. img: require('@/images/basicsModules/icon_xq_spjk.png'),
  66. },
  67. {
  68. id:2,
  69. name:'语音广播',
  70. img: require('@/images/basicsModules/icon_sskz_xz.png'),
  71. },
  72. {
  73. id:3,
  74. name:'空调1',
  75. img: require('@/images/basicsModules/icon_xq_kt.png'),
  76. },
  77. {
  78. id:4,
  79. name:'空调2',
  80. img: require('@/images/basicsModules/icon_xq_kt.png'),
  81. },
  82. ],
  83. sensorData:[
  84. {
  85. name:'温度: 36°',
  86. img: require('@/images/basicsModules/icon_yw_yc.png'),
  87. },
  88. {
  89. name:'湿度: 60%',
  90. img: require('@/images/basicsModules/icon_yw_yc.png'),
  91. },
  92. {
  93. name:'烟感1号: 0',
  94. img: require('@/images/basicsModules/icon_yw_yc.png'),
  95. },
  96. {
  97. name:'烟感2号: 1',
  98. img: require('@/images/basicsModules/icon_yw_yc.png'),
  99. },
  100. {
  101. name:'一氧化碳: 0ppm',
  102. img: require('@/images/basicsModules/icon_yw_yc.png'),
  103. },
  104. ],
  105. labHardwareVOList:[
  106. {
  107. hardwareName:'高温设备1',
  108. hardwareTypeEnum:{
  109. enumName:'',
  110. },
  111. state:{
  112. code:3,
  113. },
  114. pcType:2,
  115. }
  116. ],
  117. terminalData:[
  118. {
  119. name:'智能管控一体机',
  120. pcType:1,
  121. }
  122. ],
  123. }
  124. },
  125. created() {
  126. },
  127. mounted() {
  128. console.log(this.subjectData)
  129. },
  130. methods: {
  131. //物联控制设备
  132. deviceTypeFun(item){
  133. if(item.id==1){
  134. }else if(item.id==2){
  135. //语音广播弹窗开启
  136. this.$parent.buttonClick('broadcastOpen','');
  137. }else if(item.id==3){
  138. //空调弹窗开启
  139. this.$parent.buttonClick('conditioningOpen','');
  140. }
  141. },
  142. buttonClick(type,row,status){
  143. let self = this;
  144. if(type == 'switch'){
  145. //开关
  146. let text = '';
  147. if(status == 'close'){
  148. text = '关闭';
  149. }else if(status == 'open'){
  150. text = '开启';
  151. }
  152. uni.showModal({
  153. content: '确认要'+text+'吗?',
  154. cancelColor:"#999",
  155. confirmColor:"#0183FA",
  156. success: function (res) {
  157. if (res.confirm) {
  158. self.mangerControl(row,status);
  159. console.log('用户点击确定');
  160. } else if (res.cancel) {
  161. console.log('用户点击取消');
  162. }
  163. }
  164. });
  165. }else if(type=='operate'){
  166. //操作
  167. uni.showModal({
  168. content: '确认要操作该设备吗?',
  169. cancelColor:"#999",
  170. confirmColor:"#0183FA",
  171. success: function (res) {
  172. if (res.confirm) {
  173. self.controlSwitch(item.id);
  174. console.log('用户点击确定');
  175. } else if (res.cancel) {
  176. console.log('用户点击取消');
  177. }
  178. }
  179. });
  180. }
  181. },
  182. //设备开关
  183. async mangerControl(item,status){
  184. let obj = {
  185. id:item.id,
  186. command:status,
  187. };
  188. const {data} = await mangerControl(obj);
  189. if(data.code == 200){
  190. if(command == 'open'){
  191. item.type = 3;
  192. }else if(command == 'close'){
  193. item.type = 4;
  194. }
  195. uni.showToast({
  196. title: '操作成功',
  197. icon:"none",
  198. mask:true,
  199. duration: 2000
  200. });
  201. }
  202. },
  203. async controlSwitch(id){
  204. const {data} = await controlSwitch({id:id});
  205. if(data.code == 200){
  206. uni.showToast({
  207. title: '操作成功',
  208. icon:"none",
  209. mask:true,
  210. duration: 2000
  211. });
  212. }
  213. },
  214. },
  215. }
  216. </script>
  217. <style lang="stylus" scoped>
  218. .iotControl {
  219. width: 750rpx;
  220. .device-type{
  221. background: #fff;
  222. padding: 24rpx 20rpx;
  223. box-sizing: border-box;
  224. display: flex;
  225. justify-content: flex-start;
  226. flex-wrap: wrap;
  227. >view{
  228. width: 356rpx;
  229. height: 80rpx;
  230. display: flex;
  231. justify-content: flex-start;
  232. align-items: center;
  233. border-right: 1px dashed #E0E0E0;
  234. border-bottom: 1px dashed #E0E0E0;
  235. padding-left: 10rpx;
  236. box-sizing: border-box;
  237. >img:nth-of-type(1){
  238. width: 42rpx;
  239. height: 42rpx;
  240. margin-right: 12rpx;
  241. }
  242. >view{
  243. font-family: PingFang SC;
  244. font-weight: 500;
  245. font-size: 30rpx;
  246. color: #222222;
  247. line-height: 80rpx;
  248. width: 244rpx;
  249. }
  250. >img:nth-of-type(2){
  251. width: 24rpx;
  252. height: 22rpx;
  253. }
  254. }
  255. >view:nth-child(2n){
  256. border-right: none;
  257. padding-left: 20rpx;
  258. box-sizing: border-box;
  259. }
  260. >view:nth-last-child(1){
  261. border-bottom: none;
  262. }
  263. >view:nth-last-child(2){
  264. border-bottom: none;
  265. }
  266. }
  267. .small-title{
  268. height: 80rpx;
  269. border-bottom: 1rpx solid #E0E0E0;
  270. background: #FFFFFF;
  271. margin-top: 20rpx;
  272. display: flex;
  273. align-items: center;
  274. >view:nth-of-type(1){
  275. width: 4rpx;
  276. height: 34rpx;
  277. background: #0D97EB;
  278. margin: 0rpx 24rpx 0 20rpx;
  279. }
  280. >view:nth-of-type(2){
  281. font-family: PingFang SC;
  282. font-weight: 500;
  283. font-size: 32rpx;
  284. color: #333333;
  285. line-height: 80rpx;
  286. }
  287. }
  288. .sensor{
  289. display: flex;
  290. justify-content: flex-start;
  291. flex-wrap: wrap;
  292. background: #fff;
  293. padding: 12rpx 20rpx 30rpx;
  294. box-sizing: border-box;
  295. >view{
  296. display: flex;
  297. justify-content: flex-start;
  298. align-items: center;
  299. height: 66rpx;
  300. width: 355rpx;
  301. >img{
  302. width: 42rpx;
  303. height: 42rpx;
  304. margin-right: 20rpx;
  305. }
  306. >view{
  307. font-family: PingFang SC;
  308. font-weight: 500;
  309. font-size: 28rpx;
  310. color: #222222;
  311. line-height: 30rpx;
  312. }
  313. }
  314. }
  315. .intelligent-control{
  316. background: #fff;
  317. padding:0 20rpx;
  318. box-sizing: border-box;
  319. >view{
  320. display flex
  321. border-bottom:1rpx solid #e0e0e0;
  322. .for-button-p{
  323. flex:1;
  324. line-height:90rpx;
  325. color:#333333;
  326. font-size:28rpx;
  327. >text{
  328. font-size: 28rpx;
  329. color: #0183FA;
  330. }
  331. }
  332. >img{
  333. height:50rpx;
  334. width:100rpx;
  335. margin:20rpx 0 20rpx 0;
  336. }
  337. view:nth-child(2){
  338. text-align right
  339. color:#999;
  340. }
  341. .pcType-button{
  342. width:120rpx;
  343. line-height:42rpx;
  344. border:4rpx solid #0183FA;
  345. border-radius:30rpx;
  346. color: #0183FA !important;
  347. font-size: 24rpx;
  348. text-align center !important;
  349. margin:20rpx 0 20rpx 0;
  350. }
  351. }
  352. >view:nth-last-child(1){
  353. border-bottom:none;
  354. }
  355. }
  356. }
  357. </style>