warnAnalysis.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <div class="warnAnalysis">
  3. <div class="warn-search">
  4. <a-row>
  5. <a-col :span="4">
  6. <span class="search-label">查询设备:</span>
  7. <a-select v-model:value="dataTypeName" style="width: 220px" placeholder="请选择查询设备">
  8. <a-select-option v-for="item in deviceOptions" :key="item" :value="item.value">{{ item.label
  9. }}</a-select-option>
  10. </a-select>
  11. </a-col>
  12. <a-col :span="4">
  13. <span class="search-label">开始时间:</span>
  14. <a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" placeholder="开始时间"
  15. v-model:value="startTime" style="width: 220px" />
  16. </a-col>
  17. <a-col :span="4">
  18. <span class="search-label">结束时间:</span>
  19. <a-date-picker show-time valueFormat="YYYY-MM-DD HH:mm:ss" placeholder="结束时间"
  20. v-model:value="endTime" style="width: 220px" />
  21. </a-col>
  22. <a-col :span="4">
  23. <a-button type="primary" preIcon="ant-design:search-outlined" style="margin-left:15px"
  24. @click="getSearch">查询</a-button>
  25. </a-col>
  26. </a-row>
  27. </div>
  28. <div class="warn-tag" v-if="typeList.length != 0">
  29. <div :class="activeIndex == index ? 'tag-item-Y' : 'tag-item-N'" v-for="(item, index) in typeList"
  30. :key="index" @click="typeClick(index)">
  31. <div class="item-value">{{ item.label }}</div>
  32. <div class="item-label">{{ item.value }}</div>
  33. </div>
  34. </div>
  35. <div class="warn-content">
  36. <a-spin :spinning="loading">
  37. <a-table :columns="analysisColumns" :data-source="tableData" size="small" :scroll="{ y: 500 }"
  38. class="tableW" :pagination="pagination" @change="changePaper">
  39. <template #bodyCell="{ column, text }"></template>
  40. </a-table>
  41. </a-spin>
  42. </div>
  43. </div>
  44. </template>
  45. <script setup lang="ts">
  46. import { ref, reactive, onMounted } from 'vue'
  47. import { analysisColumns } from './comment.data'
  48. import { defHttp } from '/@/utils/http/axios';
  49. import dayjs from 'dayjs';
  50. import { message } from 'ant-design-vue';
  51. import ceshi from './ceshi.json'
  52. let props = defineProps({
  53. deviceType: {
  54. type: String,
  55. required: true,
  56. },
  57. })
  58. const getAlarmHistoryDataCount = (params) => defHttp.post({ url: '/ventanaly-device/monitor/history/getAlarmHistoryDataCount', params })
  59. const getDeviceListApi = (params) => defHttp.post({ url: '/monitor/device', params });
  60. let loading=ref(false)
  61. let dataTypeName = ref('')
  62. let startTime = ref(dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'))
  63. let endTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
  64. //设备下拉选项列表
  65. let deviceOptions = ref<any[]>([])
  66. let typeList = ref<any[]>([])
  67. let activeIndex = ref(0)
  68. let pagination = reactive({
  69. current: 1, // 当前页码
  70. pageSize: 10, // 每页显示条数
  71. total: 0, // 总条目数,后端返回
  72. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  73. showSizeChanger: true, // 是否可改变每页显示条数
  74. pageSizeOptions: ['10', '20', '50'], // 可选的每页显示条数
  75. });
  76. let tableData = ref<any[]>([])
  77. //查询
  78. async function getSearch() {
  79. if (dataTypeName.value) {
  80. loading.value=true
  81. let res = await getAlarmHistoryDataCount({
  82. "pageNo": pagination.current,
  83. "pageSize": pagination.pageSize,
  84. "startTime": startTime.value,
  85. "endTime": endTime.value,
  86. "dataTypeName": dataTypeName.value
  87. })
  88. if(res){
  89. loading.value=false
  90. let data = res.result
  91. typeList.value = Object.keys(data.exceptionType).map(el => {
  92. return {
  93. label: el,
  94. value: data.exceptionType[el].count || 0
  95. }
  96. })
  97. tableData.value = data.exceptionType[typeList.value[activeIndex.value].label]['records']
  98. pagination.total = typeList.value[activeIndex.value].value
  99. }
  100. } else {
  101. message.warning('请选择设备类型!')
  102. }
  103. }
  104. //选项切换
  105. function typeClick(index) {
  106. activeIndex.value = index
  107. pagination.current = 1
  108. getSearch()
  109. }
  110. //分页切换
  111. function changePaper(val) {
  112. pagination.current = val.current
  113. pagination.pageSize = val.pageSize
  114. getSearch()
  115. }
  116. async function getDeviceList() {
  117. if (props.deviceType.split('_')[1] && props.deviceType.split('_')[1] === 'history') return;
  118. let result
  119. const res = await getDeviceListApi({ devicetype: props.deviceType, pageSize: 10000 });
  120. if (res['records'] && res['records'].length > 0) {
  121. result = res['records'];
  122. } else if (res['msgTxt'] && res['msgTxt'][0] && res['msgTxt'][0]['datalist']) {
  123. result = res['msgTxt'][0]['datalist'];
  124. }
  125. if (result) {
  126. deviceOptions.value = result.map((item) => {
  127. return {
  128. label: item['strinstallpos'],
  129. value: item['id'] || item['deviceID'],
  130. // strtype: item['strtype'],
  131. // strinstallpos: item['strinstallpos'],
  132. // devicekind: item['devicekind'],
  133. // stationtype: item['stationtype'],
  134. };
  135. });
  136. // console.log( deviceOptions.value,'deviceOptions.value')
  137. }
  138. }
  139. onMounted(() => {
  140. getDeviceList()
  141. // getSearch()
  142. })
  143. </script>
  144. <style lang="less" scoped>
  145. .warnAnalysis {
  146. position: relative;
  147. width: 100%;
  148. height: 100%;
  149. .warn-search {
  150. display: flex;
  151. align-items: center;
  152. height: 30px;
  153. margin: 15px;
  154. .search-label {
  155. width: 75px;
  156. font-size: 14px;
  157. color: #fff;
  158. }
  159. }
  160. .warn-tag {
  161. height: 130px;
  162. margin: 15px;
  163. display: flex;
  164. justify-content: center;
  165. align-items: center;
  166. .tag-item-N {
  167. position: relative;
  168. width: 215px;
  169. height: 128px;
  170. margin:0px 120px;
  171. background: url('../../../../assets/images/choice-N.png') no-repeat center;
  172. background-size: 100%;
  173. }
  174. .tag-item-Y {
  175. position: relative;
  176. width: 215px;
  177. height: 128px;
  178. margin:0px 120px;
  179. background: url('../../../../assets/images/choice-Y.png') no-repeat center;
  180. background-size: 100%;
  181. }
  182. .item-label {
  183. position: absolute;
  184. left: 50%;
  185. transform: translate(-50%, 0);
  186. top: 80px;
  187. color: #3df6ff;
  188. // font-size: 18px;
  189. font-family: 'douyuFont';
  190. }
  191. .item-value {
  192. position: absolute;
  193. left: 50%;
  194. transform: translate(-50%, 0%);
  195. top: 25px;
  196. font-size: 18px;
  197. color: #fff;
  198. }
  199. }
  200. .warn-content {
  201. margin: 15px;
  202. }
  203. .zxm-row {
  204. width: 100%;
  205. }
  206. }
  207. ::v-deep .zxm-tag {
  208. font-size: 14px;
  209. padding: 0px 20px;
  210. line-height: 28px;
  211. background: linear-gradient(#2cd1ff55, #1eb0ff55);
  212. border-color: #74e9fe;
  213. color: #fff;
  214. }
  215. </style>