<!doctype html>
<html>
	<head>
		<meta charset="utf-8"><meta http-equiv="Expires" content="0"><meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Cache" content="no-cache">
		<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?v=20220425"></script>
		<script src="../../../js/vue/page.js?v=20220425"></script>
		
		<link href="../../../js/vue/element-ui/lib/theme-chalk/index.css" rel="stylesheet">
		<link href="../../../css/myelement.css?v=20220425" rel="stylesheet">
		<link href="../../../css/iconfont.css" rel="stylesheet">
		<link href="../../../css/page.css?v=20220425" 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-form >
								<el-form-item :label="isfreeze ? '选择禁用方式' : '选择激活方式' ">
									<el-select v-model="freeze_type" placeholder="">
										<el-option label="处方药" value="CFY"></el-option>
										<el-option label="特药" value="TY"></el-option>
										<el-option label="OTC" value="OTC"></el-option>
									</el-select>
								</el-form-item>
							</el-form>
							
							<h-form
								ref="form2"
								:form-attr="formAttr_ba"
								:table-fields="tableFields_ba"
								:form-data="formData"
								v-on:show-popup="showPopup"
							>
							</h-form>
						</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="formData.id && formData.delivery_status=='refuse'" style="margin: 0px 20px;">
							<el-button type="danger" @click="onrefuseApproval">撤 销</el-button>
							<el-button type="success" @click="onpassApproval">再次提交</el-button>
						</el-button-group>
						<el-button type="default" @click="closeDialog">取 消</el-button>
					</div>
				</div>
				
				
				<!-- <el-dialog :title="isfreeze ? '冻结备案' : '激活备案'" :visible.sync="dialog_freeze" v-if="dialog_freeze" width="900px">
					<el-form >
						<el-form-item :label="isfreeze ? '选择禁用方式' : '选择激活方式' ">
							<el-select v-model="freeze_type" placeholder="">
								<el-option label="处方药" value="CFY"></el-option>
								<el-option label="特药" value="TY"></el-option>
								<el-option label="OTC" value="OTC"></el-option>
							</el-select>
						</el-form-item>
					</el-form>
					
					<h-form
						ref="form2"
						:form-attr="formAttr_ba"
						:table-fields="tableFields_ba"
						:form-data="formData_ba"
						v-on:show-popup="showPopup"
					>
					</h-form>
					
					<div slot="footer" class="dialog-footer">
						<el-button @click="dialog_freeze = false" type="txt">取 消</el-button>
						<el-button-group v-if="selectedrow.id && selectedrow.delivery_status=='refuse'" style="margin: 0px 20px;">
							<el-button type="danger" @click="onrefuseApproval">撤 销</el-button>
							<el-button type="success" @click="onpassApproval">再次提交</el-button>
						</el-button-group>
						
						<el-button-group v-else style="margin: 0px 20px;">
							<el-button type="primary" @click="submitFreeze()">{{isfreeze ? '冻 结' : '激 活'}}</el-button>
						</el-button-group>
					</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: "",
					
					iframe_url: "../../approval/ApprovalList_page.html",
					
					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,
					
					submitreason_type: "",
					submitreason_dialog: false,
					submitreason: "",
					loading_submitreason: 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: {},
					activeNames: "1",
					refresh_formzz: true,
					file_zs: {},
					file_zsold: {},
					warningzs: {},
					file_img: false,
					zzimg: {},
					zzimgList: [],
					file_txt: false,
					selectZZType: "ZGL01",
					selectZZName: "",
					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},
					],
					isWithinEditTableData: true,
					licenceList: [],
					attachment_type_zzobj: {},
					formAttr_zz: {
						istitle: false,
						title: "证照详情",
						columnnumber: 1,
						labelwidth: "150px",
						labelposition: "right",
						size: "medium",
						border: "3px solid #c6c6c600",
						disabled: true,
						formatter: function(data, fields) {
							
						}
					},
					attachment_type_zs: [],
					attachment_type_zs_customer: [],
					
					attachment_type_kp: [
						{code: "prove_file_id", name: "银行开户证明", namecode: "prove_file_name"},
						{code: "invoice_file_id", name: "开票资料", namecode: "invoice_file_name"},
					],
					formAttr_kp: {
						istitle: false,
						title: "开票信息",
						columnnumber: 1,
						labelwidth: "130px",
						labelposition: "right",
						size: "medium",
						disabled: true,
						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) {
							
						}
					},
					
					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"
						},
					},
					
					tableFields_kp: [
						{isshow: "T", field: "bank_name", name: "开户银行", align: "center"},
						{isshow: "T", field: "bank_account", name: "银行帐户", align: "center"},
						{isshow: "T", field: "bank_account_name", name: "帐户名称", align: "center", width: "100"},
						//{isshow: "T", field: "bank_delete", name: "是否失效", align: "center", width: "100", type:"select", options: [{label: "否",value: 0}, {label: "是",value: 1}]},
						{isshow: "T", field: "bank_address", name: "开票地址", align: "center", width: "100"},
						{isshow: "T", field: "bank_tel", name: "开票电话", align: "center"},
						//{isshow: "T", field: "active", name: "当前系统使用", align: "center", type:"select", options: [{label: "未用",value: 0}, {label: "使用",value: 1}]},
					],
					formData_kp: {},
					formData_kpold: {},
					
					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: {
						licence_zz: {},
						business: {},
						delivery: {},
					},
					customerRequiredByRoleidTypeList: {},
					
					tableFields: [],
					tableData2: [],
					tableData2_thisoldobj: {},
					
					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: true,
						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, 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, type: "select", options: [{code: 1, name: "经销"}, {code: 2, name: "分销"}, {code: 3, name: "直销"}], props: {value: "code", label: "name", checkStrictly: true}},
						{isshow: "T", field: "business_operate_name", name: "商业操作人", required: 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: {},
					
					
					isfreeze: false,
					freeze_type: "",
					
					formAttr_ba: {
						istitle: false,
						title: "商业备案编辑",
						columnnumber: 2,
						labelwidth: "130px",
						labelposition: "right",
						size: "medium",
						border: "10px solid #c6c6c600"
					},
					tableFields_ba: [
						{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: "customer_identity", name: "客户身份", required: true, type: "select", options: [{code: 1, name: "经销"}, {code: 2, name: "分销"}, {code: 3, name: "直销"}], props: {value: "code", label: "name", 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: "business_operate_name", name: "商业操作人", required: true, type: "popup"},
						{isshow: "T", field: "business_operate_code", name: "操作人编码", disabled: true}
						//{isshow: "T", field: "remark", name: "备案原因", required: true},
						//{isshow: "T", field: "file_name", name: "附件", type: "span", buttonname:"附件上传"},
						
					],
				},
				
				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.delta) {
						this.act_type = this.popupParames.delta.act_type;
					} */
					if (this.popupParames.data) {
						let formData1 = {};
						formData1 = clone(this.popupParames.data);
						
						me.freeze_type = formData1.part_type;
						me.isfreeze = formData1.freeze;
						
						me.formData = clone(formData1);
					}
					
					if (this.popupParames.title) {
						this.title = clone(this.isfreeze ? '冻结备案' : '激活备案' + this.popupParames.title);
					}
				},
				
				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 == "versionapproval") {
								//me.isapprovaledit = true;
							}
							
							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.id) {
							this.getInfoForm();
							this.getInfoKP();
							this.getTableDelivery();
							
							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 (me.popupParames.sceneCode == "add_mdm") {
								this.getInfoKP();
							}
							this.getInitOption();
						}
					},
					
					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];
							}
						});
						if(formData1.md_code) {
							formData1.old_code = formData1.md_code.toString()
						}
						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();
						
						//设置证照信息
						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);
						}
					},
					
					getAttachmentType() {
						let me = this;
						let param_table = {
							isClientMode: false,
							dataname: "attachment_type",
							filter: "active=1",
							orderby: "order_no"
						}
						this.attachment_type_zs = [];//证书
						this.attachment_type_zs_customer = [];//商业信息证书
						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.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;
										}
										
										if(e.code == "ZGL01" || e.code == "ZG25E") {
											me.attachment_type_zs_customer.push(e);
										}
										
										me.attachment_type_zs.push(e);
									}
									else {
										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]);
							}
						});
					},
					
					getInfoFormOld() {
						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.formDataOld = clone(result.data.entityset[0]);
							}
						});
					},
					
					getInfoForm() {
						var me = this;
						var customer_id_ = this.acctObj.id;
						
						//审批时,根据明细数据中的customer_id
						if(this.acctObj.customer_id) {
							customer_id_ = this.acctObj.customer_id;
						}
						/* var dataname_ = "customerNow";
						if (this.acctObj.ag == 1) {
							dataname_ = "agCustomer";
						} */
						
						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 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();
							}
						});
					},
					
					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 {
							var customer_uscc_ = this.acctObj.uscc;
							
							var filter_ = "customer_uscc='" + customer_uscc_ + "'";
							var dataname_ = "agCustomerLicence";
							if(this.acctObj.customer_id) {
								//filter_ = "customer_id='" + this.acctObj.customer_id + "'";
								//dataname_ = "customerLicenceMapping";
							}
							
							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;
									});
									
									me.getInfoZZOld(result.data.entityset);
								}
							});
						}
					},
					
					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_licence_mapping.id in (" + ids_ + ")";
							var dataname_mapping = "agCustomerLicence";
							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;
						if (me.popupParames.sceneCode == "add_mdm") {
							if (this.popupParames.data.bankInfo) {
								me.formData_kp = clone(this.popupParames.data.bankInfo);
							}
						}
						else {
							var customer_uscc_ = this.acctObj.uscc;
							
							var filter_ = "customer_uscc='" + customer_uscc_ + "'";
							var dataname_ = "agCustomerInvoice";
							if(this.acctObj.customer_id) {
								//filter_ = "customer_id='" + this.acctObj.customer_id + "'";
								//dataname_ = "customerInvoiceMapping";
							}
							
							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) {
									me.formData_kp = result.data.entityset[0];
									
									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];
								}
							});
						}
					},
					
					
					getTableDelivery() {
						var me = this;
						var customer_uscc_ = this.acctObj.uscc;
						
						var filter_ = "customer_uscc='" + customer_uscc_ + "'";
						var dataname_mapping = "agCustomerDeliveryLineRaw";//"delivery_mapping";
						filter_ += " and cdm.used = 1 and ((cdm.flow_id is null and cdm.create_operate_code='"+ localStorage.getItem("emp_code") +"') or (cdm.flow_id is not null and flows.status in ('refuse', 'working', 'open')) )"
						if(this.acctObj.customer_id) {
							filter_ = "id='" + this.acctObj.id + "'";
							dataname_mapping = "agCustomerDelivery";//"delivery_mapping";
							filter_ += " and a.used = 1 and ((a.flow_id is null and a.create_operate_code='"+ localStorage.getItem("emp_code") +"') or (a.flow_id is not null and a.status in ('refuse', 'working', 'open')))"
						}
						
						
						let param_table = {
							isClientMode: false,
							dataname: dataname_mapping,
							filter: filter_,
						}
						if(!this.acctObj.customer_id) {
							param_table.empId = localStorage.getItem("emp_id");
						}
						
						me.tableData2 = [];
						me.tableloading = true;
						me.tableData2_thisoldobj = {};
						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;
								
								result_.data.entityset.map(e=>{
									me.tableData2_thisoldobj[e.id] = e;
								});
								
								me.getTableDataOld(result_.data.entityset);
							}
						});
					},
					
					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 = "agCustomerDelivery";
							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 internationPart_ = false;
						if (me.formData.apply_dep_code && me.formData.apply_dep_code == "202105180005") {
							internationPart_ = true;
						} */
						var param_submit = {
							isClientMode: false,
							id: id_,
							/* variable_map:{
								internationPart:internationPart_
							} */
						}
						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: "调整提交",
								internationPart: internationPart_
							},
							business_type: "accountCustomerDelivery",
							isClientMode: false,
						}
						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("fhzt");
										});
										
									});
								}
								else {
									Root.message({
										type: 'success',
										message: '保存成功'
									}); 
									
									me.saveAfter("fhzt");
								}
							}
						})
					},
					
					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: "调整提交",
												internationPart: internationPart_
											},
											business_type: "accountCustomerDelivery",
											isClientMode: false,
										}
										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(code) {
						this.submitreason_type = code;
						
						this.submitreason = "";
						this.loading_submitreason = false;
						
						this.submitreason_dialog = true;
					},
					
					saveSubmit() {
						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() {
						if (this.submitreason_type == "scsykh") {//首次商业开户
							this.issubmit = true;
							this.loading_submit = true;
							this.loading_submitreason = true;
							this.saveTables();
						}
					},
					
					saveTables() {
						var me = this;
						//校验数组中是否有重复数据checkDataByR
						this.checkDataByArray(this.tableData2, function() {
							me.doSaveTables();
						}, function() {
							me.issubmit = false;
							me.loading_submit = false;
							me.submitreason_dialog = false;
							
							Root.message({
								type: 'warning',
								message: '存在相同数据'
							});
							return
						});
					},
					
					doSaveTables() {
						var me = this;
						me.loading_save = true;
						var param = clone(this.formData);
						if (!param.uscc) {
							Root.message({
								type: 'warning',
								message: '请先设置统一社会信用代码'
							});
							return
						}
						//备案明细
						param.delivery_list = this.tableData2;
						
						//证照
						var licenceList_ = [];
						this.attachment_type_zs.map(zs=>{
							var zsobj_ = me.file_zs[zs.code];
							if (zsobj_.file_id) {
								//zsobj_.code = zs.attachment_code;
								licenceList_.push(zsobj_);
							}
						});
						
						if (licenceList_.length) {
							param.licence_list = licenceList_;
						}else {
							param.licence_list = null;
						}
						
						//开票
						var formData_kp_notnull = false;
						for (var kp_ in me.formData_kp) {
							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;
							}
							
							param.invoice = me.formData_kp;
						}else {
							param.invoice = null;
						}
						
						param.type = "create";
						param.isClientMode = false;
						Server.call("root/customer/saveCustomer", 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;
									}
									var internationPart_ = false;
									if (me.formData.apply_dep_code && me.formData.apply_dep_code == "202105180005") {
										internationPart_ = true;
									}									
									var param_submit = {
										isClientMode: false,
										id: id_,
										submitreason: me.submitreason,
										variable_map:{
											internationPart:internationPart_
										},
									}
									Server.call("root/customer/batchCommitByAccountCustomer", param_submit, function(result1) {
										console.log(result1);
										me.loading_submit = false;
										me.submitreason_dialog = 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;
										me.submitreason_dialog = 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;
							me.submitreason_dialog = 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 l_ = {
								type: "add", 
								field: "business_id", 
								fieldname: "角色关联商业",
								currentdata: p.business_id
							}
							*/
							
							var isclose = true;//是否关闭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";
								var row = clone(this.selectrow);
								if(row.id) {
									operatelogdataobj = {//日志头信息
										businessid: row.id,
										businessname: row.delivery_part_name + me.formData.uscc,
										dataname: "agCustomerDelivery",
										operateremark: "发货主体调整"
									};
									
									var isArray = false;
									var dataFields = me.tableFields_part;
									var old_data = {};
									
									if (row.old_id && me.tableDataOldObj[row.old_id]) {//id变了,变更改变
										old_data = clone(me.tableDataOldObj[row.old_id]);
									}
									
									if (me.tableData2_thisoldobj[row.id]) {//id没变,数据改变,流程中的调整
										old_data = clone(me.tableData2_thisoldobj[row.id]);
									}
									
									var new_data = clone(row);
									fieldobjlist = me.getDataDifference(dataFields, old_data, new_data, isArray);
								}
								else {
									this.doSaveAfter();
								}
							}
							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("该按键事件缺失!")
						}
					},
					
					saveTables2() {
						 if (!this.formData.manager_part_name || !this.formData.delivery_part_code || 
						!this.formData.customer_name || !this.formData.customer_consignee_address || !this.formData.customer_consignee_user_name || 
						!this.formData.customer_consignee_phone) {
							Root.message({
								type: 'warning',
								message: '请填写必填项'
							});
							return;
						}
						 
						var array_ = [];
					
						for (var i = 0;i< this.tableData2.length;i++) {
							var row = this.tableData2[i];
							var row_ = {};
							var sales_type_ = "";
							row_.id = row.id ? row.id : "";
							row_.count = row.standrad_cnt;		//ä»¶æ•°
							if(row.sales_type == "正常销售"){
								sales_type_ = "1"
							}else if(row.sales_type == "样品销售"){
								sales_type_ = "2"
							}else{
								sales_type_ = "3"
							}
							row_.rebateAmt = row.rebate_amt;
							row_.salesType = sales_type_;	//销售类型。。正常销售
							row_.taxRate = row.tax_rate;	//税率
							row_.agreementRecordId = row.agreement_record_id?row.agreement_record_id:"";		//协议id  row.agreementRecordId
							row_.remark = row.remark;
							if(row_.agreementRecordId != ""){
								array_.push(row_);
							}
						}
						
						let param =
						{
							isClientMode: false,
							id: this.formData.id ? this.formData.id : "",
							customerId: this.formData.customer_id,
							bizDate: this.formData.biz_date,
							settleType:this.formData.settle_type,
							salesBusinessType: this.formData.sales_business_type == "分期收款" || this.formData.sales_business_type == "1"?"1":"2",
							agreementRecordId: this.formData.agreementRecordId ? this.formData.agreementRecordId:"",//this.formData.agreementRecordId,	//协议id
							contractNo :this.formData.contract_no ? this.formData.contract_no:"",
							contractFileId :this.formData.ids || "",
							subSalesOrderList: array_,
							customerConsignee: {	//收货信息
								id: this.formData.addressid?this.formData.addressid:"",//this.formData.addressid,
								userName: this.formData.customer_consignee_user_name,
								address: this.formData.customer_consignee_address? this.formData.customer_consignee_address:"",
								phone: this.formData.customer_consignee_phone
							},
						}
						let me = this;
						/* Server.call("root/order/saveSalesOrder", param, function(result) {
							console.log(result);
							if(result.success){
								if(me.formData.continueCommit){
									let param_ = {
										orderId:result.data.id,
										eventType:"commit",
										dataType:"sales",
										isClientMode: false,
									}
									Server.call("root/order/onEvent", param_, function(result_) {
										console.log(result_);
										if (result_.success){
											Root.message({
												type: 'success',
												message: '提交成功'
											}); 
										}else{
											Root.confirm(result_.data.message + ',确定直接提交吗?', '提示', {
											  confirmButtonText: "提交",
											  cancelButtonText: '取消',
											  type: 'warning'
											}).then(() => {
												let param = {
													orderId:result.data.id,
													eventType:"commit",
													dataType:"sales",
													isClientMode: false,
													extra:{
														mandatory:true
													},
												}
												Server.call("root/order/onEvent", param, function(result) {
													console.log(result);
													if (result.success){
														Root.message({
															type: 'success',
															message: '提交成功'
														}); 
														Root.tab.removeItem(Root.tab.selected);
														Root.tab.open(me.popupParames.parentOption, true); 
													}else{
														Root.message({
															type: 'warning',
															message: '提交失败'
														}); 
													}
												});
												
											}).catch(() => {
												Root.message({
													type: 'info',
													message: '已取消'
												});          
											});
										}
									});
								}
								else{
									Root.message({
										type: 'success',
										message: '保存成功'
									}); 
									Root.tab.removeItem(Root.tab.selected);
									Root.tab.open(me.popupParames.parentOption, true); 
								}
								
							}
							else{
								Root.message({
									type: 'warning',
									message: result.message
								}); 
							}
							
						}); */
					},
					
					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() {
						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_;
						
						this.part_dialog = true;
						
						this.formData_part = {
							customer_uscc: this.formData.uscc,
							create_operate_name: localStorage.getItem("emp_name"),
							create_operate_code: localStorage.getItem("emp_code"),
							create_operate_id: localStorage.getItem("emp_id")
						};
						
						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
								}); 
							}
						})
					},
					onreturnApproval() {
						this.returnApproval(this.acctObj.flow_id);
					},
					onpassApproval(){
						var bo = true;
						this.textarea2 = "";
						this.reasonvisible = true;
						this.passOrRefuse = true;
						this.type_act = "deliveryFreeze";
					},
					onrefuseApproval(){
						this.canceltype = "customer_delivery";
						this.textarea2 = "";
						this.reasonvisible = true;
						this.passOrRefuse = false;
						this.type_act = "deliveryFreeze";
					},
					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.formData);
						
						if (deliveryObj_.freeze) {//冻结 
							variable_map_ = {
								reason: reason_,
								stict: false,
								
								id: me.formData.id,
								recordProvince: me.formData.record_province,
								partType: me.freeze_type,
								
								businessType: me.formData.business_type,
								customerPartCode: me.formData.customer_part_code,
								operateCode: me.formData.business_operate_code,
							}
						}
						else {//激活
							variable_map_ = {
								reason: reason_,
								stict: false,
								
								id: me.formData.id,
								recordProvince: me.formData.record_province,
								partType: me.freeze_type,
								
								businessType: me.formData.business_type,
								customerPartCode: me.formData.customer_part_code,
								operateCode: me.formData.business_operate_code,
							}
						}
						
						if (this.attachment) {
							variable_map_.attachment = this.attachment;
						}
						let param = {
							flow_id: this.formData.flow_id,
							pass: pass_,
							
							variable_map: variable_map_,
							business_type: this.type_act,//business_type: "accountCustomerDelivery"
							isClientMode: false
						}
						
						Server.call("root/api/dealAct", param, function(result) {
							console.log(result);
							me.loading_approval = false;
							if (result.success){
								if (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();
							}
							
						});
					},
					
					passApproval222(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_
							}
						}
						else {
							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;
						}
						
						variable_map_.internationPart = internationPart_
						
						//return
						let param = {
							flow_id: this.reasonvisible_flowid,
							pass: pass_,
							
							variable_map: variable_map_,
							business_type: this.type_act,//business_type: "accountCustomerDelivery"
							isClientMode: false,
						}
						Server.call("root/api/dealAct", param, function(result) {
							console.log(result);
							me.loading_approval = false;
							if (result.success){
								if (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_delivery") {//发货主体冻结/激活撤销
							var param_ = {
								isClientMode: false,
								id: me.formData.id,
								dataname: "agCustomerDelivery",
								used: 0,
								active: 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: "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",
								delta: {
									isvemployeeall: false
								},
								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(filter) {//tableFields_baObj
						var me = this;
						var fieldObj_ = filter.obj;
						var formData_part_ = clone(me.formData);
						var field_ = fieldObj_.field;
						
						if (field_ == "business_operate_name") {
							Root.showPopup({
								url: "../md/customer/popup/employee_list.html",
								delta: {
									isvemployeeall: true
								},
								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 = formData_part_;
									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)
						}
					},
					
					doCheckUscc(uscc_val) {
						var me = this;
						var filter_ = "uscc='" + uscc_val + "'";
						if (this.formData.id) {
							filter_ += " and id <> '" + this.formData.id + "'";
						}
						var param_ = {
							isClientMode: false,
							dataname: "accountCustomer",
							filter: filter_,
						}
						
						Server.call("root/data/getEntitySet", param_, function(result) {
							console.log(result);
							if (result && result.data) {
								var data_ = result.data.entityset;
								if (data_.length == 0) {
									me.getMDMByUscc(uscc_val);
								}
								else {
									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 + "'";
						if (this.formData.id) {
							filter_ = "c.uscc= '" + uscc_val + "' and c.id <>'" + this.formData.id + "'";
						}
						
						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 {
								let param_mdm = {
									isClientMode: false,
								}
								
								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);
									/* if(!error.success && error.message) {
										Root.message({
											type: 'error',
											message: error.message
										}); 
									} */
								});
							}
						})
					},
					
					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);
						}
						
					},
					
					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);
						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_;
					},
					
					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);
					},
					
				}
			});
		</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>