var nbComponent_en = {
template:`
Search
Add
Export
Export Alert
Detail
Update
Delete
`,
data(){
// 获取当前屏幕的分辨率
let screenW = window.screen.width;
let screenH = window.screen.height;
console.log("screen width:",screenW);
console.log("screen height:",screenH);
return {
tHeight:screenH*0.8,
tHeight1:screenH*0.5,
tableData: Array(0),
series_id_v:'',
num_v:'',
input:'',
currentPage: 1,
pagesize:50,
recordTotal: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: 'cannot be empty', trigger: 'blur' }
],
battery_sid: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
battery_num: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
series_id: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
instrument_id: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
begin_t: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
end_t: [
{ required: true, message: 'cannot be empty', trigger: 'blur' }
],
},
history_visible:false,
his_tableData:[],
if_show_bt:true,
if_show_et:false,
ps_info:'',
}
},
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;
if(response.data.r3=="1"){
_this.$data.if_show_bt=true;
_this.$data.if_show_et=false;
}else{
_this.$data.if_show_et=true;
_this.$data.if_show_bt=false;
}
})
.catch(function (error) {
console.log(error);
});
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_nb_warning_csv(){
var _this = this;
axios.post('deescloud/get_nb_warning_csv_en',{
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("Battery warning record"+".csv",downUrl);
})
.catch(function (error) {
console.log(error);
});
},
get_nb_csv(){
var _this = this;
axios.post('deescloud/get_nb_csv_en',{
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("Battery usage records"+".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,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "Successfully deleted",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "Delete failed",
type: "error",
duration: 1500
});
}
_this.get_nb_his_ex(row.b_id,row.b_code);
})
.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,
time:_this.$data.form.end_t,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "Successfully modified",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "Modification failed",
type: "error",
duration: 1500
});
}
_this.get_nb_his_ex(_this.$data.form.battery_sid,_this.$data.form.battery_num);
_this.$data.update_visible=false;
})
.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='';
console.log(row.time.length)
if(this.$data.ps_info.r3=="1"){
this.$data.form.end_t=row.time;
}else{
if (row.time.length>=19){
var result = row.time.split(" ")
var arr = result[0].split("-")
var t = arr[2]+"-"+arr[0]+"-"+arr[1] +" " + result[1];
console.log(t);
this.$data.form.end_t=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,
time:_this.$data.form.end_t,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "Added successfully",
type: "success",
duration: 1500
});
}else{
_this.$message({
message: "Add failed",
type: "error",
duration: 1500
});
}
_this.$data.add_visible=false;
})
.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);
});
},
get_nb_his_ex(b_id,b_code){
var _this = this;
var objs;
axios.post('/deescloud/get_nb_his_en', {
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_en', {
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);
});
},
}
}