自适应高度
<template>
<a-card class="MainCard" hoverable style="width: 100% ;height: auto;">
<a-row type="flex" justify="space-between" >
<a-col span="24">
<a-card hoverable style="font-size: 20px;width: 100%;height:auto;float:left">
<div>
<a-row>
<a-col span="7">
<div style="font-weight:bold;font-size: 20px;color: black;">
① 油藏模型导入
</div>
</a-col>
<a-col span="10" >
<a-upload-dragger
name="file"
:action="uploadUrl"
:multiple="true"
@change="handleChange"
>
<p class="ant-upload-drag-icon">
<a-icon type="inbox" />
</p>
<p class="ant-upload-text">
点击或者拖拽上传
</p>
<p class="ant-upload-hint">
将油藏模型文件多选上传,不能选文件夹!
</p>
</a-upload-dragger>
</a-col>
</a-row>
</div>
</a-card>
</a-col>
<a-col span="24" >
<a-spin size="large" :spinning="spinning_data" >
<a-card hoverable style="font-size: 20px;width: 100%;height:auto;margin-top: 10px">
<a slot = "title" style="font-weight:bold;font-size: 20px;color: black;">
② 井生产数据展示
</a>
<a slot="extra" href="#">
<a-button type="primary" :loading="loading_chuli" @click="read_Sch">
开始展示
</a-button>
</a>
<el-table
:data="tableData.filter(data => !search || data.name.toLowerCase().includes(search.toLowerCase()))"
style="width: 100%">
<el-table-column
label="井名"
prop="wellname">
</el-table-column>
<el-table-column
label="井别"
prop="type">
</el-table-column>
<el-table-column
label="产液量"
prop="chanye">
</el-table-column>
<el-table-column
label="上限"
prop="up">
</el-table-column>
<el-table-column
label="下限"
prop="down">
</el-table-column>
<el-table-column
align="right">
<template slot="header" slot-scope="scope">
<el-input
v-model="search"
size="mini"
placeholder="输入关键字搜索"/>
</template>
<template slot-scope="scope">
<el-button
size="mini"
@click="handleEdit(scope.$index, scope.row)">Edit</el-button>
<el-button
size="mini"
type="danger"
@click="handleDelete(scope.$index, scope.row)">Delete</el-button>
</template>
</el-table-column>
</el-table>
</a-card>
</a-spin>
</a-col>
</a-row>
</a-card>
</template>
<script >
// 张宝东
import {uploadFile2} from '../../api'
import {read_sch} from '../../api'
export default {
data() {
return {
//张宝东
tableData: [ ],
cslj:'D:\\Injection_production_optimization\\item\\BASE',
xmm:'BASE',
sxbs:'1.5',
xxbs:'0.5',
opt:null,
spinning_data:false
}
},
computed: {
uploadUrl() {
return uploadFile2
}
},
methods: {
//上传文件,张宝东
handleClick(row) {
console.log(row);
},
handleChange(info) {
const status = info.file.status;
if (status !== 'uploading') {
console.log(info.file, info.fileList);
}
if (status === 'done') {
this.$message.success(`${info.file.name} file uploaded successfully.`);
} else if (status === 'error') {
this.$message.error(`${info.file.name} file upload failed.`);
}
},
// 调用特征数据
read_Sch () {
var qs = require('qs');
var params = qs.stringify({
cslj: this.cslj,
xmm: this.xmm,
sxbs: this.sxbs,
xxbs: this.xxbs
});
read_sch(params).then(function (result) {
this.opt = result.data.opt;
this.tableData=result.data.opt.wellmodel;
}.bind(this)).catch(function (error) {
// this.loading4 = false
console.log(error)
})
}
}
}
</script>
const BASE_PATH2 = 'http://127.0.0.1:9521/api/yw1';
//张宝东编辑 文件上传地址
export const uploadFile2 = `http://127.0.0.1:9521/api/yw1/user/muilty_upload`
// 保存选择模型
export const read_sch = params => { return Axios.post(`${BASE_PATH2}/user/sch`, params ).then(res => res.data) }
@RequestMapping(value="/muilty_upload", method = RequestMethod.POST)
public ResponseData uploadImg(@RequestParam("file") MultipartFile file) {
String contentType = file.getContentType();
String fileName = file.getOriginalFilename();
System.out.println("fileName-->" + fileName);
System.out.println("getContentType-->" + contentType);
String filePath = "D:\\11\\";
try {
new SgtzdController().uploadFile(file.getBytes(), filePath, fileName);
} catch (Exception e) {
e.printStackTrace();
}
return ResponseData.ok("success");
}
public void uploadFile(byte[] file, String filePath, String fileName) throws Exception {
File targetFile = new File(filePath);
if(!targetFile.exists()){
targetFile.mkdirs();
}
FileOutputStream out = new FileOutputStream(filePath+fileName);
out.write(file);
out.flush();
out.close();
}
@RequestMapping(value="/sch", method = RequestMethod.POST)
public ResponseData Culculate(OptModel opt) throws JsonParseException, JsonMappingException, IOException {
//HttpServletRequest request = ServletActionContext.getRequest();
//String Optmod = request.getParameter("Optmod");
// ObjectMapper mapper = new ObjectMapper();
// opt = mapper.readValue(Optmod,OptModel.class);
//特殊的复杂数据结构
//OptModel opt=new OptModel();
WellData welldata = new WellData();
LinkedList<WellData> welllist=new LinkedList<WellData>();
//读井sch数据
//读sch文件
String pathsch =opt.getCslj()+"\\"+opt.getXmm()+".SCH";
System.out.println(pathsch);
Scanner scanner = new Scanner(new FileInputStream(pathsch) ) ;
FileInputStream fis=new FileInputStream(pathsch);
InputStreamReader isr=new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String line="";
String[] arrs=null;
while (true) {
String lines=br.readLine();
if(lines==null)break;
if(lines.contains("WCONPROD")) {//查找关键字
welllist.clear();
while((lines = br.readLine())!=null) {
if(lines.toCharArray().length<16)break;
arrs = lines.split("\\s+");//按照空格分割一行的数据
WellData wellnode = new WellData();
WellData wellnodea = new WellData();
wellnode = nwelldata2oil(wellnodea, arrs, opt.getSxbs(), opt.getXxbs());
welllist.add(wellnode);//加一行 井节点,table数据的一行,循环加完
}
}
if(lines.contains("WCONINJE")) {
while((lines = br.readLine())!=null) {
if(lines.toCharArray().length<16)break;
arrs = lines.split("\\s+");
WellData wellnode = new WellData();
WellData wellnodea = new WellData();
wellnode = nwelldata2water(wellnodea, arrs, opt.getSxbs(), opt.getXxbs());
welllist.add(wellnode);
}
}
}
opt.setWellmodel(welllist);
//writeOptFile(opt);
HashMap data=new HashMap();
data.put("opt",opt);//bean
return ResponseData.ok(data);
}
private WellData nwelldata2oil(WellData welldata, String[] arrs, String up, String down) {
welldata.setChanye(arrs[4]);
double chanyeliang=Double.parseDouble(arrs[4]);
DecimalFormat df = new DecimalFormat("#.00");
String upd=df.format(Double.parseDouble(up)*chanyeliang);
String dowd=df.format(Double.parseDouble(down)*chanyeliang);
welldata.setUp(String.valueOf(upd) );
welldata.setWellname(arrs[0]);
welldata.setDown(String.valueOf(dowd) );String aa=null;
welldata.setType("oil");
return welldata;
}
private WellData nwelldata2water(WellData welldata, String[] arrs, String up, String down) {
welldata.setChanye(arrs[4]);
double chanyeliang=Double.parseDouble(arrs[4]);
DecimalFormat df = new DecimalFormat("#.00");
String upd=df.format(Double.parseDouble(up)*chanyeliang);
String dowd=df.format(Double.parseDouble(down)*chanyeliang);
welldata.setUp(String.valueOf(upd) );
welldata.setWellname(arrs[0]);
welldata.setDown(String.valueOf(dowd) );String aa=null;
welldata.setType("water");
return welldata;
}
后台返回的对象