无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<template>
  <div class="airspaceManage">
    <div class="search-box">
      <el-form :model="params" inline>
        <div style="display: flex;justify-content: space-between">
         <div>
          <el-form-item label="类型名称:">
            <el-input v-model="params.typeName" placeholder="请输入类型名称" clearable />
          </el-form-item>
         </div>
         <div>
          <el-form-item>
            <el-button type="primary" @click="getList">搜索</el-button>
            <el-button @click="cancelSearch">清空</el-button>
          </el-form-item>
         </div>
        </div>
      </el-form>
      <div>
        <el-button type="primary" icon="el-icon-plus" @click="handleAdd">新增类型</el-button>
      </div>
    </div>
    <div class="mange-table">
            <el-table border :data="tableList" class="custom-header">
                <el-table-column label="序号" type="index" width="60"></el-table-column>
        <el-table-column prop="type_name" label="类型名称" align="center" show-overflow-tooltip></el-table-column>
        <el-table-column prop="create_time" label="创建时间" align="center"></el-table-column>
        <el-table-column prop="nick_name" label="创建人" align="center"></el-table-column>
                <el-table-column label="操作" width="180" align="center">
                    <template #default="scope">
            <!-- <el-button icon="el-icon-view" type="text" @click="handleDetail(scope.row)">查看</el-button> -->
            <el-button icon="el-icon-edit" type="text" @click="handleEdit(scope.row)">编辑</el-button>
                        <el-button icon="el-icon-delete" type="text" @click="handleDelete(scope.row)">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="pagination">
            <el-pagination class="ztzf-pagination" popper-class="custom-pagination-dropdown" background
                :page-sizes="[10, 20, 30, 40, 50, 100]" :size="size" v-model:current-page="params.current"
                v-model:page-size="params.size" layout="total, sizes, prev, pager, next, jumper" :total="total"
                @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </div>
  </div>
  <!-- <el-dialog class="ztzf-dialog" append-to-body v-model="isShowView" title="查看"
        :width="pxToRem(600)" :close-on-click-modal="false" :destroy-on-close="true">
        <div class="content">
      <table class="view-table" border>
        <tr>
          <td class="label">空域类型</td>
          <td class="value">{{ rowView.model_name }}</td>
          <td class="label">创建时间</td>
          <td class="value">{{ rowView.alg_type }}</td>
        </tr>
      </table>
    </div>
    </el-dialog> -->
  <el-dialog class="ztzf-dialog" append-to-body v-model="isShowEditView" :title="titleTxt"
        :width="pxToRem(880)" :close-on-click-modal="false" :destroy-on-close="true">
        <div class="content-edit">
      <el-form ref="ruleFormRef" :model="editParams" :rules="rules" inline>
        <el-form-item label="类型名称" prop="type_name">
          <el-input v-model="editParams.type_name" />
        </el-form-item>
        <div class="btns">
          <el-button v-if="titleTxt === '新增'" type="primary" @click="submit(ruleFormRef)"><el-icon><CirclePlus /></el-icon>确认</el-button>
          <el-button v-else type="primary" @click="submit(ruleFormRef)"><el-icon><CircleCheck /></el-icon>修改</el-button>
          <el-button @click="isShowEditView = false"><el-icon><CircleClose /></el-icon>取消</el-button>
        </div>
      </el-form>
    </div>
    </el-dialog>
</template>
<script setup>
import { getAirSpaceTypeList, airSpaceTypeEdit, airSpaceTypeAdd, airSpaceTypeDelete } from '@/api/airspace/airspace';
import { ElMessage, ElMessageBox } from 'element-plus'
 
const total = ref(0)
const params = ref({
  current: 1,
  size: 10,
  typeName: '',
});
 
let titleTxt = ref('新增')
let tableList = ref([])
 
let isShowView = ref(false)
 
let rowView = ref({})
 
let isShowEditView = ref(false)
 
const ruleFormRef = ref()
let editParams = ref({
  type_name: ''
})
const rules = reactive({
  type_name: [
    {
      required: true,
      message: '请输入空域类型名称',
      trigger: 'blur',
    },
  ],
})
 
function cancelSearch() {
  params.value = {
    id: '',
    typeName: '',
  }
  params.value.current = 1
  getList()
}
 
function getList() {
  getAirSpaceTypeList(params.value).then(res => {
    tableList.value = res.data.data.records || []
    total.value = res.data.data.total || 0
  })
}
 
function handleDetail(row) {
  isShowView.value = true
  rowView.value = row
}
function handleDelete (row) {
  ElMessageBox.confirm('确定将选择数据删除?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  }).then(() => {
    airSpaceTypeDelete(row.id).then(res => {
      ElMessage.success('删除成功')
      getList()
    })
  }).catch(() => {
    ElMessage({
      type: 'info',
      message: '已取消删除'
    })
  })
}
function handleAdd() {
  titleTxt.value = '新增'
  editParams.value.type_name = ''
  isShowEditView.value = true
}
 
function handleEdit(row) {
  titleTxt.value = '编辑'
  isShowEditView.value = true
  editParams.value = { ...row }
}
 
function handleSizeChange(val) {
  params.value.size = val
  getList()
}
 
function handleCurrentChange(val) {
  params.value.current = val
  getList()
}
 
async function submit(formValidate) {
  if (!formValidate) return
  await formValidate.validate((valid, fields) => {
    if (valid) {
      if (titleTxt.value === '新增') {
        airSpaceTypeAdd({ type_name: editParams.value.type_name }).then(res => {
          isShowEditView.value = false
          ElMessage.success('新增成功')
          getList()
        })
      } else {
        airSpaceTypeEdit({ type_name: editParams.value.type_name, id: editParams.value.id } ).then(res => {
          isShowEditView.value = false
          ElMessage.success('操作成功')
          getList()
        })
      }
      
    } 
  })
}
 
onMounted(() => {
  getList()
})
</script>
 
<style lang="scss" scoped>
  .airspaceManage {
    height: 0;
    flex: 1;
    padding: 20px;
    margin: 0 10px 10px 10px;
    background-color: #ffffff;
    // padding: 10px 20px;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    .search-box {
      margin-top: 20px;
      height: 80px;
    }
 
    :deep(.el-input) {
      .el-input__wrapper {
        width: 200px;
      }
    }
 
    // 表格
    .mange-table {
      height: 0;
      flex: 1;
      margin-top: 18px;
      overflow: auto;
    }
    :deep(.el-pagination) {
      display: flex;
      justify-content: right;
    }
 
    :deep(.el-pagination button) {
      background: center center no-repeat none !important;
      color: #8eb8ea !important;
    }
    :deep(.ztzf-select){
      .el-select__selection {
        width: 200px;
      }
    }
  }
  
 .content {
  padding: 20px;
  
  .view-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #EBEEF5;
    
    tr {
      &:not(:last-child) {
        border-bottom: 1px solid #EBEEF5;
      }
      
      td {
        padding: 12px 10px;
        
        &.label {
          width: 140px;
          text-align: right;
          // color: #909399;
          // background-color: #F5F7FA;
          border-right: 1px solid #EBEEF5;
        }
        
        &.value {
          width: 180px;
          // color: #303133;
        }
      }
    }
  }
}
.content-edit {
  .el-form {
    .el-form-item {
      width: 500px;
      :deep(.el-form-item__label) {
        width: 220px;
      }
      
    }
    .btns {
        display: flex;
        justify-content: flex-end;
      }
  }
}
</style>