parent
cb38e05a02
commit
dbb6c528f8
11 changed files with 800 additions and 339 deletions
@ -1,342 +1,251 @@ |
|||||||
<template> |
<template> |
||||||
<basic-container> |
<basic-container> |
||||||
<avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel" |
<avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" :page.sync="page" |
||||||
v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" :before-open="beforeOpen" |
:permission="permissionList" @search-change="searchChange" @search-reset="searchReset" |
||||||
@search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
|
||||||
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"> |
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"> |
||||||
|
<template #menu="{ row, index }"> |
||||||
|
<el-button type="text" icon="el-icon-view" size="small" @click="rowView(row, index)">详情 |
||||||
|
</el-button> |
||||||
|
<el-button type="text" icon="el-icon-map-location" :disabled="row.x == null" size="small" @click="rowMap(row, index)">地图定位 |
||||||
|
</el-button> |
||||||
|
</template> |
||||||
</avue-crud> |
</avue-crud> |
||||||
|
<!-- 地图定位 --> |
||||||
|
<el-dialog v-if="dialogVisible" :visible.sync="dialogVisible" modal="false" append-to-body fullscreen> |
||||||
|
<MapView :name="sn" :x="x" :y="y"></MapView> |
||||||
|
</el-dialog> |
||||||
</basic-container> |
</basic-container> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script> |
<script> |
||||||
import { bizLogin, bizDeviceList, bizDeviceStatus, bizNodeType } from "@/api/wirelessintrusion/wirelessintrusion"; |
import { bizLogin, terminalList } from "@/api/wirelessintrusion/wirelessintrusion"; |
||||||
import { mapGetters } from "vuex"; |
import { mapGetters } from "vuex"; |
||||||
|
import { dateFormat } from "../../../util/date"; |
||||||
|
import MapView from "../../map/index.vue"; |
||||||
|
|
||||||
export default { |
export default { |
||||||
|
components: { |
||||||
|
MapView |
||||||
|
}, |
||||||
data() { |
data() { |
||||||
return { |
return { |
||||||
form: {}, |
|
||||||
query: {}, |
query: {}, |
||||||
loading: true, |
loading: true, |
||||||
page: { |
page: { |
||||||
pageSize: 10, |
size: 10, |
||||||
currentPage: 1, |
current: 1, |
||||||
total: 0 |
total: 0 |
||||||
}, |
}, |
||||||
selectionList: [], |
|
||||||
option: { |
option: { |
||||||
height: 'auto', |
|
||||||
calcHeight: 30, |
calcHeight: 30, |
||||||
dialogWidth: 950, |
|
||||||
tip: false, |
tip: false, |
||||||
searchShow: true, |
searchShow: true, |
||||||
searchMenuSpan: 6, |
searchMenuSpan: 6, |
||||||
border: true, |
border: true, |
||||||
index: true, |
index: true, |
||||||
|
selection: false, |
||||||
viewBtn: true, |
viewBtn: true, |
||||||
editBtn: false, |
|
||||||
delBtn: false, |
delBtn: false, |
||||||
addBtn: false, |
|
||||||
dialogClickModal: false, |
dialogClickModal: false, |
||||||
|
menuWidth: 180, |
||||||
column: [ |
column: [ |
||||||
{ |
{ |
||||||
label: "设备名称", |
label: "设备名称", |
||||||
prop: "name", |
prop: "name", |
||||||
span: 12, |
}, |
||||||
|
{ |
||||||
|
label:"sn编号", |
||||||
|
prop: "sn", |
||||||
search: true, |
search: true, |
||||||
formatter: (val, value, label) => { |
hide: true |
||||||
return val.name + '/' + val.remark |
|
||||||
}, |
|
||||||
labelWidth: 120 |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "备注名称", |
label: "建筑 id", |
||||||
prop: "remark", |
prop: "buildId", |
||||||
span: 12, |
|
||||||
hide: true, |
|
||||||
viewDisplay: true, |
|
||||||
labelWidth: 120 |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "设备所属产品", |
label: "楼层", |
||||||
prop: "name", |
prop: "floorNo", |
||||||
span: 12, |
|
||||||
labelWidth: 120 |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "节点类型", |
label: "x坐标", |
||||||
|
prop: "x", |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "y坐标", |
||||||
|
prop: "y", |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "工作状态", |
||||||
type: "select", |
type: "select", |
||||||
dicData: [], |
dicData: [ |
||||||
props: { |
{value:'work', label:"工作"},{value:'sleep', label:"休眠"} |
||||||
label: "dictLabel", |
], |
||||||
value: "dictValue" |
prop: "workStatus", |
||||||
}, |
|
||||||
search: true, |
|
||||||
prop: "node", |
|
||||||
labelWidth: 120, |
|
||||||
viewDisplay: false |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "节点类型", |
label: "通信状态", |
||||||
prop: "nodeLabel", |
type: "select", |
||||||
labelWidth: 120, |
dicData: [ |
||||||
hide: true, |
{value:0, label:"在线"},{value:1, label:"离线"} |
||||||
viewDisplay: true |
], |
||||||
|
prop: "communicateStatus", |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "网关信息", |
label: "最后一次通信时间", |
||||||
prop: "gateway", |
labelWidth: 150, |
||||||
formatter: (val, value, label) => { |
prop: "lastCommunicateTime", |
||||||
return val.gateway || '-' |
span: 24, |
||||||
|
formatter: (data, value) => { |
||||||
|
return dateFormat(new Date(data.lastCommunicateTime)) |
||||||
}, |
}, |
||||||
labelWidth: 120 |
hide: true |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "设备状态", |
label: "最后一次配置时间", |
||||||
type: "select", |
labelWidth: 150, |
||||||
dicData: [], |
prop: "lastConfigTime", |
||||||
props: { |
span: 24, |
||||||
label: "dictLabel", |
formatter: (data, value) => { |
||||||
value: "dictValue" |
return dateFormat(new Date(data.lastConfigTime)) |
||||||
}, |
}, |
||||||
search: true, |
hide: true |
||||||
prop: "status", |
|
||||||
labelWidth: 120, |
|
||||||
viewDisplay: false, |
|
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "节点类型", |
label: "最后一次定位时间", |
||||||
prop: "statusLabel", |
labelWidth: 150, |
||||||
labelWidth: 120, |
prop: "lastLocateTime", |
||||||
hide: true, |
span: 24, |
||||||
viewDisplay: true |
formatter: (data, value) => { |
||||||
|
return dateFormat(new Date(data.lastLocateTime)) |
||||||
|
}, |
||||||
|
hide:true |
||||||
}, |
}, |
||||||
{ |
{ |
||||||
label: "创建时间时间", |
label: "创建时间", |
||||||
prop: "createTime", |
prop: "createTime", |
||||||
labelWidth: 120, |
formatter: (data, value) => { |
||||||
hide: true, |
return dateFormat(new Date(data.createTime)) |
||||||
viewDisplay: true, |
} |
||||||
}, { |
|
||||||
label: "最后上线时间", |
|
||||||
prop: "lastOnline", |
|
||||||
labelWidth: 120 |
|
||||||
}, |
}, |
||||||
|
{ |
||||||
|
label: "更新时间", |
||||||
|
prop: "updateTime", |
||||||
|
formatter: (data, value) => { |
||||||
|
return dateFormat(new Date(data.updateTime)) |
||||||
|
}, |
||||||
|
hide:true |
||||||
|
} |
||||||
] |
] |
||||||
}, |
}, |
||||||
data: [], |
data: [], |
||||||
nodeType: [],//节点类型 |
submitLoading: false, |
||||||
|
buildingId: 202861, |
||||||
|
//地图定位查看 |
||||||
|
dialogVisible: false, |
||||||
|
sn: '', |
||||||
|
x: 0, |
||||||
|
y: 0, |
||||||
|
floorNo: 1 |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
computed: { |
computed: { |
||||||
...mapGetters(["permission"]), |
...mapGetters(["userInfo", "permission"]), |
||||||
permissionList() { |
permissionList() { |
||||||
return { |
return { |
||||||
addBtn: this.vaildData(this.permission.notice_add, false), |
addBtn: false, |
||||||
viewBtn: this.vaildData(this.permission.notice_view, false), |
viewBtn: false, |
||||||
delBtn: this.vaildData(this.permission.notice_delete, false), |
delBtn: true, |
||||||
editBtn: this.vaildData(this.permission.notice_edit, false) |
editBtn: false |
||||||
}; |
}; |
||||||
}, |
}, |
||||||
ids() { |
|
||||||
let ids = []; |
|
||||||
this.selectionList.forEach(ele => { |
|
||||||
ids.push(ele.id); |
|
||||||
}); |
|
||||||
return ids.join(","); |
|
||||||
} |
|
||||||
}, |
|
||||||
mounted() { |
|
||||||
}, |
}, |
||||||
methods: { |
methods: { |
||||||
//字典加载 |
//查看详情 |
||||||
loadDict() { |
rowView(row, index) { |
||||||
let token = window.sessionStorage.getItem('bizToken'); |
this.$refs.crud.rowView(row, index); |
||||||
if (token == 'undefined' || !token) { |
|
||||||
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res => { |
|
||||||
window.sessionStorage.setItem('bizToken', res.data.data.token); |
|
||||||
bizDeviceStatus(res.data.data.token).then(res => { |
|
||||||
const column = this.findObject(this.option.column, "status"); |
|
||||||
column.dicData = res.data.data; |
|
||||||
}) |
|
||||||
bizNodeType(res.data.data.token).then(res => { |
|
||||||
const column = this.findObject(this.option.column, "node"); |
|
||||||
column.dicData = res.data.data; |
|
||||||
}) |
|
||||||
}) |
|
||||||
} else { |
|
||||||
bizDeviceStatus(token).then(res => { |
|
||||||
if(res.data.code == 401){ |
|
||||||
window.sessionStorage.removeItem('bizToken'); |
|
||||||
this.loadDict(); |
|
||||||
} |
|
||||||
else if(res.data.code == 200){ |
|
||||||
const column = this.findObject(this.option.column, "status"); |
|
||||||
column.dicData = res.data.data; |
|
||||||
} |
|
||||||
}) |
|
||||||
bizNodeType(token).then(res => { |
|
||||||
const column = this.findObject(this.option.column, "node"); |
|
||||||
column.dicData = res.data.data; |
|
||||||
}) |
|
||||||
} |
|
||||||
}, |
}, |
||||||
//节点类型转换 |
//地图定位查看 |
||||||
renderLabel(node,col) { |
rowMap(row, index) { |
||||||
const column = this.findObject(this.option.column, col); |
if(row.x && row.y) { |
||||||
let idx = column.dicData.findIndex(item => item.dictValue == node); |
this.sn = row.sn; |
||||||
return idx > -1 ? column.dicData[idx].dictLabel : ''; |
this.x = row.x; |
||||||
|
this.y = row.y; |
||||||
|
this.floorNo = row.floorNo; |
||||||
|
console.log(this.sn,this.x,this.y) |
||||||
|
this.dialogVisible = true; |
||||||
|
} |
||||||
}, |
}, |
||||||
// rowSave(row, done, loading) { |
|
||||||
// add(row).then(() => { |
|
||||||
// this.onLoad(this.page); |
|
||||||
// this.$message({ |
|
||||||
// type: "success", |
|
||||||
// message: "操作成功!" |
|
||||||
// }); |
|
||||||
// done(); |
|
||||||
// }, error => { |
|
||||||
// window.console.log(error); |
|
||||||
// loading(); |
|
||||||
// }); |
|
||||||
// }, |
|
||||||
// rowUpdate(row, index, done, loading) { |
|
||||||
// update(row).then(() => { |
|
||||||
// this.onLoad(this.page); |
|
||||||
// this.$message({ |
|
||||||
// type: "success", |
|
||||||
// message: "操作成功!" |
|
||||||
// }); |
|
||||||
// done(); |
|
||||||
// }, error => { |
|
||||||
// window.console.log(error); |
|
||||||
// loading(); |
|
||||||
// }); |
|
||||||
// }, |
|
||||||
// rowDel(row) { |
|
||||||
// this.$confirm("确定将选择数据删除?", { |
|
||||||
// confirmButtonText: "确定", |
|
||||||
// cancelButtonText: "取消", |
|
||||||
// type: "warning" |
|
||||||
// }) |
|
||||||
// .then(() => { |
|
||||||
// return remove(row.id); |
|
||||||
// }) |
|
||||||
// .then(() => { |
|
||||||
// this.onLoad(this.page); |
|
||||||
// this.$message({ |
|
||||||
// type: "success", |
|
||||||
// message: "操作成功!" |
|
||||||
// }); |
|
||||||
// }); |
|
||||||
// }, |
|
||||||
searchReset() { |
searchReset() { |
||||||
this.query = {}; |
this.query = {}; |
||||||
this.onLoad(this.page); |
this.onLoad(this.page); |
||||||
}, |
}, |
||||||
searchChange(params, done) { |
searchChange(params, done) { |
||||||
this.query = params; |
this.query = params; |
||||||
this.page.currentPage = 1; |
this.page.current = 1; |
||||||
this.onLoad(this.page, params); |
this.onLoad(this.page, params); |
||||||
done(); |
done(); |
||||||
}, |
}, |
||||||
selectionChange(list) { |
currentChange(current) { |
||||||
this.selectionList = list; |
this.page.current = current; |
||||||
}, |
}, |
||||||
selectionClear() { |
sizeChange(size) { |
||||||
this.selectionList = []; |
this.page.size = size; |
||||||
this.$refs.crud.toggleSelection(); |
|
||||||
}, |
|
||||||
// handleDelete() { |
|
||||||
// if (this.selectionList.length === 0) { |
|
||||||
// this.$message.warning("请选择至少一条数据"); |
|
||||||
// return; |
|
||||||
// } |
|
||||||
// this.$confirm("确定将选择数据删除?", { |
|
||||||
// confirmButtonText: "确定", |
|
||||||
// cancelButtonText: "取消", |
|
||||||
// type: "warning" |
|
||||||
// }) |
|
||||||
// .then(() => { |
|
||||||
// return remove(this.ids); |
|
||||||
// }) |
|
||||||
// .then(() => { |
|
||||||
// this.onLoad(this.page); |
|
||||||
// this.$message({ |
|
||||||
// type: "success", |
|
||||||
// message: "操作成功!" |
|
||||||
// }); |
|
||||||
// this.$refs.crud.toggleSelection(); |
|
||||||
// }); |
|
||||||
// }, |
|
||||||
beforeOpen(done, type) { |
|
||||||
console.log(this.form) |
|
||||||
if (["edit", "view"].includes(type)) { |
|
||||||
// let token = window.sessionStorage.getItem('bizToken'); |
|
||||||
// if (token == 'undefined') { |
|
||||||
// bizDeviceDetail(this.form.id).then(res => { |
|
||||||
// this.form = res.data.data; |
|
||||||
// }); |
|
||||||
// } |
|
||||||
} |
|
||||||
done(); |
|
||||||
}, |
|
||||||
currentChange(currentPage) { |
|
||||||
this.page.currentPage = currentPage; |
|
||||||
}, |
|
||||||
sizeChange(pageSize) { |
|
||||||
this.page.pageSize = pageSize; |
|
||||||
}, |
}, |
||||||
refreshChange() { |
refreshChange() { |
||||||
this.onLoad(this.page, this.query); |
this.onLoad(this.page, this.query); |
||||||
}, |
}, |
||||||
onLoad(page, params = {}) { |
onLoad(page, params = {}) { |
||||||
let values = { |
|
||||||
...params, |
|
||||||
...this.query, |
|
||||||
pid: 98 |
|
||||||
}; |
|
||||||
let token = window.sessionStorage.getItem('bizToken'); |
let token = window.sessionStorage.getItem('bizToken'); |
||||||
if (token == 'undefined' || !token) { |
if (token == 'undefined' || !token) { |
||||||
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res => { |
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res => { |
||||||
window.sessionStorage.setItem('bizToken', res.data.data.token); |
window.sessionStorage.setItem('bizToken', res.data.data.token); |
||||||
this.loading = true; |
this.loading = true; |
||||||
bizDeviceList(res.data.data.token, { ...values, pageSize: page.pageSize, pageNo: page.currentPage }).then(res2 => { |
terminalList(res.data.data.token, Object.assign(params, this.query, { page: page.currentPage, size: page.pageSize, buildingIds: this.buildingId })).then(res2 => { |
||||||
const data = res2.data; |
this.loading = false; |
||||||
this.page.total = data.total; |
if (res2.data.code == 401) { |
||||||
this.data = data.records; |
window.sessionStorage.removeItem('bizToken'); |
||||||
|
this.onLoad(this.page); |
||||||
|
} |
||||||
|
else { |
||||||
|
const data = res2.data.data; |
||||||
|
this.page.total = data.totalElements; |
||||||
|
this.data = data.content; |
||||||
|
} |
||||||
|
}, err => { |
||||||
this.loading = false; |
this.loading = false; |
||||||
this.selectionClear(); |
|
||||||
}); |
}); |
||||||
}) |
}) |
||||||
} else { |
} |
||||||
|
else { |
||||||
this.loading = true; |
this.loading = true; |
||||||
bizDeviceList(token, { ...values, pageSize: page.pageSize, pageNo: page.currentPage }).then(res2 => { |
terminalList(token, Object.assign(params, this.query, { page: page.currentPage, size: page.pageSize, buildingIds: this.buildingId })).then(res2 => { |
||||||
this.loading = false; |
this.loading = false; |
||||||
this.selectionClear(); |
if (res2.data.code == 401) { |
||||||
if(res2.data.code == 401){ |
|
||||||
console.log(res2.data.code) |
|
||||||
window.sessionStorage.removeItem('bizToken'); |
window.sessionStorage.removeItem('bizToken'); |
||||||
this.onLoad(); |
this.onLoad(this.page); |
||||||
} |
} |
||||||
else if(res2.data.code == 200){ |
else { |
||||||
const data = res2.data; |
const data = res2.data.data; |
||||||
this.page.total = data.total; |
this.page.total = data.totalElements; |
||||||
data.rows.map(item => { |
this.data = data.content; |
||||||
item.node = item.bizProduct.node; |
|
||||||
item.nodeLabel = this.renderLabel(item.node,'node'); |
|
||||||
item.statusLabel = this.renderLabel(item.status,'status') |
|
||||||
}) |
|
||||||
this.data = data.rows; |
|
||||||
} |
} |
||||||
}, err => { |
}, err => { |
||||||
this.loading = false; |
this.loading = false; |
||||||
this.selectionClear(); |
|
||||||
}); |
}); |
||||||
} |
} |
||||||
} |
}, |
||||||
} |
} |
||||||
}; |
}; |
||||||
</script> |
</script> |
||||||
|
|
||||||
<style></style> |
<style lang="scss" scoped> |
||||||
|
.el-table { |
||||||
|
width: 100% !important; |
||||||
|
border: 1px solid #D6D8DF; |
||||||
|
} |
||||||
|
|
||||||
|
.el-table th.el-table__cell { |
||||||
|
background: #F7F8FA; |
||||||
|
} |
||||||
|
</style> |
||||||
|
|||||||
@ -0,0 +1,444 @@ |
|||||||
|
<template> |
||||||
|
<basic-container> |
||||||
|
<avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" :page.sync="page" |
||||||
|
:permission="permissionList" @search-change="searchChange" @search-reset="searchReset" |
||||||
|
@current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"> |
||||||
|
<template slot="menuLeft"> |
||||||
|
<el-button type="primary" size="small" icon="el-icon-plus" plain @click="rowAdd">新增 |
||||||
|
</el-button> |
||||||
|
</template> |
||||||
|
<template #menu="{ row, index }"> |
||||||
|
<el-button type="text" icon="el-icon-view" size="small" @click="rowView(row)">详情 |
||||||
|
</el-button> |
||||||
|
<el-button type="text" icon="el-icon-edit" size="small" @click="rowEdit(row)">编辑 |
||||||
|
</el-button> |
||||||
|
<el-button type="text" icon="el-icon-delete" size="small" @click="rowDel(row)">删除 |
||||||
|
</el-button> |
||||||
|
</template> |
||||||
|
</avue-crud> |
||||||
|
<!-- 新增 编辑 详情 --> |
||||||
|
<el-dialog :title="title" :visible.sync="dialogVisible" :append-to-body="true" :close-on-click-modal="false" |
||||||
|
:close-on-press-escape="false" width="800px"> |
||||||
|
<el-form ref="addForm" :model="addForm" :rules="rules" label-width="80px"> |
||||||
|
<el-row :gutter="20"> |
||||||
|
<el-col :span="12"> |
||||||
|
<el-form-item label="建筑ID" prop="buildingId"> |
||||||
|
<el-input v-model="addForm.buildingId" placeholder="请输入建筑ID" disabled maxlength="10" /> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
<el-col :span="12"> |
||||||
|
<el-form-item label="区域名称" prop="name"> |
||||||
|
<el-input v-model="addForm.name" placeholder="请输入围栏名称" :disabled="type == 'view'" maxlength="30" /> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
</el-row><el-form-item label="选择电子围栏:"> |
||||||
|
<el-table class="table_box" ref="multipleTable" row-key="_id" :data="tableData" tooltip-effect="dark" |
||||||
|
style="width: 100%" @selection-change="handleSelectionChange" size="small"> |
||||||
|
<el-table-column type="selection" width="55" align="center" reserve-selection :selectable="selectable"> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="name" label="围栏名称"></el-table-column> |
||||||
|
<el-table-column prop="floorNo" label="楼层编号"> |
||||||
|
</el-table-column> |
||||||
|
<el-table-column prop="type" label="围栏类型"> |
||||||
|
<template slot-scope="scope"> |
||||||
|
{{ scope.row.type == 0 ? '当前楼层' : scope.row.type == 1 ? '当前楼层' : ''}} |
||||||
|
</template> |
||||||
|
</el-table-column> |
||||||
|
</el-table> |
||||||
|
<div class="page_box"> |
||||||
|
<el-pagination @current-change="handleCurrentRailsChange" |
||||||
|
:current-page="diaPage.currentPage" background |
||||||
|
layout="total, prev, pager, next, jumper" :total="diaPage.total"> |
||||||
|
</el-pagination> |
||||||
|
</div> |
||||||
|
</el-form-item> |
||||||
|
<el-row :gutter="20"> |
||||||
|
<el-col :span="24"> |
||||||
|
<el-form-item label="备注" prop="remark"> |
||||||
|
<el-input v-model="addForm.remark" placeholder="请输入备注" :disabled="type == 'view'" maxlength="200" |
||||||
|
show-word-limit /> |
||||||
|
</el-form-item> |
||||||
|
</el-col> |
||||||
|
</el-row> |
||||||
|
</el-form> |
||||||
|
<div slot="footer" class="dialog-footer"> |
||||||
|
<el-button @click="dialogVisible = false">取 消</el-button> |
||||||
|
<el-button v-if="type != 'view'" type="primary" @click="submitForm" :loading="submitLoading">确认</el-button> |
||||||
|
</div> |
||||||
|
</el-dialog> |
||||||
|
</basic-container> |
||||||
|
</template> |
||||||
|
|
||||||
|
<script> |
||||||
|
import { bizLogin } from "@/api/wirelessintrusion/wirelessintrusion"; |
||||||
|
import { getRegionRailsList, regionDelete, regionAdd, regionUpdate, getRailsList } from "@/api/rails/rails"; |
||||||
|
import { mapGetters } from "vuex"; |
||||||
|
import { dateFormat } from "../../util/date" |
||||||
|
|
||||||
|
export default { |
||||||
|
data() { |
||||||
|
return { |
||||||
|
addForm: { |
||||||
|
points: [] |
||||||
|
}, |
||||||
|
rules: { |
||||||
|
floorNo: [ |
||||||
|
{ required: true, message: '请输入楼层', trigger: 'blur' }, |
||||||
|
], |
||||||
|
name: [ |
||||||
|
{ required: true, message: '请输入围栏名称', trigger: 'blur' }, |
||||||
|
], |
||||||
|
x: [ |
||||||
|
{ required: true, message: '请输入坐标x', trigger: 'blur' }, |
||||||
|
], |
||||||
|
y: [ |
||||||
|
{ required: true, message: '请输入坐标y', trigger: 'blur' }, |
||||||
|
] |
||||||
|
}, |
||||||
|
dialogVisible: false, |
||||||
|
title: '电子区域新增', |
||||||
|
type: 'add', |
||||||
|
query: {}, |
||||||
|
loading: true, |
||||||
|
page: { |
||||||
|
size: 10, |
||||||
|
current: 1, |
||||||
|
total: 0 |
||||||
|
}, |
||||||
|
option: { |
||||||
|
height: 'auto', |
||||||
|
calcHeight: 30, |
||||||
|
tip: false, |
||||||
|
searchShow: true, |
||||||
|
searchMenuSpan: 6, |
||||||
|
border: true, |
||||||
|
index: true, |
||||||
|
selection: false, |
||||||
|
viewBtn: false, |
||||||
|
delBtn: false, |
||||||
|
dialogClickModal: false, |
||||||
|
column: [ |
||||||
|
{ |
||||||
|
label: "区域名称", |
||||||
|
prop: "name", |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "建筑 id", |
||||||
|
prop: "buildingId", |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "楼层", |
||||||
|
prop: "floorNo", |
||||||
|
}, |
||||||
|
{ |
||||||
|
label: "备注", |
||||||
|
prop: "remark", |
||||||
|
overHide: true |
||||||
|
}, |
||||||
|
] |
||||||
|
}, |
||||||
|
data: [], |
||||||
|
submitLoading: false, |
||||||
|
buildingId: 202861,//建筑id |
||||||
|
//选择围栏 |
||||||
|
tableData: [], |
||||||
|
multipleSelection: [], |
||||||
|
selectedArr: [], |
||||||
|
diaPage: { |
||||||
|
pageSize: 10, |
||||||
|
currentPage: 1, |
||||||
|
total: 10, |
||||||
|
}, |
||||||
|
}; |
||||||
|
}, |
||||||
|
computed: { |
||||||
|
...mapGetters(["userInfo", "permission"]), |
||||||
|
permissionList() { |
||||||
|
return { |
||||||
|
addBtn: false, |
||||||
|
viewBtn: false, |
||||||
|
delBtn: true, |
||||||
|
editBtn: false |
||||||
|
}; |
||||||
|
}, |
||||||
|
}, |
||||||
|
methods: { |
||||||
|
// 弹窗表格多选 |
||||||
|
handleSelectionChange(val) { |
||||||
|
this.multipleSelection = val; |
||||||
|
}, |
||||||
|
//查看详情 |
||||||
|
rowView(row) { |
||||||
|
this.addForm = row; |
||||||
|
this.title = '围栏详情'; |
||||||
|
this.type = 'view'; |
||||||
|
this.dialogVisible = true; |
||||||
|
// this.$refs.addForm.resetFields(); |
||||||
|
this.diaPage.currentPage = 1; |
||||||
|
this.$nextTick(() => { |
||||||
|
this.queryRailsList(this.diaPage); |
||||||
|
}) |
||||||
|
}, |
||||||
|
//新增 |
||||||
|
rowAdd(row) { |
||||||
|
this.addForm = { |
||||||
|
buildingId: this.buildingId, |
||||||
|
railIds: [], |
||||||
|
remark: '' |
||||||
|
}; |
||||||
|
this.title = '围栏新增'; |
||||||
|
this.type = 'add'; |
||||||
|
this.multipleSelection = []; |
||||||
|
this.diaPage.currentPage = 1; |
||||||
|
this.dialogVisible = true; |
||||||
|
// this.$refs.addForm.resetFields(); |
||||||
|
this.$nextTick(() => { |
||||||
|
this.queryRailsList(this.diaPage); |
||||||
|
}) |
||||||
|
}, |
||||||
|
//编辑 |
||||||
|
rowEdit(row) { |
||||||
|
this.addForm = row; |
||||||
|
this.addForm.railIds = row.rails; |
||||||
|
this.title = '围栏编辑'; |
||||||
|
this.type = 'edit'; |
||||||
|
this.dialogVisible = true; |
||||||
|
// this.$refs.addForm.resetFields(); |
||||||
|
}, |
||||||
|
//保存 |
||||||
|
submitForm() { |
||||||
|
this.$refs['addForm'].validate((valid) => { |
||||||
|
if (valid) { |
||||||
|
let token = window.sessionStorage.getItem('bizToken'); |
||||||
|
if (token == 'undefined' || !token) { |
||||||
|
return; |
||||||
|
} |
||||||
|
if (this.multipleSelection.length < 1) { |
||||||
|
this.$message({ |
||||||
|
type: "error", |
||||||
|
message: "请选择电子围栏!" |
||||||
|
}); |
||||||
|
return; |
||||||
|
} |
||||||
|
this.submitLoading = true; |
||||||
|
console.log(this.addForm.id) |
||||||
|
this.addForm.railIds = this.multipleSelection.map(item => {return item._id}); |
||||||
|
console.log(this.addForm); |
||||||
|
if (this.addForm.id != undefined) { |
||||||
|
regionUpdate(token, this.addForm).then(res => { |
||||||
|
this.submitLoading = false; |
||||||
|
if (res.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res2 => { |
||||||
|
window.sessionStorage.setItem('bizToken', res2.data.data.token); |
||||||
|
this.submitForm(); |
||||||
|
}) |
||||||
|
} |
||||||
|
else if (res.data.code == 0) { |
||||||
|
this.dialogVisible = false; |
||||||
|
this.onLoad(this.page); |
||||||
|
this.$message({ |
||||||
|
type: "success", |
||||||
|
message: "操作成功!" |
||||||
|
}); |
||||||
|
} |
||||||
|
}, err => { |
||||||
|
this.submitLoading = false; |
||||||
|
}) |
||||||
|
} else { |
||||||
|
regionAdd(token, this.addForm).then(res => { |
||||||
|
this.submitLoading = false; |
||||||
|
if (res.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res2 => { |
||||||
|
window.sessionStorage.setItem('bizToken', res2.data.data.token); |
||||||
|
this.submitForm(); |
||||||
|
}) |
||||||
|
} |
||||||
|
else if (res.data.code == 0) { |
||||||
|
this.dialogVisible = false; |
||||||
|
this.onLoad(this.page); |
||||||
|
this.$message({ |
||||||
|
type: "success", |
||||||
|
message: "操作成功!" |
||||||
|
}); |
||||||
|
} |
||||||
|
}, err => { |
||||||
|
this.submitLoading = false; |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
}) |
||||||
|
}, |
||||||
|
//增加坐标集合 |
||||||
|
addPoint() { |
||||||
|
this.addForm.coordinates.push({ "x": 0, "y": 0 }); |
||||||
|
}, |
||||||
|
//删除坐标集合 |
||||||
|
deletePoint(index) { |
||||||
|
this.addForm.coordinates.splice(index, 1); |
||||||
|
}, |
||||||
|
rowDel(row) { |
||||||
|
this.$confirm("确定将选择数据删除?", { |
||||||
|
confirmButtonText: "确定", |
||||||
|
cancelButtonText: "取消", |
||||||
|
type: "warning" |
||||||
|
}) |
||||||
|
.then(() => { |
||||||
|
let token = window.sessionStorage.getItem('bizToken'); |
||||||
|
if (token == 'undefined' || !token) { |
||||||
|
return; |
||||||
|
} |
||||||
|
regionDelete(token, { "buildingId": row.buildingId, "ids": [row.id] }).then(res => { |
||||||
|
if (res.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res2 => { |
||||||
|
window.sessionStorage.setItem('bizToken', res2.data.data.token); |
||||||
|
this.rowDel(row); |
||||||
|
}) |
||||||
|
} |
||||||
|
}); |
||||||
|
}) |
||||||
|
.then(() => { |
||||||
|
this.onLoad(this.page); |
||||||
|
this.$message({ |
||||||
|
type: "success", |
||||||
|
message: "操作成功!" |
||||||
|
}); |
||||||
|
}); |
||||||
|
}, |
||||||
|
searchReset() { |
||||||
|
this.query = {}; |
||||||
|
this.onLoad(this.page); |
||||||
|
}, |
||||||
|
searchChange(params, done) { |
||||||
|
this.query = params; |
||||||
|
this.page.current = 1; |
||||||
|
this.onLoad(this.page, params); |
||||||
|
done(); |
||||||
|
}, |
||||||
|
currentChange(current) { |
||||||
|
this.page.current = current; |
||||||
|
}, |
||||||
|
sizeChange(size) { |
||||||
|
this.page.size = size; |
||||||
|
}, |
||||||
|
refreshChange() { |
||||||
|
this.onLoad(this.page, this.query); |
||||||
|
}, |
||||||
|
onLoad(page, params = {}) { |
||||||
|
let token = window.sessionStorage.getItem('bizToken'); |
||||||
|
if (token == 'undefined' || !token) { |
||||||
|
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res => { |
||||||
|
window.sessionStorage.setItem('bizToken', res.data.data.token); |
||||||
|
this.loading = true; |
||||||
|
getRegionRailsList(res.data.data.token, Object.assign(params, this.query, { page: page.currentPage, size: page.pageSize, buildingId: this.buildingId })).then(res2 => { |
||||||
|
this.loading = false; |
||||||
|
if (res2.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
this.onLoad(this.page); |
||||||
|
} |
||||||
|
else { |
||||||
|
const data = res2.data.data; |
||||||
|
this.page.total = data.totalElements; |
||||||
|
this.data = data.content; |
||||||
|
} |
||||||
|
}, err => { |
||||||
|
this.loading = false; |
||||||
|
}); |
||||||
|
}) |
||||||
|
} |
||||||
|
else { |
||||||
|
this.loading = true; |
||||||
|
getRegionRailsList(token, Object.assign(params, this.query, { page: page.currentPage, size: page.pageSize, buildingId: this.buildingId })).then(res2 => { |
||||||
|
this.loading = false; |
||||||
|
if (res2.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
this.onLoad(this.page); |
||||||
|
} |
||||||
|
else { |
||||||
|
const data = res2.data.data; |
||||||
|
this.page.total = data.totalElements; |
||||||
|
this.data = data.content; |
||||||
|
} |
||||||
|
}, err => { |
||||||
|
this.loading = false; |
||||||
|
}); |
||||||
|
} |
||||||
|
}, |
||||||
|
//电子围栏列表 |
||||||
|
queryRailsList(page, params = {}) { |
||||||
|
let values = { |
||||||
|
...params |
||||||
|
}; |
||||||
|
let token = window.sessionStorage.getItem('bizToken'); |
||||||
|
if (token == 'undefined' || !token) { |
||||||
|
bizLogin({ appKey: 'Arf7bd4f26', appSecret: 'kb207044c8' }).then(res => { |
||||||
|
window.sessionStorage.setItem('bizToken', res.data.data.token); |
||||||
|
getRailsList(res.data.data.token, { ...values, size: page.pageSize, page: page.currentPage, buildingId: this.buildingId }).then(res2 => { |
||||||
|
const data = res2.data.data; |
||||||
|
this.diaPage.total = data.totalElements; |
||||||
|
this.tableData = data.content; |
||||||
|
this.$refs.multipleTable.clearSelection(); |
||||||
|
let multipleSelection = this.addForm.railIds ? this.addForm.railIds.split(",") : []; |
||||||
|
if (multipleSelection.length > 0) { // 判断是否存在勾选过的数据 |
||||||
|
this.$nextTick(() => { |
||||||
|
this.tableData.forEach(row => { // 获取数据列表接口请求到的数据 |
||||||
|
multipleSelection.forEach(item => { // 勾选到的数据 |
||||||
|
if (row._id === parseInt(item)) { |
||||||
|
this.$refs.multipleTable.toggleRowSelection(row, true); // 若有重合,则回显该条数据 |
||||||
|
} |
||||||
|
}); |
||||||
|
}) |
||||||
|
}) |
||||||
|
|
||||||
|
} |
||||||
|
}); |
||||||
|
}) |
||||||
|
} else { |
||||||
|
getRailsList(token, { ...values, size: page.pageSize, page: page.currentPage, buildingId: this.buildingId }).then(res2 => { |
||||||
|
if (res2.data.code == 401) { |
||||||
|
window.sessionStorage.removeItem('bizToken'); |
||||||
|
this.queryRailsList(); |
||||||
|
} |
||||||
|
else if (res2.data.code == 0) { |
||||||
|
const data = res2.data.data; |
||||||
|
this.diaPage.total = data.totalElements; |
||||||
|
this.tableData = data.content; |
||||||
|
this.$refs.multipleTable.clearSelection(); |
||||||
|
let multipleSelection = this.addForm.railIds ? this.addForm.railIds.split(",") : []; |
||||||
|
if (multipleSelection.length > 0) { // 判断是否存在勾选过的数据 |
||||||
|
this.$nextTick(() => { |
||||||
|
this.tableData.forEach(row => { // 获取数据列表接口请求到的数据 |
||||||
|
multipleSelection.forEach(item => { // 勾选到的数据 |
||||||
|
if (row._id === parseInt(item)) { |
||||||
|
this.$refs.multipleTable.toggleRowSelection(row, true); // 若有重合,则回显该条数据 |
||||||
|
} |
||||||
|
}); |
||||||
|
}) |
||||||
|
}) |
||||||
|
} |
||||||
|
} |
||||||
|
}, err => { |
||||||
|
}); |
||||||
|
} |
||||||
|
}, |
||||||
|
//翻页 |
||||||
|
handleCurrentRailsChange(current) { |
||||||
|
this.diaPage.currentPage = current; |
||||||
|
this.queryRailsList(this.diaPage); |
||||||
|
}, |
||||||
|
} |
||||||
|
}; |
||||||
|
</script> |
||||||
|
|
||||||
|
<style lang="scss" scoped> |
||||||
|
.el-table { |
||||||
|
width: 100% !important; |
||||||
|
border: 1px solid #D6D8DF; |
||||||
|
} |
||||||
|
|
||||||
|
.el-table th.el-table__cell { |
||||||
|
background: #F7F8FA; |
||||||
|
} |
||||||
|
</style> |
||||||
Loading…
Reference in new issue