<!--
* @Author: mabo 9086467+mabo19920219@user.noreply.gitee.com
* @Date: 2023-01-13 11:24:30
* @LastEditors: mabo 9086467+mabo19920219@user.noreply.gitee.com
* @LastEditTime: 2023-02-07 18:25:15
* @FilePath: \a-gongfu\src\views\tryIt\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div style="background:#fff">
<div class="envTopPart">气象海洋服务数据导入客户端</div>
<div class="flexBox">
<div class="topBox">
<el-row>
<el-col :span="2">
<div class="choiceFiles">
<i class="el-icon-folder-opened"></i> 选择文件
</div>
</el-col>
<el-col :span="4">
<el-select v-model="value" placeholder="请选择" @change='selectValue'>
<el-option v-for="(item,index) in options" :key="index+'123'" :label="item" :value="item">
</el-option>
</el-select>
</el-col>
<el-col :span="18">
<div class="choiceFile">
<el-upload class="upload-demo" ref="upload" :before-upload="beforeUpload" :http-request="httpRequest" :on-preview="handlePreview" :on-remove="handleRemove" action=''
:file-list="fileList" :auto-upload="false">
<el-button slot="trigger" size="small" type="primary">选择文件</el-button>
<el-button style="margin-left: 10px" size="small" type="success" @click="submitUpload">点击导入</el-button>
</el-upload>
</div>
</el-col>
</el-row>
</div>
<div class="rightPart">
<el-row>
<el-col :span="4">
<div class="choiceFiles">
<i class="el-icon-warning-outline"></i> 日志信息
</div>
</el-col>
<el-col :span="20">
<div class="grid-content bg-purple-light"></div>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<div class="grid-content bg-purple-light"> </div>
</el-col>
</el-row>
<div class="rizhiContent">
<el-table v-loading="loading" :data="tableData" style="width: 100%">
<el-table-column prop="upload_type" label="编号" width="180">
</el-table-column>
<el-table-column prop="upload_time" label="上传时间" width="180">
</el-table-column>
<el-table-column prop="upload_type" label="类型">
</el-table-column>
<el-table-column prop="end_time" label="结束时间">
</el-table-column>
<el-table-column prop="total_records" label="总记录数">
</el-table-column>
<el-table-column prop="insert_records" label="新增记录数">
</el-table-column>
<el-table-column prop="error_records" label="异常记录数">
</el-table-column>
<el-table-column prop="filepath" label="文件路径">
</el-table-column>
<el-table-column prop="filename" label="文件名">
</el-table-column>
<el-table-column prop="upload_status" label="上传状态">
<template slot-scope="scope">
{{scope.row.upload_status=='run'?'运行中':'停止'}}
</template>
</el-table-column>
<el-table-column prop="upload_desc" label="上传描述">
</el-table-column>
</el-table>
</div>
<div class='paginations'>
<el-pagination background :current-page.sync="currentPage" :page-sizes="pageSizes" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
</div>
</div>
</div>
</div>
</template>
<script>
import axios from "axios"
import { Message } from "element-ui"
export default {
data() {
return {
fileList: [],
options: [],
value: "",
tableData: [],loading:false,
total: 0,
pageSizes: [10],
currentPage: 1,
selectValues: "",
}
},
created() {
this.getInfo()
this.getSelect()
},
methods: {
beforeUpload(file) {
this.fileList.push(file)
},
httpRequest(param) {
if(this.selectValues===''){
this.$message({
message: "请先选择类型",
type: "error",
})
}else{
this.loading=true
let fd = new FormData()
fd.append("file", param.file) // 传文件
fd.append("upload_type", this.selectValues) // 传文件
axios.post("/upload/uploadFile", fd, {
headers: { "Content-Type": "multipart/form-data" }, //定义内容格式,很重要
timeout: 20000,
})
.then((response) => {
if ((response.code = 200)) {
this.loading=false
this.$message({
message: "上传成功",
type: "success",
})
this.getInfo()
this.$refs.upload.clearFiles()
}
})
.catch((err) => {
this.$message({
message: "上传失败",
type: "error",
})
this.getInfo()
})
}
},
handleSizeChange(e) {},
handleCurrentChange(e) {},
submitUpload() {
this.$refs.upload.submit()
},
handleRemove(file, fileList) {
debugger
console.log(file, fileList)
},
handlePreview(file) {
console.log(file)
},
getInfo() {
axios
.get("/queryUploadInfo/queryInfo", { querypage: 1 }, "baseUrl")
.then((res) => {
if(res.data.code==200){
this.tableData = res.data.data.values
this.total = res.data.data.allrecords
}
})
},
getSelect() {
axios.get("upload/getUploadTypes", {}, "baseUrl").then((res) => {
if (res.data.code == 200) {
this.options = res.data.data.values
}
})
},
selectValue(a) {
this.selectValues = a
},
},
}
</script>
<style scoped lang="scss">
.envTopPart {
font-size: 32px;
text-align: center;
height: 70px;
line-height: 70px;
}
.flexBox {
background: #ccc;
height: 90vh;
.topBox {
padding: 0 10px;
background-color: #fff;
.choiceFiles {
font-size: 16px;
height: 40px;
line-height: 40px;
}
.choiceFile {
height: 40px;
line-height: 40px;
}
}
.rightPart {
background-color: #fff;
width: 100%;
height: 100%;
.choiceFiles {
padding: 0 10px;
background-color: #fff;
font-size: 16px;
height: 50px;
line-height: 50px;
}
.rizhiContent {
padding: 10px 20px;
}
.paginations{
display: inline-block;
float: right;
width: 400px;
}
}
}
</style>
上传文件
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 步骤 1.在github里面创建仓库 并且添加下面这个文件 2.检查使用的是SSH协议 3.在本地电脑上找一个地方...
- 上传文件 (1)工具类 (2)定义接口 (3)调用 http://localhost:8080/image/upl...
- 在使用<el-upload>上传完文件后,当跳转到其他页面再返回时,已上传的文件由于页面重新刷新是不存在的,如果要...
- 上传文件的表单使用 post 方式,并且要在 form 中添加 enctype='multipart/form-d...
- 一、HttpPost上传文件 二、HttpGet对API进行Get请求 两张方式: 1、在URL中拼接 2、使用参...