bell.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <div id="aiBell w-full" style="width:100%;">
  3. <div class="page-header">
  4. <div class="page-title flex align-center">
  5. <el-button icon="el-icon-back" size="mini" style="font-size: 20px; color: #000;" type="text" @click="toBack" ></el-button>
  6. <el-divider direction="vertical"></el-divider>
  7. 预警中心
  8. </div>
  9. <div class="page-header-btn">
  10. <el-button @click="markAllEventRead">一键忽略</el-button>
  11. <el-tooltip class="item" effect="dark" content="..." placement="left-start">
  12. <el-button icon="el-icon-plus" circle size="mini" ></el-button>
  13. </el-tooltip>
  14. </div>
  15. </div>
  16. <div class="tab-box" style="width: 100%;">
  17. <el-tabs class="tab-switch" v-model="aiTypeVal" @tab-click="handleAiTypeClick">
  18. <el-tab-pane v-for="item in aiTypeArr"
  19. :key="'ai-'+item.val"
  20. :label="item.text"
  21. :name="`${item.val}`"/>
  22. </el-tabs>
  23. <div class="tab-header">
  24. <el-input class=" input-with-select" placeholder="输入算法名片段" v-model="key" >
  25. <el-select v-model="triggerTypeVal"
  26. style="width: 120px;"
  27. slot="prepend"
  28. @change="getNowTriggerType" placeholder="触发类型">
  29. <el-option
  30. :key="'trigger-0'"
  31. label="全部类型"
  32. :value="0">
  33. </el-option>
  34. <el-option
  35. v-for="item in triggerTypeArr"
  36. :key="'trigger-'+item.val"
  37. :label="item.text"
  38. :value="item.val"
  39. :disabled="item.disabled">
  40. </el-option>
  41. </el-select>
  42. </el-input>
  43. <el-select v-model="alarmState" style="width: 120px;"
  44. slot="prepend"
  45. @change="getNowTriggerType" placeholder="已读状态">
  46. <el-option
  47. :key="'read-0'"
  48. label="全部"
  49. :value="0"/>
  50. <el-option
  51. v-for="item in alarmStateArr"
  52. :key="'read-'+item.val"
  53. :label="item.text"
  54. :value="item.val"
  55. :disabled="item.disabled"/>
  56. </el-select>
  57. <el-button slot="append"
  58. style="width: 80px;"
  59. icon="el-icon-search"
  60. type="primary"
  61. :loading="isLoading"
  62. @click="searchClickHandle">搜索</el-button>
  63. </div>
  64. <div class="tab-content">
  65. <el-table
  66. class="table"
  67. style="overflow-y: auto;"
  68. :data="tabList"
  69. header-row-class-name="table-header"
  70. @sort-change="tableSortChange"
  71. >
  72. <el-table-column label="是否识别" v-if="aiTypeVal == '1'">
  73. <template slot-scope="scope">
  74. <span>{{ parseAlarmType(scope.row.alarmType) }}</span>
  75. </template>
  76. </el-table-column>
  77. <el-table-column label="识别类型" min-width="120">
  78. <template slot-scope="scope">
  79. <el-tag
  80. class="mx-025"
  81. v-for="item in scope.row.arithmetic.split(',')"
  82. :key="`${scope.row.arithmetic.id}-${item}`">
  83. {{ getArithmeticName(item) }}
  84. </el-tag>
  85. </template>
  86. </el-table-column>
  87. <el-table-column prop="deviceId" label="设备号"></el-table-column>
  88. <el-table-column prop="firmware_version" label="固件版本号"></el-table-column>
  89. <el-table-column prop="signal" label="信号" :sortable="'signal'" width="75">
  90. <template slot-scope="scope">
  91. <el-tooltip class="item" effect="dark"
  92. :content="scope.row.signal+' '+signalTransform(scope.row.signal,false)"
  93. placement="left-start">
  94. <signal-info :signal-text="scope.row.signal"></signal-info>
  95. </el-tooltip>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="createTime" label="上传时间" :sortable="'createTime'">
  99. <template slot-scope="scope">
  100. <span>{{ getTimeText(scope.row.createTime) }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="alarmState" label="状态" width="80">
  104. <template slot-scope="scope">
  105. <span>{{ getAlarmState(scope.row.alarmState) }}</span>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="操作" >
  109. <template slot-scope="scope">
  110. <el-button size="medium" @click="editAlarmHandle(scope.row)">忽略</el-button>
  111. <el-button size="medium" type="primary" @click="moreAlarmHandle(scope.row)">
  112. 查看
  113. </el-button>
  114. </template>
  115. </el-table-column>
  116. </el-table>
  117. </div>
  118. <div class="tab-page">
  119. <el-pagination
  120. style="float: right"
  121. @size-change="handleSizeChange"
  122. @current-change="currentChange"
  123. :current-page="currentPage"
  124. :page-size="count"
  125. :page-sizes="[5,10,15, 25, 35, 50]"
  126. layout="total, sizes, prev, pager, next"
  127. :total="total"
  128. ></el-pagination>
  129. </div>
  130. </div>
  131. </div>
  132. </template>
  133. <script>
  134. import {
  135. triggerTypes,
  136. getTriggerTypeArr,
  137. getAITypeArr,
  138. toAlarmState,
  139. alarmStates,
  140. getAlarmStateArr,
  141. toAlarmKey
  142. } from "@/map/ai.js"
  143. import handle from "@/until/handle";
  144. import timeUntil from "@/until/time";
  145. import SignalInfo from "@/components/common/signalInfo";
  146. import devTool from "@/hfyUntil/devTool";
  147. let bellSearchSource = null;
  148. export default {
  149. name: "bell",
  150. components: {SignalInfo},
  151. data(){
  152. return {
  153. isLoading: false,
  154. triggerTypeVal: 0,
  155. triggerTypes: triggerTypes,
  156. triggerTypeArr: getTriggerTypeArr(),
  157. aiTypeVal: "1",
  158. aiTypeArr: getAITypeArr(),
  159. alarmStates: alarmStates,
  160. alarmStateArr: getAlarmStateArr(),
  161. key: '',
  162. searchKey: '',
  163. alarmState: 0,
  164. searchAlarmState: '',
  165. searchOrder: "descending",
  166. searchSort: 'alarmId',
  167. lastPage: 1,
  168. currentPage: 1,
  169. count: 15,
  170. total: 1,
  171. tabList: [],
  172. }
  173. },
  174. beforeDestroy() {
  175. this.stopQuest();
  176. this.alarmState = this.$route.query.alarmState
  177. },
  178. beforeMount() {
  179. console.log("beforeMount")
  180. // 尝试从临时存储中获取搜索条件
  181. let searchParam = window.sessionStorage.getItem("bellSearchParam");
  182. searchParam = JSON.parse(searchParam);
  183. if (searchParam) {
  184. this.searchKey = searchParam.searchKey;
  185. this.alarmState = searchParam.alarmState;
  186. this.aiTypeVal = searchParam.aiTypeVal;
  187. this.triggerTypeVal = searchParam.triggerTypeVal;
  188. this.count = searchParam.count;
  189. this.currentPage = searchParam.currentPage;
  190. }
  191. },
  192. mounted() {
  193. console.log("mounted")
  194. this.searchClickHandle();
  195. },
  196. methods:{
  197. signalTransform:devTool.signalTransform,
  198. toBack(){
  199. this.$router.back();
  200. if (this.deviceId === "" ) {
  201. this.beforeUrl = "/"
  202. }
  203. },
  204. getNowTriggerType(){
  205. },
  206. stopQuest(){
  207. if(bellSearchSource){
  208. bellSearchSource.cancel();
  209. bellSearchSource = null;
  210. }
  211. },
  212. getAlarmState(stateCode){
  213. let state = toAlarmState(stateCode);
  214. return state?state.text:"null";
  215. },
  216. getTimeText(timeStamp){
  217. return timeUntil.dateFormat(
  218. timeUntil.timeStamp_to_Date(timeStamp),
  219. )
  220. },
  221. async searchData(searchParam){
  222. if(bellSearchSource){
  223. this.$message.warning("请等待请求完成");
  224. }
  225. searchParam.arithmetic = this.aiTypeVal;
  226. searchParam.alarmState = toAlarmKey(searchParam.alarmState);
  227. bellSearchSource = this.$axios.axios.CancelToken.source();
  228. this.isLoading = true;
  229. let [err,res] = await handle(
  230. this.$axios.axios.post('/ai/alarms',
  231. searchParam,
  232. {
  233. cancelToken: bellSearchSource.token
  234. })
  235. );
  236. this.isLoading = false;
  237. bellSearchSource = null;
  238. if(err){
  239. return this.$message.error(err.message);
  240. }
  241. console.log(res);
  242. let result = res.data;
  243. if(result.code === 0){
  244. this.tabList = result.data;
  245. this.total = result.total;
  246. this.libList = result.list;
  247. // 存储搜索条件
  248. window.sessionStorage.setItem("bellSearchParam",JSON.stringify({
  249. searchKey: this.searchKey,
  250. alarmState: this.alarmState,
  251. aiTypeVal: this.aiTypeVal,
  252. triggerTypeVal: this.triggerTypeVal,
  253. count: this.count,
  254. currentPage: this.currentPage,
  255. }));
  256. }else{
  257. this.$message.warning(result.msg);
  258. }
  259. },
  260. handleAiTypeClick(tab, event){
  261. console.log(tab, event);
  262. console.log(this.aiTypeVal);
  263. console.log(tab.name);
  264. this.searchClickHandle();
  265. },
  266. currentChange: function (val) {
  267. this.currentPage = val;
  268. this.changePage();
  269. },
  270. handleSizeChange: function (val) {
  271. this.count = val;
  272. this.changePage();
  273. },
  274. changePage(){
  275. // 使用当前配置进行搜索
  276. let searchParam = {
  277. p: this.currentPage,
  278. l: this.count,
  279. key: this.searchKey,
  280. alarmState: this.searchAlarmState,
  281. order: this.searchOrder,
  282. sort: this.searchSort,
  283. }
  284. this.searchData(searchParam);
  285. },
  286. searchClickHandle(){
  287. let searchParam = {
  288. p: 1,
  289. l: this.count,
  290. key: this.key,
  291. alarmState: this.alarmState
  292. }
  293. this.searchKey = this.key;
  294. this.searchAlarmState = this.alarmState;
  295. this.searchData(searchParam);
  296. },
  297. async editAlarmHandle(row){
  298. let [err,res] = await handle(this.$axios.get(`/ai/alarm/ignore/${row.alarmId}`))
  299. if(err){return this.$message.error(err.msg)}
  300. if(res.data.code!==0){return this.$message.warning(res.data.msg)}
  301. this.$message.success("操作成功!!!");
  302. },
  303. moreAlarmHandle(row){
  304. this.$router.push(`/alarm/${row.alarmId}`)
  305. },
  306. // 改变排序结构
  307. tableSortChange(v,v1){
  308. console.log("sort change");
  309. console.log(v,v1);
  310. let prop = v.prop,
  311. order = v.order;
  312. // 构建新搜索数据体进行搜索
  313. let searchParam = {
  314. order: order,
  315. sort: prop,
  316. p: 1,
  317. l: this.count,
  318. key: this.searchKey,
  319. alarmState: this.searchAlarmState
  320. }
  321. this.searchSort = prop;
  322. this.searchOrder = order;
  323. this.searchData(searchParam);
  324. },
  325. // 全部忽略
  326. markAllEventRead(){
  327. this.$confirm('此操作将忽略全部告警内容,请再次确认?', '提示', {
  328. confirmButtonText: '确定',
  329. cancelButtonText: '取消',
  330. type: 'warning'
  331. }).then(async () => {
  332. let [err, res] = await handle(this.$axios.get(`/ai/markAll?arithmetic=${this.aiTypeVal}`))
  333. if (err) {
  334. return this.$message.error(err.msg)
  335. }
  336. if (res.data.code !== 0) {
  337. return this.$message.warning(res.data.msg)
  338. }
  339. this.$message.success("操作成功!!!");
  340. })
  341. },
  342. getArithmeticName(text) {
  343. let res = this.aiTypeArr.find(item => item.val == text)
  344. return res ? res.text : "未知";
  345. },
  346. parseAlarmType(text) {
  347. let r = ""
  348. if (text == "1") {
  349. r = "设备名单人员";
  350. } else {
  351. r = "陌生人"
  352. }
  353. return r
  354. }
  355. }
  356. }
  357. </script>
  358. <style scoped>
  359. .mx-025 {
  360. margin-left: 0.25rem;
  361. margin-right: 0.25rem;
  362. }
  363. .page-header {
  364. height: 45px;
  365. box-sizing: border-box;
  366. margin-bottom: 5px;
  367. }
  368. .tab-box{
  369. width: 100%;
  370. height: calc(100vh - 135px);
  371. background-color: #fff;
  372. border-radius: 0.25rem;
  373. padding: 5px;
  374. box-sizing: border-box;
  375. overflow: hidden;
  376. }
  377. .tab-box .tab-switch{
  378. height: 45px;
  379. }
  380. .tab-box .tab-header{
  381. height: 40px;
  382. width: 99%;
  383. display: flex;
  384. }
  385. .tab-box .tab-header > *{
  386. height: 40px;
  387. }
  388. .tab-box .tab-content{
  389. height: calc(100% - 118px);
  390. overflow-y: auto;
  391. }
  392. .tab-box .tab-content .table{
  393. height: 100%;
  394. }
  395. .tab-box .tab-page{
  396. height: 35px;
  397. }
  398. </style>