提交 1e8d7655 authored 作者: 刘旭's avatar 刘旭

优化导入lic

上级 c0fd1eb4
......@@ -2,48 +2,31 @@
<el-alert title="lic已失效,请通过mac地址,重新导入lic文件" type="warning" :closable='false' center />
<div class='app-container'>
mac地址:{{ macAddress }}
<el-button type="primary" style="width: 100px; margin-top: 20px;" @click="handleSelected">导入lic文件</el-button>
<input ref="uploadInput" type="file" style="display: none;" accept=".tmp" @change="submitUpload" />
<el-upload v-model:file-list="uploadData.fileList" :action="uploadData.action" accept=".tmp"
:show-file-list="false" style="width: 100px; margin-top: 20px;" :on-success="handleSuccess">
<el-button type="primary">导入lic文件</el-button>
</el-upload>
</div>
</template>
<script setup lang='ts'>
import { ref } from 'vue'
import { getMacAddress, importFile } from '@/services/api/login/login'
import { ref, reactive } from 'vue'
import { getMacAddress } from '@/services/api/login/login'
import { ElMessage } from 'element-plus'
const macAddress = ref()
const uploadInput = ref()
const handleSelected = () => uploadInput.value.click()
// //选好文件之后点击打开按钮
const submitUpload = (e: any) => {
const files = e.target.files
const rawFile = files[0]
if (!rawFile) return
upload(rawFile)
}
//上传
const upload = (rawFile: any) => {
uploadInput.value = null
uploadSectionFile(rawFile)
}
const uploadData = reactive({
fileList: '' as any,
action: '/admin/api/lic/info/file/import'
})
const uploadSectionFile = (file: any, params?: any) => {
let fromData = new FormData()// FormData 对象
let fileObj = file// 相当于input里取得的files
fromData.append('file', fileObj)// 文件对象
importFile(fromData).then((res: any) => {
//调用上传接口
if (res.code === 200) {
window.location.href = '/#/login'
sessionStorage.clear()
ElMessage({ type: 'success', message: '导入成功!' })
}
})
const handleSuccess = (res: any, uploadFile: any, uploadFiles: any) => {
if (res.code === 200) {
window.location.href = '/#/login'
sessionStorage.clear()
ElMessage({ type: 'success', message: '导入成功!' })
} else return ElMessage({ type: 'error', message: res.msg })
}
getMacAddress().then((res: any) => {
......
......@@ -89,11 +89,11 @@ export default ({ command, mode }) => {
// '/foo': '',
// 选项写法
"/admin": {
target: "http://192.168.0.9:8089/",
target: "http://192.168.0.60:82/",
// rewrite: (path) => path.replace(/^\/api/, '') http://192.168.0.9:8089/
},
"/wx": {
target: "http://192.168.0.9:8089/",
target: "http://192.168.0.60:82/",
// rewrite: (path) => path.replace(/^\/api/, '')
},
// 正则表达式写法
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论