| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385 |
- <%@ page import="java.util.Map" %>
- <%@ page import="java.util.TreeMap" %>
- <html>
- <head>
- <style>
- .table-container>tr>th{
- width:130px !important;
- }
- /* 把content-box的高度限制 从公共css 抽到具体有需要的页面 by xu 20251215 */
- .form-container .content-box {
- height: calc(100% - 80px) !important;
- }
- </style>
- </head>
- <body class="env-input-body">
- <form method="post" id="app" class="form-container">
- <div class="content-box fit-height-content">
- <div class="content-div" ssFith="true">
- <table class='form'>
- <tr>
- <th style="width: 120px">退费类别</th>
- <td >
- <%-- 功能说明:个人退费页退费类别切换时联动重跑金额校验 by xu 20260323 --%>
- <onoff.ss name="grczlbm" mode="edit" rad="true" null="false" val="" onChange="handleGrczlbmChange" />
- <%
- Map<Integer,String > grczlbMap = (Map)(request.getAttribute("grczlbMap"));
- for (Integer key : grczlbMap.keySet()) {
- pageContext.setAttribute("k",key);
- pageContext.setAttribute("v",grczlbMap.get(key));
- %>
- <input name="grczlbm" value="${v}" ssVal="${k}" />
- <%
- }
- %>
- </td>
- </tr>
- <tr>
- <th>班级/亲属</th>
- <td style="display: flex;align-items: center;border: none;
- border-right: 1px solid #e2e4ec;">
- <objp.ss name="bjid" cb="bj" inp="true" width="200px"/>
- <onoff.ss name="rylbm" mode="edit" rad="false" null="false" val="1100" />
- <input name="rylbm" value="职工亲属" ssVal="1000" />
- </td>
- </tr>
- <%-- 先去掉,接入读卡器时再加。Lin
- <tr>
- <th>卡号</th>
- <td >
- <@input name="kah"/>
- </td>
- </tr>
- --%>
- <tr>
- <th>人员</th>
- <td>
- <input name="czryid" type="hidden" value='${sessionScope.ssUser.ryid}'/> <%-- 操作人员ID。Lin --%>
- <objp.ss name="ryid" cb="ryByBjOrRylb" inp="true" onChange="selBaseInfoByRyid" filterField="bjid,rylbm" />
- </td>
- </tr>
- <tr>
- <th>部门/班级</th>
- <td id='bmbj'></td>
- </tr>
- <tr>
- <th>姓名</th>
- <td id='xm'></td>
- </tr>
- <tr>
- <th>人员号</th>
- <td id='ryh'></td>
- </tr>
-
- <tr>
- <th>金额</th>
- <td>
- <script>
- // 功能说明:个人退费页金额字段改为 SsInp 组件,并声明 Vue 表单模型 by xu 20260323
- ss.dom.formElemConfig.je={val:'',type:window.ss.dom.TYPE.INPUT};
- </script>
- <ss-inp v-model="je" name="je" placeholder="请输入金额"></ss-inp>
- </td>
- </tr>
- <tr>
- <th>消费余额</th>
- <td ><input name="xfye"/></td>
- </tr>
- <tr>
- <th>描述</th>
- <td>
- <script>
- // 功能说明:个人退费页描述字段改为 SsInp 组件,并声明 Vue 表单模型 by xu 20260323
- ss.dom.formElemConfig.ms={val:'',type:window.ss.dom.TYPE.INPUT};
- </script>
- <ss-inp v-model="ms" name="ms" placeholder="请输入描述"></ss-inp>
- </td>
- </tr>
- </table>
- </div>
- <div class='bottom-div'>
- <ss-bottom-button
- id="saveAndCommit"
- text="保存并提交"
- onclick='submitGrtfForm();'<%-- 功能说明:个人退费页提交前先校验金额必须为负数 by xu 20260323 --%>
- icon-class="bottom-div-save"
- ></ss-bottom-button>
- <ss-bottom-button
- text="关闭"
- onclick='ss.display.closeDialog();'
- icon-class="bottom-div-close"
- ></ss-bottom-button>
- </div>
- </div>
- </form>
- </body>
- </html>
- <script>
- function getFormAppVm(){
- var appEl = document.getElementById("app");
- if (!appEl || !appEl.__vue_app__ || !appEl.__vue_app__._instance) {
- return null;
- }
- return appEl.__vue_app__._instance.proxy || null;
- }
- function normalizeRylbmValues(value){
- if (Array.isArray(value)) {
- return value.map(function(item){
- return item == null ? "" : item.toString();
- }).filter(Boolean);
- }
- if (value == null || value === "") {
- return [];
- }
- var cleanValue = value.toString().replace(/^,+/, "");
- if (!cleanValue) {
- return [];
- }
- return cleanValue.split(/[,|]/).filter(Boolean);
- }
- function hasRelativeRylbmValue(value){
- return normalizeRylbmValues(value).indexOf("1000") !== -1;
- }
- function clearRyDisplay(){
- var bmbjEl = document.getElementById('bmbj');
- var xmEl = document.getElementById('xm');
- var ryhEl = document.getElementById('ryh');
- if (bmbjEl) bmbjEl.innerHTML = "";
- if (xmEl) xmEl.innerHTML = "";
- if (ryhEl) ryhEl.innerHTML = "";
- }
- function clearRySelection(vm){
- if (!vm) {
- clearRyDisplay();
- return;
- }
- vm.ryid = "";
- clearRyDisplay();
- }
- function handleRylbmChange(groupValue){
- if (!hasRelativeRylbmValue(groupValue)) {
- return;
- }
- var vm = getFormAppVm();
- if (!vm) {
- clearRyDisplay();
- return;
- }
- vm.bjid = "";
- clearRySelection(vm);
- }
- function handleBjChange(value){
- if (value == null || value === "") {
- return;
- }
- var vm = getFormAppVm();
- if (!vm) {
- clearRyDisplay();
- return;
- }
- if (hasRelativeRylbmValue(vm.rylbm)) {
- vm.rylbm = "1100";
- }
- clearRySelection(vm);
- }
-
- function selBaseInfoByRyid(value){
- $.ajax({
- url:"<serv.ss name='ry_selBaseInfoByRyid'/>",
- type:"post",
- data:{
- ryid:value
- },
- dataType:"json",
- success:function(data){
- if (data.ssCode != 0) {
- alert(data.ssMsg);
- return;
- }
- var d = data.ssData;
- document.getElementById('xm').innerHTML = d.xm;
- document.getElementById('ryh').innerHTML = d.ryh;
- if (d.rylbm != 1100) { // 不是学员。Lin
- if (d.bmmc)
- document.getElementById('bmbj').innerHTML = d.bmmc;
- else
- document.getElementById('bmbj').innerHTML = "(无)";
- } else {
- if (d.bjmc)
- document.getElementById('bmbj').innerHTML = d.bjmc;
- else
- document.getElementById('bmbj').innerHTML = "(无)";
- }
- }
- });
- }
- </script>
- <script type="text/javascript" src="/js/validate/validator-rules.js"></script><%-- 功能说明:个人退费页接入桌面端校验规则,支持 SsInp 红线提示 by xu 20260323 --%>
- <script type="text/javascript" src="/js/validate/validation-manager.js"></script><%-- 功能说明:个人退费页接入桌面端校验管理器,支持 SsInp 红线提示 by xu 20260323 --%>
- <script>
- // 功能说明:根据当前退费类别渲染 code-label 映射,供金额负数校验复用 by xu 20260323
- var GRTF_LABEL_MAP = {
- <%
- for (Integer key : grczlbMap.keySet()) {
- %>
- "<%=key%>": "<%=grczlbMap.get(key)%>",
- <%
- }
- %>
- };
- // 功能说明:记录当前退费类别的最新 value/label,避免 onoff 隐藏值切换时机导致金额校验判断失真 by xu 20260323
- var CURRENT_GRTF_CATEGORY_STATE = {
- value: "",
- label: ""
- };
- // 功能说明:退费类别变化后延后一拍重跑金额校验,确保隐藏字段值更新后再清理红线状态 by xu 20260323
- function handleGrczlbmChange(groupValue, value, label){
- CURRENT_GRTF_CATEGORY_STATE.value = groupValue == null ? "" : groupValue.toString();
- CURRENT_GRTF_CATEGORY_STATE.label = label == null ? "" : label.toString();
- setTimeout(function(){
- if (window.ssVm && typeof window.ssVm.validateField === "function") {
- window.ssVm.validateField("je");
- return;
- }
- validateNegativeAmountByCategory(false);
- }, 0);
- }
- // 功能说明:初始化个人退费页金额负数校验规则,整页金额都必须输入负数 by xu 20260323
- function initNegativeAmountValidation(){
- if (!window.ssVm || typeof window.ssVm.add !== "function" || window.ss.dom._grczGrtfNegativeAmountValidationInited) {
- return;
- }
- window.ss.dom._grczGrtfNegativeAmountValidationInited = true;
- window.ssVm.add("ss.commonValidator.custom", ["je"], {
- msgPrfx: "金额",
- relField: "grczlbm",
- validate: function(value, categoryValue){
- var currentLabel = getCurrentGrczlbmLabel(categoryValue);
- if (value == null || value.toString().trim() === "") {
- return true;
- }
- if (isValidNegativeAmountText(value)) {
- return true;
- }
- return {
- valid: false,
- message: (currentLabel || "退费") + "金额只能输入负数"
- };
- }
- }, {
- je: window.ss.dom.formElemConfig.je ? window.ss.dom.formElemConfig.je.val : ""
- });
- }
- // 功能说明:根据当前退费类别值读取显示文案,供联动校验和错误提示复用 by xu 20260323
- function getCurrentGrczlbmLabel(categoryValue){
- var currentValue = categoryValue == null ? getCurrentGrczlbmValue() : categoryValue.toString();
- if (CURRENT_GRTF_CATEGORY_STATE.label && (!currentValue || CURRENT_GRTF_CATEGORY_STATE.value === currentValue)) {
- return CURRENT_GRTF_CATEGORY_STATE.label;
- }
- return GRTF_LABEL_MAP[currentValue] || "";
- }
- // 功能说明:统一判断金额文本是否为合法负数,供提交校验和 ssVm 规则复用 by xu 20260323
- function isValidNegativeAmountText(value){
- var amountText = value == null ? "" : value.toString().trim();
- if (!amountText) {
- return false;
- }
- var amountNumber = Number(amountText);
- return !isNaN(amountNumber) && amountNumber < 0;
- }
- // 功能说明:根据当前退费类别值读取隐藏字段值,供金额校验复用 by xu 20260323
- function getCurrentGrczlbmValue(){
- var vm = getFormAppVm();
- if (vm && vm.grczlbm != null && vm.grczlbm !== "") {
- return vm.grczlbm.toString();
- }
- var categoryElem = document.querySelector('[name="grczlbm"]');
- return categoryElem && categoryElem.value != null ? categoryElem.value.toString() : "";
- }
- // 功能说明:统一校验个人退费金额必须为负数,不再区分具体退费类别 by xu 20260323
- function validateNegativeAmountByCategory(showMsg){
- var currentLabel = getCurrentGrczlbmLabel();
- var jeElem = document.querySelector('[name="je"]');
- if (!jeElem) {
- return true;
- }
- if (isValidNegativeAmountText(jeElem.value)) {
- return true;
- }
- if (showMsg !== false) {
- alert((currentLabel || "退费") + "金额只能输入负数");
- jeElem.focus();
- }
- return false;
- }
- // 功能说明:个人退费页提交前先走 ssVm 全量校验,确保显示 SsInp 左侧红线与底部提示 by xu 20260323
- function submitGrtfForm(){
- if (window.ssVm && window.ssVm.validations && window.ssVm.validations.size > 0) {
- var validateResult = window.ssVm.validateAll();
- if (!validateResult.valid) {
- return false;
- }
- } else if (!validateNegativeAmountByCategory(true)) {
- return false;
- }
- var formElem = document.querySelector("form");
- if (!formElem) {
- alert("表单不存在");
- return false;
- }
- formElem.action = "<ss:serv name='grcz_lr_tj' dest='addSure' parm='{thisViewObject:\"grcz\",dataType:\"update\"}'/>";
- ss.display.resizeComponent(881,361,515,515);
- formElem.submit();
- return true;
- }
- if (window.SS && typeof SS.ready === "function") {
- SS.ready(function(){
- // 功能说明:页面初始化后同步当前退费类别状态,避免首次校验读取不到最新类别文案 by xu 20260323
- CURRENT_GRTF_CATEGORY_STATE.value = getCurrentGrczlbmValue();
- CURRENT_GRTF_CATEGORY_STATE.label = GRTF_LABEL_MAP[CURRENT_GRTF_CATEGORY_STATE.value] || "";
- // 功能说明:页面初始化后注册个人退费金额负数校验规则,保证 SsInp 输入时直接出现红线提示 by xu 20260323
- initNegativeAmountValidation();
- });
- }
- </script>
|