	var nbsComponent = {
		template:`
		<div>
			<div style="display: inline-block;width: 100%;margin-top: 10px;">
				<div style="float: left;width: 55%;">
					<div style="display: flex;">
						<div style="float: left;background-color: #ECF5FF;">
							<el-input v-model="b_code_v" placeholder="电池序列号" clearable style=""  @change="input_change"></el-input>
						</div>
						<div style="float: left;background-color: #ECF5FF;">
							<el-input v-model="sid_v" placeholder="仪器系列号" clearable style=";margin-left: 0px;"  @change="input_change"></el-input>
						</div>
						<div style="float: left;background-color: #ECF5FF;">
							<el-input v-model="iid_v" placeholder="仪器序列号" clearable style=""  @change="input_change"></el-input>
						</div>
						<!--<el-input v-model="b_id_v" placeholder="电池系列号" clearable style="width: 15%;"  @change="input_change"></el-input>
						-->
						<div style="float: left;margin-left: 5px;">
							<el-button id ="bt_serach" plain type="primary" icon="el-icon-search" @click="get_battery_base()">搜索</el-button>
						</div>
						<div style="float: left;margin-left: 5px;">
							<el-button v-if="if_show_1" id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="add_nb_dialog()">新增</el-button>
						</div>
						<!--<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:'#304156'}"
							border
							>
						    <!--<el-table-column
						      prop="b_id"
						      label="电池系列号"
						      :width="150"
							  :show-overflow-tooltip="true">
						    </el-table-column>
							-->
							<el-table-column
							  prop="b_code"
							  label="电池序列号"
							  :width="150"
							  :show-overflow-tooltip="true">
							</el-table-column>
							<el-table-column
							  prop="sid"
							  label="仪器系列号"
							  :width="150"
							  :show-overflow-tooltip="true">
							</el-table-column>
							<el-table-column
							  prop="iid"
							  label="仪器序列号"
							  :width="150"
							  :show-overflow-tooltip="true">
							</el-table-column>
						    
							<el-table-column
							      label="操作"
							      width="100"
								  v-if="if_show_1">
							      <template slot-scope="scope">
									  <el-button @click="update_nbs(scope.row)" type="text" size="medium">修改</el-button>
									  <el-button @click="remove_battery_base(scope.row)" type="text" size="medium">删除</el-button>
									</template>
							    </el-table-column>
						  </el-table>
					</div>
					<div class="block">
					    <span class="demonstration" style="background-color: #ECF5FF;"></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" style="background-color: #ECF5FF;">
					    </el-pagination>
					  </div>
				</div>
				
				<div style="float: left;margin-left: 20px;width: 40%;">
					<div style="display: inline-block;width: 100%;">
						<div style="display: inline-flex;">
							<el-input style="background-color: #ECF5FF;" v-model="b_code_v_1" placeholder="电池序列号" clearable  @change="input_change_1"></el-input>
							<el-button style="margin-left: 5px;" id ="bt_serach_1" plain type="primary" icon="el-icon-search" @click="get_b_life()">搜索</el-button>
							<el-button style="margin-left: 5px;" v-if="if_show_1" id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="add_blife_dialog()">新增</el-button>
						</div>
						<div class="span" style="width: 100%;">
							<el-table
							    :data="tableData1"
							    style="width: 100%;font-size:14px"
							    :height="tHeight"
								:cell-style="{background:'#304156'}"
								border
								>
							    <!--<el-table-column
							      prop="b_id"
							      label="电池系列号"
							      :width="150"
								  :show-overflow-tooltip="true">
							    </el-table-column>
								-->
								<el-table-column
								  prop="b_code"
								  label="电池序列号"
								  :width="150"
								  :show-overflow-tooltip="true">
								</el-table-column>
								<el-table-column
								  prop="b_life"
								  label="电池寿命(h)"
								  :width="150"
								  :show-overflow-tooltip="true">
								</el-table-column>
							    
								<el-table-column
								      label="操作"
								      width="100"
									  v-if="if_show_1">
								      <template slot-scope="scope">
										  <el-button @click="update_blife(scope.row)" type="text" size="medium">修改</el-button>
										  <el-button @click="remove_blife(scope.row)" type="text" size="medium">删除</el-button>
										</template>
								    </el-table-column>
							  </el-table>
						</div>
						<div class="block">
						    <span class="demonstration" style="background-color: #ECF5FF;"></span>
						    <el-pagination
						      @size-change="handleSizeChange1"
						      @current-change="handleCurrentChange"
						      :current-page="currentPage1"
						      :page-sizes="[50,100, 200, 300]"
						      :page-size="pagesize1"
						      layout="total, sizes, prev, pager, next, jumper"
						      :total="recordTotal1" style="background-color: #ECF5FF;">
						    </el-pagination>
						  </div>
					</div>
					
				</div>
				
			</div>
			
			  <el-dialog
			   title="电池信息"
			   :visible.sync="add_visible"
			   :lock-scroll ="false"
			   width="45%">
			   <el-form ref="bform" :model="form" :rules="rules" label-width="100px" :inline="false" class="demo-form-inline" size="medium">
			  	  
				  <el-row :gutter="10">
					  <el-col :span="12">
						  <el-form-item label="短节系列号" 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="短节序列号" 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="电池系列号" 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="电池序列号" 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">取 消</el-button>
			   <el-button id ="bt_ok" plain type="primary" @click="add_battery_base()">确 定</el-button>
			   </span>
			  </el-dialog>
			  
			  <el-dialog
			   title="电池信息"
			   :visible.sync="update_visible"
			   :lock-scroll ="false"
			   width="45%">
			   <el-form ref="bform" :model="form" :rules="rules" label-width="100px" :inline="false" class="demo-form-inline" size="medium">
			  				  <el-row :gutter="10">
			  					  <el-col :span="12">
			  						  <el-form-item label="短节系列号" 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="短节序列号" 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="电池系列号" 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="电池序列号" 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">取 消</el-button>
			   <el-button id ="bt_ok" plain type="primary" @click="update_battery_base()">确 定</el-button>
			   </span>
			  </el-dialog>
			  
			  <el-dialog
			   title="电池寿命"
			   :visible.sync="add_visible_1"
			   :lock-scroll ="false"
			   width="45%">
			   <el-form ref="bform" :model="form1" :rules="rules" label-width="100px" :inline="false" class="demo-form-inline" size="medium">
			  	  
				  <el-row :gutter="10">
					  <el-col :span="12">
						  <el-form-item label="电池序列号" prop="battery_num">
						  <el-input v-model="form1.battery_num" ></el-input>
						  </el-form-item>
					  </el-col>
					  <el-col :span="12">
						  <el-form-item label="电池寿命" prop="b_life">
						  <el-input v-model="form1.b_life" ></el-input>
						  </el-form-item>
					  </el-col>
				  </el-row>
			   </el-form>
			   <span slot="footer" class="dialog-footer">
			   <el-button @click="add_visible_1 = false">取 消</el-button>
			   <el-button id ="bt_ok" plain type="primary" @click="add_b_life()">确 定</el-button>
			   </span>
			  </el-dialog>
			  
			  <el-dialog
			   title="电池信息"
			   :visible.sync="update_visible_1"
			   :lock-scroll ="false"
			   width="45%">
			   <el-form ref="bform" :model="form1" :rules="rules" label-width="100px" :inline="false" class="demo-form-inline" size="medium">
			  		<el-row :gutter="10">
						  <el-col :span="12">
							  <el-form-item label="电池序列号" prop="battery_num">
							  <el-input v-model="form1.battery_num" :disabled="true"></el-input>
							  </el-form-item>
						  </el-col>
						  <el-col :span="12">
							  <el-form-item label="电池寿命" prop="b_life">
							  <el-input v-model="form1.b_life" ></el-input>
							  </el-form-item>
						  </el-col>
			  		</el-row>
			   </el-form>
			   <span slot="footer" class="dialog-footer">
			   <el-button @click="update_visible_1 = false">取 消</el-button>
			   <el-button id ="bt_ok" plain type="primary" @click="update_b_life()">确 定</el-button>
			   </span>
			  </el-dialog>
		</div>
		`,
	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,
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid")
			  })
			  .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,
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid")
			  })
			  .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();
				
		},
		
	  }
	}
			