tender.js 29 KB

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