kaztbd_add.ss.jsp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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. <form method="post" id="app" class="form-container">
  24. <div class="content-box fit-height-content">
  25. <div class="content-div" ssFith="true">
  26. <table class='form'>
  27. <tr>
  28. <th style="width: 120px">变动类别</th>
  29. <td>
  30. <%-- 功能说明:卡状态变动页table布局调整,变动类别独占一行 by xu 20260408 --%>
  31. <onoff.ss name="kaztm" rad="true" val=""/>
  32. <%
  33. Map<Integer,String > grczlbMap = (Map)(request.getAttribute("kaztMap"));
  34. for (Integer key : grczlbMap.keySet()) {
  35. pageContext.setAttribute("k",key);
  36. pageContext.setAttribute("v",grczlbMap.get(key));
  37. %>
  38. <input name="kaztm" value="${v}" ssVal="${k}" />
  39. <%
  40. }
  41. %>
  42. </td>
  43. </tr>
  44. <tr>
  45. <th>班级/亲属</th>
  46. <td style="display: flex;align-items: center;border: none;
  47. border-right: 1px solid #e2e4ec;">
  48. <%-- 功能说明:班级/亲属单独一行 by xu 20260408 --%>
  49. <objp.ss name="bjid" cb="bj" inp="true" width="200px"/>
  50. <%-- 再改,使用新加的 <onoff@ss opt= 和 扩展的 val=。Lin
  51. <onoff@ss name="rylbm" mode="edit" rad="false" null="false" val="1100" />
  52. <@input name="rylbm" value="职工亲属" ssVal="1000" />
  53. --%> <onoff.ss name="rylbm" opt="职工亲属" val="1000,1100"/>
  54. </td>
  55. </tr>
  56. <tr>
  57. <th>人员</th>
  58. <td>
  59. <%-- 功能说明:人员单独一行 by xu 20260408 --%>
  60. <input name="czryid" type="hidden" value='${sessionScope.ssUser.ryid}'/> <%-- 操作人员 ID。Lin --%>
  61. <input name="kaid" type="hidden"/> <%-- 卡 ID。Lin --%>
  62. <objp.ss name="cyryid" cb="ryByBjOrRylb" inp="true" chg="selBaseInfoByRyid" filterField="bjid,rylbm" /> <%-- 持有人员 ID.Lin --%>
  63. </td>
  64. </tr>
  65. <tr>
  66. <th>部门/班级</th>
  67. <td id='bmbj' class="play"></td>
  68. </tr>
  69. <tr>
  70. <th>姓名</th>
  71. <td id='xm' class="play"></td>
  72. </tr>
  73. <tr>
  74. <th>人员号</th>
  75. <td id='ryh' class="play"></td>
  76. </tr>
  77. <tr>
  78. <th>卡号</th>
  79. <td id='kah' class="play"></td>
  80. </tr>
  81. <tr>
  82. <th>卡状态</th>
  83. <td id='kaztmc' class="play"></td>
  84. </tr>
  85. <tr>
  86. <th>消费余额</th>
  87. <%-- 再改,改为只显示。Lin
  88. <td style="width: 100%;">
  89. <input name="xfye"/>
  90. </td>
  91. --%> <td id='xfye' class="play"></td>
  92. </tr>
  93. <tr>
  94. <th>描述</th>
  95. <td>
  96. <%-- 功能说明:描述单独一行 by xu 20260408 --%>
  97. <ss-inp v-model="ms" name="ms" height="72px"></ss-inp>
  98. </td>
  99. </tr>
  100. </table>
  101. </div>
  102. </div>
  103. <div class='bottom-div'>
  104. <ss-btn
  105. <%-- 再去掉,没用到。Lin
  106. id="saveAndCommit"
  107. --%>
  108. text="保存并提交"
  109. onclick='submitGrczForm();'<%-- 功能说明:个人充值页提交前先校验“反向充值”金额必须为负数 by xu 20260323 --%>
  110. icon-class="bottom-div-save"
  111. ></ss-btn>
  112. <ss-btn
  113. text="关闭"
  114. onclick='ss.display.closeDialog();'
  115. icon-class="bottom-div-close"
  116. ></ss-btn>
  117. </div>
  118. </form>
  119. </body>
  120. </html>
  121. <script>
  122. function getFormAppVm(){
  123. var appEl = document.getElementById("app");
  124. if (!appEl || !appEl.__vue_app__ || !appEl.__vue_app__._instance) {
  125. return null;
  126. }
  127. return appEl.__vue_app__._instance.proxy || null;
  128. }
  129. function normalizeRylbmValues(value){
  130. if (Array.isArray(value)) {
  131. return value.map(function(item){
  132. return item == null ? "" : item.toString();
  133. }).filter(Boolean);
  134. }
  135. if (value == null || value === "") {
  136. return [];
  137. }
  138. var cleanValue = value.toString().replace(/^,+/, "");
  139. if (!cleanValue) {
  140. return [];
  141. }
  142. return cleanValue.split(/[,|]/).filter(Boolean);
  143. }
  144. function hasRelativeRylbmValue(value){
  145. return normalizeRylbmValues(value).indexOf("1000") !== -1;
  146. }
  147. function clearRyDisplay(){
  148. var bmbjEl = document.getElementById('bmbj');
  149. var xmEl = document.getElementById('xm');
  150. var ryhEl = document.getElementById('ryh');
  151. var kahEl = document.getElementById('kah');
  152. var kaztmcEl = document.getElementById('kaztmc');
  153. if (bmbjEl) bmbjEl.innerHTML = "";
  154. if (xmEl) xmEl.innerHTML = "";
  155. if (ryhEl) ryhEl.innerHTML = "";
  156. if (kahEl) kahEl.innerHTML = "";
  157. if (kaztmcEl) kaztmcEl.innerHTML = "";
  158. if (document.getElementsByName('kaid')[0]) document.getElementsByName('kaid')[0].value = "";
  159. }
  160. function clearRySelection(vm){
  161. if (!vm) {
  162. clearRyDisplay();
  163. return;
  164. }
  165. // 功能说明:卡状态变动源模板人员字段实际使用 cyryid,清空时同步修正字段名 by xu 20260513
  166. vm.cyryid = "";
  167. clearRyDisplay();
  168. }
  169. function handleRylbmChange(groupValue){
  170. if (!hasRelativeRylbmValue(groupValue)) {
  171. return;
  172. }
  173. var vm = getFormAppVm();
  174. if (!vm) {
  175. clearRyDisplay();
  176. return;
  177. }
  178. vm.bjid = "";
  179. clearRySelection(vm);
  180. }
  181. function handleBjChange(value){
  182. if (value == null || value === "") {
  183. return;
  184. }
  185. var vm = getFormAppVm();
  186. if (!vm) {
  187. clearRyDisplay();
  188. return;
  189. }
  190. if (hasRelativeRylbmValue(vm.rylbm)) {
  191. vm.rylbm = "1100";
  192. }
  193. clearRySelection(vm);
  194. }
  195. function selBaseInfoByRyid(value){
  196. // 功能说明:卡状态变动源模板空人员值不再请求后端,避免初始化时触发参数异常 by xu 20260513
  197. if (value == null || value === '') {
  198. clearRyDisplay();
  199. return;
  200. }
  201. $.ajax({
  202. url:"<serv.ss name='kaztbd_selInfoByRyid'/>",
  203. type:"post",
  204. data:{
  205. ryid:value
  206. },
  207. dataType:"json",
  208. success:function(data){
  209. if (data.ssCode != 0) {
  210. alert(data.ssMsg);
  211. return;
  212. }
  213. var d = data.ssData;
  214. document.getElementById('xm').innerHTML = d.xm;
  215. document.getElementById('ryh').innerHTML = d.ryh;
  216. if (d.rylbm != 1100) { // 不是学员。Lin
  217. if (d.bmmc)
  218. document.getElementById('bmbj').innerHTML = d.bmmc;
  219. else
  220. document.getElementById('bmbj').innerHTML = "(无)";
  221. } else {
  222. if (d.bjmc)
  223. document.getElementById('bmbj').innerHTML = d.bjmc;
  224. else
  225. document.getElementById('bmbj').innerHTML = "(无)";
  226. }
  227. if (d.kah)
  228. document.getElementById('kah').innerHTML = d.kah;
  229. else
  230. document.getElementById('kah').innerHTML = "(无)";
  231. if (d.kaztmc)
  232. document.getElementById('kaztmc').innerHTML = d.kaztmc;
  233. else
  234. document.getElementById('kaztmc').innerHTML = "(无)";
  235. document.getElementsByName('kaid')[0].value = d.kaid;
  236. }
  237. });
  238. }
  239. </script>
  240. <script type="text/javascript" src="/js/validate/validator-rules.js"></script><%-- 功能说明:个人充值页接入桌面端校验规则,支持 SsInp 红线提示 by xu 20260323 --%>
  241. <script type="text/javascript" src="/js/validate/validation-manager.js"></script><%-- 功能说明:个人充值页接入桌面端校验管理器,支持 SsInp 红线提示 by xu 20260323 --%>
  242. <script>
  243. // 功能说明:维护个人充值页中需要强制输入负数的充值类别编码,供金额校验复用 by xu 20260323
  244. var NEGATIVE_ONLY_GRCZLBM_MAP = {
  245. "21": "反向充值"
  246. };
  247. // 功能说明:充值类别变化后延后一拍重跑金额校验,确保隐藏字段值更新后再清理红线状态 by xu 20260323
  248. function handleGrczlbmChange(groupValue, value, label){
  249. setTimeout(function(){
  250. if (window.ssVm && typeof window.ssVm.validateField === "function") {
  251. window.ssVm.validateField("je");
  252. return;
  253. }
  254. validateNegativeAmountByCategory(false);
  255. }, 0);
  256. }
  257. // 功能说明:初始化金额负数校验规则,接入 ssVm 统一红线与底部提示 by xu 20260323
  258. function initNegativeAmountValidation(){
  259. if (!window.ssVm || typeof window.ssVm.add !== "function" || window.ss.dom._grczNegativeAmountValidationInited) {
  260. return;
  261. }
  262. window.ss.dom._grczNegativeAmountValidationInited = true;
  263. window.ssVm.add("ss.commonValidator.custom", ["je"], {
  264. msgPrfx: "金额",
  265. relField: "grczlbm",
  266. validate: function(value, categoryValue){
  267. if (!isNegativeOnlyGrczlbm(categoryValue)) {
  268. return true;
  269. }
  270. if (value == null || value.toString().trim() === "") {
  271. return true;
  272. }
  273. if (isValidNegativeAmountText(value)) {
  274. return true;
  275. }
  276. return {
  277. valid: false,
  278. message: NEGATIVE_ONLY_GRCZLBM_MAP[categoryValue] + "金额只能输入负数"
  279. };
  280. }
  281. }, {
  282. je: window.ss.dom.formElemConfig.je ? window.ss.dom.formElemConfig.je.val : ""
  283. });
  284. }
  285. // 功能说明:根据充值类别判断当前金额是否必须为负数 by xu 20260323
  286. function isNegativeOnlyGrczlbm(categoryValue){
  287. var currentValue = categoryValue == null ? "" : categoryValue.toString();
  288. return !!NEGATIVE_ONLY_GRCZLBM_MAP[currentValue];
  289. }
  290. // 功能说明:统一判断金额文本是否为合法负数,供提交校验和 ssVm 规则复用 by xu 20260323
  291. function isValidNegativeAmountText(value){
  292. var amountText = value == null ? "" : value.toString().trim();
  293. if (!amountText) {
  294. return false;
  295. }
  296. var amountNumber = Number(amountText);
  297. return !isNaN(amountNumber) && amountNumber < 0;
  298. }
  299. // 功能说明:根据当前充值类别判断是否必须录入负数金额 by xu 20260323
  300. function getCurrentGrczlbmValue(){
  301. var vm = getFormAppVm();
  302. if (vm && vm.grczlbm != null && vm.grczlbm !== "") {
  303. return vm.grczlbm.toString();
  304. }
  305. var categoryElem = document.querySelector('[name="grczlbm"]');
  306. return categoryElem && categoryElem.value != null ? categoryElem.value.toString() : "";
  307. }
  308. // 功能说明:统一校验金额字段在指定充值类别下是否为负数 by xu 20260323
  309. function validateNegativeAmountByCategory(showMsg){
  310. var categoryValue = getCurrentGrczlbmValue();
  311. if (!isNegativeOnlyGrczlbm(categoryValue)) {
  312. return true;
  313. }
  314. var jeElem = document.querySelector('[name="je"]');
  315. if (!jeElem) {
  316. return true;
  317. }
  318. if (isValidNegativeAmountText(jeElem.value)) {
  319. return true;
  320. }
  321. if (showMsg !== false) {
  322. alert(NEGATIVE_ONLY_GRCZLBM_MAP[categoryValue] + "金额只能输入负数");
  323. jeElem.focus();
  324. }
  325. return false;
  326. }
  327. // 功能说明:个人充值页提交前先走 ssVm 全量校验,确保显示 SsInp 左侧红线与底部提示 by xu 20260323
  328. function submitGrczForm(){
  329. if (window.ssVm && window.ssVm.validations && window.ssVm.validations.size > 0) {
  330. var validateResult = window.ssVm.validateAll();
  331. if (!validateResult.valid) {
  332. return false;
  333. }
  334. } else if (!validateNegativeAmountByCategory(true)) {
  335. return false;
  336. }
  337. var formElem = document.querySelector("form");
  338. if (!formElem) {
  339. alert("表单不存在");
  340. return false;
  341. }
  342. formElem.action = "<ss:serv name='kaztbd_lr_tj' dest='addSure' parm='{thisViewObject:\"kaztbd\",dataType:\"update\"}'/>";
  343. ss.display.resizeComponent(881,361,515,515);
  344. formElem.submit();
  345. return true;
  346. }
  347. if (window.SS && typeof SS.ready === "function") {
  348. SS.ready(function(){
  349. // 功能说明:页面初始化后注册金额负数校验规则,保证 SsInp 输入时直接出现红线提示 by xu 20260323
  350. initNegativeAmountValidation();
  351. });
  352. }
  353. </script>