index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <div class="app-container alarmingManage" v-if="pageShow">
  3. <!-- 筛选start -->
  4. <div class="filter-container mb-10">
  5. <div class="left">
  6. <div>
  7. <div class="filter-item">
  8. 站点:
  9. <el-select
  10. v-model="store.state.siteId"
  11. placeholder="请选择"
  12. style="width: 200px"
  13. clearable
  14. filterable
  15. >
  16. <el-option
  17. v-for="item in store.state.siteList"
  18. :key="item.id"
  19. :label="item.siteName"
  20. :value="item.id"
  21. ></el-option>
  22. </el-select>
  23. </div>
  24. <div class="filter-item">
  25. 时间:
  26. <el-date-picker
  27. v-model="dateValue"
  28. type="datetimerange"
  29. range-separator="至"
  30. start-placeholder="开始日期"
  31. end-placeholder="结束日期"
  32. style="width: auto"
  33. ></el-date-picker>
  34. </div>
  35. <el-button
  36. class="search-button"
  37. @click=";(store.state.siteId = ''), (dateValue = ''), listSelect()"
  38. >
  39. 重置
  40. </el-button>
  41. <el-button type="primary" class="search-button" @click="listSelect()">
  42. 搜索
  43. </el-button>
  44. </div>
  45. </div>
  46. </div>
  47. <!-- 筛选end -->
  48. <!-- 表格start -->
  49. <el-table
  50. :data="tableData"
  51. border
  52. stripe
  53. :header-cell-style="headClass"
  54. :cell-style="cellStyle"
  55. class="alarmingTable"
  56. >
  57. <el-table-column prop="siteName" label="站点名称" width="">
  58. <template #default="scope">
  59. <div @click="handleClick(scope.row)">{{ scope.row.siteName }}</div>
  60. </template>
  61. </el-table-column>
  62. <el-table-column prop="totalGrade" label="总数">
  63. <template #default="scope">
  64. <span
  65. class="gradualBg total"
  66. :class="{ transparent: scope.row.totalGrade == 0 }"
  67. :style="{
  68. width:
  69. (scope.row.totalGrade / allMaxData.totalNumMax) * 100 + '%',
  70. }"
  71. style="min-width:35px!important"
  72. @click="goAlarmTotal(0, scope.row.siteName, scope.row.siteId)"
  73. >
  74. {{ scope.row.totalGrade }}
  75. </span>
  76. </template>
  77. </el-table-column>
  78. <el-table-column prop="oneGrade" label="一级告警" width="">
  79. <template #default="scope">
  80. <span
  81. class="gradualBg"
  82. :class="{ transparent: scope.row.oneGrade == 0 }"
  83. :style="{
  84. width:
  85. (scope.row.oneGrade / allMaxData.oneAlarmingMax) * 100 + '%',
  86. }"
  87. style="min-width:35px!important"
  88. @click="goAlarmTotal(1, scope.row.siteName, scope.row.siteId)"
  89. >
  90. {{ scope.row.oneGrade }}
  91. </span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column prop="twoGrade" label="二级告警" width="">
  95. <template #default="scope">
  96. <span
  97. class="gradualBg"
  98. :class="{ transparent: scope.row.twoGrade == 0 }"
  99. :style="{
  100. width:
  101. (scope.row.twoGrade / allMaxData.twoAlarmingMax) * 100 + '%'
  102. }"
  103. style="min-width:35px!important"
  104. @click="goAlarmTotal(2, scope.row.siteName, scope.row.siteId)"
  105. >
  106. {{ scope.row.twoGrade }}
  107. </span>
  108. </template>
  109. </el-table-column>
  110. <!-- <el-table-column prop="other" label="其他" width=""></el-table-column> -->
  111. <el-table-column prop="otherGrade" label="其他" width="">
  112. <template #default="scope">
  113. <span
  114. class="gradualBg"
  115. :class="{ transparent: scope.row.otherGrade == 0 }"
  116. :style="{
  117. width: (scope.row.otherGrade / allMaxData.otherMax) * 100 + '%',
  118. }"
  119. @click="goAlarmTotal(3, scope.row.siteName, scope.row.siteId)"
  120. >
  121. {{ scope.row.otherGrade }}
  122. </span>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <!-- 表格end -->
  127. <!-- 分页start -->
  128. <div class="paginationBlock">
  129. <el-pagination
  130. @size-change="handleSizeChange"
  131. @current-change="handleCurrentChange"
  132. :current-page="currentPage"
  133. :page-sizes="[15, 20, 25, 30]"
  134. :page-size="pageSize"
  135. layout="total, sizes, prev, pager, next, jumper"
  136. :total="total"
  137. ></el-pagination>
  138. </div>
  139. <!-- 分页end -->
  140. <!-- {{ totalNumMax }}
  141. {{ oneAlarmingMax }} -->
  142. </div>
  143. <alarm-total
  144. v-else
  145. :pageShow="pageShow"
  146. @func="goAlarmTotal"
  147. :alarmGradeList="alarmGradeList"
  148. ></alarm-total>
  149. </template>
  150. <script>
  151. import alarmTotal from './alarmTotal'
  152. import { useStore } from 'vuex'
  153. import { computed, defineComponent, onMounted, ref } from 'vue'
  154. import * as api from '@/api/alarmManage/index'
  155. import { ElMessage } from 'element-plus'
  156. import { useRouter } from 'vue-router'
  157. export default defineComponent({
  158. components: { alarmTotal },
  159. name: 'VariableList',
  160. setup() {
  161. const store = useStore()
  162. const router = useRouter()
  163. const pageShow = ref(true)
  164. const alarmGradeList = ref({})
  165. // const dateValue = ref([new Date(2020, 10, 10, 10, 10), new Date()])
  166. const dateValue = ref('')
  167. const total = ref(0)
  168. const pageSize = ref(15)
  169. const currentPage = ref(1)
  170. const tableData = ref([])
  171. //查询
  172. function listSelect() {
  173. store.commit('TimeAll_function', dateValue.value)
  174. api
  175. .alarmGradeCount({
  176. startTime: store.state.Time_Data[0],
  177. endTime: store.state.Time_Data[1],
  178. siteId: store.state.siteId,
  179. size: pageSize.value,
  180. current: currentPage.value,
  181. })
  182. .then((requset) => {
  183. if (requset.status === 'SUCCESS') {
  184. total.value = requset.data.total
  185. tableData.value = requset.data.records
  186. } else {
  187. ElMessage.error(requset.msg)
  188. }
  189. })
  190. }
  191. //查看
  192. const handleClick = (row) => {
  193. // alert('查看对应站点(页面跳转)')
  194. console.log(row)
  195. }
  196. const goVariableList = () => {
  197. // 跳转至订单列表页面传参
  198. router.push({
  199. path: '../siteManage/variableList/index.vue',
  200. })
  201. // this.$router.push({ name:'variableList'})
  202. }
  203. const goAlarmTotal = (val, val1, val2) => {
  204. pageShow.value = !pageShow.value
  205. store.commit('TimeAll_function', dateValue.value)
  206. if (val != undefined) {
  207. alarmGradeList.value = {
  208. startTime: store.state.Time_Data[0],
  209. endTime: store.state.Time_Data[1],
  210. type: val,
  211. siteName: val1,
  212. siteId: val2,
  213. }
  214. }
  215. }
  216. onMounted(() => {
  217. listSelect()
  218. // console.log(store, router)
  219. })
  220. //条数
  221. const handleSizeChange = (val) => {
  222. pageSize.value = val
  223. listSelect()
  224. }
  225. //页数
  226. const handleCurrentChange = (val) => {
  227. currentPage.value = val
  228. listSelect()
  229. }
  230. const allMaxData = computed(() => {
  231. var allMaxData = {}
  232. var totalNumData = []
  233. var oneAlarmingData = []
  234. var twoAlarmingData = []
  235. var otherData = []
  236. tableData.value.forEach((element, index) => {
  237. totalNumData[index] = element.totalGrade
  238. oneAlarmingData[index] = element.oneGrade
  239. twoAlarmingData[index] = element.twoGrade
  240. otherData[index] = element.otherGrade
  241. })
  242. allMaxData.totalNumMax = Math.max.apply(Math, totalNumData)
  243. allMaxData.oneAlarmingMax = Math.max.apply(Math, oneAlarmingData)
  244. allMaxData.twoAlarmingMax = Math.max.apply(Math, twoAlarmingData)
  245. allMaxData.otherMax = Math.max.apply(Math, otherData)
  246. return allMaxData
  247. })
  248. //自定义列样式
  249. const cellStyle = ({ row, column, rowIndex, columnIndex }) => {
  250. row, column, rowIndex
  251. // console.log(row, column, rowIndex)
  252. if (columnIndex !== 0) {
  253. return `color:#0284E8;cursor:pointer`
  254. }
  255. if (columnIndex) {
  256. // return `text-align:left;cursor:pointer;`
  257. } else {
  258. return ''
  259. }
  260. }
  261. // 表头样式设置
  262. const headClass = () => {
  263. return 'background:#FAFAFA;'
  264. }
  265. return {
  266. headClass,
  267. goVariableList,
  268. handleCurrentChange,
  269. handleSizeChange,
  270. cellStyle,
  271. handleClick,
  272. goAlarmTotal,
  273. listSelect,
  274. store,
  275. pageShow,
  276. dateValue,
  277. total,
  278. pageSize,
  279. currentPage,
  280. tableData,
  281. alarmGradeList,
  282. showDialog: false,
  283. tabPosition: 'one',
  284. input: '',
  285. region: '',
  286. allMaxData,
  287. }
  288. },
  289. })
  290. </script>
  291. <style lang="scss" scoped>
  292. </style>