
//授权组件
	var mhComponent = {
		template:`
		<div>
			<div v-show="if_show0">
				<div id="" style="display: inline-block;width: 100%;margin-top: 10px;">
				
					<div  style="float: left; width: 15%;background-color: #ECF5FF;">
					<el-input v-model="input" placeholder="请输入井名" clearable></el-input>
					</div>
					<div style="float: left;background-color: #ECF5FF;">
					 <el-date-picker
						v-if="if_show_bt==1"
					      v-model="date_value"
					      type="datetimerange"
					      range-separator="至"
					      start-placeholder="上传开始日期"
					      end-placeholder="上传结束日期"
						  value-format="yyyy-MM-dd HH:mm:ss">
					    </el-date-picker>
						<el-date-picker
							v-if="if_show_bt==2"
						     v-model="date_value"
						     type="datetimerange"
						     range-separator="至"
						     start-placeholder="上传开始日期"
						     end-placeholder="上传结束日期"
							 format="MM-dd-yyyy HH:mm:ss"
							value-format="yyyy-MM-dd HH:mm:ss">
						   </el-date-picker>
						<el-date-picker
							v-if="if_show_bt==3"
						     v-model="date_value"
						     type="datetimerange"
						     range-separator="至"
						     start-placeholder="上传开始日期"
						     end-placeholder="上传结束日期"
							 format="dd-MM-yyyy HH:mm:ss"
							value-format="yyyy-MM-dd HH:mm:ss">
						   </el-date-picker>
					</div>
					<div style="float: left;margin-left: 5px;">
						<el-checkbox style="background-color: #ECF5FF;" v-model="checked" label="全部" border></el-checkbox>
					</div>
					
					<div style="float:left;margin-left: 5px;">
						<el-checkbox style="background-color: #ECF5FF;" v-model="checked1" label="工程服务" border></el-checkbox>
					</div>
					
					<div style="float: left;margin-left: 5px;">
						<el-button id ="bt_serach" plain type="primary" icon="el-icon-search" @click="getMh(input)">搜索</el-button>
					</div>
					<div style="float: left; margin-left: 5px;">
						<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportMh()">导出</el-button>
					</div>
									
				</div>
				<div class="span">
					<el-table
					:data="tableData"
					style="width: 100%"
					:height="tHeight"
					:cell-style="{background:'#304156'}"
					border
					>
						<el-table-column
							prop="wellname"
							label="井名称"
							:width="150"
							:show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
							prop="welloper"
							label="操作人员"
							:width="150"
							:show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
							prop="state"
							label="施工状态"
							:width="100">
						</el-table-column>
						<el-table-column
							prop="wellCreateTime"
							label="开始上传时间"
							:width="170">
						</el-table-column>
						<el-table-column
							prop="wellBeginTime"
							label="上井起始时间"
							:width="170">
						</el-table-column>
					  
						<el-table-column
							prop="wellEndTime"
							label="上井结束时间"
							:width="170">
						</el-table-column>
						
						<el-table-column
							prop="wellWorkTime"
							label="工作时间"
							:width="100">
						</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 v-show="if_show" style="text-align: center; width: 100%;;font-size: 14px;">
			  <el-tag type="warning" style="width: 100%;height: 50px;font-size: 14px;">用户没有本菜单权限!</el-tag>
			</div>
		</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,
		tableData: [],
		input:'',
		currentPage: 1,
		pagesize:50,
		recordTotal:0,
		date_value:[],
		checked:false,
		
		if_show0:false,
		if_show:false,
		
		checked1:false,
		
		if_show_bt:1,
		if_show_et:false,
	  }
	},
	mounted() {
		
		if (localStorage.getItem("level")==4) {
			this.$data.if_show = true;
			return;
		}
		this.$data.if_show0= true;
		
		var _this = this;
		
		axios.post('/deescloud/get_page_setting', {
			opuser:localStorage.getItem("online_user"),
			opuser_uuid:localStorage.getItem("uuid"),
		  })
		  .then(function (response) {
				if(response.data.r3=="1"){
					_this.$data.if_show_bt=1;
					//_this.$data.if_show_et=false;
				}else if(response.data.r3=="2"){
					//_this.$data.if_show_et=true;
					_this.$data.if_show_bt=2;
				}else if(response.data.r3=="3"){
					//_this.$data.if_show_et=true;
					_this.$data.if_show_bt=3;
				}else{
					_this.$data.if_show_bt=1;
				}
		  })
		  .catch(function (error) {
		    console.log(error);
		  });
		
		var objs;
		axios.post('/deescloud/getMh', {
			opuser:localStorage.getItem("online_user"),
			opuser_uuid:localStorage.getItem("uuid"),
			index: this.$data.currentPage,
			count: this.$data.pagesize,
			if_all:this.$data.checked,
			checked:this.$data.checked1
		  })
		  .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: {
		
		exportMh(){
			document.getElementById("bt_export").blur();
			
			var beginTime= '';
			var endTime = '';
			
			if (this.$data.date_value != null && this.$data.date_value.length > 1) {
				console.log("len:",this.$data.date_value.length)
				console.log("date_value:",this.$data.date_value);
				beginTime = this.$data.date_value[0];
				endTime = this.$data.date_value[1];
			}
			
			axios.post('deescloud/getMhCsv',{
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid"),
				wellname: this.$data.input,
				beginTime:beginTime,
				endTime:endTime,
				if_all:this.$data.checked,
				checked:this.$data.checked1
			}
			).then(function (response) {
				console.log(response.data);
				var fileid = response.data.fileId;
				
				var downUrl = 'file/'+fileid;
				downloadUrl("工时统计.csv",downUrl);
			})
			.catch(function (error) {
				console.log(error);
			});
		},

		getMh(_search_name){
			document.getElementById("bt_serach").blur();
			
			var beginTime= '';
			var endTime = '';
			
			if (this.$data.date_value != null && this.$data.date_value.length > 1) {
				console.log("len:",this.$data.date_value.length)
				console.log("date_value:",this.$data.date_value);
				beginTime = this.$data.date_value[0];
				endTime = this.$data.date_value[1];
			}
			
			this.$data.currentPage=1;
			
			var _this = this;
			
			var objs;
			axios.post('/deescloud/getMh', {
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid"),
				id: _search_name,
				beginTime:beginTime,
				endTime:endTime,
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				if_all:this.$data.checked,
				checked:this.$data.checked1
			  })
			  .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) {
			var beginTime= '';
			var endTime = '';
			this.$data.currentPage = 1;
			if (this.$data.date_value != null && this.$data.date_value.length > 1) {
				console.log("len:",this.$data.date_value.length)
				console.log("date_value:",this.$data.date_value);
				beginTime = this.$data.date_value[0];
				endTime = this.$data.date_value[1];
			}
			
			  this.$data.pagesize = val;
			  
			  var _this = this;
			  
			  var objs;
			  axios.post('/deescloud/getMh', {
				  opuser:localStorage.getItem("online_user"),
				  opuser_uuid:localStorage.getItem("uuid"),
					id: this.$data.input,
					beginTime:beginTime,
					endTime:endTime,
					index: this.$data.currentPage,
					count: this.$data.pagesize,
					if_all:this.$data.checked,
					checked:this.$data.checked1
				})
				.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) {
			var beginTime= '';
			var endTime = '';
			
			if (this.$data.date_value != null && this.$data.date_value.length > 1) {
				console.log("len:",this.$data.date_value.length)
				console.log("date_value:",this.$data.date_value);
				beginTime = this.$data.date_value[0];
				endTime = this.$data.date_value[1];
			}
			
		  this.$data.currentPage = val;
		  
		  var _this = this;
		  
		  var objs;
		  axios.post('/deescloud/getMh', {
			  opuser:localStorage.getItem("online_user"),
			  opuser_uuid:localStorage.getItem("uuid"),
					id: this.$data.input,
					beginTime:beginTime,
					endTime:endTime,
					index: this.$data.currentPage,
					count: this.$data.pagesize,
					if_all:this.$data.checked,
					checked:this.$data.checked1
				})
				.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);
				});
		},
		
	  }
	}
			