warnAnalysis.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. let props = defineProps({
  52. deviceType: {
  53. type: String,
  54. required: true,
  55. },
  56. })
  57. const getAlarmHistoryDataCount = (params) => defHttp.post({ url: '/ventanaly-device/monitor/history/getAlarmHistoryDataCount', params })
  58. const getDeviceListApi = (params) => defHttp.post({ url: '/monitor/device', params });
  59. let loading=ref(false)
  60. let dataTypeName = ref('')
  61. let startTime = ref(dayjs().add(-30, 'day').format('YYYY-MM-DD HH:mm:ss'))
  62. let endTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'))
  63. //设备下拉选项列表
  64. let deviceOptions = ref<any[]>([])
  65. let typeList = ref<any[]>([])
  66. let activeIndex = ref(0)
  67. let pagination = reactive({
  68. current: 1, // 当前页码
  69. pageSize: 10, // 每页显示条数
  70. total: 0, // 总条目数,后端返回
  71. // showTotal: (total, range) => `${range[0]}-${range[1]} 条,总共 ${total} 条`, // 分页右下角显示信息
  72. showSizeChanger: true, // 是否可改变每页显示条数
  73. pageSizeOptions: ['10', '20', '50'], // 可选的每页显示条数
  74. });
  75. let tableData = ref<any[]>([])
  76. //查询
  77. async function getSearch() {
  78. if (dataTypeName.value) {
  79. loading.value=true
  80. let res = await getAlarmHistoryDataCount({
  81. "pageNo": pagination.current,
  82. "pageSize": pagination.pageSize,
  83. "startTime": startTime.value,
  84. "endTime": endTime.value,
  85. "dataTypeName": dataTypeName.value
  86. })
  87. if(res){
  88. loading.value=false
  89. let data = res.result
  90. typeList.value = Object.keys(data.exceptionType).map(el => {
  91. return {
  92. label: el,
  93. value: data.exceptionType[el].count || 0
  94. }
  95. })
  96. tableData.value = data.exceptionType[typeList.value[activeIndex.value].label]['records']
  97. pagination.total = typeList.value[activeIndex.value].value
  98. }
  99. } else {
  100. message.warning('请选择设备类型!')
  101. }
  102. }
  103. //选项切换
  104. function typeClick(index) {
  105. activeIndex.value = index
  106. pagination.current = 1
  107. getSearch()
  108. }
  109. //分页切换
  110. function changePaper(val) {
  111. pagination.current = val.current
  112. pagination.pageSize = val.pageSize
  113. getSearch()
  114. }
  115. async function getDeviceList() {
  116. if (props.deviceType.split('_')[1] && props.deviceType.split('_')[1] === 'history') return;
  117. let result
  118. const res = await getDeviceListApi({ devicetype: props.deviceType, pageSize: 10000 });
  119. if (res['records'] && res['records'].length > 0) {
  120. result = res['records'];
  121. } else if (res['msgTxt'] && res['msgTxt'][0] && res['msgTxt'][0]['datalist']) {
  122. result = res['msgTxt'][0]['datalist'];
  123. }
  124. if (result) {
  125. deviceOptions.value = result.map((item) => {
  126. return {
  127. label: item['strinstallpos'],
  128. value: item['id'] || item['deviceID'],
  129. // strtype: item['strtype'],
  130. // strinstallpos: item['strinstallpos'],
  131. // devicekind: item['devicekind'],
  132. // stationtype: item['stationtype'],
  133. };
  134. });
  135. // console.log( deviceOptions.value,'deviceOptions.value')
  136. }
  137. }
  138. onMounted(() => {
  139. getDeviceList()
  140. // getSearch()
  141. })
  142. </script>
  143. <style lang="less" scoped>
  144. .warnAnalysis {
  145. position: relative;
  146. width: 100%;
  147. height: 100%;
  148. .warn-search {
  149. display: flex;
  150. align-items: center;
  151. height: 30px;
  152. margin: 15px;
  153. .search-label {
  154. width: 75px;
  155. font-size: 14px;
  156. color: #fff;
  157. }
  158. }
  159. .warn-tag {
  160. height: 130px;
  161. margin: 15px;
  162. display: flex;
  163. justify-content: center;
  164. align-items: center;
  165. .tag-item-N {
  166. position: relative;
  167. width: 215px;
  168. height: 128px;
  169. margin:0px 120px;
  170. background: url('../../../../assets/images/choice-N.png') no-repeat center;
  171. background-size: 100%;
  172. }
  173. .tag-item-Y {
  174. position: relative;
  175. width: 215px;
  176. height: 128px;
  177. margin:0px 120px;
  178. background: url('../../../../assets/images/choice-Y.png') no-repeat center;
  179. background-size: 100%;
  180. }
  181. .item-label {
  182. position: absolute;
  183. left: 50%;
  184. transform: translate(-50%, 0);
  185. top: 80px;
  186. color: #3df6ff;
  187. // font-size: 18px;
  188. font-family: 'douyuFont';
  189. }
  190. .item-value {
  191. position: absolute;
  192. left: 50%;
  193. transform: translate(-50%, 0%);
  194. top: 25px;
  195. font-size: 18px;
  196. color: #fff;
  197. }
  198. }
  199. .warn-content {
  200. margin: 15px;
  201. }
  202. .zxm-row {
  203. width: 100%;
  204. }
  205. }
  206. ::v-deep .zxm-tag {
  207. font-size: 14px;
  208. padding: 0px 20px;
  209. line-height: 28px;
  210. background: linear-gradient(#2cd1ff55, #1eb0ff55);
  211. border-color: #74e9fe;
  212. color: #fff;
  213. }
  214. </style>