grcz_grtfAdd.ss.jsp 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <%@ page import="java.util.Map" %>
  2. <%@ page import="java.util.TreeMap" %>
  3. <html>
  4. <head>
  5. <%-- 去掉,用统一的样式 -- base.css 等。Lin
  6. <style>
  7. .table-container>tr>th{
  8. width:120px !important;
  9. }
  10. /* 功能说明:统一个人退费源模板表头宽高,和当前运行页保持一致 by xu 20260513 */
  11. .form tr th{
  12. width:120px !important;
  13. height:40px;
  14. }
  15. /* 把content-box的高度限制 从公共css 抽到具体有需要的页面 by xu 20251215 */
  16. .form-container .content-box {
  17. height: calc(100% - 80px) !important;
  18. }
  19. </style>
  20. --%>
  21. </head>
  22. <body class="env-input-body">
  23. <%-- 功能说明:个人充值/退费源模板接入免连接 NFC 刷卡监听,支持失焦后回填卡号 by xu 20260513 --%>
  24. <script type="text/javascript" src="/js/reader/ka-nfc-page.js"></script>
  25. <form method="post" id="app" class="form-container">
  26. <div class="content-box fit-height-content">
  27. <div class="content-div" ssFith="true">
  28. <table class='form'>
  29. <tr>
  30. <th style="width: 120px">退费类别</th>
  31. <td >
  32. <%-- 功能说明:个人退费页退费类别切换时联动重跑金额校验 by xu 20260323 --%>
  33. <onoff.ss name="grczlbm" rad="true" val="" chg="handleGrczlbmChange" />
  34. <%
  35. Map<Integer,String > grczlbMap = (Map)(request.getAttribute("grczlbMap"));
  36. for (Integer key : grczlbMap.keySet()) {
  37. pageContext.setAttribute("k",key);
  38. pageContext.setAttribute("v",grczlbMap.get(key));
  39. %>
  40. <input name="grczlbm" value="${v}" ssVal="${k}" />
  41. <%
  42. }
  43. %>
  44. </td>
  45. </tr>
  46. <tr>
  47. <th>班级/亲属</th>
  48. <td style="display: flex;align-items: center;border: none;
  49. border-right: 1px solid #e2e4ec;">
  50. <objp.ss name="bjid" cb="bj" inp="true" width="200px"/>
  51. <%-- 再改,使用新加的 <onoff@ss opt= 和 扩展的 val=。Lin
  52. <onoff@ss name="rylbm" mode="edit" rad="false" null="false" val="1100" />
  53. <@input name="rylbm" value="职工亲属" ssVal="1000" />
  54. --%> <onoff.ss name="rylbm" opt="职工亲属" val="1000,1100"/>
  55. </td>
  56. </tr>
  57. <%-- 功能说明:个人充值/退费源模板补回卡号输入框,供免连接刷卡直接回填 by xu 20260513 --%>
  58. <tr>
  59. <th>卡号</th>
  60. <td>
  61. <script>
  62. ss.dom.formElemConfig.kah={val:'',type:window.ss.dom.TYPE.INPUT};
  63. </script>
  64. <ss-inp v-model="kah" name="kah" placeholder="请刷卡或输入卡号"></ss-inp>
  65. </td>
  66. </tr>
  67. <tr>
  68. <th>人员</th>
  69. <td>
  70. <input name="czryid" type="hidden" value='${sessionScope.ssUser.ryid}'/> <%-- 操作人员ID。Lin --%>
  71. <objp.ss name="ryid" cb="ryByBjOrRylbOrTflb" inp="true" chg="selBaseInfoByRyid" filterField="bjid,rylbm,grczlbm" />
  72. </td>
  73. </tr>
  74. <tr>
  75. <th>部门/班级</th>
  76. <td id='bmbj' class="play"></td>
  77. </tr>
  78. <tr>
  79. <th>姓名</th>
  80. <td id='xm' class="play"></td>
  81. </tr>
  82. <tr>
  83. <th>人员号</th>
  84. <td id='ryh' class="play"></td>
  85. </tr>
  86. <tr>
  87. <th>金额</th>
  88. <td>
  89. <script>
  90. // 功能说明:个人退费页金额字段改为 SsInp 组件,并声明 Vue 表单模型 by xu 20260323
  91. ss.dom.formElemConfig.je={val:'',type:window.ss.dom.TYPE.INPUT};
  92. </script>
  93. <ss-inp v-model="je" name="je"></ss-inp>
  94. </td>
  95. </tr>
  96. <tr>
  97. <th>消费余额</th>
  98. <%-- 再改,改为只显示。Lin
  99. <td ><@input name="xfye"/></td>
  100. --%> <td id='xfye' class="play"></td>
  101. </tr>
  102. <tr>
  103. <th>描述</th>
  104. <td>
  105. <script>
  106. // 功能说明:个人退费页描述字段改为 SsInp 组件,并声明 Vue 表单模型 by xu 20260323
  107. ss.dom.formElemConfig.ms={val:'',type:window.ss.dom.TYPE.INPUT};
  108. </script>
  109. <ss-inp v-model="ms" name="ms" height="72px"></ss-inp> <%-- height="72px" = <@input ssRow="3"。Lin --%>
  110. </td>
  111. </tr>
  112. </table>
  113. </div>
  114. </div>
  115. <div class='bottom-div'>
  116. <ss-btn
  117. <%-- 再去掉,没用到。Lin
  118. id="saveAndCommit"
  119. --%>
  120. text="保存并提交"
  121. onclick='submitGrtfForm();'<%-- 功能说明:个人退费页提交前先校验金额必须为负数 by xu 20260323 --%>
  122. icon-class="bottom-div-save"
  123. ></ss-btn>
  124. <ss-btn
  125. text="关闭"
  126. onclick='ss.display.closeDialog();'
  127. icon-class="bottom-div-close"
  128. ></ss-btn>
  129. </div>
  130. </form>
  131. </body>
  132. </html>
  133. <script>
  134. function getFormAppVm(){
  135. var appEl = document.getElementById("app");
  136. if (!appEl || !appEl.__vue_app__ || !appEl.__vue_app__._instance) {
  137. return null;
  138. }
  139. return appEl.__vue_app__._instance.proxy || null;
  140. }
  141. // 功能说明:个人充值/退费源模板补充卡号输入框自动聚焦,和当前运行页保持一致 by xu 20260513
  142. function focusKahInput(trigger){
  143. var kahInput = document.querySelector('textarea[name="kah"], input[name="kah"]');
  144. if (!kahInput || typeof kahInput.focus !== "function") {
  145. return;
  146. }
  147. try {
  148. kahInput.focus();
  149. if (typeof kahInput.select === "function") {
  150. kahInput.select();
  151. }
  152. } catch (err) {}
  153. }
  154. // 功能说明:个人充值/退费源模板初始化自动聚焦卡号输入框,配合免连接刷卡直接回填 by xu 20260513
  155. function initKahInputAutoFocus(){
  156. [0, 100, 300].forEach(function(delay){
  157. setTimeout(function(){
  158. focusKahInput('timer-' + delay);
  159. }, delay);
  160. });
  161. window.addEventListener('focus', function(){
  162. focusKahInput('window-focus');
  163. });
  164. }
  165. function normalizeRylbmValues(value){
  166. if (Array.isArray(value)) {
  167. return value.map(function(item){
  168. return item == null ? "" : item.toString();
  169. }).filter(Boolean);
  170. }
  171. if (value == null || value === "") {
  172. return [];
  173. }
  174. var cleanValue = value.toString().replace(/^,+/, "");
  175. if (!cleanValue) {
  176. return [];
  177. }
  178. return cleanValue.split(/[,|]/).filter(Boolean);
  179. }
  180. function hasRelativeRylbmValue(value){
  181. return normalizeRylbmValues(value).indexOf("1000") !== -1;
  182. }
  183. function clearRyDisplay(){
  184. var bmbjEl = document.getElementById('bmbj');
  185. var xmEl = document.getElementById('xm');
  186. var ryhEl = document.getElementById('ryh');
  187. var xfyeEl = document.getElementById('xfye');
  188. if (bmbjEl) bmbjEl.innerHTML = "";
  189. if (xmEl) xmEl.innerHTML = "";
  190. if (ryhEl) ryhEl.innerHTML = "";
  191. if (xfyeEl) xfyeEl.innerHTML = "";
  192. }
  193. function clearRySelection(vm){
  194. if (!vm) {
  195. clearRyDisplay();
  196. return;
  197. }
  198. vm.ryid = "";
  199. clearRyDisplay();
  200. }
  201. function handleRylbmChange(groupValue){
  202. if (!hasRelativeRylbmValue(groupValue)) {
  203. return;
  204. }
  205. var vm = getFormAppVm();
  206. if (!vm) {
  207. clearRyDisplay();
  208. return;
  209. }
  210. vm.bjid = "";
  211. clearRySelection(vm);
  212. }
  213. function handleBjChange(value){
  214. if (value == null || value === "") {
  215. return;
  216. }
  217. var vm = getFormAppVm();
  218. if (!vm) {
  219. clearRyDisplay();
  220. return;
  221. }
  222. if (hasRelativeRylbmValue(vm.rylbm)) {
  223. vm.rylbm = "1100";
  224. }
  225. clearRySelection(vm);
  226. }
  227. function selBaseInfoByRyid(value){
  228. // 功能说明:个人充值/退费页空人员值不再请求后端,避免页面初始化时触发参数异常 by xu 20260514
  229. if (value == null || value === '') {
  230. clearRyDisplay();
  231. return;
  232. }
  233. $.ajax({
  234. url:"<serv.ss name='ry_selBaseInfoByRyid'/>",
  235. type:"post",
  236. data:{
  237. ryid:value
  238. },
  239. dataType:"json",
  240. success:function(data){
  241. if (data.ssCode != 0) {
  242. alert(data.ssMsg);
  243. return;
  244. }
  245. var d = data.ssData;
  246. document.getElementById('xm').innerHTML = d.xm;
  247. document.getElementById('ryh').innerHTML = d.ryh;
  248. if (d.rylbm != 1100) { // 不是学员。Lin
  249. if (d.bmmc)
  250. document.getElementById('bmbj').innerHTML = d.bmmc;
  251. else
  252. document.getElementById('bmbj').innerHTML = "(无)";
  253. } else {
  254. if (d.bjmc)
  255. document.getElementById('bmbj').innerHTML = d.bjmc;
  256. else
  257. document.getElementById('bmbj').innerHTML = "(无)";
  258. }
  259. // 功能说明:个人充值/退费页恢复消费余额回显,保持和人员信息联动一致 by xu 20260514
  260. if (d.xfye != null && d.xfye !== "")
  261. document.getElementById('xfye').innerHTML = d.xfye;
  262. else
  263. document.getElementById('xfye').innerHTML = "(无)";
  264. }
  265. });
  266. }
  267. </script>
  268. <script type="text/javascript" src="/js/validate/validator-rules.js"></script><%-- 功能说明:个人退费页接入桌面端校验规则,支持 SsInp 红线提示 by xu 20260323 --%>
  269. <script type="text/javascript" src="/js/validate/validation-manager.js"></script><%-- 功能说明:个人退费页接入桌面端校验管理器,支持 SsInp 红线提示 by xu 20260323 --%>
  270. <script>
  271. // 功能说明:根据当前退费类别渲染 code-label 映射,供金额负数校验复用 by xu 20260323
  272. var GRTF_LABEL_MAP = {
  273. <%
  274. for (Integer key : grczlbMap.keySet()) {
  275. %>
  276. "<%=key%>": "<%=grczlbMap.get(key)%>",
  277. <%
  278. }
  279. %>
  280. };
  281. // 功能说明:记录当前退费类别的最新 value/label,避免 onoff 隐藏值切换时机导致金额校验判断失真 by xu 20260323
  282. var CURRENT_GRTF_CATEGORY_STATE = {
  283. value: "",
  284. label: ""
  285. };
  286. // 功能说明:退费类别变化后延后一拍重跑金额校验,确保隐藏字段值更新后再清理红线状态 by xu 20260323
  287. function handleGrczlbmChange(groupValue, value, label){
  288. CURRENT_GRTF_CATEGORY_STATE.value = groupValue == null ? "" : groupValue.toString();
  289. CURRENT_GRTF_CATEGORY_STATE.label = label == null ? "" : label.toString();
  290. setTimeout(function(){
  291. if (window.ssVm && typeof window.ssVm.validateField === "function") {
  292. window.ssVm.validateField("je");
  293. return;
  294. }
  295. validateNegativeAmountByCategory(false);
  296. }, 0);
  297. }
  298. // 功能说明:初始化个人退费页金额负数校验规则,整页金额都必须输入负数 by xu 20260323
  299. function initNegativeAmountValidation(){
  300. if (!window.ssVm || typeof window.ssVm.add !== "function" || window.ss.dom._grczGrtfNegativeAmountValidationInited) {
  301. return;
  302. }
  303. window.ss.dom._grczGrtfNegativeAmountValidationInited = true;
  304. window.ssVm.add("ss.commonValidator.custom", ["je"], {
  305. msgPrfx: "金额",
  306. relField: "grczlbm",
  307. validate: function(value, categoryValue){
  308. var currentLabel = getCurrentGrczlbmLabel(categoryValue);
  309. if (value == null || value.toString().trim() === "") {
  310. return true;
  311. }
  312. if (isValidNegativeAmountText(value)) {
  313. return true;
  314. }
  315. return {
  316. valid: false,
  317. message: (currentLabel || "退费") + "金额只能输入负数"
  318. };
  319. }
  320. }, {
  321. je: window.ss.dom.formElemConfig.je ? window.ss.dom.formElemConfig.je.val : ""
  322. });
  323. }
  324. // 功能说明:根据当前退费类别值读取显示文案,供联动校验和错误提示复用 by xu 20260323
  325. function getCurrentGrczlbmLabel(categoryValue){
  326. var currentValue = categoryValue == null ? getCurrentGrczlbmValue() : categoryValue.toString();
  327. if (CURRENT_GRTF_CATEGORY_STATE.label && (!currentValue || CURRENT_GRTF_CATEGORY_STATE.value === currentValue)) {
  328. return CURRENT_GRTF_CATEGORY_STATE.label;
  329. }
  330. return GRTF_LABEL_MAP[currentValue] || "";
  331. }
  332. // 功能说明:统一判断金额文本是否为合法负数,供提交校验和 ssVm 规则复用 by xu 20260323
  333. function isValidNegativeAmountText(value){
  334. var amountText = value == null ? "" : value.toString().trim();
  335. if (!amountText) {
  336. return false;
  337. }
  338. var amountNumber = Number(amountText);
  339. return !isNaN(amountNumber) && amountNumber < 0;
  340. }
  341. // 功能说明:根据当前退费类别值读取隐藏字段值,供金额校验复用 by xu 20260323
  342. function getCurrentGrczlbmValue(){
  343. var vm = getFormAppVm();
  344. if (vm && vm.grczlbm != null && vm.grczlbm !== "") {
  345. return vm.grczlbm.toString();
  346. }
  347. var categoryElem = document.querySelector('[name="grczlbm"]');
  348. return categoryElem && categoryElem.value != null ? categoryElem.value.toString() : "";
  349. }
  350. // 功能说明:统一校验个人退费金额必须为负数,不再区分具体退费类别 by xu 20260323
  351. function validateNegativeAmountByCategory(showMsg){
  352. var currentLabel = getCurrentGrczlbmLabel();
  353. var jeElem = document.querySelector('[name="je"]');
  354. if (!jeElem) {
  355. return true;
  356. }
  357. if (isValidNegativeAmountText(jeElem.value)) {
  358. return true;
  359. }
  360. if (showMsg !== false) {
  361. alert((currentLabel || "退费") + "金额只能输入负数");
  362. jeElem.focus();
  363. }
  364. return false;
  365. }
  366. // 功能说明:个人退费页提交前先走 ssVm 全量校验,确保显示 SsInp 左侧红线与底部提示 by xu 20260323
  367. function submitGrtfForm(){
  368. if (window.ssVm && window.ssVm.validations && window.ssVm.validations.size > 0) {
  369. var validateResult = window.ssVm.validateAll();
  370. if (!validateResult.valid) {
  371. return false;
  372. }
  373. } else if (!validateNegativeAmountByCategory(true)) {
  374. return false;
  375. }
  376. var formElem = document.querySelector("form");
  377. if (!formElem) {
  378. alert("表单不存在");
  379. return false;
  380. }
  381. formElem.action = "<ss:serv name='grcz_lr_tj' dest='addSure' parm='{thisViewObject:\"grcz\",dataType:\"update\"}'/>";
  382. ss.display.resizeComponent(881,361,515,515);
  383. formElem.submit();
  384. return true;
  385. }
  386. if (window.SS && typeof SS.ready === "function") {
  387. SS.ready(function(){
  388. // 功能说明:页面初始化后同步当前退费类别状态,避免首次校验读取不到最新类别文案 by xu 20260323
  389. CURRENT_GRTF_CATEGORY_STATE.value = getCurrentGrczlbmValue();
  390. CURRENT_GRTF_CATEGORY_STATE.label = GRTF_LABEL_MAP[CURRENT_GRTF_CATEGORY_STATE.value] || "";
  391. // 功能说明:页面初始化后注册个人退费金额负数校验规则,保证 SsInp 输入时直接出现红线提示 by xu 20260323
  392. initNegativeAmountValidation();
  393. // 功能说明:个人退费源模板初始化自动聚焦卡号输入框,保持和运行页一致 by xu 20260513
  394. initKahInputAutoFocus();
  395. });
  396. }
  397. </script>