var nbsComponent = {
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),
tableData1: Array(0),
sid_v:'',
iid_v:'',
b_id_v:'',
b_code_v:'',
b_code_v_1:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
currentPage1: 1,
pagesize1:50,
recordTotal1:0,
add_visible:false,
update_visible:false,
add_visible_1:false,
update_visible_1:false,
form: {
id:0,
battery_sid:'',
battery_num:'',
series_id: '',
instrument_id:'',
},
form1: {
id:0,
battery_sid:'',
battery_num:'',
series_id: '',
instrument_id:'',
b_life:'',
},
rules: {
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' }
],
b_life:[
{ required: true, message: '电池寿命不可为空', trigger: 'blur' }
],
},
history_visible:false,
his_tableData:[],
if_show_bt:true,
if_show_et:false,
ps_info:'',
if_show_1:true,
}
},
mounted() {
if (localStorage.getItem("level")==0) {
this.$data.if_show_1 = true;
}else{
var did = localStorage.getItem("did");
if (did==1) {
this.$data.if_show_1=true;
}else{
this.$data.if_show_1=false;
}
}
this.get_battery_base();
this.get_b_life();
},
methods: {
remove_blife(row){
var _this = this;
var r;
axios.post('/deescloud/remove_blife', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: row.id,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "删除成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "删除失败",
type: "error",
duration: 1500
});
}
_this.get_b_life();
})
.catch(function (error) {
console.log(error);
});
},
update_b_life(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_b_life', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
b_code:_this.$data.form1.battery_num,
b_life:_this.$data.form1.b_life,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "修改成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "修改失败",
type: "error",
duration: 1500
});
}
_this.get_b_life();
_this.$data.update_visible_1=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
update_blife(row){
this.$data.form1.id=row.id;
this.$data.form1.battery_sid=row.b_id;
this.$data.form1.battery_num=row.b_code;
this.$data.form1.series_id= row.sid;
this.$data.form1.instrument_id=row.iid;
this.$data.form1.b_life=row.b_life;
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.update_visible_1=true;
},
add_b_life(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_b_life', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
b_code:_this.$data.form1.battery_num,
b_life:_this.$data.form1.b_life,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "添加成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "添加失败",
type: "error",
duration: 1500
});
}
_this.get_b_life();
_this.$data.add_visible_1=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
add_blife_dialog(){
document.getElementById("bt_add").blur();
this.$data.form1.battery_sid='';
this.$data.form1.battery_num='';
this.$data.form1.series_id= '';
this.$data.form1.instrument_id='';
this.$data.form1.b_life='';
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.add_visible_1=true;
},
input_change_1(value) {
this.get_b_life();
},
get_b_life(){
document.getElementById("bt_serach_1").blur();
this.$data.currentPage1=1;
var _this = this;
var objs;
axios.post('/deescloud/get_b_life', {
b_code:this.$data.b_code_v_1,
index: this.$data.currentPage1,
count: this.$data.pagesize1
})
.then(function (response) {
console.log(response.data);
objs = response.data.data;
rcnt = response.data.total;
_this.$data.tableData1 = objs;
_this.$data.recordTotal1 = rcnt;
})
.catch(function (error) {
console.log(error);
});
},
handleSizeChange1(val) {
//console.log(`每页 ${val} 条`);
this.$data.pagesize1 = val;
this.get_b_life();
},
handleCurrentChange1(val) {
//console.log(`当前页: ${val}`);
this.$data.currentPage1 = val;
this.get_b_life();
},
remove_battery_base(row){
var _this = this;
var r;
axios.post('/deescloud/remove_battery_base', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
id: row.id,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "删除成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "删除失败",
type: "error",
duration: 1500
});
}
_this.get_battery_base();
})
.catch(function (error) {
console.log(error);
});
},
update_battery_base(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_battery_base', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
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,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "修改成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "修改失败",
type: "error",
duration: 1500
});
}
_this.get_battery_base();
_this.$data.update_visible=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
update_nbs(row){
this.$data.form.id=row.id;
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.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.update_visible=true;
},
input_change(value) {
this.get_battery_base();
},
add_battery_base(){
this.$refs['bform'].validate((valid) => {
if (valid) {
var _this = this;
var r;
axios.post('/deescloud/add_battery_base', {
opuser:localStorage.getItem("online_user"),
opuser_uuid:localStorage.getItem("uuid"),
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,
})
.then(function (response) {
console.log(response.data);
r = response.data.r;
if (r==0){
_this.$message({
message: "添加成功",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "用户无权限",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "添加失败",
type: "error",
duration: 1500
});
}
_this.get_battery_base();
_this.$data.add_visible=false;
})
.catch(function (error) {
console.log(error);
});
}})
},
add_nb_dialog(){
document.getElementById("bt_add").blur();
this.$data.form.battery_sid='',
this.$data.form.battery_num='',
this.$data.form.series_id= '',
this.$data.form.instrument_id='',
this.$nextTick(() => {
this.$refs['bform'].clearValidate()
});
this.$data.add_visible=true;
},
get_battery_base(){
document.getElementById("bt_serach").blur();
this.$data.currentPage=1;
var _this = this;
var objs;
axios.post('/deescloud/get_battery_base', {
sid: this.$data.sid_v,
iid: this.$data.iid_v,
b_id: this.$data.b_id_v,
b_code:this.$data.b_code_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;
this.get_battery_base();
},
handleCurrentChange(val) {
//console.log(`当前页: ${val}`);
this.$data.currentPage = val;
this.get_battery_base();
},
}
}