Commit 1c4bd121 authored by zhanglw's avatar zhanglw

开采管理文件上传下载

parent cc13fece
...@@ -3185,7 +3185,15 @@ var HttpReq = function(){ ...@@ -3185,7 +3185,15 @@ var HttpReq = function(){
method: 'get' method: 'get'
}) })
}, },
//开采管理-下载文件
downloadExcelOrFbx: function(params){
return request({
url: '/api/miningManagement/downloadExcelOrFbx',
method: 'get',
params: params,
responseType: 'blob'
})
},
}, },
......
...@@ -19,6 +19,9 @@ const install = function(Vue) { ...@@ -19,6 +19,9 @@ const install = function(Vue) {
new Dict(this.dict).init(this.$options.dicts, () => { new Dict(this.dict).init(this.$options.dicts, () => {
this.$nextTick(() => { this.$nextTick(() => {
this.$emit('dictReady') this.$emit('dictReady')
if (this.$options.methods && this.$options.methods.onDictReady instanceof Function) {
this.$options.methods.onDictReady.call(this, this.dict)
}
}) })
}) })
} }
......
...@@ -108,7 +108,10 @@ export default { ...@@ -108,7 +108,10 @@ export default {
} }
this.truckDynamicListData.data = arr1; this.truckDynamicListData.data = arr1;
this.truckDynamicListData.num2 = 0; this.truckDynamicListData.num2 = 0;
this.kachedongtai(); if(arr1.length){
this.truckDynamicListData.number = arr1[0].number
this.xuanzekuangValue = arr1[0].number
}
this.DPcomputer13BoxTimer = setInterval(() => { this.DPcomputer13BoxTimer = setInterval(() => {
this.kachedongtai(); this.kachedongtai();
}, 20000) }, 20000)
...@@ -116,17 +119,17 @@ export default { ...@@ -116,17 +119,17 @@ export default {
}, },
//卡车动态 //卡车动态
kachedongtai() { kachedongtai() {
let num1 = parseInt(this.truckDynamicListData.data.length) - 1; // let num1 = parseInt(this.truckDynamicListData.data.length) - 1;
//获取车辆实时数据 // //获取车辆实时数据
if (this.truckDynamicListData.num2 <= num1) { // if (this.truckDynamicListData.num2 <= num1) {
//
} else { // } else {
this.truckDynamicListData.num2 = 0; // this.truckDynamicListData.num2 = 0;
} // }
if (this.truckDynamicListData.data == 0) { // if (this.truckDynamicListData.data == 0) {
return // return
} // }
this.truckDynamicListData.number = this.truckDynamicListData.data[this.truckDynamicListData.num2].number; // this.truckDynamicListData.number = this.truckDynamicListData.data[this.truckDynamicListData.num2].number;
this.initData(); this.initData();
}, },
initData(){ initData(){
......
...@@ -111,7 +111,10 @@ export default { ...@@ -111,7 +111,10 @@ export default {
} }
this.forkliftkDynamicListData.data = arr2; this.forkliftkDynamicListData.data = arr2;
this.forkliftkDynamicListData.num2 = 0; this.forkliftkDynamicListData.num2 = 0;
this.dianchandongtai(); if(arr2.length){
this.forkliftkDynamicListData.number = arr2[0].number
this.xuanzekuangValue = arr2[0].number
}
this.DPcomputer14BoxTimer = setInterval(() => { this.DPcomputer14BoxTimer = setInterval(() => {
this.dianchandongtai(); this.dianchandongtai();
}, 20000) }, 20000)
...@@ -119,17 +122,17 @@ export default { ...@@ -119,17 +122,17 @@ export default {
}, },
//挖机动态 //挖机动态
dianchandongtai() { dianchandongtai() {
let num1 = parseInt(this.forkliftkDynamicListData.data.length) - 1; // let num1 = parseInt(this.forkliftkDynamicListData.data.length) - 1;
//获取车辆实时数据 // //获取车辆实时数据
if (this.forkliftkDynamicListData.num2 <= num1) { // if (this.forkliftkDynamicListData.num2 <= num1) {
//
} else { // } else {
this.forkliftkDynamicListData.num2 = 0; // this.forkliftkDynamicListData.num2 = 0;
} // }
if (this.forkliftkDynamicListData.data == 0) { // if (this.forkliftkDynamicListData.data == 0) {
return // return
} // }
this.forkliftkDynamicListData.number = this.forkliftkDynamicListData.data[this.forkliftkDynamicListData.num2].number; // this.forkliftkDynamicListData.number = this.forkliftkDynamicListData.data[this.forkliftkDynamicListData.num2].number;
this.initData(); this.initData();
}, },
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="head-container"> <div class="head-container">
<!-- 搜索 --> <!-- 搜索 -->
<label class="el-form-item-label" style="font-weight: 500;">文件名</label> <label class="el-form-item-label" style="font-weight: 500;">文件名</label>
<el-input v-model="query.fileName" clearable size="small" placeholder="请输入安全帽MAC" style="width:180px;"/> <el-input v-model="query.fileName" clearable size="small" placeholder="请输入文件名称" style="width:180px;"/>
<label class="el-form-item-label" style="font-weight: 500;">上传时间</label> <label class="el-form-item-label" style="font-weight: 500;">上传时间</label>
<el-date-picker <el-date-picker
v-model="query.modificationTime" v-model="query.modificationTime"
...@@ -27,15 +27,22 @@ ...@@ -27,15 +27,22 @@
<div class="ctin-box"> <div class="ctin-box">
<div class="content-within"> <div class="content-within">
<div class="content-fix"> <div class="content-fix">
<div class="toolbar"></div> <div class="toolbar">
<el-button slot="left" class="filter-item" size="mini" type="primary" icon="el-icon-upload" @click="uploadVisible=true">上传</el-button>
</div>
<div class="content"> <div class="content">
<el-tabs v-model="query.type" @tab-click="loadData">
<el-tab-pane label="Excel报表" name="excel"></el-tab-pane>
<el-tab-pane label="三维模型" name="fbx"></el-tab-pane>
</el-tabs>
<el-table :data="tableData" v-loading="loading" border style="width:auto"> <el-table :data="tableData" v-loading="loading" border style="width:auto">
<el-table-column prop="fileName" label="文件名" align="center"></el-table-column> <el-table-column prop="fileName" label="文件名" align="center"></el-table-column>
<el-table-column prop="url" label="文件路由" align="center"></el-table-column> <el-table-column prop="url" label="文件路由" align="center"></el-table-column>
<el-table-column prop="modificationTime" label="上传时间" align="center"></el-table-column> <el-table-column prop="modificationTime" label="上传时间" align="center"></el-table-column>
<el-table-column label="操作" align="center" fixed="right"> <el-table-column label="操作" align="center" fixed="right">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-view" @click="viewTable(scope.row)">在线预览</el-button> <el-button v-if="query.type==='excel'" size="mini" type="text" icon="el-icon-view" @click="viewTable(scope.row)">在线预览</el-button>
<el-button size="mini" type="text" icon="el-icon-download" @click="downloadFile(scope.row)">下载</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
...@@ -56,11 +63,37 @@ ...@@ -56,11 +63,37 @@
<el-button @click="cancelForm">关闭</el-button> <el-button @click="cancelForm">关闭</el-button>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog append-to-body :close-on-click-modal="false" :before-close="cancelForm" :visible.sync="uploadVisible" title="文件上传" width="560px">
<el-form ref="form" :model="form" size="small" label-width="80px">
<!-- 上传文件 -->
<el-form-item label="">
<el-upload
ref="upload"
:before-upload="beforeUpload"
:auto-upload="false"
:headers="headers"
:on-change="handleFileChange"
:on-success="handleSuccess"
:on-error="handleError"
action="/api/miningManagement/uploadExcelOrFbx"
:data="{type:query.type}"
>
<div class="eladmin-upload"><i class="el-icon-upload" /> 添加文件</div>
<div slot="tip" class="el-upload__tip">请上传{{query.type}}文件,且不超过100M</div>
</el-upload>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="cancelForm">取消</el-button>
<el-button :loading="loading" type="primary" @click="upload">确认</el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { getToken } from '@/utils/auth'
import {Tools, HttpReq, Dates} from '@/assets/js/common.js'; import {Tools, HttpReq, Dates} from '@/assets/js/common.js';
export default { export default {
...@@ -68,24 +101,80 @@ export default { ...@@ -68,24 +101,80 @@ export default {
data() { data() {
return { return {
title: '', title: '',
fileUploadApi: '',
headers: { 'Authorization': getToken() },
visible: false, visible: false,
uploadVisible: false,
loading: false, loading: false,
query: {}, query: {
type: 'excel',
},
page: 1, page: 1,
size: 10, size: 10,
total: 0, total: 0,
tableData: [], tableData: [],
tabList: ['Sheet1'], tabList: ['Sheet1'],
activeTab: 'Sheet1', activeTab: 'Sheet1',
tableHtml: '' tableHtml: '',
form: {},
} }
}, },
mounted() { mounted() {
this.$nextTick(() => { this.$nextTick(() => {
this.loadData(); this.loadData()
}) })
}, },
methods: { methods: {
download(text, name, suffix) {
var link = document.createElement('a');
link.style.display = 'none';
link.href = URL.createObjectURL(new Blob([text], { type: this.query.type==='excel'?"application/vnd.ms-excel":"application/octet-stream" }));
link.setAttribute('download', name + '.' + suffix);
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
},
downloadFile(item) {
let strArr = item.fileName.split('.')
HttpReq.truckDispatching.downloadExcelOrFbx({url:item.url, type:this.query.type}).then((res) => {
this.download(res, strArr[0], strArr[1]||'xlsx')
})
},
upload() {
this.$refs.upload.submit()
},
handleFileChange(file) {
},
beforeUpload(file) {
let isLt2M = true
isLt2M = file.size / 1024 / 1024 < 100
if (!isLt2M) {
this.loading = false
this.$message.error('上传文件大小不能超过 100MB!')
}
return isLt2M
},
handleSuccess(res, file, fileList) {
this.$notify({
title: res.msg,
type: res.code === 200 ? 'success' : 'error',
duration: 2500
})
if (res.code === 200) {
this.cancelForm()
}
},
// 监听上传失败
handleError(e, file, fileList) {
const msg = JSON.parse(e.message)
this.$notify({
title: msg.message,
type: 'error',
duration: 2500
})
this.loading = false
},
handleTabClick(tab, event) { handleTabClick(tab, event) {
console.log(tab, event); console.log(tab, event);
}, },
...@@ -124,7 +213,10 @@ export default { ...@@ -124,7 +213,10 @@ export default {
}) })
}, },
cancelForm() { cancelForm() {
this.visible = false; this.visible = false
this.uploadVisible = false
this.$refs.upload.clearFiles()
this.loadData()
}, },
// 点击搜索 // 点击搜索
toSearch() { toSearch() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment