var nbsComponent_en = {
template:`
`,
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),
sid_v:'',
iid_v:'',
b_id_v:'',
b_code_v:'',
currentPage: 1,
pagesize:50,
recordTotal:0,
add_visible:false,
update_visible:false,
form: {
id:0,
battery_sid:'',
battery_num:'',
series_id: '',
instrument_id:'',
},
rules: {
battery_sid: [
{ required: true, message: 'Battery Series No. cannot be empty', trigger: 'blur' }
],
battery_num: [
{ required: true, message: 'Battery Serial No. Cannot be empty', trigger: 'blur' }
],
series_id: [
{ required: true, message: 'Instrument Series No. cannot be empty', trigger: 'blur' }
],
instrument_id: [
{ required: true, message: 'Instrument Serial No. cannot be empty', 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();
},
methods: {
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: "Successfully deleted",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "User does not have permission",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "Delete failed",
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: "Successfully modified",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "User does not have permission",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "Modification failed",
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: "Added successfully",
type: "success",
duration: 1500
});
}else if(r==1){
_this.$message({
message: "User does not have permission",
type: "error",
duration: 1500
});
}else{
_this.$message({
message: "Add failed",
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();
},
}
}