tender.js 29 KB

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