|
|
@ -1,52 +1,56 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div > |
|
|
<div style="position: relative"> |
|
|
<Upload :action="uploadFileUrl" :headers="accessToken" :data="uploadData" :on-success="handleSuccess" |
|
|
<Upload :action="uploadFileUrl" :headers="accessToken" :data="uploadData" :on-success="handleSuccess" |
|
|
:on-error="handleError" :max-size="100000000" :before-upload="beforeUpload" |
|
|
:on-error="handleError" :max-size="204800" :before-upload="beforeUpload" |
|
|
multiple type="drag" ref="up"> |
|
|
:format="['wgt']" :on-format-error="handleFormatError" type="drag" ref="up"> |
|
|
<div style="padding: 20px 0"> |
|
|
<div style="padding: 20px 0"> |
|
|
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon> |
|
|
<Icon type="ios-cloud-upload" size="52" style="color: #3399ff"></Icon> |
|
|
<p>点击这里或将文件拖拽到这里上传</p> |
|
|
<p>点击这里或将wgt包拖拽到这里上传</p> |
|
|
</div> |
|
|
</div> |
|
|
</Upload> |
|
|
</Upload> |
|
|
<Form ref="form" :model="form" :label-width="85" :rules="formValidate"> |
|
|
<Form ref="form" :model="form" :label-width="100" :rules="formValidate" style="margin-top: 24px"> |
|
|
<FormItem label="版本号" prop="title"> |
|
|
<FormItem label="版本号" prop="version"> |
|
|
<Input v-model="form.version" /> |
|
|
<Input v-model="form.version" placeholder="请输入版本号,如1.0.1" style="width: 380px" /> |
|
|
|
|
|
</FormItem> |
|
|
|
|
|
<FormItem label="wgt包地址" prop="url"> |
|
|
|
|
|
<Input v-model="form.url" readonly placeholder="请先上传wgt包" style="width: 520px" /> |
|
|
|
|
|
</FormItem> |
|
|
|
|
|
<FormItem label="文件名"> |
|
|
|
|
|
<Input v-model="form.fileName" readonly style="width: 380px" /> |
|
|
</FormItem> |
|
|
</FormItem> |
|
|
</Form> |
|
|
</Form> |
|
|
<div slot="footer"> |
|
|
<div> |
|
|
<Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button> |
|
|
<Button type="primary" :loading="submitLoading" @click="handelSubmit">提交</Button> |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
<Spin fix v-if="loading"></Spin> |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { |
|
|
import { |
|
|
getFileCate, |
|
|
uploadAppUpdateFile, |
|
|
addFileCate, |
|
|
|
|
|
editFileCate, |
|
|
|
|
|
uploadFile, |
|
|
|
|
|
trashFileCate, |
|
|
|
|
|
searchFileCate, |
|
|
|
|
|
checkOssSet, |
|
|
checkOssSet, |
|
|
|
|
|
getAppUpdateSet, |
|
|
|
|
|
editAppUpdateSet, |
|
|
} from "@/api/index"; |
|
|
} from "@/api/index"; |
|
|
export default { |
|
|
export default { |
|
|
name: "fileCategory", |
|
|
name: "upApp", |
|
|
props: { |
|
|
|
|
|
showOnly: { |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
default: false, |
|
|
|
|
|
}, |
|
|
|
|
|
}, |
|
|
|
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
uploadFileUrl: uploadFile, |
|
|
uploadFileUrl: uploadAppUpdateFile, |
|
|
|
|
|
loading: false, |
|
|
submitLoading: false, |
|
|
submitLoading: false, |
|
|
accessToken: {}, |
|
|
accessToken: {}, |
|
|
uploadData: {}, |
|
|
uploadData: {}, |
|
|
form:{ |
|
|
form:{ |
|
|
path:'', |
|
|
url: "", |
|
|
version:'' |
|
|
version: "", |
|
|
} |
|
|
fileName: "", |
|
|
|
|
|
}, |
|
|
|
|
|
formValidate: { |
|
|
|
|
|
version: [{ required: true, message: "请输入版本号", trigger: "blur" }], |
|
|
|
|
|
url: [{ required: true, message: "请上传wgt包", trigger: "change" }], |
|
|
|
|
|
}, |
|
|
}; |
|
|
}; |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
@ -54,6 +58,7 @@ |
|
|
this.accessToken = { |
|
|
this.accessToken = { |
|
|
accessToken: this.getStore("accessToken"), |
|
|
accessToken: this.getStore("accessToken"), |
|
|
}; |
|
|
}; |
|
|
|
|
|
this.initAppUpdateSet(); |
|
|
checkOssSet().then((res) => { |
|
|
checkOssSet().then((res) => { |
|
|
if (!res.success) { |
|
|
if (!res.success) { |
|
|
this.$Modal.confirm({ |
|
|
this.$Modal.confirm({ |
|
|
@ -71,13 +76,32 @@ |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
beforeUpload() { |
|
|
initAppUpdateSet() { |
|
|
|
|
|
this.loading = true; |
|
|
|
|
|
getAppUpdateSet().then((res) => { |
|
|
|
|
|
this.loading = false; |
|
|
|
|
|
if (res.result) { |
|
|
|
|
|
for (let attr in res.result) { |
|
|
|
|
|
if (res.result[attr] == null) { |
|
|
|
|
|
res.result[attr] = ""; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
this.form = res.result; |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
beforeUpload(file) { |
|
|
|
|
|
if (!file.name || file.name.toLowerCase().lastIndexOf(".wgt") !== file.name.length - 4) { |
|
|
|
|
|
this.$Message.error("只能上传wgt格式的热更新包"); |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
}, |
|
|
}, |
|
|
handleSuccess(res, file, fileList) { |
|
|
handleSuccess(res, file, fileList) { |
|
|
if (res.success) { |
|
|
if (res.success) { |
|
|
this.$Message.success("上传文件 " + file.name + " 成功"); |
|
|
this.$Message.success("上传文件 " + file.name + " 成功"); |
|
|
this.form.path = res.result |
|
|
this.form.url = res.result; |
|
|
|
|
|
this.form.fileName = file.name; |
|
|
} else { |
|
|
} else { |
|
|
file.percentage = 0; |
|
|
file.percentage = 0; |
|
|
file.status = "fail"; |
|
|
file.status = "fail"; |
|
|
@ -88,9 +112,23 @@ |
|
|
handleError(error, file, fileList) { |
|
|
handleError(error, file, fileList) { |
|
|
this.$Message.error(error.toString()); |
|
|
this.$Message.error(error.toString()); |
|
|
}, |
|
|
}, |
|
|
|
|
|
handleFormatError(file) { |
|
|
|
|
|
this.$Message.error(file.name + " 不是wgt格式文件"); |
|
|
|
|
|
}, |
|
|
handelSubmit() { |
|
|
handelSubmit() { |
|
|
|
|
|
this.$refs.form.validate((valid) => { |
|
|
} |
|
|
if (!valid) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
this.submitLoading = true; |
|
|
|
|
|
editAppUpdateSet(this.form).then((res) => { |
|
|
|
|
|
this.submitLoading = false; |
|
|
|
|
|
if (res.success) { |
|
|
|
|
|
this.$Message.success("保存成功"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|
this.init(); |
|
|
this.init(); |
|
|
|