compilation.js 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402
  1. /**
  2. * 编办管理相关js
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/7/28
  6. * @version
  7. */
  8. const delayTime = 500;
  9. let keyupTime;
  10. function delayKeyup(callback) {
  11. let nowTime = Date.now();
  12. keyupTime = nowTime;
  13. setTimeout(function () {
  14. if (nowTime - keyupTime == 0 && callback) {
  15. callback();
  16. }
  17. }, delayTime);
  18. }
  19. $(document).ready(function () {
  20. let isAdding = false;
  21. let model = "";
  22. let section =
  23. $(".nav-tabs li.active > a").text() === "建议估算" ? "suggestion" : "bill";
  24. let id = $("#compilation-id").val();
  25. // 计价规则页面初始化数据
  26. if ($("#save-lib").length > 0) {
  27. initCompilation();
  28. }
  29. // 计价类型选择
  30. $(".nav-tabs li > a").click(function () {
  31. section = $(this).attr("aria-controls");
  32. });
  33. // 新增编办
  34. $("#add-compilation").click(function () {
  35. try {
  36. let data = getAndValidData(model);
  37. let url = "/compilation/add";
  38. if (model === "all") {
  39. // 新增编办操作
  40. $.ajax({
  41. url: url,
  42. type: "post",
  43. data: { name: data.name },
  44. error: function () {
  45. isAdding = false;
  46. },
  47. beforeSend: function () {
  48. isAdding = true;
  49. },
  50. success: function (response) {
  51. isAdding = false;
  52. if (response.err === 0) {
  53. window.location.reload();
  54. } else {
  55. let msg = response.msg === undefined ? "未知错误" : response.msg;
  56. alert(msg);
  57. }
  58. },
  59. });
  60. } else {
  61. // 新增标准清单/定额库
  62. let addLib = {
  63. name: data[model].name,
  64. id: data[model].id,
  65. };
  66. // 判断是否有重复的数据
  67. if (
  68. $(
  69. "input:hidden[name='" +
  70. model +
  71. "_lib'][data-id='" +
  72. addLib.id +
  73. "']"
  74. ).length > 0
  75. ) {
  76. alert("重复添加数据!");
  77. return false;
  78. }
  79. let removeHtml =
  80. '<a class="pull-right text-danger remove-lib" data-model="' +
  81. model +
  82. '" ' +
  83. 'title="移除"><span class="glyphicon glyphicon-remove"></span></a>';
  84. let tmpHtml =
  85. '<p class="form-control-static">' +
  86. removeHtml +
  87. addLib.name +
  88. '<input type="hidden" data-id="' +
  89. addLib.id +
  90. "\" name='" +
  91. model +
  92. "_lib' value='" +
  93. JSON.stringify(addLib) +
  94. "'>" +
  95. "</p>";
  96. $("." + model + "-list").append(tmpHtml);
  97. $("#addcompilation").modal("hide");
  98. }
  99. } catch (error) {
  100. alert(error);
  101. }
  102. });
  103. $("#addTaxGroupBtn").click(function () {
  104. $("#groupEditType").val("add");
  105. $("#taxType").val("");
  106. $("#program_lib").val("");
  107. $("#template_lib").val("");
  108. $("#col_lib").val("");
  109. $("#fee_lib").val("");
  110. });
  111. //新增计税组合
  112. $("#add-group").click(function () {
  113. let taxMap = { 1: "一般计税", 2: "简易计税" };
  114. let actionType = $("#groupEditType").val();
  115. let groupData = getTaxGroupData();
  116. let groupIndex = getGroupIndex(groupData); //用来做重复判断
  117. if (!_.isEmpty(groupData)) {
  118. //重复判断 todo
  119. if ($("input[data-id = " + groupIndex + "]").length <= 0) {
  120. let taxName = groupData.taxType ? taxMap[groupData.taxType] : "";
  121. let p_name = groupData.program_lib
  122. ? groupData.program_lib.displayName
  123. : "";
  124. let t_name = groupData.template_lib ? groupData.template_lib.name : "";
  125. let c_name = groupData.col_lib ? groupData.col_lib.name : "";
  126. let f_name = groupData.fee_lib ? groupData.fee_lib.name : "";
  127. let htmlString =
  128. "<tr class='taxGroup_tr'><td><span>" +
  129. taxName +
  130. "</span></td>" +
  131. "<td><span>" +
  132. p_name +
  133. "</span></td>" +
  134. "<td><span>" +
  135. t_name +
  136. "</span></td>" +
  137. "<td><span>" +
  138. c_name +
  139. "</span></td>" +
  140. "<td><span>" +
  141. f_name +
  142. "</span></td>" +
  143. "<td> <a class='btn btn-link btn-sm' style='padding: 0px' onclick='editTaxGroup(this)'> 编辑</a>/<a class='btn btn-link btn-sm ' style='padding: 0px' onclick='deleteTableTr(this,\"taxGroup_tr\")'>删除</a> " +
  144. "<input type='hidden' name='tax_group' data-id ='" +
  145. groupIndex +
  146. "' value='" +
  147. JSON.stringify(groupData) +
  148. "'>" +
  149. "</td>" +
  150. "</tr>";
  151. if (actionType == "add") {
  152. $("#tax_group_tbody").append(htmlString);
  153. } else if (actionType == "modify") {
  154. let oldIndex = $("#groupIndex").val();
  155. let parentTr = $("input[data-id = " + oldIndex + "]").parents(
  156. ".taxGroup_tr"
  157. );
  158. parentTr.after(htmlString);
  159. parentTr.remove();
  160. }
  161. } else {
  162. alert("已存在相同的组合!");
  163. }
  164. }
  165. $("#addTaxGroup").modal("hide");
  166. });
  167. $("#ration_lib-search-box").on("input", function () {
  168. var keyword = $(this).val().toLowerCase().trim(); // 获取输入的关键字并转为小写
  169. // 遍历所有option元素
  170. $('select[name="ration_lib"] option').each(function () {
  171. var optionText = $(this).text().toLowerCase(); // 获取option的文本并转为小写
  172. // 如果option文本包含关键字,则显示,否则隐藏
  173. if (optionText.indexOf(keyword) !== -1) {
  174. $(this).show();
  175. } else {
  176. $(this).hide();
  177. }
  178. });
  179. });
  180. //新增定额库
  181. $("#add-ration").click(function () {
  182. const options = $("select[name='ration_lib']").children("option:selected");
  183. let alertArr = [];
  184. let htmlString = "";
  185. for (const option of options) {
  186. const rationLib = $(option).val();
  187. const rationLibString = $(option).text();
  188. if (!rationLib) {
  189. alertString.push(`“${rationLibString}”为无效定额库`);
  190. continue;
  191. }
  192. if (
  193. $("input:hidden[name=ration_lib][data-id = " + rationLib + "]").length >
  194. 0
  195. ) {
  196. alertArr.push(`“${rationLibString}”已存在`);
  197. continue;
  198. }
  199. const tem = {
  200. id: rationLib,
  201. name: rationLibString,
  202. isDefault: false,
  203. };
  204. htmlString += `
  205. <tr class='ration_tr' draggable="true">
  206. <td><span class="cursor-default">${tem.name}</span></td>
  207. <td><label class="form-check-label"> <input class="form-check-input" name="ration_isDefault" value="${
  208. tem.id
  209. }" type="radio"></td>
  210. <td>
  211. <a class='btn btn-link btn-sm ' style="padding: 0px" onclick='deleteTableTr(this,"ration_tr")'>删除</a>
  212. <input type="hidden" name="ration_lib" data-id="${
  213. tem.id
  214. }" value='${JSON.stringify(tem)}'>
  215. </td>
  216. </tr>`;
  217. }
  218. if (alertArr.length) {
  219. alert(alertArr.join("\n"));
  220. } else {
  221. $("#ration_tbody").append(htmlString);
  222. $("#addRation").modal("hide");
  223. }
  224. });
  225. // 复制定额库
  226. $("#copy-lib-confirm").click(async function () {
  227. try {
  228. $.bootstrapLoading.start();
  229. const [valuationID, engineeringID] = window.location.pathname
  230. .split("/")
  231. .slice(-2);
  232. await ajaxPost("/compilation/copyRationLibs", {
  233. valuationID,
  234. engineeringID,
  235. });
  236. } catch (err) {
  237. console.log(err);
  238. } finally {
  239. $.bootstrapLoading.end();
  240. }
  241. });
  242. // 拖动排序
  243. const dragSelector = ".ration_tr[draggable=true]";
  244. const rationBodySelector = "#ration_tbody";
  245. const wrapper = $(".panel-content")[0];
  246. let dragged;
  247. let rID = null;
  248. const scrollStep = 6;
  249. // 表格数据过多的时候,靠下方的条目想要移动到上方,需要滚动条滚动到相应位置,滚动条向上滚动需要代码自行处理
  250. function scroll(ele, step) {
  251. wrapper.scrollTop -= step;
  252. rID = window.requestAnimationFrame(() => {
  253. scroll(ele, step);
  254. });
  255. }
  256. // 动态绑定(新增的也能监听到)
  257. $(rationBodySelector).on("drag", dragSelector, function (ev) {
  258. const { clientX, clientY } = ev;
  259. const dom = document.elementFromPoint(clientX, clientY);
  260. if (dom.tagName === "H2" && !rID) {
  261. rID = window.requestAnimationFrame(() => {
  262. scroll(wrapper, scrollStep);
  263. });
  264. } else if (dom.tagName !== "H2" && rID) {
  265. window.cancelAnimationFrame(rID);
  266. rID = null;
  267. }
  268. });
  269. $(rationBodySelector).on("dragstart", dragSelector, function (ev) {
  270. dragged = this;
  271. $(this).addClass("dragging");
  272. ev.originalEvent.dataTransfer.effectAllowed = "move";
  273. });
  274. $(rationBodySelector).on("dragend", dragSelector, function (ev) {
  275. $(this).removeClass("dragging");
  276. if (rID) {
  277. window.cancelAnimationFrame(rID);
  278. rID = null;
  279. }
  280. });
  281. $(rationBodySelector).on("dragover", dragSelector, function (ev) {
  282. ev.preventDefault(); // 必须调用此方法,否则drop事件不触发
  283. });
  284. $(rationBodySelector).on("dragenter", dragSelector, function (ev) {
  285. if (this !== dragged) {
  286. $(this).addClass("highlight");
  287. }
  288. });
  289. $(rationBodySelector).on("dragleave", dragSelector, function (ev) {
  290. if (this !== dragged) {
  291. $(this).removeClass("highlight");
  292. }
  293. });
  294. $(rationBodySelector).on("drop", dragSelector, function (ev) {
  295. $(this).removeClass("highlight");
  296. $(this).after($(dragged));
  297. });
  298. // 新增计价规则
  299. $("#add-valuation").click(function () {
  300. try {
  301. if (id === "") {
  302. throw "页面数据有误";
  303. }
  304. let name = $("input[name='valuation_name']").val();
  305. if (name === "") {
  306. throw "请填写计价规则名称";
  307. }
  308. $.ajax({
  309. url: "/compilation/add-valuation",
  310. type: "post",
  311. data: { name: name, id: id, section: section },
  312. error: function () {
  313. isAdding = false;
  314. },
  315. beforeSend: function () {
  316. isAdding = true;
  317. },
  318. success: function (response) {
  319. isAdding = false;
  320. if (response.err === 0) {
  321. window.location.reload();
  322. } else {
  323. let msg = response.msg === undefined ? "未知错误" : response.msg;
  324. alert(msg);
  325. }
  326. },
  327. });
  328. } catch (error) {
  329. alert(error);
  330. return false;
  331. }
  332. });
  333. // 添加
  334. $(".add-compilation").click(function () {
  335. model = $(this).data("model");
  336. $("#addcompilation .modal-body > div").hide();
  337. switch (model) {
  338. case "all":
  339. $("#name-area").show();
  340. $("#add-compilation-title").text("添加新费用定额");
  341. break;
  342. case "bill":
  343. $("#bill-area").show();
  344. $("#add-compilation-title").text("添加标准清单");
  345. break;
  346. case "ration":
  347. $("#ration-area").show();
  348. $("#add-compilation-title").text("添加定额库");
  349. break;
  350. case "glj":
  351. $("#glj-area").show();
  352. $("#add-compilation-title").text("添加定额库");
  353. break;
  354. case "billsGuidance":
  355. $("#billsGuidance-area").show();
  356. $("#add-compilation-title").text("添加清单指引库");
  357. break;
  358. case "fee":
  359. $("#fee-area").show();
  360. $("#add-compilation-title").text("添加费率标准");
  361. break;
  362. case "artificial":
  363. $("#artificial-area").show();
  364. $("#add-compilation-title").text("添加人工系数");
  365. break;
  366. case "program":
  367. $("#program-area").show();
  368. $("#add-compilation-title").text("添加计算程序");
  369. break;
  370. case "feature":
  371. $("#feature-area").show();
  372. $("#add-compilation-title").text("添加工程特征");
  373. break;
  374. case "info":
  375. $("#info-area").show();
  376. $("#add-compilation-title").text("添加基本信息");
  377. break;
  378. case "progressive":
  379. $("#progressive-area").show();
  380. $("#add-compilation-title").text("添加累进区间");
  381. break;
  382. case "vvTax":
  383. $("#vvTax-area").show();
  384. $("#add-compilation-title").text("添加车船税");
  385. break;
  386. case "billCode":
  387. $("#billCode-area").show();
  388. $("#add-compilation-title").text("添加递延清单库");
  389. break;
  390. }
  391. $("#addcompilation").modal("show");
  392. });
  393. // 保存专业工程标准库
  394. $("#save-lib").click(function () {
  395. if (validLib()) {
  396. $("form").submit();
  397. }
  398. });
  399. // 保存计价规则
  400. $("#save-valuation").click(function () {
  401. $("#saveValuation").submit();
  402. });
  403. // 移除操作
  404. $(
  405. ".bill-list, .ration-list, .glj-list, .fee-list, .artificial-list, .program-list, .billsGuidance-list,.feature-list,.info-list,.progressive-list,.vvTax-list,.billCode-list"
  406. ).on("click", ".remove-lib", function () {
  407. $(this).parent().remove();
  408. });
  409. //更改描述
  410. $("#description").change(function () {
  411. let description = $(this).val();
  412. $.ajax({
  413. url: "/compilation/setDescription",
  414. type: "post",
  415. dataType: "json",
  416. data: { id: id, description: description },
  417. success: function (response) {
  418. if (response.err !== 0) {
  419. alert("更改失败");
  420. }
  421. },
  422. });
  423. });
  424. //更改代码覆盖路径
  425. $("#overWriteUrl").change(function () {
  426. let overWriteUrl = $(this).val();
  427. if (overWriteUrl == "") overWriteUrl = undefined;
  428. $.ajax({
  429. url: "/compilation/setOverWriteUrl",
  430. type: "post",
  431. dataType: "json",
  432. data: { id: id, overWriteUrl: overWriteUrl },
  433. success: function (response) {
  434. if (response.err !== 0) {
  435. alert("更改失败");
  436. }
  437. },
  438. });
  439. });
  440. //例题建设项目ID, 用英文字符;分隔建设项目ID
  441. $("#example").keyup(function () {
  442. let exampleVal = $(this).val();
  443. let tempExample = exampleVal.split(/[;,;]/g),
  444. example = [];
  445. for (let te of tempExample) {
  446. if (te.trim() !== "") {
  447. example.push(te.trim());
  448. }
  449. }
  450. example = Array.from(new Set(example));
  451. delayKeyup(function () {
  452. $.ajax({
  453. url: "/compilation/setExample",
  454. type: "post",
  455. dataType: "json",
  456. data: { id: id, example: example },
  457. success: function (response) {
  458. if (response.err !== 0) {
  459. alert("更改失败");
  460. }
  461. },
  462. });
  463. });
  464. });
  465. // 计价规则启用/禁止
  466. $(".enable").click(function () {
  467. let goingChangeStatus = switchChange($(this));
  468. let id = $(this).data("id");
  469. if (id === undefined || id === "" || isAdding) {
  470. return false;
  471. }
  472. $.ajax({
  473. url: "/compilation/valuation/" + section + "/enable",
  474. type: "post",
  475. dataType: "json",
  476. data: { id: id, enable: goingChangeStatus },
  477. error: function () {
  478. isAdding = false;
  479. switchChange($(this));
  480. },
  481. beforeSend: function () {
  482. isAdding = true;
  483. },
  484. success: function (response) {
  485. isAdding = false;
  486. if (response.err !== 0) {
  487. switchChange($(this));
  488. alert("更改失败");
  489. }
  490. },
  491. });
  492. });
  493. // 设置适用类型
  494. $(".fileType").change(function () {
  495. let id = $(this).data("id");
  496. if (id === undefined || id === "" || isAdding) {
  497. return false;
  498. }
  499. let fileTypes = [];
  500. let oldVal = $(this).attr("checked");
  501. if (oldVal) {
  502. $(this).removeAttr("checked");
  503. } else {
  504. $(this).attr("checked", "checked");
  505. }
  506. if ($("#" + id + "_suggest_gusuan").attr("checked")) fileTypes.push(16);
  507. if ($("#" + id + "_gusuan").attr("checked")) fileTypes.push(15);
  508. if ($("#" + id + "_estimate").attr("checked")) fileTypes.push(5);
  509. if ($("#" + id + "_submission").attr("checked")) fileTypes.push(1);
  510. if ($("#" + id + "_three_bill_budget").attr("checked")) fileTypes.push(18);
  511. if ($("#" + id + "_bill_budget").attr("checked")) fileTypes.push(19);
  512. if ($("#" + id + "_changeBudget").attr("checked")) fileTypes.push(4);
  513. if ($("#" + id + "_settlement").attr("checked")) fileTypes.push(10);
  514. let current = $(this);
  515. console.log(id, this);
  516. $.ajax({
  517. url: "/compilation/valuation/" + section + "/fileTypes",
  518. type: "post",
  519. dataType: "json",
  520. data: { id: id, fileTypes: fileTypes },
  521. error: function () {
  522. //恢复原值
  523. if (oldVal) {
  524. current.attr("checked", "checked");
  525. } else {
  526. current.removeAttr("checked");
  527. }
  528. },
  529. success: function (response) {
  530. if (response.err !== 0) {
  531. switchChange($(this));
  532. alert("更改失败");
  533. }
  534. },
  535. });
  536. });
  537. //计价规则删除
  538. $("#delete-confirm").click(function () {
  539. let id = $("#del").attr("selectedId");
  540. if (id === undefined || id === "") {
  541. return false;
  542. }
  543. window.location.href = `/compilation/valuation/${section}/delete/${id}`;
  544. });
  545. // 发布编办
  546. $("#release").click(function () {
  547. let id = $(this).data("id");
  548. let status = $(this).data("status");
  549. status = parseInt(status);
  550. if (isAdding || id === "" || isNaN(status)) {
  551. return false;
  552. }
  553. $.ajax({
  554. url: "/compilation/release",
  555. type: "post",
  556. data: { id: id, status: status },
  557. dataType: "json",
  558. error: function () {
  559. isAdding = false;
  560. },
  561. beforeSend: function () {
  562. isAdding = true;
  563. },
  564. success: function (response) {
  565. isAdding = false;
  566. if (response.err === 0) {
  567. window.location.reload();
  568. } else {
  569. let msg = response.msg === undefined ? "未知错误" : response.msg;
  570. alert(msg);
  571. }
  572. },
  573. });
  574. });
  575. //添加工程专业
  576. $("#addEngineerConfirm").click(async function () {
  577. if ($("#name").val() == "") {
  578. $("#nameError").show();
  579. return;
  580. }
  581. if ($("#feeName").val() == "") {
  582. $("#feeNameError").show();
  583. return;
  584. }
  585. if ($("#engineeringInput").val() == "") {
  586. $("#engineeringError").show();
  587. return;
  588. }
  589. if ($("#projectEngineering").val() == "") {
  590. $("#projectError").show();
  591. return;
  592. }
  593. $("#addEngineerConfirm").attr("disabled", true); //防止重复提交
  594. $("#addEngineerForm").submit();
  595. });
  596. //
  597. // CLD 办事处选择
  598. $("#category-select").change(function () {
  599. $.ajax({
  600. url: "/compilation/changeCategory",
  601. type: "post",
  602. data: { id: id, category: $(this).val() },
  603. dataType: "json",
  604. success: function (response) {
  605. if (response.error !== 0) {
  606. alert("更改失败");
  607. }
  608. },
  609. });
  610. });
  611. // 选择默认所在地
  612. $("#location-select").change(function () {
  613. $.ajax({
  614. url: "/compilation/changeLocation",
  615. type: "post",
  616. data: { id: id, location: $(this).val() },
  617. dataType: "json",
  618. success: function (response) {
  619. if (response.error !== 0) {
  620. alert("更改失败");
  621. }
  622. },
  623. });
  624. });
  625. // 选择编办类型
  626. $("#type-select").change(function () {
  627. $.ajax({
  628. url: "/compilation/changeCompilation",
  629. type: "post",
  630. data: { id: id, update: { type: $(this).val() } },
  631. dataType: "json",
  632. success: function (response) {
  633. if (response.error !== 0) {
  634. alert("更改失败");
  635. }
  636. },
  637. });
  638. });
  639. // 修改是否提供免费版
  640. $("#freeUse").change(function (val) {
  641. $.ajax({
  642. url: "/compilation/changeFreeUse",
  643. type: "post",
  644. data: { id: id, freeUse: $(this).prop("checked") },
  645. dataType: "json",
  646. success: function (response) {
  647. if (response.error !== 0) {
  648. alert("更改失败");
  649. }
  650. },
  651. });
  652. });
  653. // 选择编办类型
  654. $("#customMade").change(function () {
  655. $.ajax({
  656. url: "/compilation/changeCompilation",
  657. type: "post",
  658. data: { id: id, update: { customMade: $(this).prop("checked") } },
  659. dataType: "json",
  660. success: function (response) {
  661. if (response.error !== 0) {
  662. alert("更改失败");
  663. }
  664. },
  665. });
  666. });
  667. //更改版本号
  668. $("#edition").change(function () {
  669. let edition = $(this).val();
  670. $.ajax({
  671. url: "/compilation/setEdition",
  672. type: "post",
  673. dataType: "json",
  674. data: { id: id, edition: edition },
  675. success: function (response) {
  676. if (response.err !== 0) {
  677. alert("更改失败");
  678. }
  679. },
  680. });
  681. });
  682. //更改序号
  683. $("#serialNumber").change(function () {
  684. let serialNumber = Number($(this).val());
  685. $.ajax({
  686. url: "/compilation/setSerialNumber",
  687. type: "post",
  688. dataType: "json",
  689. data: { id: id, serialNumber: serialNumber },
  690. success: function (response) {
  691. if (response.err !== 0) {
  692. alert("更改失败");
  693. }
  694. },
  695. });
  696. });
  697. });
  698. /**
  699. * 初始化
  700. *
  701. * @return {void|boolean}
  702. */
  703. function initCompilation() {
  704. let billListData = billList === undefined ? [] : JSON.parse(billList);
  705. let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
  706. let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
  707. let feeLibData = feeRateList === undefined ? [] : JSON.parse(feeRateList);
  708. let artificialCoefficientData =
  709. artificialCoefficientList === undefined
  710. ? []
  711. : JSON.parse(artificialCoefficientList);
  712. let programData = programList === undefined ? [] : JSON.parse(programList);
  713. let billsGuidanceData =
  714. billsGuidanceList === undefined ? [] : JSON.parse(billsGuidanceList);
  715. let billTemplateData =
  716. billTemplateList == undefined ? [] : JSON.parse(billTemplateList);
  717. let mainTreeColData =
  718. mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
  719. let featureData = featureList == undefined ? [] : JSON.parse(featureList);
  720. let infoData = infoList == undefined ? [] : JSON.parse(infoList);
  721. let progressiveData =
  722. progressiveList == undefined ? [] : JSON.parse(progressiveList);
  723. let vvTaxData = vvTaxList == undefined ? [] : JSON.parse(vvTaxList);
  724. let billCodeData = billCodeList == undefined ? [] : JSON.parse(billCodeList);
  725. /*mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
  726. billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
  727. let mainTreeColObj = mainTreeCol === '' ? {} : JSON.parse(mainTreeCol);
  728. // 初始化 造价书列设置
  729. colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
  730. let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
  731. billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
  732. if (mainTreeCol !== '' && mainTreeColObj.cols.length > 0) {
  733. TREE_SHEET_HELPER.loadSheetHeader(mainTreeColObj, colSpread.getActiveSheet());
  734. TREE_SHEET_HELPER.showTreeData(mainTreeColObj, colSpread.getActiveSheet(), billsTemplateTree);
  735. }*/
  736. /*
  737. if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {
  738. return false;
  739. } */
  740. // 标准清单
  741. let html = "";
  742. for (let tmp of billListData) {
  743. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  744. html += tmpHtml;
  745. }
  746. $("select[name='standard_bill']").children("option").first().after(html);
  747. // 定额库
  748. html = "";
  749. for (let tmp of rationLibData) {
  750. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  751. html += tmpHtml;
  752. }
  753. $("select[name='ration_lib']").html(html);
  754. // 工料机库
  755. html = "";
  756. for (let tmp of gljLibData) {
  757. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  758. html += tmpHtml;
  759. }
  760. $("select[name='glj_lib']").children("option").first().after(html);
  761. // 清单指引库
  762. html = "";
  763. for (let tmp of billsGuidanceData) {
  764. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  765. html += tmpHtml;
  766. }
  767. $("select[name='billsGuidance_lib']").children("option").first().after(html);
  768. // 人工系数标准库
  769. html = "";
  770. for (let tmp of artificialCoefficientData) {
  771. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  772. html += tmpHtml;
  773. }
  774. $("select[name='artificial_lib']").children("option").first().after(html);
  775. // 计算程序标准库
  776. html = "";
  777. for (let tmp of programData) {
  778. let tmpHtml =
  779. '<option value="' + tmp.id + '">' + tmp.displayName + "</option>";
  780. html += tmpHtml;
  781. }
  782. $("select[name='program_lib']").children("option").first().after(html);
  783. //模板库
  784. html = "";
  785. for (let tmp of billTemplateData) {
  786. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  787. html += tmpHtml;
  788. }
  789. $("select[name='template_lib']").children("option").first().after(html);
  790. //列设置
  791. html = "";
  792. for (let tmp of mainTreeColData) {
  793. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  794. html += tmpHtml;
  795. }
  796. $("select[name='col_lib']").children("option").first().after(html);
  797. // 费率标准库
  798. html = "";
  799. for (let tmp of feeLibData) {
  800. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  801. html += tmpHtml;
  802. }
  803. $("select[name='fee_lib']").children("option").first().after(html);
  804. //工程特征库
  805. html = "";
  806. for (let tmp of featureData) {
  807. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  808. html += tmpHtml;
  809. }
  810. $("select[name='feature_lib']").children("option").first().after(html); //工程特征库
  811. //基本信息库
  812. html = "";
  813. for (let tmp of infoData) {
  814. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  815. html += tmpHtml;
  816. }
  817. $("select[name='info_lib']").children("option").first().after(html);
  818. //累进区间库
  819. html = "";
  820. for (let tmp of progressiveData) {
  821. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  822. html += tmpHtml;
  823. }
  824. $("select[name='progressive_lib']").children("option").first().after(html);
  825. //车船税文件
  826. html = "";
  827. for (let tmp of vvTaxData) {
  828. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  829. html += tmpHtml;
  830. }
  831. $("select[name='vvTax_lib']").children("option").first().after(html);
  832. //递延清单库文件
  833. html = "";
  834. for (let tmp of billCodeData) {
  835. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  836. html += tmpHtml;
  837. }
  838. $("select[name='billCode_lib']").children("option").first().after(html);
  839. }
  840. /**
  841. * 校验数据
  842. *
  843. * @param {String} model
  844. * @return {Object}
  845. */
  846. function getAndValidData(model) {
  847. let name = $("input[name='compilation_name']").val();
  848. let standardBill = $("select[name='standard_bill']")
  849. .children("option:selected")
  850. .val();
  851. let rationLib = $("select[name='ration_lib']")
  852. .children("option:selected")
  853. .val();
  854. let gljLib = $("select[name='glj_lib']").children("option:selected").val();
  855. // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
  856. let artificialLib = $("select[name='artificial_lib']")
  857. .children("option:selected")
  858. .val();
  859. let programLib = $("select[name='program_lib']")
  860. .children("option:selected")
  861. .val();
  862. let billsGuidanceLib = $("select[name='billsGuidance_lib']")
  863. .children("option:selected")
  864. .val();
  865. let featureLib = $("select[name='feature_lib']")
  866. .children("option:selected")
  867. .val();
  868. let infoLib = $("select[name='info_lib']").children("option:selected").val();
  869. let progressiveLib = $("select[name='progressive_lib']")
  870. .children("option:selected")
  871. .val();
  872. let vvTaxLib = $("select[name='vvTax_lib']")
  873. .children("option:selected")
  874. .val();
  875. let billCodeLib = $("select[name='billCode_lib']")
  876. .children("option:selected")
  877. .val();
  878. if (name === "" && model === "all") {
  879. throw "编办名字不能为空";
  880. }
  881. if (model === "bill" && (standardBill === "" || standardBill === undefined)) {
  882. throw "请选择标准清单库";
  883. }
  884. if (model === "ration" && (rationLib === "" || rationLib === undefined)) {
  885. throw "请选择定额库";
  886. }
  887. if (model === "feature" && (featureLib === "" || featureLib === undefined)) {
  888. throw "请选择工程特征库";
  889. }
  890. if (
  891. model === "progressive" &&
  892. (progressiveLib === "" || progressiveLib === undefined)
  893. ) {
  894. throw "请选择累进区间库";
  895. }
  896. if (model === "vvTax" && (vvTaxLib === "" || vvTaxLib === undefined)) {
  897. throw "请选择车船税文件";
  898. }
  899. if (
  900. model === "billCode" &&
  901. (billCodeLib === "" || billCodeLib === undefined)
  902. ) {
  903. throw "请选择递延清单库文件";
  904. }
  905. if (model === "glj" && (gljLib === "" || gljLib === undefined)) {
  906. throw "请选择人材机库";
  907. }
  908. if (
  909. model === "artificial" &&
  910. (artificialLib === "" || artificialLib === undefined)
  911. ) {
  912. throw "请选择人工系数库";
  913. }
  914. if (model === "program" && (programLib === "" || programLib === undefined)) {
  915. throw "请选择计算程序";
  916. }
  917. if (
  918. model === "billsGuidance" &&
  919. (billsGuidanceLib === "" || billsGuidanceLib === undefined)
  920. ) {
  921. throw "请选择清单指引库";
  922. }
  923. let standardBillString = $("select[name='standard_bill']")
  924. .children("option:selected")
  925. .text();
  926. let rationLibString = $("select[name='ration_lib']")
  927. .children("option:selected")
  928. .text();
  929. let gljLibString = $("select[name='glj_lib']")
  930. .children("option:selected")
  931. .text();
  932. // let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
  933. let artificialString = $("select[name='artificial_lib']")
  934. .children("option:selected")
  935. .text();
  936. let programString = $("select[name='program_lib']")
  937. .children("option:selected")
  938. .text();
  939. let billsGuidanceString = $("select[name='billsGuidance_lib']")
  940. .children("option:selected")
  941. .text();
  942. let featrueString = $("select[name='feature_lib']")
  943. .children("option:selected")
  944. .text();
  945. let infoString = $("select[name='info_lib']")
  946. .children("option:selected")
  947. .text();
  948. let progressiveString = $("select[name='progressive_lib']")
  949. .children("option:selected")
  950. .text();
  951. let vvTaxString = $("select[name='vvTax_lib']")
  952. .children("option:selected")
  953. .text();
  954. let billCodeLibString = $("select[name='billCode_lib']")
  955. .children("option:selected")
  956. .text();
  957. let result = {
  958. name: name,
  959. bill: {
  960. id: standardBill,
  961. name: standardBillString,
  962. },
  963. ration: {
  964. id: rationLib,
  965. name: rationLibString,
  966. },
  967. glj: {
  968. id: gljLib,
  969. name: gljLibString,
  970. },
  971. /* fee: {
  972. id: feeLib,
  973. name: feeLibString
  974. },*/
  975. artificial: {
  976. id: artificialLib,
  977. name: artificialString,
  978. },
  979. program: {
  980. id: programLib,
  981. name: programString,
  982. },
  983. billsGuidance: {
  984. id: billsGuidanceLib,
  985. name: billsGuidanceString,
  986. },
  987. feature: {
  988. id: featureLib,
  989. name: featrueString,
  990. },
  991. info: {
  992. id: infoLib,
  993. name: infoString,
  994. },
  995. progressive: {
  996. id: progressiveLib,
  997. name: progressiveString,
  998. },
  999. vvTax: {
  1000. id: vvTaxLib,
  1001. name: vvTaxString,
  1002. },
  1003. billCode: {
  1004. id: billCodeLib,
  1005. name: billCodeLibString,
  1006. },
  1007. };
  1008. return result;
  1009. }
  1010. /**
  1011. * 验证标准库数据
  1012. *
  1013. * @return {boolean}
  1014. */
  1015. function validLib() {
  1016. let result = false;
  1017. try {
  1018. let valuationName = $("input[name='name']").val();
  1019. if (valuationName === "") {
  1020. throw "请填写计价规则名称";
  1021. }
  1022. let engineering = $("select[name='engineering']").val();
  1023. if (engineering === "" || engineering <= 0) {
  1024. throw "请选择工程专业";
  1025. }
  1026. //按新需求,清单库、定额库等不做非空验证
  1027. /* if ($("input:hidden[name='bill_lib']").length <= 0) {
  1028. throw '请添加标准清单';
  1029. }
  1030. if ($("input:hidden[name='ration_lib']").length <= 0) {
  1031. throw '请添加定额库';
  1032. }
  1033. if ($("input:hidden[name='glj_lib']").length <= 0) {
  1034. throw '请添加人材机库';
  1035. }
  1036. if ($("input:hidden[name='fee_lib']").length <= 0) {
  1037. throw '请添加费率标准';
  1038. }
  1039. if ($("input:hidden[name='artificial_lib']").length <= 0) {
  1040. throw '请添加人工系数';
  1041. }
  1042. if ($("input:hidden[name='program_lib']").length <= 0) {
  1043. throw '请添加计算程序';
  1044. }
  1045. if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
  1046. throw '请添加清单指引库';
  1047. }*/
  1048. result = true;
  1049. } catch (error) {
  1050. alert(error);
  1051. result = false;
  1052. }
  1053. return result;
  1054. }
  1055. /**
  1056. * 切换switch效果
  1057. *
  1058. * @param {Object} element
  1059. * @return {boolean}
  1060. */
  1061. function switchChange(element) {
  1062. // 第一个元素判断当前的状态
  1063. let firstButton = element.children("button").first();
  1064. let secondButton = element.children("button").eq(1);
  1065. let currentStatus = firstButton.is(":disabled");
  1066. if (currentStatus) {
  1067. // 当前为true切换到false
  1068. firstButton
  1069. .removeClass("btn-success")
  1070. .removeClass("disabled")
  1071. .addClass("btn-default")
  1072. .removeAttr("disabled");
  1073. firstButton.text("开启");
  1074. secondButton
  1075. .removeClass("btn-default")
  1076. .addClass("btn-danger")
  1077. .addClass("disabled")
  1078. .attr("disabled", "disabled");
  1079. secondButton.text("已禁用");
  1080. } else {
  1081. // 当前false切换到true
  1082. firstButton
  1083. .removeClass("btn-default")
  1084. .addClass("btn-success")
  1085. .addClass("disabled")
  1086. .attr("disabled", "disabled");
  1087. firstButton.text("已开启");
  1088. secondButton
  1089. .removeClass("btn-danger")
  1090. .removeClass("disabled")
  1091. .addClass("btn-default")
  1092. .removeAttr("disabled");
  1093. secondButton.text("禁用");
  1094. }
  1095. return !currentStatus;
  1096. }
  1097. /* function editEngineer(selector) {
  1098. let engineerName = $(selector).prev("span").text();
  1099. let parentDiv = $(selector).parent("div");
  1100. parentDiv.next("div").find("input").val(engineerName);
  1101. parentDiv.hide();
  1102. parentDiv.next("div").show();
  1103. } */
  1104. function editEngineer(selector, key) {
  1105. let editText = $(selector).prev("span").text();
  1106. let parentDiv = $(selector).parent("div");
  1107. let width = key == "seq" ? 70 : 200;
  1108. parentDiv.next("div").css("width", width);
  1109. parentDiv.next("div").find("input").val(editText);
  1110. parentDiv.hide();
  1111. parentDiv.next("div").show();
  1112. }
  1113. /* function confirmUpdate(selector, engineerID) {
  1114. let inputDiv = $(selector).parents(".input_group_div");
  1115. let input = $(selector).parent(".input-group-btn").prev("input");
  1116. let oldValue = inputDiv.prev("div").find("span").text();
  1117. let newValue = input.val();
  1118. let key = input.attr("name");
  1119. if (newValue == "" || newValue == oldValue || !engineerID) {
  1120. inputDiv.prev("div").show();
  1121. inputDiv.hide();
  1122. return;
  1123. }
  1124. let updateData = {};
  1125. updateData[key] = newValue;
  1126. updateEngineer(engineerID, updateData, function () {
  1127. inputDiv.prev("div").find("span").text(newValue);
  1128. });
  1129. inputDiv.prev("div").show();
  1130. inputDiv.hide();
  1131. } */
  1132. function confirmUpdate(selector, engineerID) {
  1133. let inputDiv = $(selector).parents(".input_group_div");
  1134. let input = $(selector).parent(".input-group-btn").prev("input");
  1135. let oldValue = inputDiv.prev("div").find("span").text();
  1136. let newValue = input.val();
  1137. let key = input.attr("name");
  1138. if (newValue == oldValue || !engineerID) {
  1139. //不做非空判断
  1140. inputDiv.prev("div").show();
  1141. inputDiv.hide();
  1142. return;
  1143. }
  1144. let updateData = {};
  1145. updateData[key] = newValue;
  1146. updateEngineer(engineerID, updateData, function () {
  1147. if (key == "seq") {
  1148. window.location.reload();
  1149. } else {
  1150. inputDiv.prev("div").find("span").text(newValue);
  1151. }
  1152. });
  1153. inputDiv.prev("div").show();
  1154. inputDiv.hide();
  1155. }
  1156. function deleteEngineerClick(engineerID, element) {
  1157. hintBox.infoBox(
  1158. "操作确认",
  1159. "是否删除所选工程专业?",
  1160. 2,
  1161. async function () {
  1162. try {
  1163. let result = await ajaxPost("/compilation/delete-engineer", {
  1164. id: engineerID,
  1165. });
  1166. $(element).parent("td").parent("tr").remove();
  1167. } catch (err) {
  1168. console.log(err);
  1169. }
  1170. },
  1171. null,
  1172. ["确定", "取消"],
  1173. false
  1174. );
  1175. }
  1176. function copyEngineerClick(engineerID) {
  1177. hintBox.infoBox(
  1178. "操作确认",
  1179. "是否拷贝所选工程专业?",
  1180. 2,
  1181. async function () {
  1182. try {
  1183. await ajaxPost("/compilation/copy-engineer", { id: engineerID });
  1184. window.location.reload();
  1185. } catch (err) {
  1186. console.log(err);
  1187. }
  1188. },
  1189. null,
  1190. ["确定", "取消"],
  1191. false
  1192. );
  1193. }
  1194. function engineerVisibleChange(checkBox, engineerID) {
  1195. if (engineerID) {
  1196. updateEngineer(engineerID, { visible: checkBox.checked });
  1197. }
  1198. }
  1199. function updateEngineer(engineerID, data, callback) {
  1200. CommonAjax.post(
  1201. "/compilation/update-engineer",
  1202. { id: engineerID, updateData: data },
  1203. function (data) {
  1204. if (callback) {
  1205. callback();
  1206. }
  1207. }
  1208. );
  1209. }
  1210. function editTaxGroup(ele) {
  1211. $("#groupEditType").val("modify");
  1212. let groupData = $(ele).nextAll("input[name = 'tax_group']").val();
  1213. groupData = JSON.parse(groupData);
  1214. if (!_.isEmpty(groupData)) {
  1215. $("#taxType").val(groupData.taxType ? groupData.taxType : "");
  1216. $("#program_lib").val(
  1217. groupData.program_lib ? groupData.program_lib.id : ""
  1218. );
  1219. $("#template_lib").val(
  1220. groupData.template_lib ? groupData.template_lib.id : ""
  1221. );
  1222. $("#col_lib").val(groupData.col_lib ? groupData.col_lib.id : "");
  1223. $("#fee_lib").val(groupData.fee_lib ? groupData.fee_lib.id : "");
  1224. } else {
  1225. $("#taxType").val("");
  1226. $("#program_lib").val("");
  1227. $("#template_lib").val("");
  1228. $("#col_lib").val("");
  1229. $("#fee_lib").val("");
  1230. }
  1231. $("#groupIndex").val(getGroupIndex(groupData));
  1232. $("#addTaxGroup").modal({ show: true });
  1233. }
  1234. function deleteTableTr(ele, classString) {
  1235. let parentTr = $(ele).parents(`.${classString}`);
  1236. parentTr.remove();
  1237. }
  1238. function getGroupIndex(groupData) {
  1239. //用来做唯一标识
  1240. let index = "";
  1241. if (groupData) {
  1242. if (groupData.taxType) index = index + groupData.taxType;
  1243. if (groupData.program_lib) index = index + groupData.program_lib.id;
  1244. if (groupData.template_lib) index = index + groupData.template_lib.id;
  1245. if (groupData.col_lib) index = index + groupData.col_lib.id;
  1246. if (groupData.fee_lib) index = index + groupData.fee_lib.id;
  1247. }
  1248. return index;
  1249. }
  1250. function getTaxGroupData() {
  1251. let programData =
  1252. programList === undefined ? [] : _.indexBy(JSON.parse(programList), "id");
  1253. let billTemplateData =
  1254. billTemplateList == undefined
  1255. ? []
  1256. : _.indexBy(JSON.parse(billTemplateList), "ID");
  1257. let mainTreeColData =
  1258. mainTreeColList == undefined
  1259. ? []
  1260. : _.indexBy(JSON.parse(mainTreeColList), "ID");
  1261. let feeLibData =
  1262. feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList), "id");
  1263. let groupData = {};
  1264. if ($("#taxType").val() !== "") {
  1265. groupData.taxType = $("#taxType").val();
  1266. }
  1267. if ($("#program_lib").val() !== "") {
  1268. let program = programData[$("#program_lib").val()];
  1269. if (program) {
  1270. groupData.program_lib = {
  1271. id: program.id,
  1272. name: program.name,
  1273. displayName: program.displayName,
  1274. };
  1275. }
  1276. }
  1277. if ($("#template_lib").val() !== "") {
  1278. let template = billTemplateData[$("#template_lib").val()];
  1279. if (template) {
  1280. groupData.template_lib = {
  1281. id: template.ID,
  1282. name: template.name,
  1283. };
  1284. }
  1285. }
  1286. if ($("#col_lib").val() !== "") {
  1287. let col = mainTreeColData[$("#col_lib").val()];
  1288. if (col) {
  1289. groupData.col_lib = {
  1290. id: col.ID,
  1291. name: col.name,
  1292. };
  1293. }
  1294. }
  1295. if ($("#fee_lib").val() !== "") {
  1296. let feeRate = feeLibData[$("#fee_lib").val()];
  1297. if (feeRate) {
  1298. groupData.fee_lib = {
  1299. id: feeRate.id,
  1300. name: feeRate.name,
  1301. };
  1302. }
  1303. }
  1304. return groupData;
  1305. }
  1306. function intChecking(e, elemt) {
  1307. //限制输入正整数
  1308. let code = e.which || e.keyCode;
  1309. if (code == 46 || code == 45) {
  1310. //不能输入小数点和-号
  1311. e.preventDefault();
  1312. }
  1313. if (elemt.value == "" && code == 48) {
  1314. //当输入框为空时不能输入0
  1315. e.preventDefault();
  1316. }
  1317. }