index.vue
8.52 KB
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
<template>
<div>
<back-box>
<template slot="title">
<span>授课端版本管理</span>
</template>
<template slot="btns">
<el-tooltip effect="dark" content="添加版本" placement="bottom">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
plain
circle
@click="openAddDia"
></el-button>
</el-tooltip>
</template>
</back-box>
<div class="table-box">
<el-table
:data="tableData"
border
style="width: 100%"
v-loading="loading"
>
<el-table-column
prop="md5"
label="MD5编码"
align="center"
></el-table-column>
<el-table-column
prop="versionName"
label="版本名称"
align="center"
></el-table-column>
<el-table-column
width="80"
prop="versionNumber"
label="版本号"
align="center"
></el-table-column>
<el-table-column
prop="createdTime"
label="上传时间"
align="center"
width="200"
></el-table-column>
<el-table-column
prop="fileSize"
label="文件大小"
align="center"
><template slot-scope="scoped">{{setSize(scoped.row.fileSize)}}</template></el-table-column>
<el-table-column
prop="description"
label="更新描述"
align="center"
></el-table-column>
<!-- <el-table-column label="操作" align="center" width="160">
<template slot-scope="scoped">
<el-popconfirm title="确定删除吗?" @confirm="remove(scoped.row)">
<span class="del" slot="reference">删除</span>
</el-popconfirm>
</template>
</el-table-column> -->
</el-table>
<div class="pagination-box">
<el-pagination
layout="total,prev, pager, next"
:hide-on-single-page="true"
:total="total"
@current-change="changePage"
:current-page="page"
:page-size="size"
>
</el-pagination>
</div>
</div>
<el-dialog :close-on-click-modal="false"
title="添加账号"
:visible.sync="diaAdd"
v-if="diaAdd"
width="400"
>
<el-form
class="form-box"
:model="formAdd"
:rules="ruleAdd"
ref="formAdd"
label-width="160px"
>
<el-form-item label="应用名称:" prop="versionName">
<el-col :span="12">
<el-input
placeholder="请输入应用名称"
v-model.trim="formAdd.appName"
maxlength="30"
>
</el-input>
</el-col>
</el-form-item>
<el-form-item label="版本名称:" prop="versionName">
<el-col :span="12">
<el-input
placeholder="请输入版本名称"
v-model.trim="formAdd.versionName"
maxlength="30"
>
</el-input>
</el-col>
</el-form-item>
<el-form-item label="版本号:">
<el-col :span="12">
<el-input
placeholder="请输入版本号"
v-model.trim="formAdd.versionNumber"
maxlength="30"
>
</el-input>
</el-col>
</el-form-item>
<el-form-item label="类型:">
<el-col :span="12">
<el-select v-model="formAdd.appType" placeholder="">
<el-option label="授课端软件" :value="0"></el-option>
<el-option label="发卡软件" :value="1"></el-option>
<el-option label="授课端个人版" :value="2"></el-option>
</el-select>
</el-col>
</el-form-item>
<el-form-item label="软件图标:">
<el-col :span="12">
<upLoadImg url="/file/uploadImg" @upSuccess="logoSuccess" />
</el-col>
</el-form-item>
<el-form-item label="上传全量文件包:" prop="filePath">
<el-col :span="12">
<upLoad :url="url" @upSuccess="appfilesSuccess" />
</el-col>
</el-form-item>
<el-form-item label="上传增量文件包:" prop="incrementFilePath">
<el-col :span="12">
<upLoad :url="url" @upSuccess="addfilesSuccess" />
</el-col>
</el-form-item>
<el-form-item label="更新描述:" prop="description">
<el-col :span="12">
<el-input
type="textarea"
:rows="3"
v-model="formAdd.description"
placeholder="填写描述"
></el-input>
</el-col>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="save">确 定</el-button>
<el-button @click="diaAdd = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import upLoad from "./components/upLoad.vue";
import upLoadImg from "./components/upLoadImg.vue";
export default {
components: {
upLoad,
upLoadImg,
},
data() {
return {
url: "/file/uploadApp",
loading: false,
addLoading: false,
diaAdd: false,
tableData: [],
formAdd: {
appName: "",
versionName: "",
versionNumber: "",
appType:0,
appImage: "",
md5: "",
fileSize: "",
filePath: "",
incrementMd5: "",
incrementFileSize: "",
incrementFilePath: "",
description: "",
},
ruleAdd: {
appName: [
{ required: true, message: "请输入应用名称", trigger: "blur" },
],
versionName: [
{ required: true, message: "请输入版本名称", trigger: "blur" },
],
appType: [
{ required: true, message: "请选择版本名称", trigger: "blur" },
],
filePath: [
{ required: true, message: "请上传全量文件包", trigger: "blur" },
],
// incrementFilePath: [
// { required: true, message: "请上传增量文件包", trigger: "blur" },
// ],
},
page: 1,
size: 20,
total: 0,
};
},
created() {
this._QueryData();
},
methods: {
setSize(size){
let fileSize = (size/1024/1224).toFixed(2)
return `${fileSize}MB`
},
openAddDia() {
for (let key in this.formAdd) {
this.formAdd[key] = "";
}
this.formAdd.appType = 0
this.diaAdd = true;
},
changePage(page) {
this.page = page;
this._QueryData();
},
async remove(obj) {
const { data, status, info } = await this.$request.delVersion({
id: obj.id,
});
if (status === 0) {
this.$message.success("删除成功~");
this._QueryData();
} else {
this.$message.error(info);
}
},
logoSuccess(res) {
this.formAdd.appImage = res.data.resId;
},
appfilesSuccess(res) {
this.formAdd.md5 = res.data.md5;
this.formAdd.fileSize = res.data.size;
this.formAdd.filePath = res.data.resId;
},
addfilesSuccess(res) {
this.formAdd.incrementMd5 = res.data.md5;
this.formAdd.incrementFileSize = res.data.size;
this.formAdd.incrementFilePath = res.data.resId;
},
async save() {
this.$refs.formAdd.validate(async (valid) => {
if (valid) {
if (this.addLoading) return;
this.addLoading = true;
const { data, status, info } = await this.$request.addVersion({
...this.formAdd,
});
this.addLoading = false;
if (status === 0) {
this.diaAdd = false;
this.$message.success("添加成功~");
this._QueryData();
} else {
this.$message.error(info);
}
} else {
this.$message.warning("必填项不能为空,请检查。");
}
});
},
async _QueryData() {
this.loading = true;
this.tableData = [];
const { data, status, info } = await this.$request.versionPage({
page: this.page,
size: this.size,
});
this.loading = false;
if (status === 0) {
this.tableData = data.list || [];
this.total = data.count;
} else {
this.$message.error(info);
}
},
},
};
</script>
<style lang="scss" scoped>
.table-box {
padding: 20px;
}
.del {
font-size: 14px;
color: #666;
cursor: pointer;
}
</style>