|
@@ -1,15 +1,112 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
-
|
|
|
+ <div class="box">
|
|
|
+ <div class="box-content flex">
|
|
|
+ <div>
|
|
|
+ <div class="font-title">当前版本 {{ versionNo || '版本号丢失' }}</div>
|
|
|
+ </div>
|
|
|
+ <el-upload
|
|
|
+ drag
|
|
|
+ action="#"
|
|
|
+ :limit="1"
|
|
|
+ accept=".zip, .7z, .bin"
|
|
|
+ :on-exceed="onExceed"
|
|
|
+ :http-request="onImport"
|
|
|
+ >
|
|
|
+ <i class="el-icon-upload"></i>
|
|
|
+ <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div class="el-upload__tip" slot="tip">请上传.zip、.7z、.bin等文件格式的更新包</div>
|
|
|
+ </el-upload>
|
|
|
+ <div class="pa-3">
|
|
|
+ <m-button type="primary" size="small" :disabled="!file" icon="el-icon-s-promotion" @click="onUpdate" :loading="loading">执行且更新</m-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="box-content">
|
|
|
+ <LogDetails></LogDetails>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import {
|
|
|
+ uploadVersionPackage,
|
|
|
+ versionLogHistory
|
|
|
+} from '@/api/system'
|
|
|
+import LogDetails from '../components/logDetails'
|
|
|
export default {
|
|
|
- name: 'update-system'
|
|
|
+ name: 'update-system',
|
|
|
+ components: {
|
|
|
+ LogDetails
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ loading: false,
|
|
|
+ file: null,
|
|
|
+ versionNo: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.getNowVersion()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 最新版本
|
|
|
+ async getNowVersion (i) {
|
|
|
+ try {
|
|
|
+ const { data } = await versionLogHistory({ size: 1, current: 1 })
|
|
|
+ if (!data.records.length) return
|
|
|
+ this.versionNo = data.records[0].versionNo
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onUpdate () {
|
|
|
+ this.$confirm('是否确定执行该更新包?', '系统提示').then(async () => {
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('package', this.file)
|
|
|
+ formData.append('run', true)
|
|
|
+ this.loading = true
|
|
|
+ this.versionNo = null
|
|
|
+ try {
|
|
|
+ const { data } = await uploadVersionPackage(formData)
|
|
|
+ this.$message.success('上传成功!')
|
|
|
+ this.versionNo = data.versionNo
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onImport (response) {
|
|
|
+ this.file = response.file
|
|
|
+ },
|
|
|
+ onExceed () {
|
|
|
+ this.$message.error('只能上传一个文件')
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+.box {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ height: 100%;
|
|
|
+ &-content {
|
|
|
+ &.flex {
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ width: 50%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+.font-title {
|
|
|
+ font-size: 24px;
|
|
|
+ font-weight: 600;
|
|
|
+ color: #666;
|
|
|
+ padding: 30px 0;
|
|
|
+}
|
|
|
|
|
|
</style>
|