tender.js 29 KB

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