无人机管理后台前端(已迁走)
张含笑
2025-09-01 2ca94de8ede18ac07ccfd8dec7b6f6a707adde9b
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
<!-- filepath: /d:/work/drone-web-manage/src/views/license/upload.vue -->
<template>
    <!-- <basic-container>
        <el-upload
            class="upload-demo"
            drag
            :http-request="customUpload"
            :show-file-list="false"
            accept=".lic"
        >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
            <div class="el-upload__tip">仅支持扩展名:lic</div>
        </el-upload>
    </basic-container> -->
    <!-- 密钥上传 -->
    <div class="upload-file">
      <img v-if="isSuccess === 'success'" :src="uploadSuccess" alt="" />
      <div v-if="isSuccess === 'success'">上传成功</div>
      <img v-if="isSuccess === 'error'" :src="uploadError" alt="" />
      <div v-if="isSuccess === 'error'">上传失败</div>
      <el-upload
        action="/upload"
        accept=".lic"
        :show-file-list="false"
        :before-upload="handleUpload"
      >
        <div class="upload-btn">密钥上传</div>
      </el-upload>
      <div class="password-time">密钥有效期:{{ passwordTime || '永久有效' }}</div>
    </div>
</template>
 
<script>
import { uploadLicense } from '@/api/license/uploadLicense';
import { findLicenseDate } from '@/api/system/dict';
import uploadSuccess from '@/assets/images/uoload-success.png';
import uploadError from '@/assets/images/upload-error.png';
 
export default {
    data() {
        return {
            isSuccess: '', // 上传状态
            passwordTime: '', // 密钥有效期
            uploadSuccess, // 上传成功图片
            uploadError, // 上传失败图片
        };
    },
    mounted() {
        this.getFindLicenseDate();
    },
    methods: {
        handleUpload(file) {
            uploadLicense(file)
            .then(res => {
                console.log(res.data.code,'444')
                if (res.data.code !== 200) return this.$message.error('上传失败');
                this.$message.success('上传成功');
                this.isSuccess = 'success';
                this.getFindLicenseDate();
            })
            .catch(err => {
                this.isSuccess = 'error';
                this.$message.error('上传失败');
            });
        },
        getFindLicenseDate() {
            findLicenseDate()
                .then(res => {
                    if (res.data.code !== 0) return this.$message.error('上传失败');
                    this.passwordTime = res.data.data;
                })
                .catch(err => {
                    this.$message.error('获取失败失败');
                });
        },
    },
};
</script>
 
<style scoped lang="scss">
.upload-file {
  text-align: center;
  margin-top: 60px;
  .upload-btn {
    width: 93px;
    height: 38px;
    background: #DDEBFF;
    border-radius: 8px 8px 8px 8px;
    border: 1px solid #409EFF;
    text-align: center;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: bold;
    font-size: 14px;
    color: #228CFA;
    line-height: 38px;
    text-align: center;
    margin-top: 10px;
  }
  .password-time {
    margin-top: 50px;
    width: 100%;
    height: 16px;
    font-family: Source Han Sans CN, Source Han Sans CN;
    font-weight: 400;
    font-size: 14px;
    color: #2d9dff;
    line-height: 16px;
    // text-align: left;
  }
}
</style>