parent
cb38e05a02
commit
dbb6c528f8
11 changed files with 800 additions and 339 deletions
@ -1,342 +1,251 @@ |
||||
<template> |
||||
<basic-container> |
||||
<avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel" |
||||
v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave" :before-open="beforeOpen" |
||||
@search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange" |
||||
<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 #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> |
||||
<!-- 地图定位 --> |
||||
<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> |
||||
</template> |
||||
|
||||
<script> |
||||
import { bizLogin, bizDeviceList, bizDeviceStatus, bizNodeType } from "@/api/wirelessintrusion/wirelessintrusion"; |
||||
import { bizLogin, terminalList } from "@/api/wirelessintrusion/wirelessintrusion"; |
||||
import { mapGetters } from "vuex"; |
||||
import { dateFormat } from "../../../util/date"; |
||||
import MapView from "../../map/index.vue"; |
||||
|
||||
export default { |
||||
components: { |
||||
MapView |
||||
}, |
||||
data() { |
||||
return { |
||||
form: {}, |
||||
query: {}, |
||||
loading: true, |
||||
page: { |
||||
pageSize: 10, |
||||
currentPage: 1, |
||||
size: 10, |
||||
current: 1, |
||||
total: 0 |
||||
}, |
||||
selectionList: [], |
||||
option: { |
||||
height: 'auto', |
||||
calcHeight: 30, |
||||
dialogWidth: 950, |
||||
tip: false, |
||||
searchShow: true, |
||||
searchMenuSpan: 6, |
||||
border: true, |
||||
index: true, |
||||
selection: false, |
||||
viewBtn: true, |
||||
editBtn: false, |
||||
delBtn: false, |
||||
addBtn: false, |
||||
dialogClickModal: false, |
||||
menuWidth: 180, |
||||
column: [ |
||||
{ |
||||
label: "设备名称", |
||||
prop: "name", |
||||
span: 12, |
||||
}, |
||||
{ |
||||
label:"sn编号", |
||||
prop: "sn", |
||||
search: true, |
||||
formatter: (val, value, label) => { |
||||
return val.name + '/' + val.remark |
||||
}, |
||||
labelWidth: 120 |
||||
hide: true |
||||
}, |
||||
{ |
||||
label: "备注名称", |
||||
prop: "remark", |
||||
span: 12, |
||||
hide: true, |
||||
viewDisplay: true, |
||||
labelWidth: 120 |
||||
label: "建筑 id", |
||||
prop: "buildId", |
||||
}, |
||||
{ |
||||
label: "设备所属产品", |
||||
prop: "name", |
||||
span: 12, |
||||
labelWidth: 120 |
||||
label: "楼层", |
||||
prop: "floorNo", |
||||
}, |
||||
{ |
||||
label: "节点类型", |
||||
label: "x坐标", |
||||
prop: "x", |
||||
}, |
||||
{ |
||||
label: "y坐标", |
||||
prop: "y", |
||||
}, |
||||
{ |
||||
label: "工作状态", |
||||
type: "select", |
||||
dicData: [], |
||||
props: { |
||||
label: "dictLabel", |
||||
value: "dictValue" |
||||
}, |
||||
search: true, |
||||
prop: "node", |
||||
labelWidth: 120, |
||||
viewDisplay: false |
||||
dicData: [ |
||||
{value:'work', label:"工作"},{value:'sleep', label:"休眠"} |
||||
], |
||||
prop: "workStatus", |
||||
}, |
||||
{ |
||||
label: "节点类型", |
||||
prop: "nodeLabel", |
||||
labelWidth: 120, |
||||
hide: true, |
||||
viewDisplay: true |
||||
label: "通信状态", |
||||
type: "select", |
||||
dicData: [ |
||||
{value:0, label:"在线"},{value:1, label:"离线"} |
||||
], |
||||
prop: "communicateStatus", |
||||
}, |
||||
{ |
||||
label: "网关信息", |
||||
prop: "gateway", |
||||
formatter: (val, value, label) => { |
||||
return val.gateway || '-' |
||||
label: "最后一次通信时间", |
||||
labelWidth: 150, |
||||
prop: "lastCommunicateTime", |
||||
span: 24, |
||||
formatter: (data, value) => { |
||||
return dateFormat(new Date(data.lastCommunicateTime)) |
||||
}, |
||||
labelWidth: 120 |
||||
hide: true |
||||
}, |
||||
{ |
||||
label: "设备状态", |
||||
type: "select", |
||||
dicData: [], |
||||
props: { |
||||
label: "dictLabel", |
||||
value: "dictValue" |
||||
label: "最后一次配置时间", |
||||
labelWidth: 150, |
||||
prop: "lastConfigTime", |
||||
span: 24, |
||||
formatter: (data, value) => { |
||||
return dateFormat(new Date(data.lastConfigTime)) |
||||
}, |
||||
search: true, |
||||
prop: "status", |
||||
labelWidth: 120, |
||||
viewDisplay: false, |
||||
}, |
||||
hide: true |
||||
}, |
||||
{ |
||||
label: "节点类型", |
||||
prop: "statusLabel", |
||||
labelWidth: 120, |
||||
hide: true, |
||||
viewDisplay: true |
||||
label: "最后一次定位时间", |
||||
labelWidth: 150, |
||||
prop: "lastLocateTime", |
||||
span: 24, |
||||
formatter: (data, value) => { |
||||
return dateFormat(new Date(data.lastLocateTime)) |
||||
}, |
||||
hide:true |
||||
}, |
||||
{ |
||||
label: "创建时间时间", |
||||
label: "创建时间", |
||||
prop: "createTime", |
||||
labelWidth: 120, |
||||
hide: true, |
||||
viewDisplay: true, |
||||
}, { |
||||
label: "最后上线时间", |
||||
prop: "lastOnline", |
||||
labelWidth: 120 |
||||
formatter: (data, value) => { |
||||
return dateFormat(new Date(data.createTime)) |
||||
} |
||||
}, |
||||
{ |
||||
label: "更新时间", |
||||
prop: "updateTime", |
||||
formatter: (data, value) => { |
||||
return dateFormat(new Date(data.updateTime)) |
||||
}, |
||||
hide:true |
||||
} |
||||
] |
||||
}, |
||||
data: [], |
||||
nodeType: [],//节点类型 |
||||
submitLoading: false, |
||||
buildingId: 202861, |
||||
//地图定位查看 |
||||
dialogVisible: false, |
||||
sn: '', |
||||
x: 0, |
||||
y: 0, |
||||
floorNo: 1 |
||||
}; |
||||
}, |
||||
computed: { |
||||
...mapGetters(["permission"]), |
||||
...mapGetters(["userInfo", "permission"]), |
||||
permissionList() { |
||||
return { |
||||
addBtn: this.vaildData(this.permission.notice_add, false), |
||||
viewBtn: this.vaildData(this.permission.notice_view, false), |
||||
delBtn: this.vaildData(this.permission.notice_delete, false), |
||||
editBtn: this.vaildData(this.permission.notice_edit, false) |
||||
addBtn: false, |
||||
viewBtn: false, |
||||
delBtn: true, |
||||
editBtn: false |
||||
}; |
||||
}, |
||||
ids() { |
||||
let ids = []; |
||||
this.selectionList.forEach(ele => { |
||||
ids.push(ele.id); |
||||
}); |
||||
return ids.join(","); |
||||
} |
||||
}, |
||||
mounted() { |
||||
}, |
||||
methods: { |
||||
//字典加载 |
||||
loadDict() { |
||||
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); |
||||
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; |
||||
}) |
||||
} |
||||
//查看详情 |
||||
rowView(row, index) { |
||||
this.$refs.crud.rowView(row, index); |
||||
}, |
||||
//节点类型转换 |
||||
renderLabel(node,col) { |
||||
const column = this.findObject(this.option.column, col); |
||||
let idx = column.dicData.findIndex(item => item.dictValue == node); |
||||
return idx > -1 ? column.dicData[idx].dictLabel : ''; |
||||
//地图定位查看 |
||||
rowMap(row, index) { |
||||
if(row.x && row.y) { |
||||
this.sn = row.sn; |
||||
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() { |
||||
this.query = {}; |
||||
this.onLoad(this.page); |
||||
}, |
||||
searchChange(params, done) { |
||||
this.query = params; |
||||
this.page.currentPage = 1; |
||||
this.page.current = 1; |
||||
this.onLoad(this.page, params); |
||||
done(); |
||||
}, |
||||
selectionChange(list) { |
||||
this.selectionList = list; |
||||
}, |
||||
selectionClear() { |
||||
this.selectionList = []; |
||||
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; |
||||
currentChange(current) { |
||||
this.page.current = current; |
||||
}, |
||||
sizeChange(pageSize) { |
||||
this.page.pageSize = pageSize; |
||||
sizeChange(size) { |
||||
this.page.size = size; |
||||
}, |
||||
refreshChange() { |
||||
this.onLoad(this.page, this.query); |
||||
}, |
||||
onLoad(page, params = {}) { |
||||
let values = { |
||||
...params, |
||||
...this.query, |
||||
pid: 98 |
||||
}; |
||||
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; |
||||
bizDeviceList(res.data.data.token, { ...values, pageSize: page.pageSize, pageNo: page.currentPage }).then(res2 => { |
||||
const data = res2.data; |
||||
this.page.total = data.total; |
||||
this.data = data.records; |
||||
terminalList(res.data.data.token, Object.assign(params, this.query, { page: page.currentPage, size: page.pageSize, buildingIds: 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; |
||||
this.selectionClear(); |
||||
}); |
||||
}) |
||||
} else { |
||||
} |
||||
else { |
||||
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.selectionClear(); |
||||
if(res2.data.code == 401){ |
||||
console.log(res2.data.code) |
||||
if (res2.data.code == 401) { |
||||
window.sessionStorage.removeItem('bizToken'); |
||||
this.onLoad(); |
||||
this.onLoad(this.page); |
||||
} |
||||
else if(res2.data.code == 200){ |
||||
const data = res2.data; |
||||
this.page.total = data.total; |
||||
data.rows.map(item => { |
||||
item.node = item.bizProduct.node; |
||||
item.nodeLabel = this.renderLabel(item.node,'node'); |
||||
item.statusLabel = this.renderLabel(item.status,'status') |
||||
}) |
||||
this.data = data.rows; |
||||
else { |
||||
const data = res2.data.data; |
||||
this.page.total = data.totalElements; |
||||
this.data = data.content; |
||||
} |
||||
}, err => { |
||||
this.loading = false; |
||||
this.selectionClear(); |
||||
}); |
||||
} |
||||
} |
||||
}, |
||||
} |
||||
}; |
||||
</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