Commit 5d0dbed6 authored by xinzhedeai's avatar xinzhedeai

视频监控配置

parent 79f5b388
import request from '@/utils/request'
export default {
// 监测点数据类型
monitoringPointDataTypes: () => {
return [{
key: 1, value: '开关量'
}, {
key: 2, value: '模拟量'
}]
},
// ID查询
getById: (id) => {
return request({
url: 'api/iot-normal-machine/environment/id',
method: 'get',
params: { id }
})
},
// page查询
getDataList: (pageParam) => {
return request({
url: 'api/video-mine',
method: 'get',
params: pageParam
})
},
// 新增
add: (iotNormalMachine) => {
return request({
url: 'api/video-mine',
method: 'post',
data: iotNormalMachine
})
},
// 修改
set: (iotNormalMachine) => {
return request({
url: 'api/video-mine',
method: 'put',
data: iotNormalMachine
})
},
// 删除
deleteById: (ids) => {
return request({
url: 'api/video-mine',
method: 'delete',
data: ids
})
},
// 根据企业查询所属矿山(含停产)enterpriseId
getAllMineByEnterpriseId: (mineSearchParam) => {
return request({
url: 'api/mine/all-mine/list',
method: 'get',
params: mineSearchParam
})
}
}
<template>
<div class="app-container">
<!--工具栏-->
<!-- 表单渲染 -->
<el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="520px">
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="80px">
<el-form-item label="角色名称" prop="name">
<el-input v-model="form.name" style="width: 380px;" />
</el-form-item>
<el-form-item label="角色级别" prop="level">
<el-input-number v-model.number="form.level" :min="1" controls-position="right" style="width: 145px;" />
</el-form-item>
<el-form-item label="数据范围" prop="dataScope">
<el-select v-model="form.dataScope" style="width: 140px" placeholder="请选择数据范围" @change="changeScope">
<el-option
v-for="item in dateScopes"
:key="item"
:label="item"
:value="item"
/>
</el-select>
</el-form-item>
<el-form-item label="描述信息" prop="description">
<el-input v-model="form.description" style="width: 380px;" rows="5" type="textarea" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
<el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
</div>
</el-dialog>
<el-row :gutter="15">
<!-- 菜单授权 -->
<el-col :span="6" style="margin-bottom: 10px">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<el-button
v-permission="['admin','roles:edit']"
icon="el-icon-plus"
size="mini"
style="float: right; padding: 6px 9px"
type="primary"
@click="saveMenu">
新建文件夹</el-button>
</div>
<el-tree
ref="menu"
lazy
:data="menus"
:default-checked-keys="menuIds"
:load="getMenuDatas"
:props="defaultProps"
check-strictly
accordion
show-checkbox
node-key="id"
@check="menuChange"
/>
</el-card>
</el-col>
<!--角色管理-->
<el-col :span="16">
<el-card class="box-card" shadow="never">
<div slot="header" class="clearfix">
<el-button type="primary" size="mini">上传文件</el-button>
<el-input v-model="query.blurry" size="small" clearable placeholder="输入名称或者描述搜索" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<date-range-picker v-model="query.createTime" class="date-item" />
<el-input v-model="query.blurry" size="small" clearable placeholder="查询文件名称" style="width: 200px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
<el-button type="primary" size="mini">查询</el-button>
</div>
<el-table ref="table" style="width: 100%;" :data="crud.data">
<el-table-column type="" width="55" />
<el-table-column prop="name" label="文件名称"/>
<el-table-column label="文件类型" prop="level" width="100" />
<el-table-column :show-overflow-tooltip="true" width="200px" prop="createTime" label="录入时间" />
<el-table-column v-if="checkPer(['admin','roles:edit','roles:del'])" label="操作" width="230px" align="center">
<template slot-scope="scope">
<el-button type="primary" size="mini">查看</el-button>
<el-button type="success" size="mini">下载</el-button>
<el-button type="danger" size="mini">删除</el-button>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import crudRoles from '@/api/system/role'
import { getDepts, getDeptSuperior } from '@/api/system/dept'
import { getMenusTree, getChild } from '@/api/system/menu'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import udOperation from '@crud/UD.operation'
import pagination from '@crud/Pagination'
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import { LOAD_CHILDREN_OPTIONS } from '@riophae/vue-treeselect'
import DateRangePicker from '@/components/DateRangePicker'
import { mapGetters } from 'vuex'
const defaultForm = { id: null, name: null, depts: [], description: null, dataScope: '全部', level: 3 }
export default {
name: 'Role',
components: { Treeselect, pagination, crudOperation, rrOperation, udOperation, DateRangePicker },
cruds() {
return CRUD({ title: '角色', url: 'api/roles', sort: 'level,asc', crudMethod: { ...crudRoles }})
},
mixins: [presenter(), header(), form(defaultForm), crud()],
data() {
return {
dateScopes: ["全部", "本级及以下", "自定义",],
defaultProps: { children: 'children', label: 'label', isLeaf: 'leaf' },
level: 3,
currentId: 0, currentName: '', menuLoading: false, showButton: false,
menus: [], menuIds: [], depts: [], deptDatas: [], // 多选时使用
permission: {
add: ['admin', 'roles:add'],
edit: ['admin', 'roles:edit'],
del: ['admin', 'roles:del']
},
rules: {
name: [
{ required: true, message: '请输入名称', trigger: 'blur' }
],
permission: [
{ required: true, message: '请输入权限', trigger: 'blur' }
]
}
}
},
computed: {
...mapGetters([
'user'
])
},
created() {
crudRoles.getLevel().then(data => {
this.level = data.level
})
},
methods: {
getMenuDatas(node, resolve) {
setTimeout(() => {
getMenusTree(node.data.id ? node.data.id : 0).then(res => {
if (this.user && this.user.isAdmin) {
res.forEach(menu => {
menu.label = (menu.enterpriseType === 0 ? '局)' : '企)') + menu.label
})
}
resolve(res)
})
}, 100)
},
[CRUD.HOOK.afterRefresh]() {
this.$refs.menu.setCheckedKeys([])
},
// 新增前初始化部门信息
[CRUD.HOOK.beforeToAdd](crud, form) {
this.deptDatas = []
form.menus = null
},
// 编辑前初始化自定义数据权限的部门信息
[CRUD.HOOK.beforeToEdit](crud, form) {
this.deptDatas = []
const _this = this
form.depts.forEach(function(dept) {
_this.deptDatas.push(dept.id)
})
// 将角色的菜单清空,避免日志入库数据过长
form.menus = null
},
// 提交前做的操作
[CRUD.HOOK.afterValidateCU](crud) {
// crud.form.dataScope = '全部'
// crud.form.depts = []
return true
},
// 触发单选
handleCurrentChange(val) {
if (val) {
const _this = this
// 清空菜单的选中
this.$refs.menu.setCheckedKeys([])
// 保存当前的角色id
this.currentId = val.id
this.currentName = val.name
// 初始化默认选中的key
this.menuIds = []
val.menus.forEach(function(data) {
_this.menuIds.push(data.id)
})
this.showButton = true
}
},
menuChange(menu) {
// 获取该节点的所有子节点,id 包含自身
getChild(menu.id).then(childIds => {
// 判断是否在 menuIds 中,如果存在则删除,否则添加
if (this.menuIds.indexOf(menu.id) !== -1) {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
if (index !== -1) {
this.menuIds.splice(index, 1)
}
}
} else {
for (let i = 0; i < childIds.length; i++) {
const index = this.menuIds.indexOf(childIds[i])
if (index === -1) {
this.menuIds.push(childIds[i])
}
}
}
this.$refs.menu.setCheckedKeys(this.menuIds)
})
},
// 保存菜单
saveMenu() {
this.menuLoading = true
const role = { id: this.currentId, menus: [] }
// 得到已选中的 key 值
this.menuIds.forEach(function(id) {
const menu = { id: id }
role.menus.push(menu)
})
crudRoles.editMenu(role).then(() => {
this.crud.notify('保存成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
this.menuLoading = false
this.update()
}).catch(err => {
this.menuLoading = false
console.log(err.response.data.message)
})
},
// 改变数据
update() {
// 无刷新更新 表格数据
crudRoles.get(this.currentId).then(res => {
for (let i = 0; i < this.crud.data.length; i++) {
if (res.id === this.crud.data[i].id) {
this.crud.data[i] = res
break
}
}
})
},
// 获取部门数据
getDepts() {
getDepts({ enabled: true }).then(res => {
this.depts = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
})
},
getSupDepts(depts) {
const ids = []
depts.forEach(dept => {
ids.push(dept.id)
})
getDeptSuperior(ids).then(res => {
const date = res.content
this.buildDepts(date)
this.depts = date
})
},
buildDepts(depts) {
depts.forEach(data => {
if (data.children) {
this.buildDepts(data.children)
}
if (data.hasChildren && !data.children) {
data.children = null
}
})
},
// 获取弹窗内部门数据
loadDepts({ action, parentNode, callback }) {
if (action === LOAD_CHILDREN_OPTIONS) {
getDepts({ enabled: true, pid: parentNode.id }).then(res => {
parentNode.children = res.content.map(function(obj) {
if (obj.hasChildren) {
obj.children = null
}
return obj
})
setTimeout(() => {
callback()
}, 200)
})
}
},
// 如果数据权限为自定义则获取部门数据
changeScope() {
if (this.form.dataScope === '自定义') {
this.getDepts()
}
},
checkboxT(row) {
return row.level >= this.level
}
}
}
</script>
<style rel="stylesheet/scss" lang="scss">
.role-span {
font-weight: bold;color: #303133;
font-size: 15px;
}
</style>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
::v-deep .vue-treeselect__multi-value{
margin-bottom: 0;
}
::v-deep .vue-treeselect__multi-value-item{
border: 0;
padding: 0;
}
</style>
\ No newline at end of file
<template>
<div class="app-container">
<!--工具栏-->
<div class="head-container">
<!-- <div>
<el-input
v-model="searchParam.mineName"
clearable
size="small"
placeholder="所属矿山"
style="width: 400px"
class="filter-item"
/>
<el-button
class="filter-item"
size="mini"
type="success"
icon="el-icon-search"
@click="searchSubmit"
>搜索</el-button
>
<el-button
class="filter-item"
size="mini"
type="warning"
icon="el-icon-refresh-left"
@click="searchParamReset"
>重置</el-button
>
</div> -->
<el-button
class="filter-item"
size="mini"
type="primary"
icon="el-icon-plus"
@click="doAdd()"
>新增</el-button
>
</div>
<!--弹出框1-->
<el-dialog
append-to-body
:close-on-click-modal="true"
:visible.sync="dialog1Show"
title="矿山-摄像头资料"
width="960px"
>
<el-form
ref="dialog1Form"
:hide-required-asterisk="!dialog1Editing"
:model="dialog1Data"
:rules="dialog1Rules"
size="mini"
label-width="180px"
style="margin-right: 80px"
>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="所属企业:" prop="enterpriseId">
<el-select
v-model="dialog1Data.enterpriseId"
placeholder="请选择"
@change="enterpriseChange"
style="width: 400px"
>
<el-option
v-for="item in options4enterpriseIdList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item label="所属矿山:" prop="mine_id">
<el-select
v-model="mine_id"
placeholder="请选择"
clearable
size="small"
class="filter-item"
style="width: 400px"
>
<el-option
v-for="(mine, key) in mineList"
:key="key"
:label="mine.name"
:value="mine.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="appKey:" prop="appKey">
<el-input
v-model="dialog1Data.appKey"
:disabled="editState == 3"
maxlength="100"
/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="appSecret:" prop="appSecret">
<el-input
v-model="dialog1Data.appSecret"
:disabled="editState == 3"
maxlength="100"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div style="margin: 10px 0">
<!-- <el-divider></el-divider>
<h5>监控摄像头</h5> -->
<el-divider content-position="left">通道列表</el-divider>
<div
style="margin: 10px 0; padding-left: 30px"
v-for="(employee, eIndex) in dialog1Data.videoChannelList"
:key="eIndex"
>
<el-input
v-model="employee.channel"
placeholder="通道(如:1.hd.live)"
type="text"
style="width: 200px"
:disabled="editState == 3"
/>
<el-input
v-model="employee.id"
placeholder="萤石云ID(G67791073)"
type="text"
style="width: 200px"
:disabled="editState == 3"
/>
<el-input
v-model="employee.name"
placeholder="名称"
type="text"
style="width: 200px"
:disabled="editState == 3"
/>
<el-input
v-model="employee.remark"
placeholder="备注"
type="text"
style="width: 200px"
:disabled="editState == 3"
/>
<el-button
v-if="eIndex===0"
type="primary"
@click="addEmployee"
:disabled="editState == 3"
>新增</el-button
>
<el-button
type="danger"
@click="deleteEmployee(index, eIndex)"
v-if="eIndex > 0"
:disabled="editState == 3"
>删除</el-button
>
</div>
</div>
<div v-show="dialog1Editing" slot="footer" class="dialog-footer">
<el-button type="text" @click="dialog1Show = false">取消</el-button>
<el-button
:loading="dialog1Saving"
type="primary"
@click="dialog1Submit"
>确认</el-button
>
</div>
</el-dialog>
<!--表格-->
<el-table ref="table" v-loading="searching" :data="tableData" row-key="id">
<el-table-column
:show-overflow-tooltip="true"
prop="id"
label="ID"
width="100px"
align="center"
/>
<el-table-column
:show-overflow-tooltip="true"
prop="appKey"
label="APPKEY"
align="center"
/>
<el-table-column
:show-overflow-tooltip="true"
prop="appSecret"
label="APPSECRET"
align="center"
/>
<el-table-column
:show-overflow-tooltip="true"
prop="mineName"
label="所属矿山"
align="center"
/>
<el-table-column label="操作" width="300px" align="center" fixed="right">
<template slot-scope="scope">
<el-button size="mini" round @click="doEdit(scope.row, false)"
>查看</el-button
>
<el-button size="mini" round @click="doEdit(scope.row, true)"
>修改</el-button
>
<el-button size="mini" round @click="doDelete(scope.row.id)"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<el-pagination
:page-sizes="[10, 20, 50, 100]"
:current-page.sync="searchParam.page"
:page-size.sync="searchParam.count"
:total="searchResult.total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="searchSubmit"
@current-change="searchSubmit"
/>
</div>
</template>
<script>
import videoConfigApi from "@/api/kd/videoConfig";
import { getToken } from "@/utils/auth";
import {getCompanyList} from '@/api/system/user'
const searchParam = {
// 默认搜索条件
page: 1,
size: 10,
mineName: "",
};
export default {
name: "videoConfig", // 本页面名
data() {
return {
mine_id: '',
options4enterpriseIdList: [],
mineList: [],
selectedMine: {},
httpHeaders: {
Authorization: getToken(),
},
videoConfigApi: videoConfigApi,
searching: false,
exporting: false,
searchParam: {},
searchResult: {
total: 0,
results: [], // 搜索结果
},
dialog1Show: false,
dialog1Editing: false,
dialog1Saving: false,
dialog1Data: {
videoChannelList: [
{
channel: "",
id: "",
name: "",
remark: "",
},
],
},
dialog1Rules: {
enterpriseId: [{ required: true, message: '请选择' }],
appKey: [{ required: true, message: "请填写" }],
mine_id: [{ required: true, message: "请选择" }],
appSecret: [{ required: true, message: "请填写" }],
},
editState: 0, // (刚打开窗口时)记录了上次窗口作用;(保存编辑时)记录了当前窗口作用; 0无 1新增 2修改 3查看
addingData: {
videoChannelList: [
{
channel: "",
id: "",
name: "",
remark: "",
},
],
}, // 上次正在新增时的内容,下次打开dialog1窗口时记录下来
};
},
computed: {
tableData() {
// 此处对返回值进行算法重组
return this.searchResult.results;
},
},
mounted() {
this.searchParamReset();
this.searchSubmit();
// 获取企业公司
getCompanyList({})
.then((res) => {
this.options4enterpriseIdList = res.body;
});
},
methods: {
getMineTypeByMineId(mineId){
return this.mineList.find((item)=>{
return item.id = mineId
})['type']
},
validData(data){
return data.filter((item) => {
return !item.channel || !item.id || !item.name
}).length
},
enterpriseChange(value){
this.mine_id = ''
// 矿山选项卡
this.getAllMineByEnterpriseId(value)
},
getAllMineByEnterpriseId(enterpriseId){
videoConfigApi.getAllMineByEnterpriseId({
enterpriseId
}).then(response => {
this.mineList = response.body
// this.mine_id = ''
})
},
addEmployee() {
// 添加组成员
this.dialog1Data.videoChannelList.unshift({
channel: "",
id: "",
name: "",
remark: "",
});
},
deleteEmployee(index, eIndex) {
this.dialog1Data.videoChannelList.splice(
eIndex,
1
);
},
searchParamReset() {
this.searchParam = JSON.parse(JSON.stringify(searchParam));
},
searchSubmit() {
this.searching = true;
videoConfigApi
.getDataList(this.searchParam)
.then((response) => {
console.log()
this.searching = false;
this.searchResult.results = response.body.results;
})
.catch(() => {
this.searching = false;
});
},
dialog1Submit() {
this.$refs["dialog1Form"].validate((valid) => {
if (valid) {
if(!!this.validData(this.dialog1Data.videoChannelList)){
this.$message.warning('通道数据存在空项,请确认')
return
}
this.dialog1Saving = true;
this.dialog1Data.mineType = this.getMineTypeByMineId(this.mine_id)
this.dialog1Data.mineId = this.mine_id
// this.mine_id = "1"; // 地下矿山
if (this.editState === 1) {
videoConfigApi
.add(this.dialog1Data)
.then(() => {
this.dialog1Show = false;
this.$message.success("保存成功");
setTimeout(() => {
// 立即清除会导致输入框Validate一闪变红
this.dialog1Data = {};
this.dialog1Saving = false;
}, 500);
this.searchSubmit();
})
.catch(() => {
this.dialog1Saving = false;
});
} else if (this.editState === 2) {
// 修改
videoConfigApi
.set(this.dialog1Data)
.then(() => {
this.dialog1Show = false;
this.$message.success("修改成功");
setTimeout(() => {
// 立即清除会导致输入框Validate一闪变红
this.dialog1Data = {};
this.dialog1Saving = false;
}, 500);
this.searchSubmit();
})
.catch(() => {
this.dialog1Saving = false;
});
} else {
this.$message.error("出错啦,请重试");
this.dialog1Saving = false;
}
}
});
},
beforeDialog1Open() {
// 窗口打开前的统一操作
if (this.editState === 1) {
this.addingData = this.dialog1Data;
}
},
doAdd() {
this.beforeDialog1Open();
this.editState = 1;
this.dialog1Editing = true;
this.dialog1Data = this.addingData; // 初始值:上次编辑的内容
this.dialog1Show = true;
this.$nextTick(() => {
this.$refs["dialog1Form"].clearValidate();
});
},
doEdit(row, isEdit) {
this.beforeDialog1Open();
this.editState = isEdit ? 2 : 3;
this.dialog1Data = row;
this.mine_id = row.mineId
this.dialog1Editing = isEdit;
this.dialog1Show = true;
this.$refs["dialog1Form"].clearValidate();
// videoConfigApi
// .getById(id)
// .then((response) => {
// this.dialog1Data = response;
// this.dialog1Editing = isEdit;
// this.dialog1Show = true;
// this.$nextTick(() => {
// this.$refs["dialog1Form"].clearValidate();
// this.getAllMineByEnterpriseId(this.dialog1Data.enterpriseId);
// });
// })
// .catch(() => {
// this.searchSubmit();
// });
},
doDelete(id) {
this.$confirm("确定要删除吗?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
}).then(
() => {
videoConfigApi.deleteById([id]).then((response) => {
this.searchSubmit();
});
},
() => {
this.$message({
type: "info",
message: "已取消删除",
});
}
);
},
},
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
text-align: left;
}
::v-deep .vue-treeselect__control,
::v-deep .vue-treeselect__placeholder,
::v-deep .vue-treeselect__single-value {
height: 30px;
line-height: 30px;
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment