Modify代码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/csdn_cSharp/article/details/83027581
public JsonResult ModifyDataSave()
       {
 
           var cc_Technology = "TechnologyCarbonCopy";//技术主管部门CC
           var cc_Finance = "FinanceCarbonCopy";//财务部CC
           var cc_Purchase = "PurchaseCarbonCopy";//采购部CC     
           var cc_Factory = "FactoryCarbonCopy";
 
           var cc_Review1 = string.Empty;
           var cc_Review2 = string.Empty;
           var cc_Review3 = string.Empty;
           var cc_Review4 = string.Empty;
           var stepId = 0;
           var selectedRole = 0;
           var financeApproval = new FixedAssetInspection1();
           var tenderApproval = new FixedAssetInspection2();
           var factoryApproval = new FixedAssetInspection3();
           #region 原获取数据方式
           //获取前台表单提交的数据
           var formData = JsonConvert.DeserializeObject<System.Collections.Hashtable>(Request["jsonStr"]);
 
           //获取审批步骤类型ID (0:技术主管/财务审核前, 1:技术主管/财务, 2:采购审核前, 3:采购, 4:进口部前, 5:进口部门, 6:进口部门审批之后)
 
           if (formData["Step"] != null)
           {
               stepId = JsonConvert.DeserializeObject<int>(formData["Step"].ToString());
           }
 
           //获取第一次修改时用户选择的审批角色
 
           if (formData["SelectedRole"] != null)
           {
               selectedRole = JsonConvert.DeserializeObject<int>(formData["SelectedRole"].ToString());
           }
 
           //获取 技术主管/财务 填写内容
 
           if (formData["FinanceApproval"] != null)
           {
               financeApproval = JsonConvert.DeserializeObject<FixedAssetInspection1>(formData["FinanceApproval"].ToString());
           }
 
           //获取 采购员 填写内容
 
           if (formData["TenderApproval"] != null)
           {
               tenderApproval = JsonConvert.DeserializeObject<FixedAssetInspection2>(formData["TenderApproval"].ToString());
           }
 
           //获取 归口部门/厂务部门 填写内容
 
           if (formData["FactoryApproval"] != null)
           {
               factoryApproval = JsonConvert.DeserializeObject<FixedAssetInspection3>(formData["FactoryApproval"].ToString());
           }
           #endregion
 
           #region 新获取数据方式
           //var jsonStr = Request["jsonStr"];
 
           //if (!string.IsNullOrWhiteSpace(Request["Step"]))
           //{
           //    int.TryParse(Request["Step"], out stepId);
           //}
 
           //if (!string.IsNullOrWhiteSpace(Request["SelectedRole"]))
           //{
           //    int.TryParse(Request["SelectedRole"], out selectedRole);
 
           //}
           //if (!string.IsNullOrWhiteSpace(Request["FinanceApproval"]))
           //{
           //    financeApproval=JsonConvert.DeserializeObject<FixedAssetInspection1>(Request["FinanceApproval"]);
           //}
           //if (!string.IsNullOrWhiteSpace(Request["TenderApproval"]))
           //{
           //    tenderApproval = JsonConvert.DeserializeObject<FixedAssetInspection2>(Request["TenderApproval"]);
           //}
           //if (!string.IsNullOrWhiteSpace(Request["FactoryApproval"]))
           //{
           //    factoryApproval = JsonConvert.DeserializeObject<FixedAssetInspection3>(Request["FactoryApproval"]);
           //}
           #endregion
 
 
 
           ///附件上传
 
           var basePath = "/Uploads/FixedAssetReview/";
           var path = Server.MapPath(basePath);
           if (Request.Files.Count > 0)//有上传文件
           {
               //指定路径目录不存在时,创建目录
               if (!Directory.Exists(path))
               {
                   Directory.CreateDirectory(path);
               }
           }
 
           switch (stepId)
           {
               case 1:
                   {
                       var file1 = Request.Files["Annex_Technology"];//技术主管部门附件
                       var file2 = Request.Files["Annex_Finance"];//财务部附件
                       var file3 = Request.Files["Annex_Purchase"];//采购部门附件
 
                       if (db.FixedAssetInspection1.Where(p => p.DocumentId == financeApproval.DocumentId).Count() == 0)
                       {
                           db.FixedAssetInspection1.Add(financeApproval);
                       }
                       else
                       {
                           //在数据库中查询原有的记录
                           var temp = db.FixedAssetInspection1.Where(p => p.DocumentId == financeApproval.DocumentId).FirstOrDefault();
                           if (selectedRole == 1)
                           {
 
                               temp.AuditOpinion_Technology = financeApproval.AuditOpinion_Technology;
                               temp.CarbonCopy_Technology = financeApproval.CarbonCopy_Technology;
                               temp.Remark_Technology = financeApproval.Remark_Technology;
 
                               if (file1 != null && file1.ContentLength > 0)
                               {
                                   var shortName = Guid.NewGuid().ToString() + Path.GetExtension(file1.FileName);
                                   var filePath = Path.Combine(path, shortName);
                                   file1.SaveAs(filePath);
                                   temp.Annex_Technology = Path.Combine(basePath, shortName);
                               }
 
                               db.Entry(temp).State = EntityState.Modified;
                               db.OAApprovers.RemoveRange(db.OAApprovers.Where(p => p.DocumentId == financeApproval.DocumentId && p.ApproverKey == cc_Technology));
                           }
                           else if (selectedRole == 2)
                           {
                               temp.AuditOpinion_Finance = financeApproval.AuditOpinion_Finance;
                               temp.CarbonCopy_Finance = financeApproval.CarbonCopy_Finance;
                               temp.Remark_Finance = financeApproval.Remark_Finance;
                               temp.CostAmountTypeCode = financeApproval.CostAmountTypeCode;
                               temp.CostAmountTypeName = financeApproval.CostAmountTypeName;
 
                               if (file2 != null && file2.ContentLength > 0)
                               {
                                   var shortName = Guid.NewGuid().ToString() + Path.GetExtension(file2.FileName);
                                   var filePath = Path.Combine(path, shortName);
                                   file2.SaveAs(filePath);
                                   temp.Annex_Finance = Path.Combine(basePath, shortName);
                               }
 
                               db.Entry(temp).State = EntityState.Modified;
                               db.OAApprovers.RemoveRange(db.OAApprovers.Where(p => p.DocumentId == financeApproval.DocumentId && p.ApproverKey == cc_Finance));
                           }
 
                       }
 
                       if (db.FixedAssetInspection2.Where(p => p.DocumentId == tenderApproval.DocumentId).Count() == 0)
                       {
                           db.FixedAssetInspection2.Add(tenderApproval);
                       }
                       else
                       {
                           //在数据库中查询原有的记录
                           var temp = db.FixedAssetInspection2.Where(p => p.DocumentId == tenderApproval.DocumentId).FirstOrDefault();
 
                           if (selectedRole == 3)
                           {
                               temp.AssetRangeName = tenderApproval.AssetRangeName;
                               temp.AssetRangeCode = tenderApproval.AssetRangeCode;
                               temp.Remark_Purchase = tenderApproval.Remark_Purchase;
                               temp.AuditOpinion_Purchase = tenderApproval.AuditOpinion_Purchase;
                               temp.CarbonCopy_Purchase = tenderApproval.CarbonCopy_Purchase;
 
                               if (file3 != null && file3.ContentLength > 0)
                               {
                                   var shortName = Guid.NewGuid().ToString() + Path.GetExtension(file3.FileName);
                                   var filePath = Path.Combine(path, shortName);
                                   file3.SaveAs(filePath);
                                   temp.Annex_Purchase = Path.Combine(basePath, shortName);
                               }
 
                               db.Entry(temp).State = EntityState.Modified;
                               db.OAApprovers.RemoveRange(db.OAApprovers.Where(p => p.DocumentId == tenderApproval.DocumentId && p.ApproverKey == cc_Purchase));
                           }
                       }
 
                       //技术主管部门CC
                       if (!string.IsNullOrEmpty(financeApproval.CarbonCopy_Technology) && selectedRole == 1)
                       {
                           var oAApprover = new OAApprover();
                           oAApprover.DocumentId = financeApproval.DocumentId;
                           oAApprover.ApproverKey = cc_Technology;
                           oAApprover.ApproverValue = financeApproval.CarbonCopy_Technology;
                           db.OAApprovers.Add(oAApprover);
 
                           var cc_Array = financeApproval.CarbonCopy_Technology.Split(new char[] { ';' });
 
                           cc_Review1 = string.Empty;
                           foreach (string str in cc_Array)
                           {
                               if (!string.IsNullOrWhiteSpace(str))
                               {
                                   cc_Review1 = cc_Review1 + "GWKF\\\\" + str + ";";
                               }
                           }
                       }
 
                       //财务部CC
                       if (!string.IsNullOrEmpty(financeApproval.CarbonCopy_Finance) && selectedRole == 2)
                       {
                           var oAApprover = new OAApprover();
                           oAApprover.DocumentId = financeApproval.DocumentId;
                           oAApprover.ApproverKey = cc_Finance;
                           oAApprover.ApproverValue = financeApproval.CarbonCopy_Finance;
                           db.OAApprovers.Add(oAApprover);
 
                           var cc_Array = financeApproval.CarbonCopy_Finance.Split(new char[] { ';' });
 
                           cc_Review2 = string.Empty;
                           foreach (string str in cc_Array)
                           {
                               if (!string.IsNullOrWhiteSpace(str))
                               {
                                   cc_Review2 = cc_Review2 + "GWKF\\\\" + str + ";";
                               }
                           }
                       }
 
                       //采购部CC
                       if (!string.IsNullOrEmpty(tenderApproval.CarbonCopy_Purchase) && selectedRole == 3)
                       {
                           var oAApprover = new OAApprover();
                           oAApprover.DocumentId = financeApproval.DocumentId;
                           oAApprover.ApproverKey = cc_Purchase;
                           oAApprover.ApproverValue = tenderApproval.CarbonCopy_Purchase;
                           db.OAApprovers.Add(oAApprover);
 
                           var cc_Array = tenderApproval.CarbonCopy_Purchase.Split(new char[] { ';' });
 
                           cc_Review3 = string.Empty;
                           foreach (string str in cc_Array)
                           {
                               if (!string.IsNullOrWhiteSpace(str))
                               {
                                   cc_Review3 = cc_Review3 + "GWKF\\\\" + str + ";";
                               }
                           }
                       }
                       ////进出口部门
                       if (factoryApproval != null && selectedRole == 4)
                       {
                           factoryApproval.DocumentId = financeApproval.DocumentId;
                           db.FixedAssetInspection3.Add(factoryApproval);
                       }
 
 
 
 
                   }
                   break;
 
               case 2:
                   {
 
 
                       var file4 = Request.Files["Annex_Factory"];
                       if (file4 != null && file4.ContentLength > 0)
                       {
                           var shortName = Guid.NewGuid().ToString() + Path.GetExtension(file4.FileName);
                           var filePath = Path.Combine(path, shortName);
                           file4.SaveAs(filePath);
                           factoryApproval.Annex_Factory = Path.Combine(basePath, shortName);
                       }
 
                       if (factoryApproval.FixedAssetInspection3Id == 0)
                       {
                           db.FixedAssetInspection3.Add(factoryApproval);
                       }
                       else
                       {
                           db.Entry(factoryApproval).State = EntityState.Modified;
                           db.OAApprovers.RemoveRange(db.OAApprovers.Where(p => p.DocumentId == factoryApproval.DocumentId && p.ApproverKey == cc_Factory));
                       }
 
                       if (!string.IsNullOrEmpty(factoryApproval.CarbonCopy_Factory))
                       {
                           var oAApprover = new OAApprover();
                           oAApprover.DocumentId = factoryApproval.DocumentId;
                           oAApprover.ApproverKey = cc_Factory;
                           oAApprover.ApproverValue = factoryApproval.CarbonCopy_Factory;
                           db.OAApprovers.Add(oAApprover);
 
                           var cc_Array = factoryApproval.CarbonCopy_Factory.Split(new char[] { ';' });
 
                           cc_Review4 = string.Empty;
                           foreach (string str in cc_Array)
                           {
                               if (!string.IsNullOrWhiteSpace(str))
                               {
                                   cc_Review4 = cc_Review4 + "GWKF\\\\" + str + ";";
                               }
                           }
                       }
                   }
                   break;
 
               default:
                   { }
                   break;
           }
 
 
           //内管分组码
 
           var innerTubeBlockCode = string.Empty;
           #region 原获取数据方式
           //if (formData["InnerTubeBlockCode"] != null)
           //{
           //    innerTubeBlockCode = formData["InnerTubeBlockCode"].ToString();
 
           //    var documentId = 0;
 
           //    documentId = financeApproval.DocumentId;
 
           //    if (documentId == 0)
           //    {
           //        documentId = tenderApproval.DocumentId;
           //    }
 
           //    if (documentId == 0)
           //    {
           //        documentId = factoryApproval.DocumentId;
           //    }
 
           //    var fixedAsset = db.FixedAssets.Where(p => p.DocumentId == documentId).FirstOrDefault();
 
           //    if (fixedAsset != null)
           //    {
           //        fixedAsset.InnerTubeBlockCode = innerTubeBlockCode;
           //    }
           //}
           #endregion
 
           #region 新获取数据方式
           if (Request["InnerTubeBlockCode"] != null)
           {
               innerTubeBlockCode = Request["InnerTubeBlockCode"];
 
               var documentId = 0;
 
               documentId = financeApproval.DocumentId;
 
               if (documentId == 0)
               {
                   documentId = tenderApproval.DocumentId;
               }
 
               if (documentId == 0)
               {
                   documentId = factoryApproval.DocumentId;
               }
 
               var fixedAsset = db.FixedAssets.Where(p => p.DocumentId == documentId).FirstOrDefault();
 
               if (fixedAsset != null)
               {
                   fixedAsset.InnerTubeBlockCode = innerTubeBlockCode;
               }
           }
           #endregion
 
           var count = db.SaveChanges();
 
 
           //触发OA审批流程
 
           var userID = string.Empty;
           var userName = string.Empty;
           var wFListItemID = 0;
           var wFWorkListAuditingID = 0;
           var actionName = string.Empty;
           var OAMessage = "OK/同意! ";///审批意见
           var OAFlowID = 0;///FlowID
 
           #region 原获取数据方式
           //if (formData["UserID"] != null)
           //{
           //    userID = formData["UserID"].ToString();
           //}
 
          
           //if (formData["UserName"] != null)
           //{
           //    userName = formData["UserName"].ToString();
           //}
 
          
           //if (formData["WFListItemID"] != null)
           //{
           //    int.TryParse(formData["WFListItemID"].ToString(), out wFListItemID);
           //}
 
           
           //if (formData["WFWorkListAuditingID"] != null)
           //{
           //    int.TryParse(formData["WFWorkListAuditingID"].ToString(), out wFWorkListAuditingID);
           //}
 
           
           //if (formData["ActionName"] != null)
           //{
           //    actionName = formData["ActionName"].ToString();
           //}
           
           //if (formData["OAMessage"] != null)
           //{
           //    OAMessage = formData["OAMessage"].ToString();
           //}
          
           //if (formData["OAFlowID"] != null)
           //{
 
           //    int.TryParse(formData["OAFlowID"].ToString(), out OAFlowID);
 
           //   // OAFlowID = Convert.ToInt32(formData["OAFlowID"]);
           //}
           #endregion
 
           #region 新获取数据方式
           if (Request["UserID"] != null)
           {
               userID = Request["UserID"].ToString();
           }
 
 
           if (Request["UserName"] != null)
           {
               userName = Request["UserName"].ToString();
           }
 
 
           if (Request["WFListItemID"] != null)
           {
               int.TryParse(Request["WFListItemID"].ToString(), out wFListItemID);
           }
 
 
           if (Request["WFWorkListAuditingID"] != null)
           {
               int.TryParse(Request["WFWorkListAuditingID"].ToString(), out wFWorkListAuditingID);
           }
 
 
           if (Request["ActionName"] != null)
           {
               actionName = Request["ActionName"].ToString();
           }
 
           if (Request["OAMessage"] != null)
           {
               OAMessage = Request["OAMessage"].ToString();
           }
 
           if (Request["OAFlowID"] != null)
           {
 
               int.TryParse(Request["OAFlowID"].ToString(), out OAFlowID);
 
               // OAFlowID = Convert.ToInt32(formData["OAFlowID"]);
           }
           #endregion
 
           var oAGuid = db.Documents.Find(financeApproval.DocumentId).OAGuid;
 
           var msg = "";
 
           //审批动作
           //var working = new SingleViewModel()
           //{
           //    OaGuid = oAGuid,//工作流
           //    ActionName = actionName//步骤
           //};
 
           ////查找 此工作流的该步骤 是否已存在 正在处理的审批动作
           //var work = WorkingList.Where(p => p.OaGuid == working.OaGuid && p.ActionName == working.ActionName).FirstOrDefault();
           //if (work != null)//有正在处理的审批动作
           //{
           //    msg = "此任务正在被其他人审批中,请稍后再试!";
 
           //    //WorkingList.Remove(work);
 
           //    return new EmptyResult();
           //}
           //else//没有正在处理的审批动作
           //{
           //    WorkingList.Add(working);//将审批动作添加到list
           //}
 
           var sb = new StringBuilder();
           sb.Append("");
           if (count > 0)
           {
               switch (stepId)
               {
                   case 1:
                       {
                           sb.Clear();
                           sb.Append("{\"ActivityEditColumn\":[");
                           //sb.Append("{ ");
 
                           var hasKeyValue = false;
 
                           //财务部预算审核
                           if (!string.IsNullOrEmpty(financeApproval.CostAmountTypeCode.ToString()))
                           {
                               if (hasKeyValue == true)
                               {
                                   sb.Append(",");
                               }
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"APAFinBudget\",");
                               sb.Append("\"ColumnValue\":\"" + financeApproval.CostAmountTypeCode + "\"");
                               sb.Append("}");
                               hasKeyValue = true;
                           }
 
                           //国内采购,国外采购
                           if (!string.IsNullOrEmpty(tenderApproval.AssetRangeCode.ToString()))
                           {
                               if (hasKeyValue == true)
                               {
                                   sb.Append(",");
                               }
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"APAAssetClassification\",");
                               sb.Append("\"ColumnValue\":\"" + tenderApproval.AssetRangeCode + "\"");
                               sb.Append("}");
                               hasKeyValue = true;
                           }
 
                           //sb.Append("}");
                           //if (!string.IsNullOrEmpty(tenderApproval.BaseCurrencyTotalAmount.ToString()))///根据后面预算财务总金额
                           //{
                           //    sb.Append(",");
                           //    sb.Append("{ ");
                           //    sb.Append("\"ColumnName\":\"TotalAmountRMB\",");
                           //    sb.Append("\"ColumnValue\":\"" + tenderApproval.BaseCurrencyTotalAmount + "\"");
                           //    sb.Append("}");
                           //}
                           if (!string.IsNullOrEmpty(cc_Review1))
                           {
                               if (hasKeyValue == true)
                               {
                                   sb.Append(",");
                               }
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"CC\",");
                               sb.Append("\"ColumnValue\":\"" + cc_Review1 + "\"");
                               sb.Append("}");
                               hasKeyValue = true;
                           }
 
                           if (!string.IsNullOrEmpty(cc_Review2))
                           {
                               if (hasKeyValue == true)
                               {
                                   sb.Append(",");
                               }
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"CC2\",");
                               sb.Append("\"ColumnValue\":\"" + cc_Review2 + "\"");
                               sb.Append("}");
                               hasKeyValue = true;
                           }
 
                           if (!string.IsNullOrEmpty(cc_Review3))
                           {
                               if (hasKeyValue == true)
                               {
                                   sb.Append(",");
                               }
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"CC3\",");
                               sb.Append("\"ColumnValue\":\"" + cc_Review3 + "\"");
                               sb.Append("}");
                               hasKeyValue = true;
                           }
 
                           sb.Append("]}");
                       }
                       break;
 
                   case 2:
                       {
                           if (!string.IsNullOrEmpty(cc_Review4))
                           {
                               sb.Clear();
                               sb.Append("{\"ActivityEditColumn\":[");
                               sb.Append("{ ");
                               sb.Append("\"ColumnName\":\"CC4\",");
                               sb.Append("\"ColumnValue\":\"" + cc_Review4 + "\"");
                               sb.Append("}");
                               sb.Append("]}");
                           }
                       }
                       break;
 
                   default:
                       { }
                       break;
               }
 
 
           }
           APILog aPILog = new APILog
           {
               InterfaceSource = "Purchase",
               Url = "/FixedAsset/ModifyDataSave",
               MethodName = "FixedAssetModifyDataSave",
               Caller = userName,
               CallTime = DateTime.Now,
               Remark = "固定资产OA同意或拒绝触发OA流程"
           };
           try
           {
 
               var aPILogDetail1 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sOAGuid",
                   Value = oAGuid
               };
               db.APILogDetails.Add(aPILogDetail1);
 
               var aPILogDetail2 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sFlowTypeId",
                   Value = ((int)FlowTypeEnum.FixedAsset).ToString()
               };
               db.APILogDetails.Add(aPILogDetail2);
 
               var aPILogDetail3 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sUserId",
                   Value = userID
               };
               db.APILogDetails.Add(aPILogDetail3);
 
               var aPILogDetail4 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sUserName",
                   Value = userName
               };
               db.APILogDetails.Add(aPILogDetail4);
 
               var aPILogDetail5 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sWFListItemID",
                   Value = wFListItemID.ToString()
               };
               db.APILogDetails.Add(aPILogDetail5);
 
               var aPILogDetail6 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sWFWorkListAuditingID",
                   Value = wFWorkListAuditingID.ToString()
               };
               db.APILogDetails.Add(aPILogDetail6);
 
               var aPILogDetail7 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sOAMessage",
                   Value = OAMessage
               };
               db.APILogDetails.Add(aPILogDetail7);
 
               var aPILogDetail8 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sActionName",
                   Value = actionName
               };
               db.APILogDetails.Add(aPILogDetail8);
               var aPILogDetail9 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = false,//入参
                   Key = "sUpdateJson",
                   Value = sb.ToString()
               };
               db.APILogDetails.Add(aPILogDetail9);
               msg = new Common().UpdateOAWorkListAuditing(oAGuid, userID, userName, wFListItemID, wFWorkListAuditingID, OAMessage, actionName, sb.ToString(), (int)FlowTypeEnum.FixedAsset);
           }
           catch (Exception ex)
           {
               msg = "OA Exception:" + ex.Message;
               var aPILogDetail11 = new APILogDetail
               {
                   APILogId = aPILog.APILogId,
                   ParameterDirection = true,//出参
                   Key = "Exception",
                   Value = ex.Message
               };
               db.APILogDetails.Add(aPILogDetail11);
           }
           finally
           {
               aPILog.EndCallTime = DateTime.Now;
               db.APILogs.Add(aPILog);
               db.SaveChanges();
           }
 
           if (string.IsNullOrEmpty(msg))
           {
 
               //OA折腾,改回原来调接口API
 
               //Thread t2 = new Thread(GetFlows);
               //t2.Start(OAFlowID + "#" + working.OaGuid + "#" + working.ActionName);
               ////bool result = false;
               ////if (OAFlowID > 0 && !string.IsNullOrWhiteSpace(oAGuid))
               ////    result = new Common().GetFlowsInfo(oAGuid, OAFlowID);
               ////ExecuteThread = false;
           }
           //else
           //{
           //    WorkingList.Remove(working);
           //}
           //return new EmptyResult();
           return Json(new { Msg = msg }, JsonRequestBehavior.AllowGet);
       }



HTML 代码:

@{
    ViewBag.Title = "固定资产";
    Layout = null;
}
<style>
    select {
        max-width: 155px !important;
        width: 155px !important;
    }
</style>

<link href="~/Content/jquery.autocomplete.css" rel="stylesheet" />
<link rel="shortcut icon" type="image/x-icon" href="~/Images/favicon.ico" />
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />

<script src="~/Scripts/moment.min.js"></script>
<script src="~/Scripts/knockout-3.4.2.js"></script>
<script src="~/Scripts/jquery-1.12.4.min.js"></script>
<script src="~/Scripts/pagination.js"></script>

<script src="~/Scripts/json2.min.js"></script>
<script src="~/Scripts/jquery.autocomplete.js"></script>
<script src="~/Scripts/form.js"></script>
<script src="~/Plugin/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
    body {
        overflow-x: hidden;
    }

    * {
        padding: 0;
        margin: 0;
    }

    .table_contanct tr {
        text-align: center;
    }

    .ulContact {
        list-style: none;
        width: 96%;
        overflow: hidden;
        line-height: 30px;
        margin: 20px auto 5px auto !important;
        padding: 0;
        background-color: #fff;
        margin-top: 10px;
        overflow: hidden;
    }

        .ulContact li {
            float: left;
        }

    .table_contanct {
        width: 96%;
        margin: 0 auto 10px auto !important;
        border-collapse: collapse;
        background-color: #fff;
        margin-bottom: 10px;
        table-layout: fixed;
    }

        .table_contanct td, .table_contanct th {
            color: #000;
            border: 1px solid #ddd;
            box-sizing: border-box;
            padding: 0 10px !important;
            line-height: 35px;
            /*height: 35px;*/
        }

        .table_contanct th {
            background-color: #f7f7f7;
            color: #000;
        }

        .table_contanct .title {
            width: 10% !important;
            background-color: #f7f7f7;
        }

        .table_contanct .tContent {
            width: 23.3333% !important;
        }

    .shrinkBar {
        line-height: 40px;
        box-sizing: border-box;
        background-color: #f6f6f6;
        color: #999;
        margin: 5px auto 0 auto !important;
        border: 1px solid #ddd;
        overflow: hidden;
        cursor: pointer;
    }

    .icon_down {
        width: 20px;
        margin-right: 6px;
    }

    .icon_up {
        height: 16px;
        margin-right: 6px;
    }

    .contannier_u {
        padding-left: 10px;
        padding-right: 10px;
        box-sizing: border-box;
        width: 96%;
        overflow: hidden;
    }
</style>


<div id="PageHeight">
    <!--表_申请界面-->
    <div style="font-family:'微软雅黑';overflow:auto;margin: 0px auto;">
        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('demand')"*@ onclick="SearchExpand('demand');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!IsDemandDisplay()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:IsDemandDisplay()" />
                需求内容 @*<span name="DemandContent">需求内容</span>*@
            </div>
            <table class="table_contanct" style="width:100%;cursor:auto;" data-bind="visible:IsDemandDisplay(),with:FixedAssets">
                <tbody>
                    <tr>
                        <td class="title" name="AssetRuleName">资产一级分类</td>
                        <td class="content" data-bind="text:AssetRuleName"></td>
                        <td class="title" name="AssetGroupName">资产二级分类</td>
                        <td class="content" data-bind="text:AssetGroupName"></td>
                        <td class="title" name="AssetClassName">资产三级分类</td>
                        <td class="content" data-bind="text:AssetClassName"></td>
                    </tr>

                    <tr>
                        <td class="title" name="AssetTypeName">资产四级分类</td>
                        <td class="content" data-bind="text:AssetTypeName"></td>
                        <td class="title" name="AssetModel">资产型号</td>
                        <td class="content" data-bind="text:AssetModelName"></td>
                        <td class="title" name="AssetClassDesc">其他型号描述</td>
                        <td class="content" data-bind="text:AssetClassDesc"></td>
                    <tr>

                        <td class="title" name="FactoryCode">工厂</td>
                        <td class="content" data-bind="text:FactoryCode"></td>

                        <td class="title" name="RequiredQuantity">需求数量</td>
                        <td class="content" data-bind="text:Quantity"></td>

                        <td class="title" name="EstimatedUnitPrice">资产单价</td>
                        <td class="content" data-bind="text:EstimatedUnitPrice"></td>



                    </tr>
                    <tr>
                        <td class="title" name="BudgetAmount">预估金额</td>
                        <td class="content" style="color:blue;" data-bind="text:TotalAmount+'&nbsp'+CurrencyCode"></td>
                        <td class="title" name="TotalAmountB">本位币金额</td>
                        <td class="content" data-bind="text:BaseCurrencyTotalAmount"></td>
                        <td class="title"><span name="ReasonPurchase">请购原因</span><input type="hidden" id="ParValue" data-bind="value:PurchaseReason" /></td><!--hidden-->
                        <td class="content" data-bind="text:show_Par(PurchaseReason)+','+(PurchaseReason==1?ProjectName:'')+''+(PurchaseReason==2?OldAssetCode:'')+''+(PurchaseReason==3?Reason:'')"></td>


                    </tr>
                    <tr>
                        <td class="title" name="Budget">预算信息</td>
                        <td class="content" id="budget_id" data-bind="text:YuSuan(IsBudget)+','+(IsBudget==false?(ItemName==null?'':ItemName):'')+'&nbsp&nbsp'+(IsBudget==false?(Balance==null?'':Balance):'')+'&nbsp&nbsp'+(IsBudget==false?(BudgetTime==null?'':formatterTime(BudgetTime,'YYYY/MM/DD')):'')+'&nbsp&nbsp'+(IsBudget==true?(ReasonForBudget==null?'':ReasonForBudget):'')"></td>
                        <td class="title" name="IsNew">是否全新</td>
                        <td class="content" data-bind="text:isNew(IsNew)"></td>
                        <td class="title" name="DemandDate">需求日期</td>
                        <td class="content" data-bind="text:formatterTime(DemandDate,'YYYY/MM/DD')"></td>

                    </tr>
                    <tr>
                        <td class="title" name="PlacementPlace">安置地点</td>
                        <td class="content" data-bind="text:PlacementPlace"></td>
                        <td class="title" name="LowvalueAssetFlag">是否低值资产</td>
                        <td class="content" data-bind="text:isNew(LowvalueAssetFlag)"></td>
                        <td class="title" name="AssetNumber">低值物料号</td>
                        <td class="content" data-bind="text:AssetNumber"></td>

                    </tr>

                </tbody>
            </table>
        </div>
        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('document')"*@ onclick="SearchExpand('document');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!DocumentDisplay()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:DocumentDisplay()" />
                单据信息@*<span name="DocumentInfo">单据信息</span>*@
            </div>
            <table class="table_contanct" style="width:100%;cursor:auto;" data-bind="visible:DocumentDisplay,with:FixedAssets">
                <tbody>
                    <tr>
                        <td class="title" name="DocumentNumber">请求单号</td>
                        <td class="content" data-bind="text:$parent.Documents().DocumentCode"></td>
                        <td class="title" name="Creator">开 单 人</td>
                        <td class="content" data-bind="text:$parent.Documents().Creator"></td>
                        <td class="title" name="ApplicationDate">开单日期</td>
                        <td class="content" data-bind="text:formatterTime($parent.Documents().ApplicationDate,'YYYY-MM-DD')"></td>
                    </tr>
                    <tr>
                        <td class="title" name="ApplicantName">需 求 人</td>
                        <td class="content" data-bind="text:$parent.Documents().ApplicantName"></td>
                        <td class="title" name="CompanyName">需求公司</td>
                        <td class="content" data-bind="text:$parent.Documents().CompanyName"></td>
                        <td class="title" name="DepartmentName">需求部门</td>
                        <td class="content" data-bind="text:$parent.Documents().DepartmentName"></td>
                    </tr>
                    <tr>
                        <td class="title" name="CostCenter">成本中心</td>
                        <td class="content" data-bind="text:CostCenter"></td>
                        <td class="title" name="PurchasingGroup">采购组</td>
                        <td class="content" data-bind="text:PurchaserName"></td>
                        <td class="title" name="Annex">附件</td>
                        <td class="content"><a id="AnnexLabel" target="_blank" href="#"><span name="checkAnnex">点击查看附件</span></a></td>

                    </tr>

                </tbody>
            </table>

        </div>
        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('require')"*@ onclick="SearchExpand('require');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!RequirementsDisplay()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:RequirementsDisplay()" />
                详细要求 @*<span name="DetailedRequirements">详细要求</span>*@
            </div>
            <table class="table_contanct" style="width:100%;cursor:auto;" data-bind="visible:RequirementsDisplay,with:FixedAssets">
                <tbody>
                    <tr>
                        <td class="title" name="skillsRequirement">技术要求</td>
                        <td class="content" data-bind="text:Claim"></td>
                    </tr>

                    <tr>
                        <td class="title" name="OtherRemark">其他要求</td>
                        <td class="content" data-bind="text:Remark"></td>
                    </tr>

                    <tr>
                        <td class="title" name="Remarks">备注</td>
                        <td class="content" data-bind="text:Remark2"></td>
                    </tr>

                    <tr>
                        <td class="title" name="InnerTubeBlock">内管分组码</td>
                        <td class="content">
                            <select data-bind="options:$parent.InnerTubeBlocks,optionsText: 'Text', optionsValue: 'Key',value:InnerTubeBlockCode,optionsCaption:'',visible:$parent.InnerTubeBlockCodeEdit"></select>
                            <div data-bind="text:$parent.formatterInnerTubeBlock(InnerTubeBlockCode),visible:!$parent.InnerTubeBlockCodeEdit()"></div>
                        </td>
                    </tr>

                </tbody>
            </table>

        </div>
    </div>
    <!--表_技术主管部门/财务部门 审核-->
    <div>

        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('tecfinadvice')"*@ onclick="SearchExpand('tecfinadvice');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!TecFinancialApprovalAdvice()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:TecFinancialApprovalAdvice()" />
                职能部门审批意见@*<span name="FunctionalDepartmentApprovalComments">职能部门审批意见</span>*@
            </div>
            <form id="ajaxForm" name="ajaxForm" data-bind="visible:TecFinancialApprovalAdvice" enctype="multipart/form-data" action="/FixedAsset/ModifyDataSave" method="post">
                @*<button id="ShowStep1" type="button" data-bind="click:save1">测试1(技术/财务)</button>
    <button id="ShowStep3" type="button" data-bind="click:save2">测试2(招标)</button>
    <button id="ShowStep5" type="button" data-bind="click:save3">测试3(归口/厂务)</button>
    <button type="button" id="ShowStepAll" data-bind="click:save4">测试4(review)</button>*@
    <button id="SaveAllMessage" type="button" data-bind="click:save">测试5(保存数据)</button>
                <div style="color:black !important;" data-bind="visible:OneStepEdit()">
                    <lable style="font-weight:bold;" name="ApprovalRole">审批角色:</lable>
                    <input type="radio" name="StepRadio" id="StepRadio1" value="1" data-bind="checked:selectedRole,checkedValue:1" />
                    <span name="TechnicalDepartment">技术主管部门</span>
                    <input type="radio" name="StepRadio" id="StepRadio2" value="2" data-bind="checked:selectedRole,checkedValue:2" />
                    <span name="FinanceDepartment">财务部</span>
                    <input type="radio" name="StepRadio" id="StepRadio3" value="3" data-bind="checked:selectedRole,checkedValue:3" />
                    <span name="PurchasingDepartment">采购部</span>
                    <input type="radio" name="StepRadio" id="StepRadio4" value="4" data-bind="checked:selectedRole,checkedValue:4" />
                    <span name="ImportAndExportDepartment">进出口部</span>
                </div>

                <table class="table_review" style="width:100%" id="FinanceApproval">


                    <tr>
                        <td class="title" name="AuditDepartment">审核部门</td>
                        <td class="title" name="KeyItems">关键项</td>
                        <td class="title" name="AuditOpinion">审核意见</td>
                        <td class="title" name="Annex">附件</td>
                        <td class="title" name="Remarks">备注</td>
                        <td class="title">CC</td>
                    </tr>

                    <tr data-bind="with:FinanceApproval,attr:{disabled:selectedRole()!=1}">
                        <td class="title"><span name="TechnicalDepartment">技术主管部门</span></td>
                        <td class="content"></td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:AuditOpinion_Technology"></textarea></div>
                            <div data-bind="text:AuditOpinion_Technology,visible:!$parent.OneStepEdit()"></div>
                        </td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><input type="file" name="Annex_Technology" /></div>
                            <div data-bind="visible:!$parent.OneStepEdit()"><a id="Annex_Technology" target="_blank" data-bind="attr:{href:Annex_Technology}"><span name="checkAnnex">点击查看附件</span></a></div>@*data-bind="visible:!$parent.OneStepEdit()"*@
                        </td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:Remark_Technology"></textarea></div>
                            <div data-bind="text:Remark_Technology,visible:!$parent.OneStepEdit()"></div>
                        </td>
                        <td class="content">
                            <input type="text" data-bind="value:CarbonCopy_Technology,visible:$parent.OneStepEdit()" />
                            <div data-bind="text:CarbonCopy_Technology,visible:!$parent.OneStepEdit()"></div>
                        </td>
                    </tr>
                    <tr data-bind="with:FinanceApproval,attr:{disabled:selectedRole()!=2}">

                        <td class="title"><span name="FinanceDepartment">财务部</span></td>
                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()">
                                <span style="color:red">*</span>
                                <select name="FinanceCost" id="FinanceCost" data-bind="options:$parent.CostAmountTypeSelect,optionsText: 'CName', optionsValue: 'ID',value:CostAmountTypeCode"></select>
                            </div>
                            <div data-bind="text:$parent.formatterCost(CostAmountTypeCode),visible:!$parent.OneStepEdit()"></div>
                        </td>



                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:AuditOpinion_Finance"></textarea></div>
                            <div data-bind="text:AuditOpinion_Finance,visible:!$parent.OneStepEdit()"></div>
                        </td>


                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><input type="file" name="Annex_Finance" /></div>
                            <div data-bind="visible:!$parent.OneStepEdit()"><a id="Annex_Finance" target="_blank" data-bind="attr:{href:Annex_Finance}"><span name="checkAnnex">点击查看附件</span></a></div>@*data-bind="visible:!$parent.OneStepEdit()"*@
                        </td>


                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:Remark_Finance"></textarea></div>
                            <div data-bind="text:Remark_Finance,visible:!$parent.OneStepEdit()"></div>
                        </td>
                        <td class="content">
                            <input type="text" data-bind="value:CarbonCopy_Finance,visible:$parent.OneStepEdit()" />
                            <div data-bind="text:CarbonCopy_Finance,visible:!$parent.OneStepEdit()"></div>
                        </td>

                    </tr>


                    <tr data-bind="with:TenderApproval,attr:{disabled:selectedRole()!=3}">
                        <td class="title"><span name="PurchasingDepartment">采购部</span></td>


                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()">
                                <span style="color:red">*</span>
                                <select id="AssetClassification" data-bind="options:$parent.AssetRangeSelect,optionsText: 'CName', optionsValue: 'ID',value:AssetRangeCode"></select>
                            </div>
                            <div data-bind="text:$parent.formatterAsset(AssetRangeCode),visible:!$parent.OneStepEdit()"></div>
                        </td>


                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:AuditOpinion_Purchase"></textarea></div>
                            <div data-bind="text:AuditOpinion_Purchase,visible:!$parent.OneStepEdit()"></div>
                        </td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><input type="file" name="Annex_Purchase" /></div>
                            <div data-bind="visible:!$parent.OneStepEdit()"><a id="Annex_Purchase" target="_blank" data-bind="attr:{href:Annex_Purchase}"><span name="checkAnnex">点击查看附件</span></a></div>@*data-bind="visible:!$parent.OneStepEdit()"*@
                        </td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:Remark_Purchase"></textarea></div>
                            <div data-bind="text:Remark_Purchase,visible:!$parent.OneStepEdit()"></div>
                        </td>
                        <td class="content">
                            <input type="text" data-bind="value:CarbonCopy_Purchase,visible:$parent.OneStepEdit()" />
                            <div data-bind="text:CarbonCopy_Purchase,visible:!$parent.OneStepEdit()"></div>
                        </td>

                    </tr>


                    <tr data-bind="with:FactoryApproval,attr:{disabled:selectedRole()!=4}">
                        <td class="title"><span name="ImportAndExportDepartment">进出口部</span></td>


                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()">
                                <span style="color:red">*</span>
                                <select id="Customs_Declaration" data-bind="options:$parent.CustomsDeclarationSelect,
            optionsText: 'name', optionsValue: 'status',value:$parent.CustomsDeclaration,optionsCaption:''"></select><!--进出口部报关方式-->
                            </div>
                            <div data-bind="text:$parent.formatterDeclaration(CustomsDeclaration),visible:!$parent.OneStepEdit()"></div>
                        </td>


                        <td class="content">
                            <!--报关单位-->
                            <div data-bind="visible:$parent.OneStepEdit()"><select data-bind="options:$parent.AssetRuleCompanies,optionsText: 'AssetRuleCompanyName', optionsValue: 'AssetRuleCompanyId',value:CustomsDeclarationUnit,optionsCaption:''"></select></div>
                            <div data-bind="text:$parent.formatterUnit(CustomsDeclarationUnit),visible:!$parent.OneStepEdit()"></div>
                        </td>

                        <td class="content">
                            @*<div data-bind="visible:$parent.OneStepEdit()"><input type="file" name="Annex_Import" /></div>
                                <div data-bind="visible:!$parent.OneStepEdit()"><a id="Annex_Purchase" target="_blank" data-bind="attr:{href:Annex_Import}">(点击查看附件)</a></div>*@
                        </td>

                        <td class="content">
                            <div data-bind="visible:$parent.OneStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:Remark_Factory"></textarea></div>
                            <div data-bind="text:Remark_Factory,visible:!$parent.OneStepEdit()"></div>
                        </td>
                        <td class="content">
                            @*<input type="text" data-bind="value:CarbonCopy_Purchase,visible:$parent.OneStepEdit()" />
                                <div data-bind="text:CarbonCopy_Purchase,visible:!$parent.OneStepEdit()"></div>*@
                        </td>

                    </tr>


                </table>


                <!--表_进口部/厂务部 审核-->
                <table class="table_review" style="margin-top:10px !important;width:100% !important;" id="FactoryApproval"
                       data-bind="with:FactoryApproval">
                    <thead>
                        <tr>
                            <th class="title" colspan="6" name="ImportDepartment">
                                <!---进口部/厂务部 审核意见(归口部门-公司资产管理员/厂务部管理员填写)-->
                                物管中心 审核意见(进出口部报关员-公司资产管理员填写)
                            </th>
                        </tr>
                    </thead>
                    <tbody>



                        <tr>

                            <td class="title"><span name="classification">分类</span></td>
                            <td class="content">
                                <div data-bind="visible:$parent.TwoStepEdit()">
                                    <select data-bind="options:$parent.ClassificationSelect,
        optionsText: 'name', optionsValue: 'status',value:Classification,optionsCaption:''"></select>
                                </div>
                                <div data-bind="text:$parent.formatterClassification(Classification),visible:!$parent.TwoStepEdit()"></div>
                            </td>


                            <td class="title"><spna name="OwnedCompany">所属公司</spna><span style="color:red">*</span></td>
                            <td class="content">
                                <select id="AffiliatedCompany" data-bind="options:$parent.AssetRuleCompanies,optionsText: 'AssetRuleCompanyName', optionsValue: 'AssetRuleCompanyId',value:$parent.AssetRuleId2,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                                <div data-bind="text:$parent.RuleCode2,visible:!$parent.TwoStepEdit()"></div>
                            </td>

                            <td class="title"><span name="DateTime">日期</span></td>
                            <td class="content">
                                <div data-bind="visible:$parent.TwoStepEdit()">
                                    <input id="DeclarationDateReview" readonly="readonly" class="Wdate" onFocus="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd'})" data-bind="value:formatterTime(DeclarationDate,'YYYY-MM-DD')" />
                                </div>
                                <div data-bind="text:formatterTime(DeclarationDate,'YYYY-MM-DD'),visible:!$parent.TwoStepEdit()"></div>
                            </td>

                        </tr>

                        <tr>

                            <td class="title" name="Annex">附件</td>
                            <td class="content">
                                <div data-bind="visible:$parent.TwoStepEdit()"><input type="file" name="Annex_Factory" /></div>
                                <div data-bind="visible:!$parent.TwoStepEdit()"><a id="Annex_Factory" target="_blank" data-bind="attr:{href:Annex_Factory}"><span name="checkAnnex">点击查看附件</span></a></div>
                            </td>


                            <td class="title" name="CompetentDepartmentNotes">主管部门备注</td>
                            <td class="content">
                                <div data-bind="visible:$parent.TwoStepEdit()"><textarea style="width:100%; max-width:100%;" data-bind="value:Remark_Supervisor"></textarea></div>
                                <div data-bind="text:Remark_Supervisor,visible:!$parent.TwoStepEdit()"></div>
                            </td>


                            <td class="title">CC</td>
                            <td class="content">
                                <input type="text" data-bind="value:CarbonCopy_Factory,visible:$parent.TwoStepEdit()" />
                                <div data-bind="text:CarbonCopy_Factory,visible:!$parent.TwoStepEdit()"></div>
                            </td>


                        </tr>

                        <tr>
                            <td class="title" name="AssetNumberingRules">资产编号规则</td>
                            <td class="content" name="AssetGroupName">资产一级分类</td>
                            <td class="content" name="AssetClassName">资产二级分类</td>
                            <td class="content" name="AssetTypeName">资产三级分类</td>
                            <td class="content" name="AssetForth">资产四级分类</td>
                            <td class="content" name="AssetModel">资产型号明细</td>

                        </tr>


                        <tr>
                            <td class="title" name="AssetNumberRuleDefinition">资产编号规则定义</td>

                            <td class="content">
                                <select id="AssetRule" onchange="assetChange(1);" data-bind="options:$parent.AssetRules,optionsText: 'AssetRuleName', optionsValue: 'AssetRuleId',value:$parent.AssetRuleId1,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                            </td>

                            <td class="content">
                                <select id="AssetGroup" onchange="assetChange(3);" data-bind="options:$parent.AssetGroups,optionsText: 'AssetGroupName', optionsValue: 'AssetGroupId',value:$parent.AssetRuleId3,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                            </td>

                            <td class="content">
                                <select id="AssetClass" onchange="assetChange(4);" data-bind="options:$parent.AssetClasses,optionsText: 'AssetClassName', optionsValue: 'AssetClassId',value:$parent.AssetRuleId4,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                            </td>

                            <td class="content">
                                <select id="AssetType" onchange="assetChange(5);" data-bind="options:$parent.AssetTypes,optionsText: 'AssetTypeName', optionsValue: 'AssetTypeId',value:$parent.AssetRuleId5,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                            </td>


                            <td class="content">
                                <select id="AssetModel" data-bind="options:$parent.AssetModels,optionsText: 'AssetModelName', optionsValue: 'AssetModelId',value:$parent.AssetRuleId6,optionsCaption:'',visible:$parent.TwoStepEdit()"></select>
                            </td>

                        </tr>


                        <tr>

                            <td class="title" name="AssetNumberRuleValue">资产编号规则值</td>

                            <td class="content" data-bind="text:$parent.RuleCode1"></td>

                            <td class="content" data-bind="text:$parent.RuleCode3"></td>

                            <td class="content" data-bind="text:$parent.RuleCode4"></td>

                            <td class="content" data-bind="text:$parent.RuleCode5"></td>

                            <td class="content" data-bind="text:$parent.RuleCode6"></td>

                        </tr>
                        <tr>

                            <td class="title" name="AssetNumberRuleValue">资产编号规则值名称</td>

                            <td class="content" data-bind="text:$parent.RuleName1"></td>

                            <td class="content" data-bind="text:$parent.RuleName3"></td>

                            <td class="content" data-bind="text:$parent.RuleName4"></td>

                            <td class="content" data-bind="text:$parent.RuleName5"></td>

                            <td class="content" data-bind="text:$parent.RuleName6"></td>

                        </tr>


                        <tr>


                            <td class="title"><spna name="AssetNumberRuleCode">资产编号规则编码</spna></td>
                            <td class="content" data-bind="text:$parent.RuleCombination"></td>

                            <td class="title"><spna name="AssetRuleStartingNumber">资产规则起始号</spna></td>
                            <td class="content" data-bind="text:$parent.SerialNumber_Start"></td>

                            <td class="title"><spna name="AssetRuleRerminationNumber">资产规则终止号</spna></td>
                            <td class="content" data-bind="text:$parent.SerialNumber_End"></td>
                        </tr>
                        <tr>
                            <td class="title" name="SAPAssetNumberingRules">SAP资产编号规则</td>
                            <td class="content" data-bind="text:SAPRuleCode"></td>
                            <td class="title"></td>
                            <td class="content"></td>
                            <td class="title"></td>
                            <td class="content"></td>
                        </tr>





                    </tbody>
                </table>

                <input id="Hidden1" name="Hidden1" type="hidden" />

            </form>
            <div><a href="javascript:void(0)" onclick="window.open('/assetpoinfo?pr='+vm.Documents().PR+'&language='+'@ViewBag.Language');" data-bind="visible:Documents().DocumentStatus==2?true:false"><span name="AssetNoLink">查询资产号</span></a></div>
        </div>
    </div>

    <!--表_审批人-->

    <div>
        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('data')"*@ onclick="SearchExpand('data');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!IsDataDisplay()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:IsDataDisplay()" />
                数据决策 @*<span name="DataDecision">数据决策</span>*@
            </div>
            <ul data-bind="visible:IsDataDisplay">
                <li style="background-color:white; height:640px;" id="SetfromName">
                    <iframe frameborder="0" height="100%" width="100%" id="ifromName"
                            src="" scrolling="auto" frameborder="no"></iframe>
                    @*<span name="Developing">待开发</span>...*@
                </li>
            </ul>
        </div>
    </div>

    <div>
        <div class="shrinkBar contannier_u">
            <div @*data-bind="click:DetailToggole('approver')"*@ onclick="SearchExpand('approver');">
                <img src="~/Images/comm/arrow_up.png" class="icon_up" data-bind="visible:!ApprovalDisplay()" />
                <img src="~/Images/comm/arrow_down.png" class="icon_down" data-bind="visible:ApprovalDisplay()" />
                审批职级 @*<span name="Approver">审批职级</span>*@
            </div>
            <table data-bind="visible:ApprovalDisplay" class="table_review" style="margin-top:40px !important;">
                <thead>
                    <tr>
                        <th style="width:20% !important" name="SerialNumber">序号</th>
                        <th style="width:40% !important" name="ApprovalLevel">审批职级</th>
                        <th style="width:40% !important" name="Approver">审批人</th>
                    </tr>
                </thead>
                <tbody id="approvers"></tbody>
            </table>
        </div>
    </div>

</div>


<script>
    language = '@ViewBag.Language';
    var translations= @Html.Raw(Json.Encode(ViewBag.Translations));//本页面所有需要翻译的键值对
    var [email protected](Json.Encode(ViewBag.BiConfiguration));///获取配置列表信息
    var BiConfigId=0;//记住编号

    var ActionName = "";
    ActionName = GetQueryString("ActivityName");
    var WFListItemID = 0;
    var UserID = "";
    var UserName = "";
    var WFWorkListAuditingID = 0;
    var OAMessage="";//审批意见
    var OAFlowID="";///返回FlowID

    var initFinished = false;

    var ruleJson = new Object();//规则JSON
    $(function(){
        GetHight();
    })

    ///成本中心,物料组3
    $(function(){
        var href="";
        var FixedAssetHref="";
        href+="http://eaipo.kaifa.cn:85/Home/EmbedReport?FromAddress=FixedAsset/Review";
        @*href+="&CostCenterID="+vm.FixedAssets().CostCenter+"SZ01";
        href+="&Asset3ID="[email protected];//vm.FactoryApproval().RuleCode4;*@
        var UrlHref="";
        var IsTrue=false;
        ///首先判断活动和值是否存在
        ///$.each(BiConfiguration,function(index,item)
        for(var i in BiConfiguration) {
            debugger;
            var JsonVal=BiConfiguration[i].JsonCondition;
            var Json;
            if (JsonVal!=null && JsonVal!="")
            {
                Json=$.parseJSON(JsonVal);
                for(var item in Json){
                    ///判断配置参数值是否是该参数值 例如 当公司为A 才能走该报表,如果不是走默认报表
                    if (vm.FixedAssets().hasOwnProperty(Json[item].Key) && Json[item].value==vm.FixedAssets()[Json[item].Key] && ActionName==BiConfiguration[i].Activity)
                    {
                        IsTrue=true;///是当前活动并且是当前条件
                        BiConfigId=BiConfiguration[i].BiConfigurationId;
                        break;
                    }
                }
            }
            if ((BiConfiguration[i].Activity=="0" || BiConfiguration[i].Activity==null || BiConfiguration[i].Activity=="") && !IsTrue)
                BiConfigId=BiConfiguration[i].BiConfigurationId;
        }
        //    alert(BiConfigId);
        for(var item in BiConfiguration)
        {
            if (BiConfiguration[item].BiConfigurationId==BiConfigId)
            {
                if (BiConfiguration[item].Parameter!=null && BiConfiguration[item].Parameter!="")
                {
                    if (BiConfiguration[item].Parameter.indexOf("#")>-1)///查看有几个参数
                    {
                        var Pr=BiConfiguration[item].Parameter.split("#");
                        var Pm=BiConfiguration[item].CheckParameter.split("#");
                        for(var i=0;i<Pr.length;i++)
                        {
                            ///主表
                            if (Pr[i]=="Asset3ID")
                                UrlHref+="&"+Pr[i]+"="[email protected];
                            else
                                UrlHref+="&"+Pr[i]+"="+vm.FixedAssets()[Pr[i]];
                        }
                    }
                    else
                    {
                        UrlHref+="&"+BiConfiguration[item].Parameter+"="+vm.FixedAssets()[BiConfiguration[item].Parameter];
                    }
                }
                break
            }
        }
        href+=UrlHref;
        // alert(href);
        if (BiConfigId==0)
            href="";
        ///end 物料号
        $("#ifromName").attr("src",href);
    })


    function GetHight(){
        var height=1000;
        height=$("#PageHeight").height()
        //height=$(document.body).outerHeight(true);
        window.parent.postMessage("Height"+height,"*");
    }

    function SearchExpand(para)
    {
        switch(para){
            case"demand":{
                vm.IsDemandDisplay(!vm.IsDemandDisplay());
            }
                break;
            case "document":{
                vm.DocumentDisplay(!vm.DocumentDisplay());
                //alert(para);
            }
                break;
            case "require":{
                vm.RequirementsDisplay(!vm.RequirementsDisplay());
                //alert(para);
            }
                break;
            case "approver":{
                vm.ApprovalDisplay(!vm.ApprovalDisplay());
                //alert(para);
            }
                break;
            case "data":{
                // vm.IsDataDisplay(!vm.IsDataDisplay());
                OpenData();
                //alert(para);
            }
                break;
            case"tecfinadvice":{
                vm.TecFinancialApprovalAdvice(!vm.TecFinancialApprovalAdvice())
            }
                break;
            default:{
                //alert(para);
            }
                break;
        }
        GetHight();
    }




    ///判断当前审批人是否有权限打开
    function OpenData()
    {
        //  debugger;
        //alert(vm.Documents().OAGuid);
        var guid=vm.Documents().OAGuid;
        // alert(guid);
        if (guid!=null && guid!="")
        {
            $.ajax({
                type: "POST",
                url: "/FixedAsset/GetOaOpenData",
                data: { "oaGuid": guid},
                dataType: "json",
                success: function (data) {
                    //  debugger;
                    // alert(data.msg);
                    if (data.msg=="1")
                    {
                        vm.IsDataDisplay(!vm.IsDataDisplay());
                        //   alert("ssss");
                    }
                    else{
                        vm.IsDataDisplay(vm.IsDataDisplay());
                        alert("你无此权限查看!");
                    }
                    GetHight();
                },
                error: function (failure) {
                    alert(failure.responseText);
                }
            });
        }
        else
        {
            $("#ifromName").attr("src","");
            $("#SetfromName").html("");
        }
    }

    $(function(){
        var idx=$("#ParValue").val();
        //  alert(idx);
        for(var i=0;i<4;i++)
        {
            if (idx == i)
            {
                $(".Par_"+idx).show();
            }
            else{
                $(".Par_"+i).hide();
            }
        }

        ActionName = GetQueryString("ActivityName");

        //ActionName="No6";
        if (ActionName=="No4" || ActionName=="No6" || ActionName == "No15")
        {
            ////技术主管部门

            //$("#ShowStep1").click();

            vm.OneStepEdit(true);

        }


        if (ActionName=="No9")
        {
            ////采购

            //$("#ShowStep3").click();

        }
        if (ActionName == "No20" )///|| ActionName == "No15"
        {

            ////进口部/厂务部
            //$("#ShowStep5").click();
            vm.TwoStepEdit(true);
        }

        //获取URL参数



        WFListItemID= GetQueryString("WFListItemID");
        UserID= GetQueryString("UserID");
        UserName= GetQueryString("UserName");
        WFWorkListAuditingID= GetQueryString("WFWorkListAuditingID");
        //  alert(ActionName+WFListItemID+UserID+UserName+WFWorkListAuditingID);
        //  $("#FinanceApproval").hide();
        // alert(ActionName);


        initFinished = true;//是否初始化完成

    })

    function ModifyData (event){
        debugger;
        //alert(event.data);
        //return false;
        var OAreturnMeg=event.data;//"Agree#54644#同意";
        if (OAreturnMeg.toString().indexOf("#")>-1)
        {
            var splitvalue=OAreturnMeg.toString().split('#');
            if (splitvalue.length>0)
            {
                OAFlowID=splitvalue[1];
                OAMessage=splitvalue[2];
                if (splitvalue[0]=="Agree")///同意才提交
                {
                    vm.save();
                }
            }
        }
        else{
            //  alert("OA传入值有误:"+OAreturnMeg);
        }
        //if (event.data!=""){
        //    OAMessage=event.data;
        //    // alert("成功了");
        //}
        //if(event.data!="WindowClose"){
        //    //$("#SaveAllMessage").click();
        //    //  alert(OAMessage);

        //}
    }
    window.addEventListener = window.addEventListener || function (e, f) { window.attachEvent('on' + e, f); };
    window.addEventListener("message", ModifyData, false);

    //function sendMsg() {
    //    window.parent.postMessage("WindowClose", "*");
    //}

    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return (r[2]); return null;
    }

    function YuSuan(obj)
    {
        var str="";
        if (obj==false)
        {
            str=getValueByKey(language, translations, "budgetOne");//"预算内";///budgetOne
        }
        else
        {
            str=getValueByKey(language, translations, "budgetTwo");//"预算外";///budgetTwo
            $("#budget_id").css("color","red");
        }
        return str;

    }
    function isNew(obj)
    {
        var str="";
        if (obj==true)
        {
            str=getValueByKey(language, translations, "AltYes") ;
        }
        else
        {
            str=getValueByKey(language, translations, "AltNo");
        }
        return str;

    }

</script>
<script type="text/javascript">
    $(function () {
        $("#ShowStep1,#ShowStep3,#ShowStep5,#ShowStepAll").css("display", "none");//,#SaveAllMessage
    })

    function show_Par(obj)
    {
        var str="";
        if (obj==1)
        {
            str=getValueByKey(language, translations, "AltProjoctOne");//"项目";
        }else if(obj==2){
            str=getValueByKey(language, translations, "AltProjoctTwo");//"替换";
        }
        else if(obj==3){
            str=getValueByKey(language, translations, "AltProjoctTree");//"补充";
        }
        return str;
    }

    //显示审批人列表
    function showOAApprovers()
    {
        $("#approvers").empty();

        var html = "";

        if (approvers && approvers.length > 0)
        {
            for (var i = 0; i < approvers.length; i++) {
                html += "<tr><td class = 'title'>" + (i + 1) + "</td><td class = 'content'>"+ approvers[i].ApproverKey+ "</td><td class = 'content'>" + approvers[i].ApproverValue + "</td></tr>";
            }
        }

        $("#approvers").append(html);
    }

    var approvers [email protected](Json.Encode(ViewBag.OAApprovers));//审批人

    //给CC文本框添加联想功能
    function autoComplete(id)//id:元素id
    {
        $(id).autocomplete({
            appendMethod:"replace",
            valueKey: "SamAccountName",
            titleKey:"SamAccountName",
            source: [
                function (q, add) {
                    if (q != "")
                    {
                        var url = "/FixedAsset/CheckCC?cc=" + q;
                        $.ajaxSettings.async = false
                        $.getJSON(url, function (resp) {
                            add(resp)
                        })
                    }
                }
            ]
        });
    }

    //将抄送人员以label的形式展示
    //arr: 数组;   id: 展示的元素id
    function showCC (arr,id)
    {
        $(id).empty();
        $.each(arr,function(index,item){
            if(index < arr.length - 1 ){
                $(id).append("<div id="+ index +" style='height:18px;float:left;line-height:18px;font-size:12px;display:inline;border:1px solid #666666;color:#666666;padding:0 3px !important;margin-right:5px;border-radius:5px;'>" + item + "<span onclick='deleteCC(this)' style=\"font-size:20px;color:red;cursor:hand;margin-left:2px !important;\">×</span></label>&nbsp;")
            }
        })
    }

    function translatePage(lang, translationsArray, isPopWindow) {

        isPopWindow = isPopWindow || false;

        //获取公共翻译部分
        language = lang;

        if (translationsArray && translationsArray.length > 0) {

            if (isPopWindow) {
                $.each(translationsArray, function (i, item) {

                    if (item.LanguageDesc == lang) {
                        if (item.TranslationItem == "Title") {

                            //弹出窗口标题

                            if ($("#popupWindow .modal-title").length > 0) {
                                $("#popupWindow .modal-title").html(item.TranslationContent)
                            }
                        }
                        else {
                            if ($("#popupWindow .modal-body [name='" + item.TranslationItem + "']").length > 0) {
                                $("#popupWindow .modal-body [name='" + item.TranslationItem + "']").text(item.TranslationContent);
                            }
                        }
                    }
                });
            }
            else {
                $.each(translationsArray, function (i, item) {

                    if (item.LanguageDesc == lang) {
                        if (item.TranslationItem == "Title") {

                            $(document).attr("title", item.TranslationContent);//网页标题
                            $("#myPageName").html(item.TranslationContent);
                            $("#title").html(item.TranslationContent);
                        }

                        if ($("[name='" + item.TranslationItem + "']").length > 0) {
                            $("[name='" + item.TranslationItem + "']").text(item.TranslationContent);
                        }
                    }
                });
            }
        }
        //监听翻译

        if (monitorLanguage) {
            monitorLanguage();
        }

    }

    //监视语言变化
    function monitorLanguage(_language, event) {
        if (event) {
            event();
        }
    }


    ////翻译,弹消息,根据键值对,读取值,
    function getValueByKey(lang, translations, key) {

        if (translations && translations.length > 0) {

            var filterArray = $.grep(translations, function (item) {
                return item.LanguageDesc == lang && item.TranslationItem == key;
            });

            if (filterArray.length > 0) {
                return filterArray[0].TranslationContent;
            }
        }
    }



    //删除对应的抄送人员
    function deleteCC(obj){

        if(vm.ApprovalID() == 1){
            vm.FinanceApproval().CarbonCopy = vm.FinanceApproval().CarbonCopy.replace(obj.previousSibling.data+";","");
            vm.FinanceApproval(vm.FinanceApproval());
            showCC(vm.FinanceApproval().CarbonCopy.split(";"),"#CC_Show_1");
            //autoComplete("#CC_Condition_1");
            //carbonCopies = $("#CarbonCopy_Finance").val();
            //carbonCopies = carbonCopies.replace(obj.previousSibling.data+";","");
            //$("#CarbonCopy_Finance").val(carbonCopies);
            //showCC(carbonCopies.split(";"),"#CC_Show_1");
        }

        if(vm.ApprovalID() == 3){
            vm.TenderApproval().CarbonCopy = vm.TenderApproval().CarbonCopy.replace(obj.previousSibling.data+";","");
            vm.TenderApproval(vm.TenderApproval());
            showCC(vm.TenderApproval().CarbonCopy.split(";"),"#CC_Show_2");
            //autoComplete("#CC_Condition_2");
            //carbonCopies = $("#CarbonCopy_Tender").val();
            //carbonCopies = carbonCopies.replace(obj.previousSibling.data+";","");
            //$("#CarbonCopy_Tender").val(carbonCopies);
            //showCC(carbonCopies.split(";"),"#CC_Show_2");
        }

        if(vm.ApprovalID() == 5){
            vm.FactoryApproval().CarbonCopy = vm.FactoryApproval().CarbonCopy.replace(obj.previousSibling.data+";","");
            vm.FactoryApproval(vm.FactoryApproval());
            showCC(vm.FactoryApproval().CarbonCopy.split(";"),"#CC_Show_3");
            //autoComplete("#CC_Condition_3");
            //carbonCopies = $("#CarbonCopy_Factory").val();
            //carbonCopies = carbonCopies.replace(obj.previousSibling.data+";","");
            //$("#CarbonCopy_Factory").val(carbonCopies);
            //showCC(carbonCopies.split(";"),"#CC_Show_3");
        }
    }

    var ViewModel = function () {

        var self = this;
        self.IsDemandDisplay = ko.observable(true);//是否显示需求内容
        self.DocumentDisplay = ko.observable(true);//是否显示单据信息
        self.RequirementsDisplay = ko.observable(true);//是否显示详细要求
        self.TecFinancialApprovalAdvice = ko.observable(true);//是否显示技术及财务审批意见
        self.IsDataDisplay = ko.observable(false);//是否显示数据决策
        self.ApprovalDisplay = ko.observable(false);//是否显示审批职级
        //折叠展开 实现方式3 (备用):HTML元素绑定 click:DetailToggole(para),判断para参数
        self.DetailToggole = function (para){
            switch(para){
                case"demand":{
                    self.IsDemandDisplay(!self.IsDemandDisplay());
                }
                    break;
                case "document":{
                    self.DocumentDisplay(!self.DocumentDisplay());
                    //alert(para);
                }
                    break;
                case "require":{
                    self.RequirementsDisplay(!self.RequirementsDisplay());
                    //alert(para);
                }
                    break;
                case "approver":{
                    self.ApprovalDisplay(!self.ApprovalDisplay());
                    //alert(para);
                }
                    break;
                case "data":{
                    self.IsDataDisplay(!self.IsDataDisplay());
                    //alert(para);
                }
                    break;
                case"tecfinadvice":{
                    self.TecFinancialApprovalAdvice(!self.TecFinancialApprovalAdvice())
                }
                    break;
                default:{
                    //alert(para);
                }
                    break;
            }
            GetHight();
        }


        //self.IsInvoiceDisplay = ko.observable(false);//是否显示需求内容
        //self.DocumentDisplay = ko.observable(false);//是否显示单据信息
        //self.RequirementsDisplay = ko.observable(false);//是否显示详细要求

        //数据绑定
        self.Documents = ko.observable(@Html.Raw(Json.Encode(ViewBag.Documents)));//单据表

        self.FixedAssets = ko.observable(@Html.Raw(Json.Encode(ViewBag.FixedAssets)));//固定资产

        self.FinanceApproval = ko.observable(@Html.Raw(Json.Encode(ViewBag.FinanceApproval)));//技术主管部门/财务部门 审核

        self.TenderApproval = ko.observable(@Html.Raw(Json.Encode(ViewBag.TenderApproval)));//招标以及建议结果

        self.FactoryApproval = ko.observable(@Html.Raw(Json.Encode(ViewBag.FactoryApproval)));//进口部/厂务部 审核

        //下拉框选项绑定
        self.CostAmountTypeSelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.CostAmountType)));//财务部预算审核

        self.AssetRangeSelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.AssetRange)));//资产分类

        self.CurrencySelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.Currency)));//币种

        self.CustomsDeclarationSelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.CustomsDeclaration)));//报关方式

        self.CustomsDeclarationUnitSelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.CustomsDeclarationUnit)));//报关单位

        self.ClassificationSelect = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.Classification)));//分类

        self.InnerTubeBlocks = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.InnerTubeBlocks)));//内管分组码

        self.selectedRole = ko.observable(0);//选择角色审批

        //资产编号规则(大类-公司-二级分类-三级-明细-报关方式-序列号)

        self.AssetRules = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.AssetRules)));//资产规则大类
        self.AssetRuleCompanies = ko.observableArray(@Html.Raw(Json.Encode(ViewBag.AssetRuleCompanies)));//资产规则公司
        self.AssetGroups = ko.observableArray();//二级分类
        self.AssetClasses = ko.observableArray();//三级
        self.AssetTypes = ko.observableArray();//明细
        self.AssetModels = ko.observableArray();//资产型号

        self.AssetRuleId1 = ko.observable(self.FactoryApproval().AssetRuleId1);
        self.AssetRuleId2 = ko.observable(self.FactoryApproval().AssetRuleId2);
        self.AssetRuleId3 = ko.observable(self.FactoryApproval().AssetRuleId3);
        self.AssetRuleId4 = ko.observable(self.FactoryApproval().AssetRuleId4);
        self.AssetRuleId5 = ko.observable(self.FactoryApproval().AssetRuleId5);
        self.AssetRuleId6 = ko.observable(self.FactoryApproval().AssetRuleId6);

        self.RuleCode1 = ko.observable(self.FactoryApproval().RuleCode1);
        self.RuleCode2 = ko.observable(self.FactoryApproval().RuleCode2);
        self.RuleCode3 = ko.observable(self.FactoryApproval().RuleCode3);
        self.RuleCode4 = ko.observable(self.FactoryApproval().RuleCode4);
        self.RuleCode5 = ko.observable(self.FactoryApproval().RuleCode5);
        self.RuleCode6 = ko.observable(self.FactoryApproval().RuleCode6);

        self.RuleName1 = ko.observable(self.FactoryApproval().RuleName1);
        self.RuleName2 = ko.observable(self.FactoryApproval().RuleName2);
        self.RuleName3 = ko.observable(self.FactoryApproval().RuleName3);
        self.RuleName4 = ko.observable(self.FactoryApproval().RuleName4);
        self.RuleName5 = ko.observable(self.FactoryApproval().RuleName5);
        self.RuleName6 = ko.observable(self.FactoryApproval().RuleName6);

        self.CustomsDeclaration = ko.observable(self.FactoryApproval().CustomsDeclaration); //报关方式

        self.SerialNumber_Start = ko.observable(self.FactoryApproval().SerialNumber_Start);//规则起始序列号
        self.SerialNumber_End = ko.observable(self.FactoryApproval().SerialNumber_End);//规则终止序列号
        self.RuleCombination = ko.observable(self.FactoryApproval().RuleCombination);//规则组合

        //id联动code

        self.AssetRuleId1.subscribe(function (newValue) {


            if (self.AssetRules() && self.AssetRules().length > 0) {

                var filterArray = $.grep(self.AssetRules(), function (item) {
                    return item.AssetRuleId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode1(filterArray[0].KFRuleCode);
                }
            }

        });

        self.AssetRuleId2.subscribe(function (newValue) {


            if (self.AssetRuleCompanies() && self.AssetRuleCompanies().length > 0) {

                var filterArray = $.grep(self.AssetRuleCompanies(), function (item) {
                    return item.AssetRuleCompanyId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode2(filterArray[0].AssetRuleCompanyCode);
                }
            }

        });

        self.AssetRuleId3.subscribe(function (newValue) {

            if (self.AssetGroups() && self.AssetGroups().length > 0) {

                var filterArray = $.grep(self.AssetGroups(), function (item) {
                    return item.AssetGroupId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode3(filterArray[0].Evaluationgroup);
                }
            }

        });


        self.AssetRuleId4.subscribe(function (newValue) {

            if (self.AssetClasses() && self.AssetClasses().length > 0) {

                var filterArray = $.grep(self.AssetClasses(), function (item) {
                    return item.AssetClassId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode4(filterArray[0].Evaluationgroup);
                }
            }

        });

        self.AssetRuleId5.subscribe(function (newValue) {

            if (self.AssetTypes() && self.AssetTypes().length > 0) {

                var filterArray = $.grep(self.AssetTypes(), function (item) {
                    return item.AssetTypeId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode5(filterArray[0].Evaluationgroup);
                }
            }

        });

        self.AssetRuleId6.subscribe(function (newValue) {

            if (self.AssetModels() && self.AssetModels().length > 0) {

                var filterArray = $.grep(self.AssetModels(), function (item) {
                    return item.AssetModelId == newValue;
                });

                if (filterArray.length > 0) {

                    self.RuleCode6(filterArray[0].Evaluationgroup);
                }
            }

        })


        self.RuleCombination = ko.computed(function () {

            debugger;

            var ruleCombination = "";

            ruleCombination += self.RuleCode1();
            ruleJson.ANLKL = self.RuleCode1();


            ruleCombination += " ";

            ruleCombination += (self.RuleCode2() + "");
            ruleJson.ASCOM = (self.RuleCode2() + "");

            ruleCombination += " ";

            ruleCombination += self.RuleCode3();
            ruleJson.ORD42 = self.RuleCode3();


            ruleCombination += " ";

            ruleCombination += self.RuleCode4();
            ruleJson.ORD43 = self.RuleCode4();


            ruleCombination += " ";

            ruleCombination += self.RuleCode5();
            ruleJson.ORD44 = self.RuleCode5();

            ruleCombination += " ";

            if(self.RuleCode6()==null){
                self.RuleCode6("");
            }

            ruleCombination += self.RuleCode6();
            ruleJson.GDLGRP = self.RuleCode6();


            ruleCombination += " ";

            //报关方式
            var customsDeclarationValue = self.CustomsDeclaration();
            var customsDeclarationCode = "";

            switch (customsDeclarationValue)
            {
                case 5070:
                    {
                        customsDeclarationCode = "F";
                    }
                    break;

                case 5071:
                    {
                        customsDeclarationCode = "Y";
                    }
                    break;

                case 5072:
                    {
                        customsDeclarationCode = "J";
                    }
                    break;

                case 5073:
                    {
                        customsDeclarationCode = "D";
                    }
                    break;

                default:
                    {
                        customsDeclarationCode = "0";
                    }
                    break;
            }

            ruleCombination += customsDeclarationCode;

            ruleJson.ASTRD = customsDeclarationCode;
            ruleCombination += " ";


            ruleJson.GDLGRP = "";



            //if ($.trim(self.RuleCode6()).length > 8) {
            //    ruleCombination += self.RuleCode6().substring(0, 8);
            //    ruleJson.ASNO5 = self.RuleCode6().substring(0, 8);
            //}
            //else {
            //    ruleCombination += self.RuleCode6();
            //    ruleJson.ASNO5 = self.RuleCode6();
            //}


            ruleJson.COCEN = self.FixedAssets().CostCenter;

            debugger

            var ruleJsons = new Array();
            ruleJsons.push(ruleJson);

            //$.ajax({
            //    type: "GET",
            //    url: "/FixedAsset/CheckAssetRule",
            //    data: { "ruleCode": JSON.stringify(ruleJsons) },
            //    async: false,
            //    cache: false,
            //    dataType: "json",
            //    success: function (data) {

            //        debugger

            //        if (data.flag == true) {
            //            self.FactoryApproval().SAPRuleCode = data.msg;//SAP资产编号规则
            //            assetRulePass = true;
            //        }
            //        else {
            //            alert(data.msg);
            //            assetRulePass = false;
            //        }

            //    },
            //    error: function (failure) {
            //        alert(failure.responseText);
            //    }
            //});



            return ruleCombination;

        }, this);

        //资产规则序列号
        self.SerialNumber_Start = ko.computed(function () {

            //报关方式
            var totalLength = 0;
            var customsDeclarationValue = self.CustomsDeclaration();
            if ($.trim(customsDeclarationValue) == "") {
                totalLength = 4;//国内
            }
            else
            {
                totalLength = 3;//国外
            }

            var _count = self.FixedAssets().Quantity;


            var _start = prefixInteger(1, totalLength);

            return _start;

        }, this);


        self.SerialNumber_End = ko.computed(function () {

            //报关方式
            var totalLength = 0;
            var customsDeclarationValue = self.CustomsDeclaration();
            if ($.trim(customsDeclarationValue) == "") {
                totalLength = 4;//国内
            }
            else {
                totalLength = 3;//国外
            }

            var _count = self.FixedAssets().Quantity;


            var _end = prefixInteger(_count, totalLength);

            return _end;

        }, this);

        self.OneStepEdit = ko.observable(true);//第一步审批能编辑
        self.TwoStepEdit = ko.observable(false);//第二步审批能编辑


        ////下拉框回填时format
        //预算审核
        self.formatterCost = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.CostAmountTypeSelect(),function(item){
                    return value == item.ID;
                })
                if(filterArr.length > 0){
                    return filterArr[0].CName;
                }
            }
        }
        //资产分类
        self.formatterAsset = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.AssetRangeSelect(),function(item){
                    return value == item.ID;
                })
                if(filterArr.length > 0){
                    return filterArr[0].CName;
                }
            }
        }

        //币种
        self.formatterCurrency = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.CurrencySelect(),function(item){
                    return value == item.UKURS;
                })
                if(filterArr.length > 0){
                    return filterArr[0].FCURR;
                }
            }
        }

        //报关方式
        self.formatterDeclaration = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.CustomsDeclarationSelect(),function(item){
                    return value == item.status;
                })
                if(filterArr.length > 0){
                    return filterArr[0].name;
                }
            }
        }

        //报关单位
        self.formatterUnit = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.AssetRuleCompanies(),function(item){
                    return value == item.AssetRuleCompanyId;
                })
                if(filterArr.length > 0){
                    return filterArr[0].AssetRuleCompanyName;
                }
            }
        }

        //预算审核
        self.formatterClassification = function(value){
            if(value != null || value != ""){
                var filterArr = $.grep(self.ClassificationSelect(),function(item){
                    return value == item.status;
                })
                if(filterArr.length > 0){
                    return filterArr[0].name;
                }
            }
        }

        //内管分组码
        self.formatterInnerTubeBlock = function (value) {

            if (value != null || value != "") {
                var filterArr = $.grep(self.InnerTubeBlocks(), function (item) {

                    return value == item.Key;
                })

                if (filterArr.length > 0) {
                    return filterArr[0].Text;
                }
            }
        }

        //显示/隐藏标志

        self.ApprovalID = ko.observable('5');

        // self.ApprovalID = ko.observable('@ViewBag.ApprovalID');//审批步骤(0:技术主管/财务审核前, 1:技术主管/财务, 2:采购审核前, 3:采购, 4:进口部前, 5:进口部门, 6:进口部门审批之后)





        //self.ShowBtn_AddCC = ko.observable(false);//用于添加抄送人员按钮的显示隐藏

        //if(ApprovalStep != 0)//当前审批为有修改数据的步骤
        //{
        //    self.ApprovalID(ApprovalStep);
        //}
        //var ActionName= GetQueryString("ActivityName");
        //if (ActionName=="No4" || ActionName=="No6")
        //{
        //    ////技术主管部门
        //    self.ApprovalID(1);
        //}
        //if (ActionName=="No9")
        //{
        //    ////采购
        //    self.ApprovalID(3);
        //}
        //if (ActionName=="No20")
        //{
        //    ////进口部/厂务部
        //    self.ApprovalID(5);
        //}

        showOAApprovers();

        //数据表附件 显示/查看
        if(self.FixedAssets().Annex == null || self.FixedAssets().Annex == ""){
            $("#AnnexLabel").text("");
        }
        else{
            $("#AnnexLabel").attr("href", self.FixedAssets().Annex);//附件(链接)
        }

        if(self.FinanceApproval().Annex != null && self.FinanceApproval().Annex != ""){
            $.each(self.FinanceApproval().Annex.split(";"),function(index,item){
                if(item!= null&&item != ""){
                    $("#FinanceAnnex").append("<a href='"+item+"' target='_blank' style='padding-left:5px;'>"+(index+1)+"("+getValueByKey(language, translations, "AltAnnexLook")+")</a>");///点击查看附件
                }
            });
            //$("#FinanceAnnex").attr("href", self.FinanceApproval().Annex);//附件(链接)
            $("#FinanceAnnex").show();
        }

        if(self.TenderApproval().Annex != null && self.TenderApproval().Annex != ""){
            $.each(self.TenderApproval().Annex.split(";"),function(index,item){
                if(item!= null&&item != ""){
                    $("#TenderAnnex").append("<a href='"+item+"' target='_blank' style='padding-left:5px;'>"+(index+1)+"("+getValueByKey(language, translations, "AltAnnexLook")+")</a>")
                }
            });
            //$("#TenderAnnex").attr("href", self.TenderApproval().Annex);//附件(链接)
            $("#TenderAnnex").show();
        }

        /**********************  ↓  测  试  部  分  ↓  **********************/
        self.save1=function(){
            self.ApprovalID(1);
            //autoComplete("#CC_Condition_1");//联想功能(抄送人员)
            if(self.FinanceApproval().CarbonCopy != null && self.FinanceApproval().CarbonCopy != ""){
                showCC(self.FinanceApproval().CarbonCopy.split(";"),"#CC_Show_1");
            }
        }

        self.save2=function(){
            self.ApprovalID(3);
            //autoComplete("#CC_Condition_2");//联想功能(抄送人员)
            if(self.TenderApproval().CarbonCopy != null && self.TenderApproval().CarbonCopy != ""){
                showCC(self.TenderApproval().CarbonCopy.split(";"),"#CC_Show_2");
            }
        }

        self.save3 = function () {


            self.ApprovalID(5);
            //autoComplete("#CC_Condition_3");//联想功能(抄送人员)
            if(self.FactoryApproval().CarbonCopy != null && self.FactoryApproval().CarbonCopy != ""){
                showCC(self.FactoryApproval().CarbonCopy.split(";"),"#CC_Show_3");
            }

            //测试资产规则

            //ruleJson.ASNO1 = "A";
            //ruleJson.ASCOM = "0";
            //ruleJson.ASNO2 = "00";
            //ruleJson.ASNO3 = "00";
            //ruleJson.ASNO4 = "01";
            //ruleJson.ASTRD = "0";
            //ruleJson.ASNO5 = "3";
            //ruleJson.COCEN = "B20120";

            debugger;

            var ruleJsons = new Array();
            ruleJsons.push(ruleJson);

            $.ajax({
                type: "GET",
                url: "/FixedAsset/CheckAssetRule",
                data: { "ruleCode": JSON.stringify(ruleJsons) },
                async: false,
                cache: false,
                dataType: "json",
                success: function (data) {

                    debugger

                    if (data.flag == true) {
                        self.FactoryApproval().SAPRuleCode = data.msg;//SAP资产编号规则
                        assetRulePass = true;
                    }
                    else {
                        alert(data.msg);
                        assetRulePass = false;
                    }

                },
                error: function (failure) {
                    alert(failure.responseText);
                }
            });


        }

        self.save4=function(){
            self.ApprovalID(6);
        }
        /**********************  ↑  测  试  部  分  ↑  **********************/


        //// ActionName,WFListItemID,UserID,UserName,WFWorkListAuditingID
        //保存审批数据
        self.save = function () {

            //校验审批人

            var userCodes = [];

            if ($.trim(self.FinanceApproval().CarbonCopy_Technology) != "") {
                userCodes.push(self.FinanceApproval().CarbonCopy_Technology);
            }

            if ($.trim(self.FinanceApproval().CarbonCopy_Finance) != "") {
                userCodes.push(self.FinanceApproval().CarbonCopy_Finance);
            }

            if ($.trim(self.TenderApproval().CarbonCopy_Purchase) != "") {
                userCodes.push(self.TenderApproval().CarbonCopy_Purchase);
            }

            if ($.trim(self.FactoryApproval().CarbonCopy_Factory) != "") {
                userCodes.push(self.FactoryApproval().CarbonCopy_Factory);
            }

            var isCheckUserCode = true;

            if (userCodes.length > 0)
            {
                $.ajax({
                    type: "GET",
                    url: "/Account/CheckUserCode",
                    data: { "UserCodes": JSON.stringify(userCodes) },
                    async: false,
                    cache: false,
                    dataType: "json",
                    success: function (data) {

                        if (!data.flag) {
                            isCheckUserCode = false;

                            alert("CC人员输入有误" + data.userCode);
                        }
                        else {
                            isCheckUserCode = true;
                        }

                    },
                    error: function (failure) {
                        alert(failure.responseText);
                    }
                });
            }

            if (isCheckUserCode == false) {
                return false;
            }


            ////获取部分下拉框的文本内容
            //财务部预算审核
            self.FinanceApproval().CostAmountTypeName = self.formatterCost(self.FinanceApproval().CostAmountTypeCode)
            //资产分类
            self.TenderApproval().AssetRangeName = self.formatterAsset(self.TenderApproval().AssetRangeCode);
            //币种
            self.TenderApproval().CurrencyName = self.formatterCurrency(self.TenderApproval().CurrencyCode);
            //获取日期
            self.FactoryApproval().DeclarationDate = $("#DeclarationDateReview").val();

            //资产规则单据收集

            self.FactoryApproval().CustomsDeclaration = self.CustomsDeclaration();//报关方式


            self.FactoryApproval().AssetRuleId1 = self.AssetRuleId1();//规则大类id
            self.FactoryApproval().AssetRuleId2 = self.AssetRuleId2();//规则公司id
            self.FactoryApproval().AssetRuleId3 = self.AssetRuleId3();//规则二级分类id
            self.FactoryApproval().AssetRuleId4 = self.AssetRuleId4();//规则三级分类id
            self.FactoryApproval().AssetRuleId5 = self.AssetRuleId5();//规则四级分类id
            self.FactoryApproval().AssetRuleId6 = self.AssetRuleId6();//规则五级分类id

            self.FactoryApproval().RuleCode1 = self.RuleCode1();//规则大类编号
            self.FactoryApproval().RuleCode2 = self.RuleCode2();//规则公司编号
            self.FactoryApproval().RuleCode3 = self.RuleCode3();//规则二级分类编号
            self.FactoryApproval().RuleCode4 = self.RuleCode4();//规则三级分类编号
            self.FactoryApproval().RuleCode5 = self.RuleCode5();//规则四级分类编号
            self.FactoryApproval().RuleCode6 = self.RuleCode6();//规则五级分类编号

            self.FactoryApproval().RuleCode1 = self.RuleCode1();//规则大类编号
            self.FactoryApproval().RuleCode2 = self.RuleCode2();//规则公司编号
            self.FactoryApproval().RuleCode3 = self.RuleCode3();//规则二级分类编号
            self.FactoryApproval().RuleCode4 = self.RuleCode4();//规则三级分类编号
            self.FactoryApproval().RuleCode5 = self.RuleCode5();//规则四级分类编号
            self.FactoryApproval().RuleCode6 = self.RuleCode6();//规则五级分类编号

            self.FactoryApproval().RuleName1 = $("#AssetRule option:selected").text();//规则大类名称
            self.FactoryApproval().RuleName2 = $("#AffiliatedCompany option:selected").text();//规则公司名称
            self.FactoryApproval().RuleName3 = $("#AssetGroup option:selected").text();//规则二级分类名称
            self.FactoryApproval().RuleName4 = $("#AssetClass option:selected").text();//规则三级分类名称
            self.FactoryApproval().RuleName5 = $("#AssetType option:selected").text();//规则四级分类名称
            self.FactoryApproval().RuleName6 = $("#AssetModel option:selected").text();//规则五级分类名称

            self.FactoryApproval().SerialNumber_Start = self.SerialNumber_Start();//规则起始序列号
            self.FactoryApproval().SerialNumber_End = self.SerialNumber_End();//规则终止序列号
            self.FactoryApproval().RuleCombination = self.RuleCombination();//规则组合

            ////抄送人员
            //self.FinanceApproval().CarbonCopy = $("#CarbonCopy_Finance").val();
            //self.TenderApproval().CarbonCopy = $("#CarbonCopy_Tender").val();
            //self.FactoryApproval().CarbonCopy = $("#CarbonCopy_Factory").val();

            //必填项判断
            //if(self.ApprovalID() == 1){
            //    if(self.FinanceApproval().CostAmountTypeName == null || self.FinanceApproval().CostAmountTypeName == ""){
            //        alert("财务部预算审核未选择!");
            //        return false;
            //    }
            //}
            //if(self.ApprovalID() == 3){
            //    if(self.TenderApproval().AssetRangeName == null || self.TenderApproval().AssetRangeName == ""){
            //        alert(getValueByKey(language, translations, "Altassets"))
            //        $("#AssetClassification").focus();
            //        return false;
            //    }
            //if(self.TenderApproval().Quantity == null || self.TenderApproval().Quantity == ""){
            //    alert(getValueByKey(language, translations, "AltQuantity"));//"数量未填写!"
            //    $("#QuantityReview").focus();
            //    return false;
            //}
            //if(self.TenderApproval().CurrencyName == null || self.TenderApproval().CurrencyName == ""){
            //    alert(getValueByKey(language, translations, "AltCurrency"));//"币种未选择!"
            //    return false;
            //}
            //if(self.TenderApproval().ExchangeRate == null || self.TenderApproval().ExchangeRate == ""){
            //    alert(getValueByKey(language, translations, "Altexchange"));//"汇率未填写!"
            //    $("#ExchangeRateReview").focus();
            //    return false;
            //}
            //if(self.TenderApproval().UnitPrice == null || self.TenderApproval().UnitPrice == ""){
            //    alert(getValueByKey(language, translations, "AltPice"));//"单价未填写!"
            //    $("#UnitePriceReview").focus();
            //    return false;
            //}
            //if(self.TenderApproval().TotalAmount == null || self.TenderApproval().TotalAmount == ""){
            //    alert(getValueByKey(language, translations, "AltTotalAmount"));//"总金额未填写!"
            //    return false;
            //}
            //if(self.TenderApproval().BaseCurrencyTotalAmount == null || self.TenderApproval().BaseCurrencyTotalAmount == ""){
            //    alert(getValueByKey(language, translations, "AltTotalAmountRMB"));//"总金额(RMB)未填写!"
            //    return false;
            //}
            //if(self.TenderApproval().TaxRate == null || self.TenderApproval().TaxRate == ""){
            //    alert(getValueByKey(language, translations, "AlttaxRate"));//"税率未填写!"
            //    $("#TaxRateReview").focus();
            //    return false;
            //}



            //必填项判断
            debugger;
            if (self.OneStepEdit() == true && ActionName!="No6") {

                //self.selectedRole($("input[name='StepRadio']:checked").val());
                if (!self.selectedRole() > 0) {
                    alert("请选择审批角色!");
                    return false;
                }

                if ($.trim(self.TenderApproval().AssetRangeCode) == "") {
                    alert("国内或国外采购必须选择!");
                    return false;
                }

                if ($.trim(self.FinanceApproval().CostAmountTypeCode) == "") {
                    alert("财务预算必须选择!");
                    return false;
                }
            }


            var assetRulePass = true;//是否通过
            if (self.TwoStepEdit() == true) {

                debugger;

                //申请时普通资产不能在审批阶段转化为低资资产
                if (self.FixedAssets().LowvalueAssetFlag == null || self.FixedAssets().LowvalueAssetFlag == false)
                {
                    if (self.FactoryApproval().Classification == 6247)
                    {
                        alert("申请时的普通资产,审批阶段不能转为低资资产!When applying for ordinary assets, the approval stage cannot be turned into a low-grade asset!");
                        return false;
                    }
                }else{
                    if (self.FactoryApproval().Classification == 6246)
                    {
                        alert("申请时的低值资产,审批阶段不能转为固定资产!When applying for low-value assets, the approval stage cannot be turned into fixed assets!");
                        return false;
                    }
                }

                if ($.trim(self.AssetRuleId2()) == "") {
                    alert("所属公司必须选择!");
                    assetRulePass = false;
                    return false;
                }


                //做资产编号规则校验

                //测试资产规则

                //ruleJson.ASNO1 = "A";
                //ruleJson.ASCOM = "0";
                //ruleJson.ASNO2 = "00";
                //ruleJson.ASNO3 = "00";
                //ruleJson.ASNO4 = "01";
                //ruleJson.ASTRD = "0";
                //ruleJson.ASNO5 = "3";
                //ruleJson.COCEN = "B20120";



                var ruleJsons = new Array();
                ruleJsons.push(ruleJson);

                $.ajax({
                    type: "GET",
                    url: "/FixedAsset/CheckAssetRule",
                    data: { "ruleCode": JSON.stringify(ruleJsons) },
                    async: false,
                    cache: false,
                    dataType: "json",
                    success: function (data) {

                        debugger

                        if (data.flag == true) {
                            self.FactoryApproval().SAPRuleCode = data.msg;//SAP资产编号规则
                            assetRulePass = true;
                        }
                        else {
                            alert(data.msg);
                            assetRulePass = false;
                        }

                    },
                    error: function (failure) {
                        alert(failure.responseText);
                    }
                });

            }

            debugger

            //当技术主管部门为SMT的时候,技术主管部门审批允许改内管分组码,厂务部允许最后修改;
            if ((self.InnerTubeBlockCodeEdit())) {

                if ($.trim(self.FixedAssets().InnerTubeBlockCode) == "") {
                    alert("内管分组码没有填写哦:)(注意:此项是友情提醒,非强制要求)!");
                    //return false;//只提示,允许不填
                }
            }


            //if(self.TenderApproval().Remark == null || self.TenderApproval().Remark == ""){
            //    alert("详细描述未填写!")
            //    $("#QuantityReview").focus();
            //    return false;
            //}
            //}
            //if(self.ApprovalID() == 5){
            //    if(self.FactoryApproval().CustomsDeclaration == null || self.FactoryApproval().CustomsDeclaration == ""){
            //        alert("报关方式未选择!")
            //        $("#Customs_Declaration").focus();
            //        return false;
            //    }
            //    if(self.FactoryApproval().CustomsDeclarationUnit == null || self.FactoryApproval().CustomsDeclarationUnit == ""){
            //        alert("报关单位未选择!")
            //        return false;
            //    }
            //    if(self.FactoryApproval().DeclarationDate == null || self.FactoryApproval().DeclarationDate == ""){
            //        alert("日期未选择!");
            //        $("#DeclarationDateReview").focus();
            //        return false;
            //    }
            //}

            //self.formData = new FormData();
            //self.formData.append("ApprovalID", JSON.stringify(self.ApprovalID()));
            //self.formData.append("FinanceApproval", JSON.stringify(self.FinanceApproval()));
            //self.formData.append("TenderApproval", JSON.stringify(self.TenderApproval()));
            //self.formData.append("FactoryApproval", JSON.stringify(self.FactoryApproval()));
            //self.formData.append("ActionName", JSON.stringify(ActionName));
            //self.formData.append("WFListItemID", JSON.stringify(WFListItemID));
            //self.formData.append("UserID", JSON.stringify(UserID));
            //self.formData.append("UserName", JSON.stringify(UserName));
            //self.formData.append("WFWorkListAuditingID", JSON.stringify(WFWorkListAuditingID));

            //////向后台请求数据
            //$.ajax({
            //    type: "POST",
            //    enctype: "multipart/form-data",
            //    url: "/FixedAsset/ModifyDataSave",
            //    data: self.formData,
            //    cache: false,
            //    processData: false,
            //    contentType: false,
            //    success: function () {
            //        alert("ok!");
            //    },
            //    error: function (failure) {
            //        alert(failure.responseText);
            //    }
            //});



            if (assetRulePass == true) {

                //打包数据,使用表单进行提交
                var formData = new Object();

                var stepid = 0;

                if (self.OneStepEdit() == true) {
                    stepid = 1;
                }
                if (self.TwoStepEdit() == true) {
                    stepid = 2;
                }

                formData.Step = stepid;
                formData.SelectedRole = self.selectedRole();
                formData.FinanceApproval = self.FinanceApproval();
                formData.TenderApproval = self.TenderApproval();
                formData.FactoryApproval = self.FactoryApproval();
                formData.ActionName = ActionName;
                formData.WFListItemID = WFListItemID;
                formData.UserID = UserID;
                formData.UserName = UserName;
                formData.WFWorkListAuditingID = WFWorkListAuditingID;
                formData.OAMessage = OAMessage;///审批意见
                formData.OAFlowID = OAFlowID;//FlowID

                if ($.trim(self.FixedAssets().InnerTubeBlockCode) != "") {

                    formData.InnerTubeBlockCode = self.FixedAssets().InnerTubeBlockCode;//内管分组码
                }


                var jsonStr = JSON.stringify(formData);//序列化对象

                $("#Hidden1").val(jsonStr);

                $("#ajaxForm").ajaxSubmit({
                    success: function (data) {
                        if(data.Msg==""){
                            alert(getValueByKey(language, translations, "AltTrue"));//"提交成功!"
                            window.parent.postMessage("WindowClose", "*");
                        }else{
                            alert(getValueByKey(language, translations, "AltFalse"));//"提交失败!"
                        }
                        
                    },
                    error: function () {
                        alert(getValueByKey(language, translations, "AltFalse"));//"提交失败!"
                    }
                });


                ////直接传参数到后台
                //var innerTubeBlockCode = "";
                //if ($.trim(self.FixedAssets().InnerTubeBlockCode) != "") {

                // innerTubeBlockCode = self.FixedAssets().InnerTubeBlockCode;//内管分组码
                //}
                //var reslutStr = '{"Step":'+stepid+
                //                ',"SelectedRole":'+self.selectedRole()+
                //                ',"FinanceApproval":'+self.FinanceApproval()+
                //                ',"TenderApproval":'+self.TenderApproval()+
                //                ',"FactoryApproval":'+self.FactoryApproval()+
                //                ',"ActionName":'+ActionName+
                //                ',"WFListItemID":'+WFListItemID+
                //                ',"UserID":'+UserID+
                //                ',"UserName":'+UserName+
                //                ',"WFWorkListAuditingID":'+WFWorkListAuditingID+
                //                ',"OAMessage":'+OAMessage+
                //                ',"OAFlowID":'+OAFlowID+
                //                ',"InnerTubeBlockCode":'+innerTubeBlockCode+'}';
                //var viewModel = {
                //    Step:stepid,
                //    SelectedRole:self.selectedRole(),
                //    FinanceApproval:self.FinanceApproval(),
                //    TenderApproval:self.TenderApproval(),
                //    FactoryApproval:self.FactoryApproval(),
                //    ActionName:ActionName,
                //    WFListItemID:WFListItemID,
                //    UserID:UserID,
                //    WFWorkListAuditingID:WFWorkListAuditingID,
                //    OAMessage:OAMessage,
                //    OAFlowID:OAFlowID,
                //    InnerTubeBlockCode:innerTubeBlockCode
                //};
                //console.log( ko.toJSON(viewModel));
                //console.log(JSON.stringify(reslutStr));
                //console.log(reslutStr);
                //$.ajax({
                //    type: "POST",
                //    url: "/FixedAsset/ModifyDataSave",
                //    data: {"jsonStr":ko.toJSON(viewModel)},
                //    cache: false,
                //    dataType: "json",
                //    success: function (data) {
                //        if(data.Msg==""){
                //            alert(getValueByKey(language, translations, "AltTrue"));//"提交成功!"
                //            window.parent.postMessage("WindowClose", "*");
                //        }else{
                //            alert(getValueByKey(language, translations, "AltFalse"));//"提交失败!"
                //        }
                       
                //    },
                //    error: function (failure) {
                //        alert(getValueByKey(language, translations, "AltFalse"));//"提交失败!"
                //    }
                //});

            }

            //$("#ajaxForm").submit();
            ////setTimeout("sendMsg()",1000);
            //self.closeWindow();
        }

        //self.closeWindow = function (){

        //    window.parent.postMessage("WindowClose", "*");

        //}

        ////根据数量,单价,汇率  计算  总金额,总金额(RMB)
        //self.calculate = function(){

        //    if(self.TenderApproval().Quantity != null && self.TenderApproval().Quantity != ""
        //        && self.TenderApproval().UnitPrice != null && self.TenderApproval().UnitPrice != "")//数量和单价不为空
        //    {
        //        var quantity = parseFloat(self.TenderApproval().Quantity);
        //        var unitPrice = parseFloat(self.TenderApproval().UnitPrice);
        //        var totalAmount = quantity * unitPrice;//总价 = 数量 * 单价
        //        self.TenderApproval().TotalAmount = totalAmount.toFixed(2);
        //        //$("#TotalAmountReview").val(totalAmount);

        //        if(self.TenderApproval().ExchangeRate != null && self.TenderApproval().ExchangeRate != ""){
        //            var exchangeRate = parseFloat(self.TenderApproval().ExchangeRate);
        //            var baseCurrencyTotalAmount = totalAmount * exchangeRate;//RMB价格 = 总价 * 汇率
        //            self.TenderApproval().BaseCurrencyTotalAmount = baseCurrencyTotalAmount.toFixed(2);
        //            //$("#BaseCurrencyTotalAmountReview").val(baseCurrencyTotalAmount);
        //        }
        //        else{
        //            self.TenderApproval().BaseCurrencyTotalAmount = null;
        //            //$("#BaseCurrencyTotalAmountReview").val(null);
        //        }
        //    }
        //    else{
        //        //$("#TotalAmountReview").val(null);
        //        //$("#BaseCurrencyTotalAmountReview").val(null);
        //        self.TenderApproval().TotalAmount = null;
        //        self.TenderApproval().BaseCurrencyTotalAmount = null;
        //    }
        //    self.TenderApproval(self.TenderApproval());
        //}

        ////根据币种带出汇率
        //self.setExchangeRate = function (){

        //    self.TenderApproval().ExchangeRate = self.TenderApproval().CurrencyCode;
        //    self.calculate();
        //}

        ////根据输入内容查询抄送人员
        //self.checkCC = function(){

        //    if(self.CC_Condition() == null || self.CC_Condition() == ""){
        //        alert("查询内容不能为空");
        //        return false;
        //    }
        //    else{
        //        $.ajax({
        //            type: "GET",
        //            url: "/FixedAsset/CheckCC",
        //            data: {"cc":self.CC_Condition()},
        //            async: false,
        //            cache: false,
        //            dataType: "json",
        //            success: function (data) {
        //                if(data != null && data != ""){

        //                    self.CC_Condition(data);
        //                    //self.ShowBtn_AddCC(true);
        //                }
        //            },
        //            error: function (XMLHttpRequest) {
        //                //self.ShowBtn_AddCC(false);
        //                alert(XMLHttpRequest.readyState);
        //            }
        //        });
        //    }
        //}

        //将查询框中的抄送人员添加到抄送人员列表中
        self.addCC = function(){

            if(self.ApprovalID() == 1){
                self.checkCC("CC_Condition_1",$("#CC_Condition_1").val());
                //self.FinanceApproval().CarbonCopy = $("#CarbonCopy_Finance").val();
                if($("#CC_Condition_1").val() == null || $("#CC_Condition_1").val() == "")
                {
                    alert(getValueByKey(language, translations, "AltNotFindMsg"));//"未能找到人员信息!"
                    //autoComplete("#CC_Condition_1");
                    return false;
                }
                //carbonCopies = self.FinanceApproval().CarbonCopy;
                if(self.FinanceApproval().CarbonCopy == null){
                    self.FinanceApproval().CarbonCopy = $("#CC_Condition_1").val() + ";";
                }
                else{
                    self.FinanceApproval().CarbonCopy = self.FinanceApproval().CarbonCopy + $("#CC_Condition_1").val() + ";";
                }
                //$("#CarbonCopy_Finance").val(carbonCopies);
                self.FinanceApproval(self.FinanceApproval());

                showCC(self.FinanceApproval().CarbonCopy.split(";"),"#CC_Show_1");

                $("#CC_Condition_1").val(null);
                //autoComplete("#CC_Condition_1");
            }
            else if(self.ApprovalID() == 3){
                self.checkCC("CC_Condition_2",$("#CC_Condition_2").val());
                //self.TenderApproval().CarbonCopy = $("#CarbonCopy_Tender").val();
                if($("#CC_Condition_2").val() == null || $("#CC_Condition_2").val() == "")
                {
                    alert(getValueByKey(language, translations, "AltNotFindMsg"));//"未能找到人员信息!"
                    //autoComplete("#CC_Condition_2");
                    return false;
                }
                //carbonCopies = self.TenderApproval().CarbonCopy;
                if(self.TenderApproval().CarbonCopy == null){
                    self.TenderApproval().CarbonCopy = $("#CC_Condition_2").val() + ";";
                }
                else{
                    self.TenderApproval().CarbonCopy = self.TenderApproval().CarbonCopy + $("#CC_Condition_2").val() + ";";
                }
                //$("#CarbonCopy_Tender").val(carbonCopies);
                self.TenderApproval(self.TenderApproval());

                showCC(self.TenderApproval().CarbonCopy.split(";"),"#CC_Show_2");

                $("#CC_Condition_2").val(null);
                //autoComplete("#CC_Condition_2");
            }
            else if(self.ApprovalID() == 5){
                self.checkCC("CC_Condition_3",$("#CC_Condition_3").val());
                //self.FactoryApproval().CarbonCopy = $("#CarbonCopy_Factory").val();
                if($("#CC_Condition_3").val() == null || $("#CC_Condition_3").val() == "")
                {
                    alert(getValueByKey(language, translations, "AltNotFindMsg"));//"未能找到人员信息!"
                    //autoComplete("#CC_Condition_3");
                    return false;
                }
                //carbonCopies = self.FactoryApproval().CarbonCopy;
                if(self.FactoryApproval().CarbonCopy == null){
                    self.FactoryApproval().CarbonCopy = $("#CC_Condition_3").val() + ";";
                }
                else{
                    self.FactoryApproval().CarbonCopy = self.FactoryApproval().CarbonCopy + $("#CC_Condition_3").val() + ";";
                }
                //$("#CarbonCopy_Factory").val(carbonCopies);
                self.FactoryApproval(self.FactoryApproval());

                showCC(self.FactoryApproval().CarbonCopy.split(";"),"#CC_Show_3");

                $("#CC_Condition_3").val(null);
                //autoComplete("#CC_Condition_3");
            }

            //self.ShowBtn_AddCC(false);
        }


        self.checkCC = function (key,value){
            $.ajax({
                type: "GET",
                url: "/Contract/CheckApprover",
                data: { "ApproverKey": key , "ApproverValue": value },
                async: false,
                cache: false,
                dataType: "text",
                success: function (data) {
                    $("#"+key).val(data);
                },
                error: function (XMLHttpRequest) {
                    alert(XMLHttpRequest.readyState);
                }
            });
        }


        //$("#AssetRule").change(function () {


        //})


        //$("#AssetGroup").change(function () {
        //    debugger;
        //    var selectedValue = "";
        //    if (initFinished == true) {
        //        selectedValue = $(this).val();
        //    }
        //    else
        //    {
        //        selectedValue = self.RuleCode3();
        //    }

        //    if ($.trim(selectedValue) != "") {
        //        self.GetSonAssets(3, selectedValue);
        //    }
        //})

        //$("#AssetClass").change(function () {
        //    debugger;
        //    var selectedValue = "";
        //    if (initFinished == true) {
        //        selectedValue = $(this).val();
        //    }
        //    else {
        //        selectedValue = self.RuleCode4();
        //    }

        //    if ($.trim(selectedValue) != "") {
        //        self.GetSonAssets(4, selectedValue);
        //    }
        //})


        //$("#AssetType").change(function () {
        //    debugger;
        //    var selectedValue = "";
        //    if (initFinished == true) {
        //        selectedValue = $(this).val();
        //    }
        //    else {
        //        selectedValue = self.RuleCode5();
        //    }

        //    if ($.trim(selectedValue) != "") {
        //        self.GetSonAssets(5, selectedValue);
        //    }
        //})



        self.GetSonAssets = function (level, code) {

            if ($.trim(code) != "")
            {
                $.ajax({
                    type: "GET",
                    url: "/FixedAsset/GetSonAssets",
                    data: { "level": level, "code": code},
                    async: false,
                    cache: false,
                    dataType: "json",
                    success: function (data) {

                        switch (level)
                        {
                            case 1:
                                {
                                    self.AssetGroups(data);//一级
                                }
                                break;

                            case 3:
                                {
                                    self.AssetClasses(data);//三级
                                }
                                break;

                            case 4:
                                {
                                    self.AssetTypes(data);//明细
                                }
                                break;

                            case 5:
                                {
                                    self.AssetModels(data);//资产型号
                                }
                                break;

                            default:
                                { }
                                break;
                        }

                    },
                    error: function (failure) {
                        alert(failure.responseText);
                    }
                });
            }
        }


        self.InnerTubeBlockCodeEdit = ko.computed(function () {

            var innerTubeBlockCodeEdit = false;

            innerTubeBlockCodeEdit = (self.FixedAssets().TechnicalDepartmentCode == '16053') && (self.TwoStepEdit() || self.selectedRole() == 1);

            return innerTubeBlockCodeEdit;

        }, this);


    };


    var vm=new ViewModel();
    ko.applyBindings(vm);

    function assetChange(i) {

        var selectedValue = "";
        if (initFinished == true) {
            if (i == 1) {
                selectedValue = $("#AssetRule").val();
            }
            else if(i==3){
                selectedValue = $("#AssetGroup").val();
            }
            else if(i==4){
                selectedValue = $("#AssetClass").val();
            }
            else if(i==5){
                selectedValue = $("#AssetType").val();
            }
        }
        else
        {
            if (i == 1) {
                selectedValue = vm.AssetRuleId1();
            }
            else if(i==3){
                selectedValue = vm.AssetRuleId3();
            }
            else if(i==4){
                selectedValue = vm.AssetRuleId4();
            }
            else if(i==5){
                selectedValue = vm.AssetRuleId5();
            }
        }

        if ($.trim(selectedValue) != "") {
            vm.GetSonAssets(i, selectedValue);
        }
    }


    //修改时间格式
    function formatterTime(value, formatStr) {

        //YYYY-MM-DD HH:mm:ss

        formatStr = formatStr || "YYYY-MM-DD HH:mm:ss";

        if (value) {
            var s = value;
            s = s.replace("/Date(", "").replace(")/", "");
            var date = new Date(parseInt(s));
            date = moment(date).format(formatStr);
            return date;
        }
        else {
            return value;
        }
    }

    //位数不够前面补0
    function prefixInteger(num, length) {
        return (Array(length).join('0') + num).slice(-length);
    }

    translatePage(language, translations);
</script>

猜你喜欢

转载自blog.csdn.net/csdn_cSharp/article/details/83027581