index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <div class="safetyList">
  3. <customHeader>监控分站管理</customHeader>
  4. <div class="content">
  5. <div class="left-box">
  6. <div class="left-title">
  7. <div class="title-fz">
  8. <span>分站:</span>
  9. <span>
  10. [通讯正常]
  11. <span class="zd-open">{{ openNum || 0 }}</span>
  12. </span>
  13. <span>
  14. [通讯中断]
  15. <span class="zd-close">{{ clsoeNum || 0 }}</span>
  16. </span>
  17. </div>
  18. <!-- <div class="title-cd">
  19. <span>测点:</span>
  20. <span>
  21. [通讯正常]
  22. <span class="zd-open">407</span>
  23. </span>
  24. <span>
  25. [通讯中断]
  26. <span class="zd-close">0</span>
  27. </span>
  28. </div> -->
  29. </div>
  30. <div class="left-content">
  31. <div class="card-box" v-for="(item, index) in cardList" :key="index">
  32. <div :class="item.isNewAccess ? 'card-itemN' : item.linkstatus ? 'card-itemL' : 'card-itemD'"
  33. @click="cardClick(item, index)">
  34. <div class="card-item-label">{{ item.strname }}</div>
  35. </div>
  36. <div :class="activeIndex % 4 == 3 ? 'card-modal1' : 'card-modal'" v-if="activeIndex == index && isShow">
  37. <div class="modal-name">站点名称:</div>
  38. <a-input v-model:value="stationName" size="small" placeholder="请输入" @blur="changeName" />
  39. <div class="modal-lj">连接状态:</div>
  40. <a-radio-group v-model:value="stationStatus" size="small" :options="ljList" @change="changeStatus" />
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <div class="right-box">
  46. <div class="right-title">详细信息:</div>
  47. <a-table size="small" :scroll="{ y: 710 }" :columns="columns" :data-source="tableData" :pagination="pagination"
  48. @change="pageChange">
  49. <template #action="{ record }">
  50. <a-button v-if="!record.devInfoList" type="primary" style="margin-right:10px" :disabled="record.linkId != '0'" size="small"
  51. @click="handlerunDeviceMonitor(record, '启动')">启动</a-button>
  52. <a-button type="success" size="small" @click="handlerunDeviceMonitor(record, '编辑')">编辑</a-button>
  53. </template>
  54. <template #bodyCell="{ column, text }">
  55. <template v-if="column.dataIndex === 'valueJc' && text">
  56. <div v-for="item in text.split(',')" :key="item">
  57. <span v-if="item.substring(item.indexOf(':') + 1) && !isNaN(parseFloat(item.substring(item.indexOf(':') + 1)))"
  58. style="display: inline-block;width: 45%;text-align: right; color:rgb(0, 242, 255);margin-right:5px">{{
  59. item.substring(0, item.indexOf(':') + 1) }}</span>
  60. <span v-if="item.substring(item.indexOf(':') + 1) && !isNaN(parseFloat(item.substring(item.indexOf(':') + 1)))"
  61. style="display: inline-block; width:50%;text-align: left; color:#fff">{{
  62. item.substring(item.indexOf(':') + 1)==='1' ? '正风' : item.substring(item.indexOf(':') + 1)==='2' ? '反风' : item.substring(item.indexOf(':') + 1) }} </span>
  63. </div>
  64. </template>
  65. </template>
  66. </a-table>
  67. <!-- 一键启动弹窗 -->
  68. <a-modal style="top:300px;left:360px" v-model:visible="visibleModal" :width="450" title="一键启动" @ok="handleOk"
  69. @cancel="handleCancel">
  70. <a-form :model="startupData" labelAlign="right" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }">
  71. <a-form-item label="安装位置">
  72. <a-input v-model:value="startupData.address" placeholder="请输入" style="width: 260px" />
  73. </a-form-item>
  74. </a-form>
  75. </a-modal>
  76. <!-- 编辑弹窗 -->
  77. <a-modal style="top:300px;left:360px" v-model:visible="visibleModalEdit" :width="450" title="编辑信息"
  78. @ok="handleOkEdit" @cancel="handleCancelEdit">
  79. <a-form :model="startupDataEdit" labelAlign="right" :label-col="{ span: 8 }" :wrapper-col="{ span: 16 }">
  80. <a-form-item label="安装位置">
  81. <a-input v-model:value="startupDataEdit.address" placeholder="请输入" style="width: 260px" />
  82. </a-form-item>
  83. </a-form>
  84. </a-modal>
  85. </div>
  86. </div>
  87. </div>
  88. </template>
  89. <script setup lang="ts">
  90. import { ref, nextTick, reactive, onMounted, onUnmounted } from 'vue';
  91. import customHeader from '/@/components/vent/customHeader.vue';
  92. import { subStationList, getList, getEdit, runDeviceMonitor, update158DevName } from './safetyList.api';
  93. import { columns } from './safetyList.data'
  94. let paramId = ref('')
  95. let isShow = ref(false)
  96. let stationName = ref('')
  97. let stationStatus = ref(null)
  98. let stationId = ref(null)
  99. let ljList = reactive<any[]>([
  100. { value: 0, label: '断开' },
  101. { value: 1, label: '连接' }
  102. ])
  103. let activeIndex = ref(null)
  104. let cardList = ref<any[]>()
  105. let openNum = ref(0)
  106. let clsoeNum = ref(0)
  107. //分页参数配置
  108. let pagination = reactive({
  109. current: 1, // 当前页码
  110. pageSize: 20, // 每页显示条数
  111. total: 0, // 总条目数,后端返回
  112. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  113. showSizeChanger: true, // 是否可改变每页显示条数
  114. pageSizeOptions: ['10', '20', '30', '40', '50', '100'], // 可选的每页显示条数
  115. });
  116. let tableData = ref<any[]>([])
  117. //一键启动弹窗
  118. let visibleModal = ref(false);
  119. let startupData = reactive({
  120. address: '',
  121. })
  122. let devId = ref('')
  123. //编辑弹窗
  124. let visibleModalEdit = ref(false)
  125. let startupDataEdit = reactive({
  126. address: ''
  127. })
  128. // https获取监测数据
  129. let timer: null | NodeJS.Timeout = null;
  130. function getMonitor(flag = false) {
  131. timer = setTimeout(
  132. async () => {
  133. // await getSubStationList()
  134. await getStationList()
  135. if (timer) {
  136. timer = null;
  137. }
  138. getMonitor();
  139. },
  140. flag ? 0 : 5000
  141. );
  142. }
  143. //获取分站信息
  144. async function getSubStationList() {
  145. let res = await subStationList({ strtype: "modbus" })
  146. console.log(res, '分站-----------')
  147. if (res.length != 0) {
  148. cardList.value = res
  149. openNum.value = cardList.value?.filter(v => v.linkstatus == 1)['length']
  150. clsoeNum.value = cardList.value?.filter(v => v.linkstatus == 0)['length']
  151. } else {
  152. cardList.value = []
  153. }
  154. }
  155. //站点选项点击
  156. function cardClick(item, index) {
  157. console.log(item, '站点选项------------')
  158. activeIndex.value = item.isNewAccess ? index : null
  159. stationName.value = item.strname
  160. stationStatus.value = item.linkstatus
  161. stationId.value = item.id
  162. isShow.value = true
  163. getStationList()
  164. }
  165. //站点名称编辑
  166. function changeName(val) {
  167. getChangeStation()
  168. }
  169. //站点连接状态修改
  170. function changeStatus(val) {
  171. getChangeStation()
  172. }
  173. async function getChangeStation() {
  174. let res = await getEdit({ id: stationId.value, strname: stationName.value, linkstatus: stationStatus.value })
  175. console.log(res, '站点编辑')
  176. getSubStationList()
  177. isShow.value = false
  178. }
  179. //获取详细信息列表
  180. async function getStationList() {
  181. let res = await getList({ subId: stationId.value, pageNo: pagination.current, pageSize: pagination.pageSize, })
  182. console.log(res, '详细信息列表--------')
  183. res.forEach(el => {
  184. el.key = el.id
  185. el.linkstatusC = el.linkstatus ? '连接' : '未连接'
  186. el.children = el.devInfoList
  187. el.children.forEach(v => {
  188. v.key = v.id
  189. v.linkstatus = v.linkId
  190. v.linkstatusC = v.linkstatus == '0' ? '待启用' : v.linkstatus == '1' ? '连接' : '断开'
  191. v.updateTime = v.time
  192. v.valueJc = `风向:${v.forward || ''},风量:${v.m3 || ''}m³/min,风速:${v.windSpeed || ''}m/s,气压:${v.difPress || ''}Pa,温度:${v.temperature || ''}℃,湿度:${v.humidity || ''}%,断面积:${v.area || ''}㎡`
  193. })
  194. })
  195. tableData.value = res
  196. pagination.total = res.total
  197. }
  198. //分页切换
  199. function pageChange(val) {
  200. pagination.current = val.current;
  201. pagination.pageSize = val.pageSize;
  202. getStationList();
  203. }
  204. //启动新设备
  205. function handlerunDeviceMonitor(record, val) {
  206. devId.value = record.id
  207. switch (val) {
  208. case '编辑':
  209. visibleModalEdit.value = true
  210. startupDataEdit.address = record.strinstallpos
  211. paramId.value = record.devInfoList ? 'subId' : 'devId'
  212. break;
  213. case '启动':
  214. visibleModal.value = true
  215. startupData.address = record.strinstallpos
  216. break;
  217. }
  218. }
  219. async function handleOk() {
  220. let res = await runDeviceMonitor({ devId: devId.value, devName: startupData.address })
  221. console.log(res, '新设备启动---')
  222. visibleModal.value = false
  223. getStationList();
  224. }
  225. function handleCancel() {
  226. visibleModal.value = false
  227. startupData.address = ''
  228. }
  229. //编辑
  230. async function handleOkEdit() {
  231. if (paramId.value == 'subId') {
  232. let res = await update158DevName({ subId: devId.value, devName: startupDataEdit.address })
  233. console.log(res, '设备名称编辑---')
  234. visibleModalEdit.value = false
  235. getStationList();
  236. } else {
  237. let res = await update158DevName({ devId: devId.value, devName: startupDataEdit.address })
  238. console.log(res, '设备名称编辑---')
  239. visibleModalEdit.value = false
  240. getStationList();
  241. }
  242. }
  243. //取消编辑
  244. function handleCancelEdit() {
  245. visibleModalEdit.value = false
  246. startupDataEdit.address = ''
  247. }
  248. onMounted(() => {
  249. getSubStationList()
  250. getMonitor(true);
  251. })
  252. onUnmounted(() => {
  253. if (timer) {
  254. clearTimeout(timer);
  255. timer = undefined;
  256. }
  257. });
  258. </script>
  259. <style lang="less" scoped>
  260. .safetyList {
  261. width: calc(100% - 20px);
  262. height: calc(100% - 90px);
  263. position: relative;
  264. margin: 80px 10px 10px 10px;
  265. .content {
  266. position: relative;
  267. width: 100%;
  268. height: 100%;
  269. display: flex;
  270. justify-content: space-between;
  271. align-items: center;
  272. .left-box {
  273. width: 40%;
  274. height: 100%;
  275. margin-right: 15px;
  276. padding: 10px;
  277. box-sizing: border-box;
  278. background: url('@/assets/images/fire/bj1.png') no-repeat center;
  279. background-size: 100% 100%;
  280. .left-title {
  281. display: flex;
  282. height: 30px;
  283. align-items: center;
  284. font-size: 14px;
  285. margin-bottom: 10px;
  286. span {
  287. color: #fff;
  288. }
  289. .zd-open {
  290. color: rgb(0, 242, 255);
  291. }
  292. .zd-close {
  293. color: #ff0000;
  294. }
  295. .title-fz {
  296. margin-right: 25px;
  297. }
  298. }
  299. .left-content {
  300. display: flex;
  301. justify-content: flex-start;
  302. align-items: flex-start;
  303. flex-wrap: wrap;
  304. height: calc(100% - 40px);
  305. overflow-y: auto;
  306. .card-box {
  307. position: relative;
  308. // width: 242px;
  309. width: 182px;
  310. height: 110px;
  311. margin-bottom: 15px;
  312. display: flex;
  313. justify-content: center;
  314. .card-itemN {
  315. position: relative;
  316. width: 85px;
  317. height: 110px;
  318. background: url('../../../assets/images/zd-2.png') no-repeat center;
  319. background-size: 100% 100%;
  320. cursor: pointer;
  321. .card-item-label {
  322. width: 100%;
  323. position: absolute;
  324. bottom: 5px;
  325. font-size: 12px;
  326. color: #fff;
  327. text-align: center;
  328. }
  329. }
  330. .card-itemL {
  331. position: relative;
  332. width: 85px;
  333. height: 110px;
  334. background: url('../../../assets/images/zd-3.png') no-repeat center;
  335. background-size: 100% 100%;
  336. cursor: pointer;
  337. .card-item-label {
  338. width: 100%;
  339. position: absolute;
  340. bottom: 5px;
  341. font-size: 12px;
  342. color: #fff;
  343. text-align: center;
  344. }
  345. }
  346. .card-itemD {
  347. position: relative;
  348. width: 85px;
  349. height: 110px;
  350. background: url('../../../assets/images/zd-1.png') no-repeat center;
  351. background-size: 100% 100%;
  352. cursor: pointer;
  353. .card-item-label {
  354. width: 100%;
  355. position: absolute;
  356. bottom: 5px;
  357. font-size: 12px;
  358. color: #fff;
  359. text-align: center;
  360. }
  361. }
  362. .card-modal {
  363. width: 86px;
  364. position: absolute;
  365. left: 140px;
  366. color: #FFF;
  367. top: 50%;
  368. transform: translate(0, -50%);
  369. font-size: 12px;
  370. }
  371. .card-modal1 {
  372. width: 86px;
  373. position: absolute;
  374. left: -42px;
  375. color: #FFF;
  376. top: 50%;
  377. transform: translate(0, -50%);
  378. font-size: 12px;
  379. }
  380. }
  381. }
  382. }
  383. .right-box {
  384. width: calc(60% - 15px);
  385. height: 100%;
  386. padding: 10px;
  387. box-sizing: border-box;
  388. background: url('@/assets/images/fire/bj1.png') no-repeat center;
  389. background-size: 100% 100%;
  390. .right-title {
  391. display: flex;
  392. height: 30px;
  393. align-items: center;
  394. font-size: 14px;
  395. color: #fff;
  396. margin-bottom: 10px;
  397. }
  398. }
  399. }
  400. }
  401. .zxm-form {
  402. padding-top: 20px !important;
  403. box-sizing: border-box;
  404. }
  405. ::v-deep(.zxm-radio-wrapper) {
  406. font-size: 12px;
  407. }
  408. ::v-deep(.zxm-input) {
  409. font-size: 12px;
  410. }
  411. </style>