safetyWarnAnalysis.vue 6.6 KB

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