瀏覽代碼

付款流程

ouyj 1 周之前
父節點
當前提交
de88c707f8

+ 35 - 0
src/main/contract/com/yw/contract/paymentApply/action/AccountAction.java

@@ -91,6 +91,10 @@ public class AccountAction  extends BaseAction {
 			this.downloadFromJdy(request, response);
 			this.path = "ajax";
 			return;
+		} else if ("setDefaultAccount".equals(task)) {//设置默认账号
+			this.setDefaultAccount(request, response);
+			this.path = "ajax";
+			return;
 		}
 	} 
 
@@ -308,6 +312,37 @@ public class AccountAction  extends BaseAction {
 		}
 	}
 		
+	/**
+	 * 设置默认账号
+	 */
+	private void setDefaultAccount(HttpServletRequest request, HttpServletResponse response) throws Exception {
+		accountService = this.getBean(AccountService.class, "accountService");
+		String universalid = request.getParameter("universalid");
+			
+		try {
+			if (StringUtil.isEmpty(universalid)) {
+				response.getWriter().print("{\"success\":false,\"message\":\"参数错误\"}");
+				return;
+			}
+				
+			// 获取账户信息
+			Account account = new Account();
+			account.setUniversalid(StringUtil.strToLong(universalid));
+				
+			// 调用服务层方法设置默认账号
+			String result = accountService.setDefaultAccount(account, (OASession) oasession);
+				
+			if ("success".equals(result)) {
+				response.getWriter().print("{\"success\":true,\"message\":\"设置成功\"}");
+			} else {
+				response.getWriter().print("{\"success\":false,\"message\":\"" + result + "\"}");
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			response.getWriter().print("{\"success\":false,\"message\":\"" + e.getMessage() + "\"}");
+		}
+	}
+		
 	/************************************ 获取数据用 ***********************************/
 
 	public Account getAccount() {

+ 33 - 2
src/main/contract/com/yw/contract/paymentApply/action/PaymentApplyAction.java

@@ -28,7 +28,9 @@ import com.yw.contract.common.sync.mes.MesCommonHelper;
 import com.yw.contract.common.sync.jdy.JdyHelper;
 import com.yw.contract.common.sync.jdy.JdyCommonHelper;
 import com.yw.contract.paymentApply.model.PaymentApply;
+import com.yw.contract.paymentApply.model.Account;
 import com.yw.contract.paymentApply.service.PaymentApplyService;
+import com.yw.contract.paymentApply.service.AccountService;
 import com.kingdee.service.data.entity.SettlementAccountListRes;
 import com.kingdee.service.data.entity.SettlementAccountListResRow;
 import com.yw.core.framework.view.service.PagerService;
@@ -123,6 +125,17 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		String department = oasession.getGroup().getGroupName();
 		String depid = oasession.getGroup().getId().toString();
 		String applyDate = DateUtil.getCurrDate("yyyy-MM-dd");  
+		
+		// 获取默认账户信息
+		AccountService accountService = this.getBean(AccountService.class, "accountService");
+		Account defaultAccount = accountService.getDefaultAccount(oasession.getUnit().getId());
+		if (defaultAccount != null) {
+			paymentApply.setBankName(defaultAccount.getOpeningBank());
+			paymentApply.setBankAccount(defaultAccount.getAccount());
+			paymentApply.setAccountId(defaultAccount.getAccountId());
+			paymentApply.setAccountName(defaultAccount.getName());
+		}
+		
 		request.setAttribute("initiator", initiator);
 		request.setAttribute("applyDate", applyDate);
 		request.setAttribute("department", department);
@@ -779,6 +792,11 @@ public class PaymentApplyAction  extends BpmBaseAction {
 	private String toSelectPurchaseOrder(HttpServletRequest request, HttpServletResponse response) throws Exception {
 		request.setAttribute("checkValue", request.getParameter("checkValue"));
 		request.setAttribute("checkbox", request.getParameter("checkbox"));
+		String vendorCode = request.getParameter("vendorCode");
+		if(StringUtils.isNotEmpty(vendorCode)){
+			vendorCode=URLDecoder.decode(vendorCode,"utf-8"); 
+		}
+		request.setAttribute("vendorCode", vendorCode);
 		return "/yw/contract/paymentApply/selectPurchaseOrder.jsp";
 	}
 	
@@ -787,9 +805,13 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		String p = request.getParameter("p");
 		String pSize = request.getParameter("pSize");
 		String purchaseName = request.getParameter("purchaseName");
+		String vendorCode = request.getParameter("vendorCode");
 		if(StringUtils.isNotEmpty(purchaseName)){
 			purchaseName=URLDecoder.decode(purchaseName,"utf-8"); 
 		}
+		if(StringUtils.isNotEmpty(vendorCode)){
+			vendorCode=URLDecoder.decode(vendorCode,"utf-8"); 
+		}
 		int n_p;
 		int n_pSize;
 		if (StringUtils.isNumeric(p)) {
@@ -805,7 +827,7 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		}		
 		
 		MesCommonHelper mesCommonHelper = new MesCommonHelper();
-        JSONObject resp = mesCommonHelper.getPurchases(n_p, n_pSize, purchaseName);
+        JSONObject resp = mesCommonHelper.getPurchases(n_p, n_pSize, purchaseName, vendorCode);
         int total = resp.getInt("total");
         // 获取 rows 数组 
         org.json.JSONArray rowsArray = resp.getJSONArray("rows");    
@@ -818,6 +840,11 @@ public class PaymentApplyAction  extends BpmBaseAction {
 	private String toSelectStorageOrder(HttpServletRequest request, HttpServletResponse response) throws Exception {
 		request.setAttribute("checkValue", request.getParameter("checkValue"));
 		request.setAttribute("checkbox", request.getParameter("checkbox"));
+		String vendorCode = request.getParameter("vendorCode");
+		if(StringUtils.isNotEmpty(vendorCode)){
+			vendorCode=URLDecoder.decode(vendorCode,"utf-8"); 
+		}
+		request.setAttribute("vendorCode", vendorCode);
 		return "/yw/contract/paymentApply/selectStorageOrder.jsp";
 	}
 	
@@ -826,9 +853,13 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		String p = request.getParameter("p");
 		String pSize = request.getParameter("pSize");
 		String recptName = request.getParameter("recptName");
+		String vendorCode = request.getParameter("vendorCode");
 		if(StringUtils.isNotEmpty(recptName)){
 			recptName=URLDecoder.decode(recptName,"utf-8");
 		}
+		if(StringUtils.isNotEmpty(vendorCode)){
+			vendorCode=URLDecoder.decode(vendorCode,"utf-8");
+		}
 		int n_p;
 		int n_pSize;
 		if (StringUtils.isNumeric(p)) {
@@ -844,7 +875,7 @@ public class PaymentApplyAction  extends BpmBaseAction {
 		}
 
 		MesCommonHelper mesCommonHelper = new MesCommonHelper();
-        JSONObject resp = mesCommonHelper.getItemrecpts(n_p, n_pSize, recptName);
+        JSONObject resp = mesCommonHelper.getItemrecpts(n_p, n_pSize, recptName, vendorCode);
         int total = resp.getInt("total");
         // 获取 rows 数组
         org.json.JSONArray rowsArray = resp.getJSONArray("rows");

+ 24 - 0
src/main/contract/com/yw/contract/paymentApply/dao/AccountDao.java

@@ -81,4 +81,28 @@ public interface AccountDao {
 	 * @throws Exception
 	 */
 	List<Account> queryByAccount(Account account) throws Exception;
+	
+	/**
+	 * 取消所有默认账号
+	 * @param unitId 单位ID
+	 * @return 更新数量
+	 * @throws Exception
+	 */
+	int cancelAllDefaultAccounts(Long unitId) throws Exception;
+	
+	/**
+	 * 设置默认账号
+	 * @param universalid 账户ID
+	 * @return 更新数量
+	 * @throws Exception
+	 */
+	int setDefaultAccount(Long universalid) throws Exception;
+	
+	/**
+	 * 查询默认账户
+	 * @param unitId 单位ID
+	 * @return 默认账户,如果没有则返回null
+	 * @throws Exception
+	 */
+	Account getDefaultAccount(Long unitId) throws Exception;
 }

+ 29 - 3
src/main/contract/com/yw/contract/paymentApply/dao/AccountDaoImpl.java

@@ -67,7 +67,7 @@ public class AccountDaoImpl extends BaseDao implements AccountDao {
 	public List<Account> accountList(int n_p, int n_pSize, ParameterHelper ph,
 			Account account) throws Exception {
 		StringBuffer sb = new StringBuffer("SELECT t.universalid,t.name,t.number,t.account,"
-				+ "t.account_name,t.opening_bank,t.sync_status,t.account_id,"
+				+ "t.account_name,t.opening_bank,t.sync_status,t.is_default,t.account_id,"
 				+ "t.remark,t.creator,t.create_time,t.unit_id "
 				+ " FROM oa_account t WHERE 1=1  ");
 		if (null != ph.getParam("name") && !"".equals(ph.getParam("name"))) {
@@ -125,7 +125,7 @@ public class AccountDaoImpl extends BaseDao implements AccountDao {
 	@Override
 	public List<Account> checkDuplicate(Account account) throws Exception {
 		StringBuffer sb = new StringBuffer("SELECT t.universalid,t.name,t.number,t.account,"
-				+ "t.account_name,t.opening_bank,t.sync_status,t.account_id,"
+				+ "t.account_name,t.opening_bank,t.sync_status,t.is_default,t.account_id,"
 				+ "t.remark,t.creator,t.create_time,t.unit_id "
 				+ " FROM oa_account t WHERE 1=1  ");
 		
@@ -158,7 +158,7 @@ public class AccountDaoImpl extends BaseDao implements AccountDao {
 	@Override
 	public List<Account> queryByAccount(Account account) throws Exception {
 		StringBuffer sb = new StringBuffer("SELECT t.universalid,t.name,t.number,t.account,"
-				+ "t.account_name,t.opening_bank,t.sync_status,t.account_id,"
+				+ "t.account_name,t.opening_bank,t.sync_status,t.is_default,t.account_id,"
 				+ "t.remark,t.creator,t.create_time,t.unit_id "
 				+ " FROM oa_account t WHERE 1=1  ");
 		
@@ -172,6 +172,31 @@ public class AccountDaoImpl extends BaseDao implements AccountDao {
 		
 		return jdbcTemplate.query(sb.toString(), new AccountRowMapper());
 	}
+	
+	@Override
+	public int cancelAllDefaultAccounts(Long unitId) throws Exception {
+		String sql = "UPDATE oa_account SET is_default = 0 WHERE unit_id = ? AND is_default = 1";
+		return jdbcTemplate.update(sql, unitId);
+	}
+	
+	@Override
+	public int setDefaultAccount(Long universalid) throws Exception {
+		String sql = "UPDATE oa_account SET is_default = 1 WHERE universalid = ?";
+		return jdbcTemplate.update(sql, universalid);
+	}
+	
+	@Override
+	public Account getDefaultAccount(Long unitId) throws Exception {
+		String sql = "SELECT t.universalid,t.name,t.number,t.account,"
+				+ "t.account_name,t.opening_bank,t.sync_status,t.is_default,t.account_id,"
+				+ "t.remark,t.creator,t.create_time,t.unit_id "
+				+ " FROM oa_account t WHERE t.unit_id = ? AND t.is_default = 1";
+		List<Account> list = jdbcTemplate.query(sql, new AccountRowMapper(), unitId);
+		if (list != null && list.size() > 0) {
+			return list.get(0);
+		}
+		return null;
+	}
 
 	private static class AccountRowMapper implements org.springframework.jdbc.core.RowMapper<Account> {
 		@Override
@@ -184,6 +209,7 @@ public class AccountDaoImpl extends BaseDao implements AccountDao {
 			account.setAccountName(rs.getString("account_name"));
 			account.setOpeningBank(rs.getString("opening_bank"));
 			account.setSyncStatus(rs.getInt("sync_status"));
+			account.setIsDefault(rs.getInt("is_default"));
 			account.setAccountId(rs.getString("account_id"));
 			account.setRemark(rs.getString("remark"));
 			account.setCreator(rs.getLong("creator"));

+ 11 - 0
src/main/contract/com/yw/contract/paymentApply/model/Account.java

@@ -34,6 +34,9 @@ public class Account {
 	@Column(name="sync_status",type=Types.INTEGER)
 	private Integer syncStatus;			//同步状态,0 未同步,1 已同步
 	
+	@Column(name="is_default",type=Types.INTEGER)
+	private Integer isDefault;			//是否默认账号,0 否,1 是
+	
 	@Column(name="account_id",type=Types.VARCHAR)
 	private String accountId;			//金蝶云账号 ID
 	
@@ -105,6 +108,14 @@ public class Account {
 		this.syncStatus = syncStatus;
 	}
 
+	public Integer getIsDefault() {
+		return isDefault;
+	}
+
+	public void setIsDefault(Integer isDefault) {
+		this.isDefault = isDefault;
+	}
+
 	public String getAccountId() {
 		return accountId;
 	}

+ 48 - 4
src/main/contract/com/yw/contract/paymentApply/model/PaymentApply.java

@@ -47,12 +47,24 @@ public class PaymentApply {
 	@Column(name="payee_name",type=Types.VARCHAR)
 	private String payeeName;			//收款单位
 	
+	@Column(name="contract_id",type=Types.BIGINT)
+	private Long contractId;			//合同ID
+	
+	@Column(name="contract_number",type=Types.VARCHAR)
+	private String contractNumber;		//合同编号
+	
+	@Column(name="contract_name",type=Types.VARCHAR)
+	private String contractName;		//合同名称
+	
 	@Column(name="bank_name",type=Types.VARCHAR)
 	private String bankName;			//开户行
 	
 	@Column(name="bank_account",type=Types.VARCHAR)
 	private String bankAccount;			//账号
 	
+	@Column(name="payee_bank_account",type=Types.VARCHAR)
+	private String payeeBankAccount;		//收款方开户行及账号
+	
 	@Column(name="payment_method",type=Types.VARCHAR)
 	private String paymentMethod;		//付款方式
 	
@@ -134,8 +146,8 @@ public class PaymentApply {
 	@Column(name="account_name",type=Types.VARCHAR)
 	private String accountName;			//账号名称
 
-	@Column(name="order_id_from_mes",type=Types.BIGINT)
-	private Long orderIdFromMes;			//MES 订单 ID
+	@Column(name="order_id_from_mes",type=Types.VARCHAR)
+	private String orderIdFromMes;			//MES 订单 ID
 
 	public Long getUniversalid() {
 		return universalid;
@@ -225,6 +237,30 @@ public class PaymentApply {
 		this.payeeName = payeeName;
 	}
 
+	public Long getContractId() {
+		return contractId;
+	}
+
+	public void setContractId(Long contractId) {
+		this.contractId = contractId;
+	}
+
+	public String getContractNumber() {
+		return contractNumber;
+	}
+
+	public void setContractNumber(String contractNumber) {
+		this.contractNumber = contractNumber;
+	}
+
+	public String getContractName() {
+		return contractName;
+	}
+
+	public void setContractName(String contractName) {
+		this.contractName = contractName;
+	}
+
 	public String getBankName() {
 		return bankName;
 	}
@@ -241,6 +277,14 @@ public class PaymentApply {
 		this.bankAccount = bankAccount;
 	}
 
+	public String getPayeeBankAccount() {
+		return payeeBankAccount;
+	}
+
+	public void setPayeeBankAccount(String payeeBankAccount) {
+		this.payeeBankAccount = payeeBankAccount;
+	}
+
 	public String getPaymentMethod() {
 		return paymentMethod;
 	}
@@ -457,11 +501,11 @@ public class PaymentApply {
 		this.accountName = accountName;
 	}
 
-	public Long getOrderIdFromMes() {
+	public String getOrderIdFromMes() {
 		return orderIdFromMes;
 	}
 
-	public void setOrderIdFromMes(Long orderIdFromMes) {
+	public void setOrderIdFromMes(String orderIdFromMes) {
 		this.orderIdFromMes = orderIdFromMes;
 	}
 }

+ 17 - 0
src/main/contract/com/yw/contract/paymentApply/service/AccountService.java

@@ -65,4 +65,21 @@ public interface AccountService {
 	 * @throws Exception
 	 */
 	public Map<String, Integer> downloadFromJdy(OASession oasession) throws Exception;
+	
+	/**
+	 * 设置默认账号
+	 * @param account 账户对象
+	 * @param oasession 会话信息
+	 * @return 设置结果
+	 * @throws Exception
+	 */
+	public String setDefaultAccount(Account account, OASession oasession) throws Exception;
+	
+	/**
+	 * 获取默认账户
+	 * @param unitId 单位ID
+	 * @return 默认账户,如果没有则返回null
+	 * @throws Exception
+	 */
+	public Account getDefaultAccount(Long unitId) throws Exception;
 }

+ 38 - 0
src/main/contract/com/yw/contract/paymentApply/service/AccountServiceImpl.java

@@ -245,4 +245,42 @@ public class AccountServiceImpl implements AccountService{
 		return result;
 	}
 	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public String setDefaultAccount(Account account, OASession oasession) throws Exception {
+		try {
+			// 获取账户信息
+			Account existAccount = accountDao.getAccount(account);
+			if (existAccount == null || existAccount.getUniversalid() == null) {
+				throw new Exception("账户不存在");
+			}
+			
+			// 检查条件:开户行和卡号不能为空,并且是已同步的数据
+			/*if (StringUtils.isEmpty(existAccount.getOpeningBank())) {
+				throw new Exception("开户行不能为空");
+			}
+			if (StringUtils.isEmpty(existAccount.getAccount())) {
+				throw new Exception("卡号不能为空");
+			}*/
+			if (existAccount.getSyncStatus() == null || existAccount.getSyncStatus() != 1) {
+				throw new Exception("只能设置已同步的账户为默认账号");
+			}
+			
+			// 取消当前单位下所有默认账号
+			accountDao.cancelAllDefaultAccounts(oasession.getUnit().getId());
+			
+			// 设置当前账户为默认账号
+			accountDao.setDefaultAccount(existAccount.getUniversalid());
+			
+			return "success";
+		} catch (Exception e) {
+			throw new Exception("设置默认账号失败:" + e.getMessage());
+		}
+	}
+	
+	@Override
+	public Account getDefaultAccount(Long unitId) throws Exception {
+		return accountDao.getDefaultAccount(unitId);
+	}
+	
 }

+ 46 - 1
src/main/webapp/yw/contract/paymentApply/accountList.jsp

@@ -70,6 +70,17 @@ function loadAccountList(params) {
 									name : 'createTime',
 									width : 200
 								},
+								{ 
+									display: '是否默认', 
+									name: 'isDefault',
+									render: function (item) {
+										if(item.isDefault == 1) {
+											return '<span style="color:red;font-weight:bold;">是</span>';
+										}else{
+											return '否';
+										}
+									}
+								},
 								{
 									display : '操作',
 									isAllowHide : false,
@@ -86,7 +97,12 @@ function loadAccountList(params) {
 											html += '<a href="#" onclick="syncToJdy('
 												+ row.universalid
 												+ ')">同步金蝶云</a>&nbsp;';
-										//}
+										//} 
+										if(row.name && row.name != '' && row.accountId && row.accountId != '' && row.syncStatus == 1 && row.isDefault != 1){
+											html += '<a href="#" onclick="setDefaultAccount('
+												+ row.universalid
+												+ ')">设为默认</a>&nbsp;';
+										}
 										html += '<a href="#" onclick="deleteAccount('
 											+ row.universalid
 											+ ')">删除</a>';
@@ -200,6 +216,35 @@ function deleteAccount(universalid){
 	}
 }
 
+function setDefaultAccount(universalid){
+	if(confirm('确定要设置为默认账号吗?设置后其他默认账号将自动取消。')){
+		$.ajax({
+			url: '${pageContext.request.contextPath }/accountAction.do?task=setDefaultAccount',
+			type: 'post',
+			data: {
+				universalid: universalid
+			},
+			success: function(result){
+				try{
+					var data = eval('(' + result + ')');
+					if(data.success){
+						alert('设置成功!');
+						// 刷新列表
+						searchByKword();
+					}else{
+						alert('设置失败:' + data.message);
+					}
+				}catch(e){
+					alert('设置异常!');
+				}
+			},
+			error: function(){
+				alert('设置请求失败!');
+			}
+		});
+	}
+}
+
 function downloadAccounts(){
 	if(confirm('确定要从金蝶云下载账户信息吗?\n系统将自动同步所有账户')){
 		var dialogWarn = $.ligerDialog.waitting('正在从金蝶云获取账户列表,请稍候...', {

+ 231 - 11
src/main/webapp/yw/contract/paymentApply/js/paymentApply.js

@@ -1,11 +1,49 @@
+// 验证收款单位是否已选择且有供应商编码
+function validatePayeeForOrderSelection() {
+    var payeeName = $('#payeeName').val();
+    var vendorCode = $('#vendorCode').val();
+    
+    if (!payeeName) {
+        $.ligerDialog.warn('请先选择收款单位!');
+        return false;
+    }
+    
+    if (!vendorCode) {
+        $.ligerDialog.warn('手动输入的收款单位不能选择采购订单/入库单,请选择供应商!');
+        return false;
+    }
+    
+    return true;
+}
+
 // 采购订单选择功能
 function selectPurchaseOrder() {
+    // 验证收款单位
+    if (!validatePayeeForOrderSelection()) {
+        return;
+    }
+    
+    // 检查是否已选择合同或入库单,如果有则提示并阻止
+    var contractId = $('#contractId').val();
+    var storageOrderNo = $('#storageOrderNo').val();
+    if (contractId) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择合同,不能同时选择采购单!请先清除合同 。');
+        return;
+    }
+    if (storageOrderNo) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择入库单,不能同时选择采购单!请先清除入库单。');
+        return;
+    }
+    
+    var vendorCode = $('#vendorCode').val();
     var obj = window.top;
     obj.$.ligerDialog.open({
         title: '选择采购订单',
         width: 860,
         height: 450,
-        url: 'paymentApplyAction.do?task=toSelectPurchaseOrder&checkbox=true',
+        url: 'paymentApplyAction.do?task=toSelectPurchaseOrder&vendorCode=' + vendorCode + '&checkbox=true',
         buttons: [{
             text: '确定',
             onclick: f_importOKPurchaseOrder
@@ -22,11 +60,10 @@ function f_importOKPurchaseOrder(item, dialog) {
     if (rows.length > 0) {
         var selectedRow = rows[0]; // 只取第一条数据
         $('#purchaseOrderNo').val(selectedRow.purchaseCode || '');
-        $('#vendorCode').val(selectedRow.vendorCode || '');
         $('#orderIdFromMes').val(selectedRow.purchaseId || '');
         dialog.close();
     } else {
-        alert('请选择一条采购订单数据');
+        alert('请选择一条采购订单数据!');
     }
 }
 
@@ -37,12 +74,31 @@ function f_importCancelPurchaseOrder(item, dialog) {
 
 // 入库单选择功能
 function selectStorageOrder() {
+    // 验证收款单位
+    if (!validatePayeeForOrderSelection()) {
+        return;
+    }
+    
+    // 检查是否已选择合同或采购订单,如果有则提示并阻止
+    var contractId = $('#contractId').val();
+    var purchaseOrderNo = $('#purchaseOrderNo').val(); 
+    if (contractId) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择合同,不能同时选择入库单!请先清除合同 。');
+        return;
+    }
+    if (purchaseOrderNo) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择采购单,不能同时选择入库单!请先清除采购单。');
+        return;
+    }
+    var vendorCode = $('#vendorCode').val();
     var obj = window.top;
     obj.$.ligerDialog.open({
         title: '选择入库单',
         width: 860,
         height: 450,
-        url: 'paymentApplyAction.do?task=toSelectStorageOrder&checkbox=true',
+        url: 'paymentApplyAction.do?task=toSelectStorageOrder&vendorCode=' + vendorCode + '&checkbox=true',
         buttons: [{
             text: '确定',
             onclick: f_importOKStorageOrder
@@ -57,13 +113,22 @@ function selectStorageOrder() {
 function f_importOKStorageOrder(item, dialog) {
     var rows = dialog.frame.f_select();
     if (rows.length > 0) {
-        var selectedRow = rows[0]; // 只取第一条数据
-        $('#storageOrderNo').val(selectedRow.recptCode || '');
-        $('#vendorCode').val(selectedRow.vendorCode || '');
-        $('#orderIdFromMes').val(selectedRow.recptId || '');
+        // 支持多选:拼接所有选中的入库单编号和ID
+        var recptCodes = [];
+        var recptIds = [];
+        for (var i = 0; i < rows.length; i++) {
+            if (rows[i].recptCode) {
+                recptCodes.push(rows[i].recptCode);
+            }
+            if (rows[i].recptId) {
+                recptIds.push(rows[i].recptId);
+            }
+        }
+        $('#storageOrderNo').val(recptCodes.join(','));
+        $('#orderIdFromMes').val(recptIds.join(','));
         dialog.close();
     } else {
-        alert('请选择一条入库单数据!');
+        alert('请至少选择一条入库单数据!');
     }
 }
 
@@ -72,6 +137,163 @@ function f_importCancelStorageOrder(item, dialog) {
     dialog.close();
 }
 
+// 选择供应商
+function selectSupplier() {
+    // 判断是否有合同,有合同则提示
+    if ($('#contractId').val()) {
+        $.ligerDialog.warn('已选择合同,收款单位由合同自动填充,如需修改请先清除合同!');
+        return;
+    }
+    
+    var obj = window.top;
+    obj.$.ligerDialog.open({
+        title : '选择供应商',
+        width : 860,
+        height : 350, 
+        url : 'contractEntry.do?task=toSelectSupplier',
+        buttons : [ {
+            text : '确定',
+            onclick : f_importOKSupplier
+        }, {
+            text : '取消',
+            onclick : f_importCancelSupplier
+        } ]
+    });  
+}
+
+// 选择合同
+function selectContract() {
+    // 检查是否已选择采购订单或入库单,如果有则提示并阻止
+    var purchaseOrderNo = $('#purchaseOrderNo').val();
+    var storageOrderNo = $('#storageOrderNo').val();
+    if (purchaseOrderNo) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择采购单,不能同时选择合同!请先清除采购单。');
+        return;
+    }
+    if (storageOrderNo) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('已选择入库单,不能同时选择合同!请先清除入库单。');
+        return;
+    }
+    var obj = window.top;
+    obj.$.ligerDialog.open({
+        height : 350,
+        width : 750,
+        title : '选择合同',
+        url : 'contractEntry.do?task=toSelectContract&time=' + new Date().getTime(),
+        showMax : false,
+        showToggle : true,
+        showMin : false,
+        isResize : true,
+        slide : false,
+        buttons : [ {
+            text : "确定",
+            onclick : f_ContractOK
+        }, {
+            text : "取消",
+            onclick : f_ContractCancel
+        } ]
+    }); 
+}
+
+// 确定选择合同
+function f_ContractOK(item, dialog){
+    var rows = dialog.frame.f_select();
+    if (rows.length == 0) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('请选择合同!');
+        return;
+    }
+    if (rows.length > 1) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('只能选择一个合同!');
+        return;
+    }
+    // 检查合同类型,只允许采购合同(2)和技术服务合同
+    var contractType = rows[0].contract_type;
+    if (contractType !== 2 && contractType !== 3) {
+        var obj = window.top;
+        obj.$.ligerDialog.warn('只能选择采购合同或技术服务合同!');
+        return;
+    }
+    
+    $("#contractId").val(rows[0].universalid);
+    $("#contractNumber").val(rows[0].contract_number);
+    $("#contractName").val(rows[0].contract_name);  
+    
+    // 回填供应商信息到收款单位
+    if (rows[0].supplierName) {
+        $("#payeeName").val(rows[0].supplierName);
+    }
+    if (rows[0].supplierCode) {
+        $("#vendorCode").val(rows[0].supplierCode);
+    }
+    
+    // 设置收款单位为只读
+    $("#payeeName").attr("readonly", "readonly");
+    
+    dialog.close();
+}
+
+// 取消选择合同
+function f_ContractCancel(item, dialog) {
+    dialog.close();
+}
+
+// 清除合同
+function clearContract(){
+    $("#contractId").val(''); 
+    $("#contractNumber").val('');
+    $("#contractName").val(''); 
+    
+    // 恢复收款单位字段的可编辑状态
+    $("#payeeName").removeAttr("readonly");
+    // 注意:不清空收款单位和供应商编码,因为可能是手动选择的供应商
+}
+
+// 清除采购订单
+function clearPurchaseOrder(){
+    $("#purchaseOrderNo").val('');
+    $("#orderIdFromMes").val('');
+}
+
+// 清除入库单
+function clearStorageOrder(){
+    $("#storageOrderNo").val('');
+    $("#orderIdFromMes").val('');
+}
+
+// 清空合同、采购订单、入库单
+function clearRelatedOrders() {
+    $("#contractId").val(''); 
+    $("#contractNumber").val('');
+    $("#contractName").val(''); 
+    $("#purchaseOrderNo").val('');
+    $("#storageOrderNo").val('');
+    $("#orderIdFromMes").val('');
+}
+
+// 确定选择供应商
+function f_importOKSupplier(item, dialog) { 
+    var rows = dialog.frame.f_select();
+    if(rows && rows.length > 0){
+        // 将选择的供应商填入收款单位
+        $("#payeeName").val(rows[0].vendorName);
+        $("#vendorCode").val(rows[0].vendorCode);
+        
+        dialog.close();
+    }else{
+        $.ligerDialog.warn('请选择供应商!');
+        return;
+    }
+}
+
+// 取消选择供应商
+function f_importCancelSupplier(item, dialog) {
+    dialog.close();
+}
+
 // 初始化付款类型显示
 function initPaymentTypeDisplay() {
     // 设置默认选中预付款
@@ -94,7 +316,6 @@ function togglePaymentFields() {
         // 只有在字段可编辑时才清空被隐藏的字段
         //if (isFieldEditable && isFieldEditable('paymentApply.storageOrderNo')) {
             $('#storageOrderNo').val('');
-            $('#vendorCode').val('');
             $('#orderIdFromMes').val('');
         //}
     } else if (paymentType == '2') { // 到付款
@@ -106,7 +327,6 @@ function togglePaymentFields() {
         // 只有在字段可编辑时才清空被隐藏的字段
         //if (isFieldEditable && isFieldEditable('paymentApply.purchaseOrderNo')) {
             $('#purchaseOrderNo').val('');
-            $('#vendorCode').val('');
             $('#orderIdFromMes').val('');
         //}
     }

+ 113 - 64
src/main/webapp/yw/contract/paymentApply/processPaymentApply.jsp

@@ -93,18 +93,57 @@
                     selectStorageOrder();
                 });
             }
-
-            if (isFieldEditable('paymentApply.bankName')) {
-                $('#selectAccountBtn').click(function() {
-                    selectSettlementAccount();
+            
+            // 绑定收款单位(供应商)选择按钮事件
+            if (isFieldEditable('paymentApply.payeeName')) {
+                $('#selectPayeeBtn').click(function() {
+                    selectSupplier();
+                });
+                
+                // 绑定收款单位字段变化事件,清空合同、采购订单、入库单和供应商编码
+                $('#payeeName').on('input change', function() {
+                    clearRelatedOrders();
+                    // 清空供应商编码,这样手动输入后就不能选择采购订单/入库单
+                    $('#vendorCode').val('');
                 });
+                
+                // 初始化:如果已有合同,则设置收款单位为只读
+                if ($('#contractId').val()) {
+                    $("#payeeName").attr("readonly", "readonly");
+                }
             }
+
         });
 
         //校验表单
         function checkForm() {
+            // 验证隐藏域:开户行和账号
+            /* if($.trim($("#bankName").val()) == ''){
+                 addError("开户行不能为空!请检查是否已设置默认账户。");
+                 return false;
+             }
+             if($.trim($("#bankAccount").val()) == ''){
+                 addError("账号不能为空!请检查是否已设置默认账户。");
+                 return false;
+             }*/
+
             var rs = true; 
             
+            // 验证合同、采购订单、入库单互斥逻辑
+            var contractId = $('#contractId').val();
+            var purchaseOrderNo = $('#purchaseOrderNo').val();
+            var storageOrderNo = $('#storageOrderNo').val();
+            
+            var selectedCount = 0;
+            if (contractId) selectedCount++;
+            if (purchaseOrderNo) selectedCount++;
+            if (storageOrderNo) selectedCount++;
+            
+            if (selectedCount > 1) {
+                addError("合同、采购订单、入库单只能选择其中一个!");
+                return false;
+            }
+            
             // 基础必填字段验证(根据权限判断)
             rs = validateFieldIfEditable("paymentApply.payerName", "单位", [{type: "require", msg: "单位不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.payeeName", "收款单位", [{type: "require", msg: "收款单位不能为空!"}]) && rs;
@@ -114,23 +153,22 @@
             rs = validateFieldIfEditable("paymentApply.paymentType", "付款类型", [{type: "require", msg: "付款类型必须选择!"}]) && rs;
             
             // 根据付款类型验证相应字段
-            if (isFieldEditable("paymentApply.paymentType")) {
+            /*if (isFieldEditable("paymentApply.paymentType")) {
                 var paymentType = $('#paymentType').val();
                 if (paymentType == '1') { // 预付款
                     rs = validateFieldIfEditable("paymentApply.purchaseOrderNo", "采购订单编号", [{type: "require", msg: "采购订单编号不能为空!"}]) && rs;
                 } else if (paymentType == '2') { // 到付款
                     rs = validateFieldIfEditable("paymentApply.storageOrderNo", "入库单编号", [{type: "require", msg: "入库单编号不能为空!"}]) && rs;
                 }
-            }
+            }*/
             
             // 其他必填字段验证(根据权限判断)
-            rs = validateFieldIfEditable("paymentApply.bankName", "开户行", [{type: "require", msg: "开户行不能为空!"}]) && rs;
-            rs = validateFieldIfEditable("paymentApply.bankAccount", "账号", [{type: "require", msg: "账号不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.paymentMethod", "付款方式", [{type: "require", msg: "付款方式不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.paymentDate", "付款日期", [{type: "require", msg: "付款日期不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.amountUpper", "付款金额(大写)", [{type: "require", msg: "付款金额(大写)不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.purpose", "用途或理由", [{type: "require", msg: "用途或理由不能为空!"}]) && rs;
             rs = validateFieldIfEditable("paymentApply.operator", "经办人", [{type: "require", msg: "经办人不能为空!"}]) && rs;
+            rs = validateFieldIfEditable("paymentApply.payeeBankAccount", "开户行及账号", [{type: "require", msg: "开户行及账号不能为空!"}]) && rs;
             
 			if(dept_approver){ 
 				rs = $.validate({name: "dept_approver_imgval", model: [{type: "require", msg: "部门负责人审批不能为空!"}]}) && rs;  
@@ -251,53 +289,22 @@
             </td>
         </tr>
         <tr>
-            <td class="l-table-edit-text">付款类型<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payment_type,')}"><font color="red">*</font></c:if>:</td>
-            <td class="l-table-edit-td">
-                <c:choose>
-                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',payment_type,')}">
-                        <c:choose>
-                            <c:when test="${paymentApply.paymentType eq '1'}">预付款</c:when>
-                            <c:when test="${paymentApply.paymentType eq '2'}">到付款</c:when>
-                            <c:otherwise></c:otherwise>
-                        </c:choose>
-                        <input type="hidden" id="paymentType" name="paymentApply.paymentType" value="${paymentApply.paymentType}"/>
-                    </c:when>
-                    <c:otherwise>
-                        <select name="paymentApply.paymentType" id="paymentType">
-                            <option value="1" <c:if test="${empty paymentApply.paymentType or paymentApply.paymentType eq '1'}">selected</c:if>>预付款</option>
-                            <option value="2" <c:if test="${paymentApply.paymentType eq '2'}">selected</c:if>>到付款</option>
-                        </select>
-                    </c:otherwise>
-                </c:choose>
-            </td>
-            <td class="l-table-edit-text" id="orderLabel1">采购订单编号<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',purchase_order_no,')}"><font color="red">*</font></c:if>:</td>
-            <td class="l-table-edit-td" id="orderField1">
-                <c:choose>
-                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',purchase_order_no,')}">
-                        ${paymentApply.purchaseOrderNo}
-                    </c:when>
-                    <c:otherwise>
-                        <input type="text" name="paymentApply.purchaseOrderNo" id="purchaseOrderNo" value="${paymentApply.purchaseOrderNo}" readonly="readonly">
-                        <input type="button" id="selectPurchaseOrderBtn" name="selectPurchaseOrderBtn" class="l-button" value="选择采购单" />
-                        <input type="hidden" id="vendorCode" name="paymentApply.vendorCode" value="${paymentApply.vendorCode}">
-                    </c:otherwise>
-                </c:choose>
-            </td>
-            <td class="l-table-edit-text" id="orderLabel2">入库单编号<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',storage_order_no,')}"><font color="red">*</font></c:if>:</td>
-            <td class="l-table-edit-td" id="orderField2">
+            <td class="l-table-edit-text" style="width: 100px;">合同:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
                 <c:choose>
-                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',storage_order_no,')}">
-                        ${paymentApply.storageOrderNo}
+                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',contract_number,')}">
+                        <input type="hidden" name="paymentApply.contractNumber" value="${paymentApply.contractNumber}">
+                        ${paymentApply.contractNumber}
                     </c:when>
                     <c:otherwise>
-                        <input type="text" name="paymentApply.storageOrderNo" id="storageOrderNo" value="${paymentApply.storageOrderNo}" readonly="readonly">
-                        <input type="button" id="selectStorageOrderBtn" name="selectStorageOrderBtn" class="l-button" value="选择入库单" />
-                        <input type="hidden" id="vendorCode" name="paymentApply.vendorCode" value="${paymentApply.vendorCode}">
+                        <input type="hidden" id="contractId" name="paymentApply.contractId" value="${paymentApply.contractId}" />
+                        <input type="text" readonly="readonly" id="contractNumber" name="paymentApply.contractNumber" value="${paymentApply.contractNumber}">
+                        <input type="hidden" id="contractName" name="paymentApply.contractName" value="${paymentApply.contractName}">
+                        <img id="searchContract" class="fee" onClick="selectContract()" src="${pageContext.request.contextPath}/images/sousuo.png" style="height: 20px; width: 20px; cursor: pointer;">
+                        <input id="clearContractBtn" name="clearContractBtn" type="button" class="l-button" value="清除" onclick="clearContract()"/>
                     </c:otherwise>
                 </c:choose>
             </td>
-        </tr>
-        <tr>
             <td class="l-table-edit-text" style="width: 100px;">单位<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payer_name,')}"><font color="red">*</font></c:if>:</td>
             <td class="l-table-edit-td" style="width: 250px;">
                 <c:choose>
@@ -310,6 +317,8 @@
                     </c:otherwise>
                 </c:choose>
             </td>
+        </tr>
+        <tr>
             <td class="l-table-edit-text" style="width: 100px;">收款单位<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payee_name,')}"><font color="red">*</font></c:if>:</td>
             <td class="l-table-edit-td" style="width: 250px;">
                 <c:choose>
@@ -319,40 +328,75 @@
                     </c:when>
                     <c:otherwise>
                         <input type="text" name="paymentApply.payeeName" id="payeeName" value="${paymentApply.payeeName}">
+                        <input type="button" id="selectPayeeBtn" name="selectPayeeBtn" class="l-button" value="选择供应商" />
+                        <input type="hidden" id="vendorCode" name="paymentApply.vendorCode" value="${paymentApply.vendorCode}">
+                    </c:otherwise>
+                </c:choose>
+            </td>
+            <td class="l-table-edit-text" style="width: 100px;">开户行及账号<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payee_bank_account,')}"><font color="red">*</font></c:if>:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                <c:choose>
+                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',payee_bank_account,')}">
+                        <input type="hidden" name="paymentApply.payeeBankAccount" value="${paymentApply.payeeBankAccount}">
+                        ${paymentApply.payeeBankAccount}
+                    </c:when>
+                    <c:otherwise>
+                        <input type="text" name="paymentApply.payeeBankAccount" id="payeeBankAccount" value="${paymentApply.payeeBankAccount}" style="width: 100%;">
                     </c:otherwise>
                 </c:choose>
             </td>
         </tr>
-        <!-- </table>
-
-        <table class="l-table-edit line l-table-edit-custom" width="99%"> -->
         <tr>
-            <td class="l-table-edit-text">开户行<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',bank_name,')}"><font color="red">*</font></c:if>:</td>
+            <td class="l-table-edit-text">付款类型<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payment_type,')}"><font color="red">*</font></c:if>:</td>
             <td class="l-table-edit-td">
                 <c:choose>
-                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',bank_name,')}">
-                        ${paymentApply.bankName}
+                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',payment_type,')}">
+                        <c:choose>
+                            <c:when test="${paymentApply.paymentType eq '1'}">预付款</c:when>
+                            <c:when test="${paymentApply.paymentType eq '2'}">到付款</c:when>
+                            <c:otherwise></c:otherwise>
+                        </c:choose>
+                        <input type="hidden" id="paymentType" name="paymentApply.paymentType" value="${paymentApply.paymentType}"/>
                     </c:when>
                     <c:otherwise>
-                        <input type="text" name="paymentApply.bankName" id="bankName" value="${paymentApply.bankName}" readonly="readonly">
-                        <input type="button" id="selectAccountBtn" name="selectAccountBtn" class="l-button" value="选择账户" />
+                        <select name="paymentApply.paymentType" id="paymentType">
+                            <option value="1" <c:if test="${empty paymentApply.paymentType or paymentApply.paymentType eq '1'}">selected</c:if>>预付款</option>
+                            <option value="2" <c:if test="${paymentApply.paymentType eq '2'}">selected</c:if>>到付款</option>
+                        </select>
                     </c:otherwise>
                 </c:choose>
             </td>
-            <td class="l-table-edit-text">账号<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',bank_account,')}"><font color="red">*</font></c:if>:</td>
-            <td class="l-table-edit-td">
+            <td class="l-table-edit-text" id="orderLabel1">采购订单编号:</td>
+            <td class="l-table-edit-td" id="orderField1">
                 <c:choose>
-                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',bank_account,')}">
-                        ${paymentApply.bankAccount}
+                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',purchase_order_no,')}">
+                        ${paymentApply.purchaseOrderNo}
                     </c:when>
                     <c:otherwise>
-                        <input type="text" name="paymentApply.bankAccount" id="bankAccount" value="${paymentApply.bankAccount}" readonly="readonly">
-                        <input type="hidden" id="accountId" name="paymentApply.accountId" value="${paymentApply.accountId}"/>
-                        <input type="hidden" id="accountName" name="paymentApply.accountName" value="${paymentApply.accountName}"/>
+                        <input type="text" name="paymentApply.purchaseOrderNo" id="purchaseOrderNo" value="${paymentApply.purchaseOrderNo}" readonly="readonly" style="width: 70%;">
+                        <input type="button" id="selectPurchaseOrderBtn" name="selectPurchaseOrderBtn" class="l-button" value="选择采购单" />
+                        <input id="clearPurchaseOrderBtn" name="clearPurchaseOrderBtn" type="button" class="l-button" value="清除" onclick="clearPurchaseOrder()"/>
+                    </c:otherwise>
+                </c:choose>
+            </td>
+            <td class="l-table-edit-text" id="orderLabel2">入库单编号:</td>
+            <td class="l-table-edit-td" id="orderField2">
+                <c:choose>
+                    <c:when test="${curTacheModel.n_se ne 1 and !fn:contains(curTacheModel.table_fields, ',storage_order_no,')}">
+                        ${paymentApply.storageOrderNo}
+                    </c:when>
+                    <c:otherwise>
+                        <input type="text" name="paymentApply.storageOrderNo" id="storageOrderNo" value="${paymentApply.storageOrderNo}" readonly="readonly" style="width: 70%;">
+                        <input type="button" id="selectStorageOrderBtn" name="selectStorageOrderBtn" class="l-button" value="选择入库单" />
+                        <input id="clearStorageOrderBtn" name="clearStorageOrderBtn" type="button" class="l-button" value="清除" onclick="clearStorageOrder()"/>
                     </c:otherwise>
                 </c:choose>
             </td>
         </tr>
+
+        <!-- </table>
+
+        <table class="l-table-edit line l-table-edit-custom" width="99%"> --> 
         <tr>
             <td class="l-table-edit-text">付款方式<c:if test="${curTacheModel.n_se eq 1 or fn:contains(curTacheModel.table_fields, ',payment_method,')}"><font color="red">*</font></c:if>:</td>
             <td class="l-table-edit-td">
@@ -736,6 +780,11 @@
     <input type="hidden" id="table_fields" name="table_fields" value="${curTacheModel.table_fields}">
     <input type="hidden" id="universalid" name="paymentApply.universalid" value="${paymentApply.universalid}">
     <input type="hidden" id="lFormInsId" name="paymentApply.lFormInsId" value="${paymentApply.lFormInsId}">
+    
+    <input type="hidden" name="paymentApply.bankName" id="bankName" value="${paymentApply.bankName}"/>
+    <input type="hidden" name="paymentApply.bankAccount" id="bankAccount" value="${paymentApply.bankAccount}"/>
+    <input type="hidden" id="accountId" name="paymentApply.accountId" value="${paymentApply.accountId}"/>
+    <input type="hidden" id="accountName" name="paymentApply.accountName" value="${paymentApply.accountName}"/>
 </form>
 </body>
 </html>

+ 8 - 0
src/main/webapp/yw/contract/paymentApply/selectPurchaseOrder.jsp

@@ -105,6 +105,10 @@ function initPurchaseOrderList(){
 	var params="";
 	var purchaseName=$("#purchaseName").val();
 	params=params+"&purchaseName="+encodeURI(encodeURI(purchaseName)); 
+	// 添加供应商编码参数
+	<c:if test="${not empty vendorCode}">
+		params=params+"&vendorCode=${vendorCode}";
+	</c:if>
 	loadPurchaseOrderList(params);
 }
 
@@ -113,6 +117,10 @@ function searchByKword(){
 	var params="";
 	var purchaseName=$("#purchaseName").val();
 	params=params+"&purchaseName="+encodeURI(encodeURI(purchaseName)); 
+	// 添加供应商编码参数
+	<c:if test="${not empty vendorCode}">
+		params=params+"&vendorCode=${vendorCode}";
+	</c:if>
 	loadPurchaseOrderList(params);
 }
 

+ 19 - 3
src/main/webapp/yw/contract/paymentApply/selectStorageOrder.jsp

@@ -75,7 +75,7 @@ function loadStorageOrderList(params) {
 								}],
 						pageSize : 10,
 						checkbox: true, 
-						isSingleCheck: true, // 启用单选模式
+						isSingleCheck: false, // 启用多选模式
 						url : 'paymentApplyAction.do?task=storageOrderList'+params
 								+ '&time='
 								+ new Date().getTime(),
@@ -85,10 +85,18 @@ function loadStorageOrderList(params) {
 						height : '99.9%',
 						isChecked: f_isChecked,
 						onCheckRow:function(checked, rowdata, rowindex) {            
+							// 多选模式:维护选中值的数组
 							if(checked){
-								checkValue = [rowdata.recptCode];
+								// 添加到选中列表
+								if(checkValue.indexOf(rowdata.recptCode) === -1){
+									checkValue.push(rowdata.recptCode);
+								}
 							}else{
-								checkValue = [];
+								// 从选中列表中移除
+								var index = checkValue.indexOf(rowdata.recptCode);
+								if(index > -1){
+									checkValue.splice(index, 1);
+								}
 							}								
 						},
 						onSelectRow: function (rowdata, rowindex, rowobj) {
@@ -105,6 +113,10 @@ function initStorageOrderList(){
 	var params="";
 	var recptName=$("#recptName").val();
 	params=params+"&recptName="+encodeURI(encodeURI(recptName)); 
+	// 添加供应商编码参数
+	<c:if test="${not empty vendorCode}">
+		params=params+"&vendorCode=${vendorCode}";
+	</c:if>
 	loadStorageOrderList(params);
 }
 
@@ -113,6 +125,10 @@ function searchByKword(){
 	var params="";
 	var recptName=$("#recptName").val();
 	params=params+"&recptName="+encodeURI(encodeURI(recptName)); 
+	// 添加供应商编码参数
+	<c:if test="${not empty vendorCode}">
+		params=params+"&vendorCode=${vendorCode}";
+	</c:if>
 	loadStorageOrderList(params);
 }
 

+ 88 - 41
src/main/webapp/yw/contract/paymentApply/startPaymentApply.jsp

@@ -52,22 +52,62 @@
             $('#selectStorageOrderBtn').click(function() {
                 selectStorageOrder();
             });
-            // 初始化时转换一次
-            convertToChinese();
             
-            // 绑定选择账户按钮事件
-            $('#selectAccountBtn').click(function() {
-                selectSettlementAccount();
+            // 绑定收款单位(供应商)选择按钮事件
+            $('#selectPayeeBtn').click(function() {
+                selectSupplier();
+            });
+            
+            // 绑定收款单位字段变化事件,清空合同、采购订单、入库单和供应商编码
+            $('#payeeName').on('input change', function() {
+                clearRelatedOrders();
+                // 清空供应商编码,这样手动输入后就不能选择采购订单/入库单
+                $('#vendorCode').val('');
             });
+            
+            // 初始化:如果已有合同,则设置收款单位为只读
+            if ($('#contractId').val()) {
+                $("#payeeName").attr("readonly", "readonly");
+            }
+            
+            // 初始化时转换一次
+            convertToChinese();
         });
         
         
 
         //校验表单
         function checkForm() {
-            var rs = true; 
+            // 验证隐藏域:开户行和账号
+            /* if($.trim($("#bankName").val()) == ''){
+                addError("开户行不能为空!请检查是否已设置默认账户。");
+                return false;
+            }
+            if($.trim($("#bankAccount").val()) == ''){
+                addError("账号不能为空!请检查是否已设置默认账户。");
+                return false;
+            } */
+            var accountId = $('#accountId').val();
+        	if(!accountId){
+                addError("没有默认付款账户!请检查是否已设置默认账户。");
+                return false;
+            }
+            // 验证合同、采购订单、入库单互斥逻辑
+            var contractId = $('#contractId').val();
+            var purchaseOrderNo = $('#purchaseOrderNo').val();
+            var storageOrderNo = $('#storageOrderNo').val();
+            
+            var selectedCount = 0;
+            if (contractId) selectedCount++;
+            if (purchaseOrderNo) selectedCount++;
+            if (storageOrderNo) selectedCount++;
             
-            // 基础必填字段验证
+            if (selectedCount > 1) {
+                addError("合同、采购订单、入库单只能选择其中一个!");
+                return false;
+            }
+            
+            var rs = true;
             rs = $.validate({name: "paymentApply.payerName", model: [{type: "require", msg: "单位不能为空!"}]}) && rs; 
             rs = $.validate({name: "paymentApply.payeeName", model: [{type: "require", msg: "收款单位不能为空!"}]}) && rs; 
             rs = $.validate({name: "paymentApply.amountLower", model: [{type: "require", msg: "付款金额不能为空!"}]}) && rs;
@@ -76,22 +116,20 @@
             rs = $.validate({name: "paymentApply.paymentType", model: [{type: "require", msg: "付款类型必须选择!"}]}) && rs;
             
             // 根据付款类型验证相应字段
-            var paymentType = $('#paymentType').val();
+           /* var paymentType = $('#paymentType').val();
             if (paymentType == '1') { // 预付款
                 rs = $.validate({name: "paymentApply.purchaseOrderNo", model: [{type: "require", msg: "采购订单编号不能为空!"}]}) && rs;
             } else if (paymentType == '2') { // 到付款
                 rs = $.validate({name: "paymentApply.storageOrderNo", model: [{type: "require", msg: "入库单编号不能为空!"}]}) && rs;
-            }
+            }*/
             
             // 其他必填字段验证
-            rs = $.validate({name: "paymentApply.bankName", model: [{type: "require", msg: "开户行不能为空!"}]}) && rs;
-            rs = $.validate({name: "paymentApply.bankAccount", model: [{type: "require", msg: "账号不能为空!"}]}) && rs;
             rs = $.validate({name: "paymentApply.paymentMethod", model: [{type: "require", msg: "付款方式不能为空!"}]}) && rs;
             rs = $.validate({name: "paymentApply.paymentDate", model: [{type: "require", msg: "付款日期不能为空!"}]}) && rs;
             rs = $.validate({name: "paymentApply.amountUpper", model: [{type: "require", msg: "付款金额(大写)不能为空!"}]}) && rs;
             rs = $.validate({name: "paymentApply.purpose", model: [{type: "require", msg: "用途或理由不能为空!"}]}) && rs;
             rs = $.validate({name: "paymentApply.operator", model: [{type: "require", msg: "经办人不能为空!"}]}) && rs;
-            
+            rs = $.validate({name: "paymentApply.payeeBankAccount", model: [{type: "require", msg: "开户行及账号不能为空!"}]}) && rs;
             return rs;
         }
 
@@ -180,6 +218,32 @@
                 ${applyDate}
             </td>
         </tr>
+        <tr>
+            <td class="l-table-edit-text" style="width: 100px;">合同:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                <input type="hidden" id="contractId" name="paymentApply.contractId" value="${paymentApply.contractId}" />
+                <input type="text" readonly="readonly" id="contractNumber" name="paymentApply.contractNumber" value="${paymentApply.contractNumber}">
+                <input type="hidden" id="contractName" name="paymentApply.contractName" value="${paymentApply.contractName}">
+                <img id="searchContract" class="fee" onClick="selectContract()" src="${pageContext.request.contextPath}/images/sousuo.png" style="height: 20px; width: 20px; cursor: pointer;">
+                <input id="clearContractBtn" name="clearContractBtn" type="button" class="l-button" value="清除" onclick="clearContract()"/>
+            </td>
+            <td class="l-table-edit-text" style="width: 100px;">单位<font color="red">*</font>:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                <input type="text" name="paymentApply.payerName" id="payerName" value="${paymentApply.payerName}">
+            </td>
+        </tr>
+        <tr>
+            <td class="l-table-edit-text" style="width: 100px;">收款单位<font color="red">*</font>:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                <input type="text" name="paymentApply.payeeName" id="payeeName" value="${paymentApply.payeeName}">
+                <input type="button" id="selectPayeeBtn" name="selectPayeeBtn" class="l-button" value="选择供应商" />
+                <input type="hidden" id="vendorCode" name="paymentApply.vendorCode" value="${paymentApply.vendorCode}">
+            </td>
+            <td class="l-table-edit-text" style="width: 100px;">开户行及账号<font color="red">*</font>:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                <input type="text" name="paymentApply.payeeBankAccount" id="payeeBankAccount" value="${paymentApply.payeeBankAccount}" style="width: 100%;">
+            </td>
+        </tr>
         <tr>
             <td class="l-table-edit-text">付款类型<font color="red">*</font>:</td>
             <td class="l-table-edit-td">
@@ -188,45 +252,24 @@
                     <option value="2" <c:if test="${paymentApply.paymentType eq '2'}">selected</c:if>>到付款</option>
                 </select>
             </td>
-            <td class="l-table-edit-text" id="orderLabel1">采购订单编号<font color="red">*</font>:</td>
+            <td class="l-table-edit-text" id="orderLabel1">采购订单编号:</td>
             <td class="l-table-edit-td" id="orderField1">
-                <input type="text" name="paymentApply.purchaseOrderNo" id="purchaseOrderNo" value="${paymentApply.purchaseOrderNo}" readonly="readonly">
+                <input type="text" name="paymentApply.purchaseOrderNo" id="purchaseOrderNo" value="${paymentApply.purchaseOrderNo}" readonly="readonly" style="width: 70%;">
                 <input type="button" id="selectPurchaseOrderBtn" name="selectPurchaseOrderBtn" class="l-button" value="选择采购单" />
+                <input id="clearPurchaseOrderBtn" name="clearPurchaseOrderBtn" type="button" class="l-button" value="清除" onclick="clearPurchaseOrder()"/>
             </td>
-            <td class="l-table-edit-text" id="orderLabel2">入库单编号<font color="red">*</font>:</td>
+            <td class="l-table-edit-text" id="orderLabel2">入库单编号:</td>
             <td class="l-table-edit-td" id="orderField2">
-                <input type="text" name="paymentApply.storageOrderNo" id="storageOrderNo" value="${paymentApply.storageOrderNo}" readonly="readonly">
+                <input type="text" name="paymentApply.storageOrderNo" id="storageOrderNo" value="${paymentApply.storageOrderNo}" readonly="readonly" style="width: 70%;">
                 <input type="button" id="selectStorageOrderBtn" name="selectStorageOrderBtn" class="l-button" value="选择入库单" />
+                <input id="clearStorageOrderBtn" name="clearStorageOrderBtn" type="button" class="l-button" value="清除" onclick="clearStorageOrder()"/>
             </td>
-            <input type="hidden" id="vendorCode" name="paymentApply.vendorCode" value="${paymentApply.vendorCode}">
             <input type="hidden" id="orderIdFromMes" name="paymentApply.orderIdFromMes" value="${paymentApply.orderIdFromMes}">
         </tr> 
-        <tr>
-        	<td class="l-table-edit-text" style="width: 100px;">单位<font color="red">*</font>:</td>
-            <td class="l-table-edit-td" style="width: 250px;">
-                <input type="text" name="paymentApply.payerName" id="payerName" value="${paymentApply.payerName}">
-            </td>
-            <td class="l-table-edit-text" style="width: 100px;">收款单位<font color="red">*</font>:</td>
-            <td class="l-table-edit-td" style="width: 250px;">
-                <input type="text" name="paymentApply.payeeName" id="payeeName" value="${paymentApply.payeeName}">
-            </td> 
-        </tr>
+
     <!-- </table>
     
-    <table class="l-table-edit line l-table-edit-custom" width="99%"> -->
-    	<tr>
-            <td class="l-table-edit-text">开户行<font color="red">*</font>:</td>
-            <td class="l-table-edit-td">
-                <input type="text" name="paymentApply.bankName" id="bankName" value="${paymentApply.bankName}" readonly="readonly">
-                <input type="button" id="selectAccountBtn" name="selectAccountBtn" class="l-button" value="选择账户" />
-            </td>
-            <td class="l-table-edit-text">账号<font color="red">*</font>:</td>
-            <td class="l-table-edit-td">
-                <input type="text" name="paymentApply.bankAccount" id="bankAccount" value="${paymentApply.bankAccount}" readonly="readonly">
-                <input type="hidden" id="accountId" name="paymentApply.accountId" value="${paymentApply.accountId}"/>
-                <input type="hidden" id="accountName" name="paymentApply.accountName" value="${paymentApply.accountName}"/>
-            </td>
-        </tr>
+    <table class="l-table-edit line l-table-edit-custom" width="99%"> --> 
         <tr>
             <td class="l-table-edit-text">付款方式<font color="red">*</font>:</td>
             <td class="l-table-edit-td">
@@ -264,6 +307,10 @@
         </tr>
     </table>
     <input type="hidden" id="depid" name="paymentApply.depid" value="${depid}">
+     <input type="hidden" name="paymentApply.bankName" id="bankName" value="${paymentApply.bankName}"/>
+     <input type="hidden" name="paymentApply.bankAccount" id="bankAccount" value="${paymentApply.bankAccount}"/>
+     <input type="hidden" id="accountId" name="paymentApply.accountId" value="${paymentApply.accountId}"/>
+     <input type="hidden" id="accountName" name="paymentApply.accountName" value="${paymentApply.accountName}"/>
     <br>
     <br>
     <br>

+ 26 - 20
src/main/webapp/yw/contract/paymentApply/viewPaymentApply.jsp

@@ -110,12 +110,34 @@
             <td class="l-table-edit-text" style="width: 120px;">申请部门:</td>
             <td class="l-table-edit-td" style="width: 250px;">
                 ${paymentApply.department}
+                
+                <input type="hidden" id="initiator" name="paymentApply.initiator" value="${paymentApply.initiator}"/>
             </td>
             <td class="l-table-edit-text" style="width: 120px;">申请日期:</td>
             <td class="l-table-edit-td" style="width: 250px;">
                 ${paymentApply.applyDate}
             </td>
         </tr>
+        <tr>
+            <td class="l-table-edit-text" style="width: 100px;">合同:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                ${paymentApply.contractNumber}
+            </td>
+            <td class="l-table-edit-text" style="width: 100px;">单位:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                ${paymentApply.payerName}
+            </td>
+        </tr>
+        <tr>
+            <td class="l-table-edit-text" style="width: 100px;">收款单位:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                ${paymentApply.payeeName}
+            </td>
+            <td class="l-table-edit-text" style="width: 100px;">开户行及账号:</td>
+            <td class="l-table-edit-td" style="width: 250px;">
+                ${paymentApply.payeeBankAccount}
+            </td>
+        </tr>
         <tr>
             <td class="l-table-edit-text">付款类型:</td>
             <td class="l-table-edit-td">
@@ -135,26 +157,9 @@
                 ${paymentApply.storageOrderNo}
             </td>
         </tr>
-        <tr>
-            <td class="l-table-edit-text">单位:</td>
-            <td class="l-table-edit-td">
-                ${paymentApply.payerName}
-            </td>
-            <td class="l-table-edit-text">收款单位:</td>
-            <td class="l-table-edit-td">
-                ${paymentApply.payeeName}
-            </td>
-        </tr>
-        <tr>
-            <td class="l-table-edit-text">开户行:</td>
-            <td class="l-table-edit-td">
-                ${paymentApply.bankName}
-            </td>
-            <td class="l-table-edit-text">账号:</td>
-            <td class="l-table-edit-td">
-                ${paymentApply.bankAccount}
-            </td>
-        </tr>
+        <!-- </table>
+
+        <table class="l-table-edit line l-table-edit-custom" width="99%"> --> 
         <tr>
             <td class="l-table-edit-text">付款方式:</td>
             <td class="l-table-edit-td">
@@ -165,6 +170,7 @@
                 ${paymentApply.paymentDate}
             </td>
         </tr>
+
         <tr>
             <td class="l-table-edit-text">付款金额(大写):</td>
             <td class="l-table-edit-td">

+ 22 - 22
src/main/webapp/yw/contract/paymentApply/viewPaymentApplyInfo.jsp

@@ -105,6 +105,26 @@ body {
 				                ${paymentApply.applyDate}
 				            </td>
 				        </tr>
+				        <tr>
+				            <td class="l-table-edit-text">合同:</td>
+				            <td class="l-table-edit-td">
+				                ${paymentApply.contractNumber}
+				            </td>
+				            <td class="l-table-edit-text">单位:</td>
+				            <td class="l-table-edit-td">
+				                ${paymentApply.payerName}
+				            </td>
+				        </tr>
+				        <tr>
+				            <td class="l-table-edit-text">收款单位:</td>
+				            <td class="l-table-edit-td">
+				                ${paymentApply.payeeName}
+				            </td>
+				            <td class="l-table-edit-text">开户行及账号:</td>
+				            <td class="l-table-edit-td">
+				                ${paymentApply.payeeBankAccount}
+				            </td>
+				        </tr>
 				        <tr>
 				            <td class="l-table-edit-text">付款类型:</td>
 				            <td class="l-table-edit-td">
@@ -129,28 +149,8 @@ body {
 									</td>
 								</c:when>
 								<c:otherwise></c:otherwise>
-							</c:choose> 
-				        </tr>
-				        <tr>
-				            <td class="l-table-edit-text">单位:</td>
-				            <td class="l-table-edit-td">
-				                ${paymentApply.payerName}
-				            </td>
-				            <td class="l-table-edit-text">收款单位:</td>
-				            <td class="l-table-edit-td">
-				                ${paymentApply.payeeName}
-				            </td>
-				        </tr>
-				        <tr>
-				            <td class="l-table-edit-text">开户行:</td>
-				            <td class="l-table-edit-td">
-				                ${paymentApply.bankName}
-				            </td>
-				            <td class="l-table-edit-text">账号:</td>
-				            <td class="l-table-edit-td">
-				                ${paymentApply.bankAccount}
-				            </td>
-				        </tr>
+							</c:choose>
+						</tr>
 				        <tr>
 				            <td class="l-table-edit-text">付款方式:</td>
 				            <td class="l-table-edit-td">