tender.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. /**
  2. * 标段相关js
  3. *
  4. * @author CaiAoLin
  5. * @date 2018/2/5
  6. * @version
  7. */
  8. // 属性
  9. function loadCommonProperty () {
  10. // 合同信息
  11. $('#build-name').val(property.deal_info.buildName);
  12. $('#deal-code').val(property.deal_info.dealCode);
  13. $('#deal-name').val(property.deal_info.dealName);
  14. // 参建单位
  15. // 建设单位
  16. $('#build-company').val(property.construction_unit.build.company);
  17. $('#build-corporation').val(property.construction_unit.build.corporation);
  18. $('#build-date').val(property.construction_unit.build.date);
  19. // 承包单位1
  20. $('#contract1-company').val(property.construction_unit.contract1.company);
  21. $('#contract1-corporation').val(property.construction_unit.contract1.corporation);
  22. $('#contract1-date').val(property.construction_unit.contract1.date);
  23. // 承包单位2
  24. $('#contract2-company').val(property.construction_unit.contract2.company);
  25. $('#contract2-corporation').val(property.construction_unit.contract2.corporation);
  26. $('#contract2-date').val(property.construction_unit.contract2.date);
  27. // 监理单位1
  28. $('#supervision1-company').val(property.construction_unit.supervision1.company);
  29. $('#supervision1-corporation').val(property.construction_unit.supervision1.corporation);
  30. $('#supervision1-date').val(property.construction_unit.supervision1.date);
  31. // 监理单位2
  32. $('#supervision2-company').val(property.construction_unit.supervision2.company);
  33. $('#supervision2-corporation').val(property.construction_unit.supervision2.corporation);
  34. $('#supervision2-date').val(property.construction_unit.supervision2.date);
  35. // 技术参数
  36. $('#loadLevel').val(property.tech_param.loadLevel);
  37. $('#length').val(property.tech_param.loadLength);
  38. $('#start-peg').val(property.tech_param.startPeg);
  39. $('#end-peg').val(property.tech_param.endPeg);
  40. $('#lane-count').val(property.tech_param.laneCount);
  41. $('#deal-period').val(property.tech_param.dealPeriod);
  42. $('#start-date').val(property.tech_param.startDate);
  43. $('#plan-end-date').val(property.tech_param.planEndDate);
  44. }
  45. // 小数位数
  46. function loadCalculateProperty () {
  47. $('#decimal-up').val(property.decimal.up);
  48. $('#decimal-tp').val(property.decimal.tp);
  49. $('#decimal-pay')[0].checked = property.decimal.pay;
  50. $('#decimal-pay-tp').val(property.decimal.payTp);
  51. }
  52. // 显示设置
  53. function loadDisplayProperty () {
  54. $('#ledger-dgn-qty')[0].checked = property.display.ledger.dgnQty;
  55. $('#ledger-cl-qty')[0].checked = property.display.ledger.clQty;
  56. }
  57. // 设置某个div下全部的input、select是否只读
  58. function setReadOnly(obj, readOnly) {
  59. if (readOnly) {
  60. $('input', obj).attr('readonly', '');
  61. $('select', obj).attr('disabled', '');
  62. $('input[type=checkbox]', obj).attr('disabled', '');
  63. } else {
  64. $('input', obj).removeAttr('readonly');
  65. $('select', obj).removeAttr('disabled');
  66. $('input[type=checkbox]', obj).removeAttr('disabled');
  67. }
  68. }
  69. // 根据Min Max限制Input输入
  70. function limitInputMinMax (obj) {
  71. if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
  72. obj.value = obj.max;
  73. }
  74. if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
  75. obj.value = obj.min;
  76. }
  77. }
  78. // 根据Maxlength限制input输入
  79. function limitMaxLength (obj) {
  80. if (obj.value.length > obj.maxLength) {
  81. obj.value = obj.value.substr(0, obj.maxLength);
  82. }
  83. }
  84. // 根据正则限制输入
  85. function limitReg(obj, reg) {
  86. obj.value = obj.value.replace(reg, '');
  87. }
  88. // 小数位数 input 输入限制
  89. function limitDecimal(obj) {
  90. limitReg(obj, /[^\d]/g);
  91. limitMaxLength(obj);
  92. limitInputMinMax(obj);
  93. }
  94. function limitDealParamLength(obj) {
  95. limitReg(obj, /[^\d\.]/g); // 过滤数字和.
  96. limitReg(obj, /\.{2,}/g); // 过滤第二个.
  97. limitInputMinMax(obj);
  98. }
  99. function checkNumberValid(obj) {
  100. const value = _.toNumber(obj.value);
  101. obj.value = value ? value : '';
  102. }
  103. $(document).ready(function() {
  104. // 清单精度
  105. const precisionObj = (function () {
  106. const spread = SpreadJsObj.createNewSpread($('#precision-spread')[0]);
  107. spread.options.showVerticalScrollbar = false;
  108. spread.options.showHorizontalScrollbar = false;
  109. const sheet = spread.getActiveSheet();
  110. SpreadJsObj.protectedSheet(sheet);
  111. sheet.options.rowHeaderVisible = false;
  112. sheet.options.colHeaderVisible = false;
  113. const vStyle = new spreadNS.Style();
  114. vStyle.font = '12px 微软雅黑';
  115. sheet.setDefaultStyle(vStyle, spreadNS.SheetArea.viewport);
  116. SpreadJsObj.massOperationSheet(sheet, function () {
  117. sheet.defaults.rowHeight = 25;
  118. sheet.setColumnCount(3);
  119. sheet.setRowCount(14);
  120. sheet.setColumnWidth(0, 1);
  121. sheet.setColumnWidth(1, 100);
  122. sheet.setColumnWidth(2, 60);
  123. sheet.setRowHeight(0, 1);
  124. sheet.getRange(1, 1, 14, 1).vAlign(1).backColor('#e4e7ea').locked(true);
  125. sheet.getRange(1, 2, 14, 1).vAlign(1).hAlign(2).locked(true);
  126. sheet.setText(1, 1, 't');
  127. sheet.setText(2, 1, 'km');
  128. sheet.setText(3, 1, 'm');
  129. sheet.setText(4, 1, 'm2');
  130. sheet.setText(5, 1, 'm3');
  131. sheet.setText(6, 1, 'kg');
  132. sheet.setText(7, 1, '个');
  133. sheet.setText(8, 1, '台');
  134. sheet.setText(9, 1, '套');
  135. sheet.setText(10, 1, '棵');
  136. sheet.setText(11, 1, '组');
  137. sheet.setText(12, 1, '系统');
  138. sheet.setText(13, 1, '其他未列单位');
  139. const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
  140. sheet.getRange(0, 0, 14, 3).setBorder(lineBorder, {all: true});
  141. sheet.getRange(0, 0, 14, 3).formatter('@');
  142. sheet.setSelection(1, 2, 1, 1);
  143. });
  144. spread.bind(spreadNS.Events.EditEnded, function (e, info) {
  145. const value = _.toNumber(info.editingText);
  146. if (!_.isInteger(value)) {
  147. toastr.warning('请输入0-6的整数');
  148. sheet.setText(info.row, info.col, '0');
  149. } else if (value > 6) {
  150. toastr.warning('请输入0-6的整数');
  151. sheet.setText(info.row, info.col, '6');
  152. } else if (value < 0) {
  153. toastr.warning('请输入0-6的整数');
  154. sheet.setText(info.row, info.col, '0');
  155. }
  156. });
  157. SpreadJsObj.addDeleteBind(spread, function (sheet) {
  158. const sel = sheet.getSelections()[0];
  159. let calc = false;
  160. if (sel) {
  161. for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
  162. if (iRow === 3) continue;
  163. for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
  164. if (iCol !== 2) continue;
  165. sheet.setText(iRow, iCol, '0');
  166. if (iRow === 1 || iRow === 2) calc = true;
  167. }
  168. }
  169. }
  170. if (calc) calcHtjMinusZlj();
  171. });
  172. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  173. let bHint = false;
  174. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  175. const curRow = info.cellRange.row + iRow;
  176. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  177. const curCol = info.cellRange.col + iCol;
  178. const value = _.toNumber(info.sheet.getText(curRow, curCol));
  179. if (_.isNaN(value) || !_.isInteger(value)) {
  180. bHint = true;
  181. info.sheet.setText(curRow, curCol, '0');
  182. } else if (value > 6) {
  183. bHint = true;
  184. info.sheet.setText(curRow, curCol, '6');
  185. } else if (value < 0) {
  186. bHint = true;
  187. info.sheet.setText(curRow, curCol, '0');
  188. }
  189. }
  190. }
  191. if (bHint) {
  192. toastr.warning('请输入0-6的整数');
  193. }
  194. });
  195. function loadPrecisonProperty() {
  196. $('#hint-3').hide();
  197. sheet.setValue(1, 2, property.precision.t.value);
  198. sheet.setValue(2, 2, property.precision.km.value);
  199. sheet.setValue(3, 2, property.precision.m.value);
  200. sheet.setValue(4, 2, property.precision.m2.value);
  201. sheet.setValue(5, 2, property.precision.m3.value);
  202. sheet.setValue(6, 2, property.precision.kg.value);
  203. sheet.setValue(7, 2, property.precision.ge.value);
  204. sheet.setValue(8, 2, property.precision.tai.value);
  205. sheet.setValue(9, 2, property.precision.tao.value);
  206. sheet.setValue(10, 2, property.precision.ke.value);
  207. sheet.setValue(11, 2, property.precision.zu.value);
  208. sheet.setValue(12, 2, property.precision.xitong.value);
  209. sheet.setValue(13, 2, property.precision.other.value);
  210. }
  211. function setReadOnly(readOnly) {
  212. sheet.getRange(1, 2, 14, 1).locked(readOnly);
  213. }
  214. function getNewPrecisionData() {
  215. const precision = JSON.parse(JSON.stringify(property.precision));
  216. precision.t.value = _.toNumber(sheet.getText(1, 2));
  217. precision.km.value = _.toNumber(sheet.getText(2, 2));
  218. precision.m.value = _.toNumber(sheet.getText(3, 2));
  219. precision.m2.value = _.toNumber(sheet.getText(4, 2));
  220. precision.m3.value = _.toNumber(sheet.getText(5, 2));
  221. precision.kg.value = _.toNumber(sheet.getText(6, 2));
  222. precision.ge.value = _.toNumber(sheet.getText(7, 2));
  223. precision.tai.value = _.toNumber(sheet.getText(8, 2));
  224. precision.tao.value = _.toNumber(sheet.getText(9, 2));
  225. precision.ke.value = _.toNumber(sheet.getText(10, 2));
  226. precision.zu.value = _.toNumber(sheet.getText(11, 2));
  227. precision.xitong.value = _.toNumber(sheet.getText(12, 2));
  228. precision.other.value = _.toNumber(sheet.getText(13, 2));
  229. return precision;
  230. }
  231. function checkPrecisionMinLimit(precision, limit) {
  232. for (const unit of precision) {
  233. if (precision[unit].value < limit[unit].value) {
  234. if (precision[unit].unit) {
  235. toastr.warning('台账已审批通过,清单精度不可减少,单位为' + limit[unit].unit + '的清单的精度不可小于' + limit[unit].value);
  236. } else {
  237. toastr.warning('台账已审批通过,清单精度不可减少,其他清单的精度不可小于' + limit[unit].value);
  238. }
  239. return false;
  240. }
  241. }
  242. return true;
  243. };
  244. return {loadPrecisonProperty, setReadOnly, getNewPrecisionData, checkPrecisionMinLimit};
  245. })();
  246. // 合同参数
  247. const dealObj = (function () {
  248. const spread = SpreadJsObj.createNewSpread($('#param-spread')[0]);
  249. spread.options.showVerticalScrollbar = false;
  250. spread.options.showHorizontalScrollbar = false;
  251. const sheet = spread.getActiveSheet();
  252. SpreadJsObj.protectedSheet(sheet);
  253. const vStyle = new spreadNS.Style();
  254. vStyle.font = '12px 微软雅黑';
  255. sheet.setDefaultStyle(vStyle, spreadNS.SheetArea.viewport);
  256. SpreadJsObj.massOperationSheet(sheet, function () {
  257. sheet.options.rowHeaderVisible = false;
  258. sheet.options.colHeaderVisible = false;
  259. sheet.defaults.rowHeight = 25;
  260. sheet.setColumnCount(3);
  261. sheet.setRowCount(6);
  262. sheet.setColumnWidth(0, 1);
  263. sheet.setColumnWidth(1, 200);
  264. sheet.setColumnWidth(2, 200);
  265. sheet.setRowHeight(0, 1);
  266. sheet.getRange(1, 1, 5, 1).vAlign(1).backColor('#e4e7ea').locked(true);
  267. sheet.getRange(1, 2, 5, 1).vAlign(1).hAlign(2).locked(true);
  268. sheet.setText(1, 1, '签约合同价');
  269. sheet.setText(2, 1, '暂列金额');
  270. sheet.setText(3, 1, '签约合同价(不含暂列金)');
  271. sheet.setText(4, 1, '签约开工预付款');
  272. sheet.setText(5, 1, '签约材料预付款');
  273. const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
  274. sheet.getRange(0, 0, 6, 3).setBorder(lineBorder, {all: true});
  275. sheet.getRange(0, 0, 6, 3).formatter('@');
  276. sheet.setSelection(1, 2, 1, 1);
  277. });
  278. function calcHtjMinusZlj() {
  279. const htj = _.toNumber(sheet.getText(1, 2));
  280. const zlj = _.toNumber(sheet.getText(2, 2));
  281. sheet.setValue(3, 2, accSub(zlj, htj));
  282. }
  283. spread.bind(spreadNS.Events.EditEnded, function (e, info) {
  284. const value = _.toNumber(info.editingText);
  285. if (_.isNaN(value)) {
  286. toastr.warning('请输入不超过万亿的数字');
  287. info.sheet.setText(info.row, info.col, '0');
  288. } else if (value > Math.pow(10, 13)) {
  289. toastr.warning('请输入不超过万亿的数字');
  290. info.sheet.setText(info.row, info.col, '0');
  291. }
  292. if (info.row === 1 || info.row === 2) {
  293. calcHtjMinusZlj();
  294. }
  295. });
  296. SpreadJsObj.addDeleteBind(spread, function (sheet) {
  297. const sel = sheet.getSelections()[0];
  298. let calc = false;
  299. if (sel) {
  300. for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
  301. if (iRow === 3) continue;
  302. for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
  303. if (iCol !== 2) continue;
  304. sheet.setText(iRow, iCol, '0');
  305. if (iRow === 1 || iRow === 2) calc = true;
  306. }
  307. }
  308. }
  309. if (calc) calcHtjMinusZlj();
  310. });
  311. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  312. let bHint = false;
  313. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  314. const curRow = info.cellRange.row + iRow;
  315. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  316. const curCol = info.cellRange.col + iCol;
  317. const value = _.toNumber(info.sheet.getText(curRow, curCol));
  318. if (_.isNaN(value) || value > Math.pow(10, 13)) {
  319. bHint = true;
  320. info.sheet.setText(curRow, curCol, '0');
  321. }
  322. }
  323. }
  324. if (bHint) {
  325. toastr.warning('请输入不超过万亿的数字');
  326. }
  327. calcHtjMinusZlj();
  328. });
  329. function loadDealProperty() {
  330. $('#hint-4').hide();
  331. sheet.setValue(1, 2, property.deal_param.contractPrice);
  332. sheet.setValue(2, 2, property.deal_param.zanLiePrice);
  333. sheet.setValue(3, 2, accSub(property.deal_param.zanLiePrice, property.deal_param.contractPrice));
  334. sheet.setValue(4, 2, property.deal_param.startAdvance);
  335. sheet.setValue(5, 2, property.deal_param.materialAdvance);
  336. }
  337. function setReadOnly (readOnly) {
  338. sheet.getCell(1, 2).locked(readOnly);
  339. sheet.getCell(2, 2).locked(readOnly);
  340. sheet.getCell(4, 2).locked(readOnly);
  341. sheet.getCell(5, 2).locked(readOnly);
  342. }
  343. function getNewDealData () {
  344. const result = {};
  345. result.contractPrice = _.toNumber(sheet.getText(1, 2));
  346. result.zanLiePrice = _.toNumber(sheet.getText(2, 2));
  347. result.startAdvance = _.toNumber(sheet.getText(4, 2));
  348. result.materialAdvance = _.toNumber(sheet.getText(5, 2));
  349. return result;
  350. }
  351. return { loadDealProperty, setReadOnly, getNewDealData, };
  352. })();
  353. // 章节设置
  354. const chapterObj = (function () {
  355. const spreadSetting = {
  356. cols: [
  357. {title: '章节', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: true},
  358. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
  359. ],
  360. emptyRows: 0,
  361. headRows: 1,
  362. headRowHeight: [32],
  363. defaultRowHeight: 21,
  364. headerFont: '12px 微软雅黑',
  365. font: '12px 微软雅黑',
  366. };
  367. const spread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]);
  368. spread.options.showVerticalScrollbar = false;
  369. spread.options.showHorizontalScrollbar = false;
  370. SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
  371. function checkSheetData(sheet) {
  372. let hint = '';
  373. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  374. const cell = sheet.getCell(iRow, 1);
  375. const defaultStype = sheet.getDefaultStyle();
  376. if (cell.text().length > 50) {
  377. cell.backColor('#f8d7da');
  378. hint = '章节名称的长度超出范围,请重新输入';
  379. } else {
  380. cell.backColor(defaultStype.backColor);
  381. }
  382. }
  383. if (hint === '') {
  384. $('#hint-6').hide();
  385. } else {
  386. $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
  387. }
  388. }
  389. spread.bind(spreadNS.Events.EditEnding, function (e, info) {
  390. checkSheetData(info.sheet);
  391. });
  392. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  393. checkSheetData(info.sheet);
  394. });
  395. function loadChapterProperty() {
  396. SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
  397. $('#hint-6').hide();
  398. const sheet = spread.getActiveSheet();
  399. const defaultStype = sheet.getDefaultStyle();
  400. sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).backColor(defaultStype.backColor);
  401. }
  402. function setReadOnly(readOnly) {
  403. SpreadJsObj.resetFieldReadOnly(spread.getActiveSheet(), 'name', readOnly);
  404. }
  405. function getNewChapterData() {
  406. const result = [];
  407. const sheet = spread.getActiveSheet();
  408. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  409. const data = {};
  410. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
  411. const col = spreadSetting.cols[iCol];
  412. data[col.field] = sheet.getText(iRow, iCol);
  413. if (col.field === 'name') {
  414. if (data.name.length > 50) {
  415. return null;
  416. }
  417. }
  418. }
  419. result.push(data);
  420. }
  421. return result;
  422. }
  423. return { loadChapterProperty, setReadOnly, getNewChapterData, }
  424. })();
  425. // 标段属性
  426. function loadTenderProperty() {
  427. // 加载属性
  428. loadCommonProperty();
  429. loadCalculateProperty();
  430. precisionObj.loadPrecisonProperty();
  431. dealObj.loadDealProperty();
  432. loadDisplayProperty();
  433. chapterObj.loadChapterProperty();
  434. // 设置只读
  435. setReadOnly('#shuxing', true);
  436. }
  437. loadTenderProperty();
  438. /**
  439. * 属性
  440. */
  441. // 编辑
  442. $('#edit-1').click(() => {
  443. setReadOnly('#v-pills-1', false);
  444. $('#post-1').parent().show();
  445. $('#edit-1').parent().hide();
  446. });
  447. // 取消
  448. $('#cancel-1').click(() => {
  449. setReadOnly('#v-pills-1', true);
  450. loadCommonProperty();
  451. $('#post-1').parent().hide();
  452. $('#edit-1').parent().show();
  453. });
  454. // 提交
  455. $('#post-1').click(() => {
  456. const prop = {
  457. deal_info: {
  458. buildName: $('#build-name').val(),
  459. dealCode: $('#deal-code').val(),
  460. dealName: $('#deal-name').val(),
  461. },
  462. construction_unit: {
  463. build: {
  464. company: $('#build-company').val(),
  465. corporation: $('#build-corporation').val(),
  466. date: $('#build-date').val(),
  467. },
  468. contract1: {
  469. company: $('#contract1-company').val(),
  470. corporation: $('#contract1-corporation').val(),
  471. date: $('#contract1-date').val(),
  472. },
  473. contract2: {
  474. company: $('#contract2-company').val(),
  475. corporation: $('#contract2-corporation').val(),
  476. date: $('#contract2-date').val(),
  477. },
  478. supervision1: {
  479. company: $('#supervision1-company').val(),
  480. corporation: $('#supervision1-corporation').val(),
  481. date: $('#supervision1-date').val(),
  482. },
  483. supervision2: {
  484. company: $('#supervision2-company').val(),
  485. corporation: $('#supervision2-corporation').val(),
  486. date: $('#supervision2-date').val(),
  487. },
  488. },
  489. tech_param: {
  490. loadLevel: _.toNumber($('#loadLevel').val()),
  491. loadLength: _.toNumber($('#length').val()),
  492. startPeg: $('#start-peg').val(),
  493. endPeg: $('#end-peg').val(),
  494. laneCount: _.toNumber($('#lane-count').val()),
  495. dealPeriod: $('#deal-period').val(),
  496. startDate: $('#start-date').val(),
  497. planEndDate: $('#plan-end-date').val(),
  498. }
  499. };
  500. const tenderId = window.location.pathname.split('/')[2];
  501. postData('/tender/' + tenderId + '/save', prop, function (data) {
  502. setReadOnly('#v-pills-1', true);
  503. property.deal_info = data.deal_info;
  504. property.construction_unit = data.construction_unit;
  505. property.tech_param = data.tech_param;
  506. $('#post-1').parent().hide();
  507. $('#edit-1').parent().show();
  508. });
  509. });
  510. /**
  511. * 计算参数
  512. */
  513. // 编辑
  514. $('#edit-2').click(() => {
  515. setReadOnly('#v-pills-2', false);
  516. $('#post-2').parent().show();
  517. $('#edit-2').parent().hide();
  518. });
  519. // 取消
  520. $('#cancel-2').click(() => {
  521. setReadOnly('#v-pills-2', true);
  522. loadCalculateProperty();
  523. $('#post-2').parent().hide();
  524. $('#edit-2').parent().show();
  525. });
  526. // 提交
  527. $('#post-2').click(() => {
  528. const prop = {
  529. decimal: {
  530. up: _.toNumber($('#decimal-up').val()),
  531. tp: _.toNumber($('#decimal-tp').val()),
  532. pay: $('#decimal-pay')[0].checked,
  533. payTp: _.toNumber($('#decimal-pay-tp').val()),
  534. }
  535. };
  536. if (ledgerChecked) {
  537. if (prop.decimal.up < property.decimal.up) {
  538. toastr.warning('台账已审批完成,单价的小数位数,不可小于' + property.decimal.up);
  539. return;
  540. }
  541. if (prop.decimal.tp < property.decimal.tp) {
  542. toastr.warning('台账已审批完成,金额的小数位数,不可小于' + property.decimal.tp);
  543. return;
  544. }
  545. }
  546. if (firstStageChecked) {
  547. if (property.decimal.pay) {
  548. if (!prop.decimal.pay) {
  549. toastr.warning('第一期已审批完成,不可取消合同支付单独设置');
  550. return;
  551. }
  552. if (prop.decimal.payTp < property.decimal.payTp) {
  553. toastr.warning('第一期已审批完成,单独设置的合同支付小数位数,不可小于' + property.decimal.payTp);
  554. return;
  555. }
  556. } else {
  557. if (prop.decimal.pay) {
  558. toastr.warning('第一期已审批完成,合同支付不可单独设置');
  559. return;
  560. }
  561. }
  562. }
  563. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.decimal, property.decimal)) return;
  564. const tenderId = window.location.pathname.split('/')[2];
  565. postData('/tender/' + tenderId + '/save', prop, function (data) {
  566. setReadOnly('#v-pills-2', true);
  567. property.decimal = data.decimal;
  568. $('#post-2').parent().hide();
  569. $('#edit-2').parent().show();
  570. }, null, true);
  571. });
  572. /**
  573. * 清单精度
  574. */
  575. // 编辑
  576. $('#edit-3').click(() => {
  577. precisionObj.setReadOnly(false);
  578. $('#post-3').parent().show();
  579. $('#edit-3').parent().hide();
  580. });
  581. // 取消
  582. $('#cancel-3').click(() => {
  583. precisionObj.setReadOnly(true);
  584. precisionObj.loadPrecisonProperty();
  585. $('#post-3').parent().hide();
  586. $('#edit-3').parent().show();
  587. });
  588. // 提交
  589. $('#post-3').click(() => {
  590. const prop = { precision: precisionObj.getNewPrecisionData() };
  591. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.precision, property.precision)) return;
  592. const tenderId = window.location.pathname.split('/')[2];
  593. postData('/tender/' + tenderId + '/save', prop, function (data) {
  594. precisionObj.setReadOnly(true);
  595. property.precision = data.precision;
  596. $('#post-3').parent().hide();
  597. $('#edit-3').parent().show();
  598. }, null, true);
  599. });
  600. /**
  601. * 合同参数
  602. */
  603. // 编辑
  604. $('#edit-4').click(() => {
  605. dealObj.setReadOnly(false);
  606. $('#post-4').parent().show();
  607. $('#edit-4').parent().hide();
  608. });
  609. // 取消
  610. $('#cancel-4').click(() => {
  611. dealObj.setReadOnly(true);
  612. dealObj.loadDealProperty();
  613. $('#post-4').parent().hide();
  614. $('#edit-4').parent().show();
  615. });
  616. // 提交
  617. $('#post-4').click(() => {
  618. const prop = { deal_param: dealObj.getNewDealData() };
  619. const tenderId = window.location.pathname.split('/')[2];
  620. postData('/tender/' + tenderId + '/save', prop, function (data) {
  621. dealObj.setReadOnly(true);
  622. property.deal_param = data.deal_param;
  623. $('#post-4').parent().hide();
  624. $('#edit-4').parent().show();
  625. dealObj.loadDealProperty();
  626. });
  627. });
  628. /**
  629. * 显示设置
  630. */
  631. // 编辑
  632. $('#edit-5').click(() => {
  633. setReadOnly('#v-pills-5', false);
  634. $('#post-5').parent().show();
  635. $('#edit-5').parent().hide();
  636. });
  637. // 取消
  638. $('#cancel-5').click(() => {
  639. setReadOnly('#v-pills-5', true);
  640. loadDisplayProperty();
  641. $('#post-5').parent().hide();
  642. $('#edit-5').parent().show();
  643. });
  644. // 提交
  645. $('#post-5').click(() => {
  646. const prop = {
  647. display: {
  648. ledger: { dgnQty: $('#ledger-dgn-qty')[0].checked, clQty: $('#ledger-cl-qty')[0].checked, },
  649. },
  650. };
  651. const tenderId = window.location.pathname.split('/')[2];
  652. postData('/tender/' + tenderId + '/save', prop, function (data) {
  653. setReadOnly('#v-pills-5', true);
  654. property.display = data.display;
  655. $('#post-5').parent().hide();
  656. $('#edit-5').parent().show();
  657. });
  658. });
  659. /**
  660. * 章节设置
  661. */
  662. // 编辑
  663. $('#edit-6').click(() => {
  664. chapterObj.setReadOnly(false);
  665. $('#post-6').parent().show();
  666. $('#edit-6').parent().hide();
  667. });
  668. // 取消
  669. $('#cancel-6').click(() => {
  670. chapterObj.loadChapterProperty();
  671. chapterObj.setReadOnly(true);
  672. $('#hint-6').hide();
  673. $('#post-6').parent().hide();
  674. $('#edit-6').parent().show();
  675. });
  676. // 提交
  677. $('#post-6').click(() => {
  678. const chapter = chapterObj.getNewChapterData();
  679. if (!chapter) { return; }
  680. const tenderId = window.location.pathname.split('/')[2];
  681. postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
  682. chapterObj.setReadOnly(true);
  683. property.chapter = data.chapter;
  684. $('#post-6').parent().hide();
  685. $('#edit-6').parent().show();
  686. });
  687. });
  688. });