tender.js 29 KB

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