	var Paymentcomponent = {
		template:`
		<div>
			<div id="" style="display: flex">
				<el-input v-model="supplier_v" placeholder="供应商" clearable style="width: 150px;" @change="input_change"></el-input>
				<el-input v-model="code_v" placeholder="编号" clearable style="width: 150px;" @change="input_change"></el-input>
				<el-input v-model="name_v" placeholder="名称" clearable style="width: 150px;" @change="input_change"></el-input>
				<!--<el-date-picker
					style="width: 150px;"
					 v-model="begin_t_v"
					 type="date"
					 placeholder="开始日期"
					 format="yyyy-MM-dd"
					 value-format="yyyy/MM/dd"
					 >
				</el-date-picker>
				<el-date-picker
					style="width: 150px;"
					 v-model="end_t_v"
					 type="date"
					 placeholder="结束日期"
					 format="yyyy-MM-dd"
					 value-format="yyyy/MM/dd"
					 >
				</el-date-picker>
				-->
				<el-button id ="bt_search" plain type="primary" icon="el-icon-search" @click="get_payment()">搜索</el-button>
				<!--<el-button plain type="primary" icon="el-icon-circle-plus-outline" @click="importCsv()">导入审批物料</el-button>
				<el-button style="margin-left: 10px;" id ="bt_export" plain type="primary" icon="el-icon-document" @click="exportSap()">导出</el-button>
				-->
			</div>
			<div>
				<el-progress v-if="if_show_process" :percentage="percent_len" ></el-progress>
			</div>
			<div class="span">
				<el-table
				    :data="tableData"
				    style="width: 100%"
				    :height="tHeight"
					:cell-style="{background:'#fff'}"
					border
					@selection-change="handleSelectionChange"
					>
					<!--
					<el-table-column
					  type="selection"
					  >
					</el-table-column>
					-->
					<el-table-column
					  prop="id"
					  label="序号"
					  width="60">
					</el-table-column>
				    <el-table-column
				      prop="supplier"
				      label="供应商"
				      width="100"
					  :show-overflow-tooltip="true">
				    </el-table-column>
					
					<el-table-column
						prop="code"
						label="编号"
						width="100"
						:show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
						prop="name"
						label="名称"
						width="120"
						:show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
						prop="spec"
						label="规格"
						width="100"
						:show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
						prop="unit"
						label="单位"
						width="60"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="num"
						label="数量"
						width="60"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="price"
						label="单价"
						width="60"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="pt"
						label="付款方式"
						width="80"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="total_p"
						label="合计"
						width="120"
						:show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
						prop="paid"
						label="已付"
						width="120"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="rp"
						label="应付"
						width="120"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  label="操作"
					  width="100">
					  <template slot-scope="scope">
						<el-button @click="update_p(scope.row)" type="text" size="medium" >付款详情</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="支付详情"
				 :visible.sync="dialogVisible"
				 :lock-scroll ="false"
				 width="40%"
				 style="height: 100%;">
					<div>
						<el-button id ="bt_add" plain type="primary" icon="el-icon-circle-plus-outline" @click="showAddkpiplan_1()">新增付款</el-button>
						<span style="margin-left: 10px;">合计：{{row.total_p}}</span>
						<span style="margin-left: 10px;">已付：{{row.paid}}</span>
						<span style="margin-left: 10px;">应付：{{row.rp}}</span>
					</div>
					<el-table
						    :data="row.payment_data"
						    style="font-size:13px;margin-top: 10px;width: 100%;"
							:height="tHeight*0.5"
							:cell-style="{background:'#fff'}"
							stripe border>
							
							<el-table-column
							  prop="payment_month"
							  label="待付月份"
							  width="120"
							  :show-overflow-tooltip="true">
							</el-table-column>
							<el-table-column
								prop="payment"
								label="支付金额"
								width="120"
								:show-overflow-tooltip="true">
							</el-table-column>
							<el-table-column
								prop="payment_user"
								label="支付人"
								width="120"
								:show-overflow-tooltip="true">
							</el-table-column>
							<el-table-column
								  label="操作"
								  width="120">
								  <template slot-scope="scope">
									  <el-button @click="show_updateplan_dialog(scope.row)" type="text" size="medium" >修改</el-button>
									  <el-button @click="delKpiplan(scope.row)" type="text" size="medium" >删除</el-button>
									  <!--<el-button v-if="approve_flag" @click="approve_plan(scope.row)" type="text" size="medium" >审核</el-button>-->
								  </template>
								</el-table-column>
						  </el-table>
					
					 <span slot="footer" class="dialog-footer">
					 <el-button @click="dialogVisible = false">取 消</el-button>
					 <el-button id ="bt_ok" plain type="primary" @click="post_p()">确 定</el-button>
					 </span>
			  </el-dialog>
			  
			  <el-dialog
			  v-dialogDrag
			   title="付款信息"
			   :visible.sync="addplanVisible_1"
			   :lock-scroll ="false"
			   width="45%">
			   <el-form ref="planform_1" :model="planform" :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="payment_month">
			  			  <el-date-picker
			  					v-model="planform.payment_month"
			  					type="date"
			  					placeholder="支付月份"
			  				  style="width: 190px;"
			  				  format="yyyy/MM/dd"
			  				  value-format="yyyy/MM/dd">
			  			  </el-date-picker>
			  			  </el-form-item>
			  		  </el-col>
					  <el-col :span="12">
						  <el-form-item label="付款金额" prop="payment">
						  <el-input-number v-model="planform.payment" :min="0" ></el-input-number>
						  </el-form-item>
					  </el-col>
			  		</el-row>
					<el-row :gutter="10">
						  <el-col :span="12">
							  <el-form-item label="支付人" prop="payment_user">
							  <el-input v-model="planform.payment_user"  ></el-input>
							  </el-form-item>
						  </el-col>
					</el-row>
			   </el-form>
			   <span slot="footer" class="dialog-footer">
			   <el-button @click="addplanVisible_1 = false">取 消</el-button>
			   <el-button id ="bt_ok" plain type="primary" @click="addkpiplan_1();">确 定</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-40-232,
			tableData: [],
			currentPage: 1,
			pagesize:50,
			recordTotal:0,
			code_v:'',
			name_v:'',
			supplier_v:'',
			
			row:'',
			dialogVisible:false,
			oper_type:0,
			rules: {
			    p_id: [
			        { required: true, message: '产品编号不可为空', trigger: 'blur' }
			    ],
			    p_name: [
			        { required: true, message: '产品名称不可为空', trigger: 'blur' }
			    ],
				payment_month: [
				    { required: true, message: '月份不可为空', trigger: 'blur' }
				],
				payment: [
				    { required: true, message: '支付金额不可为空', trigger: 'blur' }
				],
			},
			multipleSelection: [],
			importdialogVisible:false,
			fileListUpload:[],
			importTableData:[],
			disabled:true,
			
			if_show_process:false,
			percent_len:0,
			interval:'',
			if_show_process1:false,
			
			begin_t_v:'',
			end_t_v:'',
			
			//payment_data:'',
			
			addplanVisible_1:false,
			maxid:-1,
			planform: {
				id:0,
				payment_month:'',
				payment:'',
				payment_user:'',
			},
			plan_op_type:0,
		  }
		},
		mounted() {
			this.get_payment()
		},
	  methods: {
		delKpiplan(row){
			var index =-1;
			for(var i=0;i<this.$data.row.payment_data.length;++i){
				if(this.$data.row.payment_data[i].id==row.id){
					index=i;
					break;
				}
			}
			if (index > -1) { 
				this.$data.row.payment_data.splice(index, 1); 
			} 
			
			var total =0
			for(var i=0;i<this.$data.row.payment_data.length;++i){
				var t = parseFloat(this.$data.row.payment_data[i].payment)
				total = total+t;
			}
			console.log("已付：",total);
			this.$data.row.paid=total.toString();
			
			var t = parseFloat(this.$data.row.total_p)
			if (t>total){
				this.$data.row.rp = (t-total).toString();
			}
			
		},
		show_updateplan_dialog(row){
			
			this.$data.planform.payment_month=row.payment_month;
			this.$data.planform.payment=row.payment;
			this.$data.planform.payment_user=row.payment_user;
			this.$data.planform.id =row.id;
			
			this.$data.plan_op_type=2;
			this.$nextTick(() => {
				this.$refs['planform_1'].clearValidate()
			});
			this.$data.addplanVisible_1=true;
		},
		addkpiplan_1(){
			
			this.$refs['planform_1'].validate((valid) => {
				if (valid) {
					if (this.$data.plan_op_type==1) {
						var obj ={
							id:this.$data.maxid,
							payment_month:this.$data.planform.payment_month,
							payment:this.$data.planform.payment.toString(),
							payment_user:this.$data.planform.payment_user,
						}
						this.$data.row.payment_data.push(obj);
						
						this.$data.maxid+=1;
						console.log("id:",this.$data.maxid);
					} else if (this.$data.plan_op_type==2){
						for(var i=0;i<this.$data.row.payment_data.length;++i){
							if(this.$data.row.payment_data[i].id==this.$data.planform.id){
								this.$data.row.payment_data[i].payment_month=this.$data.planform.payment_month;
								this.$data.row.payment_data[i].payment=this.$data.planform.payment.toString();
								this.$data.row.payment_data[i].payment_user=this.$data.planform.payment_user;
								console.log(this.$data.row);
								break;
							}
						}
					}
					
					var total =0
					for(var i=0;i<this.$data.row.payment_data.length;++i){
						var t = parseFloat(this.$data.row.payment_data[i].payment)
						total = total+t;
					}
					console.log("已付：",total);
					this.$data.row.paid=total.toString();
					
					var t = parseFloat(this.$data.row.total_p)
					if (t>total){
						this.$data.row.rp = (t-total).toString();
					}
					
					this.$data.addplanVisible_1 = false;
				}
			});
		},
		showAddkpiplan_1(){
			this.$data.planform.payment_month='';
			this.$data.planform.payment='';
			this.$data.planform.payment_user='';
			this.$data.plan_op_type=1;
			
			for (var i = 0; i < this.$data.row.payment_data.length; i++) {
				 if(this.$data.row.payment_data[i].id >this.$data.maxid){
					 this.$data.maxid = this.$data.row.payment_data[i].id
				 }
			}
			if(this.$data.maxid !=-1){
				this.$data.maxid+=1;
			}else{
				this.$data.maxid = 0;
			}
			
			this.$nextTick(() => {
				this.$refs['planform_1'].clearValidate()
			});
			this.$data.addplanVisible_1=true;
		},
		download_template(){
			document.getElementById("bt_download").blur();
			
			var downUrl = '/pp/download_file'+"?id="+"审批导入.csv";
			downloadUrl("导入审批物料模版.csv",downUrl);
		},
		
		input_change(value) {
			console.log(value);
			this.get_payment();
		},
		exportSap(){
			document.getElementById("bt_export").blur();
			
			var _this = this;
			var objs;
			axios.post('/u_ma/export_sap', {
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid"),
				p_id: _this.$data.p_id_v,
				p_name: _this.$data.p_name_v,
			  })
			  .then(function (response) {
				console.log(response.data);
				var fileid = response.data.fileId;
				
				var downUrl = '/u_ma/download_file'+"?id="+fileid;
				downloadUrl("产品编码名称.csv",downUrl);
			  })
			  .catch(function (error) {
				console.log(error);
			  });
		},
		
			importData(){
				document.getElementById("bt_import").blur();
				if(this.$data.importTableData.length==0){
				   this.$message({
					message: "请选择导入文件",
					type: "warning",
					duration: 1500
				   });
				   return;
				}
				
				  this.$confirm('是否确认导入?', '提示', {
					  confirmButtonText: '确定',
					  cancelButtonText: '取消',
					  type: 'warning'
					}).then(() => {
					  var _this = this;
					  _this.$data.percent_len=0;
					  _this.$data.if_show_process1=true;
					  _this.$data.interval= setInterval(()=>{
					     if(_this.$data.percent_len>=99){
					  		clearInterval(_this.$data.interval);
					  		return;
					     }
					     
					     if (_this.$data.percent_len<98){
					  	   _this.$data.percent_len+=2
					     }
					  },20)
					  
					  axios.post('/pp/import_approve_m', {
					  	opuser:localStorage.getItem("online_user"),
					  	opuser_uuid:localStorage.getItem("uuid"),
					  	data:this.$data.importTableData,
					  })
					  .then(function (response) {
					  							
					  	let r = response.data.r;
					  	let s = ""
					  	let errType = ""
					  	if (r == 0) {
					  		let len = _this.$data.importTableData.length;
					  		errType = "success"
					  		s = "导入"+len+"条物料成功！";
					  		_this.$data.percent_len=100;
					  		_this.$data.if_show_process1=false;
					  	} else if(r == 1) {
					  		errType = "error"
					  		s = "正在导入物料，请稍后！";
					  		clearInterval(_this.$data.interval);
					  	} else{
					  		errType = "error"
					  		s = "导入物料失败！";
					  		clearInterval(_this.$data.interval);
					  	}
						
						console.log(s);
						_this.$message({
							message: s,
							type: errType,
							duration: 3000
						});
					  					
					  	_this.$data.importdialogVisible=false;
					  	//更新页面
					  	//_this.get_p();
					  })
					  .catch(function (error) {
					  	console.log(error);
					  });
					}).catch(() => {
					  this.$message({
						type: 'info',
						message: '已取消'
					  });
					return;
					});
			},
			handleChange(file, fileList) {
			   document.getElementById("bt_upload").blur();
			   
				this.fileTemp = file.raw
				console.log("filetype:",this.fileTemp);
		     	if (this.fileTemp) {
					console.log("begin ...")
					console.log(this.fileTemp.type);
		        	if ((this.fileTemp.type == 'text/csv') || (this.fileTemp.type == '.csv') || (this.fileTemp.type == 'application/vnd.ms-excel')) {
						let _this = this//如果需要点击事件结束之后对DOM进行操作使用)_this.xx=xx进行操作
						Papa.parse(_this.fileTemp, {
						  encoding:'gb2312',
						  complete (results) {
							console.log(results)//这个是csv文件的数据
							let data = []
							//遍历csv文件中的数据，存放到data中 方法不唯一，可自己更改
							for (let i = 0; i < results.data.length; ++i) {
								if(i==0){
									continue;
								}
								let obj = {}
								obj.supplier = results.data[i][0]
								if(obj.supplier==""|| obj.supplier==undefined){
									continue;
								}
								obj.supplier_code = results.data[i][1]
								if(obj.supplier_code==""|| obj.supplier_code==undefined){
									continue;
								}
								obj.pt = results.data[i][2]
								if(obj.pt==""|| obj.pt==undefined){
									continue;
								}
								
								obj.code = results.data[i][3]
								if(obj.code==""|| obj.code==undefined){
									continue;
								}
								
								obj.name = results.data[i][4]
								if(obj.name==""|| obj.name==undefined){
									continue;
								}
								
								obj.spec = results.data[i][5]
								if(obj.spec==""|| obj.spec==undefined){
									continue;
								}
								
								obj.unit = results.data[i][6]
								if(obj.unit==""|| obj.unit==undefined){
									continue;
								}
								
								obj.price = results.data[i][7]
								if(obj.price==""|| obj.price==undefined){
									continue;
								}
								
								obj.update_date = results.data[i][8]
								if(obj.update_date==""|| obj.update_date==undefined){
									continue;
								}
								
								obj.pc = results.data[i][9]
								if(obj.pc==""|| obj.pc==undefined){
									continue;
								}
								
								obj.vpoq = results.data[i][10]
								if(obj.vpoq==""|| obj.vpoq==undefined){
									continue;
								}
								
								data.push(obj)
							}
							//data.splice(0, 1)//将数组第一位的表格名称去除
							let num = 0
							console.log('data', data)
							_this.$data.importTableData=data;
						  }
						})
								
					} else {
						this.$data.fileListUpload=[];
						this.$message({
						type: 'warning',
							message: '附件格式错误，请删除后重新上传！'
						})
					}
		     	} else {
		      	this.$message({
		     			type: 'warning',
		              message: '请上传附件！'
		          	})
		    		}
		  },
		
		  importCsv(){
			  this.$data.fileListUpload=[];
			  this.$data.importTableData=[];
			  this.$data.importdialogVisible=true;
		  },
		importDialog_close(done){
		  done();
		},
		handleSelectionChange(val) {
			console.log("已选择");
			console.log(val);
			this.multipleSelection = val;
		},

		post_p(){
			this.$data.dialogVisible = false;
			  
			var _this = this;
			 
			 var objs;
			 axios.post('/pp/update_payment', {
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid"),
				data: _this.$data.row,
			})
			.then(function (response) {
				
				let r = response.data.r;
				let s = ""
				let errType = ""
				if (r == 0) {
					errType = "success"
				} else{
					errType = "error"
				}
				
				if (r ==0) {
					s = "修改成功！";
				} else{
					s = "修改失败！";
				}
				
				_this.$message({
					message: s,
					type: errType,
					duration: 1500
				});
				
				//更新页面
				_this.get_payment();
			})
			.catch(function (error) {
			  console.log(error);
			});
		},

		del_p(){
			var _this = this;
		  
		   axios.post('/u_ma/del_p', {
			opuser:localStorage.getItem("online_user"),
			opuser_uuid:localStorage.getItem("uuid"),
			ids: _this.$data.multipleSelection,
		  })
		  .then(function (response) {
			
			let r = response.data.r;
			let s = ""
			let errType = ""
			if (r == 0) {
				s = "删除产品信息成功！";
				errType = "success"
			} else{
				s = "删除产品信息失败！";
				errType = "error"
			}

			_this.$message({
				message: s,
				type: errType,
				duration: 1500
			});
			
			if (r ==0) {
				_this.get_p();//更新页面
			}
			
		  })
		  .catch(function (error) {
			console.log(error);
		  });
		},

		add_p(){
			document.getElementById("bt_add").blur();
			
			this.$data.disabled=false;
			this.$data.oper_type = 1;
			this.$data.form = {
				id:'',
				p_id: '',
				p_name:'',
			};
	
			this.$nextTick(() => {
				this.$refs['form_p'].clearValidate()
			});
	
			this.$data.dialogVisible = true;
		},

		update_p(info){
			this.$data.disabled=true;
		  this.$data.oper_type = 2;
		  this.$data.row = {
			  id:info.id,
			  supplier:info.supplier,
			  code:info.code,
			  name:info.name,
			  spec:info.spec,
			  unit:info.unit,
			  num:info.num,
			  price:info.price,
			  pt:info.pt,
			  total_p:info.total_p,
			  paid:info.paid,
			  rp:info.rp,
			  payment_data:[],
			  pre_id:info.pre_id,
		  };
		  for(var i=0;i<info.payment_data.length;++i){
			  var obj={
				  payment_month:info.payment_data[i].payment_month,
				  payment:info.payment_data[i].payment,
				  payment_user:info.payment_data[i].payment_user,
			  }
			  this.$data.row.payment_data.push(obj);
		  }
		  
		  this.$nextTick(() => {
			  this.$refs['form_p'].clearValidate()
		  });
		  this.$data.dialogVisible = true;
		},

		get_payment(){
			document.getElementById("bt_search").blur();	
			
			this.$data.currentPage=1;

			var _this = this;

			var objs;
			axios.post('/pp/get_payment', {
				opuser:localStorage.getItem("online_user"),
				opuser_uuid:localStorage.getItem("uuid"),
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				code: this.$data.code_v,
				name:this.$data.name_v,
				supplier:this.$data.supplier_v,
			  })
			  .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) {
		  this.$data.pagesize = val;
		  
		  this.get_payment();
		},
		handleCurrentChange(val) {
		  this.$data.currentPage = val;
		  
		  this.get_payment();
		}
	  }
	}
			