elevatoralarm.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :table-loading="loading"
  5. :data="data"
  6. :page="page"
  7. :permission="permissionList"
  8. :before-open="beforeOpen"
  9. v-model="form"
  10. ref="crud"
  11. @row-update="rowUpdate"
  12. @row-save="rowSave"
  13. @row-del="rowDel"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad">
  21. <template slot="menuLeft">
  22. <el-button type="danger"
  23. size="small"
  24. icon="el-icon-delete"
  25. plain
  26. v-if="permission.elevatoralarm_delete"
  27. @click="handleDelete">删 除
  28. </el-button>
  29. </template>
  30. <template slot="menu" slot-scope="{row}">
  31. <el-button icon="el-icon-video-camera" v-if="'1000007,1000010,1000018,1000050'.indexOf(row.alarmType) != -1" type="text" @click="getAlarmVideoData(row)">查看告警视频</el-button>
  32. </template>
  33. </avue-crud>
  34. <!-- 告警视频 -->
  35. <el-dialog :append-to-body="true" :close-on-click-modal="false" :modal-append-to-body="false" width="40%" top="1vh"
  36. :title="videoAlarmName" :visible.sync="videoAlarmVisible" @close="videoClose">
  37. <video id="videoAlarm" autoplay style="background-color: black; width:100%;height:100%"></video>
  38. </el-dialog>
  39. </basic-container>
  40. </template>
  41. <script>
  42. import {getList, getDetail, add, update, remove} from "@/api/device/elevatoralarm";
  43. import {getAlarmVideo} from "@/api/device/elevatoralarm";
  44. import {mapGetters} from "vuex";
  45. import {startPlay, stopPlay} from "@/api/device/elevatorUtil";
  46. export default {
  47. name: "elevatorAlarm",
  48. data() {
  49. return {
  50. form: {},
  51. query: {},
  52. videoAlarmName: '',
  53. videoAlarmVisible: false,
  54. player: null,
  55. loading: true,
  56. page: {
  57. pageSize: 10,
  58. currentPage: 1,
  59. total: 0
  60. },
  61. selectionList: [],
  62. option: {
  63. height:'auto',
  64. calcHeight: 30,
  65. tip: false,
  66. searchShow: true,
  67. searchMenuSpan: 6,
  68. border: true,
  69. index: true,
  70. viewBtn: true,
  71. selection: true,
  72. dialogClickModal: false,
  73. column: [
  74. /*{
  75. label: "告警编号",
  76. prop: "alarmCode",
  77. rules: [{
  78. required: true,
  79. message: "请输入告警编号",
  80. trigger: "blur"
  81. }]
  82. },
  83. {
  84. label: "电梯注册编码",
  85. prop: "registerCode",
  86. rules: [{
  87. required: true,
  88. message: "请输入电梯注册编码",
  89. trigger: "blur"
  90. }]
  91. },*/
  92. {
  93. label: "小区名称",
  94. prop: "residentialName",
  95. // search: true,
  96. // searchSpan: 4,
  97. },
  98. {
  99. label: "小区",
  100. prop: "residentialId",
  101. type: "select",
  102. hide: true,
  103. search: true,
  104. searchSpan: 4,
  105. searchFilterable: true,
  106. // remote: true,
  107. //回显的时候有问题,如果所选不在前十条内,下拉框只会显示id
  108. dicUrl: "/api/cyzh-community/residential/list?size=1000&name={{key}}",
  109. // dicUrl: "/api/community/elevator/elevator/getListWithYtelevatorXq",
  110. props:{
  111. label: "name",
  112. value: "id"
  113. },
  114. },
  115. {
  116. label: "告警大类",
  117. prop: "standardType",
  118. type: "select",
  119. search: true,
  120. searchSpan: 4,
  121. dicUrl: "/api/blade-system/dict-biz/dictionary?code=yt_standard_type",
  122. props:{
  123. label: "dictValue",
  124. value: "dictKey",
  125. },
  126. rules: [{
  127. required: true,
  128. message: "请输入告警大类{9000001:报警 ,9000002:故障, 9000004:事件}",
  129. trigger: "blur"
  130. }]
  131. },
  132. {
  133. label: "告警类型",
  134. prop: "alarmType",
  135. type: "select",
  136. search: true,
  137. searchSpan: 4,
  138. dicUrl: "/api/blade-system/dict-biz/dictionary?code=yt_alarm_type",
  139. props:{
  140. label: "dictValue",
  141. value: "dictKey",
  142. },
  143. rules: [{
  144. required: true,
  145. message: "请输入告警类型",
  146. trigger: "blur"
  147. }]
  148. },
  149. {
  150. label: "告警状态",
  151. prop: "alarmStatus",
  152. type: "select",
  153. search: true,
  154. searchSpan: 4,
  155. dicUrl: "/api/blade-system/dict-biz/dictionary?code=yt_alarm_status",
  156. dataType: "number",
  157. props:{
  158. label: "dictValue",
  159. value: "dictKey",
  160. },
  161. rules: [{
  162. required: true,
  163. message: "请输入告警状态{1:告警中,6:自动结束,7:超期结束,8:自动处理}",
  164. trigger: "blur"
  165. }]
  166. },
  167. {
  168. label: "告警时间",
  169. prop: "alarmTime",
  170. rules: [{
  171. required: true,
  172. message: "请输入告警时间",
  173. trigger: "blur"
  174. }]
  175. },
  176. {
  177. label: "告警结束时间",
  178. prop: "alarmEndTime",
  179. rules: [{
  180. required: true,
  181. message: "请输入告警结束时间",
  182. trigger: "blur"
  183. }]
  184. },
  185. {
  186. label: "云梯状态",
  187. prop: "ytStatus",
  188. type: "select",
  189. search: true,
  190. searchSpan: 4,
  191. dicUrl: "/api/blade-system/dict-biz/dictionary?code=yt_status",
  192. props:{
  193. label: "dictValue",
  194. value: "dictKey",
  195. },
  196. rules: [{
  197. required: true,
  198. message: "请输入云梯告警状态{20:正常,40:演示,50:测试}",
  199. trigger: "blur"
  200. }]
  201. },
  202. ]
  203. },
  204. data: []
  205. };
  206. },
  207. computed: {
  208. ...mapGetters(["permission"]),
  209. permissionList() {
  210. return {
  211. addBtn: this.vaildData(this.permission.elevatoralarm_add, false),
  212. viewBtn: this.vaildData(this.permission.elevatoralarm_view, false),
  213. delBtn: this.vaildData(this.permission.elevatoralarm_delete, false),
  214. editBtn: this.vaildData(this.permission.elevatoralarm_edit, false)
  215. };
  216. },
  217. ids() {
  218. let ids = [];
  219. this.selectionList.forEach(ele => {
  220. ids.push(ele.id);
  221. });
  222. return ids.join(",");
  223. }
  224. },
  225. props:["registerCode"],
  226. methods: {
  227. videoClose(){
  228. stopPlay(this.player);
  229. },
  230. getAlarmVideoData(row){
  231. let alarmCode = row.alarmCode;
  232. this.videoAlarmName = row.$alarmType;
  233. this.videoAlarmVisible = true;
  234. alarmCode && getAlarmVideo(alarmCode).then(res => {
  235. if (res.data.code == 200 && res.data.data.code == 0){
  236. let videoUrl = res.data.data.data.urlSec;
  237. this.videoDetail(videoUrl);
  238. }
  239. });
  240. },
  241. videoDetail(videoUrl){
  242. let elementId = 'videoAlarm';
  243. this.player = startPlay(elementId, videoUrl, this.player);
  244. },
  245. rowSave(row, done, loading) {
  246. add(row).then(() => {
  247. this.onLoad(this.page);
  248. this.$message({
  249. type: "success",
  250. message: "操作成功!"
  251. });
  252. done();
  253. }, error => {
  254. loading();
  255. window.console.log(error);
  256. });
  257. },
  258. rowUpdate(row, index, done, loading) {
  259. update(row).then(() => {
  260. this.onLoad(this.page);
  261. this.$message({
  262. type: "success",
  263. message: "操作成功!"
  264. });
  265. done();
  266. }, error => {
  267. loading();
  268. console.log(error);
  269. });
  270. },
  271. rowDel(row) {
  272. this.$confirm("确定将选择数据删除?", {
  273. confirmButtonText: "确定",
  274. cancelButtonText: "取消",
  275. type: "warning"
  276. })
  277. .then(() => {
  278. return remove(row.id);
  279. })
  280. .then(() => {
  281. this.onLoad(this.page);
  282. this.$message({
  283. type: "success",
  284. message: "操作成功!"
  285. });
  286. });
  287. },
  288. handleDelete() {
  289. if (this.selectionList.length === 0) {
  290. this.$message.warning("请选择至少一条数据");
  291. return;
  292. }
  293. this.$confirm("确定将选择数据删除?", {
  294. confirmButtonText: "确定",
  295. cancelButtonText: "取消",
  296. type: "warning"
  297. })
  298. .then(() => {
  299. return remove(this.ids);
  300. })
  301. .then(() => {
  302. this.onLoad(this.page);
  303. this.$message({
  304. type: "success",
  305. message: "操作成功!"
  306. });
  307. this.$refs.crud.toggleSelection();
  308. });
  309. },
  310. beforeOpen(done, type) {
  311. if (["edit", "view"].includes(type)) {
  312. getDetail(this.form.id).then(res => {
  313. this.form = res.data.data;
  314. });
  315. }
  316. done();
  317. },
  318. searchReset() {
  319. this.query = {};
  320. this.onLoad(this.page);
  321. },
  322. searchChange(params, done) {
  323. this.query = params;
  324. this.page.currentPage = 1;
  325. this.onLoad(this.page, params);
  326. done();
  327. },
  328. selectionChange(list) {
  329. this.selectionList = list;
  330. },
  331. selectionClear() {
  332. this.selectionList = [];
  333. this.$refs.crud.toggleSelection();
  334. },
  335. currentChange(currentPage){
  336. this.page.currentPage = currentPage;
  337. },
  338. sizeChange(pageSize){
  339. this.page.pageSize = pageSize;
  340. },
  341. refreshChange() {
  342. this.onLoad(this.page, this.query);
  343. },
  344. onLoad(page, params = {}) {
  345. this.loading = true;
  346. params.registerCode = this.registerCode;
  347. if (params.registerCode){
  348. this.option.column[1].search = false;
  349. }
  350. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  351. const data = res.data.data;
  352. this.page.total = data.total;
  353. this.data = data.records;
  354. this.loading = false;
  355. this.selectionClear();
  356. });
  357. }
  358. }
  359. };
  360. </script>
  361. <style>
  362. </style>