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

优化导入lic

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