无人机管理后台前端(已迁走)
张含笑
2025-08-28 e1cb0923a89efbaddeec71a292607c4fa5cb33ac
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
<template>
  <basic-container>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model:page="page"
      :permission="permissionList"
      v-model="form"
      ref="crud"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @row-del="rowDel"
      :before-open="beforeOpen"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left>
        <el-button type="primary" icon="el-icon-upload" @click="handleDebug"> 上传图斑 </el-button>
        <el-button type="primary" icon="el-icon-setting" @click="goTypeManagement">
          类型管理
        </el-button>
        <el-button type="success" icon="el-icon-download" @click="downloadPatch"> 导出 </el-button>
      </template>
 
      <template #menu="scope">
        <el-button type="primary" text icon="el-icon-view" @click="uploadPatch(scope.row, 'detail')"
          >详情
        </el-button>
        <el-button type="primary" text icon="el-icon-edit" @click="uploadPatch(scope.row, 'edit')"
          >编辑
        </el-button>
        <el-button type="primary" text icon="el-icon-delete" @click="rowDel">删除 </el-button>
      </template>
    </avue-crud>
 
    <el-dialog title="上传图斑" append-to-body align-center v-model="box" width="550px">
      <el-form
        ref="ruleFormRef"
        style="max-width: 600px"
        :model="ruleForm"
        :rules="rules"
        label-width="auto"
      >
        <el-form-item label="文件名称" prop="name">
          <el-input v-model="ruleForm.name" />
        </el-form-item>
        <el-form-item label="图斑类型" prop="region">
          <el-select v-model="ruleForm.region" placeholder="Activity zone">
            <el-option label="Zone one" value="shanghai" />
            <el-option label="Zone two" value="beijing" />
          </el-select>
        </el-form-item>
        <el-form-item class="center-align">
          <el-button type="primary"> 图斑上传 </el-button>
        </el-form-item>
        <el-form-item class="center-align">
          <span>注:仅支持gis平台导出的zip压缩文件</span>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!-- 图斑详情 -->
    <SpotDetails v-model:show="uploadPatchDialog" :title="spotDetailsTitle"></SpotDetails>
    <!-- <patchDetails ref="patchDetails" /> -->
  </basic-container>
</template>
 
<script setup>
import {
  spotManagementTableApi,
  searchManagementApi,
  uploadManagementApi,
  tableMapListApi,
  exportExcel
} from '@/api/patchManagement/index';
import { getRegionTreeAll } from '@/api/job/task';
import { ref, computed, watch } from 'vue';
import { useStore } from 'vuex';
import { useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { getListPage, getDetail, add, update, remove, enable, disable } from '@/api/resource/oss';
import func from '@/utils/func';
import patchDetails from '@/views/resource/components/patchDetails.vue';
import SpotDetails from '@/views/resource/components/spotDetails.vue';
const spotDetailsTitle = ref('');
const store = useStore();
const router = useRouter();
const ruleFormRef = ref(null);
let deptTreeData = ref([]);
const userAreaCode = computed(() => store.getters.userInfo.detail.areaCode);
const ruleForm = reactive({
  name: 'Hello',
  region: '',
  count: '',
  date1: '',
  date2: '',
  delivery: false,
  location: '',
  type: [],
  resource: '',
  desc: '',
});
const rules = reactive({
  name: [
    { required: true, message: 'Please input Activity name', trigger: 'blur' },
    { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  region: [
    {
      required: true,
      message: 'Please select Activity zone',
      trigger: 'change',
    },
  ],
});
 
// ===== state =====
const form = ref({});
const query = ref({});
const loading = ref(true);
const box = ref(false);
 
const page = ref({
  pageSize: 10,
  currentPage: 1,
  total: 0,
});
 
const selectionList = ref([]);
 
const option = ref({
  addBtn: false,
  tip: false,
  searchShow: true,
  searchMenuSpan: 8,
  searchMenuPosition: 'right',
  border: true,
  index: true,
  selection: true,
  grid: false,
  menuWidth: 240,
  labelWidth: 100,
  dialogWidth: 880,
  dialogClickModal: false,
  height: 'auto',
  calcHeight: 20,
  refreshBtn: false,
  gridBtn: false,
  searchShowBtn: false,
  columnBtn: false,
  viewBtn: false,
  editBtn: false,
  delBtn: false,
  column: [
    {
      label: '文件名称',
      prop: 'name',
      span: 24,
      search: true,
      searchSpan: 4,
      rules: [{ required: true, message: '请输入文件名称', trigger: 'blur' }],
    },
    {
      label: '图斑类型',
      prop: 'ossCode',
      span: 24,
      searchLabelWidth: 100,
      search: true,
      searchSpan: 4,
      type: 'select',
      dicData: [
        { label: 'Zone one', value: 'shanghai' },
        { label: 'Zone two', value: 'beijing' },
      ],
      props: {
        label: 'label',
        value: 'value',
      },
      rules: [{ required: true, message: '请输入图斑类型', trigger: 'blur' }],
    },
    {
      label: '图斑数量',
      prop: 'ossCode',
      span: 24,
      rules: [{ required: true, message: '请输入图斑数量', trigger: 'blur' }],
    },
    {
      label: '异常图斑数量',
      prop: 'ossCode',
      span: 24,
      rules: [{ required: true, message: '请输入异常图斑数量', trigger: 'blur' }],
    },
    {
      label: '行政区划',
      prop: 'ossCode111',
      span: 24,
      searchLabelWidth: 100,
      search: true,
      searchSpan: 4,
      type: 'tree',
      dicData: deptTreeData,
      props: {
        label: 'name', 
        value: 'id', 
        children: 'childrens', 
      },
      rules: [{ required: true, message: '请选择行政区划', trigger: 'blur' }],
    },
    {
      label: '数据来源',
      prop: 'ossCode',
      span: 24,
      rules: [{ required: true, message: '请输入数据来源', trigger: 'blur' }],
    },
    {
      label: '创建时间',
      prop: 'ossCode',
      span: 24,
      rules: [{ required: true, message: '请输入创建时间', trigger: 'blur' }],
    },
    {
      label: '创建人',
      prop: 'bucketName',
      span: 24,
      searchLabelWidth: 100,
      search: true,
      searchSpan: 4,
      type: 'select',
      dicData: [
        { label: '张三', value: 'zhangsan' },
        { label: '李四', value: 'lisi' },
        { label: '王五', value: 'wangwu' },
      ],
      props: {
        label: 'label',
        value: 'value',
      },
      rules: [{ required: true, message: '请输入创建人', trigger: 'blur' }],
    },
  ],
});
 
const data = ref([]);
// ===== refs =====
const crudRef = ref(null);
const uploadPatchDialog = ref(null);
 
// ===== computed =====
const userInfo = computed(() => store.getters.userInfo);
const permission = computed(() => store.getters.permission);
 
const permissionList = computed(() => ({
  addBtn: !!permission.value.oss_add,
  viewBtn: !!permission.value.oss_view,
  delBtn: !!permission.value.oss_delete,
  editBtn: !!permission.value.oss_edit,
}));
 
const ids = computed(() => selectionList.value.map(ele => ele.id).join(','));
// 获取行政区划
const requestDockInfo = () => {
  getRegionTreeAll({ parentCode: userAreaCode.value }).then(res => {
    deptTreeData.value = res.data.data ? [res.data.data] : [];
 
    console.log('xingzhengquhua', deptTreeData.value);
  });
};
// ===== watch =====
watch(
  () => form.value.category,
  () => {
    const category = func.toInt(form.value.category);
    option.value.column.forEach(item => {
      if (item.prop === 'appId') {
        item.display = category === 4;
      }
    });
  }
);
// ===== methods =====
const rowSave = (row, done, loading) => {
  add(row).then(
    () => {
      onLoad(page.value);
      ElMessage.success('操作成功!');
      done();
    },
    error => {
      console.log(error);
      loading();
    }
  );
};
 
const rowUpdate = (row, index, done, loading) => {
  update(row).then(
    () => {
      onLoad(page.value);
      ElMessage.success('操作成功!');
      done();
    },
    error => {
      console.log(error);
      loading();
    }
  );
};
 
const rowDel = row => {
  ElMessageBox.confirm('确定将选择数据删除?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  });
  // .then(() => remove(row.id))
  // .then(() => {
  //   onLoad(page.value);
  //   ElMessage.success('操作成功!');
  // });
};
 
const searchReset = () => {
  query.value = {};
  onLoad(page.value);
};
 
const searchChange = (params, done) => {
  query.value = params;
  page.value.currentPage = 1;
  onLoad(page.value, params);
  done();
};
 
const selectionChange = list => {
  selectionList.value = list;
};
 
const selectionClear = () => {
  selectionList.value = [];
  crudRef.value?.toggleSelection();
};
 
const handleDebug = row => {
  box.value = true;
};
const beforeOpen = (done, type) => {
  // if (['edit', 'view'].includes(type)) {
  //   getDetail(form.value.id).then(res => {
  //     form.value = res.data.data
  //   })
  // }
  done();
};
 
const currentChange = currentPage => {
  page.value.currentPage = currentPage;
};
 
const sizeChange = pageSize => {
  page.value.pageSize = pageSize;
};
 
const refreshChange = () => {
  onLoad(page.value, query.value);
};
 
const onLoad = (pageInfo, params = {}) => {
  console.log('参数', pageInfo);
  const searchparams = {
    current: pageInfo.currentPage,
    size: pageInfo.pageSize,
  };
  loading.value = true;
  getListPage(pageInfo.currentPage, pageInfo.pageSize, Object.assign({}, params, query.value)).then(
    res => {
      const d = res.data.data;
      page.value.total = d.total;
      data.value = d.records;
      loading.value = false;
      selectionClear();
    }
  );
};
 
// 图斑详情/编辑
const uploadPatch = (row, type = 'detail') => {
  uploadPatchDialog.value = true;
  spotDetailsTitle.value = type === 'detail' ? '图斑详情' : '图斑编辑';
};
 
// 跳转至图斑类型管理页面
const goTypeManagement = () => {
  router.push({ path: '/resource/patchTypeManagement' });
};
 
// 下载图斑
const downloadPatch = () => {
  crudRef.value?.download();
};
onMounted(() => {
  requestDockInfo();
});
</script>
 
<style scoped lang="scss">
.center-align :deep(.el-form-item__content) {
  justify-content: center !important;
}
</style>