ll
liukangdong
2025-02-20 b565a275fe240e2bd8a939c3b4beed98d03767bc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<template>
  <TableLayout :permissions="['business:sites:query']">
    <!-- 搜索表单 -->
    <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
      <el-form-item label="站点编号" prop="code">
        <el-input v-model="searchForm.code" placeholder="请输入站点编号" @keypress.enter.native="search"></el-input>
      </el-form-item>
      <el-form-item label="站点名称" prop="name">
        <el-input v-model="searchForm.name" placeholder="请输入站点名称" @keypress.enter.native="search"></el-input>
      </el-form-item>
 
      <section>
        <el-button type="primary" @click="search">搜索</el-button>
        <el-button @click="reset">重置</el-button>
      </section>
    </el-form>
    <!-- 表格和分页 -->
    <template v-slot:table-wrap>
      <ul class="toolbar" v-permissions="['business:sites:create']">
        <li><el-button type="primary" @click="$refs.operaSitesWindow.open('新建站点')" icon="el-icon-plus"
            v-permissions="['business:sites:create']">新建</el-button></li>
      </ul>
      <el-table v-loading="isWorking.search" :data="tableData.list" stripe border>
        <el-table-column prop="code" label="站点编号" :sort-method="(a, b) => { return a.code - b.code }" sortable
          min-width="100px" align="center"></el-table-column>
        <el-table-column prop="name" label="站点名称" sortable min-width="100px" align="center"></el-table-column>
 
        <el-table-column prop="createDate" label="创建时间" sortable min-width="100px" align="center"></el-table-column>
        <el-table-column v-if="containPermissions(['business:sites:update', 'business:sites:delete'])" label="操作"
          min-width="120" align="center" fixed="right">
          <template slot-scope="{row}">
            <el-button type="text" @click="handleDraw(row)">绘制地图区域</el-button>
            <el-button type="text" @click="$refs.operaSitesWindow.open('编辑站点', row)" icon="el-icon-edit"
              v-permissions="['business:sites:update']">编辑</el-button>
            <el-button type="text" @click="deleteById(row)" icon="el-icon-delete"
              v-permissions="['business:sites:delete']">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination @size-change="handleSizeChange" @current-change="handlePageChange" :pagination="tableData.pagination">
      </pagination>
    </template>
    <!-- 新建/修改 -->
    <OperaSitesWindow ref="operaSitesWindow" @success="handlePageChange" />
    <!--  查看二维码  -->
    <AMap @change="changeMap" ref="MapRef" />
  </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaSitesWindow from './components/SitesWindow'
import AMap from './components/AMap.vue'
import { Message } from 'element-ui'
import { updateById } from '@/api/business/sites.js'
export default {
  name: 'Sites',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaSitesWindow, AMap },
  data() {
    return {
      // 搜索
      searchForm: {
        id: '',
        createDate: '',
        creator: '',
        editDate: '',
        editor: '',
        isdeleted: '',
        info: '',
        name: '',
        code: '',
        status: '',
        lockNum: '',
        ip: '',
        clientVersion: '',
        type: 1
      },
      isShowMap: false
    }
  },
  created() {
    this.config({
      module: '站点信息表',
      api: '/business/sites',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
  },
  methods: {
    changeMap(e, row) {
      console.log(e); 
      updateById({ ...row, electronicFence: JSON.stringify(e) }).then(res => {
        if (res) {
          Message.success('设置成功')
          this.search()
        }
      })
    },
    handleDraw(row) {
      this.$refs.MapRef.isShowModal = true
      this.$nextTick(() => {
        this.$refs.MapRef.row = row
        if (row.electronicFence) {
          this.$refs.MapRef.polygons = JSON.parse(row.electronicFence)
        }
 
        this.$refs.MapRef.initMap()
      })
    }
  }
}
</script>