| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163 | 
							- 'use strict';
 
- /**
 
-  * 材料调差 - 调差工料
 
-  *
 
-  * @author Mai
 
-  * @date 2019/1/16
 
-  * @version
 
-  */
 
- function loadUpdateMaterials(newMaterial, fields) {
 
-     const newMaterials = newMaterial instanceof Array ? newMaterial : [newMaterial];
 
-     for (const nm of newMaterials) {
 
-         const om = _.find(materialBillsData, {id: nm.id});
 
-         for (const prop in nm) {
 
-             if (!fields || fields.indexOf(prop) >= 0) {
 
-                 om[prop] = nm[prop];
 
-             }
 
-         }
 
-     }
 
- }
 
- function DatePickerCellType() {
 
- }
 
- DatePickerCellType.prototype = new GC.Spread.Sheets.CellTypes.Base();
 
- DatePickerCellType.prototype.createEditorElement = function () {
 
-     //Create input presenter.
 
-     var input = document.createElement("input");
 
-     return input;
 
- };
 
- DatePickerCellType.prototype.activateEditor = function (editorContext, cellStyle, cellRect) {
 
-     //Initialize input editor.
 
-     if (editorContext) {
 
-         const $editor = $(editorContext);
 
-         GC.Spread.Sheets.CellTypes.Base.prototype.activateEditor.apply(this, arguments);
 
-         $editor.datepicker({});
 
-         $editor.css("position", "absolute");
 
-         $editor.attr("gcUIElement", "gcEditingInput");
 
-         $(".ui-datepicker").attr("gcUIElement", "gcEditingInput");
 
-     }
 
- }
 
- DatePickerCellType.prototype.deactivateEditor = function (editorContext) {
 
-     //Remove input editor when end editor status.
 
-     if (editorContext) {
 
-         var element = editorContext;
 
-         // $(element).datepicker().data('datepicker').hide();
 
-         // $(element).datepicker().data('datepicker').destroy();
 
-         $(element).datepicker("hide");
 
-         $(element).datepicker("destroy");
 
-     }
 
-     GC.Spread.Sheets.CellTypes.Base.prototype.deactivateEditor.apply(this, arguments)
 
- };
 
- DatePickerCellType.prototype.setEditorValue = function (editor, value) {
 
-     //Sync value from Cell value to editor value.
 
-     // console.log($(editor), value);
 
-     $(editor).datepicker("setDate", value);
 
-     // $(editor).datepicker().data('datepicker').selectDate(value ? new Date(value) : new Date());
 
- };
 
- DatePickerCellType.prototype.getEditorValue = function (editor, context) {
 
-     // console.log($(editor).datepicker().data('datepicker'), context);
 
-     //Sync value from editor value to cell value.
 
-     // console.log($(editor).datepicker("getDate"));
 
-     // return $(editor).datepicker("getDate");
 
-     return $(editor).val();
 
- };
 
- DatePickerCellType.prototype.updateEditor = function (editorContext, cellStyle, cellRect) {
 
-     if (editorContext) {
 
-         const $editor = $(editorContext);
 
-         $editor.css("width", cellRect.width - 1);
 
-         $editor.css("height", cellRect.height - 3);
 
-     }
 
- };
 
- function resetTpTable() {
 
-     const rate = $('#changeRate').val();
 
-     const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
 
-     const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
 
-     $('#tp_set').find('td').eq(1).text(ZhCalc.round(m_tp, 2));
 
-     $('#tp_set').find('td').eq(2).text(ZhCalc.round(ZhCalc.add(pre_tp, m_tp), 2));
 
-     $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
 
-     $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
 
- }
 
- function getPasteHint (str, row = '') {
 
-     let returnObj = str;
 
-     if (row) {
 
-         returnObj.msg = '工料第' + (row+1) + '行' + str.msg;
 
-     }
 
-     return returnObj;
 
- }
 
- const is_numeric = (value) => {
 
-     if (typeof(value) === 'object') {
 
-         return false;
 
-     } else {
 
-         return !Number.isNaN(Number(value)) && value.toString().trim() !== '';
 
-     }
 
- };
 
- $(document).ready(() => {
 
-     autoFlashHeight();
 
-     const materialSpread = SpreadJsObj.createNewSpread($('#material-spread')[0]);
 
-     const materialSpreadSetting = {
 
-         cols: [
 
-             {title: '调差类型', colSpan: '1', rowSpan: '2', field: 't_type', hAlign: 1, width: 80, formatter: '@', readOnly: 'readOnly.isUsed', cellType: 'customizeCombo', comboItems: materialType.t_type, cellTypeKey: 1},
 
-             {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.isUsed'},
 
-             {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '规格', colSpan: '1', rowSpan: '2', field: 'spec', hAlign: 0, width: 180, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '工料分类', colSpan: '1', rowSpan: '2', field: 'm_type', hAlign: 1, width: 60, readOnly: 'readOnly.isEdit', cellType: 'customizeCombo', comboItems: materialType.m_type, cellTypeKey: 2},
 
-             {title: '本期应耗数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 100, type: 'Number', readOnly: true},
 
-             {title: '基准价', colSpan: '1', rowSpan: '2', field: 'basic_price', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.isEdit'},
 
-             {title: '基准时间', colSpan: '1', rowSpan: '2', field: 'basic_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.isEdit'},
 
-             {title: '本期信息价|单价', colSpan: '3|1', rowSpan: '1|1', field: 'msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: 'readOnly.msg_tp'},
 
-             {title: '|时间', colSpan: '|1', rowSpan: '|1', field: 'msg_times', hAlign: 0, width: 80, formatter: '@', readOnly: 'readOnly.remark'},
 
-             {title: '|价差', colSpan: '|1', rowSpan: '|1', field: 'msg_spread', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue: 'getValue.msg_spread'},
 
-             {title: '本期材料调差|上涨幅度(%)', colSpan: '4|1', rowSpan: '1|1', field: 'm_up_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
 
-             {title: '|下跌幅度(%)', colSpan: '|1', rowSpan: '|1', field: 'm_down_risk', hAlign: 2, width: 100, type: 'Number', readOnly: 'readOnly.isEdit'},
 
-             {title: '|有效价差', colSpan: '|1', rowSpan: '|1', field: 'm_spread', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.m_spread'},
 
-             {title: '|调差金额', colSpan: '|1', rowSpan: '|1', field: 'm_tp', hAlign: 2, width: 80, type: 'Number', readOnly: true, getValue: 'getValue.m_tp'},
 
-             {title: '截止上期调差金额', colSpan: '1', rowSpan: '2', field: 'pre_tp', hAlign: 2, width: 120, type: 'Number', readOnly: true},
 
-             {title: '备注', colSpan: '1', rowSpan: '2', field: 'remark', hAlign: 0, width: 60, formatter: '@', readOnly: 'readOnly.remark'},
 
-             {title: '是否汇总', colSpan: '1', rowSpan: '2', field: 'is_summary', hAlign: 1, width: 60, cellType: 'checkbox', readOnly: 'readOnly.isEdit'},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         readOnly: readOnly,
 
-     };
 
-     const spCol = _.find(materialSpreadSetting.cols, {field: 'quantity'});
 
-     spCol.readOnly = true;
 
-     spCol.cellType = 'activeImageBtn';
 
-     spCol.normalImg = '#ellipsis-icon';
 
-     spCol.indent = 5;
 
-     spCol.showImage = function (data) {
 
-         // return !readOnly && data.t_type === 2 && data.mid === materialID;
 
-         return data.t_type === 2;
 
-     };
 
-     materialSpreadSetting.imageClick = function (data) {
 
-         if (data.t_type === 2) {
 
-             $('#bcyy').modal('show');
 
-             $('#materialbillsId').val(data.id);
 
-             $('#expr').val(data.expr);
 
-             if (!readOnly) {
 
-                 $('#expr').attr('readOnly', false);
 
-                 $('#expr_btn').show();
 
-                 $('#expr_select').show();
 
-             } else {
 
-                 $('#expr').attr('readOnly', true);
 
-                 $('#expr_btn').hide();
 
-                 $('#expr_select').hide();
 
-             }
 
-         }
 
-     };
 
-     const materialBase = {
 
-         isUsed: function (data) {
 
-             if (data.t_type === 2) {
 
-                 return data.mid === materialID;
 
-             } else {
 
-                 const mlInfo = _.find(materialListData, { mb_id: data.id });
 
-                 return data.mid === materialID && mlInfo === undefined;
 
-             }
 
-         },
 
-         isEdit: function (data) {
 
-             // if (data.t_type === 2) {
 
-             //     return data.mid === materialID;
 
-             // } else {
 
-             //     const mlInfo = _.find(materialListData, { mb_id: data.id });
 
-             //     return data.mid === materialID && mlInfo === undefined;
 
-             // }
 
-             return data.mid === materialID;
 
-         },
 
-         // isStage: function (data) {
 
-         //     return data.mid === materialID;
 
-         // }
 
-     }
 
-     const materialCol = {
 
-         getValue: {
 
-             msg_spread: function (data) {
 
-                 return ZhCalc.round(ZhCalc.sub(data.msg_tp, data.basic_price), 3);
 
-             },
 
-             m_spread : function (data) {
 
-                 const msg_spread = materialCol.getValue.msg_spread(data);
 
-                 const cor = msg_spread >= 0 ? ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_up_risk, 100)) : ZhCalc.mul(data.basic_price, ZhCalc.div(data.m_down_risk, 100));
 
-                 return Math.abs(msg_spread) > Math.abs(cor) ? (msg_spread > 0 ? ZhCalc.round(ZhCalc.sub(msg_spread, cor), 3) : ZhCalc.round(ZhCalc.add(msg_spread, cor), 3)) : 0;
 
-             },
 
-             m_tp: function (data) {
 
-                 return ZhCalc.round(ZhCalc.mul(materialCol.getValue.m_spread(data), data.quantity), 2);
 
-             }
 
-         },
 
-         readOnly: {
 
-             isEdit: function (data) {
 
-                 return !(!readOnly && materialBase.isEdit(data));
 
-             },
 
-             isUsed: function (data) {
 
-                 return !(!readOnly && materialBase.isUsed(data));
 
-             },
 
-             remark: function () {
 
-                 return readOnly;
 
-             },
 
-             msg_tp: function () {
 
-                 return !(!readOnly && months.length === 0);
 
-             }
 
-         },
 
-     };
 
-     SpreadJsObj.initSpreadSettingEvents(materialSpreadSetting, materialCol);
 
-     SpreadJsObj.initSheet(materialSpread.getActiveSheet(), materialSpreadSetting);
 
-     SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-     const materialSpreadObj = {
 
-         refreshActn: function (rowCount = 1) {
 
-             const setObjEnable = function (obj, enable) {
 
-                 if (enable) {
 
-                     obj.removeClass('disabled');
 
-                 } else {
 
-                     obj.addClass('disabled');
 
-                 }
 
-             };
 
-             const sheet = materialSpread.getActiveSheet();
 
-             const select = SpreadJsObj.getSelectObject(sheet);
 
-             // 还需判断是否已被调差清单调用
 
-             setObjEnable($('#del'), !readOnly && select && materialBase.isUsed(select) && rowCount === 1);
 
-         },
 
-         add: function () {
 
-             const sheet = materialSpread.getActiveSheet();
 
-             postData(window.location.pathname + '/save', {type: 'add'}, function (result) {
 
-                 if (result) {
 
-                     materialBillsData.push(result);
 
-                     // sheet.addRows(materialBillsData.length - 1, 1);
 
-                     // SpreadJsObj.reLoadRowData(sheet, materialBillsData.length - 1);
 
-                     SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                     sheet.setSelection(materialBillsData.length - 1, 0, 1, 1);
 
-                     materialSpreadObj.refreshActn();
 
-                     // 月信息价需要同时添加空白的list
 
-                     if (months.length > 0) {
 
-                         const one_month ={ mb_id: result.id, code: '', name: null, unit: null, };
 
-                         for (const m of months) {
 
-                             one_month[m] = null;
 
-                         }
 
-                         monthsList.push(one_month);
 
-                         materialMonthSpread.getActiveSheet().addRows(monthsList.length - 1, 1);
 
-                         SpreadJsObj.reLoadRowData(materialMonthSpread.getActiveSheet(), monthsList.length - 1);
 
-                     }
 
-                 }
 
-             });
 
-         },
 
-         del: function () {
 
-             const sheet = materialSpread.getActiveSheet();
 
-             const select = SpreadJsObj.getSelectObject(sheet);
 
-             postData(window.location.pathname + '/save', {type: 'del', id: select.id}, function (result) {
 
-                 m_tp = result.m_tp;
 
-                 resetTpTable();
 
-                 const index = materialBillsData.indexOf(select);
 
-                 materialBillsData.splice(index, 1);
 
-                 sheet.deleteRows(index, 1);
 
-                 // SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 
-                 const sel = sheet.getSelections();
 
-                 sheet.setSelection(index > 0 ? index - 1 : 0, sel.length > 0 ? sel[0].col : 0, 1, 1);
 
-                 materialSpreadObj.refreshActn();
 
-                 // 月信息价需要同时删除
 
-                 if (months.length > 0) {
 
-                     monthsList.splice(index, 1);
 
-                     materialMonthSpread.getActiveSheet().deleteRows(index, 1);
 
-                     // SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
 
-                 }
 
-             });
 
-         },
 
-         selectionChanged: function (e, info) {
 
-             const sel = info.sheet.getSelections()[0];
 
-             const col = info.sheet.zh_setting.cols[sel.col];
 
-             materialSpreadObj.refreshActn(sel.rowCount);
 
-             const data = SpreadJsObj.getSelectObject(info.sheet);
 
-             materialSpreadObj.setReadOnly(true);
 
-         },
 
-         editEnded: function (e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (col.field === 'is_summary') {
 
-                     return;
 
-                 }
 
-                 // 未改变值则不提交
 
-                 const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
 
-                 const orgValue = select[col.field];
 
-                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 // 判断部分值是否输入的是数字判断和数据计算
 
-                 if (col.field === 'basic_price') {
 
-                     if (isNaN(validText)) {
 
-                         toastr.error('不能输入其它非数字类型字符');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     const num = parseFloat(validText);
 
-                     if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
 
-                         toastr.error('请输入大于0并且小于3位小数的浮点数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-                 if (col.field === 'msg_tp') {
 
-                     if (isNaN(validText)) {
 
-                         toastr.error('不能输入其它非数字类型字符');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     const num = parseFloat(validText);
 
-                     if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
 
-                         toastr.error('请输入大于0并且小于3位小数的浮点数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-                 if (col.field === 'm_up_risk') {
 
-                     // 只能输入正整数
 
-                     if (isNaN(validText)) {
 
-                         toastr.error('不能输入其它非数字类型字符');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     const num = parseFloat(validText);
 
-                     if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
 
-                         toastr.error('只能输入0-100的正整数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-                 if (col.field === 'm_down_risk') {
 
-                     // 只能输入正整数
 
-                     if (isNaN(validText)) {
 
-                         toastr.error('不能输入其它非数字类型字符');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                     const num = parseFloat(validText);
 
-                     if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
 
-                         toastr.error('只能输入0-100的正整数');
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                         return;
 
-                     }
 
-                 }
 
-                 if (col.field === 't_type') {
 
-                     if (validText === 1) {
 
-                         select.quantity = null;
 
-                         select.expr = null;
 
-                         select.m_tp = null;
 
-                     }
 
-                 }
 
-                 select[col.field] = validText;
 
-                 select.msg_spread = materialCol.getValue.msg_spread(select);
 
-                 select.m_spread = materialCol.getValue.m_spread(select);
 
-                 select.m_tp = materialCol.getValue.m_tp(select);
 
-                 // console.log(select);
 
-                 // 更新至服务器
 
-                 postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
 
-                     m_tp = result.m_tp;
 
-                     resetTpTable();
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     // 判断如果是更改了编号,名称,单位,月信息价需要跟着改变值
 
-                     if (months.length > 0 && (col.field === 'code' || col.field === 'name' || col.field === 'unit')) {
 
-                         monthsList[info.row][col.field] = validText;
 
-                         SpreadJsObj.reLoadRowData(materialMonthSpread.getActiveSheet(), info.row);
 
-                     }
 
-                 }, function () {
 
-                     select[col.field] = orgValue;
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 });
 
-             }
 
-         },
 
-         buttonClicked: function (e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 if (materialCol.readOnly.isEdit(select)) {
 
-                     return;
 
-                 }
 
-                 if (col.field === 'is_summary') {
 
-                     if (info.sheet.isEditing()) {
 
-                         info.sheet.endEdit(true);
 
-                     }
 
-                     select.is_summary = info.sheet.getValue(info.row, info.col) ? 1 : 0;
 
-                     // 更新至服务器
 
-                     postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
 
-                         m_tp = result.m_tp;
 
-                         resetTpTable();
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     }, function () {
 
-                         select.is_summary = info.sheet.getValue(info.row, info.col) ? 0 : 1;
 
-                         SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     });
 
-                 }
 
-             }
 
-         },
 
-         deletePress: function (sheet) {
 
-             return;
 
-         },
 
-         clipboardPasted(e, info) {
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 codeEmpty: {type: 'error', msg: '请先输入编号,并且不超过15个字符'},
 
-                 codeUsed: {type: 'error', msg: '该编号已存在,请重新输入。'},
 
-                 codeError: {type: 'error', msg: '编号为纯数字时,不能为小数'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 riskCan: {type: 'error', msg: '只能粘贴0-100的正整数'},
 
-                 numberCan: {type: 'error', msg: '请粘贴大于0并且小于3位小数的浮点数'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 // SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
 
-                 SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 
-                 return;
 
-             }
 
-             if (sortData.length > 0 && range.col + range.colCount > 18) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 SpreadJsObj.reLoadSheetHeader(materialSpread.getActiveSheet());
 
-                 SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 
-                 return;
 
-             }
 
-             const data = [];
 
-             // const rowData = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 // const materialData = JSON.parse(JSON.stringify(sortData[curRow]));
 
-                 const materialData = { id: sortData[curRow].id };
 
-                 const hintRow = range.rowCount > 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     const colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     if (colSetting.field === 'code' && (validText === '' || validText.length > 15)) {
 
-                         toastMessageUniq(getPasteHint(hint.codeEmpty, hintRow));
 
-                         bPaste = false;
 
-                         continue;
 
-                     }
 
-                     if (colSetting.field === 'code' && validText.toString().indexOf('.') !== -1) {
 
-                         toastMessageUniq(getPasteHint(hint.codeError, hintRow));
 
-                         bPaste = false;
 
-                         continue;
 
-                     }
 
-                     if (colSetting.field === 'code' && _.find(sortData, { code: validText.toString() })) {
 
-                         toastMessageUniq(getPasteHint(hint.codeUsed, hintRow));
 
-                         bPaste = false;
 
-                         continue;
 
-                     }
 
-                     if (colSetting.field === 't_type' || colSetting.field === 'm_type') {
 
-                         continue;
 
-                     }
 
-                     if (colSetting.field === 'basic_price' || colSetting.field === 'msg_tp'
 
-                         || colSetting.field === 'm_up_risk' || colSetting.field === 'm_down_risk') {
 
-                         if (isNaN(validText)) {
 
-                             toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                             bPaste = false;
 
-                             continue;
 
-                         }
 
-                         const num = parseFloat(validText);
 
-                         if (colSetting.field === 'basic_price' || colSetting.field === 'msg_tp') {
 
-                             if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
 
-                                 toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         } else if (colSetting.field === 'm_up_risk' || colSetting.field === 'm_down_risk') {
 
-                             if (validText !== null && (num < 0 || num > 100 || !/^\d+$/.test(num))) {
 
-                                 toastMessageUniq(getPasteHint(hint.riskCan, hintRow));
 
-                                 bPaste = false;
 
-                                 continue;
 
-                             }
 
-                         }
 
-                     }
 
-                     materialData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                 }
 
-                 if (materialData.code === '' || materialData.code === null) {
 
-                     toastMessageUniq(getPasteHint(hint.codeEmpty, hintRow));
 
-                     bPaste = false;
 
-                 }
 
-                 if (bPaste) {
 
-                     materialData.msg_spread = materialCol.getValue.msg_spread(sortData[curRow]);
 
-                     materialData.m_spread = materialCol.getValue.m_spread(sortData[curRow]);
 
-                     materialData.m_tp = materialCol.getValue.m_tp(sortData[curRow]);
 
-                     data.push(materialData);
 
-                     // rowData.push(curRow);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             // console.log(data);
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/save', { type:'paste', updateData: data }, function (result) {
 
-                 materialBillsData = result.info;
 
-                 SpreadJsObj.reLoadSheetData(materialSpread.getActiveSheet());
 
-                 // for (const row in rowData) {
 
-                 //     materialBillsData.splice(index, 1, result.info[row]);
 
-                 //     SpreadJsObj.reLoadRowData(info.sheet, row);
 
-                 // }
 
-                 if (months.length > 0) {
 
-                     for (const [i,m] of monthsList.entries()) {
 
-                         m.code = materialBillsData[i].code;
 
-                         m.name = materialBillsData[i].name;
 
-                         m.unit = materialBillsData[i].unit;
 
-                     }
 
-                     SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
 
-                 }
 
-                 m_tp = result.m_tp;
 
-                 resetTpTable();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         },
 
-         setReadOnly: function(readOnly) {
 
-             // SpreadJsObj.resetFieldReadOnly(materialSpread.getActiveSheet(), 'msg_spread', 'm_spread', 'm_tp', 'pre_tp', readOnly);
 
-         }
 
-     };
 
-     materialSpreadObj.refreshActn();
 
-     materialSpread.bind(spreadNS.Events.SelectionChanged, materialSpreadObj.selectionChanged);
 
-     materialSpread.bind(spreadNS.Events.ClipboardPasted, materialSpreadObj.clipboardPasted);
 
-     SpreadJsObj.addDeleteBind(materialSpread, materialSpreadObj.deletePress);
 
-     const sheet = materialSpread.getActiveSheet();
 
-     sheet.suspendPaint();
 
-     // const basic_range = sheet.getRange(-1, 8, -1, 1);
 
-     // basic_range.cellType(new DatePickerCellType());
 
-     // basic_range.formatter("yyyy-MM-dd");
 
-     // const msg_range = sheet.getRange(-1, 10, -1, 1);
 
-     // msg_range.cellType(new DatePickerCellType());
 
-     // msg_range.formatter("yyyy-MM-dd");
 
-     sheet.resumePaint();
 
-     const static_cols = [
 
-         {title: '编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 60, formatter: '@', readOnly: true},
 
-         {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 180, formatter: '@', readOnly: true},
 
-         {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', readOnly: true},
 
-         {title: '平均单价', colSpan: '1', rowSpan: '2', field: 'average_msg_tp', hAlign: 2, width: 60, type: 'Number', readOnly: true, getValue:'getValue.average_msg_tp'},
 
-     ];
 
-     // 月信息价方法集合
 
-     const monthFunGather = {
 
-         _setMonthHtml: function() {
 
-             let html = '';
 
-             let qihtml = '';
 
-             for (const m of months) {
 
-                 html += '<div class="custom-control custom-checkbox mb-2">\n' +
 
-                     '                            <input type="checkbox" name="del_month" value="' + m + '" class="custom-control-input" id="month_' + m + '">\n' +
 
-                     '                            <label class="custom-control-label" for="month_' + m + '">' + m + '月</label>\n' +
 
-                     '                        </div>';
 
-                 qihtml += parseInt(m.split('-')[1]) + '月,';
 
-             }
 
-             if (months.length > 0) {
 
-                 qihtml = '<span class="mx-2 text-muted">/</span>本期月信息价:' + qihtml;
 
-                 qihtml = qihtml.substring(0, qihtml.length-1);
 
-             }
 
-             $('#show_month').html(html);
 
-             $('#qi-month').html(qihtml);
 
-         },
 
-         _monthHeaderSet: function() {
 
-             const newMonths = [];
 
-             for (const m of months) {
 
-                 const year = m.split('-')[0];
 
-                 const month = parseInt(m.split('-')[1]);
 
-                 let one = _.find(newMonths, { 'year': year });
 
-                 let oneIndex = _.findIndex(newMonths, { 'year': year });
 
-                 if (one) {
 
-                     one.month.push(month);
 
-                     newMonths.splice(oneIndex, 1, one);
 
-                 } else {
 
-                     one = {
 
-                         year: year,
 
-                         month: [ month ],
 
-                     };
 
-                     newMonths.push(one);
 
-                 }
 
-             }
 
-             const pushMonth = [];
 
-             for(const mo of newMonths) {
 
-                 for (let i in mo.month) {
 
-                     i = parseInt(i);
 
-                     const newCols = {
 
-                         title: (i === 0 ? mo.year: '') + '|' + mo.month[i] + '月',
 
-                         colSpan: (i === 0 ? (mo.month.length === 1 ? '0' : mo.month.length) : '') + '|1',
 
-                         rowSpan: i === 0 ? '1|1' : '|1',
 
-                         field: mo.year + '-' + (mo.month[i] < 10 ? '0' + mo.month[i] : mo.month[i]),
 
-                         hAlign: 2, width: 60, type: '@', readOnly: 'readOnly.isEdit'};
 
-                     pushMonth.push(newCols);
 
-                 }
 
-             }
 
-             return pushMonth;
 
-         },
 
-         monthSheetReset: function () {
 
-             const monthCols = monthFunGather._monthHeaderSet();
 
-             const newMonthSpreadHeaderCols = static_cols.concat(monthCols);
 
-             materialMonthSpreadSetting.cols = newMonthSpreadHeaderCols;
 
-             // 表头变化需要重新绘制,不然报错;
 
-             materialMonthSpread.getActiveSheet().reset();
 
-             SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
 
-             SpreadJsObj.initSheet(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
 
-             SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
 
-             monthFunGather._setMonthHtml();
 
-         }
 
-     }
 
-     const materialMonthSpread = SpreadJsObj.createNewSpread($('#material-month-spread')[0]);
 
-     const materialMonthSpreadSetting = {
 
-         cols: static_cols,
 
-         emptyRows: 0,
 
-         headRows: 2,
 
-         headRowHeight: [25, 25],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         readOnly: readOnly,
 
-     };
 
-     if (months.length > 0) {
 
-         const monthCols = monthFunGather._monthHeaderSet();
 
-         const monthSpreadHeaderCols = static_cols.concat(monthCols);
 
-         materialMonthSpreadSetting.cols = monthSpreadHeaderCols;
 
-     }
 
-     const materialMonthCol = {
 
-         getValue: {
 
-             average_msg_tp: function (data) {
 
-                 let msg_tp = 0;
 
-                 let hadnum = 0;
 
-                 for (const m of months) {
 
-                     msg_tp += data[m];
 
-                     if (data[m] !== null && data[m] !== '' && data[m] !== 0) {
 
-                         hadnum++;
 
-                     }
 
-                 }
 
-                 const average_tp = hadnum !== 0 ? ZhCalc.round(ZhCalc.div(msg_tp, hadnum), 3) : ZhCalc.round(ZhCalc.div(msg_tp, months.length), 3);
 
-                 return average_tp;
 
-             },
 
-         },
 
-         readOnly: {
 
-             isEdit: function (data) {
 
-                 return readOnly;
 
-             },
 
-         },
 
-     };
 
-     materialMonthSpread.getActiveSheet().frozenColumnCount(4);
 
-     materialMonthSpread.getActiveSheet().options.frozenlineColor = '#f1f1f1';
 
-     SpreadJsObj.initSpreadSettingEvents(materialMonthSpreadSetting, materialMonthCol);
 
-     SpreadJsObj.initSheet(materialMonthSpread.getActiveSheet(), materialMonthSpreadSetting);
 
-     SpreadJsObj.loadSheetData(materialMonthSpread.getActiveSheet(), SpreadJsObj.DataType.Data, monthsList);
 
-     const materialMonthSpreadObj = {
 
-         editEnded: function (e, info) {
 
-             if (info.sheet.zh_setting) {
 
-                 const select = SpreadJsObj.getSelectObject(info.sheet);
 
-                 const col = info.sheet.zh_setting.cols[info.col];
 
-                 // 未改变值则不提交
 
-                 const validText = is_numeric(info.editingText) ? parseFloat(info.editingText) : (info.editingText ? trimInvalidChar(info.editingText) : null);
 
-                 const orgValue = select[col.field];
 
-                 if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 // 判断部分值是否输入的是数字判断和数据计算
 
-                 if (isNaN(validText)) {
 
-                     toastr.error('不能输入其它非数字类型字符');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 const num = parseFloat(validText);
 
-                 if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
 
-                     toastr.error('请输入大于0并且小于3位小数的浮点数');
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     return;
 
-                 }
 
-                 select[col.field] = validText;
 
-                 // 更新至服务器
 
-                 postData(window.location.pathname + '/month/save', { type:'update', updateData: { mb_id: select.mb_id, yearmonth: col.field, value: validText } }, function (result) {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                     materialBillsData = result.materialBillsData;
 
-                     SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                     m_tp = result.m_tp;
 
-                     resetTpTable();
 
-                 }, function () {
 
-                     select[col.field] = orgValue;
 
-                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
 
-                 });
 
-             }
 
-         },
 
-         deletePress: function (sheet) {
 
-             // if (sheet.zh_setting && sheet.zh_data) {
 
-             //     const sel = sheet.getSelections()[0];
 
-             //     if (!sel) return;
 
-             //
 
-             //     const col = sheet.zh_setting.cols[sel.col];
 
-             //     const select = SpreadJsObj.getSelectObject(sheet);
 
-             //     const orgValue = select[col.field];
 
-             //     if (sel.colCount > 1 || sel.rowCount > 1) {
 
-             //         toastr.warning('请勿同时删除多行或多列数据');
 
-             //     }
 
-             //     console.log(sel, select, col);
 
-                 // if (orgValue === null || col.field === 'type' || col.field === 'is_summary') {
 
-                 //     return;
 
-                 // }
 
-                 // select[col.field] = null;
 
-                 // select.calc_num = materialExponentCol.getValue.calc_num(select);
 
-                 // console.log(select);
 
-                 // 更新至服务器
 
-                 // postData(window.location.pathname + '/save', { type:'update', updateData: select }, function (result) {
 
-                 //     ex_tp = result.ex_tp;
 
-                 //     ex_expr = result.ex_expr;
 
-                 //     resetExTpTable();
 
-                 //     SpreadJsObj.reLoadRowData(sheet, sel.row);
 
-                 //     materialExponentData.splice(sel.row, 1, select);
 
-                 // }, function () {
 
-                 //     select[col.field] = orgValue;
 
-                 //     SpreadJsObj.reLoadRowData(sheet, sel.row);
 
-                 // });
 
-             // }
 
-             return;
 
-         },
 
-         clipboardPasted(e, info) {
 
-             const hint = {
 
-                 cellError: {type: 'error', msg: '粘贴内容超出了表格范围'},
 
-                 numberExpr: {type: 'error', msg: '不能粘贴其它非数字类型字符'},
 
-                 numberCan: {type: 'error', msg: '请粘贴大于0并且小于3位小数的浮点数'},
 
-             };
 
-             const range = info.cellRange;
 
-             const sortData = info.sheet.zh_data || [];
 
-             if (info.cellRange.row + info.cellRange.rowCount > sortData.length) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 SpreadJsObj.reLoadSheetHeader(materialMonthSpread.getActiveSheet());
 
-                 SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
 
-                 return;
 
-             }
 
-             if (sortData.length > 0 && range.col + range.colCount > 4 + months.length) {
 
-                 toastMessageUniq(hint.cellError);
 
-                 SpreadJsObj.reLoadSheetHeader(materialMonthSpread.getActiveSheet());
 
-                 SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
 
-                 return;
 
-             }
 
-             const data = [];
 
-             for (let iRow = 0; iRow < range.rowCount; iRow++) {
 
-                 let bPaste = true;
 
-                 const curRow = range.row + iRow;
 
-                 const materialMonthData = sortData[curRow];
 
-                 const hintRow = range.rowCount > 1 ? curRow : '';
 
-                 let sameCol = 0;
 
-                 for (let iCol = 0; iCol < range.colCount; iCol++) {
 
-                     const curCol = range.col + iCol;
 
-                     const colSetting = info.sheet.zh_setting.cols[curCol];
 
-                     if (!colSetting) continue;
 
-                     let validText = info.sheet.getText(curRow, curCol);
 
-                     validText = is_numeric(validText) ? parseFloat(validText) : (validText ? trimInvalidChar(validText) : null);
 
-                     const orgValue = sortData[curRow][colSetting.field];
 
-                     if (orgValue == validText || ((!orgValue || orgValue === '') && (validText === ''))) {
 
-                         sameCol++;
 
-                         if (range.colCount === sameCol)  {
 
-                             bPaste = false;
 
-                         }
 
-                         continue;
 
-                     }
 
-                     const num = parseFloat(validText);
 
-                     if (isNaN(validText)) {
 
-                         toastMessageUniq(getPasteHint(hint.numberExpr, hintRow));
 
-                         bPaste = false;
 
-                         continue;
 
-                     }
 
-                     if (validText !== null && (num < 0 || !/^\d+(\.\d{1,3})?$/.test(num))) {
 
-                         toastMessageUniq(getPasteHint(hint.numberCan, hintRow));
 
-                         bPaste = false;
 
-                         continue;
 
-                     }
 
-                     materialMonthData[colSetting.field] = validText;
 
-                     sortData[curRow][colSetting.field] = validText;
 
-                 }
 
-                 if (bPaste) {
 
-                     data.push(materialMonthData);
 
-                 } else {
 
-                     SpreadJsObj.reLoadRowData(info.sheet, curRow);
 
-                 }
 
-             }
 
-             if (data.length === 0) {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             }
 
-             // 更新至服务器
 
-             postData(window.location.pathname + '/month/save', { type:'paste', updateData: data }, function (result) {
 
-                 SpreadJsObj.reLoadSheetData(materialMonthSpread.getActiveSheet());
 
-                 materialBillsData = result.materialBillsData;
 
-                 SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 m_tp = result.m_tp;
 
-                 resetTpTable();
 
-             }, function () {
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.cellRange.row, info.cellRange.rowCount);
 
-                 return;
 
-             });
 
-         },
 
-     };
 
-     materialMonthSpread.bind(spreadNS.Events.ClipboardPasted, materialMonthSpreadObj.clipboardPasted);
 
-     SpreadJsObj.addDeleteBind(materialMonthSpread, materialMonthSpreadObj.deletePress);
 
-     if (!readOnly) {
 
-         $('#add').click(materialSpreadObj.add);
 
-         $('#del').click(materialSpreadObj.del);
 
-         materialSpread.bind(spreadNS.Events.EditEnded, materialSpreadObj.editEnded);
 
-         materialSpread.bind(spreadNS.Events.ButtonClicked, materialSpreadObj.buttonClicked);
 
-         materialMonthSpread.bind(spreadNS.Events.EditEnded, materialMonthSpreadObj.editEnded);
 
-         // 右键菜单
 
-         $.contextMenu({
 
-             selector: '#material-spread',
 
-             build: function ($trigger, e) {
 
-                 const target = SpreadJsObj.safeRightClickSelection($trigger, e, materialSpread);
 
-                 return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
 
-             },
 
-             items: {
 
-                 'create': {
 
-                     name: '新增材料',
 
-                     icon: 'fa-sign-in',
 
-                     callback: function (key, opt) {
 
-                         materialSpreadObj.add(materialSpread.getActiveSheet());
 
-                     },
 
-                 },
 
-                 'delete': {
 
-                     name: '删除材料',
 
-                     icon: 'fa-remove',
 
-                     callback: function (key, opt) {
 
-                         materialSpreadObj.del(materialSpread.getActiveSheet());
 
-                     },
 
-                     disabled: function (key, opt) {
 
-                         const sheet = materialSpread.getActiveSheet();
 
-                         const select = SpreadJsObj.getSelectObject(sheet);
 
-                         const sel = sheet.getSelections()[0];
 
-                         materialSpreadObj.refreshActn(sel.rowCount);
 
-                         if (!readOnly && select && materialBase.isUsed(select) && sel.rowCount === 1) {
 
-                             return false;
 
-                         } else {
 
-                             return true;
 
-                         }
 
-                     }
 
-                 },
 
-             }
 
-         });
 
-         $('#changeRate').change(function () {
 
-             const rate = parseInt($(this).val());
 
-             postData(window.location.pathname + '/save', { type:'rate', rate: rate }, function (result) {
 
-                 const bqhs = ZhCalc.round(ZhCalc.mul(m_tp, 1+rate/100), 2);
 
-                 const exbqhs = ZhCalc.round(ZhCalc.mul(ex_tp, 1+rate/100), 2);
 
-                 const jzbqhs = ZhCalc.round(ZhCalc.add(pre_tp_hs, bqhs), 2);
 
-                 const exjzbqhs = ZhCalc.round(ZhCalc.add(ex_pre_tp_hs, exbqhs), 2);
 
-                 $('#rate_set').find('td').eq(1).text(bqhs !== 0 ? bqhs : '');
 
-                 $('#rate_set').find('td').eq(2).text(jzbqhs !== 0 ? jzbqhs : '');
 
-                 $('#rate_set').find('td').eq(3).text(exbqhs !== 0 ? exbqhs : '');
 
-                 $('#rate_set').find('td').eq(4).text(exjzbqhs !== 0 ? exjzbqhs : '');
 
-             });
 
-         });
 
-         $('#expr_select button').on('click', function () {
 
-             const code = $(this).text();
 
-             // $('#expr').val($('#expr').val() + code);
 
-             $('#expr').insertAtCaret(code);
 
-         });
 
-         const ExprObj = {
 
-             _checkExprValid(expr, invalidParam) {
 
-                 if (!expr) return [true, null];
 
-                 const param = [];
 
-                 let num = '', base = '';
 
-                 for (let i = 0, iLen = expr.length; i < iLen; i++) {
 
-                     if (/^[\d\.%]+/.test(expr[i])) {
 
-                         if (base !== '') {
 
-                             param.push({type: 'base', value: base});
 
-                             base = '';
 
-                         }
 
-                         num = num + expr[i];
 
-                     } else if (/^[a-z]/.test(expr[i])) {
 
-                         if (num !== '') {
 
-                             param.push({type: 'num', value: num});
 
-                             num = '';
 
-                         }
 
-                         base = base + expr[i];
 
-                     } else if (expr[i] === '(') {
 
-                         if (num !== '') {
 
-                             param.push({type: 'num', value: num});
 
-                             num = '';
 
-                         }
 
-                         if (base !== '') {
 
-                             param.push({type: 'base', value: base});
 
-                             base = '';
 
-                         }
 
-                         param.push({type: 'left', value: '('});
 
-                     } else if (expr[i] === ')') {
 
-                         if (num !== '') {
 
-                             param.push({type: 'num', value: num});
 
-                             num = '';
 
-                         }
 
-                         if (base !== '') {
 
-                             param.push({type: 'base', value: base});
 
-                             base = '';
 
-                         }
 
-                         param.push({type: 'right', value: ')'});
 
-                     } else if (/^[\+\-*\/]/.test(expr[i])) {
 
-                         if (num !== '') {
 
-                             param.push({type: 'num', value: num});
 
-                             num = '';
 
-                         }
 
-                         if (base !== '') {
 
-                             param.push({type: 'base', value: base});
 
-                             base = '';
 
-                         }
 
-                         param.push({type: 'calc', value: expr[i]});
 
-                     } else {
 
-                         return [false, '输入的表达式含有非法字符: ' + expr[i]];
 
-                     }
 
-                 }
 
-                 if (num !== '') {
 
-                     param.push({type: 'num', value: num});
 
-                     num = '';
 
-                 }
 
-                 if (base !== '') {
 
-                     param.push({type: 'base', value: base});
 
-                     base = '';
 
-                 }
 
-                 if (param.length === 0) return true;
 
-                 if (param.length > 1) {
 
-                     if (param[0].value === '-') {
 
-                         param[1].value = '-' + param[1];
 
-                     }
 
-                     param.unshift();
 
-                 }
 
-                 const iLen = param.length;
 
-                 let iLeftCount = 0, iRightCount = 0;
 
-                 for (const [i, p] of param.entries()) {
 
-                     if (p.type === 'calc') {
 
-                         if (i === 0 || i === iLen - 1)
 
-                             return [false, '输入的表达式非法:计算符号' + p.value + '前后应有数字或计算基数'];
 
-                     }
 
-                     if (p.type === 'num') {
 
-                         num = p.value.replace('%', '');
 
-                         if (p.value.length - num.length > 1)
 
-                             return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 
-                         num = _.toNumber(num);
 
-                         if (num === undefined || num === null || _.isNaN(num))
 
-                             return [false, '输入的表达式非法:' + p.value + '不是一个有效的数字'];
 
-                         if (i > 0) {
 
-                             if (param[i - 1].type !== 'calc') {
 
-                                 return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 
-                             } else if (param[i - 1].value === '/' && num === 0) {
 
-                                 return [false, '输入的表达式非法:请勿除0'];
 
-                             }
 
-                         }
 
-                     }
 
-                     if (p.type === 'base') {
 
-                         const baseParam = _.find(calcBase, {code: p.value});
 
-                         if (!baseParam)
 
-                             return [false, '输入的表达式非法:不存在计算基数' + p.value];
 
-                         if (invalidParam && invalidParam.indexOf(p.value) >= 0)
 
-                             return [false, '不可使用计算基数' + p.value];
 
-                         if (i > 0 && (param[i - 1].type === 'num' || param[i - 1].type === 'right'))
 
-                             return [false, '输入的表达式非法:' + p.value + '前应有运算符'];
 
-                     }
 
-                     if (p.type === 'left') {
 
-                         iLeftCount += 1;
 
-                         if (i !== 0 && param[i-1].type !== 'calc')
 
-                             return [false, '输入的表达式非法:(前应有运算符'];
 
-                     }
 
-                     if (p.type === 'right') {
 
-                         iRightCount += 1;
 
-                         if (i !== iLen - 1 && param[i+1].type !== 'calc')
 
-                             return [false, '输入的表达式非法:)后应有运算符'];
 
-                         if (iRightCount > iLeftCount)
 
-                             return [false, '输入的表达式非法:")"前无对应的"("'];
 
-                     }
 
-                 }
 
-                 if (iLeftCount > iRightCount)
 
-                     return [false, '输入的表达式非法:"("后无对应的")"'];
 
-                 return [true, ''];
 
-             },
 
-             _checkExpr: function (text) {
 
-                 if (text) {
 
-                     const num = _.toNumber(text);
 
-                     if (num) {
 
-                         console.log(num);
 
-                     } else {
 
-                         const expr = text.replace('=', '').toLowerCase();
 
-                         const [valid, msg] = this._checkExprValid(expr);
 
-                         if (!valid) return [valid, msg];
 
-                     }
 
-                 }
 
-                 return [true, ''];
 
-             },
 
-         };
 
-         $('#expr_btn').click(function () {
 
-             const expr = $('#expr').val();
 
-             // 判断表达式格式
 
-             const [valid, msg] = ExprObj._checkExpr(expr);
 
-             if (!valid) {
 
-                 toastr.error(msg);
 
-                 return false;
 
-             }
 
-             postData(window.location.pathname + '/save', { type:'expr', id: $('#materialbillsId').val(), expr: expr }, function (result) {
 
-                 m_tp = result.m_tp;
 
-                 resetTpTable();
 
-                 const sheet = materialSpread.getActiveSheet();
 
-                 const select = SpreadJsObj.getSelectObject(sheet);
 
-                 const index = materialBillsData.indexOf(select);
 
-                 materialBillsData.splice(index, 1, result.info);
 
-                 SpreadJsObj.reLoadRowData(sheet, index);
 
-                 $('#bcyy').modal('hide');
 
-             });
 
-         });
 
-         // 创建月信息价
 
-         $('#make-month').click(function() {
 
-             const yearmonth = $('#months').val();
 
-             const result = yearmonth.match(/^(\d{1,4})(-|\/)(\d{1,2})$/);
 
-             if (result === null) {
 
-                 toastr.error('请选择正确的信息价月份');
 
-                 return false;
 
-             }
 
-             //判断是否已存在当前月份
 
-             if (months.indexOf(yearmonth) !== -1) {
 
-                 toastr.error('调差期已创建过本月的信息价');
 
-                 return false;
 
-             }
 
-             postData(window.location.pathname + '/month/save', { type: 'add', updateData: { yearmonth: yearmonth } }, function (data) {
 
-                 months.push(yearmonth);
 
-                 months.sort();
 
-                 monthsList = data.monthsList;
 
-                 monthFunGather.monthSheetReset();
 
-                 // 工料表单价显示也要更新
 
-                 materialBillsData = data.materialBillsData;
 
-                 SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 m_tp = data.m_tp;
 
-                 resetTpTable();
 
-                 $('#add-month').modal('hide');
 
-             });
 
-         });
 
-         // 删除月信息价
 
-         $('#del-month').click(function () {
 
-             const del_month_array = [];
 
-             $("input[name='del_month']:checked").each(function () {
 
-                 del_month_array.push($(this).val());
 
-             });
 
-             if (del_month_array.length === 0) {
 
-                 toastr.error('请选择要移除的月信息价');
 
-                 return false;
 
-             }
 
-             postData(window.location.pathname + '/month/save', { type: 'del', updateData: { del_yearmonth: del_month_array } }, function (data) {
 
-                 for (const dm of del_month_array) {
 
-                     // _.remove(materialMonthSpreadSetting.cols, function (n) {
 
-                     //     return n.field === dm;
 
-                     // });
 
-                     _.remove(months, function (n) {
 
-                         return n === dm;
 
-                     });
 
-                 }
 
-                 monthsList = data.monthsList;
 
-                 monthFunGather.monthSheetReset();
 
-                 // 工料表单价显示也要更新
 
-                 materialBillsData = data.materialBillsData;
 
-                 SpreadJsObj.loadSheetData(materialSpread.getActiveSheet(), SpreadJsObj.DataType.Data, materialBillsData);
 
-                 m_tp = data.m_tp;
 
-                 resetTpTable();
 
-                 $('#remove-month').modal('hide');
 
-             });
 
-         });
 
-     } else {
 
-         // SpreadJsObj.forbiddenSpreadContextMenu('#material-spread', materialSpread);
 
-     }
 
-     $.subMenu({
 
-         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
 
-         toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
 
-         key: 'menu.1.0.0',
 
-         miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
 
-         callback: function (info) {
 
-             if (info.mini) {
 
-                 $('.panel-title').addClass('fluid');
 
-                 $('#sub-menu').removeClass('panel-sidebar');
 
-             } else {
 
-                 $('.panel-title').removeClass('fluid');
 
-                 $('#sub-menu').addClass('panel-sidebar');
 
-             }
 
-             autoFlashHeight();
 
-             materialSpread.refresh();
 
-         }
 
-     });
 
-     $.divResizer({
 
-         select: '#right-spr',
 
-         callback: function () {
 
-             materialSpread.refresh();
 
-             materialMonthSpread.refresh();
 
-             const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
 
-             setLocalCache('material_month_' + materialID, width);
 
-         }
 
-     });
 
-     // 展开收起月信息价并浏览器记住本期展开收起
 
-     $('a', '.right-nav').bind('click', function () {
 
-         //const main = $('#main-view'), tool = $('#tools-view');
 
-         const tab = $(this), tabPanel = $(tab.attr('content'));
 
-         if (!tab.hasClass('active')) {
 
-             $('a', '.side-menu').removeClass('active');
 
-             $('.tab-content .tab-select-show').removeClass('active');
 
-             tab.addClass('active');
 
-             tabPanel.addClass('active');
 
-             showSideTools(tab.hasClass('active'));
 
-             if (tab.attr('content') === '#month-tab') {
 
-                 const width = (($('#right-view').width()/$('#right-view').parent('div').width())*100).toFixed();
 
-                 setLocalCache('material_month_' + materialID, width);
 
-                 materialMonthSpread.refresh();
 
-             }
 
-         } else {
 
-             removeLocalCache('material_month_' + materialID);
 
-             tab.removeClass('active');
 
-             tabPanel.removeClass('active');
 
-             showSideTools(tab.hasClass('active'));
 
-         }
 
-         materialSpread.refresh();
 
-         materialMonthSpread.refresh();
 
-     });
 
-     // 根据浏览器记录展开收起
 
-     if (getLocalCache('material_month_' + materialID)) {
 
-         const tab = $('.right-nav a[content="#month-tab"]'), tabPanel = $(tab.attr('content'));
 
-         $('a', '.side-menu').removeClass('active');
 
-         $('.tab-content .tab-select-show').removeClass('active');
 
-         tab.addClass('active');
 
-         tabPanel.addClass('active');
 
-         $('#right-view').width(getLocalCache('material_month_' + materialID) + '%');
 
-         showSideTools(tab.hasClass('active'));
 
-         materialSpread.refresh();
 
-         materialMonthSpread.refresh();
 
-     }
 
- });
 
 
  |