优化上传文件

main
fanluyan 4 months ago
parent 9cd3d98d5e
commit 1678ca805a

@ -2,12 +2,19 @@
<div class="transformer">
<div class="choose chooseInputColor">
<div class="button" style="margin-bottom: 10px">
<el-button icon="el-icon-upload2" @click="onImportClick"></el-button>
<el-button icon="el-icon-upload2" @click="onImportClick"
>导入</el-button
>
<!-- <el-button
icon="el-icon-download"
@click="onDownloadClick"
>下载模板</el-button>-->
<el-button v-show="buttonShow" icon="el-icon-delete" @click="deleteReport"></el-button>
<el-button
v-show="buttonShow"
icon="el-icon-delete"
@click="deleteReport"
>删除</el-button
>
<!-- 删除弹出框 -->
<el-dialog
title="删除"
@ -16,7 +23,9 @@
width="36.5%"
center
>
<el-button type="primary" size="small" @click="handleDelete"></el-button>
<el-button type="primary" size="small" @click="handleDelete"
>删除</el-button
>
<el-table
:data="reportData.data"
border
@ -24,20 +33,44 @@
@selection-change="reportSelectionChange"
>
<el-table-column type="selection" align="center" />
<el-table-column label="序号" type="index" align="center" width="50" />
<el-table-column prop="fileName" label="报告名称" align="center" width="350" />
<el-table-column prop="createTime" label="创建时间" align="center" width="200" />
<el-table-column
label="序号"
type="index"
align="center"
width="50"
/>
<el-table-column
prop="fileName"
label="报告名称"
align="center"
width="350"
/>
<el-table-column
prop="createTime"
label="创建时间"
align="center"
width="200"
/>
</el-table>
</el-dialog>
<!--导入弹出框 -->
<el-dialog title="导入" :visible.sync="isShow" style="width: 100%" @close="downWindows">
<el-dialog
title="导入"
:visible.sync="isShow"
style="width: 100%"
@close="downWindows"
>
<div class="uploadBox">
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col :span="6">
<div>
<el-form-item label="设备名称">
<el-select v-model="equId2" placeholder="请选择设备名称">
<el-form-item label="设备间隔">
<el-select
v-model="equId2"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -46,6 +79,19 @@
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="6">
<div>
<el-form-item label="设备名称">
<el-select v-model="stId2" placeholder="请选择设备名称">
<el-option
v-for="item in equThirdNameList"
:key="item.stId"
:label="item.stName"
:value="item.stId"
/>
</el-select>
</el-form-item>
</div>
</el-col>
</el-row>
@ -74,7 +120,8 @@
type="primary"
icon="el-icon-plus"
plain
>报告选择</el-button>
>报告选择</el-button
>
<div slot="tip" class="el-upload__tip">只能上传xlsx/xls文件</div>
</el-upload>
</div>
@ -102,7 +149,8 @@
type="primary"
icon="el-icon-plus"
plain
>附件选择已选择{{ fileList.length }}</el-button>
>附件选择已选择{{ fileList.length }}</el-button
>
</el-upload>
</div>
<span slot="footer" class="dialog-footer">
@ -118,9 +166,12 @@
icon="el-icon-upload"
plain
@click="submitUpload()"
>将选择文件上传服务器</el-button>
>将选择文件上传服务器</el-button
>
</span>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"></el-button>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"
>关闭</el-button
>
<!-- <file-preview v-show="Showexcel" :file-type="fileType" :excel-pv-props="excelPvProps" />
<img v-show="Showimg" :src="srcOthers" alt width="300px" height="300px">
<pdf v-for="i in numPages" v-show="Showpdf" :key="i" :src="src" :page="i" /> -->
@ -134,10 +185,15 @@
</el-dialog>
</div>
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap;">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col v-show="excelShow" :span="6">
<el-form-item label="设备间隔">
<el-select v-model="equId" clearable placeholder="请选择设备间隔" @change="equIdChange">
<el-select
v-model="equId"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -227,8 +283,12 @@
</el-col>
<el-col :span="searchLeft">
<div class="searchButton">
<el-button icon="el-icon-search" @click="onSeacherClick"></el-button>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"></el-button>
<el-button icon="el-icon-search" @click="onSeacherClick"
>查询</el-button
>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"
>重置</el-button
>
</div>
</el-col>
</el-row>
@ -238,8 +298,8 @@
</template>
<script>
// import FilePreview from '@mrhanson/vue-file-preview'
import pdf from 'vue-pdf'
import Storage from '@/commons/storage'
import pdf from "vue-pdf";
import Storage from "@/commons/storage";
import {
importReport,
downloadExcel,
@ -248,68 +308,69 @@ import {
getFirstExcelList,
deviceSubclassList,
testItemList,
} from '@/api/user'
var mytoken = Storage.get(Storage.KEYS.TOKEN)
} from "@/api/user";
var mytoken = Storage.get(Storage.KEYS.TOKEN);
export default {
components: {
// 'file-preview': FilePreview,
pdf: pdf
pdf: pdf,
},
props: {
deleteShow: Boolean,
excelShow: Boolean,
buttonShow: Boolean,
reportData: Object
reportData: Object,
},
data() {
return {
sheetName: '',
stId: '',
equId: '',
equId2: '',
timeData: '',
testItem: '',
offlineParam: '',
deleted: '',
sheetName: "",
stId: "",
stId2: "",
equId: "",
equId2: "",
timeData: "",
testItem: "",
offlineParam: "",
deleted: "",
pickerOptions: {
shortcuts: [
{
text: '最近一个月',
text: "最近一个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近三个月',
text: "最近三个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近半年',
text: "最近半年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近一年',
text: "最近一年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
picker.$emit('pick', [start, end])
}
}
]
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
picker.$emit("pick", [start, end]);
},
},
],
},
equNameList: [],
deviceSubclassList: [],
@ -326,28 +387,28 @@ export default {
Showword: false,
ShowVideo: false,
preview: false,
fileType: 'excel',
fileType: "excel",
excelPvProps: {
file: null,
isClientStream: true,
tableHeight: 500
tableHeight: 500,
},
srcOthers: '',
src: '',
srcOthers: "",
src: "",
numPages: undefined,
upload: '', //
upload: "", //
uploadData: null,
headers: { token: mytoken },
paramsArrester: {
equType: '',
equType: "",
limit: 10,
page: 1,
equLittleId: '',
testItem: '',
offlineParam: ''
equLittleId: "",
testItem: "",
offlineParam: "",
},
equThirdNameList: [],
experimentData: []
experimentData: [],
// vHtml: '',
// playerOptions: {
// playbackRates: [0.5, 1.0, 1.5, 2.0],//
@ -372,14 +433,14 @@ export default {
// fullscreenToggle: true,//
// },
// },
}
};
},
computed: {
searchLeft() {
let valSpan = 6
this.excelShow ? valSpan = 6 : valSpan = 24
return valSpan
}
let valSpan = 6;
this.excelShow ? (valSpan = 6) : (valSpan = 24);
return valSpan;
},
},
created() {
this.getEquNameList();
@ -404,45 +465,47 @@ export default {
});
},
arresterExperimentListData() {
this.paramsArrester.equType = 4
this.paramsArrester.equType = 4;
getFirstExcelList(this.paramsArrester).then((res) => {
if (res.code == 0 && res.data) {
this.experimentData = res.data
this.experimentData = res.data;
}
})
});
},
//
getEquNameList() {
const equType = 4
const equType = 4;
getEquNameList(equType).then((res) => {
if (res.code == 0 && res.data) {
this.equNameList = res.data
this.equNameList = res.data;
}
})
});
},
equIdChange() {
const equType = 4
getThirdEquNameList(equType, this.equId).then((res) => {
const equType = 4;
const paramId = this.equId2 || this.equId;
console.log(this.equId);
getThirdEquNameList(equType, paramId).then((res) => {
if (res.code == 0 && res.data) {
this.equThirdNameList = res.data
this.equThirdNameList = res.data;
}
})
});
},
handleDelete() {
this.$emit('handleDelete')
this.$emit("handleDelete");
},
onResetBtnClick() {
this.equId = ''
this.timeData = ''
this.sheetName = ''
this.stId = ''
this.testItem = ''
this.offlineParam = ''
this.deleted = ''
this.equId = "";
this.timeData = "";
this.sheetName = "";
this.stId = "";
this.testItem = "";
this.offlineParam = "";
this.deleted = "";
},
onSeacherClick() {
this.$emit(
'onSeacherClick',
"onSeacherClick",
this.equId,
this.stId,
this.sheetName,
@ -450,13 +513,13 @@ export default {
this.testItem,
this.offlineParam,
this.deleted
)
);
},
deleteReport() {
this.$emit('deleteReport', true)
this.$emit("deleteReport", true);
},
handleClose() {
this.$emit('deleteReport', false)
this.$emit("deleteReport", false);
},
// //
// handleReportChange(files, reportList) {
@ -469,56 +532,56 @@ export default {
// },
//
handleReportRemove(file, reportList) {
this.reportList = reportList
this.reportList = reportList;
// this.fileList = undefined
// this.fileList = new Array()
},
//
handleChange(files, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handleChangeReport(files, reportList) {
// this.reportList = reportList
this.reportList = reportList
this.reportList = reportList;
if (reportList.length > 1) {
reportList.splice(0, 1)
reportList.splice(0, 1);
}
},
//
handleRemove(file, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handlePreview(file, fileList) {
// console.log(file)
const types = file.name.split('.')[1]
const fileType1 = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(
const types = file.name.split(".")[1];
const fileType1 = ["xlsx", "xlc", "xlm", "xls", "xlt", "xlw", "csv"].some(
(item) => item === types
)
const fileType2 = ['svg', 'png', 'jpg', 'jpeg'].some(
);
const fileType2 = ["svg", "png", "jpg", "jpeg"].some(
(item) => item === types
)
);
// let fileType3 = ['doc','docx','docm','dotm','dotx','dot'].some(item => item === types)
const fileType4 = ['pdf'].some((item) => item === types)
const fileType4 = ["pdf"].some((item) => item === types);
// let fileType5 = ['mp4'].some(item => item === types)
if (fileType1) {
console.log(file.raw)
this.excelPvProps.file = file.raw
console.log(this.excelPvProps.file)
this.ShowPreview = true
this.Showexcel = true
console.log(file.raw);
this.excelPvProps.file = file.raw;
console.log(this.excelPvProps.file);
this.ShowPreview = true;
this.Showexcel = true;
} else if (fileType2) {
const reader = new FileReader()
const _this = this
reader.readAsDataURL(file.raw)
const reader = new FileReader();
const _this = this;
reader.readAsDataURL(file.raw);
reader.onloadend = function () {
_this.srcOthers = this.result
_this.ShowPreview = true
_this.Showimg = true
}
_this.srcOthers = this.result;
_this.ShowPreview = true;
_this.Showimg = true;
};
// }else if(fileType3){
// let _this = this
// let reader = new FileReader()
@ -532,14 +595,14 @@ export default {
// }).done()
// }
} else if (fileType4) {
const pdfurl = URL.createObjectURL(file.raw)
const loadingTask = pdf.createLoadingTask(pdfurl)
this.src = loadingTask
const pdfurl = URL.createObjectURL(file.raw);
const loadingTask = pdf.createLoadingTask(pdfurl);
this.src = loadingTask;
this.src.promise.then((pdf) => {
this.numPages = pdf.numPages
})
this.ShowPreview = true
this.Showpdf = true
this.numPages = pdf.numPages;
});
this.ShowPreview = true;
this.Showpdf = true;
// }else if(fileType5){
// let url = null ;
// if (window.createObjectURL!=undefined) { // basic
@ -556,113 +619,116 @@ export default {
// console.log(url)
} else {
this.$message({
message: '暂不支持该类型文件预览',
type: 'warning'
})
message: "暂不支持该类型文件预览",
type: "warning",
});
}
},
close() {
this.ShowPreview = false
this.Showexcel = false
this.Showimg = false
this.Showpdf = false
this.Showword = false
this.ShowVideo = false
this.ShowPreview = false;
this.Showexcel = false;
this.Showimg = false;
this.Showpdf = false;
this.Showword = false;
this.ShowVideo = false;
},
importFile() {
if (
this.$refs.upload.$el.children[0].children[1].value == '' ||
this.$refs.upload2.$el.children[0].children[1].value == ''
this.$refs.upload.$el.children[0].children[1].value == "" ||
this.$refs.upload2.$el.children[0].children[1].value == ""
) {
this.$message({
message: '报告和附件不能为空',
type: 'warning'
})
message: "报告和附件不能为空",
type: "warning",
});
}
this.$refs.upload.submit()
this.$refs.upload2.submit()
const formData = new FormData()
this.$refs.upload.submit();
this.$refs.upload2.submit();
const formData = new FormData();
this.fileList.forEach((item) => {
formData.append('files', item.raw)
})
formData.append("files", item.raw);
});
this.reportList.forEach((item) => {
formData.append('file', item.raw)
})
formData.append('eqType', 4)
formData.append('equipmentId', this.equId2)
formData.append('jgId', '')
formData.append("file", item.raw);
});
formData.append("eqType", 4);
// formData.append("equipmentId", this.equId2);
formData.append("equipmentId", this.stId2);
formData.append("jgId", this.equId2);
// formData.append("jgId", "");
importReport(formData).then((res) => {
if (res.code == 0) {
this.$message.success('文件上传成功!')
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.$message.success("文件上传成功!");
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
} else {
this.$message.warning('文件上传失败!')
this.$message.warning("文件上传失败!");
}
})
});
},
//
submitUpload() {
const name = this.reportList[0].name
let status = 0
const name = this.reportList[0].name;
let status = 0;
if (this.experimentData.length != 0) {
for (let index = 0; index < this.experimentData.length; index++) {
const element = this.experimentData[index].fileName
const element = this.experimentData[index].fileName;
if (element === name) {
this.$confirm('此报告已存在是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("此报告已存在是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.importFile()
return
this.importFile();
return;
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消导入'
})
return
})
type: "info",
message: "已取消导入",
});
return;
});
} else {
status = status + 1
status = status + 1;
}
}
if (status === this.experimentData.length) {
this.importFile()
this.importFile();
}
} else {
this.importFile()
this.importFile();
}
},
downWindows() {
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.fileList = []
this.reportList = []
this.$router.replace({ path: '/refresh' })
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
this.fileList = [];
this.reportList = [];
this.$router.replace({ path: "/refresh" });
},
onImportClick() {
this.equId2 = ''
this.isShow = true
this.arresterExperimentListData()
this.equId2 = "";
this.stId2 = "";
this.isShow = true;
this.arresterExperimentListData();
},
//
onDownloadClick() {
const token = Storage.get(Storage.KEYS.TOKEN)
const equType = 4
const params = '?token=' + token + '&equType=' + equType
downloadExcel(params)
const token = Storage.get(Storage.KEYS.TOKEN);
const equType = 4;
const params = "?token=" + token + "&equType=" + equType;
downloadExcel(params);
},
reportSelectionChange(val) {
this.$emit('reportSelectionChange', val)
}
}
}
this.$emit("reportSelectionChange", val);
},
},
};
</script>
<style lang="scss" scoped>
@import '~@/assets/stylesheet/index';
@import "~@/assets/stylesheet/index";
/deep/ .el-dialog__headerbtn {
background: none !important;
color: #909399 !important;
@ -693,4 +759,3 @@ export default {
margin-bottom: 10px;
}
</style>

@ -2,12 +2,19 @@
<div class="transformer">
<div class="choose chooseInputColor">
<div class="button" style="margin-bottom: 10px">
<el-button icon="el-icon-upload2" @click="onImportClick"></el-button>
<el-button icon="el-icon-upload2" @click="onImportClick"
>导入</el-button
>
<!-- <el-button
icon="el-icon-download"
@click="onDownloadClick"
>下载模板</el-button>-->
<el-button v-show="buttonShow" icon="el-icon-delete" @click="deleteReport"></el-button>
<el-button
v-show="buttonShow"
icon="el-icon-delete"
@click="deleteReport"
>删除</el-button
>
<!-- 删除弹出框 -->
<el-dialog
title="删除"
@ -16,7 +23,9 @@
width="36.5%"
center
>
<el-button type="primary" size="small" @click="handleDelete"></el-button>
<el-button type="primary" size="small" @click="handleDelete"
>删除</el-button
>
<el-table
:data="reportData.data"
border
@ -24,19 +33,44 @@
@selection-change="reportSelectionChange"
>
<el-table-column type="selection" align="center" />
<el-table-column label="序号" type="index" align="center" width="50" />
<el-table-column prop="fileName" label="报告名称" align="center" width="350" />
<el-table-column prop="createTime" label="创建时间" align="center" width="200" />
<el-table-column
label="序号"
type="index"
align="center"
width="50"
/>
<el-table-column
prop="fileName"
label="报告名称"
align="center"
width="350"
/>
<el-table-column
prop="createTime"
label="创建时间"
align="center"
width="200"
/>
</el-table>
</el-dialog>
<!--导入弹出框 -->
<el-dialog title="导入" :visible.sync="isShow" style="width: 100%" @close="downWindows">
<el-dialog
title="导入"
:visible.sync="isShow"
style="width: 100%"
@close="downWindows"
>
<div class="uploadBox">
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap;">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col :span="6">
<el-form-item label="设备间隔">
<el-select v-model="equId2" clearable placeholder="请选择设备间隔" @change="equIdChange">
<el-select
v-model="equId2"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -85,7 +119,8 @@
type="primary"
icon="el-icon-plus"
plain
>报告选择</el-button>
>报告选择</el-button
>
<div slot="tip" class="el-upload__tip">只能上传xlsx/xls文件</div>
</el-upload>
</div>
@ -113,7 +148,8 @@
type="primary"
icon="el-icon-plus"
plain
>附件选择已选择{{ fileList.length }}</el-button>
>附件选择已选择{{ fileList.length }}</el-button
>
</el-upload>
</div>
<span slot="footer" class="dialog-footer">
@ -129,9 +165,12 @@
icon="el-icon-upload"
plain
@click="submitUpload()"
>将选择文件上传服务器</el-button>
>将选择文件上传服务器</el-button
>
</span>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"></el-button>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"
>关闭</el-button
>
<!-- <file-preview v-show="Showexcel" :file-type="fileType" :excel-pv-props="excelPvProps" />
<img v-show="Showimg" :src="srcOthers" alt width="300px" height="300px">
<pdf v-for="i in numPages" v-show="Showpdf" :key="i" :src="src" :page="i" />
@ -145,10 +184,15 @@
</el-dialog>
</div>
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap;">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col v-if="excelShow" :span="6">
<el-form-item label="设备间隔">
<el-select v-model="equId" clearable placeholder="请选择设备间隔" @change="equIdChange">
<el-select
v-model="equId"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -230,8 +274,12 @@
</el-col>
<el-col :span="searchLeft">
<div class="searchButton">
<el-button icon="el-icon-search" @click="onSeacherClick"></el-button>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"></el-button>
<el-button icon="el-icon-search" @click="onSeacherClick"
>查询</el-button
>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"
>重置</el-button
>
</div>
</el-col>
</el-row>
@ -241,8 +289,8 @@
</template>
<script>
// import FilePreview from '@mrhanson/vue-file-preview'
import pdf from 'vue-pdf'
import Storage from '@/commons/storage'
import pdf from "vue-pdf";
import Storage from "@/commons/storage";
import {
importReport,
getEquNameList,
@ -251,30 +299,30 @@ import {
getFirstExcelList,
deviceSubclassList,
testItemList,
} from '@/api/user'
var mytoken = Storage.get(Storage.KEYS.TOKEN)
} from "@/api/user";
var mytoken = Storage.get(Storage.KEYS.TOKEN);
export default {
components: {
// 'file-preview': FilePreview,
pdf: pdf
pdf: pdf,
},
props: {
deleteShow: Boolean,
excelShow: Boolean,
buttonShow: Boolean,
reportData: Object
reportData: Object,
},
data() {
return {
sheetName: '',
stId: '',
stId2: '',
timeData: '',
equId: '',
equId2: '',
testItem: '',
offlineParam: '',
deleted: '',
sheetName: "",
stId: "",
stId2: "",
timeData: "",
equId: "",
equId2: "",
testItem: "",
offlineParam: "",
deleted: "",
equNameList: [],
deviceSubclassList: [],
testItemList: [],
@ -282,42 +330,42 @@ export default {
pickerOptions: {
shortcuts: [
{
text: '最近一个月',
text: "最近一个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近三个月',
text: "最近三个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近半年',
text: "最近半年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近一年',
text: "最近一年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
picker.$emit('pick', [start, end])
}
}
]
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
picker.$emit("pick", [start, end]);
},
},
],
},
GisData: [], //
//
@ -332,27 +380,27 @@ export default {
Showword: false,
ShowVideo: false,
preview: false,
fileType: 'excel',
fileType: "excel",
excelPvProps: {
file: null,
isClientStream: true,
tableHeight: 500
tableHeight: 500,
},
srcOthers: '',
src: '',
srcOthers: "",
src: "",
numPages: undefined,
upload: '', //
upload: "", //
uploadData: null,
headers: { token: mytoken },
paramsTransformer: {
equType: '',
equType: "",
limit: 10,
page: 1,
equLittleId: '',
testItem: '',
offlineParam: ''
equLittleId: "",
testItem: "",
offlineParam: "",
},
experimentData: []
experimentData: [],
// vHtml: '',
// playerOptions: {
// playbackRates: [0.5, 1.0, 1.5, 2.0],//
@ -377,14 +425,14 @@ export default {
// fullscreenToggle: true,//
// },
// },
}
};
},
computed: {
searchLeft() {
let valSpan = 6
this.excelShow ? valSpan = 6 : valSpan = 24
return valSpan
}
let valSpan = 6;
this.excelShow ? (valSpan = 6) : (valSpan = 24);
return valSpan;
},
},
created() {
this.getEquNameList();
@ -409,45 +457,48 @@ export default {
});
},
onResetBtnClick() {
this.equId = ''
this.sheetName = ''
this.timeData = ''
this.stId = ''
this.testItem = ''
this.offlineParam = ''
this.deleted = ''
this.equId = "";
this.sheetName = "";
this.timeData = "";
this.stId = "";
this.testItem = "";
this.offlineParam = "";
this.deleted = "";
},
handleDelete() {
this.$emit('handleDelete')
this.$emit("handleDelete");
},
GisExperimentListData() {
this.paramsTransformer.equType = 2
this.paramsTransformer.equType = 2;
getFirstExcelList(this.paramsTransformer).then((res) => {
if (res.code == 0 && res.data) {
this.experimentData = res.data
this.experimentData = res.data;
}
})
});
},
//
getEquNameList() {
const equType = 2
const equType = 2;
getEquNameList(equType).then((res) => {
if (res.code == 0 && res.data) {
this.equNameList = res.data
this.equNameList = res.data;
}
})
});
},
equIdChange() {
const equType = 2
getThirdEquNameList(equType, this.equId2).then((res) => {
console.log("aaaaaaaaaa");
const paramId = this.equId2 || this.equId;
console.log(this.equId);
const equType = 2;
getThirdEquNameList(equType, paramId).then((res) => {
if (res.code == 0 && res.data) {
this.equThirdNameList = res.data
this.equThirdNameList = res.data;
}
})
});
},
onSeacherClick() {
this.$emit(
'onSeacherClick',
"onSeacherClick",
this.equId,
this.stId,
this.sheetName,
@ -455,63 +506,63 @@ export default {
this.testItem,
this.offlineParam,
this.deleted
)
);
},
// onDeleteBtnClick(){
// this.$emit('onDeleteBtnClick', this.transformerName,this.timeData)
// },
deleteReport() {
this.$emit('deleteReport', true)
this.$emit("deleteReport", true);
},
handleClose() {
this.$emit('deleteReport', false)
this.$emit("deleteReport", false);
},
//
handleReportChange(files, reportList) {
this.reportList = reportList
this.reportList = reportList;
if (reportList.length > 1) {
reportList.splice(0, 1)
reportList.splice(0, 1);
}
},
//
handleReportRemove(file, reportList) {
this.reportList = reportList
this.reportList = reportList;
},
//
handleChange(files, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handleRemove(file, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handlePreview(file, fileList) {
// console.log(file)
const types = file.name.split('.')[1]
const fileType1 = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(
const types = file.name.split(".")[1];
const fileType1 = ["xlsx", "xlc", "xlm", "xls", "xlt", "xlw", "csv"].some(
(item) => item === types
)
const fileType2 = ['svg', 'png', 'jpg', 'jpeg'].some(
);
const fileType2 = ["svg", "png", "jpg", "jpeg"].some(
(item) => item === types
)
);
// let fileType3 = ['doc','docx','docm','dotm','dotx','dot'].some(item => item === types)
const fileType4 = ['pdf'].some((item) => item === types)
const fileType4 = ["pdf"].some((item) => item === types);
// let fileType5 = ['mp4'].some(item => item === types)
if (fileType1) {
this.excelPvProps.file = file.raw
this.ShowPreview = true
this.Showexcel = true
this.excelPvProps.file = file.raw;
this.ShowPreview = true;
this.Showexcel = true;
} else if (fileType2) {
const reader = new FileReader()
const _this = this
reader.readAsDataURL(file.raw)
const reader = new FileReader();
const _this = this;
reader.readAsDataURL(file.raw);
reader.onloadend = function () {
_this.srcOthers = this.result
_this.ShowPreview = true
_this.Showimg = true
}
_this.srcOthers = this.result;
_this.ShowPreview = true;
_this.Showimg = true;
};
// }else if(fileType3){
// let _this = this
// let reader = new FileReader()
@ -525,14 +576,14 @@ export default {
// }).done()
// }
} else if (fileType4) {
const pdfurl = URL.createObjectURL(file.raw)
const loadingTask = pdf.createLoadingTask(pdfurl)
this.src = loadingTask
const pdfurl = URL.createObjectURL(file.raw);
const loadingTask = pdf.createLoadingTask(pdfurl);
this.src = loadingTask;
this.src.promise.then((pdf) => {
this.numPages = pdf.numPages
})
this.ShowPreview = true
this.Showpdf = true
this.numPages = pdf.numPages;
});
this.ShowPreview = true;
this.Showpdf = true;
// }else if(fileType5){
// let url = null ;
// if (window.createObjectURL!=undefined) { // basic
@ -549,84 +600,84 @@ export default {
// console.log(url)
} else {
this.$message({
message: '暂不支持该类型文件预览',
type: 'warning'
})
message: "暂不支持该类型文件预览",
type: "warning",
});
}
},
close() {
this.ShowPreview = false
this.Showexcel = false
this.Showimg = false
this.Showpdf = false
this.Showword = false
this.ShowVideo = false
this.ShowPreview = false;
this.Showexcel = false;
this.Showimg = false;
this.Showpdf = false;
this.Showword = false;
this.ShowVideo = false;
},
importFile() {
if (
this.$refs.upload.$el.children[0].children[1].value == '' ||
this.$refs.upload2.$el.children[0].children[1].value == ''
this.$refs.upload.$el.children[0].children[1].value == "" ||
this.$refs.upload2.$el.children[0].children[1].value == ""
) {
this.$message({
message: '报告和附件不能为空',
type: 'warning'
})
message: "报告和附件不能为空",
type: "warning",
});
}
this.$refs.upload.submit()
this.$refs.upload2.submit()
const formData = new FormData()
this.$refs.upload.submit();
this.$refs.upload2.submit();
const formData = new FormData();
this.fileList.forEach((item) => {
formData.append('files', item.raw)
})
formData.append("files", item.raw);
});
this.reportList.forEach((item) => {
formData.append('file', item.raw)
})
formData.append('eqType', 2)
formData.append('equipmentId', this.stId2)
formData.append('jgId', this.equId2)
formData.append("file", item.raw);
});
formData.append("eqType", 2);
formData.append("equipmentId", this.stId2);
formData.append("jgId", this.equId2);
importReport(formData).then((res) => {
if (res.code == 0) {
this.$message.success('文件上传成功!')
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.$message.success("文件上传成功!");
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
} else {
this.$message.warning('文件上传失败!')
this.$message.warning("文件上传失败!");
}
})
});
},
//
submitUpload() {
const name = this.reportList[0].name
let status = 0
const name = this.reportList[0].name;
let status = 0;
if (this.experimentData.length != 0) {
for (let index = 0; index < this.experimentData.length; index++) {
const element = this.experimentData[index].fileName
const element = this.experimentData[index].fileName;
if (element === name) {
this.$confirm('此报告已存在是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("此报告已存在是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.importFile()
return
this.importFile();
return;
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消导入'
})
return
})
type: "info",
message: "已取消导入",
});
return;
});
} else {
status = status + 1
status = status + 1;
}
}
if (status === this.experimentData.length) {
this.importFile()
this.importFile();
}
} else {
this.importFile()
this.importFile();
}
},
// beforeUpload (file) {
@ -639,36 +690,36 @@ export default {
// return promise; //promis
// },
downWindows() {
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.fileList = []
this.reportList = []
this.$router.replace({ path: '/refresh' })
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
this.fileList = [];
this.reportList = [];
this.$router.replace({ path: "/refresh" });
},
onImportClick() {
this.equId2 = ''
this.stId2 = ''
this.isShow = true
this.GisExperimentListData()
this.equId2 = "";
this.stId2 = "";
this.isShow = true;
this.GisExperimentListData();
},
//
onDownloadClick() {
const token = Storage.get(Storage.KEYS.TOKEN)
const equType = 2
const params = '?token=' + token + '&equType=' + equType
downloadExcel(params)
const token = Storage.get(Storage.KEYS.TOKEN);
const equType = 2;
const params = "?token=" + token + "&equType=" + equType;
downloadExcel(params);
},
GisSelectionChange(val) {
this.$emit('GisSelectionChange', val)
this.$emit("GisSelectionChange", val);
},
reportSelectionChange(val) {
this.$emit('reportSelectionChange', val)
}
}
}
this.$emit("reportSelectionChange", val);
},
},
};
</script>
<style lang="scss" scoped>
@import '~@/assets/stylesheet/index';
@import "~@/assets/stylesheet/index";
/deep/ .el-dialog__headerbtn {
background: none !important;
color: #909399 !important;

@ -2,12 +2,19 @@
<div class="transformer">
<div class="choose chooseInputColor">
<div class="button" style="margin-bottom: 10px">
<el-button icon="el-icon-upload2" @click="onImportClick"></el-button>
<el-button icon="el-icon-upload2" @click="onImportClick"
>导入</el-button
>
<!-- <el-button
icon="el-icon-download"
@click="onDownloadClick"
>下载模板</el-button>-->
<el-button v-show="buttonShow" icon="el-icon-delete" @click="deleteReport"></el-button>
<el-button
v-show="buttonShow"
icon="el-icon-delete"
@click="deleteReport"
>删除</el-button
>
<!-- 删除弹出框 -->
<el-dialog
title="删除"
@ -16,7 +23,9 @@
width="36.5%"
center
>
<el-button type="primary" size="small" @click="handleDelete"></el-button>
<el-button type="primary" size="small" @click="handleDelete"
>删除</el-button
>
<el-table
:data="reportData.data"
border
@ -24,19 +33,44 @@
@selection-change="reportSelectionChange"
>
<el-table-column type="selection" align="center" />
<el-table-column label="序号" type="index" align="center" width="50" />
<el-table-column prop="fileName" label="报告名称" align="center" width="350" />
<el-table-column prop="createTime" label="创建时间" align="center" width="200" />
<el-table-column
label="序号"
type="index"
align="center"
width="50"
/>
<el-table-column
prop="fileName"
label="报告名称"
align="center"
width="350"
/>
<el-table-column
prop="createTime"
label="创建时间"
align="center"
width="200"
/>
</el-table>
</el-dialog>
<!--导入弹出框 -->
<el-dialog title="导入" :visible.sync="isShow" style="width: 100%" @close="downWindows">
<el-dialog
title="导入"
:visible.sync="isShow"
style="width: 100%"
@close="downWindows"
>
<div class="uploadBox">
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap;">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col :span="6">
<el-form-item label="设备间隔">
<el-select v-model="equId2" clearable placeholder="请选择设备间隔" @change="equIdChange">
<el-select
v-model="equId2"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -84,7 +118,8 @@
type="primary"
icon="el-icon-plus"
plain
>报告选择</el-button>
>报告选择</el-button
>
<div slot="tip" class="el-upload__tip">只能上传xlsx/xls文件</div>
</el-upload>
</div>
@ -112,7 +147,8 @@
type="primary"
icon="el-icon-plus"
plain
>附件选择已选择{{ fileList.length }}</el-button>
>附件选择已选择{{ fileList.length }}</el-button
>
</el-upload>
</div>
<span slot="footer" class="dialog-footer">
@ -128,9 +164,12 @@
icon="el-icon-upload"
plain
@click="submitUpload()"
>将选择文件上传服务器</el-button>
>将选择文件上传服务器</el-button
>
</span>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"></el-button>
<el-button v-show="ShowPreview" style="width: 60px" @click="close"
>关闭</el-button
>
<!-- <file-preview v-show="Showexcel" :file-type="fileType" :excel-pv-props="excelPvProps" />
<img v-show="Showimg" :src="srcOthers" alt width="300px" height="300px">
<pdf v-for="i in numPages" v-show="Showpdf" :key="i" :src="src" :page="i" /> -->
@ -144,10 +183,15 @@
</el-dialog>
</div>
<el-form label-width="80px!important" :inline="true">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap;">
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
<el-col v-show="excelShow" :span="6">
<el-form-item label="设备间隔">
<el-select v-model="equId" clearable placeholder="请选择设备间隔" @change="equIdChange">
<el-select
v-model="equId"
clearable
placeholder="请选择设备间隔"
@change="equIdChange"
>
<el-option
v-for="item in equNameList"
:key="item.equId"
@ -237,8 +281,12 @@
</el-col>
<el-col :span="searchLeft">
<div class="searchButton">
<el-button icon="el-icon-search" @click="onSeacherClick"></el-button>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"></el-button>
<el-button icon="el-icon-search" @click="onSeacherClick"
>查询</el-button
>
<el-button icon="el-icon-refresh-right" @click="onResetBtnClick"
>重置</el-button
>
</div>
</el-col>
</el-row>
@ -248,8 +296,8 @@
</template>
<script>
// import FilePreview from '@mrhanson/vue-file-preview'
import pdf from 'vue-pdf'
import Storage from '@/commons/storage'
import pdf from "vue-pdf";
import Storage from "@/commons/storage";
import {
importReport,
downloadExcel,
@ -258,69 +306,69 @@ import {
getFirstExcelList,
deviceSubclassList,
testItemList,
} from '@/api/user'
var mytoken = Storage.get(Storage.KEYS.TOKEN)
} from "@/api/user";
var mytoken = Storage.get(Storage.KEYS.TOKEN);
export default {
components: {
// 'file-preview': FilePreview,
pdf: pdf
pdf: pdf,
},
props: {
deleteShow: Boolean,
excelShow: Boolean,
buttonShow: Boolean,
reportData: Object
reportData: Object,
},
data() {
return {
sheetName: '',
stId: '',
equId: '',
stId2: '',
equId2: '',
timeData: '',
testItem: '',
offlineParam: '',
deleted: '',
sheetName: "",
stId: "",
equId: "",
stId2: "",
equId2: "",
timeData: "",
testItem: "",
offlineParam: "",
deleted: "",
pickerOptions: {
shortcuts: [
{
text: '最近一个月',
text: "最近一个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近三个月',
text: "最近三个月",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 91);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近半年',
text: "最近半年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183)
picker.$emit('pick', [start, end])
}
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 183);
picker.$emit("pick", [start, end]);
},
},
{
text: '最近一年',
text: "最近一年",
onClick(picker) {
const end = new Date()
const start = new Date()
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365)
picker.$emit('pick', [start, end])
}
}
]
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
picker.$emit("pick", [start, end]);
},
},
],
},
equNameList: [],
deviceSubclassList: [],
@ -337,28 +385,28 @@ export default {
Showword: false,
ShowVideo: false,
preview: false,
fileType: 'excel',
fileType: "excel",
excelPvProps: {
file: null,
isClientStream: true,
tableHeight: 500
tableHeight: 500,
},
srcOthers: '',
src: '',
srcOthers: "",
src: "",
numPages: undefined,
upload: '', //
upload: "", //
uploadData: null,
headers: { token: mytoken },
paramsArrester: {
equType: '',
equType: "",
limit: 10,
page: 1,
equLittleId: '',
testItem: '',
offlineParam: ''
equLittleId: "",
testItem: "",
offlineParam: "",
},
equThirdNameList: [],
experimentData: []
experimentData: [],
// vHtml: '',
// playerOptions: {
// playbackRates: [0.5, 1.0, 1.5, 2.0],//
@ -383,14 +431,14 @@ export default {
// fullscreenToggle: true,//
// },
// },
}
};
},
computed: {
searchLeft() {
let valSpan = 6
this.excelShow ? valSpan = 6 : valSpan = 24
return valSpan
}
let valSpan = 6;
this.excelShow ? (valSpan = 6) : (valSpan = 24);
return valSpan;
},
},
created() {
this.getEquNameList();
@ -415,45 +463,47 @@ export default {
});
},
arresterExperimentListData() {
this.paramsArrester.equType = 3
this.paramsArrester.equType = 3;
getFirstExcelList(this.paramsArrester).then((res) => {
if (res.code == 0 && res.data) {
this.experimentData = res.data
this.experimentData = res.data;
}
})
});
},
//
getEquNameList() {
const equType = 3
const equType = 3;
getEquNameList(equType).then((res) => {
if (res.code == 0 && res.data) {
this.equNameList = res.data
this.equNameList = res.data;
}
})
});
},
equIdChange() {
const equType = 3
getThirdEquNameList(equType, this.equId2).then((res) => {
const equType = 3;
const paramId = this.equId2 || this.equId;
console.log(this.equId);
getThirdEquNameList(equType, paramId).then((res) => {
if (res.code == 0 && res.data) {
this.equThirdNameList = res.data
this.equThirdNameList = res.data;
}
})
});
},
handleDelete() {
this.$emit('handleDelete')
this.$emit("handleDelete");
},
onResetBtnClick() {
this.equId = ''
this.sheetName = ''
this.timeData = ''
this.stId = ''
this.testItem = ''
this.offlineParam = ''
this.deleted = ''
this.equId = "";
this.sheetName = "";
this.timeData = "";
this.stId = "";
this.testItem = "";
this.offlineParam = "";
this.deleted = "";
},
onSeacherClick() {
this.$emit(
'onSeacherClick',
"onSeacherClick",
this.equId,
this.stId,
this.sheetName,
@ -461,13 +511,13 @@ export default {
this.testItem,
this.offlineParam,
this.deleted
)
);
},
deleteReport() {
this.$emit('deleteReport', true)
this.$emit("deleteReport", true);
},
handleClose() {
this.$emit('deleteReport', false)
this.$emit("deleteReport", false);
},
// //
// handleReportChange(files, reportList) {
@ -480,56 +530,56 @@ export default {
// },
//
handleReportRemove(file, reportList) {
this.reportList = reportList
this.reportList = reportList;
// this.fileList = undefined
// this.fileList = new Array()
},
//
handleChange(files, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handleChangeReport(files, reportList) {
// this.reportList = reportList
this.reportList = reportList
this.reportList = reportList;
if (reportList.length > 1) {
reportList.splice(0, 1)
reportList.splice(0, 1);
}
},
//
handleRemove(file, fileList) {
this.fileList = fileList
this.fileList = fileList;
},
//
handlePreview(file, fileList) {
// console.log(file)
const types = file.name.split('.')[1]
const fileType1 = ['xlsx', 'xlc', 'xlm', 'xls', 'xlt', 'xlw', 'csv'].some(
const types = file.name.split(".")[1];
const fileType1 = ["xlsx", "xlc", "xlm", "xls", "xlt", "xlw", "csv"].some(
(item) => item === types
)
const fileType2 = ['svg', 'png', 'jpg', 'jpeg'].some(
);
const fileType2 = ["svg", "png", "jpg", "jpeg"].some(
(item) => item === types
)
);
// let fileType3 = ['doc','docx','docm','dotm','dotx','dot'].some(item => item === types)
const fileType4 = ['pdf'].some((item) => item === types)
const fileType4 = ["pdf"].some((item) => item === types);
// let fileType5 = ['mp4'].some(item => item === types)
if (fileType1) {
console.log(file.raw)
this.excelPvProps.file = file.raw
console.log(this.excelPvProps.file)
this.ShowPreview = true
this.Showexcel = true
console.log(file.raw);
this.excelPvProps.file = file.raw;
console.log(this.excelPvProps.file);
this.ShowPreview = true;
this.Showexcel = true;
} else if (fileType2) {
const reader = new FileReader()
const _this = this
reader.readAsDataURL(file.raw)
const reader = new FileReader();
const _this = this;
reader.readAsDataURL(file.raw);
reader.onloadend = function () {
_this.srcOthers = this.result
_this.ShowPreview = true
_this.Showimg = true
}
_this.srcOthers = this.result;
_this.ShowPreview = true;
_this.Showimg = true;
};
// }else if(fileType3){
// let _this = this
// let reader = new FileReader()
@ -543,14 +593,14 @@ export default {
// }).done()
// }
} else if (fileType4) {
const pdfurl = URL.createObjectURL(file.raw)
const loadingTask = pdf.createLoadingTask(pdfurl)
this.src = loadingTask
const pdfurl = URL.createObjectURL(file.raw);
const loadingTask = pdf.createLoadingTask(pdfurl);
this.src = loadingTask;
this.src.promise.then((pdf) => {
this.numPages = pdf.numPages
})
this.ShowPreview = true
this.Showpdf = true
this.numPages = pdf.numPages;
});
this.ShowPreview = true;
this.Showpdf = true;
// }else if(fileType5){
// let url = null ;
// if (window.createObjectURL!=undefined) { // basic
@ -567,114 +617,114 @@ export default {
// console.log(url)
} else {
this.$message({
message: '暂不支持该类型文件预览',
type: 'warning'
})
message: "暂不支持该类型文件预览",
type: "warning",
});
}
},
close() {
this.ShowPreview = false
this.Showexcel = false
this.Showimg = false
this.Showpdf = false
this.Showword = false
this.ShowVideo = false
this.ShowPreview = false;
this.Showexcel = false;
this.Showimg = false;
this.Showpdf = false;
this.Showword = false;
this.ShowVideo = false;
},
importFile() {
if (
this.$refs.upload.$el.children[0].children[1].value == '' ||
this.$refs.upload2.$el.children[0].children[1].value == ''
this.$refs.upload.$el.children[0].children[1].value == "" ||
this.$refs.upload2.$el.children[0].children[1].value == ""
) {
this.$message({
message: '报告和附件不能为空',
type: 'warning'
})
message: "报告和附件不能为空",
type: "warning",
});
}
this.$refs.upload.submit()
this.$refs.upload2.submit()
const formData = new FormData()
this.$refs.upload.submit();
this.$refs.upload2.submit();
const formData = new FormData();
this.fileList.forEach((item) => {
formData.append('files', item.raw)
})
formData.append("files", item.raw);
});
this.reportList.forEach((item) => {
formData.append('file', item.raw)
})
formData.append('eqType', 3)
formData.append('equipmentId', this.stId2)
formData.append('jgId', this.equId2)
formData.append("file", item.raw);
});
formData.append("eqType", 3);
formData.append("equipmentId", this.stId2);
formData.append("jgId", this.equId2);
importReport(formData).then((res) => {
if (res.code == 0) {
this.$message.success('文件上传成功!')
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.$message.success("文件上传成功!");
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
} else {
this.$message.warning('文件上传失败!')
this.$message.warning("文件上传失败!");
}
})
});
},
//
submitUpload() {
const name = this.reportList[0].name
let status = 0
const name = this.reportList[0].name;
let status = 0;
if (this.experimentData.length != 0) {
for (let index = 0; index < this.experimentData.length; index++) {
const element = this.experimentData[index].fileName
const element = this.experimentData[index].fileName;
if (element === name) {
this.$confirm('此报告已存在是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
this.$confirm("此报告已存在是否继续?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
.then(() => {
this.importFile()
return
this.importFile();
return;
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消导入'
})
return
})
type: "info",
message: "已取消导入",
});
return;
});
} else {
status = status + 1
status = status + 1;
}
}
if (status === this.experimentData.length) {
this.importFile()
this.importFile();
}
} else {
this.importFile()
this.importFile();
}
},
downWindows() {
this.$refs.upload.clearFiles() //
this.$refs.upload2.clearFiles()
this.fileList = []
this.reportList = []
this.$router.replace({ path: '/refresh' })
this.$refs.upload.clearFiles(); //
this.$refs.upload2.clearFiles();
this.fileList = [];
this.reportList = [];
this.$router.replace({ path: "/refresh" });
},
onImportClick() {
this.equId2 = ''
this.stId2 = ''
this.isShow = true
this.arresterExperimentListData()
this.equId2 = "";
this.stId2 = "";
this.isShow = true;
this.arresterExperimentListData();
},
//
onDownloadClick() {
const token = Storage.get(Storage.KEYS.TOKEN)
const equType = 3
const params = '?token=' + token + '&equType=' + equType
downloadExcel(params)
const token = Storage.get(Storage.KEYS.TOKEN);
const equType = 3;
const params = "?token=" + token + "&equType=" + equType;
downloadExcel(params);
},
reportSelectionChange(val) {
this.$emit('reportSelectionChange', val)
}
}
}
this.$emit("reportSelectionChange", val);
},
},
};
</script>
<style lang="scss" scoped>
@import '~@/assets/stylesheet/index';
@import "~@/assets/stylesheet/index";
/deep/ .el-dialog__headerbtn {
background: none !important;
color: #909399 !important;
@ -705,4 +755,3 @@ export default {
margin-bottom: 10px;
}
</style>

@ -4,40 +4,40 @@
</div>
</template>
<script>
import { wiringDiagramControllerList } from '@/api/system'
import { wiringDiagramControllerList } from "@/api/system";
export default {
name: 'PDFPreview',
name: "PDFPreview",
data() {
return {
filePdfUrl: '',
url: ''
}
filePdfUrl: "",
url: "",
};
},
created() {
this.getPdfFile()
this.getPdfFile();
},
methods: {
async getPdfFile() {
const params = {
endDate: '',
fileName: '',
endDate: "",
fileName: "",
limit: 10,
page: 1,
startDate: ''
}
startDate: "",
};
await wiringDiagramControllerList(params).then((res) => {
if (res.code === 0 && res.data && res.data.length != 0) {
this.filePdfUrl = res.data[0].filePath
this.filePdfUrl = res.data[0].filePath;
}
if (res.code === 0 && res.data && res.data.length == 0) {
this.$message({ type: 'error', message: '还没有上传过PDF文件' })
}
})
this.url = this.CONSTANT.PDF_PREVIEW_URL + this.filePdfUrl
}
}
this.$message({ type: "error", message: "还没有上传过PDF文件" });
}
});
this.url = this.CONSTANT.PDF_PREVIEW_URL + this.filePdfUrl;
},
},
};
</script>
<style lang="scss" scoped>
.pdfBox {

Loading…
Cancel
Save