|
@@ -0,0 +1,383 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <addModal ref="addModel" :machine-list="machineList" :area-type-list="areaTypeList" @success="modalSuccess" />
|
|
|
+ <!--搜索区-->
|
|
|
+ <el-select v-model="form.zoneId" filterable clearable placeholder="请选择区域" class="input" no-data-text="“选择区域”为空">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in areaPreviewList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-model="form.sn"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择设备编号"
|
|
|
+ class="margin-left input"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in machineList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.sn"
|
|
|
+ :value="item.sn"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-model="form.sn"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择设备地点"
|
|
|
+ class="margin-left input"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in machineList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.sn"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-select
|
|
|
+ v-model="form.zoneType"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ placeholder="请选择区域类型"
|
|
|
+ class="margin-left input"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in areaTypeList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.desc"
|
|
|
+ :value="item.type"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ <el-button type="primary" icon="el-icon-search" class="margin-left" @click="query">搜索</el-button>
|
|
|
+ <!--主表格-->
|
|
|
+ <div class="table-wrap">
|
|
|
+ <div class="table-add" @click="handleCreate">
|
|
|
+ <img src="@/icons/images/ic_plus.png">
|
|
|
+ </div>
|
|
|
+ <div v-for="(item, index) in tableData" :key="index" class="table-item">
|
|
|
+ <div class="table-item-head">
|
|
|
+ <div class="head-title">{{ item.name }}</div>
|
|
|
+ <div style="flex:auto;text-align: center;"><el-tag v-if="item.zoneType" type="success">{{ getAreaDescByType(item.zoneType) }}</el-tag></div>
|
|
|
+ <el-button type="primary" size="small" round @click="handleUpdate(item)">编辑</el-button>
|
|
|
+ <el-button type="danger" icon="el-icon-delete" size="small" circle plain @click="handleAreaDelete(item)" />
|
|
|
+ </div>
|
|
|
+ <div class="table-item-content">
|
|
|
+ <div v-for="(itemS, indexS) in item.devices" :key="indexS" class="content-item">
|
|
|
+ <div class="content-item-id">{{ itemS.sn }}</div>
|
|
|
+ <div class="content-item-name">{{ itemS.name }}</div>
|
|
|
+ <div class="content-item-status">
|
|
|
+ <el-tag v-if="itemS.online === 1" type="success">在线</el-tag>
|
|
|
+ <el-tag v-else type="info">离线</el-tag>
|
|
|
+ <el-button type="danger" icon="el-icon-close" size="mini" class="content-item-status-delete" circle @click="handleDeviceDelete(item.id, itemS)" />
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <!--分页栏-->
|
|
|
+ <pagination
|
|
|
+ :total="pagination.total"
|
|
|
+ :page.sync="pagination.current"
|
|
|
+ :limit.sync="pagination.pageSize"
|
|
|
+ :page-sizes="pagination.pageSizeOptions"
|
|
|
+ :layout="pagination.layout"
|
|
|
+ @pagination="handleSizeChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getAreaPageList, getAreaList, deleteArea, deleteDeviceOfArea, getAreaOfType } from '@/api/area'
|
|
|
+import { getFaceDeviceList } from '@/api/old_api_pengwenbing'
|
|
|
+import tableMixins from '@/mixins/tableMixins'
|
|
|
+import Pagination from '@/components/Pagination'
|
|
|
+import AddModal from './modal/AddModal.vue'
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: { Pagination, AddModal },
|
|
|
+ mixins: [tableMixins],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {
|
|
|
+ zoneId: null,
|
|
|
+ adminId: null,
|
|
|
+ zoneType: null,
|
|
|
+ sn: null
|
|
|
+ },
|
|
|
+ areaPreviewList: [],
|
|
|
+ // 设备列表_搜索
|
|
|
+ machineList: [],
|
|
|
+ // 区域类型列表
|
|
|
+ areaTypeList: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ initData() {
|
|
|
+ this.form.adminId = this.$store.getters.adminId
|
|
|
+ this.getAreaList()
|
|
|
+ this.getFaceDeviceList()
|
|
|
+ this.getAreaTypeList()
|
|
|
+ this.getTableList()
|
|
|
+ },
|
|
|
+ getAreaDescByType(type) {
|
|
|
+ if (!type) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ const areaType = this.areaTypeList.find(item => item.type === type)
|
|
|
+ if (!areaType) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ return areaType.desc || ''
|
|
|
+ },
|
|
|
+ // 返回所有的区域列表概览
|
|
|
+ async getAreaList() {
|
|
|
+ try {
|
|
|
+ const result = await getAreaList(this.form)
|
|
|
+ this.areaPreviewList = result.data
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ this.areaPreviewList = []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取设备列表-搜索
|
|
|
+ getFaceDeviceList() {
|
|
|
+ getFaceDeviceList().then((res) => {
|
|
|
+ this.machineList = res.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取区域类型列表
|
|
|
+ getAreaTypeList() {
|
|
|
+ getAreaOfType().then((res) => {
|
|
|
+ this.areaTypeList = res.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取表格数据
|
|
|
+ async getTableList() {
|
|
|
+ this.tableLoading = true
|
|
|
+ try {
|
|
|
+ const result = await getAreaPageList(this.getFilterParams())
|
|
|
+ this.setDataList(result.data)
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e)
|
|
|
+ } finally {
|
|
|
+ this.tableLoading = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取筛选信息
|
|
|
+ query() {
|
|
|
+ this.clearPageParams()
|
|
|
+ this.getTableList()
|
|
|
+ },
|
|
|
+ // 增加筛选条件
|
|
|
+ transformFilterForm() {
|
|
|
+ return this.form
|
|
|
+ },
|
|
|
+ modalSuccess(isEdit) {
|
|
|
+ if (!isEdit) {
|
|
|
+ this.clearPageParams()
|
|
|
+ }
|
|
|
+ this.getTableList()
|
|
|
+ },
|
|
|
+ handleCreate() {
|
|
|
+ this.$refs.addModel.open()
|
|
|
+ },
|
|
|
+ handleUpdate(row) {
|
|
|
+ this.$refs.addModel.open(Object.assign({}, row))
|
|
|
+ },
|
|
|
+ handleAreaDelete(row) {
|
|
|
+ const that = this
|
|
|
+ this.$confirm('确定要删除此区域吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ showClose: false,
|
|
|
+ type: 'warning',
|
|
|
+ beforeClose: async(action, instance, done) => {
|
|
|
+ if (action === 'confirm') {
|
|
|
+ instance.confirmButtonLoading = true
|
|
|
+ instance.cancelButtonLoading = true
|
|
|
+ instance.confirmButtonText = '提交中...'
|
|
|
+ try {
|
|
|
+ await deleteArea(row.id)
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '删除成功!'
|
|
|
+ })
|
|
|
+ that.getAreaList()
|
|
|
+ that.getTableList()
|
|
|
+ } catch (e) {
|
|
|
+ // this.$message({
|
|
|
+ // type: 'error',
|
|
|
+ // message: '删除失败!'
|
|
|
+ // })
|
|
|
+ } finally {
|
|
|
+ done()
|
|
|
+ setTimeout(() => {
|
|
|
+ instance.confirmButtonLoading = false
|
|
|
+ instance.cancelButtonLoading = false
|
|
|
+ }, 300)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(() => {}).catch(() => {})
|
|
|
+ },
|
|
|
+ handleDeviceDelete(areaId, row) {
|
|
|
+ const that = this
|
|
|
+ this.$confirm('确定要解绑此设备吗?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ showClose: false,
|
|
|
+ type: 'warning',
|
|
|
+ beforeClose: async(action, instance, done) => {
|
|
|
+ if (action === 'confirm') {
|
|
|
+ instance.confirmButtonLoading = true
|
|
|
+ instance.cancelButtonLoading = true
|
|
|
+ instance.confirmButtonText = '提交中...'
|
|
|
+ try {
|
|
|
+ await deleteDeviceOfArea(areaId, row.sn)
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: '解绑成功!'
|
|
|
+ })
|
|
|
+ that.getTableList()
|
|
|
+ } catch (e) {
|
|
|
+ // this.$message({
|
|
|
+ // type: 'error',
|
|
|
+ // message: '解绑失败!'
|
|
|
+ // })
|
|
|
+ } finally {
|
|
|
+ done()
|
|
|
+ setTimeout(() => {
|
|
|
+ instance.confirmButtonLoading = false
|
|
|
+ instance.cancelButtonLoading = false
|
|
|
+ }, 300)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).then(() => {}).catch(() => {})
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+ .table{
|
|
|
+ margin-top: 15px;
|
|
|
+ }
|
|
|
+ .flex {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ .margin-left {
|
|
|
+ margin: 10px 0 0 10px;
|
|
|
+ }
|
|
|
+ .input {
|
|
|
+ width: 200px;
|
|
|
+ }
|
|
|
+ ::-webkit-scrollbar{
|
|
|
+ width: 6px;
|
|
|
+ height: 6px;
|
|
|
+ background-color: #F1F2F5;
|
|
|
+ }
|
|
|
+
|
|
|
+::-webkit-scrollbar-thumb{
|
|
|
+ background-color:#BFC6D4;
|
|
|
+ border-radius: 10px;
|
|
|
+}
|
|
|
+::-webkit-scrollbar-track{
|
|
|
+ background-color: transparent;
|
|
|
+}
|
|
|
+ .table-wrap {
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ & > div {
|
|
|
+ margin-top: 28px;
|
|
|
+ margin-left: 1%;
|
|
|
+ min-width: 375px;
|
|
|
+ width: 32%;
|
|
|
+ height: 256px;
|
|
|
+ flex: none;
|
|
|
+ overflow: hidden;
|
|
|
+ border: 1px solid #E3E9F8;
|
|
|
+ border-radius: 8px;
|
|
|
+ }
|
|
|
+ & > div:nth-of-type(3n+1) {
|
|
|
+ margin-left: 0;
|
|
|
+ }
|
|
|
+ .table-add {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ background-color: #F8FAFF;
|
|
|
+ cursor: pointer;
|
|
|
+ & img {
|
|
|
+ width: 80px;
|
|
|
+ height: 80px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .table-item {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ .table-item-head {
|
|
|
+ width: 100%;
|
|
|
+ height: 62px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 0 14px 0 20px;
|
|
|
+ background-color: #E3EBFF57;
|
|
|
+ .head-title {
|
|
|
+ font-size: 20px;
|
|
|
+ color: #1B55AB;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .table-item-content {
|
|
|
+ width: 100%;
|
|
|
+ padding: 0 12px;
|
|
|
+ height: calc(256px - 62px);
|
|
|
+ overflow: auto;
|
|
|
+ .content-item {
|
|
|
+ margin-top: 12px;
|
|
|
+ padding: 4px 6px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ font-size: 14xp;
|
|
|
+ color: #606266;
|
|
|
+ &:last-of-type {
|
|
|
+ margin-bottom: 12px;
|
|
|
+ }
|
|
|
+ &:hover {
|
|
|
+ background-color: #F5F8FF;
|
|
|
+ border-radius: 5px;
|
|
|
+ .content-item-status .content-item-status-delete {
|
|
|
+ visibility: visible;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .content-item-id {
|
|
|
+ width: 160px;
|
|
|
+ flex: none;
|
|
|
+ }
|
|
|
+ .content-item-name {
|
|
|
+ flex: auto;
|
|
|
+ }
|
|
|
+ .content-item-status {
|
|
|
+ flex: none;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ .content-item-status-delete {
|
|
|
+ margin-left: 15px;
|
|
|
+ visibility: hidden;
|
|
|
+ padding: 3px !important;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|