index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <div class="dustAtomizing">
  3. <div class="dustAto-right-box">
  4. <div class="search-area">
  5. <Form :model="formState" :label-col="{ span: 1.5 }">
  6. <FormItem label="设备名称 : ">
  7. <a-input v-model:value="formState.devicename" clearable placeholder="请输入..."
  8. style="width:240px;margin-right: 20px;" />
  9. </FormItem>
  10. <FormItem label="">
  11. <a-button type="primary" style="height: 30px;margin: 0 10px; padding: 2px 15px;background-color: #227fad;"
  12. @click="getSearch">
  13. <template #icon>
  14. <SearchOutlined />
  15. </template>
  16. 查询
  17. </a-button>
  18. <a-button type="primary" style="height: 30px;margin: 0 10px; padding: 2px 15px;background-color: #227fad;">
  19. <template #icon>
  20. <PlusOutlined />
  21. </template>
  22. 新增
  23. </a-button>
  24. <a-button type="primary" style="height: 30px;margin: 0 10px; padding: 2px 15px;background-color: #227fad;">
  25. 一键开启
  26. </a-button>
  27. <a-button type="primary" style="height: 30px;margin: 0 10px; padding: 2px 15px;background-color: #227fad;">
  28. 一键关闭
  29. </a-button>
  30. <a-button type="primary" style="height: 30px;margin: 0 10px; padding: 2px 15px;background-color: #227fad;">
  31. 自动启停
  32. </a-button>
  33. </FormItem>
  34. </Form>
  35. </div>
  36. <div class="content-area">
  37. <Table class="ant-table-striped" size="small" :dataSource="dataSource" :columns="columns" :scroll="{ y: 720 }"
  38. :pagination="false">
  39. <template #action="{ record }">
  40. <a-button type="link" style="color:#3DF6FF">
  41. 启动
  42. </a-button>
  43. <a-button type="link" style="color:#3DF6FF">
  44. 关闭
  45. </a-button>
  46. <a-button type="link" style="color:#3DF6FF">
  47. 自动
  48. </a-button>
  49. </template>
  50. </Table>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script setup lang="ts">
  56. import { ref, reactive, onMounted, onUnmounted } from 'vue'
  57. import { Form, FormItem, Table } from 'ant-design-vue';
  58. import { SearchOutlined, PlusOutlined } from '@ant-design/icons-vue';
  59. import { realData } from './dustAtomizing.api'
  60. import dayjs from 'dayjs'
  61. //查询条件
  62. let formState = reactive({
  63. devicename: ''
  64. })
  65. //table 数据
  66. let dataSource = reactive<any[]>([])
  67. //table 列
  68. let columns = reactive<any[]>([
  69. {
  70. title: '序号',
  71. width: 60,
  72. align: 'center',
  73. customRender: ({ index }: { index: number }) => `${index + 1}`
  74. },
  75. {
  76. title: '设备名称',
  77. dataIndex: 'deviceName',
  78. key: 'deviceName',
  79. align: 'center',
  80. ellipsis: true,
  81. },
  82. {
  83. title: '安装位置',
  84. dataIndex: 'location',
  85. key: 'location',
  86. align: 'center',
  87. ellipsis: true,
  88. },
  89. {
  90. title: '喷雾状态',
  91. dataIndex: 'stateSpray',
  92. key: 'stateSpray',
  93. width: 100,
  94. align: 'center',
  95. ellipsis: true,
  96. },
  97. {
  98. title: '链接状态',
  99. dataIndex: 'stateConn',
  100. key: 'stateConn',
  101. width: 100,
  102. align: 'center',
  103. ellipsis: true,
  104. },
  105. {
  106. title: '设备状态',
  107. dataIndex: 'deviceState',
  108. key: 'deviceState',
  109. width: 100,
  110. align: 'center',
  111. ellipsis: true,
  112. },
  113. {
  114. title: '使用状态',
  115. dataIndex: 'stateEnable',
  116. key: 'stateEnable',
  117. width: 100,
  118. align: 'center',
  119. ellipsis: true,
  120. },
  121. {
  122. title: '控制状态',
  123. dataIndex: 'stateManual',
  124. key: 'stateManual',
  125. width: 100,
  126. align: 'center',
  127. ellipsis: true,
  128. },
  129. {
  130. title: '粉尘浓度',
  131. dataIndex: 'dust',
  132. key: 'dust',
  133. width: 100,
  134. align: 'center',
  135. ellipsis: true,
  136. },
  137. {
  138. title: '电池电量',
  139. dataIndex: 'batteryLevel',
  140. key: 'batteryLevel',
  141. width: 100,
  142. align: 'center',
  143. ellipsis: true,
  144. },
  145. {
  146. title: '是否定时',
  147. dataIndex: 'timingSwitch',
  148. key: 'timingSwitch',
  149. width: 100,
  150. align: 'center',
  151. ellipsis: true,
  152. },
  153. {
  154. title: '时间',
  155. dataIndex: 'time',
  156. key: 'time',
  157. align: 'center',
  158. ellipsis: true,
  159. },
  160. {
  161. title: '操作',
  162. key: 'action',
  163. width: 300,
  164. slots: { customRender: 'action' },
  165. align: 'center',
  166. },
  167. ])
  168. // https获取监测数据
  169. let timer: null | NodeJS.Timeout = null;
  170. function getMonitor() {
  171. timer = setTimeout(
  172. async () => {
  173. await getList()
  174. if (timer) {
  175. timer = null;
  176. }
  177. getMonitor();
  178. },
  179. 5000
  180. );
  181. }
  182. //获取喷雾列表
  183. async function getList() {
  184. let res = await realData({ deviceName: formState.devicename, type: "DustPw" })
  185. console.log(res, '喷雾列表数据------')
  186. if (res.length != 0) {
  187. dataSource.length = 0
  188. res.forEach(el => {
  189. el.timingSwitch = el.timingSwitch == '1' ? '是' : '否'
  190. el.stateSpray = el.stateSpray == '1' ? '喷雾开' : '喷雾关'
  191. el.stateConn = el.stateConn == '1' ? '链接' : '未链接'
  192. el.deviceState = el.deviceState == '1' ? '喷雾打开' : el.deviceState == '0' ? '喷雾关闭' : '未连接'
  193. el.stateEnable = el.stateEnable == '1' ? '使用' : '未使用'
  194. el.stateManual = el.stateManual == '0' ? '自动控制' : '手动控制'
  195. el.time = dayjs().format('YYYY-MM-DD HH:MM:ss')
  196. dataSource.push(el)
  197. })
  198. }
  199. }
  200. //列表查询
  201. function getSearch() {
  202. getList()
  203. }
  204. onMounted(() => {
  205. getList()
  206. getMonitor()
  207. })
  208. onUnmounted(() => {
  209. if (timer) {
  210. clearTimeout(timer);
  211. timer = null;
  212. }
  213. });
  214. </script>
  215. <style lang="less" scoped>
  216. .dustAtomizing {
  217. display: flex;
  218. position: relative;
  219. align-items: center;
  220. justify-content: space-between;
  221. width: calc(100% - 20px);
  222. // height: calc(100vh - 82px);
  223. height: 863px;
  224. margin: 50px 10px 15px;
  225. background: #282828;
  226. .dustAto-right-box {
  227. box-sizing: border-box;
  228. width: 100%;
  229. height: 100%;
  230. margin-left: 10px;
  231. padding: 15px 10px;
  232. background-color: rgb(27 35 39 / 80%);
  233. .search-area {
  234. display: flex;
  235. box-sizing: border-box;
  236. align-items: center;
  237. height: 70px;
  238. padding: 0 20px;
  239. }
  240. .content-area {
  241. height: calc(100% - 70px);
  242. }
  243. }
  244. }
  245. :deep(.vMonitor-form) {
  246. display: flex;
  247. align-items: center;
  248. width: 100%;
  249. }
  250. :deep(.vMonitor-form-item-label >label) {
  251. color: #fff;
  252. }
  253. :deep(.vMonitor-input) {
  254. padding: 2px 11px;
  255. border-color: #227fad;
  256. background-color: rgb(38 74 96 20%);
  257. color: #fff;
  258. }
  259. :deep(.vMonitor-table) {
  260. background-color: transparent;
  261. color: #fff;
  262. }
  263. :deep(.vMonitor-table-wrapper .vMonitor-table-thead >tr>th) {
  264. padding: 4px 0;
  265. border-bottom: none;
  266. background: rgb(34 127 173/ 50%);
  267. color: #04ffdb;
  268. }
  269. :deep(.vMonitor-table-thead >tr>th:not(:last-child):not(.vMonitor-table-selection-column):not(.vMonitor-table-row-expand-icon-cell):not([colspan])::before) {
  270. background: transparent;
  271. }
  272. :deep(.vMonitor-table-wrapper .vMonitor-table-cell-scrollbar:not([rowspan])) {
  273. box-shadow: none;
  274. }
  275. :deep(.vMonitor-table-wrapper .vMonitor-table:not(.vMonitor-table-bordered) .vMonitor-table-tbody >tr >td) {
  276. border-top: none;
  277. }
  278. :deep(.vMonitor-table.vMonitor-table-small .vMonitor-table-tbody>tr>td) {
  279. padding: 4px 8px;
  280. }
  281. :deep(.vMonitor-table-wrapper .vMonitor-table-tbody >tr >td.vMonitor-table-cell-row-hover) {
  282. background: rgb(38 74 96) !important;
  283. }
  284. :deep(.vMonitor-table-wrapper .vMonitor-table-tbody >tr.vMonitor-table-row:hover>td) {
  285. background: rgb(38 74 96) !important;
  286. }
  287. </style>