deesCloud-web/scripts/mss-en.js

496 lines
14 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var mssComponent_en = {
template:`
<div>
<div v-show="if_show0">
<div id="" style="display: inline-block;width: 100%;margin-top: 10px;">
<div style="float: left; width: 15%;background-color: #ECF5FF;">
<el-select v-model="value" filterable clearable placeholder="Select Well Name" style="width: 100%;">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
<div style="float: left; width: 15%;background-color: #ECF5FF;">
<el-input v-model="series_v" :placeholder="h_series_v" clearable></el-input>
</div>
<div style="float: left; width: 15%;background-color: #ECF5FF;">
<el-input v-model="instrument_id_v" :placeholder="h_instrument_id_v" clearable></el-input>
</div>
<div style="float:left;margin-left: 5px;">
<el-checkbox style="background-color: #ECF5FF;" v-model="checked1" label="Project Service" border></el-checkbox>
</div>
<div style="float: left;margin-left: 5px;">
<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="getMss(value)">Search</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportMss()">Export</el-button>
</div>
<div style="float: left; margin-left: 5px;">
<el-button id ="bt_export_1" plain type="primary" icon="el-icon-document" @click="exportWarning()">Export Alert</el-button>
</div>
</div>
<div class="span">
<el-table
:data="tableData"
style="width: 100%;font-size:14px;"
:height = "tHeight"
:cell-style="{background:'#304156'}"
:row-class-name="tableRowClassName"
border
>
<el-table-column
prop="wellname"
label="Well Name"
width="120"
:show-overflow-tooltip="true">
</el-table-column>
<el-table-column
prop="series"
label="Instrument Series No."
:width="160">
</el-table-column>
<el-table-column
prop="instrument_id"
label="Instrument Serial No."
:width="160">
</el-table-column>
<el-table-column
prop="state"
label="Status"
:width="80">
</el-table-column>
<el-table-column
prop="ver"
label="Current Firmware Version"
:width="185">
</el-table-column>
<el-table-column
prop="lastVer"
label="Latest Firmware Version"
:width="180">
</el-table-column>
<el-table-column
prop="totalWorkTime"
label="Total Working Time(h)"
:width="180">
</el-table-column>
<el-table-column
prop="workTime"
label="Current Working Time(h)"
:width="180">
</el-table-column>
<!--
<el-table-column
prop="wellEntryTime"
label="本次下井累计工作时间"
:width="60">
</el-table-column>
<el-table-column
prop="wellEntryTime"
label="本次入井时间"
:width="60">
</el-table-column>
-->
<!--<el-table-column
prop="repairCnt"
label="Maintenance Times"
:width="140">
<template slot="header" >
<el-tooltip
effect="dark"
content="number of maintenance events"
placement="top"
>
<span>Maintenance Times</span>
</el-tooltip>
</template>
</el-table-column>-->
<el-table-column
prop="saveTime"
label="Saved Time"
:width="170">
</el-table-column>
</el-table>
</div>
<div class="block" style="margin-top: 10px;">
<span class="demonstration" style="background-color: #ECF5FF;"></span>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[50,100, 200, 300]"
:page-size="pagesize"
layout="total, sizes, prev, pager, next, jumper"
:total="recordTotal" style="background-color: #ECF5FF;">
</el-pagination>
</div>
</div>
<div v-show="if_show" style="text-align: center; width: 100%;;font-size: 14px;">
<el-tag type="warning" style="width: 100%;height: 50px;font-size: 14px;">The user does not have permission for this menu!</el-tag>
</div>
</div>
`,
data(){
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.innerHeight;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH-202,
tableData: [],
currentPage: 1,
pagesize:50,
recordTotal:0,
options: [],
value: '',
series_v:"",
instrument_id_v:"",
h_series_v:"Input Series No.",
h_instrument_id_v:"Input Serial No.",
if_show0:false,
if_show:false,
checked1:false,
}
},
mounted() {
if (localStorage.getItem("level")==4) {
this.$data.if_show = true;
return;
}
this.$data.if_show0= true;
var _this = this;
axios.post('/deescloud/getWellNames',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
})
.then(function (response) {
console.log(response.data);
_this.$data.options = response.data;
})
.catch(function (error) {
console.log(error);
});
var objs;
axios.post('/deescloud/getMss_en', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
series:this.$data.series_v,
instrument_id:this.$data.instrument_id_v,
wellname: this.$data.value,
index: this.$data.currentPage,
count: this.$data.pagesize,
checked:this.$data.checked1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
console.log(objs);
})
.catch(function (error) {
console.log(error);
});
},
methods: {
exportWarning(){
document.getElementById("bt_export_1").blur();
var _this = this;
var filename = 'Statistics of early warning information';
axios.post('deescloud/getSeriesWarningCsv_en',{
//wellname: _this.$data.value,
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
},
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
downloadUrl(filename+".xlsx",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
tableRowClassName({row, rowIndex}) {
if (row.warn_type=="1") {
return 'warning-row';
}
if (row.warn_type=="2") {
return 'warning-row-1';
}
return;
var newDate = new Date();
var year=newDate.getFullYear();
var month=(newDate.getMonth()+1)<10?"0"+(newDate.getMonth()+1):newDate.getMonth()+1;
var day=newDate.getDate()<10?"0"+newDate.getDate():newDate.getDate();
var hours=newDate.getHours()<10?"0"+newDate.getHours():newDate.getHours();
var minuts=newDate.getMinutes()<10?"0"+newDate.getMinutes():newDate.getMinutes();
var seconds=newDate.getSeconds()<10?"0"+newDate.getSeconds():newDate.getSeconds();
if (month==1) {
month=12
year=year-1
} else{
month=month-1
}
if (month <10) {
month='0'+month;
}
let t = year+"-"+month+"-"+day+" "+hours+":"+minuts+":"+seconds
console.log("t:",t);
if (row.saveTime > t) {
if (row.workTime >1000) {
return 'warning-row';
}
if(row.ver.indexOf('A')!=-1||row.ver.indexOf('a')!=-1||row.lastVer.indexOf('B')!=-1||row.lastVer.indexOf('b')!=-1){
return '';
}
if (row.ver!='' && row.lastVer!='' &&row.ver <row.lastVer) {
return 'warning-row-1';
}
}
return '';
},
exportMss(){
document.getElementById("bt_export").blur();
var _this = this;
var filename = '';
if (this.$data.value == "") {
filename = 'Maintenance information statistics';
}else{
filename = _this.$data.value+'-Maintenance information statistics';
}
axios.post('deescloud/getMssCsv_en',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: _this.$data.value,
series:this.$data.series_v,
instrument_id:this.$data.instrument_id_v,
checked:this.$data.checked1
},
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
downloadUrl(filename+".csv",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
getMss(_search_name){
document.getElementById("bt_search").blur();
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/getMss_en', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
series:this.$data.series_v,
instrument_id:this.$data.instrument_id_v,
wellname: _search_name,
index: this.$data.currentPage,
count: this.$data.pagesize,
checked:this.$data.checked1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
handleSizeChange(val) {
this.$data.pagesize = val;
var _this = this;
var objs;
axios.post('/deescloud/getMss_en', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
series:this.$data.series_v,
instrument_id:this.$data.instrument_id_v,
wellname: this.$data.value,
index: this.$data.currentPage,
count: this.$data.pagesize,
checked:this.$data.checked1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
handleCurrentChange(val) {
this.$data.currentPage = val;
var _this = this;
var objs;
axios.post('/deescloud/getMss_en', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
series:this.$data.series_v,
instrument_id:this.$data.instrument_id_v,
wellname: this.$data.value,
index: this.$data.currentPage,
count: this.$data.pagesize,
checked:this.$data.checked1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData = objs;
_this.$data.recordTotal = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
flexColumnWidth(str, tableData, flag = 'max') {
// str为该列的字段名(传字符串);tableData为该表格的数据源(传变量);
// flag为可选值可不传该参数,传参时可选'max'或'equal',默认为'max'
// flag为'max'则设置列宽适配该列中最长的内容,flag为'equal'则设置列宽适配该列中第一行内容的长度。
let maxContext = new Array();
str = str + ''
let columnContent = ''
if (!tableData || !tableData.length || tableData.length === 0 || tableData === undefined) {
return '120px'
}
if (!str || !str.length || str.length === 0 || str === undefined) {
return '120px'
}
if (flag === 'equal') {
// 获取该列中第一个不为空的数据(内容)
for (let i = 0; i < tableData.length; i++) {
if (tableData[i][str].length > 0) {
// console.log('该列数据[0]:', tableData[0][str])
columnContent = tableData[i][str]
break
}
}
} else {
// 获取该列中最长的数据(内容)
let index = 0
for (let i = 0; i < tableData.length; i++) {
if (tableData[i][str] === null) {
return
}
const now_temp = tableData[i][str] + ''
const max_temp = tableData[index][str] + ''
if (now_temp.length >= max_temp.length) {
index = i
}
}
columnContent = tableData[index][str]
maxContext.push(columnContent);
}
// console.log('该列数据[i]:', columnContent)
// 以下分配的单位长度可根据实际需求进行调整
//console.log(columnContent);
let max_flex_width = 0
for (let i = 0; i < maxContext.length; i++) {
let flexWidth = 0;
for (const char of maxContext[i]) {
if ((char >= 'A' && char <= 'Z') || (char >= 'a' && char <= 'z')) {
// 如果是英文字符为字符分配8个单位宽度
flexWidth += 8
} else if (char >= '\u4e00' && char <= '\u9fa5') {
// 如果是中文字符为字符分配15个单位宽度
flexWidth += 15
} else {
// 其他种类字符为字符分配8个单位宽度
flexWidth += 8
}
}
if (flexWidth>max_flex_width) {
max_flex_width = flexWidth;
console.log(maxContext[i]);
}
}
if (max_flex_width < 120) {
// 设置最小宽度
max_flex_width = 120
}
if (max_flex_width > 300) {
// 设置最大宽度
max_flex_width = 300
}
//flexWidth = flexWidth;//20-padding
console.log("max_flex_width:",max_flex_width);
return max_flex_width + 'px'
},
}
}