warnAnalysis.vue 6.8 KB

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