compilation.js 44 KB

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