430 lines
12 KiB
JavaScript
430 lines
12 KiB
JavaScript
|
|
var nbsComponent_en = {
|
||
|
|
template:`
|
||
|
|
<div>
|
||
|
|
<div style="display: flex;">
|
||
|
|
<el-input v-model="b_code_v" placeholder="battery serial No." clearable style="width: 15%;" @change="input_change"></el-input>
|
||
|
|
<el-input v-model="sid_v" placeholder="instrument series No." clearable style="width: 17%;" @change="input_change"></el-input>
|
||
|
|
<el-input v-model="iid_v" placeholder="instrument serial No." clearable style="width: 16%;" @change="input_change"></el-input>
|
||
|
|
<!--<el-input v-model="b_id_v" placeholder="battery series No." clearable style="width: 15%;" @change="input_change"></el-input>
|
||
|
|
-->
|
||
|
|
<el-button id ="bt_serach" plain type="primary" icon="el-icon-search" @click="get_battery_base()">Search</el-button>
|
||
|
|
<el-button v-if="if_show_1" id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="add_nb_dialog()">Add</el-button>
|
||
|
|
<!--<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="import_battery()">导入</el-button>
|
||
|
|
-->
|
||
|
|
</div>
|
||
|
|
<div class="span">
|
||
|
|
<el-table
|
||
|
|
:data="tableData"
|
||
|
|
style="width: 100%;font-size:14px"
|
||
|
|
:height="tHeight"
|
||
|
|
:cell-style="{background:'#fff'}"
|
||
|
|
border
|
||
|
|
>
|
||
|
|
<!--<el-table-column
|
||
|
|
prop="b_id"
|
||
|
|
label="Battery Series No."
|
||
|
|
:width="150"
|
||
|
|
:show-overflow-tooltip="true">
|
||
|
|
</el-table-column>
|
||
|
|
-->
|
||
|
|
<el-table-column
|
||
|
|
prop="b_code"
|
||
|
|
label="Battery Serial No."
|
||
|
|
:width="150"
|
||
|
|
:show-overflow-tooltip="true">
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column
|
||
|
|
prop="sid"
|
||
|
|
label="Instrument Series No."
|
||
|
|
:width="170"
|
||
|
|
:show-overflow-tooltip="true">
|
||
|
|
</el-table-column>
|
||
|
|
<el-table-column
|
||
|
|
prop="iid"
|
||
|
|
label="Instrument Serial No."
|
||
|
|
:width="170"
|
||
|
|
:show-overflow-tooltip="true">
|
||
|
|
</el-table-column>
|
||
|
|
|
||
|
|
<el-table-column
|
||
|
|
label="Operation"
|
||
|
|
width="140"
|
||
|
|
v-if="if_show_1">
|
||
|
|
<template slot-scope="scope">
|
||
|
|
<el-button @click="update_nbs(scope.row)" type="text" size="medium">Update</el-button>
|
||
|
|
<el-button @click="remove_battery_base(scope.row)" type="text" size="medium">Delete</el-button>
|
||
|
|
</template>
|
||
|
|
</el-table-column>
|
||
|
|
</el-table>
|
||
|
|
</div>
|
||
|
|
<div class="block">
|
||
|
|
<span class="demonstration"></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">
|
||
|
|
</el-pagination>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<el-dialog
|
||
|
|
title="Battery Information"
|
||
|
|
:visible.sync="add_visible"
|
||
|
|
:lock-scroll ="false"
|
||
|
|
width="60%">
|
||
|
|
<el-form ref="bform" :model="form" :rules="rules" label-width="170px" :inline="false" class="demo-form-inline" size="medium">
|
||
|
|
|
||
|
|
<el-row :gutter="10">
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Instrument Series No." prop="series_id">
|
||
|
|
<el-input v-model="form.series_id" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Instrument Serial No." prop="instrument_id">
|
||
|
|
<el-input v-model="form.instrument_id" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
</el-row>
|
||
|
|
|
||
|
|
<el-row :gutter="10">
|
||
|
|
<!--<el-col :span="12">
|
||
|
|
<el-form-item label="Battery Series No." prop="battery_sid">
|
||
|
|
<el-input v-model="form.battery_sid" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
-->
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Battery Serial No." prop="battery_num">
|
||
|
|
<el-input v-model="form.battery_num" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
</el-row>
|
||
|
|
|
||
|
|
</el-form>
|
||
|
|
<span slot="footer" class="dialog-footer">
|
||
|
|
<el-button @click="add_visible = false">Cancel</el-button>
|
||
|
|
<el-button id ="bt_ok" plain type="primary" @click="add_battery_base()">Ok</el-button>
|
||
|
|
</span>
|
||
|
|
</el-dialog>
|
||
|
|
|
||
|
|
<el-dialog
|
||
|
|
title="Battery Information"
|
||
|
|
:visible.sync="update_visible"
|
||
|
|
:lock-scroll ="false"
|
||
|
|
width="60%">
|
||
|
|
<el-form ref="bform" :model="form" :rules="rules" label-width="170px" :inline="false" class="demo-form-inline" size="medium">
|
||
|
|
<el-row :gutter="10">
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Instrument Series No." prop="series_id">
|
||
|
|
<el-input v-model="form.series_id" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Instrument Serial No." prop="instrument_id">
|
||
|
|
<el-input v-model="form.instrument_id" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
</el-row>
|
||
|
|
|
||
|
|
<el-row :gutter="10">
|
||
|
|
<!--<el-col :span="12">
|
||
|
|
<el-form-item label="Battery Series No." prop="battery_sid">
|
||
|
|
<el-input v-model="form.battery_sid" ></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
-->
|
||
|
|
<el-col :span="12">
|
||
|
|
<el-form-item label="Battery Serial No." prop="battery_num">
|
||
|
|
<el-input v-model="form.battery_num" :disabled="true"></el-input>
|
||
|
|
</el-form-item>
|
||
|
|
</el-col>
|
||
|
|
</el-row>
|
||
|
|
</el-form>
|
||
|
|
<span slot="footer" class="dialog-footer">
|
||
|
|
<el-button @click="update_visible = false">Cancel</el-button>
|
||
|
|
<el-button id ="bt_ok" plain type="primary" @click="update_battery_base()">Ok</el-button>
|
||
|
|
</span>
|
||
|
|
</el-dialog>
|
||
|
|
</div>
|
||
|
|
`,
|
||
|
|
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();
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|