Просмотр исходного кода

OMS发票信息部分代码上传

徐滕 4 недель назад
Родитель
Сommit
c7885f6c0d

+ 7 - 0
src/main/java/com/jeeplus/modules/workinvoice/dao/WorkInvoiceReceiptDao.java

@@ -22,4 +22,11 @@ import java.util.List;
 public interface WorkInvoiceReceiptDao extends CrudDao<WorkInvoiceReceipt> {
 
     void delByInvoiceId(@Param("invoiceId") String invoiceId);
+
+    /**
+     * 根据发票编号查询已经收款的信息
+     * @param invoiceNumberList
+     * @return
+     */
+    List<WorkInvoiceReceipt> getByInvoiceNumber(@Param("list") List<String> invoiceNumberList);
 }

+ 9 - 0
src/main/java/com/jeeplus/modules/workinvoice/entity/WorkInvoiceReceipt.java

@@ -17,6 +17,7 @@ public class WorkInvoiceReceipt extends DataEntity<WorkInvoiceReceipt> {
     private String receiptDate;  //汇款时间
     private String createName;
     private String updateName;
+    private String invoiceNumber;
 
     public String getCreateName() {
         return createName;
@@ -65,4 +66,12 @@ public class WorkInvoiceReceipt extends DataEntity<WorkInvoiceReceipt> {
     public void setReceiptDate(String receiptDate) {
         this.receiptDate = receiptDate;
     }
+
+    public String getInvoiceNumber() {
+        return invoiceNumber;
+    }
+
+    public void setInvoiceNumber(String invoiceNumber) {
+        this.invoiceNumber = invoiceNumber;
+    }
 }

+ 153 - 16
src/main/java/com/jeeplus/modules/workinvoice/service/WorkInvoiceService.java

@@ -1730,6 +1730,8 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 	 */
 	@Transactional(readOnly = false)
 	public String auditSaveBranch(WorkInvoice workInvoice,List<User> auditUsers) {
+		//用于判定是否是生产环境,是否开启oms开具发票功能
+		boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 			//所属部门
 			Office office = officeService.get(workInvoice.getOffice().getId());
 			String userName = UserUtils.get(workInvoice.getCreateBy().getId()).getName();
@@ -1857,8 +1859,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 							notifyRole = "审批通过";
 							workActivityProcess.setIsApproval("1");
 
-							//用于判定是否是生产环境,是否开启oms开具发票功能
-							boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 							if(OMS_ENABLED){
 								//需要判定,此处 如果开票金额为正数,则表示是开蓝票,如果是负数,则表示是开红票
 								if(workInvoice.getMoney()>0){
@@ -1867,12 +1867,26 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 								}else{
 									//先获取对应红冲发票的数电票  票号
 									//查询关联红冲发票的开票号
-									if(1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
-										String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
-										workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+									if(1 == workInvoice.getRedInvoiceFlag()){
+										if(StringUtils.isBlank(workInvoice.getInvoiceNumberStr())){
+											if(StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+												String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
+												workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+											}
+										}
+										String invoiceNumber = workInvoice.getInvoiceNumberStr();
+										//判断 如果发票小于10位,则表示为老发票红冲,需要按照老方法进行处理
+										if (invoiceNumber == null || invoiceNumber.isEmpty() || invoiceNumber.length() < 10) {
+											OMS_ENABLED = false;
+										}
+										if(OMS_ENABLED && StringUtils.isBlank(invoiceNumber)){
+											return "红冲发票号不存在,无法进行红冲!";
+										}
+									}
+									if(OMS_ENABLED){
+										//还需要获取被红冲发票的对应invoice信息
+										new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(), "21").start();
 									}
-									//还需要获取被红冲发票的对应invoice信息
-									new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(), "21").start();
 								}
 							}
 
@@ -1933,7 +1947,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 		if (!state) {
 
 			//用于判定是否是生产环境,是否开启oms开具发票功能
-			boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 			if(OMS_ENABLED){
 				//将数据流程接点重新归属到审批状态不变,等发票开启之后 进行变更为审核通过,若失败,则变更为暂存状态并发送通知
 				users.add(workInvoice.getCreateBy());
@@ -2509,6 +2522,8 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 	 */
 	@Transactional(readOnly = false)
 	public String saveWorkInvoiceNotProjectAudit(WorkInvoice workInvoice,List<User> auditUsers) {
+		//用于判定是否是生产环境,是否开启oms开具发票功能
+		boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 		//所属部门
 		Office office = officeService.get(workInvoice.getOffice().getId());
 		String userName = UserUtils.get(workInvoice.getCreateBy().getId()).getName();
@@ -2644,8 +2659,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 						notifyRole = "审批通过";
 						workActivityProcess.setIsApproval("1");
 
-						//用于判定是否是生产环境,是否开启oms开具发票功能
-						boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 						if(OMS_ENABLED){
 							//需要判定,此处 如果开票金额为正数,则表示是开蓝票,如果是负数,则表示是开红票
 							if(workInvoice.getMoney()>0){
@@ -2654,12 +2667,26 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 							}else{
 								//先获取对应红冲发票的数电票  票号
 								//查询关联红冲发票的开票号
-								if(1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
-									String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
-									workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+								if(1 == workInvoice.getRedInvoiceFlag()){
+									if(StringUtils.isBlank(workInvoice.getInvoiceNumberStr())){
+										if(StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+											String invoiceNumberStr = this.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
+											workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+										}
+									}
+									String invoiceNumber = workInvoice.getInvoiceNumberStr();
+									//判断 如果发票小于10位,则表示为老发票红冲,需要按照老方法进行处理
+									if (invoiceNumber == null || invoiceNumber.isEmpty() || invoiceNumber.length() < 10) {
+										OMS_ENABLED = false;
+									}
+									if(OMS_ENABLED && StringUtils.isBlank(invoiceNumber)){
+										return "红冲发票号不存在,无法进行红冲!";
+									}
+								}
+								if(OMS_ENABLED){
+									//还需要获取被红冲发票的对应invoice信息
+									new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(),"213").start();
 								}
-								//还需要获取被红冲发票的对应invoice信息
-								new RedApprovalThread(workInvoice,workInvoice.getInvoiceNumberStr(),"213").start();
 							}
 						}
 
@@ -2716,7 +2743,6 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 		if (!state) {
 
 			//用于判定是否是生产环境,是否开启oms开具发票功能
-			boolean OMS_ENABLED = StringUtils.isNotBlank(omsEnabled) && Boolean.parseBoolean(omsEnabled);
 			if(OMS_ENABLED){
 				//将数据流程接点重新归属到审批状态不变,等发票开启之后 进行变更为审核通过,若失败,则变更为暂存状态并发送通知
 				users.add(workInvoice.getCreateBy());
@@ -4612,4 +4638,115 @@ public class WorkInvoiceService extends CrudService<WorkInvoiceDao, WorkInvoice>
 
 		return isSuccess;
 	}
+
+
+
+
+
+
+	/**
+	 * 查询同项目名称、价格、材料名称的数量是否只有一个
+	 */
+	public Map<String, List<WorkInvoiceReceiptInfo>> distinctProjectMaterialStorage(
+			List<WorkInvoiceReceiptInfo> workInvoiceReceiptInfo) {
+
+		HashMap<String, List<WorkInvoiceReceiptInfo>> map = new HashMap<>();
+
+		// 第一步:对本次导入数据进行去重(自身重复)
+		Set<String> seen = new HashSet<>();
+		List<WorkInvoiceReceiptInfo> uniqueList = new ArrayList<>();      // 本次去重后的有效值
+		List<WorkInvoiceReceiptInfo> duplicateList = new ArrayList<>();   // 本次自身重复值
+
+		for (WorkInvoiceReceiptInfo item : workInvoiceReceiptInfo) {
+			String distinctStr = item.getDistinctStr();
+
+			// 处理null值(视为重复)
+			if (distinctStr == null) {
+				duplicateList.add(item);
+				continue;
+			}
+
+			if (!seen.contains(distinctStr)) {
+				seen.add(distinctStr);
+				uniqueList.add(item);
+			} else {
+				duplicateList.add(item);
+			}
+		}
+
+		//对有效值进行发票查询操作,如果已经存在记录 则表示 给该数据存在问题(重复上传)
+		List<String> invoiceNumberList = Lists.newArrayList();
+		for (WorkInvoiceReceiptInfo invoiceReceiptInfo : uniqueList) {
+			invoiceNumberList.add(invoiceReceiptInfo.getInvoiceNumber());
+		}
+		//根据 invoiceNumberList 去进行查询已经存在的数据信息
+		List<WorkInvoiceReceipt> alreadyExistReceiptList = workInvoiceReceiptDao.getByInvoiceNumber(invoiceNumberList);
+
+		//遍历有效值和查出来的已经存在的收款信息进行对比,若存在同一发票号的信息,金额进行累加,若金额大于应收金额,则表示该条数据存在问题,所小于则表示部分收款,若等于 则表示完全收款,改成已收款
+		for (WorkInvoiceReceipt workInvoiceReceipt : alreadyExistReceiptList) {
+			for (WorkInvoiceReceiptInfo invoiceReceiptInfo : uniqueList) {
+				if(workInvoiceReceipt.getInvoiceNumber().equals(invoiceReceiptInfo.getInvoiceNumber())){
+
+				}
+				invoiceNumberList.add(invoiceReceiptInfo.getInvoiceNumber());
+			}
+		}
+
+
+		// 第二步:获取历史数据并处理其distinctStr
+		/*List<WorkInvoiceReceiptInfo> historyInfoList = dao.getByProjectId(projectId);
+		for (WorkInvoiceReceiptInfo info : historyInfoList) {
+			// 组合历史数据的distinctStr(材料名称+规格+含税价格)
+			// 处理可能的null值,转为空字符串
+			String invoiceName = (info.getInvoiceNumber() != null) ? info.getInvoiceNumber() : "";
+			String buyerName = (info.getBuyerName() != null) ? info.getBuyerName() : "";
+			String money = (info.getMoney() != null) ? info.getMoney().toString() : "";
+			// 以逗号分隔组合
+			String resultStr = invoiceName + "," + buyerName + "," + money;
+		}
+
+		// 第三步:筛选历史数据中的distinctStr,用于比对
+		Set<String> historyDistinctSet = new HashSet<>();
+		for (WorkInvoiceReceiptInfo historyItem : historyInfoList) {
+			String historyDistinctStr = historyItem.getDistinctStr();
+			if (historyDistinctStr != null) {
+				historyDistinctSet.add(historyDistinctStr);
+			}
+		}
+
+		// 第四步:从uniqueList中移除与历史数据重复的项,并加入重复列表
+		// 使用迭代器支持边遍历边删除
+		Iterator<WorkInvoiceReceiptInfo> iterator = uniqueList.iterator();
+		while (iterator.hasNext()) {
+			WorkInvoiceReceiptInfo currentItem = iterator.next();
+			String currentDistinctStr = currentItem.getDistinctStr();
+
+			// 处理null值(从uniqueList移除并加入重复列表)
+			if (currentDistinctStr == null) {
+				iterator.remove();
+				duplicateList.add(currentItem);
+				continue;
+			}
+
+			// 与历史数据重复:从uniqueList移除并加入重复列表
+			if (historyDistinctSet.contains(currentDistinctStr)) {
+				iterator.remove();
+				duplicateList.add(currentItem);
+			}
+		}
+
+		// 1. 提取duplicateList中所有数据的唯一标识(distinctStr)
+		Set<String> duplicateDistinctSet = new HashSet<>();
+		for (WorkInvoiceReceiptInfo item : duplicateList) {
+			String distinctStr = item.getDistinctStr();
+			if (distinctStr != null) {
+				duplicateDistinctSet.add(distinctStr);
+			}
+		}*/
+
+		// 最终返回处理后的列表
+		map.put("uniqueList", uniqueList);      // 仅包含本次新增且不与历史重复的数据
+		map.put("duplicateList", duplicateList); // 包含自身重复和与历史重复的数据
+		return map;
+	}
 }

+ 94 - 0
src/main/java/com/jeeplus/modules/workinvoice/web/WorkInvoiceAllController.java

@@ -20,6 +20,7 @@ import com.jeeplus.common.web.BaseController;
 import com.jeeplus.modules.act.entity.Act;
 import com.jeeplus.modules.act.service.ActTaskService;
 import com.jeeplus.modules.act.utils.ActUtils;
+import com.jeeplus.modules.projectmaterialstorage.entity.ProjectMaterialStorageImport;
 import com.jeeplus.modules.projectrecord.entity.ProjectRecords;
 import com.jeeplus.modules.projectrecord.enums.ProjectStatusEnum;
 import com.jeeplus.modules.projectrecord.service.ProjectRecordsService;
@@ -370,6 +371,13 @@ public class WorkInvoiceAllController extends BaseController {
 		if(StringUtils.isNotBlank(workInvoice.getId())){
 			workInvoiceService.queryDetails(workInvoice);
 		}
+
+		//查询关联红冲发票的开票号
+		if(StringUtils.isNotBlank(workInvoice.getId()) && 1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+			String invoiceNumberStr = workInvoiceService.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
+			workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+		}
+
 		String tabId = request.getParameter("tabId");
 		String isSzCloud = workInvoice.getIsSzCloud();
 		if (StringUtils.isNotBlank(isSzCloud) && isSzCloud.equals("sz")){
@@ -1627,4 +1635,90 @@ public class WorkInvoiceAllController extends BaseController {
 	}
 
 
+
+
+	/**
+	 * 导入Excel数据
+
+	 */
+	//@RequiresPermissions("workinvoice:workInvoice:importReceiptDataFile")
+	@RequestMapping(value = "importReceiptDataFile", method=RequestMethod.POST)
+	public Map<String, Object> importReceiptDataFile(MultipartFile file, RedirectAttributes redirectAttributes, Map map) {// 初始化返回结果Map
+		Map<String, Object> result = new HashMap<>();
+
+
+		List<WorkInvoiceReceiptInfo> workInvoiceReceiptInfoList = Lists.newArrayList();
+
+
+		//对相对有效的数据进行处理
+		//有效的数据
+		List<WorkInvoiceReceiptInfo> effectiveList = Lists.newArrayList();
+		//错误的数据
+		List<WorkInvoiceReceiptInfo> errorList = Lists.newArrayList();
+
+		try {
+			int successNum = 0;
+			int failureNum = 0;
+			StringBuilder failureMsg = new StringBuilder();
+			ImportExcel ei = new ImportExcel(file, 1, 0);
+			List<WorkInvoiceReceiptInfo> list = ei.getDataList(WorkInvoiceReceiptInfo.class);
+
+			//此处需要修改为迭代器形式
+			Iterator<WorkInvoiceReceiptInfo> iterator = list.iterator();
+			while (iterator.hasNext()){
+				WorkInvoiceReceiptInfo workInvoiceReceiptInfo = iterator.next();
+				if(StringUtils.isBlank(workInvoiceReceiptInfo.getInvoiceNumber()) || StringUtils.isBlank(workInvoiceReceiptInfo.getBuyerName()) || null == workInvoiceReceiptInfo.getMoney() ){
+					if(StringUtils.isNotBlank(workInvoiceReceiptInfo.getInvoiceNumber())){
+						workInvoiceReceiptInfo.setErrorMessage("数据中发票号");
+					}else if(StringUtils.isNotBlank(workInvoiceReceiptInfo.getBuyerName())){
+						workInvoiceReceiptInfo.setErrorMessage("数据中缺少购买企业名称");
+					}else if(null == workInvoiceReceiptInfo.getMoney()){
+						workInvoiceReceiptInfo.setErrorMessage("数据中缺少金额");
+					}
+					errorList.add(workInvoiceReceiptInfo);
+					iterator.remove();
+				}else{
+					effectiveList.add(workInvoiceReceiptInfo);
+				}
+			}
+
+			//对有效的数据进行去重处理
+			for (WorkInvoiceReceiptInfo info : effectiveList) {
+				// 处理可能的null值,转为空字符串
+				String invoiceName = (info.getInvoiceNumber() != null) ? info.getInvoiceNumber() : "";
+				String buyerName = (info.getBuyerName() != null) ? info.getBuyerName() : "";
+				String money = (info.getMoney() != null) ? info.getMoney().toString() : "";
+				// 以逗号分隔组合
+				String resultStr = invoiceName + "," + buyerName + "," + money;
+				info.setDistinctStr(resultStr);
+			}
+
+
+			Map<String,List<WorkInvoiceReceiptInfo>> map1 = invoiceService.distinctProjectMaterialStorage(effectiveList);
+
+
+
+			/*for (WorkInvoiceReceiptInfo workInvoice : list){
+				try{
+					workInvoiceService.save(workInvoice);
+					successNum++;
+				}catch(ConstraintViolationException ex){
+					failureNum++;
+					logger.error("Exception e:"+ex);
+				}catch (Exception ex) {
+					failureNum++;
+					logger.error("Exception e:"+ex);
+				}
+			}*/
+			if (failureNum>0){
+				failureMsg.insert(0, ",失败 "+failureNum+" 条发票管理记录。");
+			}
+			addMessage(redirectAttributes, "已成功导入 "+successNum+" 条发票管理记录"+failureMsg);
+		} catch (Exception e) {
+			addMessage(redirectAttributes, "导入发票管理失败!失败信息:"+e.getMessage());
+			logger.error("Exception e:"+e);
+		}
+		return map;
+	}
+
 }

+ 6 - 0
src/main/java/com/jeeplus/modules/workinvoice/web/WorkInvoiceTwoController.java

@@ -322,6 +322,12 @@ public class WorkInvoiceTwoController extends BaseController {
 			workInvoice.setActualDrawerName(user.getName());
 		}
 		String tabId = request.getParameter("tabId");
+
+		//查询关联红冲发票的开票号
+		if(StringUtils.isNotBlank(workInvoice.getId()) && 1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+			String invoiceNumberStr = workInvoiceService.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
+			workInvoice.setInvoiceNumberStr(invoiceNumberStr);
+		}
 		if("1".equals(tabId)){
 			List<MainDictDetail> billingContentList = DictUtils.getMainDictList("billing_content");
 			for (MainDictDetail dictDetail: billingContentList) {

+ 2 - 2
src/main/java/com/jeeplus/modules/workprojectnotify/web/WorkProjectNotifyController.java

@@ -2284,7 +2284,7 @@ public class WorkProjectNotifyController extends BaseController {
 					}
 
 					//查询关联红冲发票的开票号
-					if(1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+					if(StringUtils.isNotBlank(workInvoice.getId()) && 1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
 						String invoiceNumberStr = workInvoiceService.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
 						workInvoice.setInvoiceNumberStr(invoiceNumberStr);
 					}
@@ -11005,7 +11005,7 @@ public class WorkProjectNotifyController extends BaseController {
 		}
 
 		//查询关联红冲发票的开票号
-		if("1".equals(workInvoice.getRedInvoiceFlag()) && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
+		if(StringUtils.isNotBlank(workInvoice.getId()) && 1 == workInvoice.getRedInvoiceFlag() && StringUtils.isNotBlank(workInvoice.getRedInvoiceRelevancyId())){
 			String invoiceNumberStr = workInvoiceService.getInvoiceNumberStr(workInvoice.getRedInvoiceRelevancyId());
 			workInvoice.setInvoiceNumberStr(invoiceNumberStr);
 		}

+ 1 - 1
src/main/resources/jeeplus.properties

@@ -431,4 +431,4 @@ omsBankAccount: 7329010182600006811
 #omsUrl: https://oms-sandbox.einvoice.js.cn:7079
 omsUrl: https://www.oms.ejinshui-cloud.com:8899
 #用于判定是否开启oms开票流程事件
-omsEnabled: false
+omsEnabled: true

+ 19 - 0
src/main/resources/mappings/modules/workinvoice/WorkInvoiceReceiptDao.xml

@@ -94,4 +94,23 @@
 		DELETE FROM work_invoice_receipt
 		WHERE invoice_id = #{invoiceId}
 	</update>
+
+
+	<select id="getByInvoiceNumber" resultType="WorkInvoiceReceipt" >
+		SELECT
+		<include refid="workInvoiceColumns"/>
+		,wid.number
+		FROM work_invoice_receipt a
+		left join work_invoice_detail wid on wid.invoice_id = a.invoice_id
+		<where>
+			a.del_flag = #{DEL_FLAG_NORMAL}
+
+			<if test="list!=null and list.size!=0">
+				and wid.invoice_number in
+				<foreach collection="list" item="invoiceNumber" separator="," open="(" close=")">
+					#{invoiceNumber}
+				</foreach>
+			</if>
+		</where>
+	</select>
 </mapper>

+ 76 - 7
src/main/webapp/webpage/modules/workinvoice/workInvoiceAuditEnd.jsp

@@ -66,6 +66,77 @@
                   return;
               }
 
+			  if(obj == 1){
+				  var redInvoiceFlag = '${workInvoice.redInvoiceFlag}';//后端获取红票标识
+				  if(undefined == redInvoiceFlag || null == redInvoiceFlag || '' == redInvoiceFlag || redInvoiceFlag == "0"){
+					  // 非红票分支:无任何校验(发票号+表格)
+				  }else{
+					  // 红票分支:初始化变量
+					  var relatedInvoice = $('input:radio[name="relatedInvoice"]:checked').val();// 红冲原因值
+					  var needCheckTable = false; // 【核心】表格校验开关,默认不校验
+					  var invoiceNum = ""; // 初始化发票号变量,解决作用域问题
+
+					  // 规则1:红冲原因≠0 → 先校验发票号(8/20位纯数字)
+					  if (relatedInvoice !== "0") {
+						  var invoiceResult = null;
+						  invoiceNum = $.trim($("#invoiceNumberStr").val());// 发票号去空格取值
+						  var numReg = /^\d+$/;
+						  // 发票号校验:有值+纯数字+8/20位
+						  if (invoiceNum && numReg.test(invoiceNum) && (invoiceNum.length === 8 || invoiceNum.length === 20)) {
+							  invoiceResult = invoiceNum;
+						  }
+
+						  // 发票号校验失败:弹框提示并终止
+						  if (invoiceResult === null) {
+							  if (!invoiceNum) {
+								  top.layer.alert('红冲的发票号无值:数电发票号不能为空,请重新填写!', {icon: 0});
+								  return;
+							  } else if (!numReg.test(invoiceNum)) {
+								  top.layer.alert('红冲的发票号格式错误:数电发票号必须为纯数字,请重新填写!', {icon: 0});
+								  return;
+							  } else if (invoiceNum.length !== 8 && invoiceNum.length !== 20) {
+								  top.layer.alert('红冲的发票号长度错误:数电发票号要求8位或20位纯数字,请重新填写!', {icon: 0});
+								  return;
+							  }
+						  }
+
+						  // 【关键】发票号校验通过后,按长度设置表格校验开关
+						  needCheckTable = (invoiceNum.length === 8); // 8位→需要校验,20位→不校验
+					  }
+
+					  // 规则2:红冲原因=0 → 直接设置表格校验开关为true(必须填写)
+					  if (relatedInvoice === "0") {
+						  needCheckTable = true;
+					  }
+
+					  // 【最终】仅当表格校验开关为true时,执行表格非空校验
+					  if (needCheckTable) {
+						  var $tableTrs = $("#workAccountList tr");// 获取表格所有行
+						  var rowCount = $tableTrs.length;
+						  if (rowCount > 0) {
+							  var isEmpty = false;
+							  var emptyRow = 0;
+							  // 逐行遍历校验:第三个td→第一个input,去空格判空
+							  $tableTrs.each(function(index, tr) {
+								  var inputVal = $.trim($(tr).find("td:eq(2) input:first").val());
+								  if (!inputVal) {
+									  isEmpty = true;
+									  emptyRow = index + 1;// 行号从1开始,方便用户定位
+									  return false;// 找到空值立即终止遍历,提升效率
+								  }
+							  });
+							  // 表格有空值:弹框提示并终止后续逻辑
+							  if (isEmpty) {
+								  top.layer.alert('发票明细表第'+ emptyRow +'行的发票号不能为空,请填写!', {icon: 0});
+								  return;
+							  }
+						  }
+					  }
+					  // 表格校验开关为false时(20位发票号),直接跳过所有表格校验
+				  }
+			  }
+
+
 			  $("#inputForm").submit();
 			  return true;
 		  }
@@ -119,14 +190,12 @@
 				var relatedInvoice = '${workInvoice.relatedInvoice}';//后端获取值
 				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
 					document.getElementsByName("relatedInvoice")[1].checked = true;
-					$(".redInvoice").hide();
-					$(".redFlushReason").hide();
+					$(".redInvoice").show();
 					$(".situationDetail").show();
 
 				}else{
 					document.getElementsByName("relatedInvoice")[0].checked = true;
 					$(".redInvoice").show();
-					$(".redFlushReason").show();
 					$(".situationDetail").hide();
 				}
 			}
@@ -731,7 +800,7 @@
 					<input type="radio" name="redFlushReason" disabled lay-filter="redFlushReasonRadio" title="销售折让" value="04">
 				</div>
 			</div>
-			<div class="layui-item layui-col-sm12 with-textarea situationDetail">
+			<div class="layui-item layui-col-sm12 with-textarea redInvoice">
 				<label class="layui-form-label double-line"><span class="require-item">*</span>红冲情况说明:</label>
 				<div class="layui-input-block">
 					<form:textarea path="situationDetail" readonly="true" htmlEscape="false" rows="4" class="form-control" style="background-color: #f1f1f1" />
@@ -745,9 +814,9 @@
 				</div>
 			</div>
 			<div class="layui-item layui-col-sm6 redInvoice">
-				<label class="layui-form-label">关联发票号:</label>
+				<label class="layui-form-label" style=" font-weight: bold;color: red;">关联发票号:</label>
 				<div class="layui-input-block">
-					<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
+					<input id="invoiceNumberStr" name="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 				</div>
 			</div>
 			<%--<div class="layui-item layui-col-sm12">
@@ -1007,7 +1076,7 @@
 									<input id="workAccountList{{idx}}_code" name="workAccountList[{{idx}}].code" type="text" value="{{row.code}}"    class="form-control number"/>
 								 </td>
 								 <td>
-									<input id="workAccountList{{idx}}_number" name="workAccountList[{{idx}}].number" readonly placeholder="系统自动生成" style="background-color: #f1f1f1" onchange="checkSame(this)" type="text" value="{{row.number}}"  minlength="8" maxlength="8"  class="form-control number"/>
+									<input id="workAccountList{{idx}}_number" name="workAccountList[{{idx}}].number"  placeholder="蓝票自动生成,红票需要手填" onchange="checkSame(this)" type="text" value="{{row.number}}"  minlength="20" maxlength="20"  class="form-control number"/>
 									 <input type="hidden" id="workAccountList{{idx}}_oldNumber" value="{{row.number}}"/>
 								 </td>
 								<td>

+ 2 - 2
src/main/webapp/webpage/modules/workinvoice/workInvoiceModify.jsp

@@ -296,7 +296,7 @@
 				document.getElementsByName("redInvoiceFlag")[1].checked = true;
 				$(".relatedInvoice").hide();
 				$(".redInvoice").hide();
-				$(".redFlushReason").hide();
+				$(".redFlushReason").show();
 				$(".situationDetail").hide();
 			}else{
 				document.getElementsByName("redInvoiceFlag")[0].checked = true;
@@ -305,7 +305,7 @@
 				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
 					document.getElementsByName("relatedInvoice")[1].checked = true;
 					$(".redInvoice").hide();
-					$(".redFlushReason").hide();
+					$(".redFlushReason").show();
 					$(".situationDetail").show();
 				}else{
 					document.getElementsByName("relatedInvoice")[0].checked = true;

+ 48 - 4
src/main/webapp/webpage/modules/workinvoice/workInvoiceNotProjectAudit.jsp

@@ -48,14 +48,39 @@
 				var form = layui.form;
 				form.render();
 			});
+
+
+
+			var redFlushReason = '${workInvoice.redFlushReason}';//后端获取值
+			if(redFlushReason == "01"){
+				document.getElementsByName("redFlushReason")[0].checked = true;
+			}
+			if(redFlushReason == "04"){
+				document.getElementsByName("redFlushReason")[1].checked = true;
+			}
+
 			var redInvoiceFlag = '${workInvoice.redInvoiceFlag}';//后端获取值
 			if(undefined == redInvoiceFlag || null == redInvoiceFlag || '' == redInvoiceFlag || redInvoiceFlag == "0"){
 				document.getElementsByName("redInvoiceFlag")[1].checked = true;
+				$(".relatedInvoice").hide();
+				$(".redFlushReason").hide();
 				$(".redInvoice").hide();
+				$(".situationDetail").hide();
+				// 恢复invoiceNumberStr只读
+				$("#invoiceNumberStr").attr("readonly", "true");
 			}else{
 				document.getElementsByName("redInvoiceFlag")[0].checked = true;
-				$(".redInvoice").show();
-
+				$(".relatedInvoice").show();
+				var relatedInvoice = '${workInvoice.relatedInvoice}';//后端获取值
+				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
+					document.getElementsByName("relatedInvoice")[1].checked = true;
+					$(".redInvoice").show();
+					$(".situationDetail").show();
+				}else{
+					document.getElementsByName("relatedInvoice")[0].checked = true;
+					$(".redInvoice").show();
+					$(".situationDetail").hide();
+				}
 			}
 			$("#name").focus();
 			validateForm = $("#inputForm").validate({
@@ -637,7 +662,26 @@
 						<input type="radio" name="redInvoiceFlag" disabled lay-filter="redInvoiceFlagRadio" title="否" value="0">
 					</div>
 				</div>
-
+				<div class="layui-item layui-col-sm6 relatedInvoice">
+					<label class="layui-form-label"><span class="require-item">*</span>是否关联发票:</label>
+					<div class="layui-input-block">
+						<input type="radio" name="relatedInvoice" disabled lay-filter="relatedInvoiceRadio" title="是" value="1">
+						<input type="radio" name="relatedInvoice" disabled lay-filter="relatedInvoiceRadio" title="否" value="0">
+					</div>
+				</div>
+				<div class="layui-item layui-col-sm6 redFlushReason">
+					<label class="layui-form-label "><span class="require-item">*</span>红冲原因:</label>
+					<div class="layui-input-block">
+						<input type="radio" name="redFlushReason" disabled lay-filter="redFlushReasonRadio" title="发票有误" value="01">
+						<input type="radio" name="redFlushReason" disabled lay-filter="redFlushReasonRadio" title="销售折让" value="04">
+					</div>
+				</div>
+				<div class="layui-item layui-col-sm12 with-textarea redInvoice">
+					<label class="layui-form-label double-line"><span class="require-item">*</span>红冲情况说明:</label>
+					<div class="layui-input-block">
+						<form:textarea path="situationDetail" readonly="true" htmlEscape="false" rows="4" class="form-control" style="background-color: #f1f1f1" />
+					</div>
+				</div>
 				<div class="layui-item layui-col-sm6 redInvoice">
 					<label class="layui-form-label"><span class="require-item">*</span>关联红字发票:</label>
 					<div class="layui-input-block">
@@ -648,7 +692,7 @@
 				<div class="layui-item layui-col-sm6 redInvoice">
 					<label class="layui-form-label">关联发票号:</label>
 					<div class="layui-input-block">
-						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value=""/>
+						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 					</div>
 				</div>
 				<%--<div class="layui-item layui-col-sm12">

+ 118 - 7
src/main/webapp/webpage/modules/workinvoice/workInvoiceNotProjectAuditEnd.jsp

@@ -66,6 +66,77 @@
                   return;
               }
 
+			  if(obj == 1){
+				  var redInvoiceFlag = '${workInvoice.redInvoiceFlag}';//后端获取红票标识
+				  if(undefined == redInvoiceFlag || null == redInvoiceFlag || '' == redInvoiceFlag || redInvoiceFlag == "0"){
+					  // 非红票分支:无任何校验(发票号+表格)
+				  }else{
+					  // 红票分支:初始化变量
+					  var relatedInvoice = $('input:radio[name="relatedInvoice"]:checked').val();// 红冲原因值
+					  var needCheckTable = false; // 【核心】表格校验开关,默认不校验
+					  var invoiceNum = ""; // 初始化发票号变量,解决作用域问题
+
+					  // 规则1:红冲原因≠0 → 先校验发票号(8/20位纯数字)
+					  if (relatedInvoice !== "0") {
+						  var invoiceResult = null;
+						  invoiceNum = $.trim($("#invoiceNumberStr").val());// 发票号去空格取值
+						  var numReg = /^\d+$/;
+						  // 发票号校验:有值+纯数字+8/20位
+						  if (invoiceNum && numReg.test(invoiceNum) && (invoiceNum.length === 8 || invoiceNum.length === 20)) {
+							  invoiceResult = invoiceNum;
+						  }
+
+						  // 发票号校验失败:弹框提示并终止
+						  if (invoiceResult === null) {
+							  if (!invoiceNum) {
+								  top.layer.alert('红冲的发票号无值:数电发票号不能为空,请重新填写!', {icon: 0});
+								  return;
+							  } else if (!numReg.test(invoiceNum)) {
+								  top.layer.alert('红冲的发票号格式错误:数电发票号必须为纯数字,请重新填写!', {icon: 0});
+								  return;
+							  } else if (invoiceNum.length !== 8 && invoiceNum.length !== 20) {
+								  top.layer.alert('红冲的发票号长度错误:数电发票号要求8位或20位纯数字,请重新填写!', {icon: 0});
+								  return;
+							  }
+						  }
+
+						  // 【关键】发票号校验通过后,按长度设置表格校验开关
+						  needCheckTable = (invoiceNum.length === 8); // 8位→需要校验,20位→不校验
+					  }
+
+					  // 规则2:红冲原因=0 → 直接设置表格校验开关为true(必须填写)
+					  if (relatedInvoice === "0") {
+						  needCheckTable = true;
+					  }
+
+					  // 【最终】仅当表格校验开关为true时,执行表格非空校验
+					  if (needCheckTable) {
+						  var $tableTrs = $("#workAccountList tr");// 获取表格所有行
+						  var rowCount = $tableTrs.length;
+						  if (rowCount > 0) {
+							  var isEmpty = false;
+							  var emptyRow = 0;
+							  // 逐行遍历校验:第三个td→第一个input,去空格判空
+							  $tableTrs.each(function(index, tr) {
+								  var inputVal = $.trim($(tr).find("td:eq(2) input:first").val());
+								  if (!inputVal) {
+									  isEmpty = true;
+									  emptyRow = index + 1;// 行号从1开始,方便用户定位
+									  return false;// 找到空值立即终止遍历,提升效率
+								  }
+							  });
+							  // 表格有空值:弹框提示并终止后续逻辑
+							  if (isEmpty) {
+								  top.layer.alert('发票明细表第'+ emptyRow +'行的发票号不能为空,请填写!', {icon: 0});
+								  return;
+							  }
+						  }
+					  }
+					  // 表格校验开关为false时(20位发票号),直接跳过所有表格校验
+				  }
+			  }
+
+
 			  $("#inputForm").submit();
 			  return true;
 		  }
@@ -86,14 +157,35 @@
 				form.render();
 			});
 
+			var redFlushReason = '${workInvoice.redFlushReason}';//后端获取值
+			if(redFlushReason == "01"){
+				document.getElementsByName("redFlushReason")[0].checked = true;
+			}
+			if(redFlushReason == "04"){
+				document.getElementsByName("redFlushReason")[1].checked = true;
+			}
+
 			var redInvoiceFlag = '${workInvoice.redInvoiceFlag}';//后端获取值
 			if(undefined == redInvoiceFlag || null == redInvoiceFlag || '' == redInvoiceFlag || redInvoiceFlag == "0"){
 				document.getElementsByName("redInvoiceFlag")[1].checked = true;
+				$(".relatedInvoice").hide();
+				$(".redFlushReason").hide();
 				$(".redInvoice").hide();
+				$(".situationDetail").hide();
 			}else{
 				document.getElementsByName("redInvoiceFlag")[0].checked = true;
-				$(".redInvoice").show();
-
+				$(".relatedInvoice").show();
+				var relatedInvoice = '${workInvoice.relatedInvoice}';//后端获取值
+				console.log(relatedInvoice)
+				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
+					document.getElementsByName("relatedInvoice")[1].checked = true;
+					$(".redInvoice").show();
+					$(".situationDetail").show();
+				}else{
+					document.getElementsByName("relatedInvoice")[0].checked = true;
+					$(".redInvoice").show();
+					$(".situationDetail").hide();
+				}
 			}
 			$("#name").focus();
 			validateForm = $("#inputForm").validate({
@@ -681,7 +773,26 @@
 					<input type="radio" name="redInvoiceFlag" disabled lay-filter="redInvoiceFlagRadio" title="否" value="0">
 				</div>
 			</div>
-
+			<div class="layui-item layui-col-sm6 relatedInvoice">
+				<label class="layui-form-label"><span class="require-item">*</span>是否关联发票:</label>
+				<div class="layui-input-block">
+					<input type="radio" name="relatedInvoice" disabled lay-filter="relatedInvoiceRadio" title="是" value="1">
+					<input type="radio" name="relatedInvoice" disabled lay-filter="relatedInvoiceRadio" title="否" value="0">
+				</div>
+			</div>
+			<div class="layui-item layui-col-sm6 redFlushReason">
+				<label class="layui-form-label "><span class="require-item">*</span>红冲原因:</label>
+				<div class="layui-input-block">
+					<input type="radio" name="redFlushReason" disabled lay-filter="redFlushReasonRadio" title="发票有误" value="01">
+					<input type="radio" name="redFlushReason" disabled lay-filter="redFlushReasonRadio" title="销售折让" value="04">
+				</div>
+			</div>
+			<div class="layui-item layui-col-sm12 with-textarea redInvoice">
+				<label class="layui-form-label double-line"><span class="require-item">*</span>红冲情况说明:</label>
+				<div class="layui-input-block">
+					<form:textarea path="situationDetail" readonly="true" htmlEscape="false" rows="4" class="form-control" style="background-color: #f1f1f1" />
+				</div>
+			</div>
 			<div class="layui-item layui-col-sm6 redInvoice">
 				<label class="layui-form-label"><span class="require-item">*</span>关联红字发票:</label>
 				<div class="layui-input-block">
@@ -690,9 +801,9 @@
 				</div>
 			</div>
 			<div class="layui-item layui-col-sm6 redInvoice">
-				<label class="layui-form-label">关联发票号:</label>
+				<label class="layui-form-label" style=" font-weight: bold;color: red;">关联发票号:</label>
 				<div class="layui-input-block">
-					<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value=""/>
+					<input id="invoiceNumberStr" name="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 				</div>
 			</div>
 			<%--<div class="layui-item layui-col-sm12">
@@ -748,7 +859,7 @@
 			<div class="layui-item layui-col-sm12 with-textarea">
 				<label class="layui-form-label double-line">备注:</label>
 				<div class="layui-input-block">
-					<form:textarea path="remarks" readonly="true" htmlEscape="false" rows="4" class="form-control" style="background-color: #f1f1f1" />
+					<form:textarea path="remarks" htmlEscape="false" rows="4" class="form-control" />
 				</div>
 			</div>
 
@@ -923,7 +1034,7 @@
 									<input id="workAccountList{{idx}}_code" name="workAccountList[{{idx}}].code" type="text" value="{{row.code}}"    class="form-control number"/>
 								 </td>
 								 <td>
-									<input id="workAccountList{{idx}}_number" name="workAccountList[{{idx}}].number" onchange="checkSame(this)" type="text" value="{{row.number}}"  minlength="8" maxlength="8"  class="form-control number"/>
+									<input id="workAccountList{{idx}}_number" name="workAccountList[{{idx}}].number" placeholder="蓝票自动生成,红票需要手填" onchange="checkSame(this)" type="text" value="{{row.number}}"  minlength="20" maxlength="20"  class="form-control number"/>
 									 <input type="hidden" id="workAccountList{{idx}}_oldNumber" value="{{row.number}}"/>
 								 </td>
 								<td>

+ 3 - 3
src/main/webapp/webpage/modules/workinvoice/workInvoiceNotProjectModify.jsp

@@ -266,7 +266,7 @@
 			if(undefined == redInvoiceFlag || null == redInvoiceFlag || '' == redInvoiceFlag || redInvoiceFlag == "0"){
 				document.getElementsByName("redInvoiceFlag")[1].checked = true;
 				$(".relatedInvoice").hide();
-				$(".redFlushReason").hide();
+				$(".redFlushReason").show();
 				$(".redInvoice").hide();
 				$(".situationDetail").hide();
 			}else{
@@ -276,7 +276,7 @@
 				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
 					document.getElementsByName("relatedInvoice")[1].checked = true;
 					$(".redInvoice").hide();
-					$(".redFlushReason").hide();
+					$(".redFlushReason").show();
 					$(".situationDetail").show();
 				}else{
 					document.getElementsByName("relatedInvoice")[0].checked = true;
@@ -1324,7 +1324,7 @@
 				<div class="layui-item layui-col-sm6 redInvoice">
 					<label class="layui-form-label">关联发票号:</label>
 					<div class="layui-input-block">
-						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value=""/>
+						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 					</div>
 				</div>
 				<%--<div class="layui-item layui-col-sm12 with-textarea">

+ 33 - 29
src/main/webapp/webpage/modules/workinvoice/workInvoiceTwoForm.jsp

@@ -103,24 +103,28 @@
 					}
 
 					// 根据红冲原因校验金额
-					var redFlushReason=$('input:radio[name="redFlushReason"]:checked').val();
-					var moneyStr = $("#moneyStr").val()
-					var money =$("#money").val()
-					if ($(".redFlushReason").is(":visible")) {
-						if (redFlushReason == "01") {
-							if (money != -Math.abs(moneyStr)) {
-								parent.layer.msg("发票金额必须和需要红冲的金额相同", {icon: 0});
-								return false;
+					var relatedInvoiceVal = $("input[name='relatedInvoice']:checked").val();
+					if(relatedInvoiceVal === "1"){
+						var redFlushReason=$('input:radio[name="redFlushReason"]:checked').val();
+						var moneyStr = $("#moneyStr").val()
+						var money =$("#money").val()
+						if ($(".redFlushReason").is(":visible")) {
+							if (redFlushReason == "01") {
+								if (money != -Math.abs(moneyStr)) {
+									parent.layer.msg("发票金额必须和需要红冲的金额相同", {icon: 0});
+									return false;
+								}
 							}
-						}
-						if (redFlushReason == "04") {
-							if (money <= -Math.abs(moneyStr)) {
-								parent.layer.msg("发票金额必须小于红冲的金额", {icon: 0});
-								return false;
+							if (redFlushReason == "04") {
+								if (money <= -Math.abs(moneyStr)) {
+									parent.layer.msg("发票金额必须小于红冲的金额", {icon: 0});
+									return false;
+								}
 							}
 						}
 					}
 
+
 					if($('#actualDrawerEmailAddress').val()==null||$('#actualDrawerEmailAddress').val()=="") {
 						parent.layer.msg("请填写电子邮箱!", {icon: 5});
 						return false;
@@ -185,12 +189,10 @@
 				if(undefined == relatedInvoice || null == relatedInvoice || '' == relatedInvoice || relatedInvoice == "0"){
 					document.getElementsByName("relatedInvoice")[1].checked = true;
 					$(".redInvoice").hide();
-					$(".redFlushReason").hide();
 					$(".situationDetail").show();
 				}else{
 					document.getElementsByName("relatedInvoice")[0].checked = true;
 					$(".redInvoice").show();
-					$(".redFlushReason").show();
 					$(".situationDetail").hide();
 				}
 			}
@@ -253,7 +255,6 @@
 					if (radioVal == "1") {
 						$('textarea[name="situationDetail"]').val('');
 						$(".situationDetail").hide();
-						$(".redFlushReason").show();
 						$(".redInvoice").show();
 					} else {
 						// 切换时清空数据
@@ -261,7 +262,6 @@
 						$("#redInvoiceRelevancyIdName").val("");
 						$("#invoiceNumberStr").val("")
 						$(".redInvoice").hide();
-						$(".redFlushReason").hide();
 						$(".situationDetail").show();
 					}
 					form.render("radio");
@@ -270,20 +270,24 @@
 
 				// 监听红冲原因变化
 				form.on('radio(redFlushReasonRadio)', function (event) {
-					var radioVal = $(this).val();
-					var moneyStr = $("#moneyStr").val()
-					var money =$("#money").val()
-					console.log(money, -Math.abs(moneyStr))
-					if (radioVal == "01") {
-						if(money != -Math.abs(moneyStr)){
-							parent.layer.msg("发票金额必须和需要红冲的金额相同",{icon:0});
+					var relatedInvoiceVal = $("input[name='relatedInvoice']:checked").val();
+					if(relatedInvoiceVal === "1"){
+						var radioVal = $(this).val();
+						var moneyStr = $("#moneyStr").val()
+						var money =$("#money").val()
+						console.log(money, -Math.abs(moneyStr))
+						if (radioVal == "01") {
+							if(money != -Math.abs(moneyStr)){
+								parent.layer.msg("发票金额必须和需要红冲的金额相同",{icon:0});
+							}
 						}
-					}
-					if (radioVal == "04") {
-						if(money <= -Math.abs(moneyStr)){
-							parent.layer.msg("发票金额必须小于红冲的金额",{icon:0});
+						if (radioVal == "04") {
+							if(money <= -Math.abs(moneyStr)){
+								parent.layer.msg("发票金额必须小于红冲的金额",{icon:0});
+							}
 						}
 					}
+
 					form.render("radio");
 				});
 
@@ -1423,7 +1427,7 @@
 				<div class="layui-item layui-col-sm6 redInvoice">
 					<label class="layui-form-label">关联发票号:</label>
 					<div class="layui-input-block">
-						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value=""/>
+						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 					</div>
 				</div>
 

+ 1 - 1
src/main/webapp/webpage/modules/workinvoice/workInvoiceTwoModify.jsp

@@ -1275,7 +1275,7 @@
 				<div class="layui-item layui-col-sm6 redInvoice">
 					<label class="layui-form-label">关联发票号:</label>
 					<div class="layui-input-block">
-						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value=""/>
+						<input id="invoiceNumberStr" htmlEscape="false" readonly="true" class="form-control layui-input" value="${workInvoice.invoiceNumberStr}"/>
 					</div>
 				</div>
 				<%--<div class="layui-item layui-col-sm12 with-textarea">