fix: BUG修改
This commit is contained in:
parent
fb258da9d2
commit
196053364d
@ -14,7 +14,8 @@ const routes2 = [
|
||||
path: "/",
|
||||
name: "Home",
|
||||
// component: homeLayout
|
||||
component: homeIntro,
|
||||
// component: homeIntro,
|
||||
redirect: "/login"
|
||||
},
|
||||
{
|
||||
path: "/login",
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<!-- 南昌地铁登录页不显示智慧工地云平台字样 -->
|
||||
<span v-if="company == 'nanchang'"></span>
|
||||
</div>
|
||||
<div class="title_r">
|
||||
<!-- <div class="title_r">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@ -35,7 +35,7 @@
|
||||
@click="goBackBtn"
|
||||
>返回到首页</el-button
|
||||
>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="content flex2">
|
||||
<img
|
||||
|
||||
@ -17,6 +17,20 @@
|
||||
<el-form-item>
|
||||
<el-button type="warning" plain @click="refresh">刷新</el-button>
|
||||
<el-button type="primary" size="medium" @click="add">新增</el-button>
|
||||
<el-button size="medium" type="primary" @click="downloadFn()"> 下载模板</el-button>
|
||||
<el-upload
|
||||
style="display: inline-block; margin: 0 15px"
|
||||
class="upload-demo expintBtn"
|
||||
name="file"
|
||||
:on-success="handleImportSuccess"
|
||||
:file-list="fileList"
|
||||
:action="$http.defaults.baseURL + 'xmgl/safetyHatDev/importExcelTemplate'"
|
||||
:data="{ projectSn: $store.state.projectSn }"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
>
|
||||
<el-button size="medium" type="primary">导入</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
@ -87,6 +101,11 @@ export default {
|
||||
this.getPage()
|
||||
this.getWorkerInfoList()
|
||||
},
|
||||
computed: {
|
||||
headers() {
|
||||
return { Authorization: this.$store.state.userInfo.token }
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '',
|
||||
@ -108,9 +127,64 @@ export default {
|
||||
devSn: [{ required: true, message: '必填', trigger: 'blur' }],
|
||||
},
|
||||
searchForm: {},
|
||||
fileList: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 导入成功
|
||||
handleImportSuccess(res) {
|
||||
if (res.code == 200) {
|
||||
this.$message.success(res.message)
|
||||
this.getPage()
|
||||
} else {
|
||||
this.$message.error(res.message)
|
||||
}
|
||||
console.log('导入', res)
|
||||
},
|
||||
// 下载模板
|
||||
downloadFn() {
|
||||
// let data = {
|
||||
// type: type,
|
||||
// projectSn: this.projectSn
|
||||
// }
|
||||
// console.log("token",this.$store.state.userInfo.token)
|
||||
fetch(this.$http.defaults.baseURL + 'xmgl/safetyHatDev/downloadExcelTemplate', {
|
||||
method: 'get',
|
||||
headers: {
|
||||
Authorization: this.$store.state.userInfo.token,
|
||||
'Content-Type': 'application/json' // 设置请求头的内容类型为JSON
|
||||
},
|
||||
// body: JSON.stringify(data) // 将data对象转换为JSON字符串并作为请求体发送
|
||||
})
|
||||
.then(response => {
|
||||
// 处理响应
|
||||
if (!response.ok) {
|
||||
throw new Error('下载失败')
|
||||
}
|
||||
return response.blob()
|
||||
})
|
||||
.then(blob => {
|
||||
// 创建一个下载链接
|
||||
const url = window.URL.createObjectURL(blob)
|
||||
// 创建一个<a>元素
|
||||
const link = document.createElement('a')
|
||||
link.href = url
|
||||
link.download = '模板.xlsx' // 指定下载文件的文件名
|
||||
// 模拟点击下载链接
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
// 释放URL对象
|
||||
window.URL.revokeObjectURL(url)
|
||||
// 处理导出的文件
|
||||
// 这里可以使用blob对象来获取导出的文件内容或者将其保存到本地
|
||||
console.log('下载', link, url)
|
||||
})
|
||||
.catch(error => {
|
||||
// 处理错误
|
||||
console.error(error)
|
||||
})
|
||||
},
|
||||
async getPage() {
|
||||
await getSafeHatEquipmentCentralPageApi({
|
||||
pageNo: this.pagInfo.pageNo,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user