compilation.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  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 + "_gusuan").attr("checked")) fileTypes.push(15);
  596. if ($("#" + id + "_estimate").attr("checked")) fileTypes.push(5);
  597. if ($("#" + id + "_submission").attr("checked")) fileTypes.push(1);
  598. if ($("#" + id + "_three_bill_budget").attr("checked")) fileTypes.push(18);
  599. if ($("#" + id + "_bill_budget").attr("checked")) fileTypes.push(19);
  600. if ($("#" + id + "_changeBudget").attr("checked")) fileTypes.push(4);
  601. if ($("#" + id + "_settlement").attr("checked")) fileTypes.push(10);
  602. let current = $(this);
  603. console.log(id, this);
  604. $.ajax({
  605. url: "/compilation/valuation/" + section + "/fileTypes",
  606. type: "post",
  607. dataType: "json",
  608. data: { id: id, fileTypes: fileTypes },
  609. error: function () {
  610. //恢复原值
  611. if (oldVal) {
  612. current.attr("checked", "checked");
  613. } else {
  614. current.removeAttr("checked");
  615. }
  616. },
  617. success: function (response) {
  618. if (response.err !== 0) {
  619. switchChange($(this));
  620. alert("更改失败");
  621. }
  622. },
  623. });
  624. });
  625. //计价规则删除
  626. $("#delete-confirm").click(function () {
  627. let id = $("#del").attr("selectedId");
  628. if (id === undefined || id === "") {
  629. return false;
  630. }
  631. window.location.href = `/compilation/valuation/${section}/delete/${id}`;
  632. });
  633. // 发布编办
  634. $("#release").click(function () {
  635. let id = $(this).data("id");
  636. let status = $(this).data("status");
  637. status = parseInt(status);
  638. if (isAdding || id === "" || isNaN(status)) {
  639. return false;
  640. }
  641. $.ajax({
  642. url: "/compilation/release",
  643. type: "post",
  644. data: { id: id, status: status },
  645. dataType: "json",
  646. error: function () {
  647. isAdding = false;
  648. },
  649. beforeSend: function () {
  650. isAdding = true;
  651. },
  652. success: function (response) {
  653. isAdding = false;
  654. if (response.err === 0) {
  655. window.location.reload();
  656. } else {
  657. let msg = response.msg === undefined ? "未知错误" : response.msg;
  658. alert(msg);
  659. }
  660. },
  661. });
  662. });
  663. //添加工程专业
  664. $("#addEngineerConfirm").click(async function () {
  665. if ($("#name").val() == "") {
  666. $("#nameError").show();
  667. return;
  668. }
  669. if ($("#feeName").val() == "") {
  670. $("#feeNameError").show();
  671. return;
  672. }
  673. if ($("#engineeringInput").val() == "") {
  674. $("#engineeringError").show();
  675. return;
  676. }
  677. if ($("#projectEngineering").val() == "") {
  678. $("#projectError").show();
  679. return;
  680. }
  681. $("#addEngineerConfirm").attr("disabled", true); //防止重复提交
  682. $("#addEngineerForm").submit();
  683. });
  684. //
  685. // CLD 办事处选择
  686. $("#category-select").change(function () {
  687. $.ajax({
  688. url: "/compilation/changeCategory",
  689. type: "post",
  690. data: { id: id, category: $(this).val() },
  691. dataType: "json",
  692. success: function (response) {
  693. if (response.error !== 0) {
  694. alert("更改失败");
  695. }
  696. },
  697. });
  698. });
  699. // 选择默认所在地
  700. $("#location-select").change(function () {
  701. $.ajax({
  702. url: "/compilation/changeLocation",
  703. type: "post",
  704. data: { id: id, location: $(this).val() },
  705. dataType: "json",
  706. success: function (response) {
  707. if (response.error !== 0) {
  708. alert("更改失败");
  709. }
  710. },
  711. });
  712. });
  713. // 选择编办类型
  714. $("#type-select").change(function () {
  715. $.ajax({
  716. url: "/compilation/changeCompilation",
  717. type: "post",
  718. data: { id: id, update: { type: $(this).val() } },
  719. dataType: "json",
  720. success: function (response) {
  721. if (response.error !== 0) {
  722. alert("更改失败");
  723. }
  724. },
  725. });
  726. });
  727. // 修改是否提供免费版
  728. $("#freeUse").change(function (val) {
  729. $.ajax({
  730. url: "/compilation/changeFreeUse",
  731. type: "post",
  732. data: { id: id, freeUse: $(this).prop("checked") },
  733. dataType: "json",
  734. success: function (response) {
  735. if (response.error !== 0) {
  736. alert("更改失败");
  737. }
  738. },
  739. });
  740. });
  741. // 选择编办类型
  742. $("#customMade").change(function () {
  743. $.ajax({
  744. url: "/compilation/changeCompilation",
  745. type: "post",
  746. data: { id: id, update: { customMade: $(this).prop("checked") } },
  747. dataType: "json",
  748. success: function (response) {
  749. if (response.error !== 0) {
  750. alert("更改失败");
  751. }
  752. },
  753. });
  754. });
  755. //更改版本号
  756. $("#edition").change(function () {
  757. let edition = $(this).val();
  758. $.ajax({
  759. url: "/compilation/setEdition",
  760. type: "post",
  761. dataType: "json",
  762. data: { id: id, edition: edition },
  763. success: function (response) {
  764. if (response.err !== 0) {
  765. alert("更改失败");
  766. }
  767. },
  768. });
  769. });
  770. //更改序号
  771. $("#serialNumber").change(function () {
  772. let serialNumber = Number($(this).val());
  773. $.ajax({
  774. url: "/compilation/setSerialNumber",
  775. type: "post",
  776. dataType: "json",
  777. data: { id: id, serialNumber: serialNumber },
  778. success: function (response) {
  779. if (response.err !== 0) {
  780. alert("更改失败");
  781. }
  782. },
  783. });
  784. });
  785. });
  786. function libUp(id) {
  787. const $item = $(`#list_${id}`).closest(".billLibItem");
  788. const $prevItem = $item.prev();
  789. if ($prevItem.length) {
  790. $item.fadeOut(200, function () {
  791. $prevItem.before($item);
  792. $item.fadeIn(200);
  793. });
  794. }
  795. }
  796. function libDown(id) {
  797. const $item = $(`#list_${id}`).closest(".billLibItem");
  798. const $nextItem = $item.next();
  799. if ($nextItem.length) {
  800. $item.fadeOut(200, function () {
  801. $nextItem.after($item);
  802. $item.fadeIn(200);
  803. });
  804. }
  805. }
  806. /**
  807. * 初始化
  808. *
  809. * @return {void|boolean}
  810. */
  811. function initCompilation() {
  812. let billListData = billList === undefined ? [] : JSON.parse(billList);
  813. let rationLibData = rationList === undefined ? [] : JSON.parse(rationList);
  814. let gljLibData = gljList === undefined ? [] : JSON.parse(gljList);
  815. let feeLibData = feeRateList === undefined ? [] : JSON.parse(feeRateList);
  816. let artificialCoefficientData =
  817. artificialCoefficientList === undefined
  818. ? []
  819. : JSON.parse(artificialCoefficientList);
  820. let programData = programList === undefined ? [] : JSON.parse(programList);
  821. let billsGuidanceData =
  822. billsGuidanceList === undefined ? [] : JSON.parse(billsGuidanceList);
  823. let billTemplateData =
  824. billTemplateList == undefined ? [] : JSON.parse(billTemplateList);
  825. let mainTreeColData =
  826. mainTreeColList == undefined ? [] : JSON.parse(mainTreeColList);
  827. let featureData = featureList == undefined ? [] : JSON.parse(featureList);
  828. let infoData = infoList == undefined ? [] : JSON.parse(infoList);
  829. let progressiveData =
  830. progressiveList == undefined ? [] : JSON.parse(progressiveList);
  831. let vvTaxData = vvTaxList == undefined ? [] : JSON.parse(vvTaxList);
  832. let billCodeData = billCodeList == undefined ? [] : JSON.parse(billCodeList);
  833. /*mainTreeCol = mainTreeCol !== '' ? mainTreeCol.replace(/\n/g, '\\n') : mainTreeCol;
  834. billsTemplateData = billsTemplateData.replace(/\n/g, '\\n');
  835. let mainTreeColObj = mainTreeCol === '' ? {} : JSON.parse(mainTreeCol);
  836. // 初始化 造价书列设置
  837. colSpread = TREE_SHEET_HELPER.createNewSpread($('#main-tree-col')[0]);
  838. let billsTemplateTree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1});
  839. billsTemplateTree.loadDatas(JSON.parse(billsTemplateData));
  840. if (mainTreeCol !== '' && mainTreeColObj.cols.length > 0) {
  841. TREE_SHEET_HELPER.loadSheetHeader(mainTreeColObj, colSpread.getActiveSheet());
  842. TREE_SHEET_HELPER.showTreeData(mainTreeColObj, colSpread.getActiveSheet(), billsTemplateTree);
  843. }*/
  844. /*
  845. if (billListData.length <= 0 || rationLibData.length <= 0 || gljLibData.length <= 0) {
  846. return false;
  847. } */
  848. // 标准清单
  849. let html = "";
  850. for (let tmp of billListData) {
  851. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  852. html += tmpHtml;
  853. }
  854. $("select[name='standard_bill']").children("option").first().after(html);
  855. // 定额库
  856. html = "";
  857. for (let tmp of rationLibData) {
  858. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  859. html += tmpHtml;
  860. }
  861. $("select[name='ration_lib']").html(html);
  862. // 工料机库
  863. html = "";
  864. for (let tmp of gljLibData) {
  865. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  866. html += tmpHtml;
  867. }
  868. $("select[name='glj_lib']").children("option").first().after(html);
  869. // 清单指引库
  870. html = "";
  871. for (let tmp of billsGuidanceData) {
  872. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  873. html += tmpHtml;
  874. }
  875. $("select[name='billsGuidance_lib']").children("option").first().after(html);
  876. // 人工系数标准库
  877. html = "";
  878. for (let tmp of artificialCoefficientData) {
  879. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  880. html += tmpHtml;
  881. }
  882. $("select[name='artificial_lib']").children("option").first().after(html);
  883. // 计算程序标准库
  884. html = "";
  885. for (let tmp of programData) {
  886. let tmpHtml =
  887. '<option value="' + tmp.id + '">' + tmp.displayName + "</option>";
  888. html += tmpHtml;
  889. }
  890. $("select[name='program_lib']").children("option").first().after(html);
  891. //模板库
  892. html = "";
  893. for (let tmp of billTemplateData) {
  894. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  895. html += tmpHtml;
  896. }
  897. $("select[name='template_lib']").children("option").first().after(html);
  898. //列设置
  899. html = "";
  900. for (let tmp of mainTreeColData) {
  901. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  902. html += tmpHtml;
  903. }
  904. $("select[name='col_lib']").children("option").first().after(html);
  905. // 费率标准库
  906. html = "";
  907. for (let tmp of feeLibData) {
  908. let tmpHtml = '<option value="' + tmp.id + '">' + tmp.name + "</option>";
  909. html += tmpHtml;
  910. }
  911. $("select[name='fee_lib']").children("option").first().after(html);
  912. //工程特征库
  913. html = "";
  914. for (let tmp of featureData) {
  915. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  916. html += tmpHtml;
  917. }
  918. $("select[name='feature_lib']").children("option").first().after(html); //工程特征库
  919. //基本信息库
  920. html = "";
  921. for (let tmp of infoData) {
  922. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  923. html += tmpHtml;
  924. }
  925. $("select[name='info_lib']").children("option").first().after(html);
  926. //累进区间库
  927. html = "";
  928. for (let tmp of progressiveData) {
  929. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  930. html += tmpHtml;
  931. }
  932. $("select[name='progressive_lib']").children("option").first().after(html);
  933. //车船税文件
  934. html = "";
  935. for (let tmp of vvTaxData) {
  936. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  937. html += tmpHtml;
  938. }
  939. $("select[name='vvTax_lib']").children("option").first().after(html);
  940. //递延清单库文件
  941. html = "";
  942. for (let tmp of billCodeData) {
  943. let tmpHtml = '<option value="' + tmp.ID + '">' + tmp.name + "</option>";
  944. html += tmpHtml;
  945. }
  946. $("select[name='billCode_lib']").children("option").first().after(html);
  947. }
  948. /**
  949. * 校验数据
  950. *
  951. * @param {String} model
  952. * @return {Object}
  953. */
  954. function getAndValidData(model) {
  955. let name = $("input[name='compilation_name']").val();
  956. let standardBill = $("select[name='standard_bill']")
  957. .children("option:selected")
  958. .val();
  959. let rationLib = $("select[name='ration_lib']")
  960. .children("option:selected")
  961. .val();
  962. let gljLib = $("select[name='glj_lib']").children("option:selected").val();
  963. // let feeLib = $("select[name='fee_lib']").children("option:selected").val();
  964. let artificialLib = $("select[name='artificial_lib']")
  965. .children("option:selected")
  966. .val();
  967. let programLib = $("select[name='program_lib']")
  968. .children("option:selected")
  969. .val();
  970. let billsGuidanceLib = $("select[name='billsGuidance_lib']")
  971. .children("option:selected")
  972. .val();
  973. let featureLib = $("select[name='feature_lib']")
  974. .children("option:selected")
  975. .val();
  976. let infoLib = $("select[name='info_lib']").children("option:selected").val();
  977. let progressiveLib = $("select[name='progressive_lib']")
  978. .children("option:selected")
  979. .val();
  980. let vvTaxLib = $("select[name='vvTax_lib']")
  981. .children("option:selected")
  982. .val();
  983. let billCodeLib = $("select[name='billCode_lib']")
  984. .children("option:selected")
  985. .val();
  986. if (name === "" && model === "all") {
  987. throw "编办名字不能为空";
  988. }
  989. if (model === "bill" && (standardBill === "" || standardBill === undefined)) {
  990. throw "请选择标准清单库";
  991. }
  992. if (model === "ration" && (rationLib === "" || rationLib === undefined)) {
  993. throw "请选择定额库";
  994. }
  995. if (model === "feature" && (featureLib === "" || featureLib === undefined)) {
  996. throw "请选择工程特征库";
  997. }
  998. if (
  999. model === "progressive" &&
  1000. (progressiveLib === "" || progressiveLib === undefined)
  1001. ) {
  1002. throw "请选择累进区间库";
  1003. }
  1004. if (model === "vvTax" && (vvTaxLib === "" || vvTaxLib === undefined)) {
  1005. throw "请选择车船税文件";
  1006. }
  1007. if (
  1008. model === "billCode" &&
  1009. (billCodeLib === "" || billCodeLib === undefined)
  1010. ) {
  1011. throw "请选择递延清单库文件";
  1012. }
  1013. if (model === "glj" && (gljLib === "" || gljLib === undefined)) {
  1014. throw "请选择人材机库";
  1015. }
  1016. if (
  1017. model === "artificial" &&
  1018. (artificialLib === "" || artificialLib === undefined)
  1019. ) {
  1020. throw "请选择人工系数库";
  1021. }
  1022. if (model === "program" && (programLib === "" || programLib === undefined)) {
  1023. throw "请选择计算程序";
  1024. }
  1025. if (
  1026. model === "billsGuidance" &&
  1027. (billsGuidanceLib === "" || billsGuidanceLib === undefined)
  1028. ) {
  1029. throw "请选择清单指引库";
  1030. }
  1031. let standardBillString = $("select[name='standard_bill']")
  1032. .children("option:selected")
  1033. .text();
  1034. let rationLibString = $("select[name='ration_lib']")
  1035. .children("option:selected")
  1036. .text();
  1037. let gljLibString = $("select[name='glj_lib']")
  1038. .children("option:selected")
  1039. .text();
  1040. // let feeLibString = $("select[name='fee_lib']").children("option:selected").text();
  1041. let artificialString = $("select[name='artificial_lib']")
  1042. .children("option:selected")
  1043. .text();
  1044. let programString = $("select[name='program_lib']")
  1045. .children("option:selected")
  1046. .text();
  1047. let billsGuidanceString = $("select[name='billsGuidance_lib']")
  1048. .children("option:selected")
  1049. .text();
  1050. let featrueString = $("select[name='feature_lib']")
  1051. .children("option:selected")
  1052. .text();
  1053. let infoString = $("select[name='info_lib']")
  1054. .children("option:selected")
  1055. .text();
  1056. let progressiveString = $("select[name='progressive_lib']")
  1057. .children("option:selected")
  1058. .text();
  1059. let vvTaxString = $("select[name='vvTax_lib']")
  1060. .children("option:selected")
  1061. .text();
  1062. let billCodeLibString = $("select[name='billCode_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. vvTax: {
  1108. id: vvTaxLib,
  1109. name: vvTaxString,
  1110. },
  1111. billCode: {
  1112. id: billCodeLib,
  1113. name: billCodeLibString,
  1114. },
  1115. };
  1116. return result;
  1117. }
  1118. /**
  1119. * 验证标准库数据
  1120. *
  1121. * @return {boolean}
  1122. */
  1123. function validLib() {
  1124. let result = false;
  1125. try {
  1126. let valuationName = $("input[name='name']").val();
  1127. if (valuationName === "") {
  1128. throw "请填写计价规则名称";
  1129. }
  1130. let engineering = $("select[name='engineering']").val();
  1131. if (engineering === "" || engineering <= 0) {
  1132. throw "请选择工程专业";
  1133. }
  1134. //按新需求,清单库、定额库等不做非空验证
  1135. /* if ($("input:hidden[name='bill_lib']").length <= 0) {
  1136. throw '请添加标准清单';
  1137. }
  1138. if ($("input:hidden[name='ration_lib']").length <= 0) {
  1139. throw '请添加定额库';
  1140. }
  1141. if ($("input:hidden[name='glj_lib']").length <= 0) {
  1142. throw '请添加人材机库';
  1143. }
  1144. if ($("input:hidden[name='fee_lib']").length <= 0) {
  1145. throw '请添加费率标准';
  1146. }
  1147. if ($("input:hidden[name='artificial_lib']").length <= 0) {
  1148. throw '请添加人工系数';
  1149. }
  1150. if ($("input:hidden[name='program_lib']").length <= 0) {
  1151. throw '请添加计算程序';
  1152. }
  1153. if ($("input:hidden[name='billsGuidance_lib']").length <= 0) {
  1154. throw '请添加清单指引库';
  1155. }*/
  1156. result = true;
  1157. } catch (error) {
  1158. alert(error);
  1159. result = false;
  1160. }
  1161. return result;
  1162. }
  1163. /**
  1164. * 切换switch效果
  1165. *
  1166. * @param {Object} element
  1167. * @return {boolean}
  1168. */
  1169. function switchChange(element) {
  1170. // 第一个元素判断当前的状态
  1171. let firstButton = element.children("button").first();
  1172. let secondButton = element.children("button").eq(1);
  1173. let currentStatus = firstButton.is(":disabled");
  1174. if (currentStatus) {
  1175. // 当前为true切换到false
  1176. firstButton
  1177. .removeClass("btn-success")
  1178. .removeClass("disabled")
  1179. .addClass("btn-default")
  1180. .removeAttr("disabled");
  1181. firstButton.text("开启");
  1182. secondButton
  1183. .removeClass("btn-default")
  1184. .addClass("btn-danger")
  1185. .addClass("disabled")
  1186. .attr("disabled", "disabled");
  1187. secondButton.text("已禁用");
  1188. } else {
  1189. // 当前false切换到true
  1190. firstButton
  1191. .removeClass("btn-default")
  1192. .addClass("btn-success")
  1193. .addClass("disabled")
  1194. .attr("disabled", "disabled");
  1195. firstButton.text("已开启");
  1196. secondButton
  1197. .removeClass("btn-danger")
  1198. .removeClass("disabled")
  1199. .addClass("btn-default")
  1200. .removeAttr("disabled");
  1201. secondButton.text("禁用");
  1202. }
  1203. return !currentStatus;
  1204. }
  1205. /* function editEngineer(selector) {
  1206. let engineerName = $(selector).prev("span").text();
  1207. let parentDiv = $(selector).parent("div");
  1208. parentDiv.next("div").find("input").val(engineerName);
  1209. parentDiv.hide();
  1210. parentDiv.next("div").show();
  1211. } */
  1212. function editEngineer(selector, key) {
  1213. let editText = $(selector).prev("span").text();
  1214. let parentDiv = $(selector).parent("div");
  1215. let width = key == "seq" ? 70 : 200;
  1216. parentDiv.next("div").css("width", width);
  1217. parentDiv.next("div").find("input").val(editText);
  1218. parentDiv.hide();
  1219. parentDiv.next("div").show();
  1220. }
  1221. /* function confirmUpdate(selector, engineerID) {
  1222. let inputDiv = $(selector).parents(".input_group_div");
  1223. let input = $(selector).parent(".input-group-btn").prev("input");
  1224. let oldValue = inputDiv.prev("div").find("span").text();
  1225. let newValue = input.val();
  1226. let key = input.attr("name");
  1227. if (newValue == "" || newValue == oldValue || !engineerID) {
  1228. inputDiv.prev("div").show();
  1229. inputDiv.hide();
  1230. return;
  1231. }
  1232. let updateData = {};
  1233. updateData[key] = newValue;
  1234. updateEngineer(engineerID, updateData, function () {
  1235. inputDiv.prev("div").find("span").text(newValue);
  1236. });
  1237. inputDiv.prev("div").show();
  1238. inputDiv.hide();
  1239. } */
  1240. function confirmUpdate(selector, engineerID) {
  1241. let inputDiv = $(selector).parents(".input_group_div");
  1242. let input = $(selector).parent(".input-group-btn").prev("input");
  1243. let oldValue = inputDiv.prev("div").find("span").text();
  1244. let newValue = input.val();
  1245. let key = input.attr("name");
  1246. if (newValue == oldValue || !engineerID) {
  1247. //不做非空判断
  1248. inputDiv.prev("div").show();
  1249. inputDiv.hide();
  1250. return;
  1251. }
  1252. let updateData = {};
  1253. updateData[key] = newValue;
  1254. updateEngineer(engineerID, updateData, function () {
  1255. if (key == "seq") {
  1256. window.location.reload();
  1257. } else {
  1258. inputDiv.prev("div").find("span").text(newValue);
  1259. }
  1260. });
  1261. inputDiv.prev("div").show();
  1262. inputDiv.hide();
  1263. }
  1264. function deleteEngineerClick(engineerID, element) {
  1265. hintBox.infoBox(
  1266. "操作确认",
  1267. "是否删除所选工程专业?",
  1268. 2,
  1269. async function () {
  1270. try {
  1271. let result = await ajaxPost("/compilation/delete-engineer", {
  1272. id: engineerID,
  1273. });
  1274. $(element).parent("td").parent("tr").remove();
  1275. } catch (err) {
  1276. console.log(err);
  1277. }
  1278. },
  1279. null,
  1280. ["确定", "取消"],
  1281. false
  1282. );
  1283. }
  1284. function copyEngineerClick(engineerID) {
  1285. hintBox.infoBox(
  1286. "操作确认",
  1287. "是否拷贝所选工程专业?",
  1288. 2,
  1289. async function () {
  1290. try {
  1291. await ajaxPost("/compilation/copy-engineer", { id: engineerID });
  1292. window.location.reload();
  1293. } catch (err) {
  1294. console.log(err);
  1295. }
  1296. },
  1297. null,
  1298. ["确定", "取消"],
  1299. false
  1300. );
  1301. }
  1302. function engineerVisibleChange(checkBox, engineerID) {
  1303. if (engineerID) {
  1304. updateEngineer(engineerID, { visible: checkBox.checked });
  1305. }
  1306. }
  1307. function updateEngineer(engineerID, data, callback) {
  1308. CommonAjax.post(
  1309. "/compilation/update-engineer",
  1310. { id: engineerID, updateData: data },
  1311. function (data) {
  1312. if (callback) {
  1313. callback();
  1314. }
  1315. }
  1316. );
  1317. }
  1318. function editTaxGroup(ele) {
  1319. $("#groupEditType").val("modify");
  1320. let groupData = $(ele).nextAll("input[name = 'tax_group']").val();
  1321. groupData = JSON.parse(groupData);
  1322. if (!_.isEmpty(groupData)) {
  1323. $("#taxType").val(groupData.taxType ? groupData.taxType : "");
  1324. $("#program_lib").val(
  1325. groupData.program_lib ? groupData.program_lib.id : ""
  1326. );
  1327. $("#template_lib").val(
  1328. groupData.template_lib ? groupData.template_lib.id : ""
  1329. );
  1330. $("#col_lib").val(groupData.col_lib ? groupData.col_lib.id : "");
  1331. $("#fee_lib").val(groupData.fee_lib ? groupData.fee_lib.id : "");
  1332. } else {
  1333. $("#taxType").val("");
  1334. $("#program_lib").val("");
  1335. $("#template_lib").val("");
  1336. $("#col_lib").val("");
  1337. $("#fee_lib").val("");
  1338. }
  1339. $("#groupIndex").val(getGroupIndex(groupData));
  1340. $("#addTaxGroup").modal({ show: true });
  1341. }
  1342. function deleteTableTr(ele, classString) {
  1343. let parentTr = $(ele).parents(`.${classString}`);
  1344. parentTr.remove();
  1345. }
  1346. function getGroupIndex(groupData) {
  1347. //用来做唯一标识
  1348. let index = "";
  1349. if (groupData) {
  1350. if (groupData.taxType) index = index + groupData.taxType;
  1351. if (groupData.program_lib) index = index + groupData.program_lib.id;
  1352. if (groupData.template_lib) index = index + groupData.template_lib.id;
  1353. if (groupData.col_lib) index = index + groupData.col_lib.id;
  1354. if (groupData.fee_lib) index = index + groupData.fee_lib.id;
  1355. }
  1356. return index;
  1357. }
  1358. function getTaxGroupData() {
  1359. let programData =
  1360. programList === undefined ? [] : _.indexBy(JSON.parse(programList), "id");
  1361. let billTemplateData =
  1362. billTemplateList == undefined
  1363. ? []
  1364. : _.indexBy(JSON.parse(billTemplateList), "ID");
  1365. let mainTreeColData =
  1366. mainTreeColList == undefined
  1367. ? []
  1368. : _.indexBy(JSON.parse(mainTreeColList), "ID");
  1369. let feeLibData =
  1370. feeRateList === undefined ? [] : _.indexBy(JSON.parse(feeRateList), "id");
  1371. let groupData = {};
  1372. if ($("#taxType").val() !== "") {
  1373. groupData.taxType = $("#taxType").val();
  1374. }
  1375. if ($("#program_lib").val() !== "") {
  1376. let program = programData[$("#program_lib").val()];
  1377. if (program) {
  1378. groupData.program_lib = {
  1379. id: program.id,
  1380. name: program.name,
  1381. displayName: program.displayName,
  1382. };
  1383. }
  1384. }
  1385. if ($("#template_lib").val() !== "") {
  1386. let template = billTemplateData[$("#template_lib").val()];
  1387. if (template) {
  1388. groupData.template_lib = {
  1389. id: template.ID,
  1390. name: template.name,
  1391. };
  1392. }
  1393. }
  1394. if ($("#col_lib").val() !== "") {
  1395. let col = mainTreeColData[$("#col_lib").val()];
  1396. if (col) {
  1397. groupData.col_lib = {
  1398. id: col.ID,
  1399. name: col.name,
  1400. };
  1401. }
  1402. }
  1403. if ($("#fee_lib").val() !== "") {
  1404. let feeRate = feeLibData[$("#fee_lib").val()];
  1405. if (feeRate) {
  1406. groupData.fee_lib = {
  1407. id: feeRate.id,
  1408. name: feeRate.name,
  1409. };
  1410. }
  1411. }
  1412. return groupData;
  1413. }
  1414. function intChecking(e, elemt) {
  1415. //限制输入正整数
  1416. let code = e.which || e.keyCode;
  1417. if (code == 46 || code == 45) {
  1418. //不能输入小数点和-号
  1419. e.preventDefault();
  1420. }
  1421. if (elemt.value == "" && code == 48) {
  1422. //当输入框为空时不能输入0
  1423. e.preventDefault();
  1424. }
  1425. }