123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- /**
- * 标段相关js
- *
- * @author CaiAoLin
- * @date 2018/2/5
- * @version
- */
- // 整理数据
- let tenderData = [];
- try {
- if (tenderList.length <= 0) {
- throw '数据为空';
- }
- for(const tmp of tenderList) {
- const tmpData = {
- value: 7814964.00,
- name: tmp.name,
- };
- tenderData.push(tmpData);
- }
- } catch (error) {
- }
- // 属性
- function loadCommonProperty () {
- // 合同信息
- $('#build-name').val(property.deal_info.buildName);
- $('#deal-code').val(property.deal_info.dealCode);
- $('#deal-name').val(property.deal_info.dealName);
- // 参建单位
- // 建设单位
- $('#build-company').val(property.construction_unit.build.company);
- $('#build-corporation').val(property.construction_unit.build.corporation);
- $('#build-date').val(property.construction_unit.build.date);
- // 承包单位1
- $('#contract1-company').val(property.construction_unit.contract1.company);
- $('#contract1-corporation').val(property.construction_unit.contract1.corporation);
- $('#contract1-date').val(property.construction_unit.contract1.date);
- // 承包单位2
- $('#contract2-company').val(property.construction_unit.contract2.company);
- $('#contract2-corporation').val(property.construction_unit.contract2.corporation);
- $('#contract2-date').val(property.construction_unit.contract2.date);
- // 监理单位1
- $('#supervision1-company').val(property.construction_unit.supervision1.company);
- $('#supervision1-corporation').val(property.construction_unit.supervision1.corporation);
- $('#supervision1-date').val(property.construction_unit.supervision1.date);
- // 监理单位2
- $('#supervision2-company').val(property.construction_unit.supervision2.company);
- $('#supervision2-corporation').val(property.construction_unit.supervision2.corporation);
- $('#supervision2-date').val(property.construction_unit.supervision2.date);
- // 技术参数
- $('#loadLevel').val(property.tech_param.loadLevel);
- $('#length').val(property.tech_param.loadLength);
- $('#start-peg').val(property.tech_param.startPeg);
- $('#end-peg').val(property.tech_param.endPeg);
- $('#lane-count').val(property.tech_param.laneCount);
- $('#deal-period').val(property.tech_param.dealPeriod);
- $('#start-date').val(property.tech_param.startDate);
- $('#plan-end-date').val(property.tech_param.planEndDate);
- }
- // 小数位数
- function loadCalculateProperty () {
- $('#decimal-up').val(property.decimal.up);
- $('#decimal-tp').val(property.decimal.tp);
- $('#decimal-pay')[0].checked = property.decimal.pay;
- $('#decimal-pay-tp').val(property.decimal.payTp);
- }
- // 清单精度
- function loadPrecisionProperty () {
- $('#unit-t').val(property.precision.t.value);
- $('#unit-km').val(property.precision.km.value);
- $('#unit-m').val(property.precision.m.value);
- $('#unit-m2').val(property.precision.m2.value);
- $('#unit-m3').val(property.precision.m3.value);
- $('#unit-kg').val(property.precision.kg.value);
- $('#unit-ge').val(property.precision.ge.value);
- $('#unit-tai').val(property.precision.tai.value);
- $('#unit-tao').val(property.precision.tao.value);
- $('#unit-ke').val(property.precision.ke.value);
- $('#unit-zu').val(property.precision.zu.value);
- $('#unit-xitong').val(property.precision.xitong.value);
- $('#unit-other').val(property.precision.other.value);
- }
- // 合同参数
- function loadDealProperty () {
- $('#contract-price').val(property.deal_param.contractPrice);
- $('#zan-lie-price').val(property.deal_param.zanLiePrice);
- const iDecimal = property.decimal.pay ? property.decimal.payTp : property.decimal.tp;
- $('#c-zl').val(ZhCalc.round(ZhCalc.minus(property.deal_param.contractPrice, property.deal_param.zanLiePrice), iDecimal));
- $('#start-advance').val(property.deal_param.startAdvance);
- $('#material-advance').val(property.deal_param.materialAdvance);
- }
- // 显示设置
- function loadDisplayProperty () {
- $('#ledger-dgn-qty')[0].checked = property.display.ledger.dgnQty;
- $('#ledger-cl-qty')[0].checked = property.display.ledger.clQty;
- }
- // 设置某个div下全部的input、select是否只读
- function setReadOnly(obj, readOnly) {
- if (readOnly) {
- $('input', obj).attr('readonly', '');
- $('select', obj).attr('disabled', '');
- $('input[type=checkbox]', obj).attr('disabled', '');
- } else {
- $('input', obj).removeAttr('readonly');
- $('select', obj).removeAttr('disabled');
- $('input[type=checkbox]', obj).removeAttr('disabled');
- }
- }
- // 获取当前合同支付应该使用的小数位数
- function getDealTpDecimal() {
- const spec = $('#decimal-pay')[0].checked;
- return spec ? _.toNumber($('#decimal-pay-tp').val()) : _.toNumber($('#decimal-tp').val());
- }
- // 四舍五入
- function roundPrice(obj) {
- //const iDecimal = getDealTpDecimal();
- //obj.val(ZhCalc.round(_.toNumber(obj.val()), iDecimal));
- }
- // 计算签约合同价(不含暂列金额)
- function calculateC2() {
- const constract = _.toNumber($('#contract-price').val());
- const zanLie = _.toNumber($('#zan-lie-price').val());
- //const iDecimal = getDealTpDecimal();
- //$('#c-zl').val(ZhCalc.round(constract - zanLie, iDecimal));
- $('#c-zl').val(ZhCalc.minus(constract, zanLie));
- }
- // 根据小数位数,计算全部的合同参数
- function CalculateAllDealParam() {
- roundPrice($('#contract-price'));
- roundPrice($('#zan-lie-price'));
- roundPrice($('#start-advance'));
- roundPrice($('#material-advance'));
- calculateC2();
- }
- // 根据Min Max限制Input输入
- function limitInputMinMax (obj) {
- if (_.toNumber(obj.value) > _.toNumber(obj.max)) {
- obj.value = obj.max;
- }
- if(_.toNumber(obj.value) < _.toNumber(obj.min)) {
- obj.value = obj.min;
- }
- }
- // 根据Maxlength限制input输入
- function limitMaxLength (obj) {
- if (obj.value.length > obj.maxLength) {
- obj.value = obj.value.substr(0, obj.maxLength);
- }
- }
- // 根据正则限制输入
- function limitReg(obj, reg) {
- obj.value = obj.value.replace(reg, '');
- }
- // 小数位数 input 输入限制
- function limitDecimal(obj) {
- limitReg(obj, /[^\d]/g);
- limitMaxLength(obj);
- limitInputMinMax(obj);
- }
- function limitDealParamLength(obj) {
- limitReg(obj, /[^\d\.]/g); // 过滤数字和.
- limitReg(obj, /\.{2,}/g); // 过滤第二个.
- limitInputMinMax(obj);
- }
- function checkNumberValid(obj) {
- const value = _.toNumber(obj.value);
- obj.value = value ? value : '';
- }
- $(document).ready(function() {
- // 章节设置
- const chapterObj = (function () {
- const spreadSetting = {
- cols: [
- {title: '章节', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 100, formatter: '@', readOnly: true},
- {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@', readOnly: true},
- ],
- emptyRows: 0,
- headRows: 1,
- headRowHeight: [40],
- defaultRowHeight: 21,
- };
- const spread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]);
- spread.options.showVerticalScrollbar = false;
- spread.options.showHorizontalScrollbar = false;
- SpreadJsObj.initSheet(spread.getActiveSheet(), spreadSetting);
- function checkSheetData(sheet) {
- let hint = '';
- for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
- const cell = sheet.getCell(iRow, 1);
- const defaultStype = sheet.getDefaultStyle();
- if (cell.text().length > 50) {
- cell.backColor('#f8d7da');
- hint = '章节名称的长度超出范围,请重新输入';
- } else {
- cell.backColor(defaultStype.backColor);
- }
- }
- if (hint === '') {
- $('#hint-6').hide();
- } else {
- $('#hint-6').html('<i class="fa fa-smile-o mr-2"></i>' + hint).show();
- }
- }
- spread.bind(spreadNS.Events.EditEnding, function (e, info) {
- checkSheetData(info.sheet);
- });
- spread.bind(spreadNS.Events.ClipboardPasted, function (e, info) {
- checkSheetData(info.sheet);
- });
- function loadChapterProperty() {
- SpreadJsObj.loadSheetData(spread.getActiveSheet(), SpreadJsObj.DataType.Data, property.chapter);
- $('#hint-6').hide();
- const sheet = spread.getActiveSheet();
- const defaultStype = sheet.getDefaultStyle();
- sheet.getRange(0, 0, sheet.getRowCount(), sheet.getColumnCount()).backColor(defaultStype.backColor);
- }
- function setReadOnly(readOnly) {
- SpreadJsObj.resetFieldReadOnly(spread.getActiveSheet(), 'name', readOnly);
- }
- function getNewChapterData() {
- const result = [];
- const sheet = spread.getActiveSheet();
- for (let iRow = 0; iRow < sheet.getRowCount(); iRow++) {
- const data = {};
- for (let iCol = 0; iCol < sheet.getColumnCount(); iCol++) {
- const col = spreadSetting.cols[iCol];
- data[col.field] = sheet.getText(iRow, iCol);
- if (col.field === 'name') {
- if (data.name.length > 50) {
- return null;
- }
- }
- }
- result.push(data);
- }
- return result;
- }
- return { loadChapterProperty, setReadOnly, getNewChapterData, }
- })();
- // 标段属性
- function loadTenderProperty() {
- // 加载属性
- loadCommonProperty();
- loadCalculateProperty();
- loadPrecisionProperty();
- loadDealProperty();
- loadDisplayProperty();
- chapterObj.loadChapterProperty();
- // 设置只读
- setReadOnly('#shuxing', true);
- }
- loadTenderProperty();
- /**
- * 属性
- */
- // 编辑
- $('#edit-1').click(() => {
- setReadOnly('#v-pills-1', false);
- $('#post-1').parent().show();
- $('#edit-1').parent().hide();
- });
- // 取消
- $('#cancel-1').click(() => {
- setReadOnly('#v-pills-1', true);
- loadCommonProperty();
- $('#post-1').parent().hide();
- $('#edit-1').parent().show();
- });
- // 提交
- $('#post-1').click(() => {
- const prop = {
- deal_info: {
- buildName: $('#build-name').val(),
- dealCode: $('#deal-code').val(),
- dealName: $('#deal-name').val(),
- },
- construction_unit: {
- build: {
- company: $('#build-company').val(),
- corporation: $('#build-corporation').val(),
- date: $('#build-date').val(),
- },
- contract1: {
- company: $('#contract1-company').val(),
- corporation: $('#contract1-corporation').val(),
- date: $('#contract1-date').val(),
- },
- contract2: {
- company: $('#contract2-company').val(),
- corporation: $('#contract2-corporation').val(),
- date: $('#contract2-date').val(),
- },
- supervision1: {
- company: $('#supervision1-company').val(),
- corporation: $('#supervision1-corporation').val(),
- date: $('#supervision1-date').val(),
- },
- supervision2: {
- company: $('#supervision2-company').val(),
- corporation: $('#supervision2-corporation').val(),
- date: $('#supervision2-date').val(),
- },
- },
- tech_param: {
- loadLevel: _.toNumber($('#loadLevel').val()),
- loadLength: _.toNumber($('#length').val()),
- startPeg: $('#start-peg').val(),
- endPeg: $('#end-peg').val(),
- laneCount: _.toNumber($('#lane-count').val()),
- dealPeriod: $('#deal-period').val(),
- startDate: $('#start-date').val(),
- planEndDate: $('#plan-end-date').val(),
- }
- };
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', prop, function (data) {
- setReadOnly('#v-pills-1', true);
- property.deal_info = data.deal_info;
- property.construction_unit = data.construction_unit;
- property.tech_param = data.tech_param;
- $('#post-1').parent().hide();
- $('#edit-1').parent().show();
- });
- });
- /**
- * 计算参数
- */
- // 编辑
- $('#edit-2').click(() => {
- setReadOnly('#v-pills-2', false);
- $('#post-2').parent().show();
- $('#edit-2').parent().hide();
- });
- // 取消
- $('#cancel-2').click(() => {
- setReadOnly('#v-pills-2', true);
- loadCalculateProperty();
- $('#post-2').parent().hide();
- $('#edit-2').parent().show();
- });
- // 提交
- $('#post-2').click(() => {
- const prop = {
- decimal: {
- up: _.toNumber($('#decimal-up').val()),
- tp: _.toNumber($('#decimal-tp').val()),
- pay: $('#decimal-pay')[0].checked,
- payTp: _.toNumber($('#decimal-pay-tp').val()),
- }
- };
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', prop, function (data) {
- setReadOnly('#v-pills-2', true);
- property.decimal = data.decimal;
- $('#post-2').parent().hide();
- $('#edit-2').parent().show();
- });
- });
- /**
- * 清单精度
- */
- // 编辑
- $('#edit-3').click(() => {
- setReadOnly('#v-pills-3', false);
- $('#post-3').parent().show();
- $('#edit-3').parent().hide();
- });
- // 取消
- $('#cancel-3').click(() => {
- setReadOnly('#v-pills-3', true);
- loadPrecisionProperty();
- $('#post-3').parent().hide();
- $('#edit-3').parent().show();
- });
- // 提交
- $('#post-3').click(() => {
- const prop = { precision: JSON.parse(JSON.stringify(property.precision)) };
- prop.precision.t.value = _.toNumber($('#unit-t').val());
- prop.precision.km.value = _.toNumber($('#unit-km').val());
- prop.precision.m.value = _.toNumber($('#unit-m').val());
- prop.precision.m2.value = _.toNumber($('#unit-m2').val());
- prop.precision.m3.value = _.toNumber($('#unit-m3').val());
- prop.precision.kg.value = _.toNumber($('#unit-kg').val());
- prop.precision.ge.value = _.toNumber($('#unit-ge').val());
- prop.precision.tai.value = _.toNumber($('#unit-tai').val());
- prop.precision.tao.value = _.toNumber($('#unit-tao').val());
- prop.precision.ke.value = _.toNumber($('#unit-ke').val());
- prop.precision.zu.value = _.toNumber($('#unit-zu').val());
- prop.precision.xitong.value = _.toNumber($('#unit-xitong').val());
- prop.precision.other.value = _.toNumber($('#unit-other').val());
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', prop, function (data) {
- setReadOnly('#v-pills-3', true);
- property.precision = data.precision;
- $('#post-3').parent().hide();
- $('#edit-3').parent().show();
- });
- });
- /**
- * 合同参数
- */
- // 编辑
- $('#edit-4').click(() => {
- setReadOnly('#v-pills-4', false);
- $('#post-4').parent().show();
- $('#edit-4').parent().hide();
- });
- // 取消
- $('#cancel-4').click(() => {
- setReadOnly('#v-pills-4', true);
- loadDealProperty();
- $('#post-4').parent().hide();
- $('#edit-4').parent().show();
- });
- // 提交
- $('#post-4').click(() => {
- const prop = {
- deal_param: {
- contractPrice: _.toNumber($('#contract-price').val()),
- zanLiePrice: _.toNumber($('#zan-lie-price').val()),
- startAdvance: _.toNumber($('#start-advance').val()),
- materialAdvance: _.toNumber($('#material-advance').val()),
- }
- };
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', prop, function (data) {
- setReadOnly('#v-pills-4', true);
- property.deal_param = data.deal_param;
- $('#post-4').parent().hide();
- $('#edit-4').parent().show();
- });
- });
- /**
- * 显示设置
- */
- // 编辑
- $('#edit-5').click(() => {
- setReadOnly('#v-pills-5', false);
- $('#post-5').parent().show();
- $('#edit-5').parent().hide();
- });
- // 取消
- $('#cancel-5').click(() => {
- setReadOnly('#v-pills-5', true);
- loadDisplayProperty();
- $('#post-5').parent().hide();
- $('#edit-5').parent().show();
- });
- // 提交
- $('#post-5').click(() => {
- const prop = {
- display: {
- ledger: { dgnQty: $('#ledger-dgn-qty')[0].checked, clQty: $('#ledger-cl-qty')[0].checked, },
- },
- };
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', prop, function (data) {
- setReadOnly('#v-pills-5', true);
- property.display = data.display;
- $('#post-5').parent().hide();
- $('#edit-5').parent().show();
- });
- });
- /**
- * 章节设置
- */
- // 编辑
- $('#edit-6').click(() => {
- chapterObj.setReadOnly(false);
- $('#post-6').parent().show();
- $('#edit-6').parent().hide();
- });
- // 取消
- $('#cancel-6').click(() => {
- chapterObj.loadChapterProperty();
- chapterObj.setReadOnly(true);
- $('#hint-6').hide();
- $('#post-6').parent().hide();
- $('#edit-6').parent().show();
- });
- // 提交
- $('#post-6').click(() => {
- const chapter = chapterObj.getNewChapterData();
- if (!chapter) { return; }
- const tenderId = window.location.pathname.split('/')[2];
- postData('/tender/' + tenderId + '/save', { chapter: chapter }, function (data) {
- chapterObj.setReadOnly(true);
- property.chapter = data.chapter;
- $('#post-6').parent().hide();
- $('#edit-6').parent().show();
- });
- });
- //标段类型选择
- $('#tender_type_select').change(function () {
- const type = $(this).val() != 0 ? '/?type='+$(this).val() : '';
- window.location.href = '/tender' + type;
- });
- //编辑标段 选择
- $('.save-btn').on('click',function () {
- $('#saveid').val($(this).attr('tender-id'));
- $('#savename').val($(this).attr('tender-name'));
- $('#savetype').val($(this).attr('tender-type'));
- });
- //删除标段 选择
- $('.del-btn').on('click',function () {
- $('#delid').val($(this).attr('tender-id'));
- });
- });
|