|
@@ -0,0 +1,271 @@
|
|
|
+<template>
|
|
|
+ <div style="padding: 20px; box-sizing: border-box">
|
|
|
+ <el-form inline>
|
|
|
+ <el-form-item label="功能区名称">
|
|
|
+ <el-input v-model="name"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary">查询</el-button>
|
|
|
+ <el-button type="success" @click="add">新增功能区</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <br>
|
|
|
+ <el-table height="600" :data="list" border>
|
|
|
+ <el-table-column label="功能区名称" prop="functionName"></el-table-column>
|
|
|
+ <el-table-column label="备注" prop="remark"></el-table-column>
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button @click="open(scope.row)" size="mini" type="primary">添加摄像头</el-button>
|
|
|
+ <el-button @click="edit(scope.row)" size="mini" >编辑</el-button>
|
|
|
+ <el-popconfirm
|
|
|
+ title=" 确定要删除这个功能区吗?"
|
|
|
+ @confirm="del(scope.row)"
|
|
|
+ >
|
|
|
+ <el-button style="margin-left: 10px" type="danger" size="mini" slot="reference">删除</el-button>
|
|
|
+ </el-popconfirm>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ <table-footer
|
|
|
+ :page-num="pageNum"
|
|
|
+ :totals="total"
|
|
|
+ :size="pageSize"
|
|
|
+ @sizeChange="sizeChange"
|
|
|
+ @pageChange="pageChange"></table-footer>
|
|
|
+ <!-- 新增编辑 -->
|
|
|
+ <el-dialog
|
|
|
+ :title="showType ? '编 辑' : '新 增'"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ @close="reset"
|
|
|
+ width="20%">
|
|
|
+ <div>
|
|
|
+ <el-form ref="form" :model="form" :rules="rules" label-width="80px" size="mini">
|
|
|
+ <el-form-item label="功能名称" prop="functionName">
|
|
|
+ <el-input v-model="form.functionName"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注">
|
|
|
+ <el-input v-model="form.remark"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="reset">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit('form')">{{showType ? '更 新' : '新 增'}}</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ <el-dialog title="选择监控" :visible.sync="showModal" @close="modalReset">
|
|
|
+ <el-tree
|
|
|
+ ref="myTree"
|
|
|
+ node-key="id"
|
|
|
+ show-checkbox
|
|
|
+ default-expand-all
|
|
|
+ check-strictly
|
|
|
+ :default-checked-keys="checkedKeys"
|
|
|
+ :data="monitList"
|
|
|
+ :props="{ label: 'cameraName', children: 'cameraList', disabled: 'selectable'}"
|
|
|
+ @check="handlerSelect"
|
|
|
+ ></el-tree>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="modalReset">取 消</el-button>
|
|
|
+ <el-button type="primary" :disabled="isButton" @click="onCheckSave">保存</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {addFunctionMonit, editFunctionMonit, getFunctionMonitList, delFunctionMonit , getVideoAll, cameraFunctionList, addCameraFunction} from "../../utils/api";
|
|
|
+import TableFooter from "../../components/TableFooter";
|
|
|
+// import { Tree as ATree } from "ant-design-vue";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "FunctionMonit",
|
|
|
+ components: {
|
|
|
+ TableFooter,
|
|
|
+ // ATree
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ name: '',
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20,
|
|
|
+ list: [],
|
|
|
+ total: 0,
|
|
|
+ dialogVisible: false,
|
|
|
+ showType: false,
|
|
|
+ rules: {
|
|
|
+ functionName: [ { required: true, message: '区域名称不能为空', trigger: 'blur' } ],
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ functionName: '',
|
|
|
+ remark: '',
|
|
|
+ },
|
|
|
+ showModal: false,
|
|
|
+ monitList: [],
|
|
|
+ checkedKeys: [],
|
|
|
+ isButton: true,
|
|
|
+ selectId: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 修改size
|
|
|
+ sizeChange(val) {
|
|
|
+ this.pageSize = val;
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ // 修改页数
|
|
|
+ pageChange(val) {
|
|
|
+ this.pageNum= val;
|
|
|
+ this.init();
|
|
|
+ },
|
|
|
+ init() {
|
|
|
+ let params = {
|
|
|
+ current: this.pageNum,
|
|
|
+ size: this.pageSize,
|
|
|
+ functionName: this.name
|
|
|
+ }
|
|
|
+ getFunctionMonitList(params).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.list = res.data.records;
|
|
|
+ this.total = res.data.total;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ reset() {
|
|
|
+ this.form = {
|
|
|
+ functionName: '',
|
|
|
+ remark: '',
|
|
|
+ }
|
|
|
+ this.dialogVisible = false;
|
|
|
+ this.showType = false;
|
|
|
+ },
|
|
|
+ add() {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.showType = false;
|
|
|
+ },
|
|
|
+ edit(row) {
|
|
|
+ this.dialogVisible = true;
|
|
|
+ this.showType = true;
|
|
|
+ this.form = {
|
|
|
+ id: row.id,
|
|
|
+ functionName: row.functionName,
|
|
|
+ remark: row.remark
|
|
|
+ }
|
|
|
+ },
|
|
|
+ del(row) {
|
|
|
+ let params = {
|
|
|
+ ids: row.id
|
|
|
+ }
|
|
|
+ delFunctionMonit(params).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ this.$message.success(res.message)
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onSubmit(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (this.showType) {
|
|
|
+ // 编辑
|
|
|
+ let params = {
|
|
|
+ id: this.form.id,
|
|
|
+ functionName: this.form.functionName,
|
|
|
+ remark: this.form.remark
|
|
|
+ }
|
|
|
+ editFunctionMonit(params).then(res => {
|
|
|
+ this.reset()
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ this.$message.success(res.message)
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 新增
|
|
|
+ let params = {
|
|
|
+ functionName: this.form.functionName,
|
|
|
+ remark: this.form.remark
|
|
|
+ }
|
|
|
+ addFunctionMonit(params).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.init();
|
|
|
+ this.$message.success(res.message);
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.reset()
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ initMonit() {
|
|
|
+ getVideoAll({}).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ res.data.forEach(items => {
|
|
|
+ items.selectable = true
|
|
|
+ items.cameraList.forEach(item => {
|
|
|
+ item.selectable = false
|
|
|
+ })
|
|
|
+ })
|
|
|
+ this.monitList = res.data;
|
|
|
+ console.log(this.monitList)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ open(row) {
|
|
|
+ this.selectId = row.id;
|
|
|
+ this.showModal = true;
|
|
|
+ let params = {
|
|
|
+ functionId: this.selectId,
|
|
|
+ }
|
|
|
+ cameraFunctionList(params).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.checkedKeys = res.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ handlerSelect(val, check) {
|
|
|
+ this.checkedKeys = check.checkedKeys;
|
|
|
+ this.isButton = false;
|
|
|
+ },
|
|
|
+ onCheckSave() {
|
|
|
+ let params = {
|
|
|
+ functionId: this.selectId,
|
|
|
+ carmeraId: this.checkedKeys.join(',')
|
|
|
+ }
|
|
|
+ addCameraFunction(params).then(res => {
|
|
|
+ if(res.code === 10000) {
|
|
|
+ this.$message.success(res.message);
|
|
|
+ } else {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ }
|
|
|
+ }).finally(() => {
|
|
|
+ this.checkedKeys = [];
|
|
|
+ this.showModal = false;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ modalReset() {
|
|
|
+ this.checkedKeys = [];
|
|
|
+ this.showModal = false;
|
|
|
+ this.$refs.myTree.setCheckedKeys([]);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.init()
|
|
|
+ this.initMonit()
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|