|
@@ -0,0 +1,662 @@
|
|
|
+/**
|
|
|
+ * Created by Tony on 2017/4/28.
|
|
|
+ */
|
|
|
+
|
|
|
+$("#gongliao").click(function(){
|
|
|
+ $(this).attr('href', "/complementaryRation/glj" + "?repository=" + getQueryString("repository"))
|
|
|
+});
|
|
|
+
|
|
|
+$("#fuzhu").click(function(){
|
|
|
+ $(this).attr('href', "/complementaryRation/coe" + "?repository=" + getQueryString("repository"))
|
|
|
+});
|
|
|
+const digital = {
|
|
|
+ gljPrc: -3,//计算定额基价时单个工料机价格取三位
|
|
|
+ rationBasePrc: -2,
|
|
|
+ consumeAmt: -3
|
|
|
+};
|
|
|
+let rationOprObj = {
|
|
|
+ workBook: null,
|
|
|
+ currentRations: {},
|
|
|
+ currentEditingRation: null,
|
|
|
+ currentSectionId: -1,
|
|
|
+ rationsCodes: [],
|
|
|
+ type: {std: 'std', complementary: 'complementary'},
|
|
|
+ setting: {
|
|
|
+ header:[
|
|
|
+ {headerName:"编码",headerWidth:120,dataCode:"code", dataType: "String", formatter: "@"},
|
|
|
+ {headerName:"名称",headerWidth:280,dataCode:"name", dataType: "String"},
|
|
|
+ {headerName:"计量单位",headerWidth:120,dataCode:"unit", dataType: "String", hAlign: "center"},
|
|
|
+ {headerName:"人工费",headerWidth:120,dataCode:"labourPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
+ {headerName:"材料费",headerWidth:120,dataCode:"materialPrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
+ {headerName:"机械费",headerWidth:120,dataCode:"machinePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
+ {headerName:"基价",headerWidth:120,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right"},
|
|
|
+ {headerName:"显示名称(以%s表示参数)",headerWidth:280,dataCode:"caption", dataType: "String"},
|
|
|
+ {headerName:"取费专业",headerWidth:100,dataCode:"feeType", dataType: "Number", hAlign: "center"}
|
|
|
+ ],
|
|
|
+ view:{
|
|
|
+ comboBox:[
|
|
|
+ {row:-1,col:2,rowCount:-1,colCount:1}
|
|
|
+ ],
|
|
|
+ lockedCells:[
|
|
|
+ {row:-1,col:3,rowCount:-1, colCount:1}
|
|
|
+ ],
|
|
|
+ lockColumns: [
|
|
|
+ 3, 4, 5, 6
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ buildSheet: function(container) {
|
|
|
+ let rationRepId = getQueryString("repository");
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
+ me.getRationsCodes(rationRepId);
|
|
|
+ me.rationDelOpr();
|
|
|
+ me.setCombo(me.workBook.getSheet(0), 'dynamic');
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.LeaveCell, me.onLeaveCell);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditStarting, me.onCellEditStart);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.EditEnded, me.onCellEditEnd);
|
|
|
+ me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
|
|
|
+ },
|
|
|
+ setCombo: function (sheet, combo) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ sheet.suspendPaint();
|
|
|
+ sheet.suspendEvent();
|
|
|
+ if(combo){
|
|
|
+ combo = sheetCommonObj.getDynamicCombo();
|
|
|
+ combo.items(rationUnits).itemHeight(10).editable(true);
|
|
|
+ }
|
|
|
+ sheet.getRange(-1, me.setting.view.comboBox[0].col, -1, 1).cellType(combo);
|
|
|
+ sheet.resumePaint();
|
|
|
+ sheet.resumeEvent();
|
|
|
+ },
|
|
|
+ onSelectionChanged: function (sender, info) {
|
|
|
+ if(info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
|
|
|
+ let row = info.newSelections[0].row;
|
|
|
+ let me = rationOprObj,
|
|
|
+ sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
|
|
|
+ sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
|
|
|
+ sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
|
|
|
+ sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
|
|
|
+ sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
|
|
|
+ sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ if (cacheSection && row < cacheSection.length) {
|
|
|
+ rationGLJOprObj.getGljItems(cacheSection[row], function () {
|
|
|
+ me.workBook.focus(true);
|
|
|
+ });
|
|
|
+ rationCoeOprObj.getCoeItems(cacheSection[row], function () {
|
|
|
+ me.workBook.focus(true);
|
|
|
+ });
|
|
|
+ rationAssistOprObj.getAssItems(cacheSection[row]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rationGLJOprObj.currentRationItem = null;
|
|
|
+ }
|
|
|
+ me.workBook.focus(true);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ isDef: function (v) {
|
|
|
+ return v !== undefined && v !== null;
|
|
|
+ },
|
|
|
+ isInt: function (num) {
|
|
|
+ return !isNaN(num) && num % 1 === 0;
|
|
|
+ },
|
|
|
+ getCache: function() {
|
|
|
+ let me = this, rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ if (!(rst)) {
|
|
|
+ me.currentRations["_SEC_ID_" + me.currentSectionId] = [];
|
|
|
+ rst = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ updateCache: function(addArr, updateArr, removeIds, rstData) {
|
|
|
+ let me = this, cacheSection = me.getCache();
|
|
|
+ if (addArr.length > 0) {
|
|
|
+ me.currentRations["_SEC_ID_" + me.currentSectionId] = cacheSection.concat(addArr);
|
|
|
+ cacheSection = me.currentRations["_SEC_ID_" + me.currentSectionId];
|
|
|
+ }
|
|
|
+ for (let i = removeIds.length - 1; i >= 0; i--) {
|
|
|
+ for (let j = cacheSection.length - 1; j >= 0 ; j--) {
|
|
|
+ if (cacheSection[j]["ID"] == removeIds[i]) {
|
|
|
+ cacheSection.splice(j,1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (rstData && rstData.ops && rstData.ops.length > 0) {
|
|
|
+ for (let i = 0; i < rstData.ops.length; i++) {
|
|
|
+ for (let j = 0; j < cacheSection.length; j++) {
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == rstData.ops[i][me.setting.header[0].dataCode]) {
|
|
|
+ cacheSection[j]["ID"] = rstData.ops[i]["ID"];
|
|
|
+ cacheSection[j]["rationGljList"] = rstData.ops[i]["rationGljList"];
|
|
|
+ cacheSection[j]["rationCoeList"] = rstData.ops[i]["rationCoeList"];
|
|
|
+ cacheSection[j]["rationAssList"] = rstData.ops[i]["rationAssList"];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let i = 0; i < updateArr.length; i++) {
|
|
|
+ for (let j = 0; j < cacheSection.length; j++) {
|
|
|
+ if (updateArr[i]["ID"] && cacheSection[j]["ID"]) {
|
|
|
+ if (cacheSection[j]["ID"] == updateArr[i]["ID"]) {
|
|
|
+ cacheSection[j] = updateArr[i];
|
|
|
+ cacheSection[j].type = me.type.complementary;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == updateArr[i][me.setting.header[0].dataCode]) {
|
|
|
+ cacheSection[j] = updateArr[i];
|
|
|
+ cacheSection[j].type = me.type.complementary;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return cacheSection;
|
|
|
+ },
|
|
|
+ rationDelOpr: function () {
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.workBook.commandManager().register('rationDelete', function () {
|
|
|
+ let rationSheet = me.workBook.getActiveSheet();
|
|
|
+ let sels = rationSheet.getSelections(), updateArr = [], removeArr = [], lockCols = me.setting.view.lockColumns;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ if(sels.length > 0){
|
|
|
+ for(let sel = 0; sel < sels.length; sel++){
|
|
|
+ if(sels[sel].colCount === me.setting.header.length){
|
|
|
+ if(cacheSection){
|
|
|
+ for(let i = 0; i < sels[sel].rowCount; i++){
|
|
|
+ if(sels[sel].row + i < cacheSection.length && cacheSection[sels[sel].row + i].type !== me.type.std){
|
|
|
+ removeArr.push(cacheSection[sels[sel].row + i].ID);
|
|
|
+ me.rationsCodes.splice(me.rationsCodes.indexOf(cacheSection[sels[sel].row + i].code), 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ if(sels[sel].col === 0 && me.isDef(cacheSection[sels[sel].row]) && cacheSection[sels[sel].row].type !== me.type.std){
|
|
|
+ $('#alertText').text("编号不能为空,修改失败!");
|
|
|
+ $('#alertModalBtn').click();
|
|
|
+ $('#alertModalCls').click(function () {
|
|
|
+ });
|
|
|
+ $('#alertModalCof').click(function () {
|
|
|
+ })
|
|
|
+ }
|
|
|
+ else if(sels[sel].col !== 0 && !(sels[sel].col === 3 && sels.col + sels[sel].colCount -1 === 6)){
|
|
|
+ if(cacheSection){
|
|
|
+ for(let i = sels[sel].row === -1 ? 1 : 0; i < sels[sel].rowCount; i++){
|
|
|
+ if(sels[sel].row + i < cacheSection.length){
|
|
|
+ for(let col = sels[sel].col; col <= sels[sel].col + sels[sel].colCount - 1; col++){
|
|
|
+ if(lockCols.indexOf(col) === -1 && cacheSection[sels[sel].row + i].type !== me.type.std){
|
|
|
+ cacheSection[sels[sel].row + i][me.setting.header[col].dataCode] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(me.isDef(cacheSection[sels[sel].row + i]) && cacheSection[sels[sel].row + i].type !== me.type.std){
|
|
|
+ updateArr.push(cacheSection[sels[sel].row + i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(updateArr.length > 0 || removeArr.length > 0){
|
|
|
+ me.mixUpdate = 1;
|
|
|
+ me.mixDel = removeArr.length > 0 ? 1 : 0;
|
|
|
+ me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ me.workBook.commandManager().setShortcutKey('rationDelete', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ },
|
|
|
+ onLeaveCell: function (sender, args) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.lastCol = me.setting.header[args.col];
|
|
|
+ },
|
|
|
+ onEnterCell: function (sender, args) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ if(me.setting.header[args.col]['dataCode'] === 'unit' || me.lastCol.dataCode === 'unit'){
|
|
|
+ args.sheet.repaint();
|
|
|
+ }
|
|
|
+ me.cellRowIdx = args.row;
|
|
|
+ let isHasData = false;
|
|
|
+ if(me.addRationItem){
|
|
|
+ for(let i=0; i<me.setting.header.length; i++){
|
|
|
+ if(me.addRationItem[me.setting.header[i].dataCode]){
|
|
|
+ isHasData = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isHasData){
|
|
|
+ if(me.editingRowIdx !== me.cellRowIdx) {
|
|
|
+ let focusToCol = !me.addRationItem.code ? 0 : -1;
|
|
|
+ if(focusToCol !== -1){
|
|
|
+ $('#rationAlertBtn').click();
|
|
|
+ $('#rationAlertCac').click(function () {
|
|
|
+ me.addRationItem = null;
|
|
|
+ for(let col=0; col<me.setting.header.length; col++){
|
|
|
+ me.workBook.getSheet(0).getCell(me.editingRowIdx, col).value('');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $('#rationAlertCls').click(function () {
|
|
|
+ me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
|
|
|
+ });
|
|
|
+ $('#rationAlertCof').click(function () {
|
|
|
+ me.workBook.getSheet(0).setActiveCell(me.editingRowIdx, focusToCol);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCellEditStart: function(sender, args) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ if(!me.canRations || me.setting.view.lockColumns.indexOf(args.col) !== -1
|
|
|
+ || (me.isDef(cacheSection[args.row]) && cacheSection[args.row].type === me.type.std)){
|
|
|
+ args.cancel = true;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ let rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row);
|
|
|
+ me.currentEditingRation = rObj;
|
|
|
+ if (cacheSection) {
|
|
|
+ for (let j = 0; j < cacheSection.length; j++) {
|
|
|
+ if (cacheSection[j][me.setting.header[0].dataCode] == rObj[me.setting.header[0].dataCode]) {
|
|
|
+ rObj["ID"] = cacheSection[j]["ID"];
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onCellEditEnd: function(sender, args) {
|
|
|
+ let me = rationOprObj, rObj = sheetsOprObj.combineRationRowData(me.workBook.getSheet(0), me.setting, args.row),
|
|
|
+ updateArr = [], addArr = [];
|
|
|
+ let dataCode = me.setting.header[args.col].dataCode;
|
|
|
+ me.editingRowIdx = args.row;
|
|
|
+ if (me.currentEditingRation["ID"]) {
|
|
|
+ if((!args.editingText || args.editingText.toString().trim().length === 0) && args.col === 0){
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingRation[dataCode] + '');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rObj["ID"] = me.currentEditingRation["ID"];
|
|
|
+ if(me.currentEditingRation[dataCode] !== rObj[dataCode]){
|
|
|
+ me.addRationItem = rObj;
|
|
|
+ if(dataCode === 'code'){
|
|
|
+ if(me.rationsCodes.indexOf(rObj.code) === -1){
|
|
|
+ me.rationsCodes.splice(me.rationsCodes.indexOf(rObj.code), 1);
|
|
|
+ me.rationsCodes.push(rObj.code);
|
|
|
+ updateArr.push(rObj);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ alert("编码已存在!");
|
|
|
+ args.sheet.setValue(args.row, args.col, me.currentEditingRation[dataCode]);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(dataCode === 'feeType'){//取费专业控制为整数
|
|
|
+ if(me.isInt(rObj[dataCode])){
|
|
|
+ updateArr.push(rObj);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rObj[dataCode] = '';
|
|
|
+ args.sheet.setValue(args.row, args.col, typeof me.currentEditingRation[dataCode] !== 'undefined' && me.currentEditingRation[dataCode] ? me.currentEditingRation[dataCode] : '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ updateArr.push(rObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(!me.currentEditingRation["ID"]) {
|
|
|
+ if (!sheetCommonObj.chkIfEmpty(rObj, me.setting)) {
|
|
|
+ //addArr.push(rObj);
|
|
|
+ me.addRationItem = rObj;
|
|
|
+ if(rObj.code && rObj.code.toString().trim().length > 0){
|
|
|
+ if(me.rationsCodes.indexOf(rObj.code) === -1){
|
|
|
+ //jobContent
|
|
|
+ if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
|
|
|
+ rObj.jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
|
|
|
+ }
|
|
|
+ if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
|
|
|
+ rObj.annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
|
|
|
+ }
|
|
|
+ me.setInitPrc(rObj);
|
|
|
+ addArr.push(rObj);
|
|
|
+ me.rationsCodes.push(rObj.code);
|
|
|
+ me.addRationItem = null;
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ alert('编码已存在!');
|
|
|
+ me.workBook.getSheet(0).setValue(args.row, args.col, '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(rObj.code && rObj.code.toString.trim().length === 0){
|
|
|
+ me.workBook.getSheet(0).setValue(args.row, args.col, '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (updateArr.length > 0 || addArr.length > 0) {
|
|
|
+ me.currentEditingRation = null;
|
|
|
+ me.mixUpdate = 1;
|
|
|
+ me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ canPasted: function (beginCol, maxCol) {
|
|
|
+ let rst = false;
|
|
|
+ if(maxCol < 3 || beginCol > 6){
|
|
|
+ rst = true;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ onClipboardPasting: function(sender, args) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ let maxCol = args.cellRange.col + args.cellRange.colCount -1;
|
|
|
+ if(!me.canRations || !me.canPasted(args.cellRange.col, maxCol) || maxCol > me.setting.header.length - 1){
|
|
|
+ args.cancel = true;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let hasStd = false;
|
|
|
+ for(let row = args.cellRange.row, len = args.cellRange.row + args.cellRange.rowCount - 1; row < len; row++){
|
|
|
+ if(me.isDef(cacheSection[row]) && me.isDef(cacheSection[row].type) && cacheSection[row].type === me.type.std){
|
|
|
+ hasStd = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(hasStd){
|
|
|
+ args.cancel = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClipboardPasted: function(e, info) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ let cacheSection = me.getCache();
|
|
|
+ let updateArr = [], addArr = [];
|
|
|
+ let items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
+ for (let i = 0; i < items.length; i++) {
|
|
|
+ let rowIdx = info.cellRange.row + i;
|
|
|
+ if (cacheSection) {
|
|
|
+ if(!me.isValidUnit(items[i], rationUnits)){//无效单位
|
|
|
+ items[i].unit = rowIdx < cacheSection.length && typeof cacheSection[rowIdx].unit !== 'undefined' ? cacheSection[rowIdx].unit : '';
|
|
|
+ }
|
|
|
+ if(!cacheSection[rowIdx] && info.cellRange.col === 0 ){
|
|
|
+ if(me.rationsCodes.indexOf(items[i].code) === -1){
|
|
|
+ //jobConten
|
|
|
+ if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
|
|
|
+ items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
|
|
|
+ }
|
|
|
+ if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
|
|
|
+ items[i].annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
|
|
|
+ }
|
|
|
+ me.setInitPrc(items[i]);
|
|
|
+ addArr.push(items[i]);
|
|
|
+ me.rationsCodes.push(items[i].code);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ me.workBook.getSheet(0).setValue(rowIdx, 0, '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(cacheSection[rowIdx]){
|
|
|
+ for(let col = 0; col < me.setting.header.length; col++){
|
|
|
+ if(!items[i][me.setting.header[col].dataCode] && typeof cacheSection[rowIdx][me.setting.header[col].dataCode] !== 'undefined'){
|
|
|
+ items[i][me.setting.header[col].dataCode] = cacheSection[rowIdx][me.setting.header[col].dataCode];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(items[i].feeType && !me.isInt(items[i].feeType)){
|
|
|
+ items[i].feeType = '';
|
|
|
+ me.workBook.getSheet(0).setValue(rowIdx, 8, '');
|
|
|
+ }
|
|
|
+ if(info.cellRange.col === 0){
|
|
|
+ if(me.rationsCodes.indexOf(items[i].code) === -1){
|
|
|
+ items[i].ID = cacheSection[rowIdx].ID;
|
|
|
+ updateArr.push(items[i]);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ me.workBook.getSheet(0).setValue(rowIdx, 0, cacheSection[rowIdx].code);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ items[i].ID = cacheSection[rowIdx].ID;
|
|
|
+ updateArr.push(items[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if(!me.isValidUnit(items[i], rationUnits)){//无效单位
|
|
|
+ items[i].unit = '';
|
|
|
+ }
|
|
|
+ //add
|
|
|
+ if(info.cellRange.col === 0){
|
|
|
+ //是否含有已存在的编号
|
|
|
+ if(me.rationsCodes.indexOf(items[i].code) === -1){
|
|
|
+ //jobConten
|
|
|
+ if(jobContentOprObj && jobContentOprObj.currentSituation === jobContentOprObj.situations.ALL){
|
|
|
+ items[i].jobContent = jobContentOprObj.currentJobContent ? jobContentOprObj.currentJobContent : '';
|
|
|
+ }
|
|
|
+ if(annotationOprObj && annotationOprObj.currentSituation === annotationOprObj.situations.ALL){
|
|
|
+ items[i].annotation = annotationOprObj.currentAnnotation ? annotationOprObj.currentAnnotation : '';
|
|
|
+ }
|
|
|
+ me.setInitPrc(items[i]);
|
|
|
+ addArr.push(items[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (updateArr.length > 0 || addArr.length > 0) {
|
|
|
+ me.mixUpdate = 1;
|
|
|
+ me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ me.getRationItems(me.currentSectionId);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setInitPrc: function (obj) {
|
|
|
+ obj.labourPrice = 0;
|
|
|
+ obj.materialPrice = 0;
|
|
|
+ obj.machinePrice = 0;
|
|
|
+ obj.basePrice = 0;
|
|
|
+ },
|
|
|
+ isValidUnit: function (rationObj, validUnits) {
|
|
|
+ let rst = true;
|
|
|
+ if(typeof rationObj.unit !== 'undefined' && rationObj.unit && validUnits.indexOf(rationObj.unit) === -1){//无效
|
|
|
+ rst = false;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ getRationsCodes: function (repId) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ CommonAjax.post('api/getRationsCodes', {rationRepId: repId}, function (rstData) {
|
|
|
+ me.rationsCodes = rstData;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ mixUpdateRequest: function(updateArr, addArr, removeIds, callback) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.saveInString(updateArr);
|
|
|
+ CommonAjax.post('api/mixUpdateRationItems',
|
|
|
+ {rationRepId: getQueryString("repository"), sectionId: me.currentSectionId, updateItems: updateArr, addItems: addArr, removeIds: removeIds},
|
|
|
+ function (rstData) {
|
|
|
+ //mark complementary
|
|
|
+ for(let i = 0, len = addArr.length; i < len; i++){
|
|
|
+ addArr[i].type = me.type.complementary;
|
|
|
+ }
|
|
|
+ let cacheSection = me.updateCache(addArr, updateArr, removeIds, rstData);
|
|
|
+ cacheSection.sort(function(a, b){
|
|
|
+ let rst = 0;
|
|
|
+ if (a.code > b.code) rst = 1
|
|
|
+ else if (a.code < b.code) rst = -1;
|
|
|
+ return rst;
|
|
|
+ });
|
|
|
+ //jobContent
|
|
|
+ if(jobContentOprObj ){
|
|
|
+ jobContentOprObj.currentRationItems = cacheSection;
|
|
|
+ jobContentOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, jobContentOprObj.radios);
|
|
|
+ if(cacheSection.length === 0){
|
|
|
+ jobContentOprObj.updateSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
|
|
|
+ }
|
|
|
+ jobContentOprObj.setRadiosChecked(jobContentOprObj.currentSituation, jobContentOprObj.radios);
|
|
|
+ if(jobContentOprObj.currentSituation === jobContentOprObj.situations.PARTIAL){
|
|
|
+ jobContentOprObj.buildTablePartial(jobContentOprObj.tablePartial, jobContentOprObj.getGroup(cacheSection));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(annotationOprObj ){
|
|
|
+ annotationOprObj.setRadiosDisabled(cacheSection.length > 0 ? false : true, annotationOprObj.radios);
|
|
|
+ if(cacheSection.length === 0){
|
|
|
+ annotationOprObj.updateAnnoSituation(pageOprObj.rationLibId, me.currentSectionId, 'NONE');
|
|
|
+ }
|
|
|
+ annotationOprObj.setRadiosChecked(annotationOprObj.currentSituation, annotationOprObj.radios);
|
|
|
+ if(annotationOprObj.currentSituation === annotationOprObj.situations.PARTIAL){
|
|
|
+ annotationOprObj.buildTablePartial(annotationOprObj.fzTablePartial, annotationOprObj.getGroup(cacheSection));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.showRationItems(me.currentSectionId);
|
|
|
+ me.mixUpdate = 0;
|
|
|
+ me.mixDel = 0;
|
|
|
+ if(callback) callback();
|
|
|
+ }, function () {
|
|
|
+ me.getRationItems(me.currentSectionId);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getRationItems: function(sectionID){
|
|
|
+ if (sectionID != -1) {
|
|
|
+ let me = rationOprObj;
|
|
|
+ me.mixUpdate = 0;
|
|
|
+ me.currentSectionId = sectionID;
|
|
|
+ if (me.currentRations["_SEC_ID_" + sectionID]) {
|
|
|
+ //jobContent--
|
|
|
+ jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
+ jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
+ //annotation
|
|
|
+ annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
+ me.showRationItems(sectionID);
|
|
|
+ } else {
|
|
|
+ CommonAjax.post('/complementaryRation/api/getRationItems', {rationRepId: pageOprObj.rationLibId, sectionId: sectionID}, function (rstData) {
|
|
|
+ me.currentRations["_SEC_ID_" + sectionID] = rstData;
|
|
|
+ me.currentRations["_SEC_ID_" + sectionID] = me.sortByCode(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
+ //job--
|
|
|
+ jobContentOprObj.currentRationItems = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
+ jobContentOprObj.rationJobContentOpr(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
+ //annotation
|
|
|
+ annotationOprObj.rationAnnotationOpr(me.currentRations["_SEC_ID_" + sectionID]);
|
|
|
+ me.showRationItems(sectionID);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setColor: function (cache) {
|
|
|
+ let me = this;
|
|
|
+ let sheet = me.workBook.getSheet(0);
|
|
|
+ sheet.suspendPaint();
|
|
|
+ for(let i = 0, len = cache.length; i < len; i++){
|
|
|
+ if(cache[i].type === me.type.complementary){
|
|
|
+ sheet.getRange(i, -1, 1, -1).foreColor('gray');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ sheet.getRange(i, -1, 1, -1).foreColor('');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sheet.resumePaint();
|
|
|
+ },
|
|
|
+ showRationItems: function(sectionID){
|
|
|
+ let me = rationOprObj,
|
|
|
+ sheetGLJ = rationGLJOprObj.sheet, settingGLJ = rationGLJOprObj.setting,
|
|
|
+ sheetCoe = rationCoeOprObj.sheet, settingCoe = rationCoeOprObj.setting,
|
|
|
+ sheetAss = rationAssistOprObj.sheet, settingAss = rationAssistOprObj.setting;
|
|
|
+ if (me.workBook) {
|
|
|
+ if (me.currentRations && me.currentRations["_SEC_ID_" + sectionID] && me.currentRations["_SEC_ID_" + sectionID].length > 0) {
|
|
|
+ let cacheSection = me.currentRations["_SEC_ID_" + sectionID];
|
|
|
+ sheetCommonObj.cleanData(me.workBook.getSheet(0), me.setting, -1);
|
|
|
+ sheetsOprObj.showData(me.workBook.getSheet(0), me.setting, cacheSection);
|
|
|
+ console.log(cacheSection);
|
|
|
+ me.setColor(cacheSection);
|
|
|
+ //combo
|
|
|
+ //sheetCommonObj.setStaticCombo(me.workBook.getActiveSheet(), 0, 2, cacheSection.length, rationUnits, 10, false);
|
|
|
+ //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
|
|
|
+ if(me.mixDel === 1){
|
|
|
+ let row = me.workBook.getSheet(0).getSelections()[0].row;
|
|
|
+ if (cacheSection && row < cacheSection.length) {
|
|
|
+ sheetCommonObj.cleanData(sheetGLJ, settingGLJ, -1);
|
|
|
+ sheetCommonObj.cleanData(sheetCoe, settingCoe, -1);
|
|
|
+ sheetCommonObj.cleanData(sheetAss, settingAss, -1);
|
|
|
+ rationGLJOprObj.getGljItems(cacheSection[row]);
|
|
|
+ rationCoeOprObj.getCoeItems(cacheSection[row]);
|
|
|
+ rationAssistOprObj.getAssItems(cacheSection[row]);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rationGLJOprObj.currentRationItem = null;
|
|
|
+ sheetCommonObj.cleanData(sheetGLJ, settingGLJ, -1);
|
|
|
+ sheetCommonObj.cleanData(sheetCoe, settingCoe, -1);
|
|
|
+ sheetCommonObj.cleanData(sheetAss, settingAss, -1);
|
|
|
+ sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ sheetCommonObj.setDynamicCombo(sheetAss, 0, 5, sheetAss.getRowCount(), rationAssistOprObj.setting.comboItems, false, false);
|
|
|
+ //--sheetCommonObj.setDynamicCombo(me.workBook.getActiveSheet(), 0, 2, me.workBook.getActiveSheet().getRowCount(), rationUnits, 10, false);
|
|
|
+ //清除ration数据及工料机数据
|
|
|
+ rationGLJOprObj.currentRationItem = null;
|
|
|
+ sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
|
|
|
+ sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
|
|
|
+ sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
|
|
|
+ sheetCommonObj.cleanSheet(sheetAss, settingAss, -1);
|
|
|
+ }
|
|
|
+ //--- me.workBook.focus(true);
|
|
|
+ }
|
|
|
+ sectionTreeObj.workBook.focus(true);
|
|
|
+ },
|
|
|
+ sortByCode: function(arr){
|
|
|
+ let me = rationOprObj;
|
|
|
+ //std complementary
|
|
|
+ let stdArr = [], compleArr = [];
|
|
|
+ for(let i = 0, len = arr.length; i < len; i++){
|
|
|
+ if(arr[i].type === me.type.std){
|
|
|
+ stdArr.push(arr[i]);
|
|
|
+ }
|
|
|
+ else if(arr[i].type === me.type.complementary){
|
|
|
+ compleArr.push(arr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stdArr.sort(compare());
|
|
|
+ compleArr.sort(compare());
|
|
|
+ return stdArr.concat(compleArr);
|
|
|
+ function compare(){
|
|
|
+ return function (a, b) {
|
|
|
+ let rst = 0;
|
|
|
+ if (a.code > b.code) {
|
|
|
+ rst = 1;
|
|
|
+ }
|
|
|
+ else if (a.code < b.code) {
|
|
|
+ rst = -1;
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // arr.sort(compare());
|
|
|
+ },
|
|
|
+ saveInString(datas){
|
|
|
+ for(let i = 0, len = datas.length; i < len; i++){
|
|
|
+ let data = datas[i];
|
|
|
+ if(data.labourPrice !== undefined && data.labourPrice){
|
|
|
+ data.labourPrice = data.labourPrice.toString();
|
|
|
+ }
|
|
|
+ if(data.materialPrice !== undefined && data.materialPrice){
|
|
|
+ data.materialPrice = data.materialPrice.toString();
|
|
|
+ }
|
|
|
+ if(data.machinePrice !== undefined && data.machinePrice){
|
|
|
+ data.machinePrice = data.machinePrice.toString();
|
|
|
+ }
|
|
|
+ if(data.basePrice !== undefined && data.basePrice){
|
|
|
+ data.basePrice = data.basePrice.toString();
|
|
|
+ }
|
|
|
+ if(data.rationGljList !== undefined && data.rationGljList && data.rationGljList.length > 0){
|
|
|
+ for(let j = 0, jLen = data.rationGljList.length; j < jLen; j++){
|
|
|
+ let raGljObj = data.rationGljList[j];
|
|
|
+ if(raGljObj.consumeAmt !== undefined && raGljObj.consumeAmt){
|
|
|
+ raGljObj.consumeAmt = raGljObj.consumeAmt.toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|