jinhui.wang

pre-mde配舱页面增加

import request from '@/utils/request'
import axios from 'axios';
import settings from "@/settings"
import { getToken } from '@/utils/auth'
//模板下载
export function downLoadTemplate(template) {
return request({
url: '/flightInfoImport/downLoadTemplate?template=' + template,
method: 'get',
responseType: 'blob',
})
}
//航班目的地批量导入
/**
* @param file * 文件
* @param beginDate * 时间
*/
export function importFlightDestination(file, date) {
let formData = new FormData();
formData.append("file", file);
formData.append("beginDate", date);
return axios({
method: 'post',
url: settings.baseURL + '/flightDestination/importFlightDestination',
headers: { 'Authorization': 'Bearer ' + getToken() },
data: formData
})
// return request({
// url: '/flightDestination/importFlightDestination',
// method: 'post',
// data: formData
// })
}
//URSA目的地批量导入
/**
* @param file * 文件
* @param beginDate * 时间
*/
export function importUrsaDestination(file, date) {
let formData = new FormData();
formData.append("file", file);
formData.append("beginDate", date);
return axios({
method: 'post',
url: settings.baseURL + '/ursaDestination/importUrsaDestination',
headers: { 'Authorization': 'Bearer ' + getToken() },
data: formData
})
// return request({
// url: '/ursaDestination/importUrsaDestination',
// method: 'post',
// data: formData
// })
}
//航班目的地查询
/**
* @param page * 页数
* @param size * 长度
* @param area 地区
* @param fltNo 航班号
*/
export function searchFlightDestination(data) {
return request({
url: '/flightDestination/searchFlightDestination',
method: 'post',
data: data
})
}
//URSA目的地查询
/**
* @param page * 页数
* @param size * 长度
* @param area 地区
* @param ursa ursa list
*/
export function searchUrsaDestination(data) {
return request({
url: '/ursaDestination/searchUrsaDestination',
method: 'post',
data: data
})
}
\ No newline at end of file
<template>
<div style="margin: 20px">
<el-form ref="selectForm" :model="formData" class="form-header" label-position="right" label-width="auto"
size="small">
<el-row>
<el-col :span="6">
<el-form-item label="航班号">
<el-input type="text" v-model="formData.fltNo" placeholder="请输入航班号"></el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="地区">
<el-input type="text" v-model="formData.area" placeholder="请输入地区"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="20">
<el-row>
<el-col :span="6">
<el-form-item label="生效日期" prop="beginDate" :rules="rules">
<el-date-picker class="formItem" v-model="formData.beginDate" type="date"
placeholder="选择日期" value-format="yyyy-MM-dd" clearable>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-upload action="/flightInfoImport/importFlight" name="file" :http-request="uploadExcel"
:on-remove="handleRemove" :limit="1" :on-exceed="handleExceed" :file-list="fileList"
accept=".xlsx" class="upload-demo" v-hasPermi="['base:flightImport:importFlight']"
:disabled="formData.beginDate==null">
<el-button type="primary" icon="el-icon-upload2" size="small" @click="upload">导入Excel
</el-button>
</el-upload>
</el-col>
</el-row>
</el-col>
</el-row>
</el-form>
<div style="width:100%;display: flex;margin-bottom:10px">
<el-button type="primary" size="small" icon="el-icon-search" :loading="tableLoading" @click="selection(1)">
查询</el-button>
<el-button type="primary" icon="el-icon-download" size="small" @click="downloadTempleate"
v-hasPermi="['base:flightImport:exportExcel']">
下载模板
</el-button>
</div>
<Tables ref="flightToArea" ductName="flightToArea" :selection="false" :selectFixed="false" :order='true'
:height="tableHeight" :data="tableData" :headerData="tableHeaders" :page="formData.page" :pageSizes="[20]"
:totalCount="total" :loading="tableLoading" @currentChange="currentChange"
layout="total,prev, pager, next, jumper, ->">
</Tables>
</div>
</template>
<script>
import {
downLoadTemplate,
importFlightDestination,
searchFlightDestination
} from "@/api/preMdeConfig";
export default {
name: "FlightToArea",
data() {
return {
formData: {
fltNo: null,
area: null,
beginDate: null,
page: 1,
},
tableData: [],
errorData: [],
tableHeaders: this.tableHeaders['flightToArea'],
tableHeight: null,
total: 0,
flightType: [],
form: {
type: "",
region: "",
},
rules: {
validator: (rule, value, callback) => {
if (this.formData.beginDate == null) {
callback(new Error('上传前请选择生效时间'))
}
},
trigger: 'change'
},
fileList: [],
tableLoading: false,
};
},
created() {
},
mounted() {
this.tableHeight = window.innerHeight - this.$refs.selectForm.$el.offsetHeight - 170
this.selection(1)
},
activated() {
},
methods: {
selection(val) {
this.tableData = []
this.tableLoading = true
if (val === 1) {
this.formData.page = 1
}
let obj = {
fltNo: this.formData.fltNo,
area: this.formData.area,
page: this.formData.page,
size: 20
}
searchFlightDestination(obj).then(res => {
this.tableLoading = false
if (res.code === 200) {
this.tableData = res.data.list
this.total = res.data.total
}
}).catch(err => {
this.tableLoading = false
console.log(err)
})
},
downloadTempleate() {
let downloadType = "flightDestination";
let fileName = "航班目的地模板.xlsx";
downLoadTemplate(downloadType).then((res) => {
if (res) {
const blob = new Blob([res]);
const link = document.createElement("a"); //创建a标签
link.download = fileName; //a标签添加属性
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //执行下载
URL.revokeObjectURL(link.href); //释放url
document.body.removeChild(link); //释放标签
} else {
this.$message.error("下载失败");
}
});
},
uploadExcel(option) {
//上传excel
const file = option.file;
importFlightDestination(file, this.formData.beginDate).then((res) => {
if (res.data.code != 200) {
if (res.data.code == 603) {
this.$alert(res.msg, "提示", {
confirmButtonText: "确定",
type: "warning",
});
} else {
this.msgWarning(res.data.msg);
if (res.data.data && res.data.data.length > 0) {
this.errorData = res.data.data;
this.$router.push({ name: 'UpDateResult', params: { data: this.errorData, from: 'FlightToArea' } })
}
}
} else {
this.msgSuccess("导入成功");
this.selection()
}
});
},
handleRemove(file, fileList) {
//清掉上传的文件
this.fileList = [];
this.selection()
},
handleExceed(files) {
//重复上传文件
let file = {};
file.file = files[0];
file.name = files[0].name;
this.fileList = [];
this.fileList.push(file);
this.uploadExcel(file);
},
currentChange(val) {
this.formData.page = val.page
this.selection()
},
upload() {
this.$refs.selectForm.validateField('beginDate')
}
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.upload-demo {
display: flex;
margin-left: 10px;
float: none !important;
}
.el-upload-list {
display: inline-block;
margin-left: 10px;
vertical-align: top;
}
</style>
\ No newline at end of file
<template>
<div>
<el-button class="ml20 mb20" size="small" icon="el-icon-back" @click="close">返 回</el-button>
<el-table ref="filterTable" class="mt20" :data="tableData" size="small" border>
<el-table-column label="行号" prop="line" width="50" align="center">
</el-table-column>
<el-table-column label="错误信息" prop="errorMessage" width="200">
<template slot-scope="scope">
<div v-for="(m, key) in scope.row.errorMessage" :key="key">
{{ m }}
</div>
</template>
</el-table-column>
<el-table-column v-if="tableData.length == 0"></el-table-column>
<el-table-column v-for="(value, key) in this.tableData[0]" :key="key"
v-if="key != 'errorMessage' && key != 'line'" header-align="center" align="center" :label="key"
:prop="key"></el-table-column>
</el-table>
</div>
</template>
<script>
export default {
name: 'UpDateResult',
data() {
return {
tableData: [],
fromRoute: ''
}
},
created() {
this.tableData = this.$route.params.data
this.fromRoute = this.$route.params.from
},
wactch: {
dialogVisible(val) {
if (val) {
}
}
},
methods: {
close() {
this.$store.state.tagsView.visitedViews.splice(
this.$store.state.tagsView.visitedViews.findIndex(
(item) => item.path === this.$route.path
),
);
this.$router.push({ name: this.fromRoute })
}
}
}
</script>
<style lang="scss" scoped>
</style>
\ No newline at end of file
<template>
<div style="margin: 20px">
<el-form ref="selectForm" :model="formData" class="form-header" label-position="right" label-width="auto"
size="small">
<el-row>
<el-col :span="6">
<el-form-item label="URSA">
<el-input type="textarea" v-model="formData.ursa" placeholder="URSA之间用分号分隔,例:F2;F3;P_" rows="2">
</el-input>
</el-form-item>
</el-col>
<el-col :span="6">
<el-form-item label="地区">
<el-input type="text" v-model="formData.area" placeholder="请输入地区"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="20">
<el-row>
<el-col :span="6">
<el-form-item label="生效日期" prop="beginDate" :rules="rules">
<el-date-picker class="formItem" v-model="formData.beginDate" type="date"
placeholder="选择日期" value-format="yyyy-MM-dd" clearable>
</el-date-picker>
</el-form-item>
</el-col>
<el-col :span="12">
<el-upload action="/flightInfoImport/importFlight" name="file" :http-request="uploadExcel"
:on-remove="handleRemove" :limit="1" :on-exceed="handleExceed" :file-list="fileList"
accept=".xlsx" class="upload-demo" v-hasPermi="['base:flightImport:importFlight']"
:disabled="formData.beginDate==null">
<el-button type="primary" icon="el-icon-upload2" size="small" @click="upload">导入Excel
</el-button>
</el-upload>
</el-col>
</el-row>
</el-col>
</el-row>
</el-form>
<div style="width:100%;display: flex;margin-bottom:10px">
<el-button type="primary" size="small" icon="el-icon-search" :loading="tableLoading" @click="selection(1)">
查询</el-button>
<el-button type="primary" icon="el-icon-download" size="small" @click="downloadTempleate"
v-hasPermi="['base:flightImport:exportExcel']">
下载模板
</el-button>
</div>
<Tables ref="flightToArea" ductName="flightToArea" :selection="false" :selectFixed="false" :order='true'
:height="tableHeight" :data="tableData" :headerData="tableHeaders" :page="formData.page" :pageSizes="[20]"
:totalCount="total" :loading="tableLoading" @currentChange="currentChange"
layout="total,prev, pager, next, jumper, ->">
</Tables>
</div>
</template>
<script>
import {
downLoadTemplate,
importUrsaDestination,
searchUrsaDestination
} from "@/api/preMdeConfig";
export default {
name: "UrsaToArea",
data() {
return {
formData: {
ursa: null,
area: null,
page: 1,
},
tableData: [],
errorData: [],
tableHeaders: this.tableHeaders['ursaToArea'],
tableHeight: null,
total: 0,
flightType: [],
form: {
type: "",
region: "",
},
rules: {
validator: (rule, value, callback) => {
if (this.formData.beginDate == null) {
callback(new Error('上传前请选择生效时间'))
}
},
trigger: 'change'
},
fileList: [],
tableLoading: false,
};
},
created() {
},
mounted() {
this.tableHeight = window.innerHeight - this.$refs.selectForm.$el.offsetHeight - 170
this.selection(1)
},
activated() {
},
methods: {
selection(val) {
this.tableData = []
this.tableLoading = true
if (val === 1) {
this.formData.page = 1
}
let obj = {
area: this.formData.area,
page: this.formData.page,
size: 20
}
if (this.formData.ursa && this.formData.ursa != null && this.formData.ursa != '') {
obj.ursa = this.formData.ursa.split(';')
} else {
obj.ursa = null
}
searchUrsaDestination(obj).then(res => {
this.tableLoading = false
if (res.code === 200) {
this.tableData = res.data.list
this.total = res.data.total
} else {
this.msgWarning(res.msg)
}
}).catch(err => {
this.tableLoading = false
console.log(err)
})
},
downloadTempleate() {
let downloadType = "ursaDestination";
let fileName = "URSA目的地模板.xlsx";
downLoadTemplate(downloadType).then((res) => {
if (res) {
const blob = new Blob([res]);
const link = document.createElement("a"); //创建a标签
link.download = fileName; //a标签添加属性
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //执行下载
URL.revokeObjectURL(link.href); //释放url
document.body.removeChild(link); //释放标签
} else {
this.$message.error("下载失败");
}
});
},
uploadExcel(option) {
//上传excel
const file = option.file;
importUrsaDestination(file, this.formData.beginDate).then((res) => {
if (res.data.code != 200) {
if (res.data.code == 603) {
this.$alert(res.data.msg, "提示", {
confirmButtonText: "确定",
type: "warning",
});
} else {
this.msgWarning(res.data.msg);
if (res.data.data && res.data.data.length > 0) {
this.errorData = res.data.data;
this.$router.push({ name: 'UpDateResult', params: { data: this.errorData, from: 'FlightInformationImport' } })
}
}
} else {
this.msgSuccess("导入成功");
this.tableData = res.data.data;
}
});
},
handleRemove(file, fileList) {
//清掉上传的文件
this.fileList = [];
this.selection()
},
handleExceed(files) {
//重复上传文件
let file = {};
file.file = files[0];
file.name = files[0].name;
this.fileList = [];
this.fileList.push(file);
this.uploadExcel(file);
},
currentChange(val) {
this.formData.page = val.page
this.selection()
},
upload() {
this.$refs.selectForm.validateField('beginDate')
}
},
};
</script>
<style rel="stylesheet/scss" lang="scss">
.upload-demo {
display: flex;
margin-left: 10px;
float: none !important;
}
.el-upload-list {
display: inline-block;
margin-left: 10px;
vertical-align: top;
}
</style>
\ No newline at end of file