grcz_grtfAdd.ss.jsp 14 KB

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