var nbComponent = {
template:`
电池
井位
搜索
新增
导出电池使用报告
导出预警
搜索
新增
导出井位电池使用报告
修改
删除
`,
data(){
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.innerHeight;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH-192,
tHeight1:screenH*0.5,
tableData: Array(0),
series_id_v:'',
num_v:'',
input:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
currentPage1: 1,
pagesize1:50,
recordTotal1:0,
add_visible:false,
update_visible:false,
form: {
id:0,
wellname:'',
battery_sid:'',
battery_num:'',
series_id: '',
instrument_id:'',
begin_t:'',
end_t:'',
use_t:0,
},
rules: {
wellname: [
{ required: true, message: '井名不可为空', trigger: 'blur' }
],
battery_sid: [
{ required: true, message: '电池系列号不可为空', trigger: 'blur' }
],
battery_num: [
{ required: true, message: '电池序列号不可为空', trigger: 'blur' }
],
series_id: [
{ required: true, message: '短节系列号不可为空', trigger: 'blur' }
],
instrument_id: [
{ required: true, message: '短节序列号不可为空', trigger: 'blur' }
],
begin_t: [
{ required: true, message: '上电时间不可为空', trigger: 'blur' }
],
end_t: [
{ required: true, message: '断电时间不可为空', trigger: 'blur' }
],
},
history_visible:false,
his_tableData:[],
if_show_bt:1,
ps_info:'',
radio1: '1',
options: [],
wellname_v:'',
checked1:false,
}
},
mounted() {
var _this = this;
axios.post('/deescloud/get_page_setting', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
})
.then(function (response) {
_this.$data.ps_info = response.data;
console.log(response.data)
if(response.data.r3=="1"){
_this.$data.if_show_bt=1;
}else if(response.data.r3=="2"){
_this.$data.if_show_bt=2;
}else if(response.data.r3=="3"){
_this.$data.if_show_bt=3;
}else{
_this.$data.if_show_bt=1;
}
})
.catch(function (error) {
console.log(error);
});
this.get_all_wellname();
var objs;
axios.post('/deescloud/get_nb', {
series_id: "",
num: "",
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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);
});
},
methods: {
get_well_nb_pdf(){
document.getElementById("bt_export").blur();
if (this.$data.wellname_v==""){
this.$message({
message: "请选择井名称",
type: "warning",
duration: 1500
});
return;
}
var _this = this;
axios.post('deescloud/get_well_nb_pdf',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname:_this.$data.wellname_v,
},
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
downloadUrl(_this.$data.wellname_v+"电池使用报告"+".pdf",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
get_nb_pdf(){
document.getElementById("bt_export").blur();
var _this = this;
axios.post('deescloud/get_nb_pdf',{
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
bcode:_this.$data.num_v,
},
).then(function (response) {
console.log(response.data);
var fileid = response.data.fileId;
var downUrl = 'file/'+fileid;
downloadUrl("电池使用报告"+".pdf",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
get_nb_his_ex2(){
document.getElementById("bt_serach").blur();
var _this = this;
var objs;
axios.post('/deescloud/get_nb_his_ex', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: _this.$data.wellname_v,
index: this.$data.currentPage1,
count: this.$data.pagesize1,
checked:this.$data.checked1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.his_tableData = objs;
_this.$data.recordTotal1 = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
radio_change(){
console.log(this.$data.radio1)
if (this.$data.radio1=="1"){
this.get_nb();
} else if (this.$data.radio1=="2"){
this.$data.his_tableData=[];
this.get_nb_his_ex2()
}
},
get_all_wellname(){
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);
});
},
get_nb_warning_csv(){
var _this = this;
axios.post('deescloud/get_nb_warning_csv',{
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("电池预警记录"+".csv",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
get_nb_csv(){
var _this = this;
axios.post('deescloud/get_nb_csv',{
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("电池使用记录"+".csv",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
remove_nb_his(row){
var _this = this;
var r;
axios.post('/deescloud/remove_nb_his', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: row.id,
b_id: row.b_id,
b_code:row.b_code,
wellname:row.wellname,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "删除成功",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "删除失败",
type: "error",
duration: 1500
});
}
if (_this.$data.radio1=="1"){
_this.get_nb_his_ex(row.b_id,row.b_code);
} else if (_this.$data.radio1=="2"){
_this.get_nb_his_ex2()
}
})
.catch(function (error) {
console.log(error);
});
},
update_nb_his(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/update_nb_his', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: _this.$data.form.id,
wellname: _this.$data.form.wellname,
sid: _this.$data.form.series_id,
iid: _this.$data.form.instrument_id,
b_id: _this.$data.form.battery_sid,
b_code:_this.$data.form.battery_num,
uset:_this.$data.form.use_t,
action:0,
bt:_this.$data.form.begin_t,
et:_this.$data.form.end_t,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "修改成功",
type: "success",
duration: 1500
});
if (_this.$data.radio1=="1"){
_this.get_nb_his_ex(_this.$data.form.battery_sid,_this.$data.form.battery_num);
} else if (_this.$data.radio1=="2"){
_this.get_nb_his_ex2()
}
_this.$data.update_visible=false;
}else if (r==1){
_this.$message({
message: "结束日期必须在开始日期之后!",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "修改失败",
type: "error",
duration: 1500
});
}
})
.catch(function (error) {
console.log(error);
});
}})
},
update_b(row){
this.$data.form.id=row.id;
this.$data.form.wellname=row.wellname;
this.$data.form.battery_sid=row.b_id;
this.$data.form.battery_num=row.b_code;
this.$data.form.series_id= row.sid;
this.$data.form.instrument_id=row.iid;
this.$data.form.begin_t='';
this.$data.form.end_t='';
console.log(row.bt,row.et);
if(this.$data.ps_info.r3=="1"){
this.$data.form.begin_t=row.bt;
this.$data.form.end_t=row.et;
}else if (this.$data.ps_info.r3=="2"){
if (row.bt.length>=10){
var arr = row.bt.split("-")
var t = arr[1]+"-"+arr[2]+"-"+arr[0];
console.log(t);
this.$data.form.begin_t=t;
}
if (row.et.length>=10){
var arr = row.etsplit("-")
var t = arr[1]+"-"+arr[2]+"-"+arr[0];
console.log(t);
this.$data.form.end_t=t;
}
}else if (this.$data.ps_info.r3=="3"){
if (row.bt.length>=10){
var arr = row.bt.split("/")
var month = arr[1]
if (this.$data.ps_info.r4){
month=get_month(month)
}
var t = arr[2]+"-"+month+"-"+arr[0];
console.log(t);
this.$data.form.begin_t=t;
}
if (row.et.length>=10){
var arr = row.et.split("/")
var month = arr[1]
if (this.$data.ps_info.r4){
month=get_month(month)
}
var t = arr[2]+"-"+month+"-"+arr[0];
console.log(t);
this.$data.form.end_t=t;
}
}else{
this.$data.form.begin_t=row.bt;
this.$data.form.end_t=row.et;
}
console.log(this.$data.form.begin_t,this.$data.form.end_t)
this.$data.form.use_t=row.uset;
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.update_visible=true;
},
input_change(value) {
this.get_nb();
},
add_nb(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_nb_his', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
wellname: _this.$data.form.wellname,
sid: _this.$data.form.series_id,
iid: _this.$data.form.instrument_id,
b_id: _this.$data.form.battery_sid,
b_code:_this.$data.form.battery_num,
uset:_this.$data.form.use_t,
action:0,
bt:_this.$data.form.begin_t,
et:_this.$data.form.end_t,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "添加成功",
type: "success",
duration: 1500
});
if (_this.$data.radio1=="1"){
_this.get_nb();
} else if (_this.$data.radio1=="2"){
_this.get_nb_his_ex2()
}
_this.$data.add_visible=false;
} else if (r==1){
_this.$message({
message: "结束日期必须在开始日期之后!",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "添加失败",
type: "error",
duration: 1500
});
}
})
.catch(function (error) {
console.log(error);
});
}})
},
add_nb_dialog(){
document.getElementById("bt_add").blur();
this.$data.form.wellname='',
this.$data.form.battery_sid='',
this.$data.form.battery_num='',
this.$data.form.series_id= '',
this.$data.form.instrument_id='',
this.$data.form.begin_t='',
this.$data.form.end_t='',
this.$data.form.use_t=0,
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.add_visible=true;
},
get_nb(){
document.getElementById("bt_serach").blur();
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/get_nb', {
series_id: _this.$data.series_id_v,
num: _this.$data.num_v,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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) {
//console.log(`每页 ${val} 条`);
this.$data.pagesize = val;
var _this = this;
var objs;
axios.post('/deescloud/get_nb', {
series_id: _this.$data.series_id_v,
num: _this.$data.num_v,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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) {
//console.log(`当前页: ${val}`);
this.$data.currentPage = val;
var _this = this;
var objs;
axios.post('/deescloud/get_nb', {
series_id: _this.$data.series_id_v,
num: _this.$data.num_v,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.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);
});
},
handleSizeChange1(val) {
//console.log(`每页 ${val} 条`);
this.$data.pagesize1 = val;
this.get_nb_his_ex2();
},
handleCurrentChange1(val) {
//console.log(`当前页: ${val}`);
this.$data.currentPage1 = val;
this.get_nb_his_ex2();
},
get_nb_his_ex(b_id,b_code){
var _this = this;
var objs;
axios.post('/deescloud/get_nb_his', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
b_id: b_id,
b_code: b_code,
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
_this.$data.his_tableData = objs;
})
.catch(function (error) {
console.log(error);
});
},
get_nb_his(row){
var _this = this;
var objs;
axios.post('/deescloud/get_nb_his', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
b_id: row.b_id,
b_code: row.b_code,
index: this.$data.currentPage,
count: this.$data.pagesize
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
_this.$data.his_tableData = objs;
_this.$data.history_visible=true;
})
.catch(function (error) {
console.log(error);
});
},
}
}