compilation.js 40 KB

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