tender.js 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  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(7);
  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, 6, 1).vAlign(1).backColor('#e4e7ea').locked(true);
  267. sheet.getRange(1, 2, 6, 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. sheet.setText(6, 1, '安全生产费');
  274. const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
  275. sheet.getRange(0, 0, 7, 3).setBorder(lineBorder, {all: true});
  276. sheet.getRange(0, 0, 7, 3).formatter('@');
  277. sheet.setSelection(1, 2, 1, 1);
  278. });
  279. function calcHtjMinusZlj() {
  280. const htj = _.toNumber(sheet.getText(1, 2));
  281. const zlj = _.toNumber(sheet.getText(2, 2));
  282. sheet.setValue(3, 2, accSub(zlj, htj));
  283. }
  284. spread.bind(spreadNS.Events.EditEnded, function (e, info) {
  285. const value = _.toNumber(info.editingText);
  286. if (_.isNaN(value)) {
  287. toastr.warning('请输入不超过万亿的数字');
  288. info.sheet.setText(info.row, info.col, '0');
  289. } else if (value > Math.pow(10, 13)) {
  290. toastr.warning('请输入不超过万亿的数字');
  291. info.sheet.setText(info.row, info.col, '0');
  292. }
  293. if (info.row === 1 || info.row === 2) {
  294. calcHtjMinusZlj();
  295. }
  296. });
  297. SpreadJsObj.addDeleteBind(spread, function (sheet) {
  298. const sel = sheet.getSelections()[0];
  299. let calc = false;
  300. if (sel) {
  301. for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
  302. if (iRow === 3) continue;
  303. for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
  304. if (iCol !== 2) continue;
  305. sheet.setText(iRow, iCol, '0');
  306. if (iRow === 1 || iRow === 2) calc = true;
  307. }
  308. }
  309. }
  310. if (calc) calcHtjMinusZlj();
  311. });
  312. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  313. let bHint = false;
  314. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  315. const curRow = info.cellRange.row + iRow;
  316. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  317. const curCol = info.cellRange.col + iCol;
  318. const value = _.toNumber(info.sheet.getText(curRow, curCol));
  319. if (_.isNaN(value) || value > Math.pow(10, 13)) {
  320. bHint = true;
  321. info.sheet.setText(curRow, curCol, '0');
  322. }
  323. }
  324. }
  325. if (bHint) {
  326. toastr.warning('请输入不超过万亿的数字');
  327. }
  328. calcHtjMinusZlj();
  329. });
  330. function loadDealProperty() {
  331. $('#hint-4').hide();
  332. sheet.setValue(1, 2, property.deal_param.contractPrice);
  333. sheet.setValue(2, 2, property.deal_param.zanLiePrice);
  334. sheet.setValue(3, 2, accSub(property.deal_param.zanLiePrice, property.deal_param.contractPrice));
  335. sheet.setValue(4, 2, property.deal_param.startAdvance);
  336. sheet.setValue(5, 2, property.deal_param.materialAdvance);
  337. sheet.setValue(6, 2, property.deal_param.safeAdvance);
  338. }
  339. function setReadOnly (readOnly) {
  340. sheet.getCell(1, 2).locked(readOnly);
  341. sheet.getCell(2, 2).locked(readOnly);
  342. sheet.getCell(4, 2).locked(readOnly);
  343. sheet.getCell(5, 2).locked(readOnly);
  344. sheet.getCell(6, 2).locked(readOnly);
  345. }
  346. function getNewDealData () {
  347. const result = {};
  348. result.contractPrice = _.toNumber(sheet.getText(1, 2));
  349. result.zanLiePrice = _.toNumber(sheet.getText(2, 2));
  350. result.startAdvance = _.toNumber(sheet.getText(4, 2));
  351. result.materialAdvance = _.toNumber(sheet.getText(5, 2));
  352. result.safeAdvance = _.toNumber(sheet.getText(6, 2));
  353. return result;
  354. }
  355. return { loadDealProperty, setReadOnly, getNewDealData, };
  356. })();
  357. // 章节设置
  358. const chapterObj = (function () {
  359. const spreadSetting = {
  360. cols: [
  361. {title: '章节', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: true},
  362. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
  363. ],
  364. emptyRows: 0,
  365. headRows: 1,
  366. headRowHeight: [32],
  367. defaultRowHeight: 21,
  368. headerFont: '12px 微软雅黑',
  369. font: '12px 微软雅黑',
  370. };
  371. const spread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]);
  372. spread.options.showVerticalScrollbar = false;
  373. spread.options.showHorizontalScrollbar = false;
  374. SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
  375. function checkSheetData(sheet) {
  376. let hint = '';
  377. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  378. const cell = sheet.getCell(iRow, 1);
  379. const defaultStype = sheet.getDefaultStyle();
  380. if (cell.text().length > 50) {
  381. cell.backColor('#f8d7da');
  382. hint = '章节名称的长度超出范围,请重新输入';
  383. } else {
  384. cell.backColor(defaultStype.backColor);
  385. }
  386. }
  387. if (hint === '') {
  388. $('#hint-6').hide();
  389. } else {
  390. $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
  391. }
  392. }
  393. spread.bind(spreadNS.Events.EditEnding, function (e, info) {
  394. checkSheetData(info.sheet);
  395. });
  396. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  397. checkSheetData(info.sheet);
  398. });
  399. function loadChapterProperty() {
  400. SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
  401. $('#hint-6').hide();
  402. const sheet = spread.getActiveSheet();
  403. const defaultStype = sheet.getDefaultStyle();
  404. sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).backColor(defaultStype.backColor);
  405. }
  406. function setReadOnly(readOnly) {
  407. SpreadJsObj.resetFieldReadOnly(spread.getActiveSheet(), 'name', readOnly);
  408. }
  409. function getNewChapterData() {
  410. const result = [];
  411. const sheet = spread.getActiveSheet();
  412. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  413. const data = {};
  414. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
  415. const col = spreadSetting.cols[iCol];
  416. data[col.field] = sheet.getText(iRow, iCol);
  417. if (col.field === 'name') {
  418. if (data.name.length > 50) {
  419. return null;
  420. }
  421. }
  422. }
  423. result.push(data);
  424. }
  425. return result;
  426. }
  427. return { loadChapterProperty, setReadOnly, getNewChapterData, }
  428. })();
  429. // 标段属性
  430. function loadTenderProperty() {
  431. // 加载属性
  432. loadCommonProperty();
  433. loadCalculateProperty();
  434. precisionObj.loadPrecisonProperty();
  435. dealObj.loadDealProperty();
  436. loadDisplayProperty();
  437. chapterObj.loadChapterProperty();
  438. // 设置只读
  439. setReadOnly('#shuxing', true);
  440. }
  441. loadTenderProperty();
  442. /**
  443. * 属性
  444. */
  445. // 编辑
  446. $('#edit-1').click(() => {
  447. setReadOnly('#v-pills-1', false);
  448. $('#post-1').parent().show();
  449. $('#edit-1').parent().hide();
  450. });
  451. // 取消
  452. $('#cancel-1').click(() => {
  453. setReadOnly('#v-pills-1', true);
  454. loadCommonProperty();
  455. $('#post-1').parent().hide();
  456. $('#edit-1').parent().show();
  457. });
  458. // 提交
  459. $('#post-1').click(() => {
  460. const prop = {
  461. deal_info: {
  462. buildName: $('#build-name').val(),
  463. dealCode: $('#deal-code').val(),
  464. dealName: $('#deal-name').val(),
  465. },
  466. construction_unit: {
  467. build: {
  468. company: $('#build-company').val(),
  469. corporation: $('#build-corporation').val(),
  470. date: $('#build-date').val(),
  471. },
  472. contract1: {
  473. company: $('#contract1-company').val(),
  474. corporation: $('#contract1-corporation').val(),
  475. date: $('#contract1-date').val(),
  476. },
  477. contract2: {
  478. company: $('#contract2-company').val(),
  479. corporation: $('#contract2-corporation').val(),
  480. date: $('#contract2-date').val(),
  481. },
  482. supervision1: {
  483. company: $('#supervision1-company').val(),
  484. corporation: $('#supervision1-corporation').val(),
  485. date: $('#supervision1-date').val(),
  486. },
  487. supervision2: {
  488. company: $('#supervision2-company').val(),
  489. corporation: $('#supervision2-corporation').val(),
  490. date: $('#supervision2-date').val(),
  491. },
  492. },
  493. tech_param: {
  494. loadLevel: _.toNumber($('#loadLevel').val()),
  495. loadLength: _.toNumber($('#length').val()),
  496. startPeg: $('#start-peg').val(),
  497. endPeg: $('#end-peg').val(),
  498. laneCount: _.toNumber($('#lane-count').val()),
  499. dealPeriod: $('#deal-period').val(),
  500. startDate: $('#start-date').val(),
  501. planEndDate: $('#plan-end-date').val(),
  502. }
  503. };
  504. const tenderId = window.location.pathname.split('/')[2];
  505. postData('/tender/' + tenderId + '/save', prop, function (data) {
  506. setReadOnly('#v-pills-1', true);
  507. property.deal_info = data.deal_info;
  508. property.construction_unit = data.construction_unit;
  509. property.tech_param = data.tech_param;
  510. $('#post-1').parent().hide();
  511. $('#edit-1').parent().show();
  512. });
  513. });
  514. /**
  515. * 计算参数
  516. */
  517. // 编辑
  518. $('#edit-2').click(() => {
  519. setReadOnly('#v-pills-2', false);
  520. $('#post-2').parent().show();
  521. $('#edit-2').parent().hide();
  522. });
  523. // 取消
  524. $('#cancel-2').click(() => {
  525. setReadOnly('#v-pills-2', true);
  526. loadCalculateProperty();
  527. $('#post-2').parent().hide();
  528. $('#edit-2').parent().show();
  529. });
  530. // 提交
  531. $('#post-2').click(() => {
  532. const prop = {
  533. decimal: {
  534. up: _.toNumber($('#decimal-up').val()),
  535. tp: _.toNumber($('#decimal-tp').val()),
  536. pay: $('#decimal-pay')[0].checked,
  537. payTp: _.toNumber($('#decimal-pay-tp').val()),
  538. }
  539. };
  540. if (ledgerChecked) {
  541. if (prop.decimal.up < property.decimal.up) {
  542. toastr.warning('台账已审批完成,单价的小数位数,不可小于' + property.decimal.up);
  543. return;
  544. }
  545. if (prop.decimal.tp < property.decimal.tp) {
  546. toastr.warning('台账已审批完成,金额的小数位数,不可小于' + property.decimal.tp);
  547. return;
  548. }
  549. }
  550. if (firstStageChecked) {
  551. if (property.decimal.pay) {
  552. if (!prop.decimal.pay) {
  553. toastr.warning('第一期已审批完成,不可取消合同支付单独设置');
  554. return;
  555. }
  556. if (prop.decimal.payTp < property.decimal.payTp) {
  557. toastr.warning('第一期已审批完成,单独设置的合同支付小数位数,不可小于' + property.decimal.payTp);
  558. return;
  559. }
  560. } else {
  561. if (prop.decimal.pay) {
  562. toastr.warning('第一期已审批完成,合同支付不可单独设置');
  563. return;
  564. }
  565. }
  566. }
  567. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.decimal, property.decimal)) return;
  568. const tenderId = window.location.pathname.split('/')[2];
  569. postData('/tender/' + tenderId + '/save', prop, function (data) {
  570. setReadOnly('#v-pills-2', true);
  571. property.decimal = data.decimal;
  572. $('#post-2').parent().hide();
  573. $('#edit-2').parent().show();
  574. }, null, true);
  575. });
  576. /**
  577. * 清单精度
  578. */
  579. // 编辑
  580. $('#edit-3').click(() => {
  581. precisionObj.setReadOnly(false);
  582. $('#post-3').parent().show();
  583. $('#edit-3').parent().hide();
  584. });
  585. // 取消
  586. $('#cancel-3').click(() => {
  587. precisionObj.setReadOnly(true);
  588. precisionObj.loadPrecisonProperty();
  589. $('#post-3').parent().hide();
  590. $('#edit-3').parent().show();
  591. });
  592. // 提交
  593. $('#post-3').click(() => {
  594. const prop = { precision: precisionObj.getNewPrecisionData() };
  595. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.precision, property.precision)) return;
  596. const tenderId = window.location.pathname.split('/')[2];
  597. postData('/tender/' + tenderId + '/save', prop, function (data) {
  598. precisionObj.setReadOnly(true);
  599. property.precision = data.precision;
  600. $('#post-3').parent().hide();
  601. $('#edit-3').parent().show();
  602. }, null, true);
  603. });
  604. /**
  605. * 合同参数
  606. */
  607. // 编辑
  608. $('#edit-4').click(() => {
  609. dealObj.setReadOnly(false);
  610. $('#post-4').parent().show();
  611. $('#edit-4').parent().hide();
  612. });
  613. // 取消
  614. $('#cancel-4').click(() => {
  615. dealObj.setReadOnly(true);
  616. dealObj.loadDealProperty();
  617. $('#post-4').parent().hide();
  618. $('#edit-4').parent().show();
  619. });
  620. // 提交
  621. $('#post-4').click(() => {
  622. const prop = { deal_param: dealObj.getNewDealData() };
  623. const tenderId = window.location.pathname.split('/')[2];
  624. postData('/tender/' + tenderId + '/save', prop, function (data) {
  625. dealObj.setReadOnly(true);
  626. property.deal_param = data.deal_param;
  627. $('#post-4').parent().hide();
  628. $('#edit-4').parent().show();
  629. dealObj.loadDealProperty();
  630. });
  631. });
  632. /**
  633. * 显示设置
  634. */
  635. // 编辑
  636. $('#edit-5').click(() => {
  637. setReadOnly('#v-pills-5', false);
  638. $('#post-5').parent().show();
  639. $('#edit-5').parent().hide();
  640. });
  641. // 取消
  642. $('#cancel-5').click(() => {
  643. setReadOnly('#v-pills-5', true);
  644. loadDisplayProperty();
  645. $('#post-5').parent().hide();
  646. $('#edit-5').parent().show();
  647. });
  648. // 提交
  649. $('#post-5').click(() => {
  650. const prop = {
  651. display: {
  652. ledger: { dgnQty: $('#ledger-dgn-qty')[0].checked, clQty: $('#ledger-cl-qty')[0].checked, },
  653. },
  654. };
  655. const tenderId = window.location.pathname.split('/')[2];
  656. postData('/tender/' + tenderId + '/save', prop, function (data) {
  657. setReadOnly('#v-pills-5', true);
  658. property.display = data.display;
  659. $('#post-5').parent().hide();
  660. $('#edit-5').parent().show();
  661. });
  662. });
  663. /**
  664. * 章节设置
  665. */
  666. // 编辑
  667. $('#edit-6').click(() => {
  668. chapterObj.setReadOnly(false);
  669. $('#post-6').parent().show();
  670. $('#edit-6').parent().hide();
  671. });
  672. // 取消
  673. $('#cancel-6').click(() => {
  674. chapterObj.loadChapterProperty();
  675. chapterObj.setReadOnly(true);
  676. $('#hint-6').hide();
  677. $('#post-6').parent().hide();
  678. $('#edit-6').parent().show();
  679. });
  680. // 提交
  681. $('#post-6').click(() => {
  682. const chapter = chapterObj.getNewChapterData();
  683. if (!chapter) { return; }
  684. const tenderId = window.location.pathname.split('/')[2];
  685. postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
  686. chapterObj.setReadOnly(true);
  687. property.chapter = data.chapter;
  688. $('#post-6').parent().hide();
  689. $('#edit-6').parent().show();
  690. });
  691. });
  692. });