lxl
2022-10-27 f6ebd1820968db8521bed86d25b183efe7eb877b
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
<template>
  <div class="authorityManagement_box">
    <My-bread :list="['数据管理', '数据上传']"></My-bread>
    <el-divider />
    <div class="inquire">
      <el-form ref="formData1" :model="updateForm" :inline="true">
        <el-form-item>
          <el-button type="primary" size="small" @click="showCatalog()"
            >目录</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-tooltip
            :content="
              updateForm.cataName == '' ? '未选择目录' : updateForm.cataName
            "
            placement="top-start"
          >
            <el-input
              v-model="updateForm.cataName"
              disabled
              class="firstInput"
            />
          </el-tooltip> </el-form-item
        ><el-form-item>
          <span>类型选择</span>
        </el-form-item>
        <el-form-item>
          <el-select v-model="updateForm.type" clearable placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <span>版本</span>
        </el-form-item>
        <el-form-item>
          <el-input v-model="updateForm.version" />
        </el-form-item>
 
        <el-form-item>
          <input
            name="file1"
            :accept="acceptItem"
            type="file"
            id="uploading"
            style="display: none"
            multiple="multiple"
            @change="clearFileList"
          />
          <el-button
            @click="clearFileList"
            icon="el-icon-thumb"
            type="primary"
            size="small"
            >选择</el-button
          >
          <p class="show"></p>
 
          <el-button
            v-if="btnStatus.upload"
            @click="uploadFile"
            icon="el-icon-thumb"
            type="success"
            size="small"
            >上传</el-button
          >
          <!-- <el-row>
            <el-col :span="2">
              <el-link
                title="添加数据"
                :underline="false"
                @click="uploadFile"
                style="margin-left: 10px"
                ><i class="el-icon-plus"></i
              ></el-link>
            </el-col>
          </el-row> -->
          <!-- <el-upload
            id="uploading"
            :on-remove="handleRemove"
            :http-request="uploadFile"
            :file-list="fileList"
            multiple
            ref="upload"
            class="upload"
            action="http://192.168.20.106/LFServer/Meta/Upload"
            :auto-upload="false"
            :headers="headers"
            :accept="acceptItem"
          >
            <template #trigger>
              <el-button
                @click="clearFileList"
                icon="el-icon-thumb"
                type="primary"
                size="small"
                >选择</el-button
              >
            </template>
            <el-button
              class="ml-3"
              @click="submitUpload"
              icon="el-icon-upload2"
              type="success"
              size="small"
            >
              上传
            </el-button>
          </el-upload> -->
        </el-form-item>
      </el-form>
    </div>
    <div class="table_box">
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        fit
        height="99%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column width="50" type="index" label="序号" />
        <el-table-column min-width="150" prop="name" label="数据名称" />
        <el-table-column min-width="200" prop="path" label="所属目录" />
        <el-table-column min-width="100" prop="create_time" label="创建时间" />
        <el-table-column min-width="80" prop="create_user" label="创建人员" />
        <el-table-column min-width="50" prop="type" label="数据类型" />
        <el-table-column min-width="50" prop="format" label="数据格式" />
        <el-table-column min-width="80" prop="up_unit" label="上传单位" />
        <el-table-column min-width="50" prop="status" label="数据状态" />
        <el-table-column min-width="50" prop="version" label="数据版本" />
      </el-table>
    </div>
    <div class="pagination_box" style="margin-top: 20px; margin-left: 400px">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="10"
        layout="total, sizes, prev, pager, next, jumper"
        :total="count"
      >
      </el-pagination>
    </div>
    <div class="leftTree" v-show="showCata">
      <div class="treeBox">
        <catalogueTree></catalogueTree>
      </div>
      <div class="btnBox">
        <el-button type="primary" size="small" @click="selectCataName"
          >确定</el-button
        >
        <el-button type="primary" size="small" @click="closeCata"
          >取消</el-button
        >
      </div>
    </div>
  </div>
</template>
 
<script>
import $ from "jquery";
 
import { queryUploadData, queryDataCount } from "../../api/api";
import catalogueTree from "../../components/catalogueTree.vue";
import MyBread from "../../components/MyBread.vue";
export default {
  name: "dataUpdata",
  components: {
    MyBread,
    catalogueTree,
  },
  data() {
    return {
      options: [
        {
          value: "DEM",
          label: "高程数据",
        },
        {
          value: "DOM",
          label: "影像数据",
        },
        {
          value: "Terra",
          label: "地形数据",
        },
        {
          value: "Tilt",
          label: "倾斜模型",
        },
        {
          value: "PointCloud",
          label: "点云数据",
        },
        {
          value: "Geology",
          label: "地质模型",
        },
        {
          value: "BIM",
          label: "BIM模型",
        },
        {
          value: "manual",
          label: "手工模型",
        },
        {
          value: "line",
          label: "线划图数据",
        },
        {
          value: "Chart",
          label: "图表数据",
        },
        {
          value: "File",
          label: "文件数据",
        },
      ],
      value: "",
      showinfoBox: false,
      itemdetail: {},
      fileList: [],
      headers: { "Content-Type": "multipart/form-data" },
      acceptItem: "",
      showCata: false,
      updateForm: {
        path_id: "",
        cataName: "",
        version: "",
        type: "",
        name: "",
      },
      multipleSelection: [],
      tableData: [],
      count: 0,
      currentPage: 1,
      pageSize: 10,
      pageNum: 1,
      btnStatus: {
        select: false,
        delete: false,
        upload: false,
        download: false,
        insert: false,
        update: false,
      },
    };
  },
 
  watch: {
    "updateForm.type": {
      immediate: true,
      handler(val) {
        switch (val) {
          case "DEM":
            this.acceptItem = ".tif,.img";
            break;
          case "DOM":
            this.acceptItem = ".tif,.img";
            break;
          case "Terra":
            this.acceptItem = ".mpt";
            break;
          case "Tilt":
            this.acceptItem = ".3dml";
            break;
          case "PointCloud":
            this.acceptItem = ".cpt";
            break;
          case "Geology":
            this.acceptItem = ".3dml";
            break;
          case "BIM":
            this.acceptItem = ".3dml";
            break;
          case "manual":
            this.acceptItem = ".Max";
            break;
          case "Chart":
            this.acceptItem = ".xls,.mdb";
            break;
          case "line":
            this.acceptItem = ".mdb";
            break;
          case "File":
            this.acceptItem =
              ".xls,.mdb,.xls,.pdf,.dwg,.png,.jpg,.bmp,.avi,.mp4,.wmv,.mp3,.txt,.fly";
            break;
        }
      },
    },
  },
  created() {
    // this.getMetaData(10, 1);
    // this.getMetaCount("");
    this.showPermsBtn();
  },
  methods: {
    showPermsBtn() {
      let currentPerms = this.$store.state.currentPerms;
      let permsEntity = this.$store.state.permsEntity;
      permsEntity
        .filter((item) => item.perms == currentPerms)
        .map((item) => (this.btnStatus[item.tag.substr(1)] = true));
    },
    // 请求数据
    getMetaData(size, index) {
      queryUploadData(size, index).then((res) => {
        this.tableData = res.data;
      });
    },
    // 请求数据数量
    getMetaCount(name) {
      queryDataCount(name).then((res) => {
        this.count = res.data;
      });
    },
    // 获取多选
    handleSelectionChange(val) {
      this.multipleSelection = val;
      // console.log(val);
    },
    // 显示目录
    showCatalog() {
      this.showCata = true;
    },
    // 选择目录
    selectCataName() {
      this.updateForm.cataName = this.$store.state.catalogueName;
      this.updateForm.path_id = this.$store.state.cataNode.id;
      this.$store.commit("changeCata", ""); //清空state的面包屑
      this.$store.commit("changeNode", ""); //清空state的节点对象
      this.showCata = false;
    },
    closeCata() {
      this.showCata = false;
    },
    clearFileList() {
      $("#uploading").click();
      // var val = document.getElementById("uploading").files;
      // if (!val || !val.length) return;
 
      // val.forEach((e) => {
      //   console.log(e.name);
      // });
    },
    submitUpload() {
      if (this.updateForm.path_id == "" || this.updateForm.type == "") {
        alert("请选择数据类型或上传目录");
        this.$refs.upload.abort();
        return false;
      } else {
        this.$refs.upload.submit();
      }
    },
    uploadFile(item) {
      var val = document.getElementById("uploading").files;
      if (!val || !val.length) return;
 
      // if (val.length != 0) {
      //   var i = val.length;
      //   for (var j = 0; j < i; j++) {
      //     FormDatas.append("file" + j, val[j]); // 文件对象
      //   }
      // }
      val.forEach((e) => {
        let FormDatas = new FormData();
        FormDatas.append("file", e, e.name); // 文件对
        let name = e.name;
        let path_id = this.updateForm.path_id;
        let version = this.updateForm.version;
        let type = this.updateForm.type;
        let url = `http://192.168.20.106/LFServer/Meta/Upload?path_id=${path_id}&type=${type}&version=${version}&name=${name}`;
        // console.log(url);
        this.$http({
          method: "post",
          url,
          headers: this.headers,
          timeout: 30000,
          data: FormDatas,
          // onUploadProgress: (progressEvent) => {
          //   const complete = parseInt(
          //     ((progressEvent.loaded / progressEvent.total) * 100) | 0,
          //     10
          //   );
          //   // 重点二:onProgress()方法需要以上方接收的形参来调用
          //   // 这个方法有一个参数"percent",给他进度值 complete 即可
          //   item.onProgress({ percent: complete });
          // },
        }).then((res) => {
          if (res.status == 200 && res.data.length != 0) {
            this.$message({
              message: "上传成功",
              type: "success",
            });
            this.getMetaData(10, 1);
            this.getMetaCount("");
          } else {
            alert("上传失败");
            console.log(res);
          }
        });
      });
    },
    // 文件列表移除文件时的钩子
    handleRemove(file, fileList) {
      // console.log(file, fileList);
    },
    // 条数修改
    handleSizeChange(val) {
      this.pageSize = val;
      this.getMetaData(this.pageSize, 1);
      this.getMetaCount("");
    },
    // 页数修改
    handleCurrentChange(val) {
      this.pageNum = val;
      this.getMetaData(this.pageSize, this.pageNum);
      this.getMetaCount("");
    },
    // showDetail(index, row) {
    //   // console.log(index, row);
    //   this.showinfoBox = true;
    //   this.itemdetail = row;
    // },
    // handleDelete(index, row) {
    //   // console.log(index, row);
    //   this.$confirm("确定是否删除?", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {})
    //     .catch(() => {});
    // },
    // closeDetial() {
    //   this.showinfoBox = false;
    //   this.itemdetail = {};
    // },
  },
};
</script>
<style lang="less" scoped>
//@import url(); 引入公共css类
.authorityManagement_box {
  background: rgb(240, 242, 245);
  border-radius: 10px;
  height: 100%;
  padding: 10px;
  box-sizing: border-box;
  .inquire {
    margin: 10px auto;
    background: #fff;
    border-radius: 5px;
    border: 1px solid rgb(202, 201, 204);
    height: 90px;
    .el-form-item {
      margin: 5px;
    }
    .el-input {
      width: 307px;
    }
 
    .ml-3 {
      margin-left: 10px;
    }
    .upload {
      /deep/ .el-upload-list {
        width: 79vw;
        height: 27px;
        margin: 0;
        margin-left: 0px;
        padding: 0;
        list-style: none;
        // background: #bfa;
        position: absolute;
        left: -53vw;
        top: 5vh;
        z-index: 10;
        overflow: auto;
        display: flex;
        flex-wrap: wrap;
      }
      /deep/ .el-upload-list__item {
        margin-top: 0px;
        transition: all 0.5s cubic-bezier(0.55, 0, 0.1, 1);
        font-size: 14px;
        color: #606266;
        line-height: 1.8;
        // margin-top: 5px;
        position: relative;
        box-sizing: border-box;
        border-radius: 4px;
        width: 15%;
      }
    }
  }
  .table_box {
    height: 73%;
    overflow: auto;
    padding: 10px;
    background: #fff;
    border-radius: 5px;
    border: 1px solid rgb(202, 201, 204);
    .el-table /deep/ .el-table__header-wrapper tr th {
      background-color: rgb(255, 255, 255) !important;
      color: rgb(0, 0, 0);
    }
    // 修改每行样式:
    .el-table /deep/ .el-table__row {
      background-color: rgba(255, 255, 255) !important;
      color: rgb(0, 0, 0);
    }
    .el-table /deep/ .el-table__body tr.current-row > td {
      background-color: rgb(211, 211, 211) !important;
    }
    .el-table /deep/ .el-table__body tr:hover > td {
      background-color: rgb(211, 211, 211) !important;
    }
    // 修改表格每行边框的样式:
    .el-table /deep/ td,
    .el-table /deep/ th.is-leaf {
      border-bottom: 1px solid #eee;
      border-right: 1px solid #eee;
    }
    .el-table /deep/ .el-table__cell {
      padding: 8px 0;
    }
    // 设置表格每行的高度:
    .el-table /deep/ .el-table__header tr,
    .el-table /deep/ .el-table__header th {
      height: 50px;
    }
    .el-table__body tr,
    .el-table__body td {
      height: 50px;
      padding: 0;
    }
    // 设置表格边框颜色:
 
    .el-table--border::after,
    .el-table--group::after {
      width: 0;
    }
    .el-table::before {
      height: 0;
    }
  }
  .leftTree {
    position: absolute;
    z-index: 10;
    top: 100px;
    left: 600px;
    width: 400px;
    height: 600px;
    background: #f0f2f5;
    border: 1px solid #000;
    .treeBox {
      height: 550px;
      overflow: auto;
      /deep/ .el-tree-node__content:hover {
        background-color: rgb(153, 153, 153);
      }
    }
    .btnBox {
      width: 123px;
      margin: 10px auto 0;
      // background-color: red;
    }
  }
  .infoBox {
    width: 500px;
    border: 1px solid #eee;
    position: absolute;
    z-index: 100;
    top: 15%;
    right: 25%;
    background-color: #fff;
    .el-card {
      background-color: transparent;
      span {
        font-size: 16px;
        font-weight: 600;
      }
    }
    .contentBox {
      margin: 0 aotu 10px;
      p {
        // background-color: #bfa;
        // margin-bottom: 10px;
        font-size: 14px;
      }
    }
  }
}
</style>