change_set.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. 'use strict';
  2. /**
  3. * 变更令上报和重新上报功能js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. // 编号排序,多重判断
  11. function sortByCode(a, b) {
  12. let code1 = a.code.split('-');
  13. let code2 = b.code.split('-');
  14. let code1length = code1.length;
  15. let code2length = code2.length;
  16. for (let i = 0; i < code1length; i ++) {
  17. if (i+1 <= code2length) {
  18. if (code1[i] != code2[i]) {
  19. if (!/^\d+$/.test(code1[i])) {
  20. return code1[i].charCodeAt() - code2[i].charCodeAt();
  21. } else {
  22. return parseInt(code1[i]) - parseInt(code2[i]);
  23. }
  24. } else if (i+1 == code1length && code1[i] == code2[i]) {
  25. if (code1length == code2length) {
  26. return 0;
  27. } else {
  28. return code1length - code2length;
  29. }
  30. }
  31. } else {
  32. if (i+1 >= code1length) {
  33. return 1;
  34. } else {
  35. return -1;
  36. }
  37. }
  38. }
  39. }
  40. const preUrl = window.location.pathname.split('/').slice(0, 4).join('/');
  41. let changeListData;
  42. let gclGatherData;
  43. postData(preUrl + '/defaultBills', {}, function (result) {
  44. gclGatherModel.loadLedgerData(result.bills);
  45. gclGatherModel.loadPosData(result.pos);
  46. gclGatherData = gclGatherModel.gatherGclData();
  47. for (const ggd in gclGatherData) {
  48. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  49. }
  50. // 数组去重
  51. const dealBillList = result.dealBills;
  52. for (const db of gclGatherData) {
  53. const exist_index = dealBillList.findIndex(function (item) {
  54. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  55. });
  56. if (exist_index !== -1) {
  57. dealBillList.splice(exist_index, 1);
  58. }
  59. }
  60. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  61. console.log(changeListData);
  62. // 先加载台账数据
  63. let listHtml = '';
  64. let list_index = 1;
  65. let gcl_index = 0;
  66. for (const gcl of changeListData) {
  67. const unit = gcl.unit !== undefined && gcl.unit !== null ? gcl.unit : '';
  68. const quantity = gcl.quantity !== null && gcl.quantity !== undefined ? (unit !== '' ? roundnum(gcl.quantity, findDecimal(gcl.unit)) : gcl.quantity) : 0;
  69. const unit_price = gcl.unit_price !== null && gcl.unit_price !== undefined ? gcl.unit_price : 0;
  70. let gclhtml = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? ' data-gcl="' + gcl_index + '"': '';
  71. gcl_index = gclhtml !== '' ? ++gcl_index : gcl_index;
  72. const lid = gcl.leafXmjs !== undefined && gcl.leafXmjs !== null ? gcl.leafXmjs[0].gcl_id : gcl.id;
  73. listHtml += '<tr data-lid="' + lid + '"'+ gclhtml +' data-index="' + list_index + '" data-bwmx="">' +
  74. '<td>' + list_index + '</td>' +
  75. '<td>' + gcl.code + '</td>' +
  76. '<td>' + gcl.name + '</td>' +
  77. '<td>' + unit + '</td>' +
  78. '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
  79. '<td>' + quantity + '</td>' +
  80. // '<td>' + roundnum(parseFloat(gcl.unit_price).mul(parseFloat(gcl.quantity)), totalPriceUnit) + '</td>' +
  81. '</tr>';
  82. list_index++;
  83. }
  84. // // 再加载签约清单
  85. // for (const db of dealBillList) {
  86. // const unit = db.unit !== undefined && db.unit !== null ? db.unit : '';
  87. // const quantity = db.quantity !== null && db.quantity !== undefined ? (unit !== '' ? roundnum(db.quantity, findDecimal(db.unit)) : db.quantity) : 0;
  88. // const unit_price = db.unit_price !== null && db.unit_price !== undefined ? db.unit_price : 0;
  89. // listHtml += '<tr data-lid="' + db.id + '" data-index="' + list_index + '" data-bwmx="">' +
  90. // '<td>' + list_index + '</td>' +
  91. // '<td>' + db.code + '</td>' +
  92. // '<td>' + db.name + '</td>' +
  93. // '<td>' + unit + '</td>' +
  94. // '<td>' + roundnum(unit_price, unitPriceUnit) + '</td>' +
  95. // '<td>' + quantity + '</td>' +
  96. // // '<td>' + roundnum(parseFloat(db.unit_price).mul(parseFloat(db.quantity)), totalPriceUnit) + '</td>' +
  97. // '</tr>';
  98. // list_index++;
  99. // }
  100. $('#table-list-select').html(listHtml);
  101. tableDataRemake(changeListData);
  102. maketablelist();
  103. });
  104. // 上报时按钮点击
  105. $('a[data-target="#sub-ap"]').on('click', function () {
  106. let category = $(this).attr('data-category');
  107. if (category === 'save_change') {
  108. // 保存修改modal
  109. $('.up-change').hide();
  110. $('.save-change').show();
  111. } else {
  112. // 上报审批modal
  113. $('.up-change').show();
  114. $('.save-change').hide();
  115. }
  116. });
  117. // 多层modal关闭后的滚动bug修复
  118. $('#sub-sp2').on('hidden.bs.modal', function (e) {
  119. $(document.body).addClass('modal-open');
  120. });
  121. // 重新上报时按钮点击
  122. $('a[data-target="#sub-sp2"]').on('click', function () {
  123. let category = $(this).data('category');
  124. if (category === 'save_change') {
  125. // 保存修改modal
  126. $('.up-change').hide();
  127. $('.save-change').show();
  128. } else {
  129. // 上报审批modal
  130. $('.up-change').show();
  131. $('.save-change').hide();
  132. }
  133. $('#hideSp').attr('data-category', category);
  134. });
  135. // 提交表单
  136. // 上报时按钮点击
  137. $('button[data-sumbit="sumbit_change"]').on('click', function () {
  138. let category = $(this).data('category');
  139. if (category === 'save_change') {
  140. // 保存修改modal
  141. $('#changeStatus').val(2);
  142. // 获取auditlist并填入input中
  143. getAuditList();
  144. if ($('input[name="code"]').val() === '') {
  145. toastr.error('申请编号不能为空!');
  146. return;
  147. }
  148. if ($('input[name="name"]').val() === '') {
  149. toastr.error('工程名称不能为空!');
  150. return;
  151. }
  152. $('#change_form').submit();
  153. } else {
  154. // 上报审批modal
  155. $('#changeStatus').val(1);
  156. getAuditList();
  157. let returnFlag = false;
  158. // 表单判断
  159. if ($('input[name="code"]').val() === '') {
  160. toastr.error('申请编号不能为空!');
  161. returnFlag = true;
  162. }
  163. if ($('input[name="name"]').val() === '') {
  164. toastr.error('工程名称不能为空!');
  165. returnFlag = true;
  166. }
  167. if ($('textarea[name="content"]').val() === '') {
  168. toastr.error('工程变更理由及内容不能为空!');
  169. returnFlag = true;
  170. }
  171. if ($('#change-list').val() === '' && $('#change-whitelist').val() === '') {
  172. toastr.error('请添加变更清单!');
  173. returnFlag = true;
  174. } else {
  175. let changeList = [];
  176. if ($('#change-list').val() !== '') {
  177. changeList = $('#change-list').val().split('^_^');
  178. }
  179. let changeWhiteList = [];
  180. if ($('#change-whitelist').val() !== '') {
  181. changeWhiteList = $('#change-whitelist').val().split('^_^');
  182. }
  183. changeList.push.apply(changeList, changeWhiteList);
  184. for (const [index, cl] of changeList.entries()) {
  185. const clInfo = cl.split(';');
  186. // if (clInfo[0] === '' || clInfo[1] === '' || clInfo[3] === '' || clInfo[4] === '' || clInfo[5] === '') {
  187. if (clInfo[0] === '' || clInfo[1] === '' || clInfo[5] === '') {
  188. toastr.error('变更清单第' + (index+1) + '行未完整填写数据(变更部位、变更详情、单位、单价可空)');
  189. returnFlag = true;
  190. }
  191. }
  192. }
  193. if ($('#changeaudit').val() === '') {
  194. toastr.error('请添加审批流程!');
  195. returnFlag = true;
  196. }
  197. if (returnFlag) {
  198. return;
  199. }
  200. $('#change_form').submit();
  201. $(this).attr('disabled', true);
  202. }
  203. });
  204. // 保存修改ajax提交(不刷新页面)
  205. $('.save_change_btn').on('click', function () {
  206. // 保存修改modal
  207. $('#changeStatus').val(2);
  208. // 获取auditlist并填入input中
  209. getAuditList();
  210. if ($('input[name="code"]').val() === '') {
  211. toastr.error('申请编号不能为空!');
  212. return;
  213. }
  214. if ($('input[name="name"]').val() === '') {
  215. toastr.error('工程名称不能为空!');
  216. return;
  217. }
  218. $('#change_form').ajaxSubmit(function (result) {
  219. if ( result.err === 0) {
  220. $('.reduction-code').attr('data-code', $('input[name="code"]').val());
  221. toastr.success(result.msg);
  222. $('#show-save-btn').hide();
  223. $('.title-main').removeClass('bg-warning');
  224. $('#back-change-list').val($('#change-list').val());
  225. $('#back-change-whitelist').val($('#change-whitelist').val());
  226. back_changeInfo = Object.assign({}, changeInfo);
  227. } else {
  228. toastr.error(result.msg);
  229. }
  230. });
  231. return false;
  232. });
  233. $('#cancel_change').on('click', function () {
  234. $('#show-save-btn').hide();
  235. $('.title-main').removeClass('bg-warning');
  236. if (!isObjEqual(changeInfo, back_changeInfo)) {
  237. changeFormRemake();
  238. }
  239. if ($('#change-list').val() !== $('#back-change-list').val() || $('#change-whitelist').val() !== $('#back-change-whitelist').val()) {
  240. $('#change-list').val($('#back-change-list').val());
  241. $('#change-whitelist').val($('#back-change-whitelist').val());
  242. tableDataRemake(changeListData);
  243. // 重新绘制table
  244. maketablelist();
  245. if(!$('#bills').hasClass('first-bill-pane') && !$('a[aria-controls="bills"]').hasClass('active')) {
  246. $('#bills').addClass('first-bill-pane');
  247. }
  248. }
  249. toastr.success('已还原到上次保存状态');
  250. });
  251. // 审批人分组选择
  252. $('#account_group').change(function () {
  253. let account_html = '<option value="0">选择审批人</option>';
  254. for (const account of accountList) {
  255. if (parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) {
  256. const role = account.role !== '' ? '(' + account.role + ')' : '';
  257. const company = account.company !== '' ? ' -' + account.company : '';
  258. account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>';
  259. }
  260. }
  261. $('#account_list').html(account_html);
  262. });
  263. $('#hideSp').click(function () {
  264. $('#sub-sp2').modal('hide');
  265. });
  266. // 添加到审批流程中
  267. $('body').on('change', '#account_list', function () {
  268. let id = $(this).val();
  269. id = parseInt(id);
  270. if (id !== 0) {
  271. let auditListIdData = [];
  272. $('#auditList li').each(function () {
  273. let aid = $(this).data('auditid');
  274. auditListIdData.push(aid);
  275. });
  276. if (!in_array(auditListIdData, id)) {
  277. const accountInfo = accountList.find(function (item) {
  278. return item.id === id;
  279. });
  280. const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
  281. const addhtml = '<li class="list-group-item" data-auditmsg="' + user + '"' +
  282. 'data-auditid="' + accountInfo.id + '" >' +
  283. '<a href="javascript:void(0);" class="text-danger pull-right remove_audit_btn">移除</a>' +
  284. '<span>' + (auditListIdData.length+1) + '</span> ' + accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small>' +
  285. '<p class="m-0 ml-2"><small class="text-muted">' + accountInfo.company + '</small></p>' +
  286. '</li>';
  287. $('#auditList').append(addhtml);
  288. // 重新上报时。令其它的审批人流程图标转换
  289. $('#shenpi-audit-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  290. $('#shenpi-audit-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  291. // 添加新审批人
  292. const addhtml1 = '<li class="list-group-item" data-auditid="' + accountInfo.id + '" >' +
  293. '<i class="fa fa-stop-circle"></i> ' +
  294. accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small><span class="pull-right">终审</span>' +
  295. '</li>';
  296. const addhtml2 = '<li class="list-group-item" data-auditid="' + accountInfo.id + '" >' +
  297. '<h5 class="card-title"><i class="fa fa-stop-circle"></i> ' +
  298. accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small><span class="pull-right">终审</span>' +
  299. '</h5></li>';
  300. for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
  301. $('#shenpi-audit-list li').eq(i).find('.pull-right').text(transFormToChinese(i) + '审');
  302. $('#shenpi-audit-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i) + '审');
  303. }
  304. $('#shenpi-audit-list li').eq(0).find('.pull-right').text('原报');
  305. $('#shenpi-audit-list2 li').eq(0).find('.pull-right').text('原报');
  306. $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
  307. $('#shenpi-audit-list2 li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
  308. $('#shenpi-audit-list').append(addhtml1);
  309. $('#shenpi-audit-list2').append(addhtml2);
  310. } else {
  311. toastr.error('审批流程中已存在该用户!');
  312. }
  313. }
  314. });
  315. // 移除审批流程的审批人
  316. $('body').on('click', '.remove_audit_btn', function () {
  317. const uid = $(this).parents('li').attr('data-auditid');
  318. $(this).parents('li').remove();
  319. let index = 1;
  320. $('#auditList li').each(function () {
  321. $(this).children('span').text(index);
  322. index++;
  323. });
  324. if (index === 1) {
  325. $('#account_list').val(0);
  326. }
  327. // 重新上报时。移除审批流程
  328. // 令最后一个图标转换
  329. $('#shenpi-audit-list li[data-auditid="' + uid + '"]').remove();
  330. $('#shenpi-audit-list2 li[data-auditid="' + uid + '"]').remove();
  331. if ($('#shenpi-audit-list li').length !== 0 && !$('#shenpi-audit-list li i').hasClass('fa-stop-circle')) {
  332. $('#shenpi-audit-list li').eq($('#shenpi-audit-list li').length-1).children('i')
  333. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  334. $('#shenpi-audit-list2 li').eq($('#shenpi-audit-list2 li').length-1).children('i')
  335. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  336. }
  337. for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
  338. $('#shenpi-audit-list li').eq(i).find('.pull-right').text((i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i+1)) + '审');
  339. $('#shenpi-audit-list2 li').eq(i).find('.pull-right').text((i+1 === $('#shenpi-audit-list2 li').length ? '终' : transFormToChinese(i+1)) + '审');
  340. }
  341. $('#shenpi-audit-list li').eq(0).find('.pull-right').text('原报');
  342. $('#shenpi-audit-list2 li').eq(0).find('.pull-right').text('原报');
  343. $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
  344. $('#shenpi-audit-list2 li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
  345. });
  346. // 打开签约清单modal并删除之前的操作
  347. $('#open-list-modal').click(function () {
  348. autoFlashHeight()
  349. // tableDataRemake(changeListData);
  350. });
  351. // 清单选中和移除
  352. $('body').on('click', '#table-list-select tr', function () {
  353. $('#table-list-select tr').removeClass('table-warning');
  354. $(this).addClass('table-warning');
  355. const isCheck = $(this).hasClass('table-success') ? true : false;
  356. const data_bwmx = $(this).attr('data-bwmx').split('$#$');
  357. const isDeal = $(this).data('gcl') !== undefined ? true : false;
  358. let codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox"></td></tr>';
  359. if (isDeal) {
  360. const lid = $(this).data('lid');
  361. let gcl = _.find(gclGatherData, function (item) {
  362. return item.leafXmjs && item.leafXmjs[0].gcl_id === lid;
  363. });
  364. if (!gcl) {
  365. gcl = gclGatherData[$(this).data('gcl')];
  366. }
  367. codeHtml = '';
  368. for (const leaf of gcl.leafXmjs) {
  369. const quantity = leaf.quantity !== undefined && leaf.quantity !== null ? leaf.quantity : 0;
  370. const bwmx = leaf.bwmx !== undefined ? leaf.bwmx : '';
  371. const isChecked = data_bwmx.indexOf(leaf.code + '_' + (bwmx !== '' ? bwmx : leaf.jldy !== '' ? leaf.jldy : '') + ';' + quantity) !== -1 && isCheck ? 'checked' : '';
  372. codeHtml += '<tr quantity="' + quantity + '"><td>' + leaf.code + '</td>' +
  373. '<td>' + leaf.jldy + '</td>' +
  374. '<td>' + bwmx + '</td>' +
  375. '<td>' + leaf.dwgc + '</td>' +
  376. '<td>' + leaf.fbgc + '</td>' +
  377. '<td>' + leaf.fxgc + '</td>' +
  378. '<td>' + roundnum(quantity, findDecimal(gcl.unit)) + '</td>' +
  379. '<td><input type="checkbox"' + isChecked +
  380. '></td></tr>';
  381. }
  382. } else if (!isDeal && isCheck) {
  383. codeHtml = '<tr quantity="'+ $(this).children('td').eq(5).text() +'"><td colspan="7" class="colspan_1">&nbsp;</td><td class="colspan_2"><input type="checkbox" checked></td></tr>';
  384. }
  385. $('#code-list').attr('data-index', $(this).children('td').eq(0).text());
  386. $('#code-list').html(codeHtml);
  387. });
  388. // 右边项目节选择
  389. $('body').on('click', '#code-list input', function () {
  390. let index = $('#code-list').attr('data-index');
  391. if ($(this).is(':checked')) {
  392. // 去除其它可能已选的checked
  393. // $('#code-list input').prop('checked', false);
  394. $(this).prop('checked', true);
  395. // 左边表单传值并添加class
  396. $('#table-list-select tr[data-index="' + index + '"]').addClass('table-success');
  397. // 去除部分data-detail值
  398. let data_bwmx = [];
  399. $('#code-list input:checked').each(function () {
  400. const tr = $(this).parents('tr');
  401. const length = tr.children('td').length;
  402. const bwmx = length === 8 ? tr.children('td').eq(0).text() + '_' + (tr.children('td').eq(2).text() !== '' ? tr.children('td').eq(2).text() : tr.children('td').eq(1).text()) : '0';
  403. const quantity = tr.attr('quantity');
  404. const de_qu = bwmx + ';' + quantity;
  405. data_bwmx.push(de_qu);
  406. });
  407. data_bwmx = data_bwmx.join('$#$');
  408. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  409. } else {
  410. // 判断还有无选中项目节编号
  411. if ($('#code-list input').is(':checked')) {
  412. // 去除部分data-detail值
  413. let data_bwmx = [];
  414. $('#code-list input:checked').each(function () {
  415. const tr = $(this).parents('tr');
  416. const length = tr.children('td').length;
  417. const bwmx = length === 8 ? tr.children('td').eq(0).text() + '_' + (tr.children('td').eq(2).text() !== '' ? tr.children('td').eq(2).text() : tr.children('td').eq(1).text()) : '0';
  418. const quantity = tr.attr('quantity');
  419. const de_qu = bwmx + ';' + quantity;
  420. data_bwmx.push(de_qu);
  421. });
  422. data_bwmx = data_bwmx.join('$#$');
  423. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', data_bwmx);
  424. } else {
  425. $('#table-list-select tr[data-index="' + index + '"]').removeClass('table-success');
  426. $('#table-list-select tr[data-index="' + index + '"]').attr('data-bwmx', '');
  427. }
  428. }
  429. });
  430. // 添加空白清单or签约清单
  431. $('.add-list-btn').on('click', function () {
  432. //生成table清单
  433. if($(this).hasClass('btn-outline-primary')){
  434. maketablelist('addwhite');
  435. }else{
  436. maketablelist();
  437. }
  438. $('#addlist').modal('hide');
  439. });
  440. // 添加空白清单
  441. $('#add-white-btn').on('click', function () {
  442. maketablelist('addwhite');
  443. });
  444. // 选中input所有值
  445. $('body').on('focus', ".clist input", function() {
  446. $(this).select();
  447. });
  448. // 取消选中清单
  449. $('#cancel-list-btn').click(function () {
  450. // $('#table-list-select tr').removeClass('table-success');
  451. // $('#table-list-select tr').attr('data-bwmx', '');
  452. // $('#code-list').html('');
  453. tableDataRemake(changeListData);
  454. });
  455. // 移除已选清单并重新编号
  456. $('body').on('click', '#list td a', function () {
  457. const index = $(this).parents('tr').data('index');
  458. const lid = $(this).parents('tr').data('lid');
  459. // 判断属于空白还是普通清单,并删除对应的index值
  460. const changelist = isNaN(lid) ? $('#change-list').val().split('^_^') : $('#change-whitelist').val().split('^_^');
  461. if($.trim(changelist) != ''){
  462. changelist.splice(index, 1);
  463. if (isNaN(lid)) {
  464. $('#change-list').val(changelist.join('^_^'));
  465. } else {
  466. $('#change-whitelist').val(changelist.join('^_^'));
  467. }
  468. }
  469. tableDataRemake(changeListData);
  470. // 重新绘制table
  471. maketablelist();
  472. });
  473. // 清单输入监控并更新
  474. $('body').on('valuechange', '.clist input', function (e, previous) {
  475. const index = $(this).parents('tr').data('index');
  476. const lid = $(this).parents('tr').data('lid');
  477. const isWhite = !isNaN(lid) ? true : false;
  478. const tr = $('#list tr[data-lid="' + lid + '"]').eq(0);
  479. const site = parseInt($(this).parents('td').data('site'));
  480. switch (site) {
  481. case 0:
  482. case 1:
  483. case 2:
  484. case 3:
  485. case 5:
  486. tr.children('td[data-site="' + site + '"]').children('input').val($(this).val());
  487. break;
  488. case 6:
  489. case 8:
  490. default:
  491. break;
  492. }
  493. const code = $.trim(tr.children('td[data-site="0"]').children('input').val()) || $.trim(tr.children('td[data-site="0"]').text());
  494. const name = $.trim(tr.children('td[data-site="1"]').children('input').val()) || $.trim(tr.children('td[data-site="1"]').text());
  495. const bwmx = $.trim(tr.children('td[data-site="2"]').children('input').val()) || $.trim(tr.children('td[data-site="2"]').text());
  496. const unit = tr.children('td[data-site="4"]').children('select').val() === '' ? tr.children('td[data-site="4"]').children('select').val() : $.trim(tr.children('td[data-site="4"]').children('select').val()) || $.trim(tr.children('td[data-site="4"]').text());
  497. const price = (tr.children('td[data-site="5"]').children('input').val() != '-' ? tr.children('td[data-site="5"]').children('input').val() : '') || tr.children('td[data-site="5"]').text();
  498. const oamount = (tr.children('td[data-site="6"]').children('input').val() != '-' ? tr.children('td[data-site="6"]').children('input').val() : '') || tr.children('td[data-site="6"]').text();
  499. const scnum = tr.children('td[data-site="8"]').children('input').val() != '-' ? tr.children('td[data-site="8"]').children('input').val() : '';
  500. const detail = $.trim(tr.children('td[data-site="3"]').children('input').val());
  501. const trlist = [code,name,bwmx,unit,price,oamount,scnum,detail];
  502. if (isWhite) {
  503. let changelist = $('#change-whitelist').val().split('^_^');
  504. trlist.push(0);
  505. changelist.splice(index, 1, trlist.join(';'));
  506. $('#change-whitelist').val(changelist.join('^_^'));
  507. } else {
  508. let changelist = $('#change-list').val().split('^_^');
  509. trlist.push(lid.split('_')[0]);
  510. changelist.splice(index, 1, trlist.join(';'));
  511. $('#change-list').val(changelist.join('^_^'));
  512. }
  513. tr.children('td[data-site="7"]').text(price != '' && oamount != '' ? roundnum(parseFloat(price).mul(parseFloat(oamount)),totalPriceUnit) : '');
  514. tr.children('td[data-site="9"]').text(price != '' && scnum != '' ? roundnum(parseFloat(price).mul(parseFloat(scnum)),totalPriceUnit) : '');
  515. totalamount(totalPriceUnit);
  516. });
  517. // 空白清单单位选择监控并更新小数位数
  518. $('body').on("change", '.clist select', function () {
  519. const index = $(this).parents('tr').data('index');
  520. const tr = $('#list tr[data-lid="' + index + '"]');
  521. const code = $.trim(tr.children('td[data-site="0"]').children('input').val());
  522. const name = $.trim(tr.children('td[data-site="1"]').children('input').val());
  523. const bwmx = $.trim(tr.children('td[data-site="2"]').children('input').val());
  524. const unit = $(this).val();
  525. tr.children('td[data-site="4"]').children('select').val($(this).val());
  526. const price = tr.children('td[data-site="5"]').children('input').val() != '-' ? tr.children('td[data-site="5"]').children('input').val() : '';
  527. let oamount = tr.children('td[data-site="6"]').children('input').val() != '-' ? tr.children('td[data-site="6"]').children('input').val() : '';
  528. let scnum = tr.children('td[data-site="8"]').children('input').val() != '-' ? tr.children('td[data-site="8"]').children('input').val() : '';
  529. const detail = $.trim(tr.children('td[data-site="3"]').children('input').val());
  530. // 根据单位更新数量位数和合计
  531. const numdecimal = findDecimal(unit);
  532. oamount = roundnum(oamount, numdecimal);
  533. scnum = roundnum(scnum, numdecimal);
  534. tr.children('td[data-site="6"]').children('input').val(oamount);
  535. tr.children('td[data-site="6"]').children('input').attr('onkeyup','RegNum(this,event,'+ numdecimal +')');
  536. tr.children('td[data-site="8"]').children('input').val(scnum);
  537. tr.children('td[data-site="8"]').children('input').attr('onkeyup','RegNum(this,event,'+ numdecimal +')');
  538. const trlist = [code,name,bwmx,unit,price,oamount,scnum,detail,0];
  539. let changelist = $('#change-whitelist').val().split('^_^');
  540. changelist.splice(index, 1, trlist.join(';'));
  541. $('#change-whitelist').val(changelist.join('^_^'));
  542. tr.children('td[data-site="7"]').text(price != '' && oamount != '' ? roundnum(parseFloat(price).mul(parseFloat(oamount)),totalPriceUnit) : '');
  543. tr.children('td[data-site="9"]').text(price != '' && scnum != '' ? roundnum(parseFloat(price).mul(parseFloat(scnum)),totalPriceUnit) : '');
  544. totalamount(totalPriceUnit);
  545. });
  546. // 自动编号
  547. $('.reduction-code').click(function () {
  548. const code = $(this).attr('data-code');
  549. $('input[name="code"]').val(code);
  550. });
  551. // 记录变更信息操作
  552. $('body').on('valuechange', '#change_form input[type="text"]', function (e, previous) {
  553. changeInfo[$(this).attr('name')] = $(this).val();
  554. judgeChange();
  555. });
  556. $('body').on('valuechange', '#change_form textarea', function (e, previous) {
  557. changeInfo[$(this).attr('name')] = $(this).val().replace(/[\r\n]/g, '<br><br>');
  558. judgeChange();
  559. });
  560. $('body').on('change', '#change_form select', function (e, previous) {
  561. changeInfo[$(this).attr('name')] = $(this).val();
  562. judgeChange();
  563. });
  564. $('body').on('click', '#change_form input[type="radio"]', function (e, previous) {
  565. changeInfo[$(this).attr('name')] = $(this).val();
  566. judgeChange();
  567. });
  568. $('body').on('click', '#change_form input[type="checkbox"]', function (e, previous) {
  569. const typecheck = [];
  570. $.each($('#change_form input[name="type[]"]:checked'), function () {
  571. typecheck.push($(this).val());
  572. });
  573. changeInfo.type = typecheck.join(',');
  574. judgeChange();
  575. });
  576. });
  577. function tableDataRemake(changeListData) {
  578. $('#table-list-select tr').removeClass('table-warning');
  579. $('#table-list-select tr').removeClass('table-success');
  580. $('#table-list-select tr').attr('data-bwmx', '');
  581. $('#code-list').html('');
  582. // 根据已添加的清单显示
  583. const changeList = $('#change-list').val().split('^_^');
  584. if (changeList.length > 0 && changeList[0]) {
  585. for (const [index,cl] of changeList.entries()) {
  586. const clinfo = cl.split(';');
  587. // const listinfo = changeListData[clinfo[8] - 1];
  588. let listinfo = changeListData.find(function (item) {
  589. return (item.id !== undefined && item.id == clinfo[8]) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo[8]);
  590. });
  591. // if (listinfo === undefined) {
  592. // toastr.warning('台账清单列表已不存在'+ clinfo[0] +',故删除之');
  593. // continue;
  594. // }
  595. if (listinfo === undefined) {
  596. // 针对旧数据获取清单信息
  597. listinfo = changeListData[clinfo[8] - 1];
  598. if (listinfo === undefined) {
  599. toastr.warning('台账清单列表已不存在'+ clinfo[0] +',已更新变更清单列表');
  600. changeList.splice(index, 1);
  601. continue;
  602. }
  603. $('#table-list-select tr[data-index="'+ clinfo[8] +'"]').addClass('table-success');
  604. let pushbwmx = '0;0';
  605. if (listinfo.leafXmjs !== undefined) {
  606. const leafInfo = listinfo.leafXmjs.find(function (item) {
  607. return (item.bwmx === undefined || item.bwmx === clinfo[2]) && (item.quantity !== null ? item.quantity === parseFloat(clinfo[5]) : 0 === parseFloat(clinfo[5]));
  608. });
  609. if (leafInfo) {
  610. pushbwmx = leafInfo.code + '_' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + ';' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  611. } else {
  612. toastr.warning('台账清单列表已不存在'+ clinfo[0] +',已更新变更清单列表');
  613. changeList.splice(index, 1);
  614. continue;
  615. }
  616. } else {
  617. pushbwmx = '0;' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  618. }
  619. const bwmx = $('#table-list-select tr[data-index="'+ clinfo[8] +'"]').attr('data-bwmx');
  620. if (bwmx) {
  621. const bwmxArray = bwmx.split('$#$');
  622. bwmxArray.push(pushbwmx);
  623. $('#table-list-select tr[data-index="'+ clinfo[8] +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  624. } else {
  625. $('#table-list-select tr[data-index="'+ clinfo[8] +'"]').attr('data-bwmx', pushbwmx);
  626. }
  627. } else {
  628. $('#table-list-select tr[data-lid="'+ clinfo[8] +'"]').addClass('table-success');
  629. let pushbwmx = '0;0';
  630. if (listinfo.leafXmjs !== undefined) {
  631. const leafInfo = listinfo.leafXmjs.find(function (item) {
  632. return (item.bwmx === undefined || item.bwmx === clinfo[2]) && (item.quantity !== null ? item.quantity === parseFloat(clinfo[5]) : 0 === parseFloat(clinfo[5]));
  633. });
  634. if (leafInfo) {
  635. pushbwmx = leafInfo.code + '_' + (leafInfo.bwmx !== undefined ? leafInfo.bwmx : '') + ';' + (leafInfo.quantity !== null ? leafInfo.quantity : 0);
  636. } else {
  637. toastr.warning('台账清单列表已不存在'+ clinfo[0] +',已更新变更清单列表');
  638. changeList.splice(index, 1);
  639. continue;
  640. }
  641. } else {
  642. pushbwmx = '0;' + (listinfo.quantity !== null ? listinfo.quantity : 0);
  643. }
  644. const bwmx = $('#table-list-select tr[data-lid="'+ clinfo[8] +'"]').attr('data-bwmx');
  645. if (bwmx) {
  646. const bwmxArray = bwmx.split('$#$');
  647. bwmxArray.push(pushbwmx);
  648. $('#table-list-select tr[data-lid="'+ clinfo[8] +'"]').attr('data-bwmx', bwmxArray.join('$#$'));
  649. } else {
  650. $('#table-list-select tr[data-lid="'+ clinfo[8] +'"]').attr('data-bwmx', pushbwmx);
  651. }
  652. }
  653. }
  654. $('#change-list').val(changeList.join('^_^'));
  655. }
  656. }
  657. function changeFormRemake() {
  658. changeInfo = Object.assign({}, back_changeInfo);
  659. $('#change_form input[name="code"]').val(changeInfo.code);
  660. $('#change_form input[name="name"]').val(changeInfo.name);
  661. $('#change_form input[name="peg"]').val(changeInfo.peg);
  662. $('#change_form input[name="org_name"]').val(changeInfo.org_name);
  663. $('#change_form input[name="org_code"]').val(changeInfo.org_code);
  664. $('#change_form input[name="new_name"]').val(changeInfo.new_name);
  665. $('#change_form input[name="new_code"]').val(changeInfo.new_code);
  666. $('#change_form textarea[name="content"]').val(changeInfo.content.replace(/<br><br>/g, '\r\n'));
  667. $('#change_form textarea[name="basis"]').val(changeInfo.basis.replace(/<br><br>/g, '\r\n'));
  668. $('#change_form textarea[name="expr"]').val(changeInfo.expr.replace(/<br><br>/g, '\r\n'));
  669. $('#change_form textarea[name="memo"]').val(changeInfo.memo.replace(/<br><br>/g, '\r\n'));
  670. $('#change_form select[name="type"]').val(changeInfo.type);
  671. $('#change_form select[name="class"]').val(changeInfo.class);
  672. $('#change_form select[name="quality"]').val(changeInfo.quality);
  673. $('#change_form select[name="company"]').val(changeInfo.company);
  674. $('#change_form input[name="charge"][value="'+ changeInfo.charge +'"]').prop('checked', true);
  675. $('#change_form input[name="type[]"]').prop('checked', false);
  676. const typecheck = changeInfo.type.split(',');
  677. for (const type of typecheck) {
  678. $('#change_form input[name="type[]"][value="'+ type +'"]').prop('checked', true);
  679. }
  680. }
  681. //判断元素是否在数组中,相当于php的in_array();
  682. function in_array(arr, obj) {
  683. let i = arr.length;
  684. while (i--) {
  685. if (arr[i] == obj) {
  686. return true;
  687. }
  688. }
  689. return false;
  690. }
  691. // 获取审批流程中审批人列表数据
  692. function getAuditList() {
  693. if ($('#auditList li').length === 0) {
  694. $('#changeaudit').val('');
  695. } else {
  696. let auditInfoArray = [];
  697. $('#auditList li').each(function () {
  698. const aMsg = $(this).data('auditmsg');
  699. auditInfoArray.push(aMsg);
  700. });
  701. $('#changeaudit').val(auditInfoArray.join(','));
  702. }
  703. }
  704. // 重新生成清单
  705. function maketablelist(status){
  706. // 金额位数
  707. const decimal = totalPriceUnit;
  708. // 单价位数
  709. const updecimal = unitPriceUnit;
  710. let html = '';
  711. // 原有清单(不含空白清单)
  712. let radionList = $('#change-list').val() !== '' ? $('#change-list').val().split('^_^') : [];
  713. const newTableList = [];
  714. // 获取选中的签约清单判断并插入到原有清单中
  715. $('#table-list-select .table-success').each(function(){
  716. let code = $(this).children('td').eq(1).text();
  717. let name = $(this).children('td').eq(2).text();
  718. let unit = $(this).children('td').eq(3).text();
  719. let price = $(this).children('td').eq(4).text();
  720. // let oamount = $(this).children('td').eq(5).text();
  721. // 根据单位获取数量的位数,并得出
  722. // let numdecimal = findDecimal(unit);
  723. // let scnum = makedecimalzero(numdecimal);
  724. let scnum = 0;
  725. // let detail = $(this).attr('data-detail') != 0 ? $(this).attr('data-detail').split('_')[1] : '';
  726. let lid = $(this).data('lid');
  727. let lindex = $(this).data('index');
  728. // 原清单和数量改变
  729. let data_bwmx = $(this).attr('data-bwmx').split('$#$');
  730. for (const b of data_bwmx) {
  731. const oamount = b.split(';')[1];
  732. let bwmx = b.split(';')[0] != 0 ? b.split(';')[0].split('_')[1] : '';
  733. let trlist = [code, name, bwmx, unit, price, oamount, scnum, '', lid];
  734. const radionInfo = radionList.find(function (item) {
  735. const info = item.split(';');
  736. return info[0] === code && (info[8] == lid || parseInt(info[8]) === parseInt(lindex)) && info[2] === bwmx;
  737. });
  738. if (radionInfo) {
  739. trlist[6] = radionInfo.split(';')[6];
  740. trlist[7] = radionInfo.split(';')[7];
  741. }
  742. newTableList.push(trlist.join(';'));
  743. }
  744. });
  745. // 排序
  746. // radionList.sort();
  747. let index = 0;
  748. let whiteIndex = 0;
  749. let deteletr = '<td><a class="text-danger">移除</a></td>';
  750. for (const radion of newTableList) {
  751. const radionArray = radion.split(';');
  752. let code = radionArray[0];
  753. let name = radionArray[1];
  754. let bwmx = radionArray[2];
  755. let unit = radionArray[3];
  756. let price = radionArray[4];
  757. let oamount = radionArray[5];
  758. let scnum = radionArray[6];
  759. let detail = radionArray[7];
  760. let lid = radionArray[8];
  761. let sctotal = scnum !== '' && scnum !== '-' ? roundnum(parseFloat(price).mul(parseFloat(scnum)),decimal) : '';
  762. // 根据单位获取数量的位数,并得出
  763. let numdecimal = findDecimal(unit);
  764. html += '<tr class="clist clid" data-lid="' + lid + '_' + index + '" data-index="' + index + '">' +
  765. '<td data-site="0">'+ code +'</td>' +
  766. '<td data-site="1">'+ name +'</td>' +
  767. '<td data-site="2">'+ bwmx +'</td>' +
  768. '<td data-site="3"><input class="form-control form-control-sm" type="text" placeholder="变更详情" value="' + detail + '"></td>' +
  769. '<td data-site="4">'+ unit +'</td>' +
  770. '<td data-site="5">'+ roundnum(price, updecimal) +'</td>' +
  771. '<td data-site="6">'+ roundnum(oamount, numdecimal) +'</td>' +
  772. '<td data-site="7">'+ roundnum(parseFloat(price).mul(parseFloat(oamount)),decimal) +'</td>' +
  773. '<td data-site="8"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" placeholder="请输入变更数量" value="'+ (scnum != '-' ? roundnum(scnum, numdecimal) : '') +'"></td>' +
  774. '<td data-site="9">'+ sctotal +'</td>'+
  775. deteletr +'</tr>';
  776. index ++;
  777. }
  778. $('#change-list').val(newTableList.join('^_^'));
  779. let radionWhiteList = $('#change-whitelist').val() !== '' ? $('#change-whitelist').val().split('^_^') : [];
  780. //判断是否添加空白清单
  781. if(status == 'addwhite'){
  782. let trlist = ['','','','','',makedecimalzero(findDecimal(3)),makedecimalzero(findDecimal(3)),'',0];
  783. radionWhiteList.push(trlist.join(';'));
  784. }
  785. for (const rw of radionWhiteList) {
  786. const radionArray = rw.split(';');
  787. let code = radionArray[0];
  788. let name = radionArray[1];
  789. let bwmx = radionArray[2];
  790. let unit = radionArray[3];
  791. let price = radionArray[4];
  792. let oamount = radionArray[5];
  793. let scnum = radionArray[6];
  794. let detail = radionArray[7];
  795. let ototal = price != '' && oamount != '' ? roundnum(parseFloat(price).mul(parseFloat(oamount)),decimal) : '';
  796. let sctotal = price != '' && scnum != '' ? roundnum(parseFloat(price).mul(parseFloat(scnum)),decimal) : '';
  797. let optionlist = '<option></option>';
  798. for (const j in changeUnits) {
  799. if (changeUnits[j].unit !== undefined && changeUnits[j].unit === unit) {
  800. optionlist += '<option selected="selected">'+ changeUnits[j].unit +'</option>';
  801. } else if(changeUnits[j].unit !== undefined) {
  802. optionlist += '<option>'+ changeUnits[j].unit +'</option>';
  803. }
  804. }
  805. // 根据单位获取数量的位数,并得出
  806. let numdecimal = findDecimal(unit);
  807. html += '<tr class="clist" data-lid="' + whiteIndex + '" data-index="' + whiteIndex + '">' +
  808. '<td data-site="0"><input class="form-control form-control-sm" type="text" value="'+ code +'" placeholder="清单编号"></td>' +
  809. '<td data-site="1"><input class="form-control form-control-sm" type="text" value="'+ name +'" placeholder="名称"></td>' +
  810. '<td data-site="2"><input class="form-control form-control-sm" type="text" value="'+ bwmx +'" placeholder="变更部位"></td>' +
  811. '<td data-site="3"><input class="form-control form-control-sm" type="text" value="'+ detail +'" placeholder="变更详情"></td>' +
  812. '<td data-site="4"><select class="form-control form-control-sm">'+ optionlist +'</select></td>' +
  813. '<td data-site="5"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ updecimal +')" value="'+ roundnum(price, updecimal) +'" placeholder="请输入单价"></td>' +
  814. '<td data-site="6"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(oamount, numdecimal) +'" placeholder="请输入数量"></td>' +
  815. '<td data-site="7">'+ ototal +'</td>' +
  816. '<td data-site="8"><input class="form-control form-control-sm" type="text" onkeyup="RegNum(this,event,'+ numdecimal +')" value="'+ roundnum(scnum, numdecimal) +'" placeholder="请输入变更数量"></td>' +
  817. '<td data-site="9">'+ sctotal +'</td>'+
  818. deteletr +'</tr>';
  819. whiteIndex ++;
  820. }
  821. $('#change-whitelist').val(radionWhiteList.join('^_^'));
  822. if (table) {
  823. table.destroy();
  824. }
  825. $('#list').html(html);
  826. table = $('#tablelist').removeAttr('width').DataTable({
  827. columnDefs: [
  828. { className: 'allwidth1', width: 100, targets: 0 },
  829. { className: 'allwidth2', width: 150, targets: [1,2,3] },
  830. { className: 'allwidth4', width: 40, targets: 10 },
  831. { className: 'allwidth5', width: 60, targets: 4 },
  832. { className: 'allwidth3',width: 80, targets: '_all' }
  833. ],
  834. fixedColumns: {
  835. leftColumns: 6
  836. }
  837. });
  838. // 判断是否显示变更详情
  839. if (!$('.change-detail-checkbox').is(':checked')) {
  840. const column = table.column(3);
  841. column.visible(!column.visible());
  842. }
  843. totalamount(decimal);
  844. // $('#table-list-select tr').removeClass('table-success');
  845. }
  846. //统计合计金额
  847. function totalamount(decimal){
  848. let zero = makedecimalzero(decimal);
  849. let ctotalnum = 0;
  850. let ototalnum = 0;
  851. $('.clist').each(function(){
  852. let ctotal = $(this).children('td[data-site="9"]').text();
  853. ctotalnum = ctotal != '' ? parseFloat(ctotalnum).add(parseFloat(ctotal)) : parseFloat(ctotalnum);
  854. let ototal = $(this).children('td[data-site="7"]').text();
  855. ototalnum = ototal != '' ? parseFloat(ototalnum).add(parseFloat(ototal)) : parseFloat(ototalnum);
  856. });
  857. $('.ctatalamount').eq(1).text(ctotalnum != 0 ? roundnum(ctotalnum,decimal) : zero);
  858. $('.otatalamount').eq(1).text(ototalnum != 0 ? roundnum(ototalnum,decimal) : zero);
  859. judgeChange();
  860. }
  861. // 找出单位对应的小数位数值
  862. function findDecimal(unit) {
  863. let value = precision.other.value;
  864. const changeUnits = precision;
  865. for (const d in changeUnits) {
  866. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  867. value = changeUnits[d].value;
  868. break;
  869. }
  870. }
  871. return value;
  872. }
  873. // 判断是否有更改过
  874. function judgeChange() {
  875. let change = false;
  876. if ($('#change-list').val() !== $('#back-change-list').val()) {
  877. change = true;
  878. }
  879. if ($('#change-whitelist').val() !== $('#back-change-whitelist').val()) {
  880. change = true;
  881. }
  882. if (!isObjEqual(changeInfo, back_changeInfo)) {
  883. change = true;
  884. }
  885. if (change) {
  886. $('#show-save-btn').show();
  887. $('.title-main').addClass('bg-warning');
  888. } else {
  889. $('#show-save-btn').hide();
  890. $('.title-main').removeClass('bg-warning');
  891. }
  892. }
  893. function isObjEqual(o1,o2){
  894. var props1 = Object.getOwnPropertyNames(o1);
  895. var props2 = Object.getOwnPropertyNames(o2);
  896. if (props1.length != props2.length) {
  897. return false;
  898. }
  899. for (var i = 0,max = props1.length; i < max; i++) {
  900. var propName = props1[i];
  901. if (o1[propName] !== o2[propName]) {
  902. return false;
  903. }
  904. }
  905. return true;
  906. }