2018-10-20 13:52:42 +08:00

310 lines
13 KiB
Plaintext

<%@ page contentType="text/html; charset=GBK"%>
<%@page import="jbo.com.tenwa.entity.comm.flow.FLOW_BUSSINESS_OBJECT"%>
<%@page import="jbo.app.tenwa.customer.CUSTOMER_COMPANY_TEMP"%>
<%@page import="jbo.app.tenwa.customer.CUSTOMER_PERSON_TEMP"%>
<%@page import="com.amarsoft.app.check.CheckFLowPhaseNo"%>
<%@ include file="/Frame/resources/include/include_begin_info.jspf"%><%
/*
Author: undefined 2016-05-27
Content: 示例详情页面
History Log:
*/
String sPrevUrl = CurPage.getParameter("PrevUrl");
String customertype = CurPage.getParameter("customertype");//获取客户类型,用于判断生成合同的方法
String flowunid=CurPage.getParameter("FlowUnid");
String ishistory=CurPage.getParameter("IsHistory");
String proj_id=CurPage.getParameter("proj_id");
String projectId=CurPage.getParameter("ProjectId");//获取项目projectID
String taskno=CurPage.getParameter("TaskNo");
String nodeNo=CurPage.getParameter("NodeNo");
String contractNo=CurPage.getParameter("ContractNo");
String FlowKey=CurPage.getParameter("FlowKey");//获取合同编号
String flowName=CurPage.getParameter("FlowName");//获取合同名称
if(null==contractNo ||"null".equals(contractNo) ){
contractNo=FlowKey;
}
String RightType= CurPage.getParameter("RightType");
String phaseno = CheckFLowPhaseNo.run(flowunid, taskno);
String sFileSaveMode = CurConfig.getConfigure("FileSaveMode");
String sFileSavePath = CurConfig.getConfigure("FileSavePath");
String sFileNameType = CurConfig.getConfigure("FileNameType");
//获取租赁方式,用于判断生成的合同类型
String leasform = CurPage.getParameter("leasform");
if(sPrevUrl == null) sPrevUrl = "";
String sTempletNo = "BaseFileTemplateSelect";//--模板号--
//获取对应的承租信息
String certid=null;
String mobile=null;
String address=null;
/* BizObjectManager lultm = JBOFactory.getBizObjectManager(LB_UNION_LESSEE_temp.CLASS_NAME);
String sSql = "select o.CUSTOMER_ID FROM o where o.flowunid =:flowunid";
BizObject lult = lultm.createQuery(sSql).setParameter("flowunid", flowunid).getSingleResult(false); */
String customerid = Sqlca.getString("select customer_id from lb_union_lessee_temp where flowunid='"+flowunid+"'");
if("01".equals(customertype)){
BizObjectManager cctm = JBOFactory.getBizObjectManager(CUSTOMER_COMPANY_TEMP.CLASS_NAME);
String sSql = "select o.certid,o.tel,o.reg_address FROM o where o.customerid =:customerid";
BizObject cct = cctm.createQuery(sSql).setParameter("customerid", customerid).getSingleResult(false);
certid=cct.getAttribute("certid").getString();
mobile=cct.getAttribute("tel").getString();
address=cct.getAttribute("reg_address").getString();
}else{
BizObjectManager cptm = JBOFactory.getBizObjectManager(CUSTOMER_PERSON_TEMP.CLASS_NAME);
String sSql = "select o.certid,o.mobile,o.nativeplace FROM o where o.customerid =:customerid and o.flowunid=:flowunid";
BizObject cpt = cptm.createQuery(sSql).setParameter("customerid", customerid).setParameter("flowunid", flowunid).getSingleResult(false);
certid=cpt.getAttribute("certid").getString();
mobile=cpt.getAttribute("mobile").getString();
address=cpt.getAttribute("nativeplace").getString();
}
ASObjectModel doTemp = new ASObjectModel(sTempletNo);
String a="false";//融资租赁
String b="false";//保理
String c="false";//直租
String d="false";//回租
//查询contract_id
String sContractId = "";//合同表的主键
String sProjId="";//项目表主键
String sProductId="";
String LeaseType="";
BizObjectManager bomcl = JBOFactory.getBizObjectManager(FLOW_BUSSINESS_OBJECT.CLASS_NAME);
String sSql = "select o.proj_id,o.contract_id,o.productId FROM o where o.flow_unid =:flow_unid";
BizObject bocl = bomcl.createQuery(sSql).setParameter("flow_unid", flowunid).getSingleResult(false);
if (bocl != null) {
sContractId= bocl.getAttribute("contract_id").getString();
sProjId=bocl.getAttribute("proj_id").getString();
sProductId=bocl.getAttribute("productId").getString();
}
/* if (sProductId.equals("0005")){
LeaseType="DoubleLease";
}else if(sProductId.equals("0001")){
LeaseType="NormalLease";
}else if(sProductId.equals("004")){
LeaseType="CarBusiness";
}else{
LeaseType="NoBusiness";
} */
doTemp.setHtmlEvent("ONECLASSIFY","onchange","initTwoClass");
doTemp.setHtmlEvent("TWOCLASSIFY","onchange","initThreeClass");
doTemp.setHtmlEvent("THREECLASSIFY","onchange","initFourClass");
doTemp.setHtmlEvent("FOURCLASSIFY","onchange","loadFileTemplateClasses");
CurPage.getCurComp().setAttribute("RightType", null);
//doTemp.setColTips("", "测试");
ASObjectWindow dwTemp = new ASObjectWindow(CurPage, doTemp,request);
dwTemp.Style = "2";//freeform
//dwTemp.ReadOnly = "-2";//只读模式
dwTemp.genHTMLObjectWindow(CurPage.getParameter("id"));
CurPage.getCurComp().setAttribute("RightType", RightType);
//isShowButton=false;
String compClientID = request.getParameter("CompClientID");
String sparm="";
dwTemp.replaceColumn("LBContractTemplateList", "<iframe id=\"LBContractTemplateList\" type='iframe' name=\"LBContractTemplateList\" width=\"100%\" height=\"260\" frameborder=\"0\" src=\""+sWebRootPath+"/Tenwa/Lease/Flow/Comm/LBContractTemplate/LBContractTemplateList.jsp?FlowUnid="+flowunid+"&TaskNo="+taskno+"&IsHistory="+ishistory+"&NodeNo="+nodeNo+"&TempletNo=LBContractTemplateList"+"&CompClientID="+sCompClientID+"\"></iframe>", CurPage.getObjectWindowOutput());
String sButtons[][] = null;
if((null!=RightType&&RightType.equals("ReadOnly"))||(null!=ishistory&&ishistory.equals("true"))){
dwTemp.ReadOnly = "-2";
sButtons=new String[][]{
{phaseno.equals("0010")?"true":"false","","Button","生成合同","生成合同","createContractByTemplate()","","","","btn_icon_up",""}
};
}else{
sButtons=new String[][] {
{phaseno.equals("0010")?"true":"false","","Button","生成合同","生成合同","createContractByTemplate()","","","","btn_icon_up",""}
};
}
dwTemp.replaceColumn("contracttemplate", "<div id=\"filetemplatemodel\" style=\"heigth:100%,width:100px\">请稍等。。。。。。</div>", CurPage.getObjectWindowOutput());
%><%@ include file="/Frame/resources/include/ui/include_info.jspf"%>
<script type="text/javascript">
var docno = "";
$(document).ready(function(){
var RightType="<%=RightType%>";
var phaseno="<%=phaseno%>"
/* if(RightType=="ReadOnly"){
$('#A_Group_0010').css('display','none');
$('#A_Group_0020').css('display','none');
} */
if(phaseno=="0015"){
$('#ButtonTR').css('display','block');
$('#A_Group_0010').css('display','none');
$('#A_Group_0020').css('display','none');
}
var sReturn = RunJavaMethodSqlca("com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil","getContractClass","leasform="+"<%=leasform%>"+",isNetCar="+"<%=CurPage.getParameter("isNetCar")%>");
var jsonData=eval("("+sReturn+")");
initFileTemplate(eval("("+jsonData[0].fileTemplate+")"));
// initOneClass();
});
//加载一级分类选项
function initOneClass(status){
var oneClass=getItemValue(0,0,"ONECLASSIFY");
var sql="SELECT itemno,itemname FROM code_library WHERE codeno='DocList' AND itemno LIKE '005%' AND LENGTH(itemno)=6 ";
initSelectOption(sql,"itemname","itemno","ONECLASSIFY");
if(status=="edit"){
setItemValue(0,0,"ONECLASSIFY",oneClass);
}else{
setItemValue(0,0,"ONECLASSIFY","");
}
initTwoClass(status);
}
//加载二级分类选项
function initTwoClass(status){
var oneClass=getItemValue(0,0,"ONECLASSIFY");
if(oneClass==""){oneClass=" ";}
var twoClass=getItemValue(0,0,"TWOCLASSIFY");
var sql="SELECT itemno,itemname FROM code_library WHERE codeno='ProductContractTemplate' AND LENGTH(itemno)=3 and attribute1='"+oneClass+"'";
initSelectOption(sql,"itemname","itemno","TWOCLASSIFY");
if(status=="edit"){
setItemValue(0,0,"TWOCLASSIFY",twoClass);
}else{
setItemValue(0,0,"TWOCLASSIFY","");
}
initThreeClass(status);
}
//加载三级分类选项
function initThreeClass(status){
var twoClass=getItemValue(0,0,"TWOCLASSIFY");
if(twoClass==""){twoClass=" ";}
var threeClass=getItemValue(0,0,"THREECLASSIFY");
var sql="SELECT itemno,itemname FROM code_library WHERE codeno='ProductContractTemplate' AND itemno LIKE '"+twoClass+"%' AND LENGTH(itemno)=6";
initSelectOption(sql,"itemname","itemno","THREECLASSIFY");
if(status=="edit"){
setItemValue(0,0,"THREECLASSIFY",threeClass);
}else{
setItemValue(0,0,"THREECLASSIFY","");
}
initFourClass(status);
}
//加载四级分类选项
function initFourClass(status){
var threeClass=getItemValue(0,0,"THREECLASSIFY");
if(threeClass==""){threeClass=" ";}
var fourClass=getItemValue(0,0,"FOURCLASSIFY");
var sql="select itemno,itemname from code_library where codeno='ProductContractTemplate' and itemno like '"+threeClass+"%' AND LENGTH(itemno)=9";
initSelectOption(sql,"itemname","itemno","FOURCLASSIFY");
if(status=="edit"){
setItemValue(0,0,"FOURCLASSIFY",fourClass);
}else{
setItemValue(0,0,"FOURCLASSIFY","");
}
loadFileTemplateClasses(4);
}
function loadFileTemplateClasses(cindex){
cindex=4;
var templateType=['ONECLASSIFY','TWOCLASSIFY','THREECLASSIFY','FOURCLASSIFY'];
var searchCondtion=[];
searchCondtion.push("'DOCTYPE':'005'");
var tclass="";
for(var i=0;i<cindex;i++){
tclass=templateType[i];
var cvalue=jQuery("#"+tclass+" option:selected").val();
searchCondtion.push("'"+tclass.toLowerCase()+"':'"+cvalue+"'");
}
var param="{"+searchCondtion.join("@")+"}";
var sparam="templateCalss="+param;
var sReturn = RunJavaMethodSqlca("com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil","getTemplateClass",sparam);
var jsonData=eval("("+sReturn+")");
initFileTemplate(eval("("+jsonData[0].fileTemplate+")"));
}
function initFileTemplate(fileTemplate){
var cnumber=4;
$("#filetemplatemodel").html("");
$("#filetemplatemodel").append("<table>");
for(var i=0;i<fileTemplate.length;i++){
if(i%cnumber==0)$("#filetemplatemodel").append("<tr>");
$("#filetemplatemodel").append("<td width='200px'><input type=\"checkbox\" name=\"fileTemplate\" value=\""+fileTemplate[i].value+"\">"+fileTemplate[i].text+"</input></td>");
if((i+1)%cnumber==0){$("#filetemplatemodel").append("</tr>");}
else{$("#filetemplatemodel").append("</tr>");}
}
$("#filetemplatemodel").append("</table>");
}
function createContractByTemplate(){
var checkbox=$("#filetemplatemodel").html()||"";
if(checkbox==""){alert("请选择合同模板下面的分类,或分类下面没有模板");return false;}
var tempids="";
$('input[name="fileTemplate"]:checked').each(function(){
if(tempids.length>0){
tempids+="&";
}
tempids += $(this).attr('value');
});
if(tempids.length<=0){
alert("请勾选合同模板!");
return;
}
var message = RunJavaMethodTrans("com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil","CheckCar","contractId="+"<%=sContractId%>"+",templateIds="+tempids+",flowunid="+"<%=flowunid%>");
if(""!=message){
if("01"=="<%=customertype%>"){
if(message.indexOf("请先删除后再生成")>0){
alert("合同已生成,无法再次生成!");
location.reload();
return;
}
}
alert(message);
location.reload();
return;
}
var param={};
var tempParam={};
var sparam="";
// param["templateNo"]="0010";
tempParam["CurUserId"]="<%=CurUser.getUserID()%>";
tempParam["CurOrgId"]="<%=CurUser.getOrgID()%>";
tempParam["OBJECTTYPE"]="<%=CurPage.getParameter("FLOW_NO")%>";
tempParam["FLOW_UNID"]="<%=flowunid%>";
tempParam["CONTRACT_ID"]="<%=sContractId%>";
tempParam["PROJ_ID"]="<%=sProjId%>";
tempParam["contractNo"]="<%=contractNo%>";
tempParam["certid"]="<%=certid%>";
tempParam["mobile"]="<%=mobile%>";
tempParam["address"]="<%=address%>";
tempParam["fileSavePath"]="<%=CurConfig.getConfigure("FileSavePath")%>";
param["templateIds"]=tempids;//选择的模板ID
param["templateParam"]=JSON.stringify(tempParam).replace(/,/g,"@");//生成模板的参数据
for(var key in param){
if(sparam.length>0){sparam+=",";}
sparam+=key+"="+param[key];
}
var sReturn0 = RunJavaMethodTrans("com.tenwa.app.baseFileTemplate.handle.FileTemplateUtil","createContractTemplate",sparam);
if(sReturn0.length>2){
alert(sReturn0);
}else{
RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","wordToPdf","FlowUnid=<%=flowunid%>,flagType=word");
if("01"=="<%=customertype%>"&&"1"!="<%=CurPage.getParameter("isNetCar")%>"){
var falg = RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","compnySignIng","FlowUnid=<%=flowunid%>,flagType=word,ProjectId=<%=projectId%>");
if("success"== falg ){
alert("生成成功");
}else{
RunJavaMethodTrans("com.tenwa.channelportal.action.ContractSignAction","companyUpdateDocContractStatus","FlowUnid=<%=flowunid%>"+",ProjectId=<%=projectId%>");
alert("生成失败!!!");
}
}else{
alert("生成成功");
}
}
reloadSelf();
}
function downloadFile(id){
if(!frames["downloadTemplate"]) $("<iframe name='downloadTemplate' style='display:none;'></iframe>").appendTo("body");
window.open(sWebRootPath+"/servlet/view/docDownloadServlet?CompClientID=<%=sCompClientID%>&sqlString=save@"+id, "downloadTemplate");
}
Array.prototype.contains = function ( needle ) {
for (i in this) {
if (this[i] == needle) return true;
}
return false;
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf"%>