
var Wellcomponent = {
	template: `
		<div>
			<div style="display: flex;">
				<el-input v-model="id_v" placeholder="序号" clearable style="width: 100px;" @change="input_change"></el-input>
				<el-input v-model="rdm_v" placeholder="RDM" clearable style="width: 100px;" @change="input_change"></el-input>
				<!--
				 <el-date-picker
						style="width: 140px;"
				      v-model="bt_v"
				      type="date"
					  format="yyyy-MM-dd"
					  value-format="yyyy/MM/dd"
				      placeholder="开始日期">
				</el-date-picker>
				<el-date-picker
					style="width: 140px;"
				      v-model="et_v"
				      type="date"
					  format="yyyy-MM-dd"
					  value-format="yyyy/MM/dd"
				      placeholder="结束日期">
				</el-date-picker>
				-->
				<el-input v-model="msid_v" placeholder="六合编号" clearable style="width: 105px;" @change="input_change"></el-input>
				<el-input v-model="pname_v" placeholder="名称" clearable style="width: 105px;" @change="input_change"></el-input>
				<el-input v-model="supplier_v" placeholder="供应商" clearable style="width: 105px;" @change="input_change"></el-input>
				<el-select clearable v-model="state_v" placeholder="状态" style="width: 105px;" @change="input_change">
					<el-option label="待付款" value="待付款"></el-option>
					<el-option label="已付款" value="已付款"></el-option>
					<el-option label="交检" value="交检"></el-option>
					<el-option label="待签署" value="待签署"></el-option>
					<el-option label="已收货" value="已收货"></el-option>
					<el-option label="部分到货" value="部分到货"></el-option>
				</el-select>
				
				<el-select clearable filterable v-model="more_query_v" placeholder="更多查询"
					style="width: 110px;" @change="more_query_select">
				 <el-option-group
					   key="1"
					   label="">
					   <el-option label="采购人员" value="采购人员"></el-option>
				 </el-option-group>
				</el-select>
				<el-select v-if="more_query_v=='采购人员'" v-model="buyer_v" clearable filterable placeholder="请选择" style="width: 120px;" @change="input_change">
				  <el-option
					v-for="item in buyer_data"
					:key="item.value"
					:label="item.label"
					:value="item.value">
				  </el-option>
				</el-select>
				
				<el-checkbox style="margin: 0px;" v-model="checked" @change="if_fin_cahnge" border>已处理</el-checkbox>
				<el-checkbox style="margin: 0px;" v-model="warning_checked" @change="if_warning_checked" border>预警</el-checkbox>
				
				<el-button id ="bt_serach" plain type="primary" icon="el-icon-search" @click="search()" style="padding-left: 10px;padding-right: 10px;">搜索</el-button>
				<el-button id ="bt_add" plain type="primary" icon="el-icon-document-add" @click="importCsv()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">导入</el-button>
				<el-button id ="bt_add" plain type="primary" icon="el-icon-circle-check" @click="mul_update_pp_plan_num()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">批量到货</el-button>
				<el-button id ="bt_export" plain type="primary" icon="el-icon-document" @click="export_plan()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">应付款</el-button>
				<el-button id ="bt_export_1" plain type="primary" icon="el-icon-document" @click="export_plan_1()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">导出</el-button>
				<el-button id ="bt_contract" plain type="primary" icon="el-icon-circle-check" @click="contract_approval()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">合同审批</el-button>
				
				<el-button id ="bt_amount" plain type="primary" icon="el-icon-circle-check" @click="mul_payment_application()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">付款申请</el-button>
				<!--<el-button id ="bt_serach_1" plain type="primary" icon="el-icon-document" @click="get_ma_plan_1()" style="margin-left: 0px;padding-left: 10px;padding-right: 10px;">按我搜索</el-button>-->
			</div>
			
			<div>
				<el-progress v-if="if_show_process1" :percentage="percent_len1" ></el-progress>
			</div>
			
			<div >
				<div class="span">
					<el-table
					    :data="tableData"
					    style="width: 100%;font-size:14px"
					    :height="tHeight"
						:row-class-name="tableRowClassName"
						@selection-change="handleSelectionChange"
						border
						:row-style="selectedRowStyle"
						@cell-dblclick="celldblclick_1"
						:header-cell-style="tableHeaderColor"
						>
						
						<el-table-column
						  type="selection"
						  width="30"
						  >
						</el-table-column>
						
						<el-table-column
						  prop="id"
						  label="序号"
						  :width="flexColumnWidth('id',tableData,2)"  > 
						  <template slot-scope="scope">
							  <div >
								<el-tooltip v-if='scope.row.pre_id>0' placement="left-start" popper-class="" effect="light">
									<div  slot="content">主任务ID：{{scope.row.pre_id}}</div>
									<el-button  @click="get_pre_plan(scope.row.pre_id)" type="text" size="medium" >{{scope.row.id}}</el-button>
								</el-tooltip>
								<span v-if='scope.row.pre_id==0'>{{scope.row.id}}</span>
							  </div>
							  </template>
						</el-table-column>
						
						<el-table-column
						
						  label="合同状态"
						  :width="str_state_with('contract_name','contract_state',tableData)"
						  :show-overflow-tooltip="true">
						  <template slot-scope="scope">
						   {{scope.row.contract_state}}
						   <el-button v-if="scope.row.contract_name!=null&&scope.row.contract_name!=''"  type="text" @click="down_file_22(scope.row)" style="font-size:13px">-原始合同</el-button>
						  </template>
						</el-table-column>
						
						<el-table-column
						  prop="state_1"
						  label="付款审批"
						  :width="str_state_with('pay_contract_name','state_1',tableData)"
						  :show-overflow-tooltip="true">
					    <template slot-scope="scope">
					    <span v-if="scope.row.serial_num!=''&&scope.row.serial_num!=null ">已付款</span>
					    <span v-else>{{scope.row.state_1}}</span>
					     <el-button v-if="scope.row.pay_contract_name!=null&&scope.row.pay_contract_name!=''"  type="text" @click="down_file_23(scope.row)" style="font-size:13px" >-盖章合同</el-button>
                         </template>
						</el-table-column>
						
						<el-table-column
						  label="合同号"
						  :width="flexColumnWidth('contract_id',tableData,3)">
						  <template slot-scope="scope">
						  <span @dblclick="copyValue(scope.row,$event)" >{{scope.row.contract_id}}</span>
						  </template>
						</el-table-column>
						
						<el-table-column
						  label="付款流水号"
						  :width="flexColumnWidth('serial_num',tableData,5)"
						  :show-overflow-tooltip="true">
						  <template slot-scope="scope">
						  <span  @dblclick="copyValue(scope.row,$event)" >{{scope.row.serial_num}}</span>
						  </template>
						</el-table-column>
						
						
						<el-table-column
						  prop="state"
						  label="状态"
						 :width="flexColumnWidth('state',tableData,2)">
						</el-table-column>
						<el-table-column
						  label="RDM"
						  :width="flexColumnWidth('rdm',tableData,3)"
						  :show-overflow-tooltip="true">
						  <template slot-scope="scope">
						  <div v-for="(item, index) in scope.row.rdm.split(/[,，、 ]+/)" :key="index">                      
                             <el-button :style="scope.row.redmine_color" @click="to_redmine_1(item)" type="text" size="medium">{{item}}</el-button>
                           </div>
						  </template>
						</el-table-column>

						
					    <el-table-column
					      prop="code"
					      label="六合编号"
						  :width="flexColumnWidth('code',tableData)"
						  :show-overflow-tooltip="true">
						  <template slot-scope="scope">
						  <span @dblclick="copyValue(scope.row,$event)" >{{scope.row.code}}</span>
						  </template>
					    </el-table-column>
						
						
						<el-table-column
						  prop="name"
						  label="名称"
						 :width="flexColumnWidth('name',tableData,2)">
						</el-table-column>
						<el-table-column
						  prop="specs"
						  label="规格"
						 :width="flexColumnWidth('specs',tableData)"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="unit"
						  label="单位"
						  align="center"
						 :width="flexColumnWidth('unit',tableData,2)"
						>
						</el-table-column>
						<el-table-column
						  prop="aqt"
						  label="数量"
						 :width="flexColumnWidth('aqt',tableData,2)"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="price"
						  label="单价"
						 :width="flexColumnWidth('price',tableData)">
						 <template slot-scope="scope">
							<div>{{convert(scope.row.price)}}</div>
						 </template>
						</el-table-column>
						
						<el-table-column
						  prop="total_p"
						  label="合计"
						 :width="flexColumnWidth('total_p',tableData,2)"
						 :show-overflow-tooltip="true"
						 >
						 <template slot-scope="scope">
							<div style="float: right; padding-right: 5px;" @dblclick="copyValue(scope.row,$event)">{{convert(scope.row.total_p)}}</div>
						 </template>
						</el-table-column>
						
				
						
						<el-table-column
						  prop="pt"
						  label="付款方式"
						 :width="flexColumnWidth('pt',tableData)">
						</el-table-column>
						
						<el-table-column
						  prop="paid"
						  label="已付"
						  :width="paid_with()?flexColumnWidth('paid',tableData,2)+25:flexColumnWidth('paid',tableData,2)">
						 <template slot-scope="scope">
							<el-button v-if='scope.row.flag!="1"'  @click="show_payment(scope.row)" type="text" size="medium" >更新</el-button>
							
							<span style="float: right; padding-right: 3px;">{{convert(scope.row.paid)}}</span>
						 </template>
						</el-table-column>
						<el-table-column
						  prop="rp"
						  label="应付"
						 :width="flexColumnWidth('rp',tableData,2)">
						 <template slot-scope="scope">
							<div style="float: right; padding-right: 3px;">{{convert(scope.row.rp)}}</div>
						 </template>
						</el-table-column>
						
						<el-table-column
						  prop="demand_date"
						  label="交付日期"
						 width="65"
						 :show-overflow-tooltip="true">
						 <template slot-scope="scope">
							<span v-if='scope.row.dduc==1' style="color: #ffd04b;">{{scope.row.demand_date}}</span>
							<span v-if='scope.row.dduc>1' style="color: red;" >{{scope.row.demand_date}}</span>
							<span v-if='scope.row.dduc<1' >{{scope.row.demand_date}}</span>
						 </template>
						</el-table-column>
						<el-table-column
						  label="采购周期"
						 width="65"
						 :show-overflow-tooltip="true">
						 <template slot-scope="scope">
						 <span style="float:right">{{scope.row.purchasing_cycle}}</span>
						 </template>
						</el-table-column>
						
						<el-table-column
						  prop="order_date"
						  label="下单日期"
						 :width="65">
						</el-table-column>
						<el-table-column
						  prop="over_due1"
						  label="预计超期"
						 :width="65"
						 :show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
						  label="剩余"
						 :width="flexColumnWidth('residue',tableData,2)">
						 <template slot-scope="scope">
						 <span>{{scope.row.residue}}</span>
						 </template>
						</el-table-column>
						
						<el-table-column
						  prop="add"
						  label="实际交付"
						 width="65"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="over_due2"
						  label="超期"
						 :width="flexColumnWidth('over_due2',tableData,2)"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="buy_record"
						  label="采购记录"
						 width="65"
						 :show-overflow-tooltip="true">
							 <template slot-scope="scope">
								<el-button v-if='scope.row.buy_record!=""' @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
								<el-button v-if='scope.row.buy_record==""' style="color: #C0C4CC;" @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
							 </template>
						</el-table-column>
						<!--<el-table-column
						  prop="aqt"
						  label="到货数量"
						 width="80"
						 :show-overflow-tooltip="true">
						</el-table-column>
						-->
						
						<el-table-column
						  prop="wen"
						  label="入库单号"
						 :width="flexColumnWidth('wen',tableData)"
						 :show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
						  label="供应商"
						 width="45"
						>
						<template slot-scope="scope">
						        <el-popover trigger="hover" placement="top">
						          <span @dblclick="copyValue(scope.row,$event)">{{ scope.row.supplier }}</span>
						          <div slot="reference" class="name-wrapper">
						            <span v-if="scope.row.supplier!=''">详</span>
						          </div>
						        </el-popover>
						      </template>
						</el-table-column>
						
						<el-table-column
							prop="factory"
							label="生产厂家"
							:width="flexColumnWidth('factory',tableData)"
							:show-overflow-tooltip="true">
						</el-table-column>
						<!--
						<el-table-column
							prop="factory_code"
							label="厂商编号"
							:width="flexColumnWidth('factory_code',tableData)"
							:show-overflow-tooltip="true">
						</el-table-column>
						-->
						<el-table-column
							prop="qs"
							label="质量标准"
							:width="flexColumnWidth('qs',tableData)"
							:show-overflow-tooltip="true">
							<template slot-scope="scope">
								<el-button @click="down_qs_files(scope.row)" type="text" size="small">{{scope.row.qs}}</el-button>
							</template>
						</el-table-column>
						<el-table-column
							prop="as"
							label="验收标准"
							:width="flexColumnWidth('as',tableData)"
							:show-overflow-tooltip="true">
							<template slot-scope="scope">
								<el-button @click="down_as_files(scope.row)" type="text" size="small">{{scope.row.as}}</el-button>
							</template>
						</el-table-column>
						<el-table-column
							prop="remark"
							label="备注"
							width="150"
							:show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						      label="操作"
						      width="80">
						      <template slot-scope="scope">
								  <el-button v-if="scope.row.if_modify" class="t_hover_button"  @click="show_update_dialog(scope.row)" type="text" size="medium" >修改</el-button>
								  <el-button v-if="scope.row.if_modify" style="margin-left: 3px;margin-right: 0px;"  @click="remove_ma_plan(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"
					  :total="recordTotal"
				      layout="total, sizes, prev, pager, next, jumper"
				      >
				    </el-pagination>
				  </div>
			</div>
			
			<el-dialog
			 title="子任务"
			 :visible.sync="show_child"
			 :lock-scroll ="false"
			 :fullscreen="true"
			 :before-close="child_close"
			 >
				<el-table
				    :data="child_data"
				    style="width: 100%;font-size:14px"
					:row-class-name="tableRowClassName"
					@selection-change="handleSelectionChange"
					border
					:row-style="selectedRowStyle"
					@cell-dblclick="celldblclick_1"
					:header-cell-style="tableHeaderColor"
					:height="tHeight_1"
					>
					<!--
					<el-table-column
					  type="selection"
					  width="30"
					  >
					</el-table-column>
					-->
					<el-table-column
					  prop="id"
					  label="序号"
					  :width="flexColumnWidth('id',child_data,2)">
					</el-table-column>
					
					<el-table-column
					  prop="contract_state"
					  label="合同状态"
					  :width="flexColumnWidth('contract_state',child_data)"
					  :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="state_1"
					  label="付款审批"
					 :width="flexColumnWidth('state_1',child_data)"
					  :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="contract_id"
					  label="合同号"
					  :width="flexColumnWidth('contract_id',child_data)"
					  :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="serial_num"
					  label="付款流水号"
					  :width="flexColumnWidth('serial_num',child_data,5)"
					  :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
		
					  label="RDM"
					  :width="flexColumnWidth('RDM',child_data)"
					  :show-overflow-tooltip="true">
					  <template slot-scope="scope">
						<!--<el-button :style="scope.row.redmine_color" @click="to_redmine_1(scope.row)" type="text" size="medium">{{scope.row.rdm}}</el-button>-->
					   <div v-for="(item, index) in scope.row.rdm.split(/[,， ]+/)" :key="index">                      
                             <el-button :style="scope.row.redmine_color" @click="to_redmine_1(item)" type="text" size="medium">{{item}}</el-button>
                           </div>
							
					  </template>
					</el-table-column>
					
				    <el-table-column
				      prop="code"
				      label="六合编号"
					  :width="flexColumnWidth('code',child_data)"
					  :show-overflow-tooltip="true">
				    </el-table-column>
					
					
					
					<el-table-column
					  prop="name"
					  label="名称"
					 :width="flexColumnWidth('name',child_data,2)">
					</el-table-column>
					<el-table-column
					  prop="specs"
					  label="规格"
					 :width="flexColumnWidth('specs',child_data,2)+10"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="unit"
					  label="单位"
					 :width="flexColumnWidth('unit',child_data,2)">
					</el-table-column>
					<el-table-column
					  prop="aqt"
					  label="数量"
					 :width="flexColumnWidth('aqt',child_data,2)">
					</el-table-column>
					
					<el-table-column
					  prop="price"
					  label="单价"
					 :width="flexColumnWidth('price',child_data,2)">
					 <template slot-scope="scope">
							<div style="float: right;">{{scope.row.price}}</div>
					 </template>
					</el-table-column>
					
					<el-table-column
					  prop="total_p"
					  label="合计"
					 :width="flexColumnWidth('total_p',child_data,2)">
					 <template slot-scope="scope">
							<div style="float: right;">{{scope.row.total_p}}</div>
					 </template>
					</el-table-column>
					
					<el-table-column
					  prop="state"
					  label="状态"
					 :width="flexColumnWidth('state',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="pt"
					  label="付款方式"
					 :width="flexColumnWidth('pt',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="paid"
					  label="已付"
					 :width="flexColumnWidth('paid',child_data,2)+30"
					 :show-overflow-tooltip="true">
					 <template slot-scope="scope">
						<el-button v-if='scope.row.flag!="1"'  @click="show_payment(scope.row)" type="text" size="medium" >更新</el-button>
						<span style="float: right; padding-right: 3px;">{{scope.row.paid}}</span>
					 </template>
					</el-table-column>
					<el-table-column
					  prop="rp"
					  label="应付"
					 :width="flexColumnWidth('rp',child_data,2)"
					 :show-overflow-tooltip="true">
					 <template slot-scope="scope">
						<div style="float: right; padding-right: 3px;">{{scope.row.rp}}</div>
					 </template>
					</el-table-column>
					
					<el-table-column
					  prop="demand_date"
					  label="交付日期"
					 :width="flexColumnWidth('demand_date',child_data)"
					 :show-overflow-tooltip="true">
					 <template slot-scope="scope">
						<span v-if='scope.row.dduc==1' style="color: #ffd04b;">{{scope.row.demand_date}}</span>
						<span v-if='scope.row.dduc>1' style="color: red;" >{{scope.row.demand_date}}</span>
						<span v-if='scope.row.dduc<1' >{{scope.row.demand_date}}</span>
					 </template>
					</el-table-column>
					<el-table-column
					  prop="purchasing_cycle"
					  label="采购周期"
					 :width="flexColumnWidth('purchasing_cycle',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="order_date"
					  label="下单日期"
					 :width="flexColumnWidth('order_date',child_data)">
					</el-table-column>
					<el-table-column
					  prop="over_due1"
					  label="预计超期"
					 :width="flexColumnWidth('over_due1',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="add"
					  label="实际交付"
					 :width="flexColumnWidth('add',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="residue"
					  label="剩余"
					 :width="flexColumnWidth('residue',child_data,2)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="over_due2"
					  label="超期"
					 :width="flexColumnWidth('over_due2',child_data,2)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="buy_record"
					  label="采购记录"
					 width="80"
					 :show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-button v-if='scope.row.buy_record!=""' @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
							<el-button v-if='scope.row.buy_record==""' style='color: #C0C4CC;' @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
						</template>
					</el-table-column>
					<!--<el-table-column
					  prop="aqt"
					  label="到货数量"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column> -->
					
					<el-table-column
					  prop="wen"
					  label="入库单号"
					 :width="flexColumnWidth('wen',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="supplier"
					  label="供应商"
					 :width="flexColumnWidth('supplier',child_data)"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="factory"
						label="生产厂家"
						:width="flexColumnWidth('factory',child_data)"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="factory_code"
						label="厂商编号"
						:width="flexColumnWidth('factory_code',child_data)"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="qs"
						label="质量标准"
						:width="flexColumnWidth('qs',child_data)"
						:show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-button @click="down_qs_files(scope.row)" type="text" size="small">{{scope.row.qs}}</el-button>
						</template>
					</el-table-column>
					<el-table-column
						prop="as"
						label="验收标准"
						:width="flexColumnWidth('as',child_data)"
						:show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-button @click="down_as_files(scope.row)" type="text" size="small">{{scope.row.as}}</el-button>
						</template>
					</el-table-column>
					
					<el-table-column
					      label="操作"
					      width="80">
					      <template slot-scope="scope">
							  <el-button v-if='scope.row.if_modify' class="t_hover_button"  @click="show_update_dialog(scope.row)" type="text" size="medium" >修改</el-button>
							  <el-button v-if='scope.row.if_modify' style="margin-left: 3px;margin-right: 0px;"  @click="remove_ma_plan(scope.row)" type="text" size="medium" >删除</el-button>
					      </template>
					    </el-table-column>
				  </el-table>
			 </el-dialog>
			
			<el-dialog
						 title="采购计划"
						 :visible.sync="updatedialogVisible_ex"
						 :lock-scroll ="false"
						 width="70%">
						 <el-form ref="authform_ex" :model="form" :rules="rules" label-width="160px" :inline="false" class="demo-form-inline" size="medium">
							  <el-row :gutter="10">
								  <el-col :span="8">
									  <el-form-item label="序号" prop="id" >
									  <el-input v-model="form.id" :disabled="true" ></el-input>
									  </el-form-item>
								  </el-col>
								  <el-col :span="8">
										<el-form-item label="RDM" prop="rdm">
										<el-input v-model="form.rdm" :disabled="disabled"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8">
										<el-form-item label="六合编号" prop="code">
										<el-input v-model="form.code" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  
							  <el-row :gutter="10">
								  <el-col :span="8">
									  <el-form-item label="名称" prop="name" >
									  <el-input v-model="form.name" :disabled="true" ></el-input>
									  </el-form-item>
								  </el-col>
								  <el-col :span="8">
										<el-form-item label="规格" prop="specs">
										<el-input v-model="form.specs" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="单位" prop="unit">
										<el-input v-model="form.unit" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  
							  <el-row :gutter="10">
								  <el-col :span="8" >
									<el-form-item label="数量" prop="num">
									<el-input v-model="form.num" :disabled="disabled"></el-input>
									</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="单价" prop="price">
										<el-input v-model="form.price" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="合计" prop="total_p">
										<el-input v-model="form.total_p" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  
							  <el-row :gutter="10">
								  <el-col :span="8" >
										<el-form-item label="付款方式" prop="pt">
										<el-input v-model="form.pt" :disabled="true" ></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="已付" prop="paid">
										<el-input v-model="form.paid" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="应付" prop="rp">
										<el-input v-model="form.rp" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  <el-row :gutter="10">
								  <el-col :span="8" >
										<el-form-item label="交付日期" prop="demand_date">
										<el-input v-if="form.dduc==0" v-model="form.demand_date" :disabled="disabled"></el-input>
										<el-input v-if="form.dduc==1" class="custom-input_yellow" v-model="form.demand_date" :disabled="disabled"></el-input>
										<el-input v-if="form.dduc>1" class="custom-input_red" v-model="form.demand_date" :disabled="disabled"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="采购周期" prop="purchasing_cycle">
										<el-input v-model="form.purchasing_cycle" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="下单日期" prop="order_date">
										<el-input v-model="form.order_date" :disabled="true" @input="mcd_change(form)"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  <el-row :gutter="10">
								  <el-col :span="8" >
									<el-form-item label="预计超期" >
									<el-input v-model="form.over_due1" :disabled="true"></el-input>
									</el-form-item>
								  </el-col>
								  <el-col :span="8" >
									<el-form-item label="实际交付" prop="add">
										<el-input v-model="form.add" :disabled="true"></el-input>
									</el-form-item>
								  </el-col>
								  <el-col :span="8" >
										<el-form-item label="剩余" prop="residue">
										<el-input v-model="form.residue" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  <el-row :gutter="10">
								  <el-col :span="8" >
										<el-form-item label="超期" prop="over_due2">
										<el-input v-model="form.over_due2" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  <el-col :span="16" >
										<el-form-item label="供应商" >
										<el-input v-model="form.supplier" :disabled="true"></el-input>
										</el-form-item>
								  </el-col>
								  
								  
							  </el-row>
							  <el-row :gutter="10">
									<el-col :span="8" >
										<el-form-item label="采购记录" prop="buy_record">
										<el-input v-model="form.buy_record" ></el-input>
										</el-form-item>
									</el-col>
									<el-col :span="8" >
										<el-form-item label="到货数量" prop="aq">
										<el-input v-model="form.aq" ></el-input>
										</el-form-item>
									</el-col>
									
								  <el-col :span="8" >
									<el-form-item label="状态" >
									<!--<el-input v-model="form.state"></el-input>-->
									<el-select clearable v-model="form.state" >
										<el-option label="待付款" value="待付款"></el-option>
										<el-option label="已付款" value="已付款"></el-option>
										<el-option label="交检" value="交检"></el-option>
										<el-option label="待签署" value="待签署"></el-option>
										<el-option label="已收货" value="已收货"></el-option>
										<el-option label="部分到货" value="部分到货"></el-option>
									</el-select>
									</el-form-item>
								</el-col>
								
							  </el-row>
							  
							  <el-row :gutter="10">
								  <el-col :span="8" >
								  	<el-form-item label="入库单号" >
								  	<el-input v-model="form.wen" :disabled="disabled"></el-input>
								  	</el-form-item>
								  </el-col>
								  
								  <el-col :span="8" >
								  	<el-form-item label="采购人员" >
								  	<el-select style="width: 190px;" v-model="form.buyer" filterable placeholder="请选择">
								  	  <el-option
								  		v-for="item in buyer_data"
								  		:key="item.value"
								  		:label="item.label"
								  		:value="item.value">
								  	  </el-option>
								  	</el-select>
								  	</el-form-item>
								  </el-col>
								  <el-col :span="8" >
								  	<el-form-item label="付款流水号" >
								  	<el-input v-model="form.serial_num" :disabled="false"></el-input>
								  	</el-form-item>
								  </el-col>
							  </el-row>
							  <el-row :gutter="10">
									<el-col :span="8" >
										<el-form-item label="合同号" >
										<el-input v-model="form.contract_id" :disabled="false"></el-input>
										</el-form-item>
									</el-col>
									<el-col :span="8" >
										<el-form-item label="备注" prop="remark">
										<el-input type = "textarea" v-model="form.remark" ></el-input>
										</el-form-item>
									</el-col>
									<el-col :span="8" >
										<el-form-item label="付款金额" prop="pay_amount">
										<el-input v-model="form.pay_amount"></el-input>
										</el-form-item>
								  </el-col>
							  </el-row>
							  
						 </el-form>
						 <span slot="footer" class="dialog-footer">
						 <el-button @click="updatedialogVisible_ex = false">取 消</el-button>
						 <el-button id ="bt_ok" plain type="primary" @click="update_ma_ex();">确 定</el-button>
						 </span>
						</el-dialog>
			
			<el-dialog
			 title="采购计划导入"
			 :visible.sync="importdialogVisible"
			 :lock-scroll ="false"
			 :before-close="importDialog_close"
			 width="65%">
				<div style="display: flex;">
					<el-upload
					 class="upload-demo"
					 action=""
					 :on-change="handleChange"
					 :file-list="fileListUpload"
					 :show-file-list="false"
					  accept=".csv"
					  :auto-upload="false">
					  <el-button id ="bt_upload" size="small" plain type="primary">点击上传（csv文件）</el-button>
					</el-upload>
					 <el-button id ="bt_import" size="small" plain type="primary" @click="importData" style="margin-left: 10px;">确认导入</el-button>
				<el-button id ="bt_download" size="small" plain type="primary" @click="download_template" style="margin-left: 10px;">下载导入模板文件</el-button>
				</div>
				<div>
					<el-progress v-if="if_show_process" :percentage="percent_len" :stroke-width="2"></el-progress>
				</div>
				<el-table
					    :data="importTableData"
					    style="font-size:14px;margin-top: 10px;width: 100%;"
						:row-class-name="tableRowClassName"
						stripe border>
						
						<el-table-column
						  prop="t_id"
						  label="序号"
						  width="70"
						  :show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
						  prop="flag"
						  label="FLAG"
						  width="70"
						  :show-overflow-tooltip="true">
						</el-table-column>
						
						<!--<el-table-column
						  prop="contract_id"
						  label="合同号"
						 width="100"
						 :show-overflow-tooltip="true">
						</el-table-column>
						-->
						
						<el-table-column
						  prop="rdm"
						  label="RDM"
						 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="num"
						  label="数量"
						 width="100"
						 :show-overflow-tooltip="true">
						</el-table-column>
						<el-table-column
						  prop="demand_date"
						  label="交付日期"
						 width="100"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="buyer"
						  label="采购人员"
						 width="100"
						 :show-overflow-tooltip="true">
						</el-table-column>
						
						<el-table-column
						  prop="order_date"
						  label="下单日期"
						 width="100"
						 :show-overflow-tooltip="true">
						</el-table-column>
					  </el-table>
			</el-dialog>
			
			<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%">
			 <div>
				 <el-tag style="font-size: 14px;margin-bottom: 20px;">
					 <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>
				 </el-tag>
				 <el-checkbox v-if="plan_op_type==1" style="margin-left: 10px;" v-model="if_paid_all" @change="if_paid_all_cahnge">支付剩余</el-checkbox>
			 </div>
			 <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" :disabled="true" ></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>
			
			<el-dialog
			 title="超期预警"
			 :visible.sync="warning_dialogVisible"
			 :lock-scroll ="false"
			 width="85%"
			 style="height: 100%;"
			 :before-close="warning_close">
			 <div>
			 <el-button id ="bt_export_1" plain type="primary" icon="el-icon-document" @click="export_warn_plan()">导出</el-button>
				</div>
				<el-table
				    :data="warning_data"
				    style="width: 100%;font-size:14px"
					:row-class-name="tableRowClassName"
					@selection-change="handleSelectionChange"
					border
					:row-style="selectedRowStyle"
					@cell-dblclick="celldblclick_1"
					:header-cell-style="tableHeaderColor"
					:height="tHeight"
					>
					
					<el-table-column
					  type="selection"
					  width="30"
					  >
					</el-table-column>
					
					<el-table-column
					  prop="id"
					  label="序号"
					  width="60">
					</el-table-column>
					<el-table-column
					 
					  label="RDM"
					  width="100"
					  :show-overflow-tooltip="true">
					  <template slot-scope="scope">
						<!--<el-button :style="scope.row.redmine_color" @click="to_redmine_1(scope.row)" type="text" size="medium">{{scope.row.rdm}}</el-button>-->
						 <div v-for="(item, index) in scope.row.rdm.split(/[,， ]+/)" :key="index">                      
                             <el-button :style="scope.row.redmine_color" @click="to_redmine_1(item)" type="text" size="medium">{{item}}</el-button>
                           </div>
							
					  </template>
					</el-table-column>
					
				    <el-table-column
				      prop="code"
				      label="六合编号"
					  width="160"
					  :show-overflow-tooltip="true">
				    </el-table-column>
					
					
					<el-table-column
					  prop="name"
					  label="名称"
					 width="100"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="specs"
					  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="aqt"
					  label="数量"
					 width="60"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="price"
					  label="单价"
					 width="60"
					 :show-overflow-tooltip="true"
					 >
					 <template slot-scope="scope">
						<div style="float: right;">{{scope.row.price}}</div>
					 </template>
					</el-table-column>
					
					<el-table-column
					  prop="total_p"
					  label="合计"
					 width="80"
					 :show-overflow-tooltip="true"
					 >
					 <template slot-scope="scope">
						<div style="float: right;">{{scope.row.total_p}}</div>
					 </template>
					</el-table-column>
					
					<el-table-column
					  prop="state"
					  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="paid"
					  label="已付"
					 width="100"
					 :show-overflow-tooltip="true">
					 <template slot-scope="scope">
						<el-button v-if='scope.row.flag!="1"'  @click="show_payment(scope.row)" type="text" size="medium" >更新</el-button>
						<span>{{scope.row.paid}}</span>
					 </template>
					</el-table-column>
					<el-table-column
					  prop="rp"
					  label="应付"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>
					-->
					<el-table-column
					  prop="demand_date"
					  label="交付日期"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<!--
					<el-table-column
					  prop="purchasing_cycle"
					  label="采购周期"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>
					-->
					
					<el-table-column
					  prop="order_date"
					  label="下单日期"
					 :width="80">
					</el-table-column>
					<el-table-column
					  prop="over_due1"
					  label="预计超期"
					 :width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<!--
					<el-table-column
					  prop="add"
					  label="实际交付"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="residue"
					  label="剩余"
					 width="60"
					 :show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
					  prop="over_due2"
					  label="超期"
					 width="60"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
					  prop="buy_record"
					  label="采购记录"
					 width="100"
					 :show-overflow-tooltip="true">
						 <template slot-scope="scope">
							<el-button v-if='scope.row.buy_record!=""' @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
							<el-button v-if='scope.row.buy_record==""' style="color: #C0C4CC;" @click="to_redmine(scope.row)" type="text" size="medium">飞书链接</el-button>
						 </template>
					</el-table-column>
					-->
					<!--<el-table-column
					  prop="aqt"
					  label="到货数量"
					 width="80"
					 :show-overflow-tooltip="true">
					</el-table-column>-->
					<!--
					<el-table-column
					  prop="wen"
					  label="入库单号"
					 width="100"
					 :show-overflow-tooltip="true">
					</el-table-column>
					-->
				
					<el-table-column
					  prop="supplier"
					  label="供应商"
					 width="100"
					 :show-overflow-tooltip="true">
					</el-table-column>
					
					<!--
					<el-table-column
						prop="factory"
						label="生产厂家"
						width="100"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="factory_code"
						label="厂商编号"
						width="100"
						:show-overflow-tooltip="true">
					</el-table-column>
					
					<el-table-column
						prop="qs"
						label="质量标准"
						width="100"
						:show-overflow-tooltip="true">
					</el-table-column>
					<el-table-column
						prop="as"
						label="验收标准"
						width="100"
						:show-overflow-tooltip="true">
						<template slot-scope="scope">
							<el-button @click="down_as_files(scope.row)" type="text" size="small">{{scope.row.as}}</el-button>
						</template>
					</el-table-column>
					-->
					<!--<el-table-column
					      label="操作"
					      width="100">
					      <template slot-scope="scope">
							  <el-button class="t_hover_button"  @click="show_update_dialog(scope.row)" type="text" size="medium" >修改</el-button>
							  <el-button style="margin-left: 3px;margin-right: 0px;"  @click="remove_ma_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>
			
			
		</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,
			tHeight_1: screenH - 80 - 34,
			tableData: Array(0),
			tableData1: Array(0),
			currentPage: 1,
			pagesize: 50,
			pagecnt: 1,
			recordTotal: 0,

			checked: false,
			value1: '',
			value2: '',
			id_v: '',
			rdm_v: '',
			bt_v: '',
			et_v: '',
			msid_v: '',
			pname_v: '',
			supplier_v: '',
			state_v: '',

			rid_v: '',
			repairer_v: '',
			rs_v: '',
			regional_head_v: '',
			ms_v: '',
			asc_v: '',

			updatedialogVisible_ex: false,
			form: {
				id: 0,
				rdm: '',
				code: '',
				name: '',
				specs: '',
				unit: '',
				num: '',
				price: '',
				total_p: '',
				pt: '',
				paid: '',
				rp: '',
				demand_date: '',
				purchasing_cycle: '',
				order_date: '',
				over_due1: '',
				add: '',
				residue: '',
				over_due2: '',
				buy_record: '',
				aq: '',
				state: '',
				wen: '',
				supplier: '',

				flag: '',
				cti: '',

				buyer: '',

				dduc: 0,

				serial_num: '',
			},
			rules: {
				product_id: [
					{ required: true, message: '六合编号不可为空', trigger: 'blur' }
				],
			},

			options: [],

			importdialogVisible: false,
			fileTemp: null,
			fileListUpload: [],
			importTableData: [],

			multipleSelection: [],

			if_show_processed: true,

			if_del_show: false,
			if_del: false,

			p_id_options: [],

			loading: false,
			percent_len: 0,
			if_show_process: false,
			interval: '',

			if_show_process1: false,
			percent_len1: 0,

			ma_users: [],
			disabled: false,

			if_do: true,
			rs_data: [],

			show_child: false,
			pre_id: 0,
			child_data: [],

			row: '',
			dialogVisible: false,

			addplanVisible_1: false,
			maxid: -1,
			planform: {
				id: 0,
				payment_month: '',
				payment: '',
				payment_user: '',
			},
			plan_op_type: 0,

			if_paid_all: false,

			buyer_data: [],

			warning_dialogVisible: false,
			warning_data: [],
			warning_checked: false,

			more_query_v: '',

			buyer_v: '',
			pay_amount_changed: [],
		}
	},
	mounted() {
		var _this = this;

		var op_user = localStorage.getItem("online_user");
		var level = localStorage.getItem("level")
		var did = localStorage.getItem("did");

		if (level == 1) {
			this.$data.if_del_show = true;
		}

		this.get_ma_plan();

		this.get_buyer();


		//this.get_warning();
	},
	methods: {
		convert(amount) {
			let numStr = (amount.replaceAll(",", "").trim() * 1).toFixed(2);
			let thousandSeparated = numStr.replace(/\d(?=(\d{3})+\.)/g, '$&,');
			return thousandSeparated;
		},
		contract_approval() {
			if (this.$data.multipleSelection.length == 0) {
				this.$message({
					message: "请选择计划",
					type: "warning",
					duration: 1500
				});
				return;
			}
			for (var i = 0; i < this.$data.multipleSelection.length; i++) {
				var id = this.$data.multipleSelection[i].id
				if (this.$data.multipleSelection[i].contract_state != ''
					&& (this.$data.multipleSelection[i].contract_state == '已审批'
						|| this.$data.multipleSelection[i].contract_state == '批准')
				) {
					this.$message({
						message: "序号" + id + "计划存在已被审批，不能被重复提交",
						type: "warning",
						duration: 1500
					});
					return;
				}
			}



			var _this = this;
			console.log("323232", _this.$data.multipleSelection)

			var objs;
			axios.post('/pp/mul_contract_approval', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				data: _this.$data.multipleSelection,
			})
				.then(function (response) {

					let r = response.data.r;
					let s = ""
					let errType = ""
					if (r == 0) {
						errType = "success"
					} else {
						errType = "error"
					}

					if (r == 0) {
						s = "合同审批申请成功！";

						// 操作日志
						var list = [];
						_this.$data.multipleSelection.forEach(element => {
							list.push(element.id);
						});
						_this.add_operation_log("申请序号：" + list.toString() + "合同审批");
					} else {
						s = "合同审批申请失败！";
					}

					_this.$message({
						message: s,
						type: errType,
						duration: 1500
					});

					//_this.get_ma_plan();

					if (r == 0) {
						_this.$router.push("/sp_1");
					}
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		mul_payment_application() {

			if (this.$data.multipleSelection.length == 0) {
				this.$message({
					message: "请选择计划",
					type: "warning",
					duration: 1500
				});
				return;
			}

			var _this = this;

			// 修改付款申请金额
			this.$data.multipleSelection.forEach(element => {
			    // 如果选取的id不在 pay_amount_changed数组中，则添加进去
				if (!this.$data.pay_amount_changed.includes(element.id)) {
					element.pay_amount = element.rp;
				}
			})
			

			var objs;
			axios.post('/pp/mul_payment_application', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				data: _this.$data.multipleSelection,
			})
				.then(function (response) {

					let r = response.data.r;
					let s = ""
					let errType = ""
					if (r == 0) {
						errType = "success"

						// 操作日志
						var list = [];
						_this.$data.multipleSelection.forEach(element => {
							list.push(element.id);
							console.log(element);
						});
						_this.add_operation_log("申请序号：" + list.toString() + "付款申请");
					} else {
						errType = "error"
					}

					if (r == 0) {
						s = "付款申请成功！";
						_this.$message({
							message: s,
							type: errType,
							duration: 1500
						});

						// 付款申请日志
						_this.$data.multipleSelection.forEach(element => {
							console.log(element);
							axios.post('/pp/add_sp_2_log', {
								id: element.id,
								record: "付款申请",
								amount: element.total_p.replaceAll(",", ""),
								amount_1: element.pay_amount.replaceAll(",", ""),
								operator: localStorage.getItem("online_user"),
							}).then((response) => {
								console.log(response.data);
							}).catch((error) => {
								console.log(error);
							});
						});

					} else {
						s = response.data.context;

						_this.$message({
							dangerouslyUseHTMLString: true,
							message: s,
							type: errType,
							duration: 3000
						});
					}

					_this.get_ma_plan();
					// _this.$data.pay_amount_changed = false;

					if (r == 0) {
						_this.$router.push("/sp_2");
					}
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		more_query_select(value) {
			console.log(value);
			console.log(this.$data.more_query_v);
			if (value == "采购人员") {

			} else {
				this.$data.buyer_v = ''
			}

			console.log("更多查询", value)
			this.get_ma_plan();
		},

		get_pre_plan(pre_id) {

			this.$data.currentPage = 1;

			document.getElementById("bt_serach").blur();

			var _this = this;
			var objs;
			axios.post('/pp/get_ma_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				id: pre_id.toString(),
				if_done: this.$data.checked,
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					rcnt = response.data.total;
					_this.$data.tableData = objs;
					_this.$data.recordTotal = rcnt;
					//_this.$data.pagecnt = response.data.pagecnt;
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		warning_close(done) {
			this.$data.warning_checked = false;
			done()
		},

		if_warning_checked(val) {
			if (val) {
				this.get_warning();
			} else {
			}
		},

		child_close(done) {
			this.get_ma_plan();
			done()
		},

		down_qs_files(row) {
			var downUrl = '/pp/download_ds_file' + "?id=" + row.qs;
			downloadUrl(row.qs, downUrl);
		},
		down_as_files(row) {
			var downUrl = '/pp/download_ds_file' + "?id=" + row.as;
			downloadUrl(row.as, downUrl);
		},

		get_warning() {
			var _this = this;
			var objs;
			axios.post('/pp/get_warning_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					_this.$data.warning_data = objs;

					if (_this.$data.warning_data.length > 0) {
						_this.warning_dialogVisible = true;
					}
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		get_buyer() {
			var _this = this;
			var objs;
			axios.post('/pp/getUsers', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				index: 1,
				count: 1000
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					rcnt = response.data.total;
					for (var i = 0; i < objs.length; ++i) {
						if (objs[i].if_buyer == 1) {
							var obj = {
								value: objs[i].username,
								label: objs[i].username,
							}

							_this.$data.buyer_data.push(obj);
						}
					}
				})
				.catch(function (error) {
					console.log(error);
				});

		},

		if_paid_all_cahnge(val) {
			console.log(val);
			if (val) {
				this.$data.planform.payment = this.$data.row.rp;
			}
		},

		tableHeaderColor({ row, column, rowIndex, columnIndex }) {
			return;
			console.log(column);
			if (rowIndex === 0 && column.label == "RDM") {
				return 'background-color: #FAD355; ';//绿色
			} else if (rowIndex === 0 && column.label == "六合编号") {
				return 'background-color: #FAD355; ';//橙色
			} else if (rowIndex === 0 && column.label == "名称") {
				return 'background-color: #BACEFD; ';//橙色
			} else if (rowIndex === 0 && column.label == "规格") {
				return 'background-color: #BACEFD; ';//橙色
			} else if (rowIndex === 0 && column.label == "单位") {
				return 'background-color: #BACEFD; ';//橙色
			} else if (rowIndex === 0 && column.label == "数量") {
				return 'background-color: #FAD355; ';//橙色
			} else if (rowIndex === 0 && column.label == "单价") {
				return 'background-color: #BACEFD; ';//橙色
			} else if (rowIndex === 0 && column.label == "付款方式") {
				return 'background-color: #BACEFD; ';//橙色
			} else if (rowIndex === 0 && column.label == "交付日期") {
				return 'background-color: #FAD355; ';//橙色
			} else if (rowIndex === 0 && column.label == "采购周期") {
				return 'background-color: #BACEFD; ';//橙色
			} else {
				return 'background: #ffffff;';
			}
		},

		mul_update_pp_plan_num() {

			if (this.$data.multipleSelection.length == 0) {
				this.$message({
					message: "请选择计划",
					type: "warning",
					duration: 1500
				});
				return;
			}

			var _this = this;

			var objs;
			axios.post('/pp/mul_update_pp_plan_num', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				data: _this.$data.multipleSelection,
			})
				.then(function (response) {

					let r = response.data.r;
					let s = ""
					let errType = ""
					if (r == 0) {
						errType = "success"
						// 操作日志
						var list = [];
						_this.$data.multipleSelection.forEach(element => {
							list.push(element.id);
						});
						_this.add_operation_log("批量到货序号：" + list.toString() + "采购计划");
					} else {
						errType = "error"
					}

					if (r == 0) {
						s = "修改成功！";
					} else {
						s = "修改失败！";
					}

					_this.$message({
						message: s,
						type: errType,
						duration: 1500
					});

					_this.get_ma_plan(_this.$data.currentPage);
				})
				.catch(function (error) {
					console.log(error);
				});
		},
		show_payment(info) {
			var _this = this;

			var objs;
			axios.post('/pp/get_payment_by_id', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				id: info.id,
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					_this.$data.row = objs;

					if (_this.$data.row.total_p == "") {
						_this.$data.row.total_p = info.total_p.replace(/,/g, "")
					}
					if (_this.$data.row.paid == "") {
						_this.$data.row.paid = info.paid.replace(/,/g, "");
					}

					if (_this.$data.row.rp == "") {
						_this.$data.row.rp = info.rp.replace(/,/g, "");
					}

					_this.$data.row.supplier = info.supplier;
					_this.$data.row.code = info.code;
					_this.$data.row.name = info.name;
					_this.$data.row.spec = info.spec;
					_this.$data.row.unit = info.unit;
					_this.$data.row.num = info.num;
					_this.$data.row.price = info.price;
					_this.$data.row.pt = info.pt;

					//_this.$data.row.flag = info.flag;
					_this.$data.row.pre_id = info.pre_id;

					_this.$data.dialogVisible = true;
				})
				.catch(function (error) {
					console.log(error);
				});


		},
		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
					});

					//更新页面
					if (r == 0) {
						if (_this.$data.row.pre_id == 0) {
							_this.get_ma_plan(_this.$data.currentPage);
						} else if (_this.$data.row.pre_id != 0) {
							var arr1 = new Array();   //创建一个空数组
							for (var i = 0; i < _this.$data.child_data.length; ++i) {
								arr1.push(_this.$data.child_data[i].id);
							}
							_this.get_single_pp(arr1);
							_this.get_ma_plan(_this.$data.currentPage);
						}

					}
				})
				.catch(function (error) {
					console.log(error);
				});
		},
		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).toFixed(2).toString();
					} else {
						this.$data.row.rp = "0";
					}

					this.$data.addplanVisible_1 = false;
				}
			});
		},
		showAddkpiplan_1() {
			console.log("payment:", this.$data.row);
			const today = new Date();
			const year = today.getFullYear();
			const month = today.getMonth() + 1;  // 月份从0开始，所以要加1
			const day = today.getDate();

			this.$data.planform.payment_month = year + '/' + month + '/' + day;
			this.$data.planform.payment = '';
			this.$data.planform.payment_user = localStorage.getItem("online_user");
			this.$data.plan_op_type = 1;

			this.$data.if_paid_all = false;

			console.log("payment:", this.$data.row.payment_data);
			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;
		},
		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;
		},

		cal_num() {
			var num = parseInt(this.$data.form.num)
			var num1 = parseInt(this.$data.form.aq)

			this.$data.form.uq = (num - num1).toString()
		},

		date_change(form) {
			console.log(form);

			var bt = "";
			var days = form.cycle;
			if (form.Production_date == "") {
				return;
			} else {
				bt = form.Production_date;
			}

			var _this = this;
			axios.post('/pp/cal_completion_date', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				bt: bt,
				days: days
			})
				.then(function (response) {
					_this.form.due_date = response.data.completion_date;
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		get_ma_user() {
			var _this = this;
			axios.post('/pp/get_ma_username', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
			})
				.then(function (response) {
					_this.$data.ma_users = [];
					console.log(response.data);

					objs = response.data.data;
					for (var i = 0; i < objs.length; ++i) {
						var obj = {
							value: objs[i],
							label: objs[i]
						}
						_this.$data.ma_users.push(obj);
					}
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		get_single_pp(child_id) {
			var _this = this;
			var objs;
			axios.post('/pp/get_single_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				id: child_id,
				if_done: this.$data.checked,
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					//rcnt = response.data.total;
					_this.$data.child_data = objs;
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		celldblclick_1(row, column, cell, event) {
			console.log("row0:", row);
			if (column.property == "id") {
				if (row.flag == "1") {
					this.$data.pre_id = row.id;
					var _this = this;
					var objs;
					axios.post('/pp/get_single_plan', {
						opuser: localStorage.getItem("online_user"),
						opuser_uuid: localStorage.getItem("uuid"),
						id: row.cti,
						if_done: this.$data.checked,
					})
						.then(function (response) {
							console.log(response.data);
							objs = response.data.data;
							//rcnt = response.data.total;
							_this.$data.child_data = objs;
						})
						.catch(function (error) {
							console.log(error);
						});
					_this.$data.show_child = true;
				} else {
					if (row.if_modify == false) {
						return;
					}

					this.$data.pre_id = 0;
					console.log("row:", row);
					this.show_update_dialog(row);
				}
			}
		},
		copyValue(row, event) {
			var el = event.currentTarget;
			var range, selection;
			if (document.body.createTextRange) {
				range = document.body.createTextRange();
				range.moveToElementText(el);
				range.select();

			} else if (window.getSelection) {
				selection = window.getSelection();
				range = document.createRange();
				range.selectNodeContents(el);
				selection.removeAllRanges();
				selection.addRange(range);
			}
			document.execCommand("Copy");
		},
		to_redmine_1(rdm) {
			let id = parseInt(rdm);
			if (id < 10000) {
				return;
			}
			url = encodeURI("http://123.54.1.214:10010/redmine/issues/" + rdm);
			window.open(url, "");
		},
		to_redmine(row) {
			if (row.mt != "") {
				url = encodeURI(row.buy_record);
				window.open(url, "");
			}
		},
		input_change(value) {
			console.log(value);
			this.get_ma_plan();
		},
		pid_selectChanged(value) {
			console.log("select change");
			this.loading = true;
			var _this = this;
			axios.post('/pp/get_p_name', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				p_id: value,
			})
				.then(function (response) {
					_this.$data.form.p_name = response.data.p_name;
				})
				.catch(function (error) {
					console.log(error);
				});
		},
		remoteMethod(query) {
			if (query !== '') {
				this.loading = true;
				setTimeout(() => {

					var _this = this;
					axios.post('/pp/get_p_id_options', {
						opuser: localStorage.getItem("online_user"),
						opuser_uuid: localStorage.getItem("uuid"),
						p_like_id: query,
					})
						.then(function (response) {
							_this.$data.p_id_options = [];
							console.log(response.data);
							objs = response.data.data;
							for (var i = 0; i < objs.length; ++i) {
								var obj = {
									value: objs[i],
									label: objs[i],
								}
								_this.$data.p_id_options.push(obj);
							}
							_this.$data.loading = false;
							console.log(_this.$data.loading)
						})
						.catch(function (error) {
							console.log(error);
							_this.$data.loading = false;
						});
				}, 200);
			} else {
				_this.$data.p_id_options = [];
			}
		},


		if_fin_cahnge(val) {
			if (val) {
				this.$data.if_do = false;
			} else {
				this.$data.if_do = true;
			}

			this.get_ma_plan();
		},
		selectedRowStyle({ row, rowIndex }) {

			for (var i = 0; i < this.$data.multipleSelection.length; i++) {
				if (this.$data.multipleSelection[i].id == row.id) {
					let styleJson = {
						"background": "#134857",
						"color": "#FFFFFF",
					};
					return styleJson;
				}
			}
		},
		download_template() {
			document.getElementById("bt_download").blur();

			var downUrl = '/pp/download_file' + "?id=" + "导入采购计划.csv";
			downloadUrl("采购计划导入文件模板.csv", downUrl);
		},

		handleSelectionChange(val) {
			console.log("已选择");
			console.log(val);
			this.multipleSelection = val;
		},
		importData() {
			document.getElementById("bt_import").blur();
			if (this.$data.importTableData.length == 0) {
				this.$message({
					message: "请选择导入文件",
					type: "warning",
					duration: 1500
				});
				return;
			}

			this.$data.percent_len = 0;
			this.$data.if_show_process = true;
			this.$data.interval = setInterval(() => {
				if (this.$data.percent_len >= 99) {
					clearInterval(this.$data.interval);
					return;
				}
				this.$data.percent_len += 1
			}, 20)
			var _this = this;

			axios.post('/pp/import_ma_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				plan: this.$data.importTableData,
			})
				.then(function (response) {

					let r = response.data.r;
					console.log("r:", r);
					let s = ""
					let errType = ""
					if (r == 0) {
						let len = _this.$data.importTableData.length;
						_this.$data.percent_len = 100;
						_this.$data.if_show_process = false;

						errType = "success"
						s = "导入" + len + "采购计划成功！";
						_this.$message({
							message: s,
							type: errType,
							duration: 1500
						});

						// 操作日志
						_this.add_operation_log("导入" + len + "条采购计划");
					} else if (r == 2) {
						errType = "error"
						s = response.data.context;
						console.log(s);
						clearInterval(_this.$data.interval);

						_this.$message({
							dangerouslyUseHTMLString: true,
							message: s,
							type: errType,
							duration: 3000
						});
					} else {
						errType = "error"
						s = "导入采购计划失败！";
						clearInterval(_this.$data.interval);

						_this.$message({
							message: s,
							type: errType,
							duration: 3000
						});
					}

					_this.$data.importdialogVisible = false;
					//更新页面
					_this.get_ma_plan();

				})
				.catch(function (error) {
					console.log(error);
				});
		},
		importDialog_close(done) {
			console.log("关闭导入对话框");
			done();
		},
		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文件的数据
							if (results.data.length > 5000) {
								_this.$message({
									type: 'warning',
									message: '导入数据量过大，请分批导入！'
								})
								return;
							}
							let data = []
							//遍历csv文件中的数据，存放到data中 方法不唯一，可自己更改
							var cnt = 1
							for (let i = 0; i < results.data.length; ++i) {
								if (i == 0) {
									continue;
								}
								let obj = {}
								obj.flag = results.data[i][0]
								if (obj.flag == "" || obj.flag == undefined) {
									continue;
								}
								/*obj.contract_id = results.data[i][1] 
								obj.contract_amount = results.data[i][2]
								*/
								obj.rdm = results.data[i][1]
								obj.code = results.data[i][2]
								obj.num = results.data[i][3]
								obj.demand_date = results.data[i][4]
								obj.buyer = results.data[i][5]
								obj.order_date = results.data[i][6]

								obj.t_id = cnt
								cnt += 1
								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;
			this.$data.if_show_process = false;
		},

		search() {
			this.get_ma_plan();
		},

		export_plan_1() {

			var _this = this;
			var objs;
			axios.post('/pp/export_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				id: this.$data.id_v,
				rdm: this.$data.rdm_v,
				bt: this.$data.bt_v,
				et: this.$data.et_v,
				code: this.$data.msid_v,
				name: this.$data.pname_v,
				supplier: this.$data.supplier_v,
				if_done: this.$data.checked,
				state: this.$data.state_v,
			})
				.then(function (response) {

					var date = new Date();
					//年 getFullYear()：四位数字返回年份
					var year = date.getFullYear() % 2000; //getFullYear()代替getYear()
					console.log(year.toString());
					//月 getMonth()：0 ~ 11
					var month = date.getMonth() + 1;
					if (month < 10) {
						month = '0' + month
					}
					//日 getDate()：(1 ~ 31)
					var day = date.getDate();
					if (day < 10) {
						day = '0' + day;
					}
					//时 getHours()：(0 ~ 23)
					var hour = date.getHours();
					if (hour < 10) {
						hour = '0' + hour;
					}
					//分 getMinutes()： (0 ~ 59)
					var minute = date.getMinutes();
					if (minute < 10) {
						minute = '0' + minute;
					}
					//秒 getSeconds()：(0 ~ 59)
					var second = date.getSeconds();
					if (second < 10) {
						second = '0' + second;
					}

					var filename = year.toString() + month.toString() + day.toString() + " " + hour.toString() + minute.toString() + second.toString();
					filename = "采购计划 " + filename + ".csv"
					console.log(response.data);
					var fileid = response.data.fileId;

					// 操作日志
					_this.add_operation_log("导出：" + filename);

					var downUrl = '/pp/download_file' + "?id=" + fileid;
					downloadUrl(filename, downUrl);
				})
				.catch(function (error) {
					console.log(error);
				});
		},
		export_warn_plan() {

			var _this = this;
			var objs;
			axios.post('/pp/export_warning_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
			})
				.then(function (response) {

					var date = new Date();
					//年 getFullYear()：四位数字返回年份
					var year = date.getFullYear() % 2000; //getFullYear()代替getYear()
					console.log(year.toString());
					//月 getMonth()：0 ~ 11
					var month = date.getMonth() + 1;
					if (month < 10) {
						month = '0' + month
					}
					//日 getDate()：(1 ~ 31)
					var day = date.getDate();
					if (day < 10) {
						day = '0' + day;
					}
					//时 getHours()：(0 ~ 23)
					var hour = date.getHours();
					if (hour < 10) {
						hour = '0' + hour;
					}
					//分 getMinutes()： (0 ~ 59)
					var minute = date.getMinutes();
					if (minute < 10) {
						minute = '0' + minute;
					}
					//秒 getSeconds()：(0 ~ 59)
					var second = date.getSeconds();
					if (second < 10) {
						second = '0' + second;
					}

					var filename = year.toString() + month.toString() + day.toString() + " " + hour.toString() + minute.toString() + second.toString();
					filename = "超期预警 " + filename + ".csv"
					console.log(response.data);
					var fileid = response.data.fileId;

					var downUrl = '/pp/download_file' + "?id=" + fileid;
					downloadUrl(filename, downUrl);
				})
				.catch(function (error) {
					console.log(error);
				});
		},


		export_plan() {

			var _this = this;
			var objs;
			axios.post('/pp/export_ma_temp_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				id: this.$data.id_v,
				rid: this.$data.rid_v,
				if_done: this.$data.checked,
				repairer: this.$data.repairer_v,
				rs: this.$data.rs_v,
				regional_head: this.$data.regional_head_v,
				ms: this.$data.ms_v,
				sort_field: this.$data.asc_v,
			})
				.then(function (response) {

					var date = new Date();
					//年 getFullYear()：四位数字返回年份
					var year = date.getFullYear() % 2000; //getFullYear()代替getYear()
					console.log(year.toString());
					//月 getMonth()：0 ~ 11
					var month = date.getMonth() + 1;
					if (month < 10) {
						month = '0' + month
					}
					//日 getDate()：(1 ~ 31)
					var day = date.getDate();
					if (day < 10) {
						day = '0' + day;
					}
					//时 getHours()：(0 ~ 23)
					var hour = date.getHours();
					if (hour < 10) {
						hour = '0' + hour;
					}
					//分 getMinutes()： (0 ~ 59)
					var minute = date.getMinutes();
					if (minute < 10) {
						minute = '0' + minute;
					}
					//秒 getSeconds()：(0 ~ 59)
					var second = date.getSeconds();
					if (second < 10) {
						second = '0' + second;
					}

					var filename = year.toString() + month.toString() + day.toString() + " " + hour.toString() + minute.toString() + second.toString();
					filename = "采购计划" + filename + ".csv"
					console.log(response.data);
					var fileid = response.data.fileId;

					var downUrl = '/pp/download_file' + "?id=" + fileid;
					downloadUrl(filename, downUrl);

					// 操作日志
					_this.add_operation_log("应付款导出：" + filename);
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		tableRowClassName({ row, rowIndex }) {
			if (row.cti != undefined && row.cti.length > 0) {
				return 'success-row';
			} else {
				/*var n = rowIndex%2;
				if (n == 1) {
					return 'success-row';
				}*/
			}
			return '';
		},
		show_update_dialog(row) {
			if (!this.$data.pay_amount_changed.includes(row.id)) {
				row.pay_amount = row.rp;
				this.$data.pay_amount_changed.push(row.id); // 将row.id添加到数组中
			}

			this.$data.form = {
				pre_id: row.pre_id,
				id: row.id,
				rdm: row.rdm,
				code: row.code,
				name: row.name,
				specs: row.specs,
				unit: row.unit,
				num: row.num,
				price: row.price,
				total_p: row.total_p,
				pt: row.pt,
				paid: row.paid,
				rp: row.rp,
				demand_date: row.demand_date,
				purchasing_cycle: row.purchasing_cycle,
				order_date: row.order_date,
				demand_date: row.demand_date,
				purchasing_cycle: row.purchasing_cycle,
				order_date: row.order_date,
				over_due1: row.over_due1,
				add: row.add,
				residue: row.residue,
				over_due2: row.over_due2,
				buy_record: row.buy_record,
				aq: row.aq,
				state: row.state,
				wen: row.wen,
				supplier: row.supplier,
				flag: row.flag,
				cti: row.cti,

				buyer: row.buyer,

				dduc: row.dduc,

				serial_num: row.serial_num,
				contract_id: row.contract_id,
				batch_no: row.batch_no,
				pay_amount: row.pay_amount,
				remark: row.remark
			};

			console.log(this.$data.form)

			//this.get_ma_user();

			var op_user = localStorage.getItem("online_user");
			var level = localStorage.getItem("level");
			var did = localStorage.getItem("did");
			if (level == 1) {
				this.$data.disabled = false;
			} else {
				this.$data.disabled = true;
			}
			console.log(level, this.$data.disabled);
			this.$data.updatedialogVisible_ex = true;
		},

		update_ma_ex() {
			this.$refs['authform_ex'].validate((valid) => {
				if (valid) {
					var _this = this;
					axios.post('/pp/update_ma_plan_ex', {
						opuser: localStorage.getItem("online_user"),
						opuser_uuid: localStorage.getItem("uuid"),
						data: _this.form,
					})
						.then(function (response) {

							let r = response.data.r;
							let s = ""
							let errType = ""
							if (r == 0) {
								errType = "success"
								s = "修改成功！";

								// 操作日志
								_this.add_operation_log("修改序号：" + _this.form.id + "采购计划");
							} else {
								errType = "error"
								s = "修改失败！";
							}
							_this.$message({
								message: s,
								type: errType,
								duration: 1500
							});
							//更新页面

							if (r == 0) {
								console.log("flag:", _this.form.flag);
								if (_this.form.flag != "2") {
									_this.get_ma_plan(_this.$data.currentPage);
									_this.$data.updatedialogVisible_ex = false;
								} else if (_this.form.flag == "2") {
									var arr1 = new Array();   //创建一个空数组
									for (var i = 0; i < _this.$data.child_data.length; ++i) {
										arr1.push(_this.$data.child_data[i].id);
									}
									_this.get_single_pp(arr1);
									_this.$data.updatedialogVisible_ex = false;

								}

							}
						})
						.catch(function (error) {
							console.log(error);
						});
				}
			});
		},
		remove_ma_plan(row) {

			this.$confirm('此操作将永久删除, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				var _this = this;
				axios.post('/pp/remove_ma_plan', {
					opuser: localStorage.getItem("online_user"),
					opuser_uuid: localStorage.getItem("uuid"),
					id: row.id
				})
					.then(function (response) {

						let r = response.data.r;
						let s = ""
						let errType = ""
						if (r == 0) {
							errType = "success"
							s = "删除成功！";
							// 操作日志
							// _this.add_operation_log("删除序号：" + row.id + "采购计划");

							if (row.flag != "2") {
								_this.get_ma_plan(_this.$data.currentPage);
							} else if (row.flag == "2") {
								var arr1 = new Array();   //创建一个空数组
								for (var i = 0; i < _this.$data.child_data.length; ++i) {
									arr1.push(_this.$data.child_data[i].id);
								}
								_this.get_single_pp(arr1);
								_this.get_ma_plan(_this.$data.currentPage);
							}

						} else if (r == 1) {
							errType = "warning"
							s = "有子任务，请先删除子任务再删除主任务！";
						} else {
							errType = "error"
							s = "删除失败！";
						}
						_this.$message({
							message: s,
							type: errType,
							duration: 1500
						});
					})
					.catch(function (error) {
						console.log(error);
					});
			}).catch(() => {
			});
		},
		get_ma_plan_1() {

			document.getElementById("bt_serach_1").blur();

			var _this = this;
			var objs;
			axios.post('/pp/get_ma_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				id: this.$data.id_v,
				rdm: this.$data.rdm_v,
				bt: this.$data.bt_v,
				et: this.$data.et_v,
				code: this.$data.msid_v,
				name: this.$data.pname_v,
				supplier: this.$data.supplier_v,
				if_done: this.$data.checked,
				state: this.$data.state_v,
				buyer: this.$data.buyer_v,
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					rcnt = response.data.total;
					_this.$data.tableData = objs;
					_this.$data.recordTotal = rcnt;
					//_this.$data.pagecnt = response.data.pagecnt;
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		get_ma_plan(cur_page) {

			console.log("cur_page:", cur_page);

			document.getElementById("bt_serach").blur();

			var _this = this;
			var objs;
			axios.post('/pp/get_ma_plan', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				index: this.$data.currentPage,
				count: this.$data.pagesize,
				id: this.$data.id_v,
				rdm: this.$data.rdm_v,
				bt: this.$data.bt_v,
				et: this.$data.et_v,
				code: this.$data.msid_v,
				name: this.$data.pname_v,
				supplier: this.$data.supplier_v,
				if_done: this.$data.checked,
				state: this.$data.state_v,
				buyer: this.$data.buyer_v,
			})
				.then(function (response) {
					console.log(response.data);
					objs = response.data.data;
					rcnt = response.data.total;
					_this.$data.tableData = objs;
					_this.$data.recordTotal = rcnt;
					//_this.$data.pagecnt = response.data.pagecnt;
				})
				.catch(function (error) {
					console.log(error);
				});
		},

		handleSizeChange(val) {
			//console.log(`每页 ${val} 条`);
			this.$data.pagesize = val;

			this.get_ma_plan();
		},

		handleCurrentChange(val) {
			//console.log(`当前页: ${val}`);
			this.$data.currentPage = val;

			this.get_ma_plan();
		},
		down_file_22(row) {
			//根据id获取contract_name

			var downUrl = '/pp/download_sp_1_file' + "?id=" + row.id;
			downloadUrl(row.contract_name, downUrl);
			return;


			/*var index = row.contract_name.lastIndexOf(".")

			if(row.contract_name.slice(index) == ".pdf"){
				var downUrl = '/file/'+'sp_1/'+row.contract_name;
				window.open(downUrl, '_blank');
			}else{
				var downUrl = '/pp/download_sp_1_file'+"?id="+row.id;
				downloadUrl(row.contract_name,downUrl);
			}*/
		},
		down_file_23(row) {
			//根据id获取contract_name

			var downUrl = '/pp/upload_sp_2_file' + "?id=" + row.id;
			downloadUrl(row.pay_contract_name, downUrl);
			return;


			/*var index = row.contract_name.lastIndexOf(".")

			if(row.contract_name.slice(index) == ".pdf"){
				var downUrl = '/file/'+'sp_1/'+row.contract_name;
				window.open(downUrl, '_blank');
			}else{
				var downUrl = '/pp/download_sp_1_file'+"?id="+row.id;
				downloadUrl(row.contract_name,downUrl);
			}*/
		},
		// 根据内容设置列表宽度
		flexColumnWidth(str, arr1, fontNum = 4, flag = 'max') {
			return window.flexColumnWidth(str, arr1, fontNum, flag);
		},

		// 合同状态/付款审批宽度
		str_state_with(str, str2, arr1) {
			if(!arr1){
				return 65;
			}
			for (var i = 0; i < arr1.length; ++i) {
				if (arr1[i][str] !== null && arr1[i][str] !== "") {
					return 110;
				} else if (arr1[i][str] !== null && arr1[i][str] !== "") {
					return 95;
				}
			}
			return 65;
		},

		paid_with() {
			if(!this.$data.tableData){
				return false;
			}
		    for (var i = 0; i < this.$data.tableData.length; ++i) {
		        if (this.$data.tableData[i].flag!="1") {
		            return true;
		        }
		    }
			return false;
		},

		// 操作日志
		add_operation_log(operation) {
			axios.post('/pp/add_operation_log', {
				opuser: localStorage.getItem("online_user"),
				opuser_uuid: localStorage.getItem("uuid"),
				operation: operation,
			}).then(function (response) {
				console.log(response);
			}).catch(function (error) {
				console.log(error);
			})

		}
	}
}
