compilation.js 40 KB

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