tender.js 27 KB

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