compilation.js 44 KB

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