| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646 |
- <template>
- <div class="content-box">
- <div class="left">
- <!-- <el-icon :size="23" class="camera"><VideoCameraFilled /></el-icon> -->
- <span class="cameratxt">消息通知</span>
- </div>
- <div class="middle">
- <div class="filter">
- <div class="condition">
- <span>创建时间 : </span>
- <el-date-picker
- v-model="searchInput.createTime"
- type="date"
- placeholder="请选择时间"
- format="YYYY-MM-DD"
- value-format="YYYY-MM-DD"
- />
- </div>
- <div class="condition">
- <span>状态 : </span>
- <el-select
- style="width: 120px"
- v-model="searchInput.state"
- class="m-2"
- placeholder="请选择状态"
- >
- <el-option label="全部" value="2" />
- <el-option label="已读" value="1" />
- <el-option label="未读" value="0" />
- </el-select>
- </div>
- <el-button
- style="margin-left: 20px"
- color="rgba(61, 81, 232, 1)"
- type="primary"
- class="search"
- @click="searchBtn"
- ><el-icon><Search /></el-icon> <span>搜索</span></el-button
- >
- </div>
- <!-- 按钮列表 -->
- <div class="gongneng">
- <el-button type="primary" color="rgba(61, 81, 232, 1)" @click="reset"
- ><el-icon><RefreshRight /></el-icon><span>刷新</span></el-button
- >
- <el-button type="danger" @click="allLook" color="rgba(61, 81, 232, 1)">
- <img
- src="@/assets/read.png"
- style="width: 14px; height: 14px; margin-right: 4px"
- alt=""
- />
- <span>一键已读</span></el-button
- >
- </div>
- <!-- 编辑/新增摄像头IP -->
- <el-dialog
- v-model="centerDialogVisible"
- :title="dialongTitle"
- width="40%"
- align-center
- :before-close="editClose"
- >
- <el-form
- ref="ruleFormRef"
- :model="ruleForm"
- :rules="rules"
- label-width="120px"
- class="demo-ruleForm"
- :size="formSize"
- status-icon
- >
- <el-form-item label="厂商" prop="count">
- <el-input v-model="ruleForm.count" placeholder="请输入厂商" />
- </el-form-item>
- <el-form-item label="IP地址" prop="name">
- <el-input v-model="ruleForm.name" placeholder="请输入IP地址" />
- </el-form-item>
- <el-form-item label="状态" prop="region">
- <el-select v-model="ruleForm.region" placeholder="请选择状态">
- <el-option label="在线" value="1" />
- <el-option label="离线" value="0" />
- </el-select>
- </el-form-item>
- <el-form-item
- label="创建人"
- prop="username"
- v-show="dialongTitle == '新增摄像头IP'"
- >
- <el-input
- v-model="ruleForm.username"
- placeholder="请输入创建人姓名"
- />
- </el-form-item>
- <el-form-item label="摄像头密码" prop="pass">
- <el-input v-model="ruleForm.pass" placeholder="请输入摄像头密码" />
- </el-form-item>
- <el-form-item
- label="最后更新人"
- prop="username"
- v-show="dialongTitle == '修改摄像头IP'"
- >
- <el-input
- v-model="ruleForm.username"
- placeholder="请输入更新人姓名"
- />
- </el-form-item>
- <el-form-item label="设备型号" prop="date1">
- <el-input v-model="ruleForm.date1" placeholder="请输入设备型号" />
- </el-form-item>
- <el-form-item label="协议" prop="types">
- <el-input
- v-model="ruleForm.types"
- placeholder="请输入协议"
- ></el-input>
- </el-form-item>
- <el-form-item label="安装位置" prop="date2">
- <el-input v-model="ruleForm.date2" placeholder="请输入安装位置" />
- </el-form-item>
- <el-form-item label="摄像机编码" prop="resource">
- <el-input
- v-model="ruleForm.resource"
- placeholder="请输入摄像机编码"
- >
- </el-input>
- </el-form-item>
- <el-form-item label="备注" prop="desc">
- <el-input
- v-model="ruleForm.desc"
- type="textarea"
- placeholder="请输入备注"
- />
- </el-form-item>
- <el-form-item>
- <el-button type="primary" @click="submitForm(ruleFormRef)">
- 确定
- </el-button>
- <el-button @click="resetForm(ruleFormRef)">重置</el-button>
- </el-form-item>
- </el-form>
- </el-dialog>
- </div>
- <div class="footer">
- <el-table
- :row-class-name="tableRowClassName"
- :data="tableData.list"
- @selection-change="handleSelectionChange"
- style="width: 100%"
- :header-cell-style="{
- background: 'rgba(240, 243, 247, 1)',
- height: '50px',
- border: 0,
- }"
- >
- <!-- <el-table-column align="center" type="selection" width="80" /> -->
- <el-table-column
- align="center"
- prop="create_time"
- label="创建时间"
- width="250"
- />
- <el-table-column align="center" prop="message" label="消息" />
- <el-table-column align="center" prop="state" label="状态" width="200">
- <template #default="scope">
- <div v-if="scope.row.state == 1">已读</div>
- <div v-else-if="scope.row.state == 0" style="color: red">未读</div>
- </template> </el-table-column
- >>
- <el-table-column align="center" label="操作" width="220">
- <template #default="scope">
- <el-button link type="primary" @click="look(scope.row)"
- ><div class="look">查看</div></el-button
- >
- </template>
- </el-table-column>
- </el-table>
- </div>
- <!-- 分页组件 -->
- <el-pagination
- background
- :current-page="currentPage"
- :page-size="pageSize"
- layout="total, prev, pager, next, jumper"
- :total="total"
- @update:current-page="handleCurrentChange"
- />
- </div>
- </template>
- <script setup>
- import { ref, reactive, nextTick, onBeforeMount, onUnmounted } from "vue";
- import { useRouter } from "vue-router";
- import { ElMessage, ElMessageBox } from "element-plus";
- import vidiconsApi from "@/api/vidicons.js";
- import { dayjs } from "element-plus";
- import lodash from "lodash";
- import axios from "axios";
- import { useStore } from "vuex";
- const store = useStore();
- const api = ref("");
- const router = useRouter();
- // 表格数据
- const tableData = reactive({ list: [] });
- const activeIndex = ref(); // 默认跳转路由
- const dialongTitle = ref(""); // 弹窗标题
- const searchInput = reactive({
- state: "全部",
- createTime: "",
- }); // 搜索按钮数据
- 5;
- const currentPage = ref(1); // 当前页
- const pageSize = ref(10);
- const total = ref(10); // 当前总数
- const selectData = reactive({ list: [] }); // 多选框选择的数据
- const centerDialogVisible = ref(false); // 控制新增或修改弹窗开关
- const videoDialogVisible = ref(false); // 控制播放弹窗开关
- const urlLink = ref(); // 输出链接
- // 表单数据
- const formSize = ref("default");
- const ruleFormRef = ref();
- const ruleForm = reactive({
- name: "",
- region: "",
- count: "",
- date1: "",
- date2: "",
- types: [],
- resource: "",
- desc: "",
- username: "",
- pass: "",
- id: "",
- });
- // 表单验证
- const rules = reactive({
- region: [
- {
- required: true,
- message: "状态不能为空",
- trigger: "blur",
- },
- ],
- name: [
- { required: true, message: "IP地址不能为空", trigger: "blur" },
- // { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
- ],
- count: [
- {
- required: true,
- message: "厂商不能为空",
- trigger: "blur",
- },
- ],
- date1: [
- {
- required: true,
- message: "设备型号不能为空",
- trigger: "blur",
- },
- ],
- date2: [
- {
- required: true,
- message: "安装位置不能为空",
- trigger: "blur",
- },
- ],
- types: [
- {
- required: true,
- message: "协议不能为空",
- trigger: "blur",
- },
- ],
- username: [
- {
- required: true,
- message: "更新人员姓名不能为空",
- trigger: "blur",
- },
- ],
- pass: [
- {
- required: true,
- message: "密码不能为空",
- trigger: "blur",
- },
- ],
- resource: [
- {
- required: true,
- message: "摄像机编码不能为空",
- trigger: "blur",
- },
- ],
- // desc: [{ required: true, message: "Please input activity form", trigger: "blur" }],
- });
- // 获取摄像头列表
- const getList = async () => {
- let data = new FormData();
- console.log(searchInput.state === 0);
- data.set("create_time", searchInput.createTime);
- if (searchInput.state == 2 || searchInput.state == "全部") {
- } else {
- data.set("state", searchInput.state);
- }
- data.set("page", currentPage.value);
- data.set("rows", pageSize.value); //前面的key记得对应!
- let res = await axios({
- method: "post",
- url: api.value + "/carBook/userqueryMes.action",
- headers: {
- token: sessionStorage.getItem("token"),
- },
- data: data,
- });
- console.log(res);
- if (res.status == 200) {
- tableData.list = res.data.rows;
- if (res.data.currentPage) {
- currentPage.value = res.data.currentPage;
- } else {
- currentPage.value = 1;
- }
- if (tableData.list) {
- let newsArr = tableData.list.filter((item) => {
- return item.state == 0;
- });
- console.log(newsArr.length);
- sessionStorage.setItem("newsNum", newsArr.length);
- } else {
- sessionStorage.setItem("newsNum", 0);
- }
- total.value = res.data.total;
- } else {
- tableData.list = res.data.rows;
- currentPage.value = 1;
- total.value = res.data.total;
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- if (res.data.message == "token错误") {
- router.push({
- path: `/login`,
- });
- }
- }
- };
- // 刷新
- const reset = async () => {
- searchInput.state = "全部";
- searchInput.createTime = "";
- let data = new FormData();
- console.log(searchInput.state === 0);
- data.set("page", currentPage.value);
- data.set("rows", pageSize.value); //前面的key记得对应!
- let res = await axios({
- method: "post",
- url: api.value + "/carBook/userqueryMes.action",
- headers: {
- token: sessionStorage.getItem("token"),
- },
- data: data,
- });
- console.log(res);
- if (res.status == 200) {
- tableData.list = res.data.rows;
- if (res.data.currentPage) {
- currentPage.value = res.data.currentPage;
- } else {
- currentPage.value = 1;
- }
- if (tableData.list) {
- let newsArr = tableData.list.filter((item) => {
- return item.state == 0;
- });
- console.log(newsArr.length);
- sessionStorage.setItem("newsNum", newsArr.length);
- } else {
- sessionStorage.setItem("newsNum", 0);
- }
- total.value = res.data.total;
- } else {
- tableData.list = res.data.rows;
- currentPage.value = 1;
- total.value = res.data.total;
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- if (res.data.message == "token错误") {
- router.push({
- path: `/login`,
- });
- }
- }
- };
- // 路由
- const handleSelect = (key, keyPath) => {};
- // 搜索功能
- const searchBtn = lodash.debounce(async () => {
- getList();
- }, 300);
- // 查看按钮
- const look = async (row) => {
- let data = new FormData();
- data.set("id", row.id);
- let res = await axios({
- method: "post",
- url: api.value + "/carBook/userupdateMesState.action",
- headers: {
- token: sessionStorage.getItem("token"),
- },
- data: data,
- });
- console.log(res);
- if (res.status == 200) {
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- };
- // 查看按钮
- const allLook = async (row) => {
- let data = new FormData();
- let res = await axios({
- method: "post",
- url: api.value + "/carBook/userupdateAllMesState.action",
- headers: {
- token: sessionStorage.getItem("token"),
- },
- data: data,
- });
- console.log(res);
- if (res.status == 200) {
- } else {
- ElMessage({
- type: "error",
- showClose: true,
- message: res.data.message,
- center: true,
- });
- }
- };
- // 多选框功能
- const handleSelectionChange = (val) => {
- console.log(val);
- selectData.list = val;
- };
- // 表格斑马纹颜色修改
- const tableRowClassName = ({ row, rowIndex }) => {
- if (rowIndex % 2 === 0) {
- return "even";
- } else if (rowIndex % 2 !== 0) {
- return "odd";
- }
- return "";
- };
- // 分页
- const handleCurrentChange = (value) => {};
- onBeforeMount(() => {
- api.value = store.state.user.api;
- getList();
- });
- onUnmounted(() => {
- // document.removeEventListener("keyup", Enters);
- });
- </script>
- <style scoped lang="scss">
- .content-box {
- width: 97.5%;
- height: 89%;
- margin: 20px auto;
- background-color: #fff;
- color: #fff;
- display: flex;
- flex-direction: column;
- .left {
- // width: calc(100wh - 40px);
- display: flex;
- align-items: center;
- height: 60px;
- margin: 0 30px;
- border-bottom: 1px solid #ccc;
- color: #000;
- font-size: 18px;
- font-weight: 600;
- .camera {
- margin-right: 15px;
- color: #4392f7;
- }
- }
- .middle {
- width: 96%;
- margin: 0 auto;
- color: #000;
- // border-bottom: 1px solid rgb(231, 231, 231);
- .filter {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- margin: 10px 0 0 0;
- .condition {
- display: flex;
- align-items: center;
- margin: 10px 30px 10px 0;
- span {
- margin: 0 10px 0 0;
- }
- }
- }
- .gongneng {
- margin: 10px 0;
- }
- :deep(.cont) {
- width: 60%;
- margin: 20px auto;
- }
- :deep(.download) {
- display: flex;
- align-items: center;
- margin: 10px;
- }
- :deep(.download span) {
- font-size: 16px;
- margin-left: 20px;
- }
- :deep(.cont .el-button) {
- margin-left: 60px;
- margin-bottom: 30px;
- }
- :deep(.cont .accomplish) {
- width: 100%;
- display: flex;
- justify-content: center;
- }
- :deep(.cont .accomplish .el-button) {
- width: 50%;
- margin: 0;
- }
- }
- .footer {
- width: 96%;
- height: 550px;
- margin: 10px auto 30px;
- .el-table--fit {
- height: 100%;
- :deep(.el-table__header-wrapper) {
- background-color: #000;
- }
- :deep(.el-table__row) {
- height: 50px;
- }
- :deep(.el-table__row td) {
- padding: 0;
- border: 0;
- }
- .el-button--primary {
- margin-left: 5px;
- }
- :deep(.el-table__body .even) {
- background-color: #fff;
- }
- :deep(.el-table__body .odd) {
- background-color: rgba(240, 243, 247, 1);
- }
- :deep(.look) {
- padding: 5px 14px;
- border-radius: 45px;
- border: 0.74px solid rgba(30, 125, 251, 1);
- }
- }
- }
- .el-pagination {
- // width: 1600px;
- width: 96%;
- margin: 0 auto 18px;
- justify-content: flex-end;
- :deep(.el-pagination__total) {
- color: #000;
- }
- :deep(.el-pagination__goto) {
- color: #000;
- }
- :deep(.el-pagination__classifier) {
- color: #000;
- }
- :deep(.el-input__wrapper) {
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- box-shadow: none;
- }
- :deep(.el-pager li) {
- margin: 0 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- :deep(.el-pager li.is-active) {
- background-color: rgba(30, 125, 251, 1);
- }
- :deep(.btn-prev) {
- margin-right: 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- :deep(.btn-next) {
- margin-left: 5px;
- border: 1px solid rgba(0, 0, 0, 1);
- border-radius: 5px;
- background-color: transparent;
- }
- }
- }
- .el-input {
- width: 192px;
- }
- </style>
|