<!doctype html>
<html>
	<head>
		<meta charset="utf-8">
		<title>自销商业开户</title>
		<script src="../../../js/vue/vue.js"></script>
		<script src="../../../js/vue/element-ui/lib/index.js"></script>
		<script src="../../../js/vue/axios/dist/axios.min.js"></script>
		<script src="../../../js/myelement.js"></script>
		<script src="../../../js/vue/page.js"></script>
		
		<link href="../../../js/vue/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
		<link href="../../../css/myelement.css" rel="stylesheet">
		<link href="../../../css/iconfont.css" rel="stylesheet">
		<link href="../../../css/page.css" rel="stylesheet">
		<link href="//at.alicdn.com/t/font_2374495_mkoo966o0uo.css" rel="stylesheet">
	</head>
	
	<body>
		<div id="vbody">
			<div id="page_root">
				<div ref="popup_body" ><!-- style="padding-right: 20px;" -->
					<div class="el-dialog_header h_header" style="position: relative;">
						<div class="dialog-title" style="padding: 10px 20px;">
							<i class="iconfont icon-customermanagement"></i>
							<span> {{title}} </span>
						</div>
					</div>	
					
					<div style="height: 550px; ">
						<div class="el-dialog_body" style="height: 510px;">
							<!-- <el-button-group style="float: right;" v-if="!formAttr.disabled && (isallrefuse || isapprovaledit || iscustomerchange || iscustomereditchange)">
								<el-button size="small" @click="saveForm">保存信息</el-button>
								<el-button v-if="iscustomerchange" size="small" @click="submitForm">提 交</el-button>
								<el-button v-if="iscustomereditchange" type="danger" size="small" @click="cancelEditForm">撤 销</el-button>
								
								<el-button v-if="iscustomereditchange" size="small" @click="submitEditForm">再次提交</el-button>
							</el-button-group > -->
							<h-form
								v-if="showform"
								ref="form_xx"
								:form-attr="formAttr"
								:table-fields="formFields"
								:form-data="formData"
								:is-old-contrast="isOldContrast"
								:form-data-old="formDataOld"
								
								v-on:show-popup="showPopup"
								v-on:button-click="buttonClick"
								v-on:formcallspan-click="formcallspanClick"
								v-on:visible-change="cellVisibleChange"
								
								v-on:select-change="onformSelectChange"
								v-on:form-change="onformChange"
							>
							</h-form>
							<!-- v-on:form-change="formChange" -->
							<!-- 初始可编辑 -->
							<div v-if="notdisabled" style="text-align: right;">
								<el-button-group >
									<!-- <el-button @click="addTableData">新增数据</el-button> -->
									<el-button v-if="isrowinput" @click="editTableData">修改</el-button>
									<!-- <el-button v-if="isrowinput" @click="notActiveTableData">删除</el-button> -->
								</el-button-group>
							</div>
							
							<!-- 提交后创始人可编辑 -->
							<div v-else-if="showRowEdit" style="text-align: right;">
								<el-button-group v-if="emp_code == selectrow.create_operate_code">
									<!-- <el-button @click="addTableData">新增数据</el-button> -->
									<el-button v-if="isrowinput || selectrow.status == 'refuse'" @click="editTableData">修改</el-button>
									<!-- <el-button v-if="isrowinput" @click="notActiveTableData">删除</el-button> -->
									<el-button v-if="isrowinput || selectrow.status == 'refuse'" @click="saveRowTable">单条保存</el-button>
									<el-button v-if="iscustomereditchange" type="danger" size="small" @click="refusecancelRowTable">撤销</el-button>
									<el-button v-if="selectrow.status == 'refuse'" @click="refusesubmitRowTable">再次提交</el-button>
									<el-button v-if="isrowinput" @click="submitRowTable">单条提交</el-button>
								</el-button-group>
								
								<el-button-group v-else>
									<!-- <el-button @click="addTableData">新增数据</el-button> -->
								</el-button-group>
							</div>
							
							<!-- 审批者可编辑 -->
							<div v-else-if="isapprovaledit" style="text-align: right;">
								<el-button-group>
									<el-button @click="editTableDataByAct">修改</el-button>
								</el-button-group>
							</div>
							<h-table
								v-if="isRefresh"
								ref="table2"
								:tableloading="tableloading"
								:table-fields="tableFields" 
								:table-data="tableData2" 
								:is-within-edit-table-data="isWithinEditTableData"
								:table-height="tableHeight2"
								:is-pagination="false"
								:is-show-index="true"
								:is-highlight-row="true"
								
								:is-old-contrast="isOldContrast"
								:table-data-old="tableDataOldObj"
								
								v-on:row-click="rowClick"
								v-on:cell-click="cellClick"
							>
							</h-table>
							
							<div class="el-dialog_body" style=" padding-top: 0px;">
								<el-tabs v-model="activeNames" @tab-click="handleChange">
									<el-tab-pane label="资质证照" name="1">
										<div class="zs_" style="float:left; width: 50%;">
											<el-form ref="form_zz" :model="file_zs" label-width="160px">
												<template v-for="file in attachment_type_zs">
													<el-form-item  :label="file.name + ':'" :rules="file.rules" :prop="file.code">
														<div v-if="file.type_active || file_zs[file.code]" style="width: 100%; min-height: 34px;">
															<div style="float: left; width: 60%; min-height: 35px; border-bottom: 1px solid #ccc ;">
																<span v-if="file_zs[file.code]">{{file_zs[file.code].file_name}}</span>
															</div>
															
															<div style="float: right; width: 40%;">
																<el-button-group class="fj_button" style="float: right;">
																  <el-button v-if="notdisabled || isapprovaledit" type="primary" size="small" @click="onPopupByUploadFile(file.code, null, 'zz')">上 传</el-button>
																  <el-button :disabled="!file_zs[file.code].file_name" type="primary" size="small" @click="showFileImg(file.code)">预 览</el-button>
																  <el-button v-if="file.only_attachment != 1" :disabled="!file_zs[file.code].file_name" type="primary" size="small" @click="showFileTxt(file.code)">详 情</el-button>
																</el-button-group>
															</div>
														</div>
													</el-form-item>
													<div v-if="file.remark" style="margin-left: 140px; font-size: 12px;">
														<span style="color: red;">{{file.remark}}</span>
													</div>
												</template>
											</el-form>
										</div>
										
										<div style="float: right; width: 50%;">
											<div v-if="file_img" style="height: 50%;">
												<div style="margin-left: 30px; font-weight: bold;">
													<el-button v-if="zzimg.id" type="txt" size="small" @click="onDownloadFileByFileId(zzimg.id)">下载附件</el-button>
												</div>
												<el-image v-if="zzimg.url"
													style=" height: 400px; margin-left: 10px;" 
													:src="zzimg.url"
													:preview-src-list="zzimgList"
													fit="contain">
												</el-image>
											</div>
											
											<div  v-if="file_txt" style="height: 50%;">
												<div style="margin-left: 30px; font-weight: bold;">
													<span>{{selectZZName}}</span>
												</div>
												<h-form ref="form_zzxx" :form-attr="formAttr_zz"
													:table-fields="tableFields_zz" 
													:form-data="file_zs[selectZZType]" 
													v-on:form-change="formChange_zz"
													>
												</h-form>
											</div>
											
											<div v-if="!file_txt && !file_img" style="height: 50%;">
												<div style="margin-left: 30px; font-weight: bold;">
													<span v-if="attachment_type_zzobj && attachment_type_zzobj.ZGL01">{{attachment_type_zzobj.ZGL01.name}}</span>
												</div>
												<h-form ref="form_zzxx" :form-attr="formAttr_zz"
													:table-fields="tableFields_zz" 
													:form-data="file_zs[selectZZType]" 
													v-on:form-change="formChange_zz"
													>
												</h-form>
											</div>
											
										</div>
										
									</el-tab-pane>
									
									<el-tab-pane label="开票信息" name="2">
										<div class="zs_" style="float: left; width: 50%;">
											<el-form ref="form_kp_f" :model="formData_kp" label-width="130px">
												<template v-for="file in attachment_type_kp">
													<el-form-item :label="file.name + ':'" :rules="file.rules">
														<div style="width: 100%; min-height: 40px;">
															<div style="float: left; width: 70%; min-height: 35px; border-bottom: 1px solid #ccc ;">
																<span v-if="formData_kp[file.code]">{{formData_kp[file.namecode]}}</span>
															</div>
															<div style="float: right; width: 30%;">
																<el-button-group class="fj_button" style="float: right;">
																  <el-button v-if="notdisabled || isapprovaledit" type="primary" size="small" @click="onPopupByUploadFile(file.code, null,'kp')">上 传</el-button>
																  <el-button type="primary" size="small" @click="showFileImgByFileId(formData_kp[file.code], formData_kp[file.namecode])">预 览</el-button>
																</el-button-group>
															</div>
														</div>
													</el-form-item>
													<div v-if="file.remark" style="margin-left: 140px; font-size: 12px;">
														<span style="color: red;">{{file.remark}}</span>
													</div>
												</template>
											</el-form>
											
											<h-form ref="form_kp" :form-attr="formAttr_kp" 
												:table-fields="tableFields_kp" 
												:form-data="formData_kp" 
												v-on:form-change="formChange_kp"
												>
											</h-form>
										</div>
										<div style="float: right; width: 50%;">
											<div v-if="file_img" style="height: 50%;">
												<div style="margin-left: 30px; font-weight: bold;">
													<el-button v-if="zzimg.id" type="txt" size="small" @click="onDownloadFileByFileId(zzimg.id)">下载附件</el-button>
												</div>
												<el-image v-if="zzimg.url"
													style=" height: 400px; margin-left: 10px;" 
													:src="zzimg.url"
													:preview-src-list="zzimgList"
													fit="contain">
												</el-image>
											</div>
											
											<!-- <h-form ref="form1" :form-attr="formAttr_kp_act" 
												:table-fields="tableFields_kp" 
												:form-data="formData_kp_active" 
												>
											</h-form> -->
										</div>
										
										<!-- <div class="el-dialog__footer" style="border: 0px;">
										  <el-button v-if="notdisabled" type="primary" 
										  @click="saveTabData('kp', formData_kp)">保 存</el-button>
										</div> -->
									</el-tab-pane>
									<el-tab-pane label="收货信息" name="3">
										<div style="position: relative; min-height: 100px;">
											<div v-if="notdisabled || isapprovaledit" style="position: absolute; height: 30px; top:10px; right: 20px; z-index: 100;">
												<!-- <el-button-group  style="margin: 0px 20px;float: right;">
													<el-button v-if="notdisabled" type="primary" @click="saveTabData('consignee', tabs_sh)">保 存</el-button>
												</el-button-group> -->
												<el-button-group v-if="notdisabled || isapprovaledit" style="float: right; margin-right: 30px;">
													<el-button @click="addTableData_sh">新增收货</el-button>
												</el-button-group>
											</div>
											<el-tabs v-model="activeTabs_sh" type="card" :closable="notdisabled || isapprovaledit"
											@tab-remove="removeTab_sh">
											  <el-tab-pane
											    v-for="(item_sh, index) in tabs_sh"
											    :key="index"
											    :label="'收货信息' + (index + 1)"
											    :name="index + '_'"
											  >
											  <div class="zs_" style="float:left; width: 50%;">
												  <el-form ref="form_sh" :model="item_sh" label-width="150px">
												  	<template v-for="file in attachment_type_sh">
														<el-form-item  :label="file.name + ':'" :rules="file.rules">
															<div style="width: 100%; min-height: 40px;">
																<div style="float: left; width: 70%; min-height: 35px; border-bottom: 1px solid #ccc ;">
																	<span v-if="item_sh[file.code]">{{item_sh[file.namecode]}}</span>
																</div>
																<div style="float: right; width: 30%;">
																	<!-- <div v-if="(notdisabled || isapprovaledit) && item_sh[file.code] && item_sh[file.namecode]" class="close_file"
																	@click="delFile(file.code, 'sh', file.name, item_sh)">
																		<i class="el-icon-close" ></i>
																	</div> -->
																	
																	<el-button-group class="fj_button" style="float: right;">
																	  <el-button v-if="notdisabled || isapprovaledit" type="primary" size="small" @click="onPopupByUploadFile(file.code, null, 'sh')">上 传</el-button>
																	  <el-button type="primary" size="small" @click="showFileImgByFileId(item_sh[file.code], item_sh[file.namecode])">预 览</el-button>
																	</el-button-group>
																</div>
															</div>
														</el-form-item>
														<div v-if="file.remark" style="margin-left: 140px; font-size: 12px;">
															<span style="color: red;">{{file.remark}}</span>
														</div>
													</template>
												  </el-form>
												  
												  <h-form ref="form2" :form-attr="formAttr_sh"
												  	:table-fields="tableFields_sh" 
												  	:form-data="item_sh" 
													
													v-on:form-change="formChange_sh"
													v-on:form-checkbox-change="formCheckboxChange_sh"
												  	>
												  </h-form>
											  </div>
											  <div style="float: right; width: 50%;">
												  <div style="margin-left: 30px; font-weight: bold;">
												  	<el-button v-if="zzimg.id" type="txt" size="small" @click="onDownloadFileByFileId(zzimg.id)">下载附件</el-button>
												  </div>
												 <el-image v-if="zzimg.url"
												 	style=" height: 400px; margin-left: 10px;" 
												 	:src="zzimg.url"
													:preview-src-list="zzimgList"
												 	fit="contain">
												 </el-image>
											  </div>
											    
											  </el-tab-pane>
											</el-tabs>
										</div>
										
									</el-tab-pane>
									
									<el-tab-pane label="采购信息" name="4">
										<div style="position: relative; min-height: 100px;">
											<div v-if="notdisabled || isapprovaledit" style="position: absolute; height: 30px; top:10px; right: 20px; z-index: 100;">
												<!-- <el-button-group  style="margin: 0px 20px;float: right;">
													<el-button v-if="notdisabled" type="primary" @click="saveTabData('invoice', tabs_cg)">保 存</el-button>
												</el-button-group> -->
												<el-button-group v-if="notdisabled || isapprovaledit" style="float: right; margin-right: 30px;">
													<el-button @click="addTableData_cg">新增采购</el-button>
												</el-button-group>
											</div>
											<el-tabs v-model="activeTabs_cg" type="card" :closable="notdisabled || isapprovaledit"
												@tab-remove="removeTab_cg">
											  <el-tab-pane
												v-for="(item_cg, index) in tabs_cg"
												:key="index"
												:label="'采购信息' + (index + 1)"
												:name="index + '_'"
											  >
												<div class="zs_" style="float:left; width: 50%;">
													<el-form ref="form_cg" :model="item_cg" label-width="130px">
														<template v-for="file in attachment_type_cg">
															<el-form-item :label="file.name + ':'" :rules="file.rules">
																<div style="width: 100%; min-height: 40px;">
																	<div style="float: left; width: 70%; min-height: 35px; border-bottom: 1px solid #ccc ;">
																		<span v-if="item_cg[file.code]">{{item_cg[file.namecode]}}</span>
																	</div>
																	<div style="float: right; width: 30%;">
																		<!-- <div v-if="(notdisabled || isapprovaledit) && item_cg[file.code] && item_cg[file.namecode]" class="close_file"
																		@click="delFile(file.code, 'cg', file.name, item_cg)">
																			<i class="el-icon-close" ></i>
																		</div> -->
																		
																		<el-button-group class="fj_button" style="float: right;">
																		  <el-button v-if="notdisabled || isapprovaledit" type="primary" size="small" @click="onPopupByUploadFile(file.code, null, 'cg')">上 传</el-button>
																		  <el-button type="primary" size="small" @click="showFileImgByFileId(item_cg[file.code], item_cg[file.namecode])">预 览</el-button>
																		</el-button-group>
																	</div>
																</div>
															</el-form-item>
															<div v-if="file.remark" style="margin-left: 140px; font-size: 12px;">
																<span style="color: red;">{{file.remark}}</span>
															</div>
														</template>
													</el-form>
													
												  <h-form :form-attr="formAttr_cg"
													:table-fields="tableFields_cg" 
													:form-data="item_cg" 
													v-on:form-change="formChange_cg"
													
													v-on:form-checkbox-change="formCheckboxChange_cg"
													>
												  </h-form>
												</div>
												<div style="float: right; width: 50%;">
													<div style="margin-left: 30px; font-weight: bold;">
														<el-button v-if="zzimg.id" type="txt" size="small" @click="onDownloadFileByFileId(zzimg.id)">下载附件</el-button>
													</div>
													<el-image v-if="zzimg.url"
														style=" height: 400px; margin-left: 10px;" 
														:src="zzimg.url"
														:preview-src-list="zzimgList"
														fit="contain">
													</el-image>
												</div>
											  </el-tab-pane>
											</el-tabs>
										</div>
									</el-tab-pane>
									
									<el-tab-pane label="质保协议" name="5">
										<div class="zs_" style="float:left; width: 50%;">
											<el-form ref="form_zb" :model="file_zs" label-width="130px">
												<template v-for="file in attachment_type_zb">
														<el-form-item :label="file.name + ':'" :rules="file.rules">
															<div style="width: 100%; min-height: 40px;">
																<div style="float: left; width: 70%; min-height: 35px; border-bottom: 1px solid #ccc ;">
																	<span v-if="file_zs[file.code]">{{file_zs[file.code].file_name}}</span>
																</div>
																<div style="float: right; width: 30%;">
																	<!-- <div v-if="(notdisabled || isapprovaledit) && file_zs[file.code] && file_zs[file.code].file_name" class="close_file"
																	@click="delFile(file.code, 'zb', file.name, file_zs[file.code])">
																		<i class="el-icon-close" ></i>
																	</div> -->
																	
																	<el-button-group class="fj_button" style="float: right;">
																	  <el-button v-if="notdisabled || isapprovaledit" type="primary" size="small" @click="onPopupByUploadFile(file.code, null, 'zz')">上 传</el-button>
																	  <el-button type="primary" size="small" @click="showFileImg(file.code)">预 览</el-button>
																	</el-button-group>
																</div>
															</div>
														</el-form-item>
														
														<el-form-item label="质保协议有效期:">
															<el-date-picker
																:disabled="!(notdisabled || isapprovaledit)"
																@change="formChange_zb"
																style="width: 100%;"
															    v-model="file_zs[file.code].license_term"
															    type="date"
															    placeholder="有效期至"
															    format="yyyy-MM-dd"
																value-format="yyyy-MM-dd"
																>
															</el-date-picker>
														</el-form-item>
												</template>
											</el-form>
										</div>
										
										<div style="float: right; width: 50%;">
											<div style="height: 50%;">
												<div style="margin-left: 30px; font-weight: bold;">
													<el-button v-if="zzimg.id" type="txt" size="small" @click="onDownloadFileByFileId(zzimg.id)">下载附件</el-button>
												</div>
												<el-image v-if="zzimg.url"
													style=" height: 400px; margin-left: 10px;" 
													:src="zzimg.url"
													:preview-src-list="zzimgList"
													fit="contain">
												</el-image>
											</div>
										</div>
									</el-tab-pane>
									<el-tab-pane v-if="!isDistributor" label="纸质物流信息" name="6">
										<el-form ref="form_zzwl" label-width="130px">
											<el-form-item label="物流公司:">
												<el-input :disabled="!(notdisabled || isapprovaledit)" v-model="logistics_company" @change="formChange_wl"></el-input>
											</el-form-item>
											<el-form-item label="运单号:">
												<el-input :disabled="!(notdisabled || isapprovaledit)" v-model="logistics_no" @change="formChange_wl"></el-input>
											</el-form-item>
										</el-form>
									</el-tab-pane>
									<el-tab-pane v-if="acctObj.cer_status && acctObj.cer_status != 'input' && !isDistributor"  label="纸质文件确认" name="7">
										<el-switch
											disabled
										  v-model="logistics_check"
										  active-text="已确认"
										  inactive-text="未确认">
										</el-switch>
									</el-tab-pane>
								</el-tabs>
								
								<div v-if="acctObj.flow_id" style="height: 500px; border-top: 1px solid #ccc;">
									<iframe :src="'../../approval/ApprovalList_page.html?flow_id=' + acctObj.flow_id" style="width: 100%; height: 100%; border: 0px;"></iframe>
								</div>
							</div>
						</div>
					</div>
					<div class="el-dialog_footer">
						<el-button-group v-if="approval" style="margin: 0px 20px;">
							<el-button @click="onShowApproval">审批记录</el-button>
						</el-button-group>
						
						<el-button-group v-if="approval" style="margin: 0px 20px;">
							<el-button type="success" @click="onpassApproval">通 过</el-button>
						</el-button-group>
						<el-button-group v-if="approval" style="margin: 0px 20px;">
							<el-button type="danger" @click="onrefuseApproval">拒 绝</el-button>
						</el-button-group>
						<el-button v-if="close && !fromDing" type="default" @click="closeDialog">取 消</el-button>
						<el-button v-if="!close && !fromDing" type="default" @click="closeDialog">å…³ é—­</el-button>
						
						<el-button v-if="notdisabled && isallinput" type="primary" @click="saveTables" :loading="loading_save">保 存</el-button>
						<el-button v-if="notdisabled && isallinput" type="primary" @click="submitTables" :loading="loading_submit">提 交</el-button>
						<!-- <el-button  type="primary" @click="submitTables" :loading="loading_submit">提 交</el-button> -->
					</div>
				</div>
				
				<el-dialog :title="formData_part.id ? formData_part.delivery_part_name : '添加发货主体'" :visible.sync="part_dialog" height="50%" width="800px">
					<h-form 
						ref = "form12"
						:form-attr="formAttr_part"
						:table-fields="tableFields_part" 
						:form-data="formData_part" 
						v-on:show-popup="showFilterPopup"
						v-on:button-click="buttonClick_part"
						>
					</h-form>
					
					<div slot="footer" class="dialog-footer" >
					  <el-button type="default" @click="part_dialog = false">取 消</el-button>
					  <el-button type="primary" @click="saveFormPart">确 定</el-button>
					</div>
				</el-dialog>
				
				<el-dialog title="填写原因" :visible.sync="reasonvisible" height="50%">
					<el-input
					  type="textarea"
					  :autosize="{ minRows: 2, maxRows: 10}"
					  placeholder="请输入原因"
					  v-model="textarea2">
					</el-input>
					<el-button type="primary" size="small" @click="onPopupByUploadFileAll()">上传附件</el-button>
					<span> {{attachment_name}}</span>
					
					<div slot="footer" class="dialog-footer" >
					  <el-button type="default" @click="reasonvisible = false">取 消</el-button>
					  <el-button type="primary" @click="saveReason" :loading="loading_approval">确 定</el-button>
					</div>
				</el-dialog>
				
				<el-dialog title="未审批完的备案和资质" :visible.sync="dialog_notapproval">
					<h-table
						:table-fields="notApprovalFields" 
						:table-data="notApprovalData" 
					>
					</h-table>
				</el-dialog>
				
				<el-dialog :visible.sync="dingResult" width="40vw" height="50vh" :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false">
					 <span>{{dingResultTxt}}</span>
					 <div style="min-height: 150px;"></div>
				</el-dialog>
				
			</div>
			
			<div id="page_loading" style="position: absolute; top:0px; width: 100vw; height: 100vh;">
				<div class="spinner">
				  <div class="cube1"></div>
				  <div class="cube2"></div>
				</div>
			</div>
			
			
		</div>	
		
		<script type="text/javascript">
			new ListVue({
				el: "#vbody",
				data: {
					emp_id: localStorage.getItem("emp_id"),
					emp_code: localStorage.getItem("emp_code"),
					roleList: [],
					title: "",
					
					isallinput: false,
					isallrefuse: false,
					isapprovaledit: false,
					iscustomerchange: false,
					iscustomereditchange: false,
					
					notdisabled: false,
					showRowEdit: false,
					isrowinput: false,
					
					approval:false,
					
					loading_save: false,
					loading_submit: false,
					loading_approval: false,
					
					form_dataname: "salesOrder",
					dataname: "delivery_mapping",
					
					//filterFieldsName: "customer_acct",
					formFieldsName: "customer_acct",
					tabaleFieldsName: "customer_factory",//
					
					rolecode: window.top.userinfo.user.rolecode,
					acctObj: {},
					act_type: "",
					showform: true,
					formAttr: {
						title: "商业基本信息",
						istitle: true,
						columnnumber: 3,
						labelwidth: "100px",
						labelposition: "left", //"right",
						size: "medium",
						disabled: true,
						border: "0px solid #c6c6c600",
					},
					formFields: [],
					formData: {},
					isOldContrast: true,
					formDataOld: {},
					
					oldFormData: {},
					refresh_formzz: true,
					warningzs: {},
					isWithinEditTableData: true,
					licenceList: [],
					
					dataRequest: [
						{
							isClientMode: false,
							code: "md_code",
							label: "md_description",
							name: "hierarchy",
							filter: "long_code like '01!0101!010102!010102628!01010218!20210420-0001%'"
						},
						{
							isClientMode: false,
							code: "code",
							label: "name",
							name: "division_level1",
							filter: " level='1' and active='1'"
						},
						{
							isClientMode: false,
							code: "code",
							label: "name",
							name: "deliveryOrganizationOpen",
						},
						{
							isClientMode: false,
							code: "code",
							label: "value",
							name: "dictitem",
							filter: " parent_id='customer_part'"
						},
						
						{
							isClientMode: false,
							isnotoption: true,//不是选择项的预加载
							code: "code",
							label: "value",
							name: "roleEditAble",
							filter: " type='accountCustomerDelivery'"
						},
						
						{
							isClientMode: false,
							code: "send_code",
							label: "code",
							dataname: "division_level1",
							name: "mdm_province_mapping",
							filter: " level='1' and active='1'"
						},
						
						{
							isClientMode: false,
							isnotoption: true,//不是选择项的预加载
							code: "code",
							label: "value",
							name: "customerRequiredByRoleid",
							dataname: "getCustomerRequiredByRoleid",
							filter: "1=1",
							url: "root/data/procedure",
							paramObjBydefault: {
								returnType: "entityset",
								role_id: window.top.roleid_str.replace(/;/g,"','")
							}
						},
					],
					dataRequestObj: {},
					customerRequiredByRoleid: [],
					customerRequiredByRoleidTypeObj: {},
					customerRequiredByRoleidTypeList: {},
					
					//发货主体信息
					partObjByRole: {
						sp075: {
							rolename: "工厂填报人-浙江康莱特",
							delivery_part_code: "ZJKLT",//发货主体
							delivery_part_name: "浙江康莱特药业有限公司",
						},
						sp076: {
							rolename: "工厂填报人-江西康莱特",
							delivery_part_code: "JXKLT",//发货主体
							delivery_part_name: "江西康莱特医药有限公司",
						},
						sp077: {
							rolename: "工厂填报人-江西新森",
							delivery_part_code: "JXXS",//发货主体
							delivery_part_name: "江西康莱特新森医药原料有限公司",
						},
					},
					newtabledata_part: [
						{
							delivery_part_code: "",//发货主体
							delivery_part_name: "",
							customer_identity: 3,//客户身份
							business_operate_id: localStorage.getItem("emp_id"), 
							business_operate_name: localStorage.getItem("emp_name"), //商业操作人
							business_operate_code: localStorage.getItem("emp_code"), //商业操作人编码
						}
					],
					tableFields: [],
					tableData2: [],
					tableDataOld: [],
					tableDataOldObj: {},
					
					tableDataChange: {},
					tableHeight2: 250,
					formData2:[],
					isRefresh: true,
					selectFormField: {},
					operation_type: "",
					selectrow: {},
					close:true,
					productDetail: [],
					
					sum_noRate_: 0,
					updatetime: createDatetime(),
					type_act: "",
					reasonvisible:false,
					canceltype: "",
					reasonvisible_flowid: "",
					textarea2: '',
					attachment: "",
					attachment_name: "",
					passOrRefuse:false,
					seal:false,
					
					part_dialog: false,
					formAttr_part: {
						title: "发货主体信息",
						istitle: false,
						columnnumber: 2,
						labelwidth: "130px",
						labelposition: "right", //"right",
						size: "medium",
						border: "0px solid #c6c6c600",
						//disabled: true
					},
					tableFields_part: [
						{isshow: "T", field: "delivery_part_code", name: "发货主体", required: true, disabled: true, type: "select", options: [], props: {value: "code", label: "name", checkStrictly: true}},
						{isshow: "T", field: "customer_part_code", name: "客户主体", required: true, type: "select", options: [], props: {value: "code", label: "value", checkStrictly: true}},
						{isshow: "T", field: "business_type", name: "商业属性", required: true, type: "select", options: [{code: 1, name: "直管"}, {code: 2, name: "非直管"}], props: {value: "code", label: "name", checkStrictly: true}},
						{isshow: "T", field: "customer_identity", name: "客户身份", required: true, disabled: true, type: "select", options: [{code: 3, name: "自销"}], props: {value: "code", label: "name", checkStrictly: true}},
						{isshow: "T", field: "business_operate_name", name: "商业操作人", required: true, disabled: true, type: "popup"},
						{isshow: "T", field: "business_operate_code", name: "操作人编码",labelwidth: "130px", disabled: true},
						{isshow: "T", field: "remark", name: "备案原因", required: true},
						{isshow: "T", field: "file_name", name: "附件", type: "span", buttonname:"附件上传"},
					],
					formData_part: {},
					
					dialog_notapproval: false,
					notApprovalFields: [
						{isshow: "T", field: "delivery_part_name", name: "主体名称"},
						{isshow: "T", field: "delivery_status", name: "备案状态", width: "100", formatter: "formatter_OrderState"},
						{isshow: "T", field: "cer_status", name: "资质状态", width: "100", formatter: "formatter_OrderState"},
					],
					notApprovalData: [],
					
					checkfFields: ["delivery_part_code", "customer_part_code", "business_operate_code", "customer_identity", "business_type"],
					fromDing: false,
					dingResult: false,
					dingResultTxt: "",
					//商业信息修改前数据
					old_data_syxx: {},
					
					
					//////////////////
					//////资质信息
					//公用信息
					oldQualifications: {},
					newQualifications: {},
					
					showRowEdit: false,
					activeNames: "1",
					file_img: false,
					file_txt: false,
					zzimg: {},
					zzimgList: [],
					
					formAttr_zz: {
						istitle: false,
						title: "证照详情",
						columnnumber: 1,
						labelwidth: "150px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						
						formatter: function(data, fields) {
							
						}
					},
					
					attachment_type_kp: [
						{code: "prove_file_id", name: "银行开户证明", namecode: "prove_file_name"},//, rules: [{required: true, message: "请上传银行开票证明", trigger: "blur" }]
						{code: "invoice_file_id", name: "开票资料", namecode: "invoice_file_name", remark: "银行开户证明和开票资料至少上传一个"},
					],
					
					formAttr_kp: {
						istitle: false,
						title: "开票信息",
						columnnumber: 1,
						labelwidth: "130px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						
						formatter: function(data, fields) {
							
						}
					},
					formAttr_kp_act: {
						istitle: true,
						title: "有效开票信息",
						columnnumber: 1,
						labelwidth: "150px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						disabled: true,
						formatter: function(data, fields) {
							
						}
					},
					
					formAttr_sh: {
						istitle: false,
						title: "收货信息",
						columnnumber: 1,
						labelwidth: "130px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						
						formatter: function(data, fields) {
							
						}
					},
					formAttr_cg: {
						istitle: false,
						title: "采购信息",
						columnnumber: 1,
						labelwidth: "130px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						
						formatter: function(data, fields) {
							
						}
					},
					attachment_type_zzobj: {},
					
					//1.证照
					del_zz: [],
					file_zs: {},
					file_zs_old: {},
					attachment_type_zs: [],
					tableFields_zz: [
						{isshow: "T", field: "num", name: "序号"},
						{isshow: "T", field: "licence_date", name: "发证日期", type: "date"},
						{isshow: "T", field: "ia", name: "发证机构"},
						{isshow: "T", field: "license_term", name: "失效日期", type: "date"},
						{isshow: "T", field: "scope", name: "范围", type: "textarea", textarearows: 10, maxlength: 1000},
					],
					selectZZType: "ZGL01",
					selectZZName: "",
					
					filetypeMappin: {
						"ZGL01": {
							"num": "RegNum",
							"scope": "Business",
							"licence_date": "SetDate",
							"license_term": "Period"
						},
						"ZGL03": {
							"num": "num",
							"scope": "scope",
							"licence_date": "licence_date",
							"license_term": "license_term"
						},
						"ZGL06": {
							"num": "num",
							"scope": "scope",
							"licence_date": "licence_date",
							"license_term": "license_term"
						},
					},
					
					//2.开票
					formData_kp: {},
					//本次修改前数据,用于保存时判断是否有修改
					formData_kp_old: {},
					formData_kp_active: {},
					//上个版本数据,用于显示差异
					formData_kpold: {},
					tableFields_kp: [
						{isshow: "T", field: "bank_name", name: "开户银行", align: "center", required: true},
						{isshow: "T", field: "bank_account", name: "银行帐户", align: "center", required: true},
						{isshow: "T", field: "bank_account_name", name: "帐户名称", align: "center", width: "100", required: true},
						{isshow: "T", field: "bank_address", name: "开票地址", align: "center", width: "100", required: true},
						{isshow: "T", field: "bank_tel", name: "开票电话", align: "center", required: true},
					],
					
					//3.æ”¶è´§
					activeTabs_sh: "",
					tabs_sh: [
						{code: "t1"},
						{code: "t2"},
					],
					tabs_sh_old: [],
					tabs_sh_old_obj: {},
					tabsobj_sh: {},
					attachment_type_sh: [
						{code: "book_file_id", name: "授权委托书", namecode: "book_name", 
						remark: "需包含收件人身份证复印件",
						rules: [{required: true, message: "请上传授权委托书", trigger: "blur" }]},
						//{code: "id_card_file_id", name: "收货人身份证复印件", namecode: "id_card_name", rules: [{required: true, message: "请上传收货人身份证复印件", trigger: "blur" }]}
					],
					file_sh: {},
					tableFields_sh: [
						{isshow: "T", field: "emp_name", name: "收货人", align: "center", required: true},
						{isshow: "T", field: "address", name: "收货地址", align: "center", required: true},
						{isshow: "T", field: "emp_tel", name: "联系电话", align: "center", width: "100", required: true},
						{isshow: "T", field: "license_term", name: "委托书有效期", align: "center", type: "date"},
						{isshow: "T", field: "product_desc", name: "授权品种描述", align: "center"},
						{isshow: "T", field: "city", name: "收货城市", align: "center"},
						{isshow: "T", field: "id_card", name: "身份证号", align: "center"},
						{isshow: "T", field: "id_card_term", name: "身份证有效期", align: "center", type: "date", ischeckbox: "islongterm", checkbox_text: "长期"},
						{isshow: "T", field: "emp_email", name: "联系人邮箱", align: "center"}
					],
					default_form_sh: {
						emp_name: "",
						address: "",
						emp_tel: "",
						license_term: "",
						product_desc: "",
						city: "",
						id_card: "",
						id_card_term: "",
						emp_email: "",
						create_operate_id: localStorage.getItem("emp_id")
					},
					formData_sh: {
						islongterm: false,
					},
					//4.采购
					activeTabs_cg: "",
					tabs_cg: [
						{code: "t1"},
						{code: "t2"},
					],
					tabs_cg_old: [],
					tabs_cg_old_obj: {},
					attachment_type_cg: [
						{code: "book_file_id", name: "采购授权委托书", namecode: "book_name", 
						remark: "法人授权采购委托书原件应对应采购员的身份证、毕业证复印件(药学相关专业中专以上学历),委托书中应注明委托区域、品种、期限",
						rules: [{required: true, message: "请上传采购授权委托书", trigger: "blur" }]},
						//{code: "id_card_file_id", name: "采购员身份证", namecode: "id_card_name", rules: [{required: true, message: "请上传采购员身份证", trigger: "blur" }]},
						//{code: "diploma_file_id", name: "采购员毕业证", namecode: "diploma_name", rules: [{required: true, message: "请上传采购员毕业证", trigger: "blur" }]}
					],
					
					file_cg: {},
					tableFields_cg: [
						{isshow: "T", field: "license_term", name: "委托书有效期", align: "center", type: "date"},
						{isshow: "T", field: "product_desc", name: "授权品种描述", align: "center"},
						{isshow: "T", field: "area", name: "区域", align: "center"},
						{isshow: "T", field: "purchase_name", name: "采购人", align: "center"},
						{isshow: "T", field: "purchase_tel", name: "联系电话", align: "center"},
						{isshow: "T", field: "id_card_num", name: "身份证号", align: "center"},
						{isshow: "T", field: "id_card_term", name: "身份证有效期", align: "center", type: "date", ischeckbox: "islongterm", checkbox_text: "长期"},
						{isshow: "T", field: "purchase_email", name: "联系人邮箱", align: "center"},
					],
					default_form_cg: {
						license_term: "",
						product_desc: "",
						area: "",
						purchase_name: "",
						purchase_tel: "",
						id_card_num: "",
						id_card_term: "",
						purchase_email: "",
						create_operate_id: localStorage.getItem("emp_id")
					},
					formData_cg: {
						islongterm: false,
					},
					
					//5.质保
					del_zb: [],
					file_zb: {},
					attachment_type_zb: [],
					
					//6.纸质物流
					logistics_company: "",
					logistics_no: "",
					logistics_company_old: "",
					logistics_no_old: "",
					//7.纸质确认
					logistics_check: false,
					
					isnotcer: false,//是否没有资质,false值是存在资质
					isDistributor: false,
					
					//资质头信息
					certificationObj: {},
					
				},
				
				created() {
					var me = this;
					var hierarchy_ = {
						id: localStorage.getItem("hierarchy_id"),
						name: localStorage.getItem("hierarchy_name"),
						code: localStorage.getItem("hierarchy_code"),
					};
					
					this.popupParames = clone(Root.popupParames);
					//标题
					if (this.popupParames.title) {
						this.title = clone(this.popupParames.title);
					}
					//数据
					if (this.popupParames.data) {
						let formData1 = {};
						if (this.popupParames.sceneCode == "add_mdm") {
							//设置默认值
							var mdmdata = clone(this.popupParames.data);
							//商业信息
							this.formFields.map(ff=>{
								if (mdmdata[ff.field]) {
									formData1[ff.field] = mdmdata[ff.field];
								}
							});
							formData1.apply_dep_code = hierarchy_.code;
							formData1.apply_dep_name = hierarchy_.name;
							
							formData1.operator_code = localStorage.getItem("emp_code");
							formData1.operator_name = localStorage.getItem("emp_name");
							this.formData = formData1;
						}
						else {//赋值表单
							formData1 = clone(this.popupParames.data);
							if (!formData1.id) {
								formData1.apply_dep_code = hierarchy_.code;
								formData1.apply_dep_name = hierarchy_.name;
								
								formData1.operator_code = localStorage.getItem("emp_code");
								formData1.operator_name = localStorage.getItem("emp_name");
								this.formData = formData1;
							}
						}
						this.acctObj = formData1;
					}
					
					if (this.popupParames.sceneCode) {
						//查看
						if (this.popupParames.sceneCode == "browse") {
							this.formAttr.disabled = true;
							this.notdisabled = false;
							this.approval = false;
							this.close = false;
						}
						//不带商业数据
						else if (this.popupParames.sceneCode == "add") {
							//this.addTableData();
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							this.notdisabled = true;
							
							this.isallinput = true;
							
						}
						//从MDM或正常商业带商业数据
						else if (this.popupParames.sceneCode == "add_mdm") {
							
						}
						//从自销商业带自己数据
						else if (this.popupParames.sceneCode == "input") {
							//可编辑头,可编辑明细,可批量提交
							this.notdisabled = true;
							this.isallinput = true;
							this.formAttr.disabled = false;
							
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
						}
						//审批
						else if (this.popupParames.sceneCode == "working") {
							//全部未通过,不可编辑头,不可编辑明细
							//this.formAttr.disabled = true;
							this.showRowEdit = false;
						}
						
						/* else if (this.popupParames.sceneCode == "versionapproval") {//商业变更后提交后的审批
							//
							var roleList_ = localStorage.getItem("roleList");
							this.roleList = JSON.parse(roleList_);
							var roleEditAble_ = me.dataRequestObj.roleEditAble;
							var role_edit = false;
							if (this.roleList.length && roleEditAble_ && roleEditAble_.length) {
								roleEditAble_.map(re=>{
									var role_id = re.r_id;
									this.roleList.map(zre=>{
										if (role_id == zre.id) {
											role_edit = true;
											return
										}
									})
									
									if(role_edit) {
										return
									}
								});
							}
							
							if (role_edit) {//审批节点可编辑.
								this.approval = true;
								
								this.isapprovaledit = true;
								this.formAttr.disabled = false;
								this.formAttr_zz.disabled = false;
								this.formAttr_kp.disabled = false;
								
								this.isRefresh = false;
							}
							else {
								this.approval = true;
								this.isRefresh = false;
							}
						} */
						//待修改
						else if (this.popupParames.sceneCode == "refuse") {
							var row_ = clone(this.popupParames.data);
							//不可编辑头,可编辑未提交明细,仅单条提交
							this.showRowEdit = true;
							if (row_.refuse_cnt == row_.total_cnt) {//全部待调整的可以编辑头
								this.isallrefuse = true;
								this.formAttr.disabled = false;
							}
						}
						/* else if (this.popupParames.sceneCode == "exist_open") {
							//不可编辑头,可编辑未提交明细,仅单条提交
							this.showRowEdit = true;
						}
						
						else if (this.popupParames.sceneCode == "exist_open_all") {
							//部分通过,可编辑头,可编辑未提交明细,仅单条提交
							this.isallrefuse = true;
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							
							this.showRowEdit = true;
						}
						else if (this.popupParames.sceneCode == "open") {
							//部分通过,可编辑头,可编辑未提交明细,仅单条提交
							this.isallrefuse = true;
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							
							this.showRowEdit = true;
						} */
						else if (this.popupParames.sceneCode == "licence_version") {//商业变更
							//可编辑头,可编辑未提交明细,仅单条提交
							this.iscustomerchange = true;
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							
							this.isRefresh = false;
						}
						/* else if (this.popupParames.sceneCode == "versionedit") {//商业变更后提交前的编辑
							//可编辑头,可编辑未提交明细,仅单条提交
							this.iscustomerchange = true;
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							
							this.isRefresh = false;
						}
						else if (this.popupParames.sceneCode == "versionedit_refuse") {//商业变更后拒绝后的编辑
							//可编辑头,可编辑未提交明细,仅单条提交
							this.iscustomereditchange = true;
							this.formAttr.disabled = false;
							this.formAttr_zz.disabled = false;
							this.formAttr_kp.disabled = false;
							
							this.isRefresh = false;
						} */
						
					}
				},
				
				mounted() {
					var me = this;
					if (this.dataRequest.length) {
						var result = {};
						this.loadRequestData(this.dataRequest, result, function(data) {
							me.dataRequestObj = data;
							
							if (me.dataRequestObj.customerRequiredByRoleid) {
								me.customerRequiredByRoleid = clone(me.dataRequestObj.customerRequiredByRoleid)
								
								var customerRequiredByRoleidTypeObj = {};
								var customerRequiredByRoleidTypeList = {};
								me.customerRequiredByRoleid.map(cfr=>{
									if (!customerRequiredByRoleidTypeObj[cfr.type]) {
										customerRequiredByRoleidTypeObj[cfr.type] = {};
										customerRequiredByRoleidTypeList[cfr.type] = [];
									}
									customerRequiredByRoleidTypeObj[cfr.type][cfr.field] = cfr;
									customerRequiredByRoleidTypeList[cfr.type].push(cfr);
								})
								me.customerRequiredByRoleidTypeObj = clone(customerRequiredByRoleidTypeObj);
								me.customerRequiredByRoleidTypeList = clone(customerRequiredByRoleidTypeList);
							}
							
							if (me.popupParames.sceneCode == "approval") {
								//根据审批人角色等存在不同的编辑权限
								var roleList_ = localStorage.getItem("roleList");
								me.roleList = JSON.parse(roleList_);
								var roleEditAble_ = me.dataRequestObj.roleEditAble;
								var role_edit = false;
								//var role_edit = true;
								if (me.roleList.length && roleEditAble_ && roleEditAble_.length) {
									roleEditAble_.map(re=>{
										var role_id = re.r_id;
										me.roleList.map(zre=>{
											if (role_id == zre.id) {
												role_edit = true;
												//return
											}
										})
										
										/* if(role_edit) {
											return
										} */
									});
								}
								
								if (role_edit) {//审批节点可编辑.
									me.formAttr.disabled = false;
									me.formAttr_zz.disabled = false;
									me.formAttr_kp.disabled = false;
									me.isapprovaledit = true;
									me.approval = true;
								}
								else {
									me.approval = true;
								}
							}
							
							if (me.popupParames.sceneCode == "versionapproval") {
								//me.isapprovaledit = true;
							}
							
							if(me.formFields.length > 0) {
								var formFields_ = clone(me.formFields);
								var requiredFields_business = me.customerRequiredByRoleidTypeObj.business;
								formFields_.map(e=>{
									if (requiredFields_business[e.field] && (requiredFields_business[e.field].is_required == "T" || requiredFields_business[e.field].roleis_required == "T")) {
										e.required = true;
									}
									else if (requiredFields_business[e.field]) {
										e.required = false;
									}
									
									if(e.field == "uscc") {
										// if(me.iscustomerchange || me.iscustomereditchange || me.isapprovaledit || me.formData.old_id) {
										// 	e.disabled = true;
										// }
									}
									if(e.field == "md_description" || e.field == "legal_rep" || e.field == "address") {
										if(me.isapprovaledit) {
											e.disabled = true;
										}
									}
									
									if(e.field == "cus_dep_code") {
										e.options = me.dataRequestObj.hierarchy;
									}
									if(e.field == "record_province") {
										e.options = me.dataRequestObj.division_level1;
									}
									
									if(me.popupParames.sceneCode == "versionapproval") {
										e.disabled = true;
									}
									
									me.formFieldsObj[e.field] = e;
								});
								
								var roleList_ = localStorage.getItem("roleList");
								me.roleList = JSON.parse(roleList_);
								var bo_ = false;
								me.roleList.map(zre=>{
									if ("sp003_1" == zre.id) {//manager03
										me.formAttr.disabled = false;
										bo_ = true;
										var formFields_eas = {isshow: "T", field: "old_code", name: "EAS编码", disabled: false};
										formFields_.push(formFields_eas);
									}
								})
								if (!bo_) {
									var formFields_eas = {isshow: "T", field: "old_code", disabled: true, name: "EAS编码"};
									formFields_.push(formFields_eas);
								}
								
								
								me.formFields = formFields_;
							}
							
							if (me.tableFields.length) {
								var tableFields_ = clone(me.tableFields);
								tableFields_.map(fieldObj_=>{
									if (fieldObj_.field == "delivery_part_code") {
										fieldObj_.formatterjson = me.dataRequestObj.map.deliveryOrganizationOpen;
									}
									if (fieldObj_.field == "customer_part_code") {
										fieldObj_.formatterjson = me.dataRequestObj.map.dictitem;
									}
								});
								me.tableFields = tableFields_;
							}
							
							if (me.tableFields_part.length) {
								var tableFields_part_ = clone(me.tableFields_part);
								var requiredFields_delivery = me.customerRequiredByRoleidTypeObj.delivery;
								tableFields_part_.map(e=>{
									if (requiredFields_delivery[e.field] && (requiredFields_delivery[e.field].is_required == "T" || requiredFields_delivery[e.field].roleis_required == "T")) {
										e.required = true;
									}
									else if (requiredFields_delivery[e.field]) {
										e.required = false;
									}
									
									if(e.field == "delivery_part_code") {
										e.options = me.dataRequestObj.deliveryOrganizationOpen;
										
										me.dataRequestObj.deliveryOrganizationOpen.map(e=>{
											if (!me.dataRequestObj.map) {
												me.dataRequestObj.map = {};
											}
											if (!me.dataRequestObj.map.deliveryOrganizationOpen) {
												me.dataRequestObj.map.deliveryOrganizationOpen = {};
											}
											me.dataRequestObj.map.deliveryOrganizationOpen[e.code] = e.name;
										})
									}
									
									if(e.field == "customer_part_code") {
										e.options = me.dataRequestObj.dictitem;
										
										me.dataRequestObj.dictitem.map(e=>{
											if (!me.dataRequestObj.map) {
												me.dataRequestObj.map = {};
											}
											if (!me.dataRequestObj.map.dictitem) {
												me.dataRequestObj.map.dictitem = {};
											}
											me.dataRequestObj.map.dictitem[e.code] = e.value;
										})
									}
								});
								
								me.tableFields_part = tableFields_part_;
							}
							
							me.initData();
						});
					}
					else {
						this.initData();
					}
					
					var urlParam = getGetParams(this.popupParames.url);
					
					for(let key in urlParam) {
						if(key == "fromDing") {
							this.fromDing = urlParam[key];
						}
					}
							
					this.$nextTick(() => { // 以服务的方式调用的 Loading 需要异步关闭
						document.getElementById('page_root').style.display =  "block";
						document.getElementById('page_loading').style.display =  "none";
						
						//重新设置弹窗宽高
						this.$nextTick(function(){
							let w_ = this.$refs.popup_body.offsetWidth + "px";
							let h_ = this.$refs.popup_body.offsetHeight + "px";
							Root.setPopupWH(w_, h_);
						})
					});
				},
				
				methods:{
					onServerInitData(data) {
						var me = this.data;
						me.filterFields = data.filterFields;
						me.formFields = data.formFields;
						me.tableFields = data.tableFields;
						
						if(me.filterFields.length > 0) {
							me.filterFields.map(e=>{
								me.filterFieldsObj[e.field] = e;
							});
						}
						
						if(me.formFields.length > 0) {
							me.formFields.map(e=>{
								me.formFieldsObj[e.field] = e;
							});
						}
						if(me.tableFields.length > 0) {
							me.tableFields.map(e=>{
								me.tableFieldsObj[e.field] = e;
							});
						}
					},
					
					initData() {
						let me = this;
						this.getAttachmentType();
						if(this.acctObj.cer_id) {//自销资质id
							this.getInfoForm_me();//自销商业信息
							this.getInfoKP();//开票信息
							this.getTableDelivery();//发货主体
							
							this.getInfoSH();//收货信息
							this.getInfoCG();//采购信息
							this.getInfoWL();//物流信息
							
							if (!this.formAttr.disabled && this.acctObj.old_id && this.popupParames.sceneCode != "version") {
								this.getInfoOldForm();//oldFormData//变更用
							}
							if (this.acctObj.old_id) {
								this.getInfoFormOld();//formDataOld//差异显示用
							}
						}
						else {
							if (this.tableData2.length == 0) {
								var delivery_part_obj_ = {};
								//var roleList_ = localStorage.getItem("roleList");
								//me.roleList = JSON.parse(roleList_);
								me.roleList.map(zre=>{
									if (me.partObjByRole[zre.id]) {//manager03
										delivery_part_obj_ = me.partObjByRole[zre.id];
									}
								})
								
								//设置默认主体
								this.newtabledata_part[0].delivery_part_code = delivery_part_obj_.delivery_part_code;//发货主体
								this.newtabledata_part[0].delivery_part_name = delivery_part_obj_.delivery_part_name;//发货主体
								//this.tableData2 = clone(this.newtabledata_part);
								
								//设置默认收货
								me.tabs_sh = [];
								var form_sh = clone(me.default_form_sh);
								me.tabs_sh.push(form_sh);
								me.tabs_sh_old = [];
								me.activeTabs_sh = "0_";
								//设置默认采购
								me.tabs_cg = [];
								var form_cg = clone(me.default_form_cg);
								me.tabs_cg.push(form_cg);
								me.tabs_cg_old = [];
								me.activeTabs_cg = "0_";
							}
							
							if (me.popupParames.sceneCode == "add_mdm") {
								this.getInfoKP();
							}
							
							this.getInitOption();
						}
					},
					
					getAttachmentType() {
						let me = this;
						let param_table = {
							isClientMode: false,
							dataname: "attachment_type",
							orderby: "order_no"
						}
						this.attachment_type_zs = [];//证书
						this.attachment_type_zb = [];//质保
						
						
						Server.call("root/data/getEntitySet", param_table, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset) {
								var attachmentTypes_ = result.data.entityset;
								
								var requiredFields_zz = me.customerRequiredByRoleidTypeObj.licence_zz;
								var requiredFields_zb = me.customerRequiredByRoleidTypeObj.licence_zb;
								attachmentTypes_.map(e=>{
									if(!me.file_zs[e.code]) {
										me.file_zs[e.code] = {};
									}
									if (e.owned_by) {
										if (e.cer_mandatory) {
											e.rules = [];
											let required_ = {
												required: true,
												message: "请上传"+e.name, 
												trigger: "blur" 
											};
											e.rules.push(required_);
										}
										
										if (requiredFields_zz[e.code] && (requiredFields_zz[e.code].is_required == "T" || requiredFields_zz[e.code].roleis_required == "T")) {
											//e.required = true;
											e.rules = [];
											let required_ = {
												required: true,
												message: "请上传"+e.name, 
												trigger: "blur" 
											};
											e.rules.push(required_);
										}
										else if (requiredFields_zz[e.code]) {
											//e.required = false;
											e.rules = null;
										}
										
										
										me.attachment_type_zs.push(e);
									}
									else {
										if (e.cer_mandatory) {
											e.rules = [];
											let required_ = {
												required: true,
												message: "请上传"+e.name, 
												trigger: "blur" 
											};
											e.rules.push(required_);
										}
										
										if (requiredFields_zb[e.code] && (requiredFields_zb[e.code].is_required == "T" || requiredFields_zb[e.code].roleis_required == "T")) {
											//e.required = true;
											e.rules = [];
											let required_ = {
												required: true,
												message: "请上传"+e.name, 
												trigger: "blur" 
											};
											e.rules.push(required_);
										}
										else if (requiredFields_zb[e.code]) {
											//e.required = false;
											e.rules = null;
										}
										
										me.attachment_type_zb.push(e);
									}
									
									me.attachment_type_zzobj[e.code] = e;
									
								});
							}
							me.getInfoZZ();//证照信息
						});
					},
					
					getInfoOldForm() {
						var me = this;
						var customer_id_ = this.acctObj.old_id;
						
						var dataname_ = "agCustomer";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: "id='" + customer_id_ + "'",
						}
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length>0) {
								me.oldFormData = clone(result.data.entityset[0]);
							}
						});
					},
					
					//自销商业信息
					getInfoForm_me() {
						var me = this;
						var id_ = this.acctObj.id;
						
						var dataname_ = "direct_customer";
						
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: "dc.id='" + id_ + "'",
						}
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data) {
								var formData_ = result.data.entityset[0];
								if (me.popupParames.sceneCode == "version") {
									me.oldFormData = clone(formData_);
									formData_.id = null;
									formData_.old_id = clone(me.acctObj.id);
									formData_.flow_id = null;
									formData_.freeze = null;
									formData_.status = null;
									formData_.create_time = null;
								}
								me.formData = formData_;
								me.old_data_syxx = clone(formData_);
								me.getInitOption();
							}
						});
					},
					
					getInfoForm(customer_id) {
						var me = this;
						var dataname_ = "agCustomer";
						
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: "id='" + customer_id + "'",
						}
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data) {
								var dataobj_ = result.data.entityset[0];
								
								var id_ = uuid_short();
								me.acctObj = clone(dataobj_);
								me.formData = clone(dataobj_);
								me.acctObj.create_operate_id = me.formData.create_operate_id = me.newtabledata_part[0].business_operate_id;
								me.acctObj.create_operate_code = me.formData.create_operate_code = me.newtabledata_part[0].business_operate_code;
								me.acctObj.create_operate_name = me.formData.create_operate_name = me.newtabledata_part[0].business_operate_name;
								me.acctObj.old_id = me.formData.old_id = dataobj_.id;
								me.acctObj.id = me.formData.id = id_;
								me.acctObj.active = me.formData.active = "0";
								me.acctObj.flow_id = me.formData.flow_id = "";
								
								me.old_data_syxx = clone(dataobj_);
								
								//设置默认自销主体数据
								me.newtabledata_part[0].customer_uscc = me.formData.uscc;//发货主体中的商业uscc
								me.newtabledata_part[0].customer_id = me.formData.id;//发货主体中的商业id
								me.tableData2 = clone(me.newtabledata_part);//主体明细
								
								me.tabs_sh = [];
								var form_sh = clone(me.default_form_sh);
								me.tabs_sh.push(form_sh);
								me.tabs_sh_old = [];
								me.activeTabs_sh = "0_";
								
								me.tabs_cg = [];
								var form_cg = clone(me.default_form_cg);
								me.tabs_cg.push(form_cg);
								me.tabs_cg_old = [];
								me.activeTabs_cg = "0_";
								
								me.getInitOption();
								
								//设置默认发货主体
								me.addDeliveryByDefault(id_);
							}
						});
					},
					
					getInfoFormOld() {
						var me = this;
						var customer_id_ = this.acctObj.old_id;
						
						var dataname_ = "direct_customer";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: "dc.id='" + customer_id_ + "'",
						}
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length>0) {
								me.formDataOld = clone(result.data.entityset[0]);
							}
						});
					},
					
					getInfoZZ() {
						var me = this;
						if (me.popupParames.sceneCode == "add_mdm") {
							if (this.popupParames.data.licenceList && this.popupParames.data.licenceList.length) {
								var zzList = clone(this.popupParames.data.licenceList);
								zzList.map(zz=>{
									me.file_zs[zz.type] = zz;
								});
							}
						}
						else if (this.acctObj.cer_id) {
							var cer_id = this.acctObj.cer_id;
							
							var filter_ = "customer_certification_id='" + cer_id + "'";
							var dataname_ = "direct_customer_licence_mapping";
							let param_ = {
								isClientMode: false,
								dataname: dataname_,
								filter: filter_,
								orderby: "create_time desc"
							}
							// if(!this.acctObj.customer_id) {
							// 	param_.empId = localStorage.getItem("emp_id");
							// 	param_.subFilter = "customer_id = '" + this.acctObj.id + "'"
							// }
							// else {
							// 	param_.subFilter = "customer_id = '" + this.acctObj.customer_id + "'"
							// }
							
							Server.call("root/data/getEntitySet", param_, function(result) {
								console.log(result);
								/* if (result && result.data && result.data.entityset && result.data.entityset.length > 0) {
									//me.licenceList = result.data.entityset;
									result.data.entityset.map(e=>{
										me.file_zs[e.type] = e;
									});
									
									
								} */
								
								if (result && result.data) {
									//me.licenceList = result.data.entityset;
									var file_zs_ = clone(me.file_zs);
									result.data.entityset.map(e=>{
										file_zs_[e.type] = e;
									});
									
									me.attachment_type_zb.map(zb=>{
										if (!file_zs_[zb.code]) {
											file_zs_[zb.code] = {}
										}
									});
									
									me.file_zs = file_zs_;
									me.file_zs_old = clone(me.file_zs);
									
									me.getInfoZZOld(result.data.entityset);
								}
								
							});
						}
						else {
							var file_zs_ = clone(me.file_zs);
							me.attachment_type_zb.map(zb=>{
								if (!file_zs_[zb.code]) {
									file_zs_[zb.code] = {}
								}
							});
							
							me.file_zs = file_zs_;
							me.file_zs_old = clone(me.file_zs);
							
						}
					},
					
					getInfoZZOld(table) {
						var me = this;
						this.file_zsold = {};
						var ids_ = "";
						
						table.map(t=>{
							if (t.old_id) {
								if (!ids_) {
									ids_ = "'" + t.old_id + "'";
								}
								else {
									ids_ += ",'" + t.old_id + "'";
								}
							}
						});
						
						if (ids_) {
							var filter_ = " customer_certification_id.id in (" + ids_ + ")";
							var dataname_mapping = "direct_customer_licence_mapping";
							let param_table = {
								isClientMode: false,
								dataname: dataname_mapping,
								filter: filter_,
								subFilter: ' 1=1 '
							}
							
							Server.call("root/data/getEntitySet", param_table, function(result_) {
								console.log(result_);
								if (result_ && result_.data && result_.data.entityset && result_.data.entityset.length > 0) {
									result_.data.entityset.map(e=>{
										me.file_zsold[e.type] = e;
									});
								}
							});
						}
					},
					
					getInfoKP() {
						var me = this;
						var cer_id_ = this.acctObj.cer_id;
						
						var filter_ = "customer_certification_id='" + cer_id_ + "'";
						var dataname_ = "direct_customer_invoice_mapping";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: filter_,
							orderby: "create_time desc"
						}
						
						param_.empId = localStorage.getItem("emp_id");
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length) {
								var formData_kp_ = result.data.entityset[0];
								me.formData_kp = formData_kp_;
								//保留原先的数据,用于在保存时判断是否有修改
								me.formData_kp_old = clone(me.formData_kp);
								
								//获取上个版本的数据,为了显示差异
								var table_ = [];
								table_.push(result.data.entityset[0]);
								me.getInfoKPOld(table_);
							}
						});
					},
					
					getInfoKPOld(table) {
						var me = this;
						this.formData_kpold = {};
						var ids_ = "";
						
						table.map(t=>{
							if (t.old_id) {
								if (!ids_) {
									ids_ = "'" + t.old_id + "'";
								}
								else {
									ids_ += ",'" + t.old_id + "'";
								}
							}
						});
						
						if (ids_) {
							var filter_ = " id in (" + ids_ + ")";
							var dataname_mapping = "agCustomerInvoice";
							let param_table = {
								isClientMode: false,
								dataname: dataname_mapping,
								filter: filter_,
							}
							param_table.subFilter = "1=1"
							
							Server.call("root/data/getEntitySet", param_table, function(result_) {
								console.log(result_);
								if (result_ && result_.data && result_.data.entityset && result_.data.entityset.length) {
									me.formData_kpold = result_.data.entityset[0];
								}
							});
						}
					},
					
					getInfoSH() {
						var me = this;
						var cer_id_ = this.acctObj.cer_id;
						
						var filter_ = "customer_certification_id='" + cer_id_ + "'";
						
						var dataname_ = "direct_customer_delivery_consignee_mapping";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: filter_,
							orderby: "order_no"
						}
						me.tabs_sh = [];
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length) {
								me.activeTabs_sh = "0_";
								me.tabs_sh = result.data.entityset;
								me.tabs_sh_old = clone(me.tabs_sh);
								
								result.data.entityset.map(e=>{
									me.tabs_sh_old_obj[e.id] = clone(e);
								});
								
							}
							
							else {
								var form_sh = clone(me.default_form_sh);
								me.tabs_sh.push(form_sh);
								me.tabs_sh_old = [];
								me.activeTabs_sh = "0_";
							}
						});
						
					},
					getInfoCG() {
						var me = this;
						var cer_id_ = this.acctObj.cer_id;
						
						var filter_ = "customer_certification_id='" + cer_id_ + "'";
						
						var dataname_ = "direct_customer_delivery_procure_mapping";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: filter_,
							orderby: "order_no"
						}
						me.tabs_cg = [];
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length) {
								me.activeTabs_cg = "0_";
								me.tabs_cg = result.data.entityset;
								me.tabs_cg_old = clone(me.tabs_cg);
								result.data.entityset.map(e=>{
									me.tabs_cg_old_obj[e.id] = clone(e);
									//me.tabsobj_sh[e.type] = e;
								});
							}
							
							else {
								var form_cg = clone(me.default_form_cg);
								me.tabs_cg.push(form_cg);
								me.tabs_cg_old = [];
								me.activeTabs_cg = "0_";
								
							}
						});
					},
					getInfoWL() {
						var me = this;
						var cer_id_ = this.acctObj.cer_id;
						
						var filter_ = "id='" + cer_id_ + "'";
						
						var dataname_ = "direct_customer_delivery_certification_mapping";
						let param_ = {
							isClientMode: false,
							dataname: dataname_,
							filter: filter_,
						}
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data && result.data.entityset && result.data.entityset.length) {
								var certification_ = result.data.entityset[0];
								me.certificationObj = clone(certification_);
								me.logistics_company = certification_.logistics_company
								me.logistics_no = certification_.logistics_no
								me.logistics_check = certification_.logistics_check
							}
							
							else {
								me.logistics_company = ""
								me.logistics_no = ""
								me.logistics_check = false
								
							}
						});
						
						
					},
					
					getTableDelivery() {
						var me = this;
						var id_ = this.acctObj.id;
						
						var filter_ = "1=1 and delivery_part_code='" + this.newtabledata_part[0].delivery_part_code + "'";
						var dataname_mapping = "direct_customer_delivery_mapping";//"delivery_mapping";
						filter_ += " and customer_id='"+ id_ + "'";
						
						let param_table = {
							isClientMode: false,
							dataname: dataname_mapping,
							filter: filter_,
						}
						
						me.tableData2 = [];
						me.tableloading = true;
						
						Server.call("root/data/getEntitySet", param_table, function(result_) {
							me.tableloading = false;
							console.log(result_);
							if (result_ && result_.data && result_.data.entityset && result_.data.entityset.length > 0) {
								me.tableData2 = result_.data.entityset;
								me.getTableDataOld(result_.data.entityset);
							}
							else {
								//设置默认发货主体
								me.addDeliveryByDefault(id_);
							}
						});
					},
					
					getTableDataOld(table) {
						var me = this;
						this.tableDataOld = [];
						this.tableDataOldObj = {};
						var tableDataObj_ = {};
						var ids_mapping = {};
						var ids_ = "";
						
						var notCompareField = ["update_time"];
						
						table.map(t=>{
							if (t.old_id) {
								tableDataObj_[t.id] = t;
								ids_mapping[t.old_id] = t.id;
								if (!ids_) {
									ids_ = "'" + t.old_id + "'";
								}
								else {
									ids_ += ",'" + t.old_id + "'";
								}
							}
						});
						
						if (ids_) {
							var filter_ = " a.id in (" + ids_ + ")";
							var dataname_mapping = "direct_customer_delivery_mapping";
							let param_table = {
								isClientMode: false,
								dataname: dataname_mapping,
								filter: filter_,
							}
							
							Server.call("root/data/getEntitySet", param_table, function(result_) {
								console.log(result_);
								if (result_ && result_.data && result_.data.entityset && result_.data.entityset.length > 0) {
									me.tableDataOld = result_.data.entityset;
									var tableDataOldObj_ = {};
									me.tableDataOld.map(o=>{
										notCompareField.map(f=>{
											o[f] = tableDataObj_[ids_mapping[o.id]][f];
										})
										
										tableDataOldObj_[ids_mapping[o.id]] = o;
									});
									
									me.tableDataOldObj = tableDataOldObj_;
								}
							});
							
						}
						
						
						//tableDataOldObj
					},
					
					getInitOption() {
						var me = this;
						this.formFields.map(e=>{
							if (e.type == "select" && e.options && e.options.length == 0 && this.formData[e.field]) {
								if (e.field == "country") {
									let param_ = {
										isClientMode: false,
										filter: " level='0' and active='1' and code='" + this.formData[e.field] + "'",
									}
									Server.call("root/data/getEntitySet/division_level0", param_, function(result){
										options_ = result.data.entityset;
										e.options = options_;
										
										me.showform = false;
										me.$nextTick(() => {
											me.showform = true;
										});
									});
								}
								else if (e.field == "province") {
									if (e.selectparent) {
										if(!this.formData[e.selectparent]) {
											e.options = []
										}
										else {
											var code_ = this.formData[e.selectparent];
											let param_ = {
												isClientMode: false,
												filter: " level='1' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
											}
											Server.call("root/data/getEntitySet/division_level1", param_, function(result){
												options_ = result.data.entityset;
												e.options = options_;
												
												me.showform = false;
												me.$nextTick(() => {
													me.showform = true;
												});
											});
										}
									}
								}
								else if (e.field == "city") {
									if (e.selectparent) {
										if(!this.formData[e.selectparent]) {
											e.options = []
										}
										else {
											var code_ = this.formData[e.selectparent];
											let param_ = {
												isClientMode: false,
												filter: " level='2' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
											}
											Server.call("root/data/getEntitySet/division_level2", param_, function(result){
												options_ = result.data.entityset;
												e.options = options_;
												
												me.showform = false;
												me.$nextTick(() => {
													me.showform = true;
												});
											});
										}
									}
								}
								else if (e.field == "county") {
									if (e.selectparent) {
										if(!this.formData[e.selectparent]) {
											e.options = []
										}
										else {
											var code_ = this.formData[e.selectparent];
											let param_ = {
												isClientMode: false,
												filter: " level='3' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
											}
											Server.call("root/data/getEntitySet/division_level3", param_, function(result){
												options_ = result.data.entityset;
												e.options = options_;
												
												me.showform = false;
												me.$nextTick(() => {
													me.showform = true;
												});
											});
										}
									}
								}
							}
						})
					},
					
					//saveAfter
					closeDialog() {
						/* if (this.popupParames.totab){
							Root.tab.removeItem(Root.tab.selected);
							Root.tab.open(me.popupParames.parentOption, false); 
						}
						else {
							Root.hidePopup();
						} */
						this.saveAfter();
					},
					
					checkDataByJC() {
						var bo_ = false;
						//证照检查
						//bo_ = this.checkDataByZZ();
						return bo_;
					},
					checkDataByZZ() {
						var bo = false;
						var me = this;
						//资质证照
						me.warningzs = {};
						if(me.file_zs.ZGL01 && me.file_zs.ZGL01.file_id) {
							me.attachment_type_zs.map(t=>{
								if (me.file_zs[t.code].file_id) {
									me.tableFields_zz.map(f=>{
										if (f.required && !me.file_zs[t.code][f.field]) {
											me.warningzs[t.code] = true;
											bo = true;
										}
									})
								}
							})
						}
						else {//资质证照没有
							bo = true;
							me.warningzs.ZGL01 = true;
						}
						
						return bo;
					},
					
					verification(id_) {
						let me = this;
						var bo_ = false;
						if (!this.formData.uscc) {
							Root.message({
								type: 'warning',
								message: "没有统一信用代码"
							})
							return;
						}
						
						let param_table = {
							isClientMode: false,
							dataname: "getStatusByCustomerUscc",
							returnType: "entityset",
							
							filter: "customer_delivery_mapping.customer_uscc = '" + this.formData.uscc + "'"
						}
						Server.call("root/data/procedure", param_table, function(result) {
							console.log(result);
							me.notApprovalData = [];
							if (result.data.entityset && result.data.entityset.length) {
								me.dialog_notapproval = true;
								me.notApprovalData = result.data.entityset;
							}
							else {
								bo_ = true;
							}
							
							if (bo_) {
								me.doSubmitForm(id_);
							}
							
						});
					},
					
					//商业撤销
					cancelEditForm() {
						this.canceltype = "customer";
						this.textarea2 = "";
						this.reasonvisible = true;
						this.reasonvisible_flowid = this.formData.flow_id;
						this.passOrRefuse = false;
						this.type_act = "accountCustomerDelivery";
					},
					/* onrefuseApproval(){
						this.textarea2 = "";
						this.reasonvisible = true;
						this.reasonvisible_flowid = this.formData.flow_id;
						this.passOrRefuse = false;
						this.type_act = "accountCustomerCertification";
					},
					saveReason(){
						this.loading_approval = true;
						if(this.passOrRefuse){
							this.passApproval(true,this.textarea2)
						}else{
							if(this.textarea2 != ""){
								this.passApproval(false,this.textarea2)
							}
							else{
								Root.message({
									type: 'warning',
									message: '请填写原因'
								});
								this.loading_approval = false;
							}
						}
					},
					
					//审批
					passApproval(pass_,reason_) {
						let me = this;
						
						if(reason_) {
							//去除两端的空格
							reason_ = reason_.replace(/(^\s*)|(\s*$)/g, "");
							
							//去除中间的回车换行
							reason_ = reason_.replace(/[\r\n]/g,"");
						}
						
						var variable_map_ = {
							reason: reason_,
							stict: false
						}
						
						if (this.acctObj.freeze) {
							variable_map_ = {
								reason: reason_,
								stict: false,
								
								province: me.acctObj.record_province,
								partType: me.acctObj.part_type,
								businessType: me.acctObj.business_type,
								customerPartCode: me.acctObj.customer_part_code,
								operateCode: me.acctObj.operator_code
							}
						}
						
						if (this.attachment) {
							variable_map_.attachment = this.attachment;
						}
						
						let param = {
							flow_id: this.acctObj.cer_flow_id,
							pass: pass_,
							
							variable_map: variable_map_,
							business_type: this.type_act,
							isClientMode: false
						}
						Server.call("root/api/dealAct", param, function(result) {
							console.log(result);
							me.loading_approval = true;
							if (result.success){
								Root.message({
									type: 'success',
									message: '审批成功'
								}); 
							}else{
								Root.message({
									type: 'warning',
									message: '审批失败'
								}); 
							}
							me.saveAfter();
						});
					}, */
					submitEditForm() {
					    var me = this;
					    var actpassword_ = localStorage.getItem("actpassword");
					    if (actpassword_) {
					        var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									me.do_submitEditForm();
									if (callback) {
										callback();
									}
								}
					       };
					       this.doPopupByPublic(config);
					    }
					    else {
					       this.do_submitEditForm();
					    }
					},
					
					do_submitEditForm() {
						this.issubmit = true;
						this.saveForm(true);//拒绝后的提交
					},
					
					submitForm() {
					    var me = this;
					    var actpassword_ = localStorage.getItem("actpassword");
					    if (actpassword_) {
					        var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									me.dosubmitForm();
									if (callback) {
										callback();
									}
								}
					       };
					       this.doPopupByPublic(config);
					    }
					    else {
					       this.dosubmitForm();
					    }
					},
					
					dosubmitForm() {
						this.issubmit = true;
						this.saveForm();//变更后的提交
					},
					
					saveForm(isrefuse) {
						var me = this;
						let params = clone(this.formData);
						
						if (me.oldFormData.id && (params.md_description != me.oldFormData.md_description || params.record_province != me.oldFormData.record_province)) {
							Root.confirm('更改商业名称或备案省份提交后将冻结其所有备案数据', '冻结提示', {
							  confirmButtonText: '继续更改',
							  cancelButtonText: '取 消',
							  type: 'warning'
							}).then(() => {
								//继续提交
								me.dosaveForm(params, isrefuse);
							}).catch(() => {
								//取消更改,后获取之前的数据并更改本次的数据
								params.md_description = me.oldFormData.md_description;
								params.record_province = me.oldFormData.record_province;
								me.issubmit = false;
								me.dosaveForm(params, isrefuse);
							});
						}
						else {
							me.dosaveForm(params, isrefuse);
						}
					},
					
					dosaveForm(params, isrefuse) {
						var me = this;
						
						if (!params.old_id && me.formData.status) {
							params.old_id = this.acctObj.id;
						}
						else {
							params.strict = false;
						}
						
						if (!params.uscc) {
							Root.message({
								type: 'warning',
								message: '请先设置统一社会信用代码'
							});
							return
						}
						
						//证照
						var licenceList_ = [];
						this.attachment_type_zs.map(zs=>{
							var zsobj_ = me.file_zs[zs.code];
							if (zsobj_.file_id) {
								if(zsobj_.customer_id && zsobj_.customer_id != me.formData.id) {
									zsobj_.old_id = clone(zsobj_.id);
									zsobj_.id = null;
									zsobj_.create_time = null;
								}
								
								licenceList_.push(zsobj_);
							}
						});
						
						if (licenceList_.length) {
							params.licence_list = licenceList_;
						}else {
							params.licence_list = null;
						}
						
						
						//开票
						var formData_kp_notnull = false;
						for (var kp_ in me.formData_kp) {
							
							if (kp_ == "customer_id" && me.formData_kp.customer_id != me.formData.id) {
								me.formData_kp.old_id = clone(me.formData_kp.id);
								me.formData_kp.id = null;
								me.formData_kp.create_time = null;
							}
							
							formData_kp_notnull = true;
						}
						if (formData_kp_notnull) {
							if(!me.formData_kp.customer_uscc) {
								me.formData_kp.customer_uscc = this.formData.uscc;
							}
							if(this.formData.id && !me.formData_kp.customer_id) {
								me.formData_kp.customer_id = this.formData.id;
							}
							
							params.invoice = me.formData_kp;
						}else {
							params.invoice = null;
						}
						
						params.dataName = "agCustomer";
						params.type = "update";
						params.isClientMode = false;
						
						Server.call("root/customer/saveCustomer", params, function(result) {
							console.log(result);
							me.formData.id = result.data.id;
							
							
							var result_ = result;
							if (result && result.success) {
								if(me.issubmit) {
									me.issubmit = false;
									//提交检测
									var id_ = params.id;
									if(!id_) {
										id_ = result.data.id;
									}
									if (isrefuse) {
										me.doSubmitEditForm();
									}
									else {
										let param_table = {
											isClientMode: false,
											dataname: "getCustomerStatus",
											returnType: "entityset",
											filter: "uscc='" + me.formData.uscc + "'"
										}
										Server.call("root/data/procedure", param_table, function(result_t) {
											console.log(result_t);
											if (result_t.data.entityset && result_t.data.entityset.length) {
												Root.message({
													type: 'warning',
													message: '该商业已存在流程'
												});
												
												me.saveAfter();
											}
											else {
												me.verification(id_);
											}
										});
									}
									
									
									
									/* var bo_ = me.checkDataByJC();
									
									if (bo_) {//true:存在检查不通过数据
										
										return
									}
									
									var id_ = params.id;
									if(!id_) {
										id_ = result.data.id;
									}
									var param_submit = {
										isClientMode: false,
										id: id_,
									}
									
									Server.call("root/customer/commitModifyCustomer", param_submit, function(result2) {
										console.log(result2);
										Root.message({
											type: 'success',
											message: '提交成功'
										}); 
										
										me.saveAfter();
									}); */
									
									
									
									/* 
									var param_submit = {
										isClientMode: false,
										business_id: id_,
										business_type: "accountCustomer"
									}
									Server.call("root/api/startAct", param_submit, function(result1) {
										console.log(result1);
										let param_act = {
											id: id_,
											flow_id: result1.data.activitiId
										};
										param_act.isClientMode = false;
										param_act.dataname = "agcustomer";
										
										Server.call("root/data/updateEntity", param_act, function(result2) {
											console.log(result2);
											Root.message({
												type: 'success',
												message: '提交成功'
											}); 
											
											//me.saveAfter();
										});
									}); */
								}
								else {
									Root.message({
										type: 'success',
										message: '保存成功'
									}); 
									
									me.saveAfter();
								}
							}
						}, function(result1) {
							console.log(result1);
							me.issubmit = false;
							if (result1.message) {
								Root.message({
									type: 'error',
									message: result1.message
								}); 
							}
						})
					},
					
					doSubmitForm(id_) {
						var me = this;
						var bo_ = me.checkDataByJC();
						
						if (bo_) {//true:存在检查不通过数据
							return
						}
						
						var param_submit = {
							isClientMode: false,
							id: id_,
						}
						
						Server.call("root/customer/commitModifyCustomer", param_submit, function(result2) {
							console.log(result2);
							Root.message({
								type: 'success',
								message: '提交成功'
							}); 
							
							//变更提交商业信息日志
							me.saveAfter("syxx");
							me.saveAfter();
						});
					},
					
					doSubmitEditForm() {
						var me = this;
						var internationPart_ = false;
						if (this.formData.apply_dep_code && this.formData.apply_dep_code == "202105180005") {
							internationPart_ = true;
						}
						
						let param_act = {
							flow_id: this.formData.flow_id,
							pass: true,
							
							variable_map:{reason: "调整提交"},
							business_type: "accountCustomerDelivery",
							isClientMode: false,
							variableMap: {
								internationPart: internationPart_
							}
						}
						Server.call("root/api/dealAct", param_act, function(result1) {
							console.log(result1);
							if (result1.success){
								Root.message({
									type: 'success',
									message: '提交成功'
								}); 
								
								//拒接后提交商业信息日志
								me.saveAfter("syxx");
							}else{
								Root.message({
									type: 'warning',
									message: '提交失败'
								}); 
							}
							me.saveAfter();
						});
					},
					
					submitRowTable() {
					    var me = this;
					    var actpassword_ = localStorage.getItem("actpassword");
					    if (actpassword_) {
					        var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									me.dosubmitRowTable();
									if (callback) {
										callback();
									}
								}
					       };
					       this.doPopupByPublic(config);
					    }
					    else {
					       this.dosubmitRowTable();
					    }
					},
					
					dosubmitRowTable() {
						this.issubmit = true;
						this.saveRowTable();
					},
					saveRowTable() {
						var me = this;
						//校验一条在不在数组中;
						this.checkDataByRow(this.tableData2, this.selectrow, "edit", function() {
							me.doSaveRowTable();
						}, function() {
							me.selectrow = {};
							me.issubmit = false;
							Root.message({
								type: 'warning',
								message: '已存在相同数据'
							});
							return
						});
					},
					
					doSaveRowTable() {
						var me = this;
						var row = clone(this.selectrow);
						let params = row;
						
						params.customer_id = this.formData.id;
						params.customer_uscc = this.formData.uscc;
						
						params.isClientMode = false;
						Server.call("root/customer/saveCustomerDelivery", params, function(result) {
							console.log(result);
							var result_ = result;
							if (result && result.success) {
								me.selectrow.id = result.data.id;
								if(me.issubmit) {
									me.issubmit = false;
									var id_ = params.id;
									if(!id_) {
										id_ = result.data.id;
									}
									var internationPart_ = false;
									if (me.formData.apply_dep_code && me.formData.apply_dep_code == "202105180005") {
										internationPart_ = true;
									}
									
									var param_submit = {
										isClientMode: false,
										businessId: id_,
										businessType: "accountCustomerDelivery",
										variableMap: {
											deliveryPartCode: row.delivery_part_code,
											province: me.acctObj.record_province,
											internationPart: internationPart_
										}
									}
									Server.call("root/api/startAct", param_submit, function(result1) {
										console.log(result1);
										let param_act = {
											id: id_,
											flow_id: result1.data.data.activitiId
										};
										param_act.isClientMode = false;
										param_act.dataname = "agCustomerDelivery";
										
										Server.call("root/data/updateEntity", param_act, function(result2) {
											console.log(result2);
											me.selectrow.status = "working";
											Root.message({
												type: 'success',
												message: '提交成功'
											}); 
											//单条主体提交日志
											//me.saveAfter();
										});
										
									});
								}
								else {
									Root.message({
										type: 'success',
										message: '保存成功'
									}); 
									
									//me.saveAfter();
								}
							}
						})
					},
					
					refusesubmitRowTable() {
					    var me = this;
					    var actpassword_ = localStorage.getItem("actpassword");
					    if (actpassword_) {
					        var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									me.dorefusesubmitRowTable();
									if (callback) {
										callback();
									}
								}
					       };
					       this.doPopupByPublic(config);
					    }
					    else {
					       this.dorefusesubmitRowTable();
					    }
					},
					
					dorefusesubmitRowTable() {
						this.issubmit = true;
						this.saveRefusesuRowTable();
					},
					
					refusecancelRowTable() {
						var row = clone(this.selectrow);
						this.canceltype = "customer_delivery";
						this.textarea2 = "";
						this.reasonvisible = true;
						this.reasonvisible_flowid = row.flow_id;
						this.passOrRefuse = false;
						this.type_act = "accountCustomerDelivery";
					},
					
					saveRefusesuRowTable() {
							var me = this;
							var row = clone(this.selectrow);
							let params = row;
							
							params.customer_id = this.formData.id;
							params.customer_uscc = this.formData.uscc;
							
							params.isClientMode = false;
							Server.call("root/customer/saveCustomerDelivery", params, function(result) {
								console.log(result);
								var result_ = result;
								if (result && result.success) {
									if(me.issubmit) {
										me.issubmit = false;
										
										var internationPart_ = false;
										if (me.formData.apply_dep_code && me.formData.apply_dep_code == "202105180005") {
											internationPart_ = true;
										}
										
										let param_act = {
											flow_id: row.flow_id,
											pass: true,
											
											variable_map:{reason: "调整提交"},
											business_type: "accountCustomerDelivery",
											isClientMode: false,
											variableMap: {
												internationPart: internationPart_
											}
										}
										Server.call("root/api/dealAct", param_act, function(result1) {
											console.log(result1);
											me.loading_approval = false;
											
											if (result1.success){
												Root.message({
													type: 'success',
													message: '提交成功'
												}); 
												
												//单条主体调整提交日志
												
											}else{
												Root.message({
													type: 'warning',
													message: '提交失败'
												}); 
											}
											me.saveAfter();
										});
									}
									else {
										Root.message({
											type: 'success',
											message: '保存成功'
										}); 
										
										//me.saveAfter();
									}
								}
							})
						
					},
					
					//资质信息
					handleChange(tab) {
						this.file_img = false;
						this.file_txt = false;
						
						this.selectZZName = "";
						this.selectZZType = "ZGL01";
						this.zzimg = {};
						this.zzimgList = [];
					},
					
					submitTables() {
						var me = this;
						var actpassword_ = localStorage.getItem("actpassword");
						if (actpassword_) {
							var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									/* Root.message({
										type: 'success',
										message: '流程验证通过'
									}); */
									me.dosubmitTables();
									
									if (callback) {
										callback();
									}
								}
							};
							this.doPopupByPublic(config);
						}
						else {
							/* Root.message({
								type: 'warning',
								message: '没有流程验证密码'
							}); */
							this.dosubmitTables();
						}
					},
					
					dosubmitTables() {
						this.issubmit = true;
						this.loading_submit = true;
						this.saveTables();
					},
					
					onCheckFormByRefTab(array_f, tabs, fields_) {
						var me = this;
						var bo_ = "";
						var i = 0;
						tabs.map(t=>{
							i++;
							var upload_fileobj = t;
							upload_fileobj
							array_f.map(f=>{
								var fileObj_ = upload_fileobj[f.code];
								if (f.rules && (!fileObj_)) {
									bo_ += i + "." + f.name;
									return bo_;
								}
							})
							
							if(fields_ && fields_.length) {
								fields_.map(f=>{
									var fileObj_ = upload_fileobj[f.field];
									
									if (f.required && !fileObj_) {
										bo_ += i + "." + f.name + ";";
										return bo_;
									}
								})
							}
							
							
						})
						
						return bo_;
					},
					
					onCheckFormByRef(array_f, upload_fileobj) {
						var me = this;
						var bo_ = "";
						
						array_f.map(f=>{
							var fileObj_ = upload_fileobj[f.code];
							if (f.rules && (!fileObj_ || !fileObj_.file_name)) {
								bo_ = f.name;
								return bo_;
							}
						})
						
						return bo_;
					},
					
					saveTables() {
						var me = this;
						//校验数组中是否有重复数据checkDataByR
						this.checkDataByArray(this.tableData2, function() {
							me.doSaveTables();
						}, function() {
							me.issubmit = false;
							me.loading_submit = false;
							Root.message({
								type: 'warning',
								message: '存在相同数据'
							});
							return
						});
					},
					
					doSaveTables() {
						var me = this;
						me.loading_save = true;
						var param = clone(this.formData);
						
						if(!param.delivery_part_code) {
							param.delivery_part_code = this.tableData2[0].delivery_part_code;
							param.delivery_part_name = this.tableData2[0].delivery_part_name;
						}
						
						
						var certification_ = {
							id: param.id,
							delivery_part_code: me.tableData2[0].delivery_part_code,
							business_operate_code: me.tableData2[0].business_operate_code,
							customer_id: param.id,
							logistics_company: me.logistics_company,
							logistics_no: me.logistics_no,
							logistics_check: me.logistics_check
						}
						
						//纸质物流
						param.logistics_company = this.logistics_company;
						param.logistics_no = this.logistics_no;
						//纸质确认
						//param.logistics_check = this.logistics_check;
						
						param.certification = certification_;
						
						if (!param.uscc) {
							Root.message({
								type: 'warning',
								message: '请先设置统一社会信用代码'
							});
							return
						}
						//备案明细
						param.delivery_list = this.tableData2;
						
						//资质
						//1证照
						//attachment_type_zs
						var c_form_zz = true;
						
						if (this.issubmit) {
							c_form_zz = me.onCheckFormByRef(this.attachment_type_zs, this.file_zs);
							if (c_form_zz) {
								Root.message({
									type: 'warning',
									message: '缺少证照必填项【' + c_form_zz + '】'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
						}
						
						var licenceList_ = [];
						this.attachment_type_zs.map(zs=>{
							var zsobj_ = me.file_zs[zs.code];
							var zsobj_old = me.file_zs_old[zs.code] || {};
							
							if (zsobj_ && zsobj_.file_id) {
								//判断是否更改
								var is_old = true;//默认相同
								
								if (zsobj_.file_id && !zsobj_old.file_id) {
									//新增的证照信息
									is_old = false;
								}
								else if (zsobj_old.file_id && zsobj_.file_id) {
									//附件不同,有更改
									if (zsobj_old.file_id != zsobj_.file_id) {
										is_old = false;
									}
									else {
										me.tableFields_zz.map(zzf=>{
											if (zsobj_old[zzf.field] != zsobj_[zzf.field]) {
												is_old = false;
											}
										})
									}
								}
								
								//如果不相同
								if (!is_old) {
									//资质id是否是本此资质的id
									if (zsobj_.customer_certification_id != param.id) {
										zsobj_.customer_certification_id = param.id;
										if(zsobj_.id) {
											zsobj_.old_id = clone(zsobj_.id);
										}
										zsobj_.id = null;
									}
									
									licenceList_.push(zsobj_);
								}
							}
						});
						
						if (this.del_zz.length) {
							this.del_zz.map(z=>{
								licenceList_.push(z);
							})
						}
						
						if (licenceList_.length) {
							param.licence_list = licenceList_;
						}else {
							param.licence_list = null;
						}
						
						//开票
						if (this.issubmit) {
							var c_form_zz_ = false;
							
							c_form_zz = me.onCheckFormByRef(this.attachment_type_kp, this.formData_kp);
							if (c_form_zz) {
								Root.message({
									type: 'warning',
									message: '缺少开票附件必填项【' + c_form_zz + '】'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
							
							this.attachment_type_kp.map(f=>{
								var fileObj_ = this.formData_kp[f.code];
								if (fileObj_) {
									c_form_zz_ = true;
								}
							})
							if (!c_form_zz_) {
								Root.message({
									type: 'warning',
									message: '缺少开票必填附件(二选一)'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
							
							var checkResults = this.$refs.form_kp.checkForm();
							if (!checkResults) {
								Root.message({
									type: 'warning',
									message: '缺少开票必填项'
								}); 
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return
							}
						}
						
						var formData_kp_notnull = false;
						//判断是否更改
						var is_old_kp = true;//默认相同
						for (var kp_ in me.formData_kp) {
							if (me.formData_kp[kp_] != me.formData_kp_old[kp_]) {
								is_old_kp = false;
							}
						}
						//如果不相同
						if (!is_old_kp) {
							if (me.formData_kp.customer_certification_id != param.id) {
								me.formData_kp.customer_certification_id = param.id;
								if(me.formData_kp.id) {
									me.formData_kp.old_id = clone(me.formData_kp.id);
								}
								me.formData_kp.id = null;
							}
							
							if(!me.formData_kp.customer_uscc) {
								me.formData_kp.customer_uscc = this.acctObj.uscc;
							}
							param.invoice = me.formData_kp;
						}
						else {
							param.invoice = me.formData_kp;
						}
						
						//æ”¶è´§
						if (this.issubmit) {
							c_form_zz = me.onCheckFormByRefTab(this.attachment_type_sh, this.tabs_sh, this.tableFields_sh);
							if (c_form_zz) {
								Root.message({
									type: 'warning',
									message: '缺少收货必填项【' + c_form_zz + '】'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
						}
						
						//consigneeList
						var consigneeList_ = [];
						var i = 0;
						this.tabs_sh.map(sh=>{
							//判断是否更改
							var is_old_sh = true;//默认相同
							
							//判断附件是否相同
							if (!sh.id || !me.tabs_sh_old_obj[sh.id]) {
								is_old_sh = false;
							}
							
							if (is_old_sh) {
								me.attachment_type_sh.map(shff=>{
									if (sh[shff.code] != me.tabs_sh_old_obj[sh.id][shff.code]) {
										is_old_sh = false;
									}
								})
							}
							
							//如果附件相同,判断其它属性
							if (is_old_sh) {
								me.tableFields_sh.map(shff=>{
									if (sh[shff.field] != me.tabs_sh_old_obj[sh.id][shff.field]) {
										is_old_sh = false;
									}
								})
							}
							if (!is_old_sh) {
								if (sh.customer_certification_id != param.id) {
									sh.customer_certification_id = param.id;
									if(sh.id) {
										sh.old_id = clone(sh.id);
									}
									
									sh.id = null;
								}
								
								//sh.delivery_part_code = (this.acctObj).delivery_part_code
								//sh.delivery_part_name = (this.acctObj).delivery_part_name
								
								sh.order_no = i;
								consigneeList_.push(sh);
							}
							else if (sh.customer_certification_id == param.id) {
								sh.order_no = i;
								consigneeList_.push(sh);
							}
							i++;
						});
						
						
						if (consigneeList_.length) {
							param.consignee_list = consigneeList_;
						}else {
							param.consignee_list = null;
						}
						
						//采购
						if (this.issubmit) {
							c_form_zz = me.onCheckFormByRefTab(this.attachment_type_cg, this.tabs_cg);
							if (c_form_zz) {
								Root.message({
									type: 'warning',
									message: '缺少采购必填项【' + c_form_zz + '】'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
						}
						
						//procureList
						var procureList_ = [];
						var j = 0;
						this.tabs_cg.map(cg=>{
							//判断是否更改
							var is_old_cg = true;//默认相同
							
							//判断附件是否相同
							if (!cg.id || !me.tabs_cg_old_obj[cg.id]) {
								is_old_cg = false;
							}
							if (is_old_cg) {
								me.attachment_type_cg.map(cgff=>{
									if (cg[cgff.code] != me.tabs_cg_old_obj[cg.id][cgff.code]) {
										is_old_cg = false;
									}
								})
							}
							//如果附件相同,判断其它属性
							if (is_old_cg) {
								me.tableFields_cg.map(cgff=>{
									if (cg[cgff.field] != me.tabs_cg_old_obj[cg.id][cgff.field]) {
										is_old_cg = false;
									}
								})
							}
							if (!is_old_cg) {
								if (cg.customer_certification_id != param.id) {
									cg.customer_certification_id = param.id;
									if(cg.id) {
										cg.old_id = clone(cg.id);
									}
									
									cg.id = null;
								}
								
								//cg.delivery_part_code = (this.acctObj).delivery_part_code
								//cg.delivery_part_name = (this.acctObj).delivery_part_name
								
								cg.order_no = j;
								procureList_.push(cg);
							}
							else if (cg.customer_certification_id == param.id) {
								cg.order_no = j;
								procureList_.push(cg);
							}
							j++;
						});
						if (procureList_.length) {
							param.procure_list = procureList_;
						}else {
							param.procure_list = null;
						}
						
						//质保
						if (this.issubmit) {
							c_form_zz = me.onCheckFormByRef(this.attachment_type_zb, this.file_zs);
							if (c_form_zz) {
								Root.message({
									type: 'warning',
									message: '缺少质保必填项【' + c_form_zz + '】'
								});  
								me.loading_save = false;
								me.issubmit = false;
								me.loading_submit = false;
								return;
							}
						}
						//qaInfo
						var infoList_ = [];
						//attachment_type_zb
						this.attachment_type_zb.map(zb=>{
							var zbobj_ = me.file_zs[zb.code];
							var zbobj_old = me.file_zs_old[zb.code];
							
							if (zbobj_ && zbobj_.file_id) {
								//判断是否更改
								var is_old_zb = true;//默认相同
								
								if (zbobj_.file_id && !zbobj_old.file_id) {
									//新增的证照信息
									is_old_zb = false;
								}
								else if (zbobj_old.file_id && zbobj_.file_id) {
									//附件不同,有更改
									if (zbobj_old.file_id != zbobj_.file_id) {
										is_old_zb = false;
									}
									else {
										me.tableFields_zz.map(zzf=>{
											if (zbobj_old[zzf.field] != zbobj_[zzf.field]) {
												is_old_zb = false;
											}
										})
									}
								}
								
								//如果不相同
								if (!is_old_zb) {
									//资质id是否是本此资质的id
									if (zbobj_.customer_certification_id != param.id) {
										zbobj_.customer_certification_id = param.id;
										if(zbobj_.id) {
											zbobj_.old_id = clone(zbobj_.id);
										}
										zbobj_.id = null;
									}
									
									infoList_.push(zbobj_);
								}
								else {
									infoList_.push(zbobj_);
								}
							}
							
						});
						
						if (infoList_.length) {
							param.qa_info = infoList_[0];
						}else {
							param.qa_info = infoList_[0];
						}
						
						
						param.type = "create";
						param.isClientMode = false;
						Server.call("root/directCustomer/saveCustomerCertification", param, function(result) {
							var result_ = result;
							me.loading_save = false;
							if (result && result.success) {
								if(me.issubmit) {
									me.issubmit = false;
									var bo_ = me.checkDataByJC();
									if (bo_) {//true:存在检查不通过数据
										
										return
									}
									var id_ = param.id;
									if(!id_) {
										id_ = result.data.id;
									}
									
									Server.call("root/directCustomer/checkCustomerCertification", param, function(result_c) {
										if (result_c && result_c.success) {
											var type_ = "directCustomerCreate"
											if (false) {//是变更则
												type_ = "directCustomerModify"
											}
											var param_submit = {
												isClientMode: false,
												businessId: id_,
												businessType: type_,
												variableMap: {
													deliveryPartCode: param.delivery_part_code,
												}
												
											}
											Server.call("root/api/startAct", param_submit, function(result1) {
												console.log(result1);
												me.loading_submit = false;
												if (result1.success) {
													Root.message({
														type: 'success',
														message: '提交成功'
													}); 
													
													//首次商业开户日志
													me.saveAfter();
												}
												else if (result1.message) {
													Root.message({
														type: 'error',
														message: result1.message
													}); 
												}
											}, function(result1) {
												console.log(result1);
												me.loading_submit = false;
												if (result1.message) {
													Root.message({
														type: 'error',
														message: result1.message
													}); 
												}
											});
										}
									}, function(result1) {
										console.log(result1);
										me.loading_submit = false;
										if (result1.message) {
											Root.message({
												type: 'error',
												message: result1.message
											}); 
										}
									})
								}
								else {
									Root.message({
										type: 'success',
										message: '保存成功'
									}); 
									
									me.saveAfter();
								}
							}
						}, function(result1) {
							console.log(result1);
							me.loading_save = false;
							me.loading_submit = false;
							me.issubmit = false;
							if (result1.message) {
								Root.message({
									type: 'error',
									message: result1.message
								}); 
							}
						})
					},
					
					row_act() {
						let me = this;
						me.do_act(businessId_, "exists", me.dataname, key, function(result1){
							let paramObj = {};
							for (var k in me.selectedrow) {
								paramObj[k] = me.selectedrow[k];
							}
							paramObj[field_] = new_val;
							
							paramObj.flow_id = result1.data.activitiId;
							
							let param = paramObj;
							param.isClientMode = false;
							param.dataname = me.dataname;
							
							Server.call("root/data/updateEntity/"+ param.dataname, param, function(result) {
								console.log(result);
								Root.message({
									type: 'success',
									message: success_val
								});
								me.onQuery();
							});
						});
					},
					
					do_act(businessId_, businessType, dataname, key, callback) {
						let me = this;
						
						var param_act = {
							isClientMode: false,
							businessId: businessId_,// row.id,
							businessType: businessType, 
						}
						
						Server.call("rootact/act/start/"+ key, param_act, function(result1) {
							console.log(result1);
							
							if(callback) {
								callback(result1);
							}
						});
						
					},
					
					saveAfter(logcode) {
						var me = this;
						if (logcode) {
							var logtype = "";//日志类型
							var operatelogdataobj = {//日志头信息
								businessid: me.selectRole.id,
								businessname: me.selectRole.name,
								dataname: "sysRoleMapping",
								operateremark: "添加角色关联商业"
							};
							var fieldobjlist = [];//日志详情
							
							var isclose = false;//是否关闭Tab或弹窗
							
							if (logcode == "syxx") {//商业信息
								logtype = "customerCreate";
								operatelogdataobj = {//日志头信息
									businessid: me.formData.id,
									businessname: me.formData.uscc,
									dataname: "agCustomer",
									operateremark: "商业信息调整"
								};
								
								var isArray = false;
								var dataFields = me.formFields;
								var old_data = clone(me.old_data_syxx);
								var new_data = clone(me.formData);
								fieldobjlist = me.getDataDifference(dataFields, old_data, new_data, isArray);
							}
							else if (logcode == "fhzt") {//发货主体
								logtype = "customerDelivery";
								
							}
							else if (logcode == "zzxx") {//资质信息
								logtype = "customerDeliveryCertification";
								
							}
							me.setlog(logtype, operatelogdataobj, fieldobjlist, isclose)
						}
						else {
							this.doSaveAfter();
						}
					},
					
					setlog(logtype, operatelogdataobj, fieldobjlist, isclose) {
						var me = this;
						me.addlog(logtype, operatelogdataobj, fieldobjlist, function(){
							if (isclose) {
								me.saveAfter();
							}
						});
					},
					
					doSaveAfter() {
						var me = this;
						if(this.popupParames.callback) {
							let obj = {
								//row: this.formData
							}
							this.popupParames.callback(obj, function() {
								if (me.popupParames.totab){
									Root.tab.removeItem(Root.tab.selected);
									Root.tab.open(me.popupParames.parentOption, false); 
								}
								else {
									Root.hidePopup();
								}
							});
						}
						else {
							alert("该按键事件缺失!")
						}
					},
					
					showCredit(code, row) {
						let me = this;
						if (me.formData.customername) {
							Root.popupParames = {
								url: "../tool/credit_status.html",
							};
							Root.showPopup(Root.popupParames);
						}
						else {
							Root.message({
								type: 'warning',
								message: '请先选择客户'
							});
						}
					},
					
					rowChange(row, type) {
						//tc
						/* var id_ = row.id;
						if (this.tableDataChange[id_]) {
							this.tableDataChange[id_].data = row;
						}
						else {
							var changeRow_ = {
								type: type,
								data: row
							};
							this.tableDataChange[id_] = changeRow_;
						} */
						
						//t2
						if (type == "add") {
							this.tableData2.unshift(row);
							this.selectrow = {};
						}
						else if (type == "del") {
							this.tableData2.remove(this.selectrow);
						}
						else if (type == "edit") {
							this.tableData2.remove(this.selectrow);
							this.selectrow = {};
							this.tableData2.unshift(row);
							
							if (this.isapprovaledit) {
								this.selectrow = clone(row);
								this.saveRowTable();
							}
						}
						
						
						
						/* var sum_noRate_ = 0 ;
						var available_amt = 0 ;
						var formData_ = clone(this.formData);
						this.tableData2.map(e=>{
							sum_noRate_ += (e.product_amt || 0 ) * 1;
							available_amt += (e.rebate_amt || 0) * 1
						})
						
						formData_.available_amt = available_amt;
						formData_.amt = sum_noRate_;
						
						this.formData = formData_; */
						/* this.isRefresh = false;
						this.$nextTick(function(){ */
							this.isRefresh = true;
						//})
					},
					
					addTableData() {//formData_part
						if (!this.formData.uscc) {
							Root.message({
								type: 'warning',
								message: '请先设置统一社会信用代码'
							});
							return
						}
						this.operation_type = "add";
						
						var tableFields_part_ = clone(this.tableFields_part);
						tableFields_part_.map(e=>{
							if(e.field == "delivery_part_code") {
								e.disabled = false;
							}
						})
						this.tableFields_part = tableFields_part_;
						
						var formData_part_ = clone(this.newtabledata_part[0]);
						formData_part_.customer_uscc = this.formData.uscc;
						formData_part_.create_operate_name = localStorage.getItem("emp_name");
						formData_part_.create_operate_id = localStorage.getItem("emp_id");
						
						this.formData_part = clone(formData_part_);
						
						this.part_dialog = true;
						/* this.formData_part = {
							customer_uscc: this.formData.uscc,
							create_operate_name: localStorage.getItem("emp_name"),
							create_operate_id: localStorage.getItem("emp_id")
						}; */
						
						//newtabledata_part
						
						if (this.acctObj.id) {
							this.formData_part.customer_id = this.acctObj.id;
						}
						
						/* if (this.selectrow != {}) {
							this.selectrow.isWithinEdit = false;
						}
						
						var id_ = uuid_short();
						var tax_rate_ = "13";
						var sales_type_ = "正常销售";
						var row_ = {
							isWithinEdit: true,
							id: id_,
							tax_rate:tax_rate_,
							sales_type:sales_type_,
						};
						
						for (var i = 0; i < this.tableFields.length; i++) {
							let field_ = this.tableFields[i].field;
							
							if (field_ == "parent_id") {
								row_[field_] = this.formData.id;
							}
							else if (field_ == "sales_type") {
								row_[field_] = "正常销售";
							} 
							else if (field_ == "tax_rate") {
								row_[field_] = "13";
							}
							else {
								row_[field_]="";
							}
						} 
						
						this.selectrow = row_;
						this.rowChange(row_, "add"); */
					},
					
					editTableData() {
						this.operation_type = "edit";
						var row = clone(this.selectrow);
						if (!row.customer_uscc) {
							Root.message({
								type: 'warning',
								message: '请先选中一条数据'
							});
							return
						}
						
						if (row.status == "working") {
							Root.message({
								type: 'warning',
								message: '此数据正在审批中'
							});
							return
						}
						if (row.status == "open") {
							Root.message({
								type: 'warning',
								message: '此数据已审批通过'
							});
							return
						}
						
						this.formData_part = row;
						this.part_dialog = true;
					},
					
					editTableDataByAct() {
						this.operation_type = "edit";
						var row = clone(this.selectrow);
						if (!row.customer_uscc) {
							Root.message({
								type: 'warning',
								message: '请先选中一条数据'
							});
							return
						}
						
						var tableFields_part_ = clone(this.tableFields_part);
						tableFields_part_.map(e=>{
							if(e.field == "delivery_part_code") {
								e.disabled = true;
							}
						})
						this.tableFields_part = tableFields_part_;
						
						this.formData_part = row;
						this.part_dialog = true;
					},
					
					notActiveTableData() {
						var me = this;
						var row = clone(this.selectrow);
						/* if (!row.id) {
							Root.message({
								type: 'warning',
								message: '请先选中一条数据'
							});
							return
						}
						else */
						if(!row.id && row.delivery_part_code) {
							Root.confirm('确定删除-' + row.delivery_part_code + '-吗?', '删除提示', {
							  confirmButtonText: '删除',
							  cancelButtonText: '取消',
							  type: 'warning'
							}).then(() => {
								me.rowChange(row, "del");
								
								Root.message({
									type: 'success',
									message: '删除成功!'
								});
							}).catch(() => {
								
								Root.message({
									type: 'info',
									message: '已取消删除'
								});          
							});
						}
						else if(!row.id) {
							me.rowChange(row, "del");
						}
						else {//有id
							Root.confirm('确定删除-' + row.delivery_part_code + '-吗?', '删除提示', {
							  confirmButtonText: '删除',
							  cancelButtonText: '取消',
							  type: 'warning'
							}).then(() => {
								let param_table = {
									isClientMode: false,
									dataname: "agCustomerDelivery",
									id: row.id
								}
								
								Server.call("root/data/deleteEntity", param_table, function(result) {
									console.log(result);
									me.rowChange(row, "del")
									Root.message({
										type: 'success',
										message: '删除成功!'
									});
								});
							}).catch(() => {
								Root.message({
									type: 'info',
									message: '已取消删除'
								});          
							});
						}
					},
					
					saveFormPart() {
						var me = this;
						var checkResults = this.$refs.form12.checkForm();
						if (!checkResults) {
							return
						}
						/* if (!this.formData_part.remark) {
							Root.message({
								type: 'warning',
								message: '请填写备案原因'
							}); 
						} */
						
						var type = "add";
						if (this.formData_part.id || this.operation_type == "edit") {
							type = "edit";
						}
						else {
							
						}
						
						//校验一条在不在数组中;
						this.checkDataByRow(this.tableData2, this.formData_part, type, function() {
							me.rowChange(clone(me.formData_part), type);
							
							var tableFields_part_ = clone(me.tableFields_part);
							tableFields_part_.map(e=>{
								if(e.field == "delivery_part_code") {
									e.disabled = false;
								}
							})
							me.tableFields_part = tableFields_part_;
							
							me.part_dialog = false;
						}, function() {
							Root.message({
								type: 'warning',
								message: '已存在相同数据'
							});
							return
						});
					},
					
					checkDataByRow(array, row, type, callback, errorcallback) {
						var me = this;
						var bo_ = false;//不存在重复
						this.checkfFields;
						var row_txt = "";
						
						this.checkfFields.map(k=>{
							row_txt += row[k];
						});
						
						if (type == "add") {
							//看array中是否存在row
							array.map(a=>{
								var a_row = a;
								var a_row_txt = "";
								this.checkfFields.map(k=>{
									a_row_txt += a_row[k];
								});
								
								if (a_row_txt == row_txt) {
									bo_ = true;
								}
							});
						}
						else if (type == "edit") {
							//看array中除selectrow外中是否存在row
							array.map(a=>{
								if (a.id == me.selectrow.id) {}
								else {
									var a_row = a;
									var a_row_txt = "";
									this.checkfFields.map(k=>{
										a_row_txt += a_row[k];
									});
									
									if (a_row_txt == row_txt) {
										bo_ = true;
									}
								}
								
							});
						}
						
						if(bo_) {
							errorcallback();
						}
						else {
							callback();
						}
						
					},
					
					checkDataByArray(array, callback, errorcallback) {
						var me = this;
						var bo_ = false;//不存在重复
						var array_txt_obj = {};
						
						//看array中是否存在重复数据
						array.map(a=>{
							var a_row = a;
							var a_row_txt = "";
							this.checkfFields.map(k=>{
								a_row_txt += a_row[k];
							});
							
							if (array_txt_obj[a_row_txt]) {
								bo_ = true;
							}
							else {
								array_txt_obj[a_row_txt] = a;
							}
						});
						
						if(bo_) {
							errorcallback();
						}
						else {
							callback();
						}
					},
					
					rowClick(obj) {
						this.isrowinput = false;
						
						//if (this.selectrow != {}) {
						//	this.selectrow.isWithinEdit = false;
						//}
						var row = this.selectrow = obj.row;
						//obj.row.isWithinEdit = obj.row.isWithinEdit ? false : true;
						
						if (!this.selectrow.id || (this.selectrow.id && (this.selectrow.status == "input" || this.selectrow.status == "refuse")) || !this.selectrow.status) {
							this.isrowinput = true;
						}
						
						// if (row.status == "working") {
						// 	Root.message({
						// 		type: 'warning',
						// 		message: '此数据正在审批中'
						// 	});
						// 	return
						// }
						// if (row.status == "open") {
						// 	Root.message({
						// 		type: 'warning',
						// 		message: '此数据已审批通过'
						// 	});
						// 	return
						// }
					},
					
					onCellClick(config, obj) {
						var clickContext = this.selectCellField.clickContext;
						var row_ = obj.row;
						if(this.selectCellField.field == "file_name") {
							if (!obj.row.file_id) {
								Root.message({
									type: 'warning',
									message: '没有附件文件'
								});
								return
							}
							
							////////////
							let fileid = clone(obj.row.file_id);
							let fileName = clone(obj.row.file_name);
							let index1 = fileName.lastIndexOf(".");
							let index2 = fileName.length;
							let suffix = fileName.substring(index1, index2).toLowerCase(); //后缀名
							
							if (suffix == ".png" || suffix == ".jpg") {
								var fileids_ = [];
								fileids_.push(fileid)
								row_ = {
									filetype: "img",
									fileids: fileids_
								};
								clickContext.url = "../tool/popup_file.html";
							}
							else if (suffix == ".pdf") {
								var row = {
									fileid: fileid,
									filename: fileName
								}
								
								var config = {
									totab: true,
									icon: "icon-product",
									text: "附件预览",
									id: "pdf_" + fileid,
									url: "../tool/popup_file_pdf.html",
									data: row,
									delta: {},
									callback: function(obj, callback) {
										if (callback) {
											callback();
										}
									}
								};
								this.doPopupByPublic(config);
								return false;
								
							}
							else {//只可下载,不可预览
								handleDownload(fileid);
							}
							
							/////////
							
						}
						
						if(this.selectCellField.field == "status" && obj.row.flow_id){
							// clickContext.url = "";
							// if(obj.row.status && obj.row.status != 'input' && obj.row.flow_id){
							// 	clickContext.url = window.top.RootSetting.url_act +  "act/diagram/" + obj.row.flow_id;
							// }
							clickContext.url = "../approval/ApprovalList.html";
							clickContext.delta = {
								flow_id: obj.row.flow_id,
								title: obj.row.delivery_part_name
							}
							
							clickContext.width = "75vw";
							clickContext.height = "65vh";
							clickContext.hide_close = true;
							
						}
						
						if (clickContext && clickContext.type == "popup" && clickContext.url) {
							config.combine({
								hide_close: clickContext.hide_close,
								url: clickContext.url,
								sceneCode: clickContext.sceneCode,
								data: row_,
								delta: clickContext.delta ? clickContext.delta : {},
								width: clickContext.width,
							})
						}
						else {
							return false;
						}
						
						return true;
					},
					
					/* cellClick(scope) {//status
						let me = this;
						let row = scope.row;
						let field = scope.column.property;
						
						var text_ = this.formData.md_description + row.delivery_part_code;
						var id_ = "licence" + row.id;
						if (field == "licence"){
							//this.getFormData(row);
							
							var config = {
								totab: true,
								width: "1500px",
								icon: "icon-product",
								text: text_,
								id: id_,
								url: "../md/customer/customer_licence.html",
								data: row,
								delta: this.formData,
								callback: function(obj, callback) {
									//me.uploadFileAfter(obj);
									if (callback) {
										callback();
									}
								}
							};
							this.doPopupByPublic(config);
						}
					}, */
					
					Getfilter(filter_,filter){
						let me = this;
						//管理主体名称			
						if (me.formData.manager_part_name) {
							var filter1 = ""
							if(me.formData.manager_part_name == "otc" || me.formData.manager_part_name == "OTC"){
								filter1 = "OTC"
							}else{
								filter1 = "处方药"
							}
							filter_ += " and agreementRecord.manager_part_name = '"+filter1+"'"
						}
						//发货主体
						if (me.formData.delivery_part_name && filter != "delivery_part_name") {
							filter_ += " and agreementRecord.delivery_part_name = '"+ me.formData.delivery_part_name +"'"
						}
						//客户名称
						if (me.formData.customer_id && filter != "customer_name") {
							filter_ += " and agreementRecord.customer_id = '"+ me.formData.customer_id +"'"
						}
						//区域
						if (me.formData.province_name  && filter != "province_name") {
							filter_ += " and agreementRecord.province_name = '"+ me.formData.province_name +"'"
						}
						//业务部门
						if (me.formData.business_depart_name && filter != "business_depart_name") {
							filter_ += " and agreementRecord.business_depart_name = '"+ me.formData.business_depart_name +"'"
						}
						if (me.formData.business_type ) {
							filter_ += " and agreementRecord.business_type = '"+ me.formData.business_type +"'"
						}
						
						return filter_
					},
					
					saveForm_approval() {
						var me = this;
						let params = clone(this.formData);
						me.dosaveForm_approval(params);
					},
					
					dosaveForm_approval(params) {
						var me = this;
						
						/* if (!params.old_id && me.formData.status && ) {
							params.old_id = this.acctObj.id;
						}
						else {
							params.strict = false;
						} */
						params.strict = false;
						
						if (!params.uscc) {
							Root.message({
								type: 'warning',
								message: '请先设置统一社会信用代码'
							});
							return
						}
						
						//证照
						var licenceList_ = [];
						for (var k in me.file_zs) {
							if (me.file_zs[k].file_id) {
								if(me.file_zs[k].customer_id && me.file_zs[k].customer_id != me.formData.id) {
									me.file_zs[k].old_id = clone(me.file_zs[k].id);
									me.file_zs[k].id = null;
									me.file_zs[k].create_time = null;
								}
								
								licenceList_.push(me.file_zs[k]);
							}
						}
						if (licenceList_.length) {
							params.licence_list = licenceList_;
						}else {
							params.licence_list = null;
						}
						//return
						//开票
						var formData_kp_notnull = false;
						for (var kp_ in me.formData_kp) {
							
							if (kp_ == "customer_id" && me.formData_kp.customer_id != me.formData.id) {
								me.formData_kp.old_id = clone(me.formData_kp.id);
								me.formData_kp.id = null;
								me.formData_kp.create_time = null;
							}
							
							formData_kp_notnull = true;
						}
						if (formData_kp_notnull) {
							if(!me.formData_kp.customer_uscc) {
								me.formData_kp.customer_uscc = this.formData.uscc;
							}
							if(this.formData.id && !me.formData_kp.customer_id) {
								me.formData_kp.customer_id = this.formData.id;
							}
							
							params.invoice = me.formData_kp;
						}else {
							params.invoice = null;
						}
						
						params.dataName = "agCustomer";
						params.type = "update";
						params.isClientMode = false;
						Server.call("root/customer/saveCustomer", params, function(result) {
							console.log(result);
							me.formData.id = result.data.id;
							
							var result_ = result;
							if (result && result.success) {
								me.textarea2 = "";
								me.reasonvisible = true;
								me.reasonvisible_flowid = me.acctObj.flow_id;
								me.passOrRefuse = true;
								me.type_act = "accountCustomerDelivery";
							}
						}, function(result1) {
							console.log(result1);
							if (result1.message) {
								Root.message({
									type: 'error',
									message: result1.message
								}); 
							}
						})
					},
					
					onpassApproval(){
						var bo = true;
						var issp003_1 = false;
						this.roleList.map(zre=>{
							if ("sp003_1" == zre.id) {//manager03
								issp003_1 = true;
								// if(!this.formData.old_code){
								// 	bo = false;
								// }
							}
						})
						
						if (this.popupParames.sceneCode == "versionapproval" && issp003_1 && !this.formData.old_code) {
							Root.message({
								type: 'warning',
								message: '请填写EAS编码'
							});
							return
						}
						
						if (bo) {
							//!formAttr.disabled && (isallrefuse || isapprovaledit || iscustomerchange || iscustomereditchange)
							if (this.isapprovaledit || (this.popupParames.sceneCode == "versionapproval" && issp003_1)) {
								this.saveForm_approval();
							}
							else {
								this.textarea2 = "";
								this.reasonvisible = true;
								this.reasonvisible_flowid = this.acctObj.flow_id;
								this.passOrRefuse = true;
								this.type_act = "accountCustomerDelivery";
							}
						}
					},
					onrefuseApproval(){
						this.textarea2 = "";
						this.reasonvisible = true;
						this.reasonvisible_flowid = this.acctObj.flow_id;
						this.passOrRefuse = false;
						this.type_act = "accountCustomerDelivery";
					},
					
					saveReason() {
					    var me = this;
					    var actpassword_ = localStorage.getItem("actpassword");
					    if (actpassword_) {
					        var config = {
								text: "流程验证",
								url: "../tool/popup_actpassword.html",
								callback: function(obj, callback) {
									me.dosaveReason();
									if (callback) {
										callback();
									}
								}
					       };
					       this.doPopupByPublic(config);
					    }
					    else {
					       this.dosaveReason();
					    }
					},
					
					dosaveReason(){
						this.loading_approval = true;
						if(this.passOrRefuse){
							this.passApproval(true,this.textarea2)
						}else{
							if(this.textarea2 != ""){
								this.passApproval(false,this.textarea2)
							}
							else{
								Root.message({
									type: 'warning',
									message: '请填写原因'
								});
								this.loading_approval = false;
							}
						}
					},
					
					//审批
					passApproval(pass_, reason_) {
						let me = this;
						if(reason_) {
							//去除两端的空格
							reason_ = reason_.replace(/(^\s*)|(\s*$)/g, "");
							
							//去除中间的回车换行
							reason_ = reason_.replace(/[\r\n]/g,"");
						}
						
						var variable_map_ = {
							reason: reason_
						}
						var deliveryObj_ = clone(this.tableData2[0]);
						
						var operateCode_ = me.formData.operator_code;
						if (this.acctObj.part_type && this.acctObj.part_type != "") {
							operateCode_ = me.acctObj.business_operate_code;
						}
						
						if (deliveryObj_.freeze) {
							if(deliveryObj_.part_type === null || deliveryObj_.part_type === undefined) {
								deliveryObj_.part_type = ""
							}
							variable_map_ = {
								reason: reason_,
								stict: false,
								
								province: me.formData.record_province,
								partType: deliveryObj_.part_type,
								businessType: deliveryObj_.business_type,
								customerPartCode: deliveryObj_.customer_part_code,
								operateCode: operateCode_
							}
						}
						
						if (this.attachment) {
							variable_map_.attachment = this.attachment;
						}
						
						var internationPart_ = false;
						if (me.formData.apply_dep_code && me.formData.apply_dep_code == "202105180005") {
							internationPart_ = true;
						}
						
						if (!me.certificationObj.old_id) {
							type_act = "directCustomerCreate";
						} else {
							type_act = "directCustomerModify";
						}
						
						//return
						let param = {
							isClientMode: false,
							flow_id: this.reasonvisible_flowid,
							pass: pass_,
							
							variable_map: variable_map_,
							business_type: type_act,//business_type: "accountCustomerDelivery"
							
							variableMap: {
								//internationPart: internationPart_
							}
						}
						Server.call("root/api/dealAct", param, function(result) {
							console.log(result);
							me.loading_approval = false;
							if (result.success){
								if (me.canceltype == "customer" || me.canceltype == "customer_delivery") {//商业变更撤销
									//me.formData; //me.selectrow;
									me.cancelAfter(function() {
										Root.message({
											type: 'success',
											message: '审批成功'
										}); 
										if(me.fromDing) {
											me.dingResult = true;
											me.dingResultTxt = "审批成功"
										}
										me.saveAfter();
									});
								}
								else {
									Root.message({
										type: 'success',
										message: '审批成功'
									}); 
									if(me.fromDing) {
										me.dingResult = true;
										me.dingResultTxt = "审批成功"
										return;
									}
									me.saveAfter();
									
								}
							}
							else {
								Root.message({
									type: 'warning',
									message: '审批失败'
								}); 
								
								if(me.fromDing) {
									me.dingResult = true;
									me.dingResultTxt = "审批失败"
									return;
								}
								me.saveAfter();
							}
						});
					},
					//审批拒绝
					/* refuseApproval(dataType_,reason_) {
						let me = this;
						var row = this.selectedrow;
						var id = "";
						if(dataType_ == "deliver"){
							id = this.formData.deo_id
						}
						else{
							id = this.formData.id
						}
						let param = {
							orderId:id,
							eventType:"approvalFail",
							dataType:dataType_,
							extra:{
								variableMap:{ reason:reason_}
							},
							isClientMode: false,
						}
						Server.call("root/order/onEvent", param, function(result) {
							console.log(result);
							
							Root.message({
								type: 'success',
								message: '拒绝审批成功'
							}); 
							this.reasonvisible = false;
							Root.tab.removeItem(Root.tab.selected);
							Root.tab.open(me.popupParames.parentOption, true);
						});
					}, */
					
					cancelAfter(callback) {
						var me = this;
						
						if (me.canceltype == "customer") {//商业变更撤销
							var param_ = {
								isClientMode: false,
								id: me.formData.id,
								dataname: "agCustomer",
								used: 0,
								active: 0,
								has_change: 0
							}
							Server.call("root/data/updateEntity", param_, function(result) {
								console.log(result);
								if (result && result.success) {
									if (me.formData.old_id) {//存在old_id
										var param_o = {
											isClientMode: false,
											id: me.formData.old_id,
											dataname: "agCustomer",
											used: 1,
											active: 1,
											has_change: 0
										}
										Server.call("root/data/updateEntity", param_o, function(result) {
											console.log(result);
											if (result && result.success) {
												if (callback) {
													callback();
												}
											}
										});
									}
									else {
										if (callback) {
											callback();
										}
									}
								}
							});
						}
						else if (me.canceltype == "customer_delivery") {//发货主体撤销
							var param_ = {
								isClientMode: false,
								id: me.selectrow.id,
								dataname: "agCustomerDelivery",
								used: 0,
								active: 0
							}
							
							Server.call("root/data/updateEntity", param_, function(result) {
								console.log(result);
								if (result && result.success) {
									if (me.selectrow.old_id) {//存在old_id
										var param_o = {
											isClientMode: false,
											id: me.selectrow.old_id,
											dataname: "agCustomerDelivery",
											used: 1,
											active: 1
										}
										Server.call("root/data/updateEntity", param_o, function(result) {
											console.log(result);
											if (result && result.success) {
												if (callback) {
													callback();
												}
											}
										});
									}
									else {
										if (callback) {
											callback();
										}
									}
								}
							});
						}
					},
					
					checkCustomerAndDelivery(){
						if (this.formData.delivery_part_name && this.formData.delivery_part_name != "" && this.formData.customer_name && this.formData.customer_name != "") {
							let me = this;
							let param_ = {
								isClientMode: false,
								dataname: "deliveryType",
								code:this.formData.delivery_part_code,
							}
							Server.call("root/data/getEntity", param_, function(result) {
								if (result.data.entity.sap) {
									let param_sap = {
										isClientMode: false,
										customerId:me.formData.customer_id
									}
									Server.call("root/order/checkCustomerLicence", param_sap, function(result) {
										if(result.success){
											Root.message({
												type: 'warning',
												message: result.data.data.message
											});
											//me.reason1 = result.data.data.message;
										}
									});
								}
								else{
									//U8预留接口
									let url = window.top.RootSetting.url_stock +  "order/checkLicence/" + me.formData.customer_id;
									axios.get(url, {
									})
									.then(data => {
									  console.log(data);
										if (data.data.success){
											Root.message({
												type: 'warning',
												message: data.data.data.message
											});
										}else{
											Root.message({
												type: 'warning',
												message:  data.data.data.message
											});
										}
									})
									.catch( (error) => {
										console.log(error);
									});
								}
							});
						}
					},
					
					onshowFilterPopup(filter) {
						var me = this;
						var fieldObj_ = filter.obj;
						var formData_part_ = clone(me.formData_part);
						var field_ = fieldObj_.field;
						
						if (field_ == "business_operate_name") {
							Root.showPopup({
								url: "../md/customer/popup/employee_list.html",
								
								width: 800,
								height: 550,
								callback: function(result, callback) {
									formData_part_[field_] = result.row.md_description;
									formData_part_.business_operate_code = result.row.md_code;
									formData_part_.business_operate_id = result.row.id;
									me.formData_part = formData_part_;
									if (callback) {
										callback();
									}
								}
							});
							
						}
					},
					
					showPopup(obj) {
						var me = this;
						var fieldObj = obj.obj;
						if (fieldObj.field == "operator_name") {
							var formData_ = clone(me.formData);
							Root.showPopup({
								url: "../md/customer/popup/employee_list.html",
								
								width: 800,
								height: 550,
								callback: function(result, callback) {
									formData_.operator_name = result.row.md_description;
									formData_.operator_code = result.row.md_code;
									formData_.apply_dep_code = result.row.dep_code;
									formData_.apply_dep_name = result.row.dep_name;
									
									me.formData = formData_;
									if (callback) {
										callback();
									}
								}
							});
						}
						if (fieldObj.field == "cus_dep_name") {
							var formData_ = clone(me.formData);
							Root.showPopup({
								url: "../md/customer/popup/cus_dep_list.html",
								width: 800,
								height: 550,
								callback: function(result, callback) {
									formData_.cus_dep_name = result.row.md_description;
									formData_.cus_dep_code = result.row.md_code;
									
									me.formData = formData_;
									if (callback) {
										callback();
									}
								}
							});
						}
					},
					buttonClick(obj) {
						if (obj.obj.field == "uscc") {
							this.onPopupByUploadFile("ZGL01", true, "zz");
						}
						else if (obj.obj.field == "file_name") {
							this.onPopupByUploadFile(null, null, "syxxfj");//商业信息福附件
						}
					},
					
					formcallspanClick(obj) {
						if (obj.obj.field == "file_name" && this.formData.file_id) {
							this.onDownloadFileByFileId(this.formData.file_id);
						}
					},
					
					buttonClick_part(obj) {
						this.onPopupByUploadFile(null, null, "fhztfj");//发货主体附件
					},
					cellVisibleChange(obj) {
						let options_ = [];
						
						if (obj.field == "country") {
							let param_ = {
								isClientMode: false,
								filter: " level='0' and active='1'",
							}
							Server.call("root/data/getEntitySet/division_level0", param_, function(result){
								options_ = result.data.entityset;
								obj.options = options_;
							});
						}
						else if (obj.field == "province") {
							if (obj.selectparent) {
								if(!this.formData[obj.selectparent]) {
									obj.options = []
								}
								else {
									var code_ = this.formData[obj.selectparent];
									let param_ = {
										isClientMode: false,
										filter: " level='1' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
									}
									Server.call("root/data/getEntitySet/division_level1", param_, function(result){
										options_ = result.data.entityset;
										obj.options = options_;
									});
								}
							}
						}
						else if (obj.field == "city") {
							if (obj.selectparent) {
								if(!this.formData[obj.selectparent]) {
									obj.options = []
								}
								else {
									var code_ = this.formData[obj.selectparent];
									let param_ = {
										isClientMode: false,
										filter: " level='2' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
									}
									Server.call("root/data/getEntitySet/division_level2", param_, function(result){
										options_ = result.data.entityset;
										obj.options = options_;
									});
								}
							}
						}
						else if (obj.field == "county") {
							if (obj.selectparent) {
								if(!this.formData[obj.selectparent]) {
									obj.options = []
								}
								else {
									var code_ = this.formData[obj.selectparent];
									let param_ = {
										isClientMode: false,
										filter: " level='3' and active='1' and EXISTS( SELECT * from md_division p where code='" + code_ + "' and md_division.parent_id = p.id)",
									}
									Server.call("root/data/getEntitySet/division_level3", param_, function(result){
										options_ = result.data.entityset;
										obj.options = options_;
									});
								}
							}
						}
					 },
					 selectchange(obj){
					 /* 	this.tableFields_new 
					 	let field = obj.fieldobj.field;
					 	let row = obj.data;
					 	if (field == "address") {
					 		let val = row[field];
					 		let name_ = "";
					 		let length_ = val.length;
					 		if (length_ > 0) {
					 			id_ = val[length_ - 1];
					 			name_ = this.tableFields_new[id_].field2
					 		}
					 		this.formData.field6 = name_;
					 	} */
					 },
					onformChange(obj) {
						var me = this;
						var formField_ = obj.fieldobj;
						if (formField_.field == "uscc" && this.formData.uscc) {
							let uscc_val = this.formData.uscc;
							me.doCheckUscc(uscc_val);
						}
						
						/* if (formField_.field == "md_description" || formField_.field == "record_province") {
							Root.confirm('更改商业名称或备案省份提交后将冻结其所有备案数据', '冻结提示', {
							  confirmButtonText: '继续更改',
							  cancelButtonText: '取消更改',
							  type: 'warning'
							}).then(() => {
								//继续提交
								
							}).catch(() => {
								//取消更改,后获取之前的数据并更改本次的数据
								
							});
						} */
						
						
					},
					
					onformSelectChange(obj) {
						var me = this;
						var formField_ = obj.fieldobj;
						
						if (formField_.field == "province" && !this.formData.record_province) {
							this.formData.record_province = clone(this.formData.province)
						}
					},
					//清空资质
					emptyMaterial() {
						
					},
					
					addDeliveryByDefault(customer_id) {
						var me = this;
						me.newtabledata_part[0].customer_uscc = this.formData.uscc;
						me.newtabledata_part[0].customer_id = customer_id;
						me.tableData2 = clone(me.newtabledata_part);
					},
					
					doCheckUscc(uscc_val) {
						var me = this;
						
						//清空商业其它数据
						//清空主体
						this.tableData2 = [];
						
						//清空资质
						this.emptyMaterial();
						
						//var filter_ = "uscc='" + uscc_val + "' and dc.delivery_part_code='" + this.newtabledata_part[0].delivery_part_code + "'";
						var filter_ = "uscc='" + uscc_val + "'";
					/* 	if (this.formData.id) {
							filter_ += " and id <> '" + this.formData.id + "'";
						} */
						var param_ = {
							isClientMode: false,
							dataname: "direct_customer",
							filter: filter_,
							orderby: " create_time desc"
						}
						//获取该uscc的商业自销信息
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data) {
								var data_ = result.data.entityset;
								if (data_.length == 0) {
									//查看是否存在其他工厂申请该商业
									var filter_o = "dc.uscc='" + uscc_val + "' and dcer.delivery_part_code<>'" + me.newtabledata_part[0].delivery_part_code + "' and dc.active='1'";
									
									let param_table_o = {
										isClientMode: false,
										dataname: "direct_customer",
										returnType: "entityset",
										filter: filter_o
									}
									//获取其它人是否创建此商业()
									Server.call("root/data/getEntitySet", param_table_o, function(result) {
										console.log(result);
										if (result.data.entityset && result.data.entityset.length > 0) {
											var row_ = result.data.entityset[0];
											/* Root.message({
												type: 'warning',
												message: row_.create_operate_name + '已创建该自销商业'
											});  
											me.formData.uscc = ""; */
											var id_ = uuid_short();
											me.acctObj = clone(dataobj_);
											me.formData = clone(dataobj_);
											me.acctObj.create_operate_id = me.formData.create_operate_id = me.newtabledata_part.business_operate_id;
											me.acctObj.create_operate_code = me.formData.create_operate_code = me.newtabledata_part.business_operate_code;
											me.acctObj.create_operate_name = me.formData.create_operate_name = me.newtabledata_part.business_operate_name;
											me.acctObj.id = me.formData.id = id_;
											me.acctObj.old_id = me.formData.old_id = row_.id;
											me.acctObj.active = me.formData.active = "0";
											
											me.tabs_sh = [];
											var form_sh = clone(me.default_form_sh);
											me.tabs_sh.push(form_sh);
											me.tabs_sh_old = [];
											me.activeTabs_sh = "0_";
											
											me.tabs_cg = [];
											var form_cg = clone(me.default_form_cg);
											me.tabs_cg.push(form_cg);
											me.tabs_cg_old = [];
											me.activeTabs_cg = "0_";
											
											//设置默认发货主体
											me.addDeliveryByDefault(id_);
										}
										else {
											//如果没有则看mdm上是否存在
											me.getMDMByUscc(uscc_val);
										}
									})
								}
								else {//如果有
									var dataobj_ = result.data.entityset[0];
									//设置商业信息
									me.acctObj = clone(dataobj_);
									me.formData = clone(dataobj_);
									me.old_data_syxx = clone(dataobj_);
									//判断商业是否存在自销并且自销是否在审批中,如果在则是只读模式,不允许修改
									//if (dataobj_.ismesale) {//存在自销
										if(dataobj_.me_state_s == "审批中") {//不包含拒绝状态
											//设置只读
											me.formAttr.disabled = true;
											me.notdisabled = false;
											me.approval = false;
											me.close = false;
										}
										/* else {//审批通过或未提交或被拒绝
											//加载商业
											//加载主体
											//加载资质
										} */
										//加载自销数据
										me.getInfoForm_me();//自销商业信息
										me.getTableDelivery();//发货主体
										me.getAttachmentType();//证照信息
										me.getInfoKP();//开票信息
										me.getInfoSH();//收货信息
										me.getInfoCG();//采购信息
										me.getInfoWL();//物流信息
										
									//}
 									/* else {
										//存在商业但没有自销
										
										//加载商业
										me.getInfoForm();//商业信息
										
										//设置默认自销主体数据
										me.newtabledata_part[0].customer_uscc = me.formData.uscc;//发货主体中的商业uscc
										me.newtabledata_part[0].customer_id = me.formData.id;//发货主体中的商业id
										me.tableData2 = clone(me.newtabledata_part);//主体明细
									} */
									
									/* Root.confirm('已存在' + uscc_val , '提示', {
									  confirmButtonText: '取消本次操作',
									  cancelButtonText: '取消',
									  type: 'warning'
									}).then(() => {
										
										me.closeDialog();
									}).catch(() => {
										me.formData.uscc = "";
									}); */
								}
							}
						});
						
					},
					
					getMDMByUscc(uscc_val) {
						var me = this;
						/* var filter_ = "c.uscc= '" + uscc_val + "'";
						
						let param_table = {
							isClientMode: false,
							dataname: "getUnOpenCustomer",
							returnType: "entityset",
							filter: filter_
						}
						//获取其它人是否创建此商业()
						Server.call("root/data/procedure", param_table, function(result) {
							console.log(result);
							if (result.data.entityset && result.data.entityset.length > 0) {
								var row_ = result.data.entityset[0];
								Root.message({
									type: 'warning',
									message: row_.create_operate_name + '已创建该商业'
								});  
								me.formData.uscc = "";
								
							}
							else { */
								//从本地生效的商业库是否能获取该商业
								var filter_o = "uscc='" + uscc_val + "'";
								
								let param_table_o = {
									isClientMode: false,
									dataname: "vCustomer",
									returnType: "entityset",
									filter: filter_o
								}
								Server.call("root/data/getEntitySet", param_table_o, function(result) {
									console.log(result);
									if (result.data.entityset && result.data.entityset.length > 0) {
										var row_ = result.data.entityset[0];
										//存在商业但没有自销
										//加载商业
										me.getInfoForm(row_.id);//商业信息
									}
									else {
										//如果没有则看mdm上是否存在
										let param_mdm = {
											isClientMode: false,
										}
										//从mdm获取该商业数据
										Server.call("mdm/check/uscc/" + uscc_val, param_mdm, function(result) {
											console.log(result);
											if (result.success) {
												var row = result.data;
												Root.confirm('MDM中已存在,是否开户' + row.md_description + '?', '开户提示', {
												  confirmButtonText: '使用MDM数据覆盖开户信息',
												  cancelButtonText: '取消',//'重新输入统一信用代码',
												  type: 'warning'
												}).then(() => {
													if(row.record_province) {
														row.record_province = me.dataRequestObj.map.mdm_province_mapping[row.record_province]
													}
													
													me.setKHDataByMDM(row);
												}).catch(() => {
													me.formData.uscc = "";       
												});
											}
										}, function(error) {
											console.log(error);
											//mdm中没有
											if (!me.formData.id) {
												me.formData.id = uuid_short();
											}
											
											me.tabs_sh = [];
											var form_sh = clone(me.default_form_sh);
											me.tabs_sh.push(form_sh);
											me.tabs_sh_old = [];
											me.activeTabs_sh = "0_";
											
											me.tabs_cg = [];
											var form_cg = clone(me.default_form_cg);
											me.tabs_cg.push(form_cg);
											me.tabs_cg_old = [];
											me.activeTabs_cg = "0_";
											
											//设置默认发货主体
											me.addDeliveryByDefault(me.formData.id);
											/* if(!error.success && error.message) {
												Root.message({
													type: 'error',
													message: error.message
												}); 
											} */
										});
									}
								})
								
								
							/* }
						}) */
					},
					
					setKHDataByMDM(data){
						var me = this;
						//设置商业信息
						var mdmdata = clone(data);
						
						//this.formData = {};
						//this.acctObj = {};
						//商业信息
						var formData1 = {};
						this.formFields.map(ff=>{
							if (mdmdata[ff.field]) {
								formData1[ff.field] = mdmdata[ff.field];
							}
						});
						formData1.apply_dep_code = localStorage.getItem("hierarchy_code");
						formData1.apply_dep_name = localStorage.getItem("hierarchy_name");
						
						formData1.operator_code = localStorage.getItem("emp_code");
						formData1.operator_name = localStorage.getItem("emp_name");
						
						var formData_ = clone(this.formData);
						
						for(var k in formData_) {
							if (formData_[k] && !formData1[k]) {
								formData1[k] = formData_[k];
							}
						}
						
						this.formData = clone(formData1);
						this.acctObj = clone(formData1);
						
						this.getInitOption();
						if (!me.formData.id) {
							me.formData.id = uuid_short();
						}
						
						me.tabs_sh = [];
						var form_sh = clone(me.default_form_sh);
						me.tabs_sh.push(form_sh);
						me.tabs_sh_old = [];
						me.activeTabs_sh = "0_";
						
						me.tabs_cg = [];
						var form_cg = clone(me.default_form_cg);
						me.tabs_cg.push(form_cg);
						me.tabs_cg_old = [];
						me.activeTabs_cg = "0_";
						
						//设置默认发货主体
						me.addDeliveryByDefault(me.formData.id);
						/* //设置证照信息
						var zzList = clone(data.licenceList);
						this.attachment_type_zs.map(e=>{
							if (e.code != "ZGL01") {
								me.file_zs[e.code] = {};
							}
							
							zzList.map(zz=>{
								if (zz.type == e.code) {
									if (e.code == "ZGL01") {
										for (var z in zz) {
											if(zz[z]) {
												me.file_zs[e.code][z] = zz[z];
											}
										}
										
									}
									else {
										me.file_zs[e.code] = zz;
									}
									
								}
							});
						});
						
						//设置开票信息
						me.formData_kp = {};
						if (data.bankInfo) {
							me.formData_kp = clone(data.bankInfo);
						} */
					},
					
					showFileImgByFileId(file_id, file_name) {
						this.zzimg = {};
						this.zzimgList = [];
						this.file_txt = false;
						if(file_id) {
							var fileid = file_id;
							let fileName = clone(file_name);
							let index1 = fileName.lastIndexOf(".");
							let index2 = fileName.length;
							let suffix = fileName.substring(index1, index2).toLowerCase(); //后缀名
							
							if (suffix == ".png" || suffix == ".jpg") {
								var zzimg_ = {
									id: fileid,
									url: getDownloadFileUrl(fileid)
								}
								
								this.zzimgList.push(zzimg_.url);
								this.zzimg = zzimg_;
								this.file_img = true;
							}
							else if (suffix == ".pdf") {
								var row = {
									fileid: fileid,
									filename: fileName
								}
								
								var config = {
									totab: true,
									icon: "icon-product",
									text: "附件预览",
									id: "pdf_" + fileid,
									url: "../tool/popup_file_pdf.html",
									data: row,
									delta: {},
									callback: function(obj, callback) {
										if (callback) {
											callback();
										}
									}
								};
								this.doPopupByPublic(config);
								
							}
							else {//只可下载,不可预览
								var zzimg_ = {
									id: fileid
								}
								this.zzimg = zzimg_;
								this.file_img = true;
							}
							// var zzimg_ = {
							// 	id: fileid,
							// 	url: getDownloadFileUrl(fileid)
							// }
							// this.zzimgList.push(zzimg_.url);
							
							// this.zzimg = zzimg_;
							// this.file_img = true;
						}
						
					},
					
					showFileImg(type) {
						this.zzimg = {};
						this.zzimgList = [];
						this.file_txt = false;
						if(this.file_zs[type].file_id) {
							var fileid = this.file_zs[type].file_id;
							
							let fileName = clone(this.file_zs[type].file_name);
							let index1 = fileName.lastIndexOf(".");
							let index2 = fileName.length;
							let suffix = fileName.substring(index1, index2).toLowerCase(); //后缀名
							
							if (suffix == ".png" || suffix == ".jpg") {
								var zzimg_ = {
									id: fileid,
									url: getDownloadFileUrl(fileid)
								}
								
								this.zzimgList.push(zzimg_.url);
								this.zzimg = zzimg_;
								this.file_img = true;
							}
							else if (suffix == ".pdf") {
								var row = {
									fileid: fileid,
									filename: fileName
								}
								
								var config = {
									totab: true,
									icon: "icon-product",
									text: "附件预览",
									id: "pdf_" + fileid,
									url: "../tool/popup_file_pdf.html",
									data: row,
									delta: {},
									callback: function(obj, callback) {
										if (callback) {
											callback();
										}
									}
								};
								this.doPopupByPublic(config);
								
							}
							else {//只可下载,不可预览
								var zzimg_ = {
									id: fileid
								}
								this.zzimg = zzimg_;
								this.file_img = true;
							}
						}
					},
					
					onDownloadFileByFileId(fileid) {
						handleDownload(fileid);
					},
					
					showFileTxt(type) {
						//this.file_zs[type];
						var me = this;
						
						/* if(me.isapprovaledit) {
							me.formAttr_zz.disabled = true;
						}
						else {
							me.formAttr_zz.disabled = false;
						} */
						this.file_img = false;
						this.file_txt = true;
						this.selectZZName = this.attachment_type_zzobj[type].name;
						this.selectZZType = type;
						
						if (!me.formAttr_zz.disabled) {
							this.$nextTick(() => {
								var aa = me.$refs.form_zzxx.checkForm();
							})
						}
						
					},
					
					delFile(zz_code, type, filetypename, row) {//
						var me = this;
						
						Root.confirm('确定删除-' + filetypename + '-的附件吗?', '删除提示', {
						  confirmButtonText: '删除',
						  cancelButtonText: '取消',
						  type: 'warning'
						}).then(() => {
							me.doDelFile(zz_code, type, row);
						}).catch(() => {
							Root.message({
								type: 'info',
								message: '已取消删除'
							});          
						});
					},
					
					doDelFile(zz_code, type, row) {
						row.file_id = "";
						row.file_name = "";
						
						if (type == "zz") {
							
						}
						else if (type == "kp") {
							
						}
						else if (type == "fhztfj") {
							
						}
						else if (type == "syxxfj") {
							
						}
						
						
						Root.message({
							type: 'success',
							message: '已删除,保存后生效'
						});
					},
					
					onPopupByUploadFile(zz_code, isupform, type) {
						var me = this;
						var analysistype_ = "";
						var delta_ = {filetypelist: []};
						if(zz_code == "ZGL01") {
							analysistype_ = "BizLicense";
							delta_ = {filetypelist: [".png", ".jpg"], analysistype: analysistype_}
						}
						else if(zz_code == "ZGL03") {
							analysistype_ = "BizYPLicence";
							delta_ = {filetypelist: [".png", ".jpg"], analysistype: analysistype_}
						}
						else if(zz_code == "ZGL06") {
							analysistype_ = "BizGSP";
							delta_ = {filetypelist: [".png", ".jpg"], analysistype: analysistype_}
						}
						var config = {
							totab: false,
							width: "1500px",
							icon: "icon-product",
							text: "附件上传",
							id: "popupByUploadFile",
							url: "../tool/popup_uploadFile.html",
							data: {},
							delta: delta_,
							callback: function(obj, callback) {
								me.uploadFileAfter(zz_code, obj, isupform, type);
							//	me.fileList = obj.row[0];
								if (callback) {
									callback();
								}
							}
						};
						this.doPopupByPublic(config);
					},
					
					doPopupByPublic(config) {
						if (config.totab) {
							if (config.url) {
								if (config.text.length > 4) {
									config.text = config.text.substr(0, 4) + "...";
								}
							}
							var parames = {
								totab: true,
								url: config.url,
								sceneCode: config.sceneCode,
								data: config.data,
								delta: config.delta,
								disabled: config.disabled,
								disabledone: config.disabledone,
								operationtype: config.operationtype,
								parentOption: window.top.tab.selected.option
							};
							
							Root.popupParames = parames;
							
							window.top.tab.open(config);
						}
						else {
							this.doPopup(config);
						}
					},
					
					uploadFileAfter(zz_code, obj, isupform, type) {
						//this.file_zs[zz_code] = obj.id;
						var me = this;
						if (type == "zz") {
							this.uploadFormByZZ(zz_code, obj, isupform);
						}
						else if (type == "kp") {
							this.uploadFormByKP(zz_code, obj);
						}
						else if (type == "fhztfj") {
							this.uploadFormByfhztfj(obj);
						}
						
						else if (type == "syxxfj") {
							this.uploadFormBysyxxfj(obj);
						}
						
						if (type == "sh") {
							this.uploadFormBySH(zz_code, type, obj);
						}
						if (type == "cg") {
							this.uploadFormByCG(zz_code, type, obj);
						}
						if (type == "zb") {
							this.uploadFormByZB(zz_code, type, obj);
						}
					},
					
					uploadFormByZZ(zz_code, obj, isupform) {
						//this.file_zs[zz_code] = obj.id;
						var me = this;
						var licenceObj_ = {};
						var file_zs_ = clone(this.file_zs);
						if (file_zs_[zz_code] && file_zs_[zz_code].id) {
							licenceObj_ = file_zs_[zz_code];
						}
						else {
							file_zs_[zz_code] = {};
						}
						
						var file_ = obj.row[0];
						var filetxt = obj.filetxt;
						if((zz_code == "ZGL01" || zz_code == "ZGL03" || zz_code == "ZGL06") && !filetxt) {
							Root.message({
								type: 'warning',
								message: '没有解析到数据'
							}); 
						}
						else if(zz_code == "ZGL01" || zz_code == "ZGL03" || zz_code == "ZGL06") {
							/* if (!filetxt) {
								Root.message({
									type: 'warning',
									message: '没有解析到数据'
								}); 
								return
							} */
							
							var bo_Check_ZGL01 = true;
							if(zz_code == "ZGL01" && (me.iscustomerchange || me.iscustomereditchange || me.isapprovaledit || me.formData.old_id)) {
								if (this.formData.uscc == filetxt["RegNum"]) {
									bo_Check_ZGL01 = false;
								}
								else {
									Root.message({
										type: 'warning',
										message: "统一信用代码与之前不同"
									}); 
									return;
								}
							}
							
							if (zz_code == "ZGL01" && (!this.formData.uscc || isupform)) {
								var formData_ = clone(this.formData);
								if(filetxt && filetxt["RegNum"]) {
									if (filetxt["RegNum"].length > 25) {
										filetxt["RegNum"] = "";
									}
									var uscc_val = filetxt["RegNum"];
									formData_.uscc = uscc_val;
									formData_.md_description = filetxt["Name"];
									formData_.legal_rep = filetxt["Person"];
									formData_.address = filetxt["Address"];
									this.formData = formData_;
									
									if (bo_Check_ZGL01) {
										me.doCheckUscc(uscc_val);
									}
								}
							}
							
							if (filetxt) {
								for (var k in this.filetypeMappin[zz_code]) {
									var txt = filetxt[this.filetypeMappin[zz_code][k]];
									if (!txt) {
										continue
									}
									
									if (k == "num" && txt && txt.length > 25) {
										txt = "";
									}
									
									if (k == "licence_date") {//"SetDate": "1998年11月"
										txt = txt.toString();
										txt = txt.replace("å¹´", "-");
										txt = txt.replace("月", "-");
										txt = txt.replace("æ—¥", "");
										if(txt && txt.search(/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/) == -1) {
											txt = ""
										}
										licenceObj_[k] = txt;
									}
									if (k == "license_term") {//"Period": "1998年11月至长期"
										var txtList = txt.split("至");
										if(txtList[0] == "年月日"){
											txt = "2099-12-31";
										}
										else {
											if (txtList.length > 1) {
												if(txtList[1].indexOf("长期") != -1){
													txt = "2099-12-31";
												}
												else {
													txt = txtList[1];
													
													txt = txt.replace("å¹´", "-");
													txt = txt.replace("月", "-");
													txt = txt.replace("æ—¥", "");
													if(txt && txt.search(/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/) == -1) {
														txt = ""
													}
													//licenceObj_[k] = txt;
												}
											}
											else if (txtList.length == 1) {
												txt = txtList[0];
												if(txt.indexOf("长期") != -1){
													txt = "2099-12-31";
												}
												txt = txt.replace("å¹´", "-");
												txt = txt.replace("月", "-");
												txt = txt.replace("æ—¥", "");
												if(txt && txt.search(/^[0-9]{4}-[0-9]{1,2}-[0-9]{1,2}$/) == -1) {
													txt = ""
												}
											}
										}
										licenceObj_[k] = txt;
									}
									else {
										licenceObj_[k] = txt;
									}
								}
							}
						}
						
						var zzObj = this.attachment_type_zzobj[zz_code];
						
						licenceObj_.type = zzObj.code;
						licenceObj_.type_name = zzObj.name;
						licenceObj_.file_id = file_.id;
						licenceObj_.file_name = file_.name;
						licenceObj_.only_attachment = zzObj.only_attachment;
						licenceObj_.owned_by = zzObj.owned_by;
						
						if (this.formData.id) {
							licenceObj_.customer_id = this.formData.id;
						}
						
						file_zs_[zz_code] = licenceObj_;
						
						this.file_zs = file_zs_;
						
						/* this.refresh_formzz = false;
						this.$nextTick(() => {
							me.refresh_formzz = true;
						}) */
					},
					
					uploadFormByKP(zz_code, obj){
						var me = this;
						var file_ = obj.row[0];
						
						var from_ = clone(this.formData_kp);
						
						if (!from_.customer_certification_id) {
							from_.customer_certification_id = this.acctObj.cer_id;
						}
						
						from_[zz_code] = file_.id;
						if (zz_code == "prove_file_id") {
							from_.prove_file_name = file_.name;
						}
						else if (zz_code == "invoice_file_id") {
							from_.invoice_file_name = file_.name;
						}
						this.formData_kp = from_;
					},
					
					uploadFormBySH(zz_code, type, obj){
						var me = this;
						var file_ = obj.row[0];
						let activeName = this.activeTabs_sh.split("_")[0];
						var tabs_sh_ = clone(this.tabs_sh);
						
						var from_ = tabs_sh_[activeName*1];
						from_[zz_code] = file_.id;
						if (zz_code == "book_file_id") {
							from_.book_name = file_.name;
						}
						else if (zz_code == "id_card_file_id") {
							from_.id_card_name = file_.name;
						}
						
						/* if (this.acctObj.cer_id) {
							licenceObj_.cer_id = this.acctObj.cer_id;
						} */
						this.tabs_sh = tabs_sh_;
					},
					formCheckboxChange_sh(obj) {
						if (obj.fieldobj.field =="id_card_term") {
							let activeName = this.activeTabs_sh.split("_")[0];
							var tabs_sh_ = clone(this.tabs_sh);
							
							var from_ = tabs_sh_[activeName*1];
							if(from_.islongterm) {
								from_.id_card_term = "2099-12-31"
							}
							this.tabs_sh = tabs_sh_;
						}
					},
					uploadFormByCG(zz_code, type, obj){
						var me = this;
						var file_ = obj.row[0];
						let activeName = this.activeTabs_cg.split("_")[0];
						var tabs_cg_ = clone(this.tabs_cg);
						
						var from_ = tabs_cg_[activeName*1];
						from_[zz_code] = file_.id;
						if (zz_code == "book_file_id") {
							from_.book_name = file_.name;
						}
						else if (zz_code == "id_card_file_id") {
							from_.id_card_name = file_.name;
						}
						else if (zz_code == "diploma_file_id") {
							from_.diploma_name = file_.name;
						}
						
						/* if (this.acctObj.cer_id) {
							licenceObj_.cer_id = this.acctObj.cer_id;
						} */
						this.tabs_cg = tabs_cg_;
					},
					
					formCheckboxChange_cg(obj) {
						if (obj.fieldobj.field =="id_card_term") {
							let activeName = this.activeTabs_cg.split("_")[0];
							var tabs_cg_ = clone(this.tabs_cg);
							
							var from_ = tabs_cg_[activeName*1];
							if(from_.islongterm) {
								from_.id_card_term = "2099-12-31"
							}
							this.tabs_cg = tabs_cg_;
						}
					},
					uploadFormByZB(zz_code, type, obj){
						
						
					},
					
					uploadFormByfhztfj(obj){
						var me = this;
						var file_ = obj.row[0];
						
						var from_ = clone(this.formData_part);
						from_.file_id = file_.id;
						from_.file_name = file_.name;
						this.formData_part = from_;
					},
					
					uploadFormBysyxxfj(obj){
						var me = this;
						var file_ = obj.row[0];
						
						var from_ = clone(this.formData);
						from_.file_id = file_.id;
						from_.file_name = file_.name;
						this.formData = from_;
					},
					
					onPopupByUploadFileAll() {
						var me = this;
						this.attachment = "";
						this.attachment_name = "";
						
						var config = {
							totab: false,
							width: "1500px",
							icon: "icon-product",
							text: "附件上传",
							id: "popupByUploadFile",
							url: "../tool/popup_uploadFile.html",
							data: {},
							delta: {filetypelist: []},
							callback: function(obj, callback) {
								var file_ = obj.row[0];
								me.attachment = file_.id;
								me.attachment_name = file_.name;
								
								if (callback) {
									callback();
								}
							}
						};
						this.doPopupByPublic(config);
					},
					
					onShowApproval() {
						var me = this;
						let param = {
							isClientMode: false,
							flowId: this.acctObj.flow_id
						}
						
						Server.call("root/order/getHistoryTask/", param, function(result) {
							console.log(result);
							if (result && result.data) {
								me.getApprovalRecord(result.data);
							}
						}); 
							
					},
					
					getApprovalRecord(data) {
						let me = this;
						var config = {
							hide_close: true,
							width: "900px",
							height:"600px",
							url: "../approval/ApprovalList.html",
							data: data,
							delta: {
								flow_id: this.acctObj.flow_id,
								title: this.title
							},
						};
						this.doPopupByPublic(config);
					},
					
					formChange_zz(obj) {
						var form_ = this.file_zs[this.selectZZType];
						if (!form_.customer_certification_id) {
							if(form_.id) {
								form_.old_id = clone(form_.id);
							}
							
							form_.customer_certification_id = this.acctObj.cer_id;
							form_.id = null;
						}
					},
					
					formChange_kp(obj) {
						var form_ = this.formData_kp;
						if (!form_.customer_certification_id) {
							if(form_.id) {
								form_.old_id = clone(form_.id);
							}
							form_.customer_certification_id = this.acctObj.cer_id;
							form_.id = null;
						}
						
					},
					
					formChange_sh(obj) {
						
					},
					
					formChange_cg(obj) {
						
					},
					
					formChange_zb(obj) {
						
					},
					
					formChange_wl() {
						
					},
					
					addTableData_sh() {
						var form_ = clone(this.default_form_sh);
						this.tabs_sh.push(form_);
						this.$nextTick(function(){
							this.activeTabs_sh = (this.tabs_sh.length - 1) + "_";
						})
					},
					
					removeTab_sh(targetName) {
						let tabs = this.tabs_sh;
						let activeName = targetName.split("_")[0];
						var rab_ = this.tabs_sh[activeName*1];
						
						if (rab_.create_operate_id != localStorage.getItem("emp_id")) {
							Root.message({
								type: 'warning',
								message: '此收货数据由_' + rab_.create_operate_name + "_录入,非本人不得删除"
							});
							return
						}
						
						this.tabs_sh.remove(rab_);
						this.$nextTick(function(){
							this.activeTabs_sh = (this.tabs_sh.length - 1) + "_";
						})
					},
					
					addTableData_cg() {
						var form_ = clone(this.default_form_cg);
						this.tabs_cg.push(form_);
						this.$nextTick(function(){
							this.activeTabs_cg = (this.tabs_cg.length - 1) + "_";
						})
					},
					
					removeTab_cg(targetName) {
						let tabs = this.tabs_cg;
						let activeName = targetName.split("_")[0];
						var rab_ = this.tabs_cg[activeName*1];
						
						if (rab_.create_operate_id != localStorage.getItem("emp_id")) {
							Root.message({
								type: 'warning',
								message: '此采购数据由_' + rab_.create_operate_name + "_录入,非本人不得删除"
							});
							return
						}
						
						this.tabs_cg.remove(rab_);
						this.$nextTick(function(){
							this.activeTabs_cg = (this.tabs_cg.length - 1) + "_";
						})
					},
					
					
				}
			});
		</script>
		
		<style>
			.h_header {
				padding: 0px !important;
			}
			.zs_ .el-form-item {
				position: relative;
				line-height: 34px !important;
			}
			.zs_ .el-form-item__label {
				font-size: 12px;
				line-height: 20px;
				position: absolute;
				bottom: 5px;
			}
			
			.zs_ .el-form-item__content {
				line-height: 34px !important;
			}
			
			.zs_ .close_file {
				float: left;
			}
			
			.zs_ .close_file:hover {
				color: red;
				font-weight: bold;
				cursor: pointer;
			}
			
			.item_badge {
			  margin-top: 0px;
			  margin-right: 0px;
			}
			
			.el-image-viewer__wrapper .el-icon-circle-close {
			    color: #c00606;
			}
			
			.fj_button .el-button--small, .fj_button .el-button--small.is-round {
			    padding: 9px 9px;
			}
			.header {
				height: 21px;
			}
			.el-dialog__header {
			    border-bottom: 0;
			}
			.el-dialog__body {
			    text-align: center;
				/* height: 200px; */
			}
		</style>
	</body>
</html>