tender.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  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. toast('请输入0-6的整数', 'warning');
  160. sheet.setText(info.row, info.col, '0');
  161. } else if (value > 6) {
  162. toast('请输入0-6的整数', 'warning');
  163. sheet.setText(info.row, info.col, '6');
  164. } else if (value < 0) {
  165. toast('请输入0-6的整数', 'warning');
  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. toast('请输入0-6的整数', 'warning');
  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. return {loadPrecisonProperty, setReadOnly, getNewPrecisionData, };
  244. })();
  245. // 合同参数
  246. const dealObj = (function () {
  247. const spread = SpreadJsObj.createNewSpread($('#param-spread')[0]);
  248. spread.options.showVerticalScrollbar = false;
  249. spread.options.showHorizontalScrollbar = false;
  250. const sheet = spread.getActiveSheet();
  251. SpreadJsObj.protectedSheet(sheet);
  252. SpreadJsObj.massOperationSheet(sheet, function () {
  253. sheet.options.rowHeaderVisible = false;
  254. sheet.options.colHeaderVisible = false;
  255. sheet.defaults.rowHeight = 35;
  256. sheet.setColumnCount(3);
  257. sheet.setRowCount(6);
  258. sheet.setColumnWidth(0, 1);
  259. sheet.setColumnWidth(1, 200);
  260. sheet.setColumnWidth(2, 200);
  261. sheet.setRowHeight(0, 1);
  262. sheet.getRange(1, 1, 5, 1).vAlign(1).backColor('#e4e7ea').locked(true);
  263. sheet.getRange(1, 2, 5, 1).vAlign(1).hAlign(2).locked(true);
  264. sheet.setText(1, 1, '签约合同价');
  265. sheet.setText(2, 1, '暂列金额');
  266. sheet.setText(3, 1, '签约合同价(不含暂列金)');
  267. sheet.setText(4, 1, '签约开工预付款');
  268. sheet.setText(5, 1, '签约材料预付款');
  269. const lineBorder = new spreadNS.LineBorder('#6a696e', spreadNS.LineStyle.thin);
  270. sheet.getRange(0, 0, 6, 3).setBorder(lineBorder, {all: true});
  271. sheet.getRange(0, 0, 6, 3).formatter('@');
  272. sheet.setSelection(1, 2, 1, 1);
  273. });
  274. function calcHtjMinusZlj() {
  275. const htj = _.toNumber(sheet.getText(1, 2));
  276. const zlj = _.toNumber(sheet.getText(2, 2));
  277. sheet.setValue(3, 2, accSub(zlj, htj));
  278. }
  279. spread.bind(spreadNS.Events.EditEnded, function (e, info) {
  280. const value = _.toNumber(info.editingText);
  281. if (_.isNaN(value)) {
  282. toast('请输入不超过万亿的数字', 'warning');
  283. info.sheet.setText(info.row, info.col, '0');
  284. } else if (value > Math.pow(10, 13)) {
  285. toast('请输入不超过万亿的数字', 'warning');
  286. info.sheet.setText(info.row, info.col, '0');
  287. }
  288. if (info.row === 1 || info.row === 2) {
  289. calcHtjMinusZlj();
  290. }
  291. });
  292. SpreadJsObj.addDeleteBind(spread, function (sheet) {
  293. const sel = sheet.getSelections()[0];
  294. let calc = false;
  295. if (sel) {
  296. for (let iRow = sel.row, iRowLength = sel.row + sel.rowCount; iRow < iRowLength; iRow++) {
  297. if (iRow === 3) continue;
  298. for (let iCol = sel.col, iColLength = sel.col + sel.colCount; iCol < iColLength; iCol++) {
  299. if (iCol !== 2) continue;
  300. sheet.setText(iRow, iCol, '0');
  301. if (iRow === 1 || iRow === 2) calc = true;
  302. }
  303. }
  304. }
  305. if (calc) calcHtjMinusZlj();
  306. });
  307. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  308. let bHint = false;
  309. for (let iRow = 0; iRow < info.cellRange.rowCount; iRow++) {
  310. const curRow = info.cellRange.row + iRow;
  311. for (let iCol = 0; iCol < info.cellRange.colCount; iCol++) {
  312. const curCol = info.cellRange.col + iCol;
  313. const value = _.toNumber(info.sheet.getText(curRow, curCol));
  314. if (_.isNaN(value) || value > Math.pow(10, 13)) {
  315. bHint = true;
  316. info.sheet.setText(curRow, curCol, '0');
  317. }
  318. }
  319. }
  320. if (bHint) {
  321. toast('请输入不超过万亿的数字', 'warning');
  322. }
  323. calcHtjMinusZlj();
  324. });
  325. function loadDealProperty() {
  326. $('#hint-4').hide();
  327. sheet.setValue(1, 2, property.deal_param.contractPrice);
  328. sheet.setValue(2, 2, property.deal_param.zanLiePrice);
  329. sheet.setValue(3, 2, accSub(property.deal_param.zanLiePrice, property.deal_param.contractPrice));
  330. sheet.setValue(4, 2, property.deal_param.startAdvance);
  331. sheet.setValue(5, 2, property.deal_param.materialAdvance);
  332. }
  333. function setReadOnly (readOnly) {
  334. sheet.getCell(1, 2).locked(readOnly);
  335. sheet.getCell(2, 2).locked(readOnly);
  336. sheet.getCell(4, 2).locked(readOnly);
  337. sheet.getCell(5, 2).locked(readOnly);
  338. }
  339. function getNewDealData () {
  340. const result = {};
  341. result.contractPrice = _.toNumber(sheet.getText(1, 2));
  342. result.zanLiePrice = _.toNumber(sheet.getText(2, 2));
  343. result.startAdvance = _.toNumber(sheet.getText(4, 2));
  344. result.materialAdvance = _.toNumber(sheet.getText(5, 2));
  345. return result;
  346. }
  347. return { loadDealProperty, setReadOnly, getNewDealData, };
  348. })();
  349. // 章节设置
  350. const chapterObj = (function () {
  351. const spreadSetting = {
  352. cols: [
  353. {title: '章节', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: true},
  354. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
  355. ],
  356. emptyRows: 0,
  357. headRows: 1,
  358. headRowHeight: [40],
  359. defaultRowHeight: 21,
  360. };
  361. const spread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]);
  362. spread.options.showVerticalScrollbar = false;
  363. spread.options.showHorizontalScrollbar = false;
  364. SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
  365. function checkSheetData(sheet) {
  366. let hint = '';
  367. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  368. const cell = sheet.getCell(iRow, 1);
  369. const defaultStype = sheet.getDefaultStyle();
  370. if (cell.text().length > 50) {
  371. cell.backColor('#f8d7da');
  372. hint = '章节名称的长度超出范围,请重新输入';
  373. } else {
  374. cell.backColor(defaultStype.backColor);
  375. }
  376. }
  377. if (hint === '') {
  378. $('#hint-6').hide();
  379. } else {
  380. $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
  381. }
  382. }
  383. spread.bind(spreadNS.Events.EditEnding, function (e, info) {
  384. checkSheetData(info.sheet);
  385. });
  386. spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
  387. checkSheetData(info.sheet);
  388. });
  389. function loadChapterProperty() {
  390. SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
  391. $('#hint-6').hide();
  392. const sheet = spread.getActiveSheet();
  393. const defaultStype = sheet.getDefaultStyle();
  394. sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).backColor(defaultStype.backColor);
  395. }
  396. function setReadOnly(readOnly) {
  397. SpreadJsObj.resetFieldReadOnly(spread.getActiveSheet(), 'name', readOnly);
  398. }
  399. function getNewChapterData() {
  400. const result = [];
  401. const sheet = spread.getActiveSheet();
  402. for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
  403. const data = {};
  404. for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
  405. const col = spreadSetting.cols[iCol];
  406. data[col.field] = sheet.getText(iRow, iCol);
  407. if (col.field === 'name') {
  408. if (data.name.length > 50) {
  409. return null;
  410. }
  411. }
  412. }
  413. result.push(data);
  414. }
  415. return result;
  416. }
  417. return { loadChapterProperty, setReadOnly, getNewChapterData, }
  418. })();
  419. // 标段属性
  420. function loadTenderProperty() {
  421. // 加载属性
  422. loadCommonProperty();
  423. loadCalculateProperty();
  424. precisionObj.loadPrecisonProperty();
  425. dealObj.loadDealProperty();
  426. loadDisplayProperty();
  427. chapterObj.loadChapterProperty();
  428. // 设置只读
  429. setReadOnly('#shuxing', true);
  430. }
  431. loadTenderProperty();
  432. /**
  433. * 属性
  434. */
  435. // 编辑
  436. $('#edit-1').click(() => {
  437. setReadOnly('#v-pills-1', false);
  438. $('#post-1').parent().show();
  439. $('#edit-1').parent().hide();
  440. });
  441. // 取消
  442. $('#cancel-1').click(() => {
  443. setReadOnly('#v-pills-1', true);
  444. loadCommonProperty();
  445. $('#post-1').parent().hide();
  446. $('#edit-1').parent().show();
  447. });
  448. // 提交
  449. $('#post-1').click(() => {
  450. const prop = {
  451. deal_info: {
  452. buildName: $('#build-name').val(),
  453. dealCode: $('#deal-code').val(),
  454. dealName: $('#deal-name').val(),
  455. },
  456. construction_unit: {
  457. build: {
  458. company: $('#build-company').val(),
  459. corporation: $('#build-corporation').val(),
  460. date: $('#build-date').val(),
  461. },
  462. contract1: {
  463. company: $('#contract1-company').val(),
  464. corporation: $('#contract1-corporation').val(),
  465. date: $('#contract1-date').val(),
  466. },
  467. contract2: {
  468. company: $('#contract2-company').val(),
  469. corporation: $('#contract2-corporation').val(),
  470. date: $('#contract2-date').val(),
  471. },
  472. supervision1: {
  473. company: $('#supervision1-company').val(),
  474. corporation: $('#supervision1-corporation').val(),
  475. date: $('#supervision1-date').val(),
  476. },
  477. supervision2: {
  478. company: $('#supervision2-company').val(),
  479. corporation: $('#supervision2-corporation').val(),
  480. date: $('#supervision2-date').val(),
  481. },
  482. },
  483. tech_param: {
  484. loadLevel: _.toNumber($('#loadLevel').val()),
  485. loadLength: _.toNumber($('#length').val()),
  486. startPeg: $('#start-peg').val(),
  487. endPeg: $('#end-peg').val(),
  488. laneCount: _.toNumber($('#lane-count').val()),
  489. dealPeriod: $('#deal-period').val(),
  490. startDate: $('#start-date').val(),
  491. planEndDate: $('#plan-end-date').val(),
  492. }
  493. };
  494. const tenderId = window.location.pathname.split('/')[2];
  495. postData('/tender/' + tenderId + '/save', prop, function (data) {
  496. setReadOnly('#v-pills-1', true);
  497. property.deal_info = data.deal_info;
  498. property.construction_unit = data.construction_unit;
  499. property.tech_param = data.tech_param;
  500. $('#post-1').parent().hide();
  501. $('#edit-1').parent().show();
  502. });
  503. });
  504. /**
  505. * 计算参数
  506. */
  507. // 编辑
  508. $('#edit-2').click(() => {
  509. setReadOnly('#v-pills-2', false);
  510. $('#post-2').parent().show();
  511. $('#edit-2').parent().hide();
  512. });
  513. // 取消
  514. $('#cancel-2').click(() => {
  515. setReadOnly('#v-pills-2', true);
  516. loadCalculateProperty();
  517. $('#post-2').parent().hide();
  518. $('#edit-2').parent().show();
  519. });
  520. // 提交
  521. $('#post-2').click(() => {
  522. const prop = {
  523. decimal: {
  524. up: _.toNumber($('#decimal-up').val()),
  525. tp: _.toNumber($('#decimal-tp').val()),
  526. pay: $('#decimal-pay')[0].checked,
  527. payTp: _.toNumber($('#decimal-pay-tp').val()),
  528. }
  529. };
  530. const tenderId = window.location.pathname.split('/')[2];
  531. postData('/tender/' + tenderId + '/save', prop, function (data) {
  532. setReadOnly('#v-pills-2', true);
  533. property.decimal = data.decimal;
  534. $('#post-2').parent().hide();
  535. $('#edit-2').parent().show();
  536. });
  537. });
  538. /**
  539. * 清单精度
  540. */
  541. // 编辑
  542. $('#edit-3').click(() => {
  543. precisionObj.setReadOnly(false);
  544. $('#post-3').parent().show();
  545. $('#edit-3').parent().hide();
  546. });
  547. // 取消
  548. $('#cancel-3').click(() => {
  549. precisionObj.setReadOnly(true);
  550. precisionObj.loadPrecisonProperty();
  551. $('#post-3').parent().hide();
  552. $('#edit-3').parent().show();
  553. });
  554. // 提交
  555. $('#post-3').click(() => {
  556. const prop = { precision: precisionObj.getNewPrecisionData() };
  557. const tenderId = window.location.pathname.split('/')[2];
  558. postData('/tender/' + tenderId + '/save', prop, function (data) {
  559. precisionObj.setReadOnly(true);
  560. property.precision = data.precision;
  561. $('#post-3').parent().hide();
  562. $('#edit-3').parent().show();
  563. });
  564. });
  565. /**
  566. * 合同参数
  567. */
  568. // 编辑
  569. $('#edit-4').click(() => {
  570. dealObj.setReadOnly(false);
  571. $('#post-4').parent().show();
  572. $('#edit-4').parent().hide();
  573. });
  574. // 取消
  575. $('#cancel-4').click(() => {
  576. dealObj.setReadOnly(true);
  577. dealObj.loadDealProperty();
  578. $('#post-4').parent().hide();
  579. $('#edit-4').parent().show();
  580. });
  581. // 提交
  582. $('#post-4').click(() => {
  583. const prop = { deal_param: dealObj.getNewDealData() };
  584. const tenderId = window.location.pathname.split('/')[2];
  585. postData('/tender/' + tenderId + '/save', prop, function (data) {
  586. dealObj.setReadOnly(true);
  587. property.deal_param = data.deal_param;
  588. $('#post-4').parent().hide();
  589. $('#edit-4').parent().show();
  590. dealObj.loadDealProperty();
  591. });
  592. });
  593. /**
  594. * 显示设置
  595. */
  596. // 编辑
  597. $('#edit-5').click(() => {
  598. setReadOnly('#v-pills-5', false);
  599. $('#post-5').parent().show();
  600. $('#edit-5').parent().hide();
  601. });
  602. // 取消
  603. $('#cancel-5').click(() => {
  604. setReadOnly('#v-pills-5', true);
  605. loadDisplayProperty();
  606. $('#post-5').parent().hide();
  607. $('#edit-5').parent().show();
  608. });
  609. // 提交
  610. $('#post-5').click(() => {
  611. const prop = {
  612. display: {
  613. ledger: { dgnQty: $('#ledger-dgn-qty')[0].checked, clQty: $('#ledger-cl-qty')[0].checked, },
  614. },
  615. };
  616. const tenderId = window.location.pathname.split('/')[2];
  617. postData('/tender/' + tenderId + '/save', prop, function (data) {
  618. setReadOnly('#v-pills-5', true);
  619. property.display = data.display;
  620. $('#post-5').parent().hide();
  621. $('#edit-5').parent().show();
  622. });
  623. });
  624. /**
  625. * 章节设置
  626. */
  627. // 编辑
  628. $('#edit-6').click(() => {
  629. chapterObj.setReadOnly(false);
  630. $('#post-6').parent().show();
  631. $('#edit-6').parent().hide();
  632. });
  633. // 取消
  634. $('#cancel-6').click(() => {
  635. chapterObj.loadChapterProperty();
  636. chapterObj.setReadOnly(true);
  637. $('#hint-6').hide();
  638. $('#post-6').parent().hide();
  639. $('#edit-6').parent().show();
  640. });
  641. // 提交
  642. $('#post-6').click(() => {
  643. const chapter = chapterObj.getNewChapterData();
  644. if (!chapter) { return; }
  645. const tenderId = window.location.pathname.split('/')[2];
  646. postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
  647. chapterObj.setReadOnly(true);
  648. property.chapter = data.chapter;
  649. $('#post-6').parent().hide();
  650. $('#edit-6').parent().show();
  651. });
  652. });
  653. //标段类型选择
  654. $('#tender_type_select').change(function () {
  655. const type = $(this).val() != 0 ? '/?type='+$(this).val() : '';
  656. window.location.href = '/tender' + type;
  657. });
  658. //编辑标段 选择
  659. $('.save-btn').on('click',function () {
  660. $('#saveid').val($(this).attr('tender-id'));
  661. $('#savename').val($(this).attr('tender-name'));
  662. $('#savetype').val($(this).attr('tender-type'));
  663. });
  664. //删除标段 选择
  665. $('.del-btn').on('click',function () {
  666. $('#delid').val($(this).attr('tender-id'));
  667. });
  668. });