news.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. <template>
  2. <div class="content-box">
  3. <div class="left">
  4. <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
  5. <span class="cameratxt">消息通知</span>
  6. </div>
  7. <div class="middle">
  8. <div class="filter">
  9. <div class="condition">
  10. <span>创建时间 : </span>
  11. <el-date-picker v-model="searchInput.createTime" type="date" placeholder="请选择时间" format="YYYY-MM-DD"
  12. value-format="YYYY-MM-DD" />
  13. </div>
  14. <div class="condition">
  15. <span>状态 : </span>
  16. <el-select style="width: 120px" v-model="searchInput.state" class="m-2" placeholder="请选择状态">
  17. <el-option label="全部" value="2" />
  18. <el-option label="已读" value="1" />
  19. <el-option label="未读" value="0" />
  20. </el-select>
  21. </div>
  22. <el-button style="margin-left: 20px;color:#fff" color="rgba(111, 182, 184, 1)" type="primary" class="search"
  23. @click="searchBtn"><el-icon>
  24. <Search />
  25. </el-icon> <span>搜索</span></el-button>
  26. </div>
  27. <!-- 按钮列表 -->
  28. <div class="gongneng">
  29. <el-button type="primary" style="color:#fff" color="rgba(111, 182, 184, 1)" @click="reset"><el-icon>
  30. <RefreshRight />
  31. </el-icon><span>刷新</span></el-button>
  32. <el-button type="danger" style="color: #fff;" @click="allRead" color="rgba(111, 182, 184, 1)">
  33. <img src="@/assets/read.png" style="width: 14px; height: 14px; margin-right: 4px" alt="" />
  34. <span>一键已读</span></el-button>
  35. </div>
  36. <!-- 编辑/新增摄像头IP -->
  37. <el-dialog v-model="centerDialogVisible" :title="dialongTitle" width="40%" align-center :before-close="editClose">
  38. <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm"
  39. :size="formSize" status-icon>
  40. <el-form-item label="厂商" prop="count">
  41. <el-input v-model="ruleForm.count" placeholder="请输入厂商" />
  42. </el-form-item>
  43. <el-form-item label="IP地址" prop="name">
  44. <el-input v-model="ruleForm.name" placeholder="请输入IP地址" />
  45. </el-form-item>
  46. <el-form-item label="状态" prop="region">
  47. <el-select v-model="ruleForm.region" placeholder="请选择状态">
  48. <el-option label="在线" value="1" />
  49. <el-option label="离线" value="0" />
  50. </el-select>
  51. </el-form-item>
  52. <el-form-item label="创建人" prop="username" v-show="dialongTitle == '新增摄像头IP'">
  53. <el-input v-model="ruleForm.username" placeholder="请输入创建人姓名" />
  54. </el-form-item>
  55. <el-form-item label="摄像头密码" prop="pass">
  56. <el-input v-model="ruleForm.pass" placeholder="请输入摄像头密码" />
  57. </el-form-item>
  58. <el-form-item label="最后更新人" prop="username" v-show="dialongTitle == '修改摄像头IP'">
  59. <el-input v-model="ruleForm.username" placeholder="请输入更新人姓名" />
  60. </el-form-item>
  61. <el-form-item label="设备型号" prop="date1">
  62. <el-input v-model="ruleForm.date1" placeholder="请输入设备型号" />
  63. </el-form-item>
  64. <el-form-item label="协议" prop="types">
  65. <el-input v-model="ruleForm.types" placeholder="请输入协议"></el-input>
  66. </el-form-item>
  67. <el-form-item label="安装位置" prop="date2">
  68. <el-input v-model="ruleForm.date2" placeholder="请输入安装位置" />
  69. </el-form-item>
  70. <el-form-item label="摄像机编码" prop="resource">
  71. <el-input v-model="ruleForm.resource" placeholder="请输入摄像机编码">
  72. </el-input>
  73. </el-form-item>
  74. <el-form-item label="备注" prop="desc">
  75. <el-input v-model="ruleForm.desc" type="textarea" placeholder="请输入备注" />
  76. </el-form-item>
  77. <el-form-item>
  78. <el-button type="primary" @click="submitForm(ruleFormRef)">
  79. 确定
  80. </el-button>
  81. <el-button @click="resetForm(ruleFormRef)">重置</el-button>
  82. </el-form-item>
  83. </el-form>
  84. </el-dialog>
  85. </div>
  86. <div class="footer">
  87. <el-table :row-class-name="tableRowClassName" :data="tableData.list" @selection-change="handleSelectionChange"
  88. style="width: 100%" :header-cell-style="{
  89. background: 'rgba(240, 243, 247, 1)',
  90. height: '50px',
  91. border: 0,
  92. }">
  93. <!-- <el-table-column align="center" type="selection" width="80" /> -->
  94. <el-table-column align="center" prop="updateTime" label="创建时间" width="250" />
  95. <el-table-column align="center" prop="recordNo" label="工单号" width="250" />
  96. <el-table-column align="center" prop="content" show-overflow-tooltip label="消息" />
  97. <el-table-column align="center" prop="isRead" label="状态" width="200">
  98. <template #default="{ row }">
  99. <div v-if="row.isRead == 1">已读</div>
  100. <div @click="look(row)" style="cursor: pointer;color: red" v-else-if="row.isRead == 0">未读</div>
  101. </template>
  102. </el-table-column>
  103. <!-- <el-table-column align="center" label="操作" width="220">
  104. <template #default="scope">
  105. <el-button link type="primary" @click="look(scope.row)">
  106. <div class="look">查看</div>
  107. </el-button>
  108. </template>
  109. </el-table-column> -->
  110. </el-table>
  111. </div>
  112. <!-- 分页组件 -->
  113. <el-pagination background :current-page="currentPage" :page-size="pageSize" layout="total, prev, pager, next, jumper"
  114. :total="total" @update:current-page="handleCurrentChange" />
  115. </div>
  116. </template>
  117. <script setup>
  118. import { ref, watch, reactive, nextTick, onBeforeMount, onUnmounted } from "vue";
  119. import { useRouter } from "vue-router";
  120. import { ElMessage, ElMessageBox } from "element-plus";
  121. import vidiconsApi from "@/api/vidicons.js";
  122. import { dayjs } from "element-plus";
  123. import lodash from "lodash";
  124. import axios from "axios";
  125. import { useStore } from "vuex";
  126. const store = useStore();
  127. const api = ref("");
  128. const router = useRouter();
  129. // 表格数据
  130. const tableData = reactive({ list: [] });
  131. const activeIndex = ref(); // 默认跳转路由
  132. const dialongTitle = ref(""); // 弹窗标题
  133. const searchInput = reactive({
  134. state: "2",
  135. createTime: "",
  136. }); // 搜索按钮数据
  137. 5;
  138. const currentPage = ref(1); // 当前页
  139. const pageSize = ref(10);
  140. const total = ref(10); // 当前总数
  141. const selectData = reactive({ list: [] }); // 多选框选择的数据
  142. const centerDialogVisible = ref(false); // 控制新增或修改弹窗开关
  143. const videoDialogVisible = ref(false); // 控制播放弹窗开关
  144. const urlLink = ref(); // 输出链接
  145. // 表单数据
  146. const formSize = ref("default");
  147. const ruleFormRef = ref();
  148. const ruleForm = reactive({
  149. name: "",
  150. region: "",
  151. count: "",
  152. date1: "",
  153. date2: "",
  154. types: [],
  155. resource: "",
  156. desc: "",
  157. username: "",
  158. pass: "",
  159. id: "",
  160. });
  161. // 表单验证
  162. const rules = reactive({
  163. region: [
  164. {
  165. required: true,
  166. message: "状态不能为空",
  167. trigger: "blur",
  168. },
  169. ],
  170. name: [
  171. { required: true, message: "IP地址不能为空", trigger: "blur" },
  172. // { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
  173. ],
  174. count: [
  175. {
  176. required: true,
  177. message: "厂商不能为空",
  178. trigger: "blur",
  179. },
  180. ],
  181. date1: [
  182. {
  183. required: true,
  184. message: "设备型号不能为空",
  185. trigger: "blur",
  186. },
  187. ],
  188. date2: [
  189. {
  190. required: true,
  191. message: "安装位置不能为空",
  192. trigger: "blur",
  193. },
  194. ],
  195. types: [
  196. {
  197. required: true,
  198. message: "协议不能为空",
  199. trigger: "blur",
  200. },
  201. ],
  202. username: [
  203. {
  204. required: true,
  205. message: "更新人员姓名不能为空",
  206. trigger: "blur",
  207. },
  208. ],
  209. pass: [
  210. {
  211. required: true,
  212. message: "密码不能为空",
  213. trigger: "blur",
  214. },
  215. ],
  216. resource: [
  217. {
  218. required: true,
  219. message: "摄像机编码不能为空",
  220. trigger: "blur",
  221. },
  222. ],
  223. // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
  224. });
  225. watch(
  226. () => searchInput.createTime,
  227. (newVal, oldVal) => {
  228. console.log("监听时间:", newVal);
  229. if (newVal == null) {
  230. searchBtn();
  231. }
  232. }
  233. );
  234. // 获取消息列表
  235. const getList = async (msg) => {
  236. let data = {
  237. currentPage: currentPage.value,
  238. pageCount: pageSize.value,
  239. statu: searchInput.state
  240. }
  241. if (searchInput.createTime) {
  242. data.createTime = searchInput.createTime
  243. }
  244. let res = await axios({
  245. method: "get",
  246. url: api.value + "/repairSystemMessages/queryManageMessagePage",
  247. headers: {
  248. token: sessionStorage.getItem("token"),
  249. user_head: sessionStorage.getItem("userhead"),
  250. },
  251. params: data,
  252. });
  253. console.log(res, "消息中心列表");
  254. if (res.data.code == 200) {
  255. tableData.list = res.data.data.list;
  256. total.value = res.data.data.totalCount
  257. if (msg) {
  258. ElMessage({
  259. type: "success",
  260. showClose: true,
  261. message: msg,
  262. center: true,
  263. });
  264. }
  265. } else {
  266. ElMessage({
  267. type: "error",
  268. showClose: true,
  269. message: res.data.message,
  270. center: true,
  271. });
  272. if (res.data.code == 570) {
  273. sessionStorage.removeItem("token")
  274. router.push({
  275. path: `/login`,
  276. });
  277. }
  278. }
  279. };
  280. // 刷新
  281. const reset = async () => {
  282. getList("刷新成功")
  283. };
  284. // 路由
  285. const handleSelect = (key, keyPath) => { };
  286. // 搜索功能
  287. const searchBtn = lodash.debounce(async () => {
  288. getList();
  289. }, 300);
  290. // 查看按钮
  291. const look =lodash.throttle(async (row) => {
  292. let data = { id: row.id }
  293. let res = await axios({
  294. method: "get",
  295. url: api.value + "/repairSystemMessages/readSystemMessage",
  296. headers: {
  297. token: sessionStorage.getItem("token"),
  298. user_head: sessionStorage.getItem("userhead"),
  299. },
  300. params: data,
  301. });
  302. console.log(res, "已读");
  303. if (res.data.code == 200) {
  304. store.dispatch("newsAsync");
  305. getList()
  306. ElMessage({
  307. type: "success",
  308. showClose: true,
  309. message: res.data.message,
  310. center: true,
  311. });
  312. } else {
  313. ElMessage({
  314. type: "error",
  315. showClose: true,
  316. message: res.data.message,
  317. center: true,
  318. });
  319. }
  320. },1000);
  321. // 获取未读数量
  322. const newsNum = async () => {
  323. let data = {}
  324. let res = await axios({
  325. method: "get",
  326. url: api.value + "/repairSystemMessages/queryPCMessageUnreadCount",
  327. headers: {
  328. token: sessionStorage.getItem("token"),
  329. user_head: sessionStorage.getItem("userhead"),
  330. },
  331. params: data,
  332. });
  333. console.log(res, "获取未读数量");
  334. if (res.data.code == 200) {
  335. let num = res.data.data.count
  336. // store.dispatch("newsAsync");
  337. sessionStorage.setItem("newsNum", num)
  338. } else {
  339. ElMessage({
  340. type: "error",
  341. showClose: true,
  342. message: res.data.message,
  343. center: true,
  344. });
  345. }
  346. };
  347. // 一键已读
  348. const allRead = lodash.throttle(async () => {
  349. let data = {}
  350. let res = await axios({
  351. method: "get",
  352. url: api.value + "/repairSystemMessages/readAllManageMessage",
  353. headers: {
  354. token: sessionStorage.getItem("token"),
  355. user_head: sessionStorage.getItem("userhead"),
  356. },
  357. params: data,
  358. });
  359. console.log(res, "一键已读");
  360. if (res.data.code == 200) {
  361. store.dispatch("newsAsync");
  362. getList()
  363. ElMessage({
  364. type: "success",
  365. showClose: true,
  366. message: res.data.message,
  367. center: true,
  368. });
  369. } else {
  370. ElMessage({
  371. type: "error",
  372. showClose: true,
  373. message: res.data.message,
  374. center: true,
  375. });
  376. }
  377. },1000);
  378. // 多选框功能
  379. const handleSelectionChange = (val) => {
  380. console.log(val);
  381. selectData.list = val;
  382. };
  383. // 表格斑马纹颜色修改
  384. const tableRowClassName = ({ row, rowIndex }) => {
  385. if (rowIndex % 2 === 0) {
  386. return "even";
  387. } else if (rowIndex % 2 !== 0) {
  388. return "odd";
  389. }
  390. return "";
  391. };
  392. // 分页
  393. const handleCurrentChange = (value) => {
  394. currentPage.value = value;
  395. getList();
  396. };
  397. onBeforeMount(() => {
  398. api.value = store.state.user.api;
  399. getList();
  400. store.dispatch("newsAsync");
  401. });
  402. onUnmounted(() => {
  403. // document.removeEventListener("keyup", Enters);
  404. });
  405. </script>
  406. <style scoped lang="scss">
  407. .content-box {
  408. width: 97.5%;
  409. height: 89%;
  410. margin: 20px auto;
  411. background-color: #fff;
  412. color: #fff;
  413. display: flex;
  414. flex-direction: column;
  415. .left {
  416. // width: calc(100wh - 40px);
  417. display: flex;
  418. align-items: center;
  419. height: 60px;
  420. margin: 0 30px;
  421. border-bottom: 1px solid #ccc;
  422. color: #000;
  423. font-size: 18px;
  424. font-weight: 600;
  425. .camera {
  426. margin-right: 15px;
  427. color: #4392f7;
  428. }
  429. }
  430. .middle {
  431. width: 96%;
  432. margin: 0 auto;
  433. color: #000;
  434. // border-bottom: 1px solid rgb(231, 231, 231);
  435. .filter {
  436. display: flex;
  437. flex-wrap: wrap;
  438. align-items: center;
  439. margin: 10px 0 0 0;
  440. .condition {
  441. display: flex;
  442. align-items: center;
  443. margin: 10px 30px 10px 0;
  444. span {
  445. margin: 0 10px 0 0;
  446. }
  447. }
  448. }
  449. .gongneng {
  450. margin: 10px 0;
  451. }
  452. :deep(.cont) {
  453. width: 60%;
  454. margin: 20px auto;
  455. }
  456. :deep(.download) {
  457. display: flex;
  458. align-items: center;
  459. margin: 10px;
  460. }
  461. :deep(.download span) {
  462. font-size: 16px;
  463. margin-left: 20px;
  464. }
  465. :deep(.cont .el-button) {
  466. margin-left: 60px;
  467. margin-bottom: 30px;
  468. }
  469. :deep(.cont .accomplish) {
  470. width: 100%;
  471. display: flex;
  472. justify-content: center;
  473. }
  474. :deep(.cont .accomplish .el-button) {
  475. width: 50%;
  476. margin: 0;
  477. }
  478. }
  479. .footer {
  480. width: 96%;
  481. height: 550px;
  482. margin: 10px auto 30px;
  483. .el-table--fit {
  484. height: 100%;
  485. :deep(.el-table__header-wrapper) {
  486. background-color: #000;
  487. }
  488. :deep(.el-table__row) {
  489. height: 50px;
  490. }
  491. :deep(.el-table__row td) {
  492. padding: 0;
  493. border: 0;
  494. }
  495. .el-button--primary {
  496. margin-left: 5px;
  497. }
  498. :deep(.el-table__body .even) {
  499. background-color: #fff;
  500. }
  501. :deep(.el-table__body .odd) {
  502. background-color: rgba(240, 243, 247, 1);
  503. }
  504. :deep(.look) {
  505. padding: 5px 14px;
  506. border-radius: 45px;
  507. border: 0.74px solid rgba(30, 125, 251, 1);
  508. }
  509. }
  510. }
  511. // .el-pagination {
  512. // // width: 1600px;
  513. // width: 96%;
  514. // margin: 0 auto 18px;
  515. // justify-content: flex-end;
  516. // :deep(.el-pagination__total) {
  517. // color: #000;
  518. // }
  519. // :deep(.el-pagination__goto) {
  520. // color: #000;
  521. // }
  522. // :deep(.el-pagination__classifier) {
  523. // color: #000;
  524. // }
  525. // :deep(.el-input__wrapper) {
  526. // border: 1px solid rgba(0, 0, 0, 1);
  527. // border-radius: 5px;
  528. // box-shadow: none;
  529. // }
  530. // :deep(.el-pager li) {
  531. // margin: 0 5px;
  532. // border: 1px solid rgba(0, 0, 0, 1);
  533. // border-radius: 5px;
  534. // background-color: transparent;
  535. // }
  536. // :deep(.el-pager li.is-active) {
  537. // background-color: rgba(30, 125, 251, 1);
  538. // }
  539. // :deep(.btn-prev) {
  540. // margin-right: 5px;
  541. // border: 1px solid rgba(0, 0, 0, 1);
  542. // border-radius: 5px;
  543. // background-color: transparent;
  544. // }
  545. // :deep(.btn-next) {
  546. // margin-left: 5px;
  547. // border: 1px solid rgba(0, 0, 0, 1);
  548. // border-radius: 5px;
  549. // background-color: transparent;
  550. // }
  551. // }
  552. .el-pagination {
  553. width: 96%;
  554. margin: 0 auto 18px;
  555. justify-content: flex-end;
  556. :deep(.el-pagination__total) {
  557. color: #000;
  558. }
  559. :deep(.el-pagination__goto) {
  560. color: #000;
  561. }
  562. :deep(.el-pagination__classifier) {
  563. color: #000;
  564. }
  565. :deep(.el-input__wrapper) {
  566. border: 1px solid rgba(0, 0, 0, 1);
  567. border-radius: 5px;
  568. box-shadow: none;
  569. }
  570. :deep(.el-pager li) {
  571. margin: 0 5px;
  572. border: 1px solid rgba(0, 0, 0, 1);
  573. border-radius: 5px;
  574. background-color: transparent;
  575. }
  576. :deep(.el-pager li.is-active) {
  577. background-color: rgba(111, 182, 184, 1);
  578. }
  579. :deep(.btn-prev) {
  580. margin-right: 5px;
  581. border: 1px solid rgba(0, 0, 0, 1);
  582. border-radius: 5px;
  583. background-color: transparent;
  584. }
  585. :deep(.btn-next) {
  586. margin-left: 5px;
  587. border: 1px solid rgba(0, 0, 0, 1);
  588. border-radius: 5px;
  589. background-color: transparent;
  590. }
  591. }
  592. }
  593. .el-input {
  594. width: 192px;
  595. }
  596. </style>