tender.js 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  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: [40],
  372. defaultRowHeight: 21,
  373. };
  374. const spread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]);
  375. spread.options.showVerticalScrollbar = false;
  376. spread.options.showHorizontalScrollbar = false;
  377. SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
  378. function checkSheetData(sheet) {
  379. let hint = '';
  380. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  381. const cell = sheet.getCell(iRow, 1);
  382. const defaultStype = sheet.getDefaultStyle();
  383. if (cell.text().length > 50) {
  384. cell.backColor('#f8d7da');
  385. hint = '章节名称的长度超出范围,请重新输入';
  386. } else {
  387. cell.backColor(defaultStype.backColor);
  388. }
  389. }
  390. if (hint === '') {
  391. $('#hint-6').hide();
  392. } else {
  393. $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
  394. }
  395. }
  396. spread.bind(spreadNS.Events.EditEnding, function (e, info) {
  397. checkSheetData(info.sheet);
  398. });
  399. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  400. checkSheetData(info.sheet);
  401. });
  402. function loadChapterProperty() {
  403. SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
  404. $('#hint-6').hide();
  405. const sheet = spread.getActiveSheet();
  406. const defaultStype = sheet.getDefaultStyle();
  407. sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).backColor(defaultStype.backColor);
  408. }
  409. function setReadOnly(readOnly) {
  410. SpreadJsObj.resetFieldReadOnly(spread.getActiveSheet(), 'name', readOnly);
  411. }
  412. function getNewChapterData() {
  413. const result = [];
  414. const sheet = spread.getActiveSheet();
  415. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  416. const data = {};
  417. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
  418. const col = spreadSetting.cols[iCol];
  419. data[col.field] = sheet.getText(iRow, iCol);
  420. if (col.field === 'name') {
  421. if (data.name.length > 50) {
  422. return null;
  423. }
  424. }
  425. }
  426. result.push(data);
  427. }
  428. return result;
  429. }
  430. return { loadChapterProperty, setReadOnly, getNewChapterData, }
  431. })();
  432. // 标段属性
  433. function loadTenderProperty() {
  434. // 加载属性
  435. loadCommonProperty();
  436. loadCalculateProperty();
  437. precisionObj.loadPrecisonProperty();
  438. dealObj.loadDealProperty();
  439. loadDisplayProperty();
  440. chapterObj.loadChapterProperty();
  441. // 设置只读
  442. setReadOnly('#shuxing', true);
  443. }
  444. loadTenderProperty();
  445. /**
  446. * 属性
  447. */
  448. // 编辑
  449. $('#edit-1').click(() => {
  450. setReadOnly('#v-pills-1', false);
  451. $('#post-1').parent().show();
  452. $('#edit-1').parent().hide();
  453. });
  454. // 取消
  455. $('#cancel-1').click(() => {
  456. setReadOnly('#v-pills-1', true);
  457. loadCommonProperty();
  458. $('#post-1').parent().hide();
  459. $('#edit-1').parent().show();
  460. });
  461. // 提交
  462. $('#post-1').click(() => {
  463. const prop = {
  464. deal_info: {
  465. buildName: $('#build-name').val(),
  466. dealCode: $('#deal-code').val(),
  467. dealName: $('#deal-name').val(),
  468. },
  469. construction_unit: {
  470. build: {
  471. company: $('#build-company').val(),
  472. corporation: $('#build-corporation').val(),
  473. date: $('#build-date').val(),
  474. },
  475. contract1: {
  476. company: $('#contract1-company').val(),
  477. corporation: $('#contract1-corporation').val(),
  478. date: $('#contract1-date').val(),
  479. },
  480. contract2: {
  481. company: $('#contract2-company').val(),
  482. corporation: $('#contract2-corporation').val(),
  483. date: $('#contract2-date').val(),
  484. },
  485. supervision1: {
  486. company: $('#supervision1-company').val(),
  487. corporation: $('#supervision1-corporation').val(),
  488. date: $('#supervision1-date').val(),
  489. },
  490. supervision2: {
  491. company: $('#supervision2-company').val(),
  492. corporation: $('#supervision2-corporation').val(),
  493. date: $('#supervision2-date').val(),
  494. },
  495. },
  496. tech_param: {
  497. loadLevel: _.toNumber($('#loadLevel').val()),
  498. loadLength: _.toNumber($('#length').val()),
  499. startPeg: $('#start-peg').val(),
  500. endPeg: $('#end-peg').val(),
  501. laneCount: _.toNumber($('#lane-count').val()),
  502. dealPeriod: $('#deal-period').val(),
  503. startDate: $('#start-date').val(),
  504. planEndDate: $('#plan-end-date').val(),
  505. }
  506. };
  507. const tenderId = window.location.pathname.split('/')[2];
  508. postData('/tender/' + tenderId + '/save', prop, function (data) {
  509. setReadOnly('#v-pills-1', true);
  510. property.deal_info = data.deal_info;
  511. property.construction_unit = data.construction_unit;
  512. property.tech_param = data.tech_param;
  513. $('#post-1').parent().hide();
  514. $('#edit-1').parent().show();
  515. });
  516. });
  517. /**
  518. * 计算参数
  519. */
  520. // 编辑
  521. $('#edit-2').click(() => {
  522. setReadOnly('#v-pills-2', false);
  523. $('#post-2').parent().show();
  524. $('#edit-2').parent().hide();
  525. });
  526. // 取消
  527. $('#cancel-2').click(() => {
  528. setReadOnly('#v-pills-2', true);
  529. loadCalculateProperty();
  530. $('#post-2').parent().hide();
  531. $('#edit-2').parent().show();
  532. });
  533. // 提交
  534. $('#post-2').click(() => {
  535. const prop = {
  536. decimal: {
  537. up: _.toNumber($('#decimal-up').val()),
  538. tp: _.toNumber($('#decimal-tp').val()),
  539. pay: $('#decimal-pay')[0].checked,
  540. payTp: _.toNumber($('#decimal-pay-tp').val()),
  541. }
  542. };
  543. if (ledgerChecked) {
  544. if (prop.decimal.up < property.decimal.up) {
  545. toastr.warning('台账已审批完成,单价的小数位数,不可小于' + property.decimal.up);
  546. return;
  547. }
  548. if (prop.decimal.tp < property.decimal.tp) {
  549. toastr.warning('台账已审批完成,金额的小数位数,不可小于' + property.decimal.tp);
  550. return;
  551. }
  552. }
  553. if (firstStageChecked) {
  554. if (property.decimal.pay) {
  555. if (!prop.decimal.pay) {
  556. toastr.warning('第一期已审批完成,不可取消合同支付单独设置');
  557. return;
  558. }
  559. if (prop.decimal.payTp < property.decimal.payTp) {
  560. toastr.warning('第一期已审批完成,单独设置的合同支付小数位数,不可小于' + property.decimal.payTp);
  561. return;
  562. }
  563. } else {
  564. if (prop.decimal.pay) {
  565. toastr.warning('第一期已审批完成,合同支付不可单独设置');
  566. return;
  567. }
  568. }
  569. }
  570. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.decimal, property.decimal)) return;
  571. const tenderId = window.location.pathname.split('/')[2];
  572. postData('/tender/' + tenderId + '/save', prop, function (data) {
  573. setReadOnly('#v-pills-2', true);
  574. property.decimal = data.decimal;
  575. $('#post-2').parent().hide();
  576. $('#edit-2').parent().show();
  577. }, null, true);
  578. });
  579. /**
  580. * 清单精度
  581. */
  582. // 编辑
  583. $('#edit-3').click(() => {
  584. precisionObj.setReadOnly(false);
  585. $('#post-3').parent().show();
  586. $('#edit-3').parent().hide();
  587. });
  588. // 取消
  589. $('#cancel-3').click(() => {
  590. precisionObj.setReadOnly(true);
  591. precisionObj.loadPrecisonProperty();
  592. $('#post-3').parent().hide();
  593. $('#edit-3').parent().show();
  594. });
  595. // 提交
  596. $('#post-3').click(() => {
  597. const prop = { precision: precisionObj.getNewPrecisionData() };
  598. if (ledgerChecked && !precisionObj.checkPrecisionMinLimit(prop.precision, property.precision)) return;
  599. const tenderId = window.location.pathname.split('/')[2];
  600. postData('/tender/' + tenderId + '/save', prop, function (data) {
  601. precisionObj.setReadOnly(true);
  602. property.precision = data.precision;
  603. $('#post-3').parent().hide();
  604. $('#edit-3').parent().show();
  605. }, null, true);
  606. });
  607. /**
  608. * 合同参数
  609. */
  610. // 编辑
  611. $('#edit-4').click(() => {
  612. dealObj.setReadOnly(false);
  613. $('#post-4').parent().show();
  614. $('#edit-4').parent().hide();
  615. });
  616. // 取消
  617. $('#cancel-4').click(() => {
  618. dealObj.setReadOnly(true);
  619. dealObj.loadDealProperty();
  620. $('#post-4').parent().hide();
  621. $('#edit-4').parent().show();
  622. });
  623. // 提交
  624. $('#post-4').click(() => {
  625. const prop = { deal_param: dealObj.getNewDealData() };
  626. const tenderId = window.location.pathname.split('/')[2];
  627. postData('/tender/' + tenderId + '/save', prop, function (data) {
  628. dealObj.setReadOnly(true);
  629. property.deal_param = data.deal_param;
  630. $('#post-4').parent().hide();
  631. $('#edit-4').parent().show();
  632. dealObj.loadDealProperty();
  633. });
  634. });
  635. /**
  636. * 显示设置
  637. */
  638. // 编辑
  639. $('#edit-5').click(() => {
  640. setReadOnly('#v-pills-5', false);
  641. $('#post-5').parent().show();
  642. $('#edit-5').parent().hide();
  643. });
  644. // 取消
  645. $('#cancel-5').click(() => {
  646. setReadOnly('#v-pills-5', true);
  647. loadDisplayProperty();
  648. $('#post-5').parent().hide();
  649. $('#edit-5').parent().show();
  650. });
  651. // 提交
  652. $('#post-5').click(() => {
  653. const prop = {
  654. display: {
  655. ledger: { dgnQty: $('#ledger-dgn-qty')[0].checked, clQty: $('#ledger-cl-qty')[0].checked, },
  656. },
  657. };
  658. const tenderId = window.location.pathname.split('/')[2];
  659. postData('/tender/' + tenderId + '/save', prop, function (data) {
  660. setReadOnly('#v-pills-5', true);
  661. property.display = data.display;
  662. $('#post-5').parent().hide();
  663. $('#edit-5').parent().show();
  664. });
  665. });
  666. /**
  667. * 章节设置
  668. */
  669. // 编辑
  670. $('#edit-6').click(() => {
  671. chapterObj.setReadOnly(false);
  672. $('#post-6').parent().show();
  673. $('#edit-6').parent().hide();
  674. });
  675. // 取消
  676. $('#cancel-6').click(() => {
  677. chapterObj.loadChapterProperty();
  678. chapterObj.setReadOnly(true);
  679. $('#hint-6').hide();
  680. $('#post-6').parent().hide();
  681. $('#edit-6').parent().show();
  682. });
  683. // 提交
  684. $('#post-6').click(() => {
  685. const chapter = chapterObj.getNewChapterData();
  686. if (!chapter) { return; }
  687. const tenderId = window.location.pathname.split('/')[2];
  688. postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
  689. chapterObj.setReadOnly(true);
  690. property.chapter = data.chapter;
  691. $('#post-6').parent().hide();
  692. $('#edit-6').parent().show();
  693. });
  694. });
  695. //标段类型选择
  696. $('#tender_type_select').change(function () {
  697. const type = $(this).val() != 0 ? '/?type='+$(this).val() : '';
  698. window.location.href = '/tender' + type;
  699. });
  700. //编辑标段 选择
  701. $('.save-btn').on('click',function () {
  702. $('#saveid').val($(this).attr('tender-id'));
  703. $('#savename').val($(this).attr('tender-name'));
  704. $('#savetype').val($(this).attr('tender-type'));
  705. });
  706. //删除标段 选择
  707. $('.del-btn').on('click',function () {
  708. $('#delid').val($(this).attr('tender-id'));
  709. });
  710. });