鸿蒙智能电子锁前端项目
he wei
2025-03-15 f8fd43f1307b0ae3a55f5a5a1390fd13b506fa88
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<script setup>
    import { ref, onMounted, reactive, computed, watchEffect } from "vue";
 
    import useElement from "@/hooks/useElement.js";
 
    import {
        getMapList,
    activeMap,
    } from '@/api/system.js';
 
    const { $loading, $message, $confirm } = useElement();
    import addChartMap from "./addChartMap";
    import mapJson from "../../../public/mapJson/js/index.js";
 
    const tableData = ref([]);
    const addDialog = ref(false);
 
  const mapList = mapJson.mapList(); 
 
    function handleClick(data) {
        //点击激活
        if (data.status == 1) {
            return;
        }
        $confirm("是否激活该地图?", () => {
            //发送请求传送至后台
            let loading = $loading();
            activeMap(data.id)
                .then(res => {
                    if (res.code == 1) {
                        $message.success("激活成功!");
                        tableData.value.map((item, index) => {
                            item.status = 0;
                        });
                        data.status = 1;
                    } else {
                        $message.error("激活失败!");
                    }
                    // 关闭加载框
                    loading.close();
                })
                .catch(err => {
                    console.log(err);
                    // 关闭加载框
                    loading.close();
                });
        }
        );
    }
    function addMap() {
        //添加地图
        addDialog.value = true;
    }
    function searchData() {
        //查询数据
        let loading = $loading();
        getMapList()
            .then(res => {
                if (res.code == 1) {
                    let data = res.data.map(item => {
                        let mapInfo = mapJson.getItemByValue(item.name, mapList);
                        item.mapName = mapInfo.label;
                        return item;
                    });
                    tableData.value = data;
                }
                // 关闭加载框
                loading.close();
            })
            .catch(err => {
                console.log(err);
                // 关闭加载框
                loading.close();
                $message.error("查询失败!");
            });
    }
    function addSuccess() {
        //添加成功后查询数据
        // 关闭弹出面板
        addDialog.value = false;
        // 从新查询数据
        searchData();
    }
 
    onMounted(() => {
        searchData();
    });
</script>
 
<template>
  <div class="page-wrapper">
    <div class="page-header">
    </div>
    <div class="page-content">
      <hdw-card is-full>
        <div class="page-content-wrapper">
          <div class="page-content-table">
            <div class="pos-rel">
              <div class="pos-abs">
                <el-table stripe :data="tableData" border style="width: 100%; height: 100%">
                  <el-table-column prop="province" label="省" min-width="120" :resizable="false" align="center">
                  </el-table-column>
                  <el-table-column prop="city" label="市" min-width="120" :resizable="false" align="center">
                  </el-table-column>
                  <el-table-column prop="distinct" label="区县" min-width="120" :resizable="false" align="center">
                  </el-table-column>
                  <el-table-column prop="mapName" label="地图名称" min-width="280" :resizable="false" align="center">
                  </el-table-column>
                  <el-table-column label="操作" width="125" align="center">
                    <template #default="scope">
                      <el-button @click="handleClick(scope.row)" :disabled="scope.row.status == 1"
                        :type="scope.row.status == 1 ? 'warning' : 'info'" >
                        {{ scope.row.status == 1 ? "已激活" : "未激活" }}
                      </el-button>
                    </template>
                  </el-table-column>
  
                </el-table>
              </div>
            </div>
          </div>
          <div class="page-content-page">
            <div class="page-tool"></div>
            <el-button type="primary" round  icon="Search" @click="searchData">查询</el-button>
            <el-button type="primary" round  icon="Plus" @click="addMap">新增关联地图</el-button>
            <div class="page-tool"></div>
          </div>
        </div>
      </hdw-card>
    </div>
    <div class="page-footer"></div>
    <el-dialog title="新增关联地图" width="300px" v-model="addDialog" :close-on-click-modal="false" top="0"
      class="dialog-center" :modal-append-to-body="false">
      <add-chart-map :list="tableData" @success="addSuccess" v-if="addDialog"></add-chart-map>
    </el-dialog>
  </div>
</template>
 
<style scoped lang="scss">
.page-wrapper {
  display: flex;
  flex-direction: row;
  padding: 8px;
  height: 100%;
 
  .page-content {
    flex: 1;
  }
}
 
.page-content-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
 
  .page-content-tools {
    padding-bottom: 8px;
  }
 
  .page-content-table {
    border-top: 1px solid var(--border-light-color);
    box-sizing: border-box;
    flex: 1;
    margin-left: -8px;
    margin-right: -8px;
  }
 
  .page-content-page {
    padding: 8px 8px 0 8px;
    text-align: center;
 
    .el-page-container {
      display: inline-block;
      padding: 0 16px;
    }
 
    .page-tool {
      display: inline-block;
    }
  }
}
 
.hdw-card-container {
  width: 240px;
  padding-right: 8px;
  height: 100%;
}
 
.pos-rel {
  position: relative;
  width: 100%;
  height: 100%;
 
  .pos-abs {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 100%;
  }
}
 
.tools-filter {
  display: inline-block;
  font-size: 14px;
 
  .tools-filter-item {
    display: inline-block;
    margin-right: 8px;
 
    .filter-label {
      display: inline-block;
    }
 
    .filter-content {
      display: inline-block;
    }
  }
}
 
:deep(.el-button--warning.el-button--warning) {
  background: #f69f40;
  border: 0 none;
}
 
.form-footer {
  text-align: right;
}
</style>