|
@@ -3,28 +3,37 @@
|
|
|
*/
|
|
|
//modiyied by zhong on 2017/9/21
|
|
|
|
|
|
+$('#zmhs').click(function () {
|
|
|
+ if(!$(this).hasClass('active')){
|
|
|
+ $(this).addClass('active');
|
|
|
+ $('#mainContent').css('width', '50%');
|
|
|
+ $('#zmhsContent').show();
|
|
|
+ /* loadSize(sideResizeEles, 'width', function(){
|
|
|
+
|
|
|
+ });*/
|
|
|
+ if(!coeOprObj.workBook){
|
|
|
+ pageObj.initPage();
|
|
|
+ }
|
|
|
+ coeOprObj.workBook.refresh();
|
|
|
+ gljAdjOprObj.workBook.refresh();
|
|
|
+ rationOprObj.workBook.refresh();
|
|
|
+ rationGLJOprObj.sheet.getParent().refresh();
|
|
|
+ } else {
|
|
|
+ $(this).removeClass('active');
|
|
|
+ $('#mainContent').css('width', '75%')
|
|
|
+ $('#zmhsContent').hide();
|
|
|
+ rationOprObj.workBook.refresh();
|
|
|
+ rationGLJOprObj.sheet.getParent().refresh();
|
|
|
+ }
|
|
|
+});
|
|
|
|
|
|
var pageObj = {
|
|
|
- libID: null,
|
|
|
- gljLibID: null,
|
|
|
initPage: function (){
|
|
|
- var libID = getQueryString("repository");
|
|
|
let me = this;
|
|
|
- CommonAjax.post('/complementaryRation/api/getRationLibs', {ids: [libID]}, function (rstData) {
|
|
|
- if(rstData.length > 0){
|
|
|
- let libName = rstData[0].dispName;
|
|
|
- if (libName) {
|
|
|
- let $rationName = $(`<div id='rationname' class='navbar-text'>${libName}</div>`);
|
|
|
- $('.header-logo').after($rationName);
|
|
|
- };
|
|
|
- me.gljLibID = rstData[0].gljLib;
|
|
|
- me.libID = libID;
|
|
|
- coeOprObj.buildSheet($('#mainSpread')[0]);
|
|
|
- gljAdjOprObj.buildSheet($('#contentSpread')[0]);
|
|
|
- coeOprObj.getCoeList();
|
|
|
- gljAdjOprObj.getGljItemsOcc();
|
|
|
- }
|
|
|
- });
|
|
|
+ coeOprObj.buildSheet($('#mainSpread')[0]);
|
|
|
+ gljAdjOprObj.buildSheet($('#contentSpread')[0]);
|
|
|
+ coeOprObj.getCoeList();
|
|
|
+ //gljAdjOprObj.getGljItemsOcc();
|
|
|
|
|
|
},
|
|
|
showData: function(sheet, setting, data) {
|
|
@@ -69,20 +78,22 @@ let coeOprObj = {
|
|
|
currentMaxNo: null,
|
|
|
setting: {
|
|
|
header: [
|
|
|
- {headerName:"编号", headerWidth:60, dataCode:"serialNo", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
+ {headerName:"编号", headerWidth:50, dataCode:"serialNo", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
{headerName:"名称", headerWidth:280, dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center", readOnly: false},
|
|
|
- {headerName:"内容", headerWidth:250, dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center", readOnly: false},
|
|
|
+ {headerName:"内容", headerWidth:150, dataCode:"content", dataType: "String", hAlign: "left", vAlign: "center", readOnly: false},
|
|
|
]
|
|
|
},
|
|
|
buildSheet: function (container) {
|
|
|
let me = coeOprObj;
|
|
|
me.workBook = sheetCommonObj.buildSheet(container, me.setting, 30);
|
|
|
- sheetCommonObj.spreadDefaultStyle(me.workBook);
|
|
|
+ sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: null, editEnded: me.onEditEnded}]);
|
|
|
me.workSheet = me.workBook.getSheet(0);
|
|
|
me.workSheet.options.isProtected = true;
|
|
|
+ me.onDelOpr(me.workBook, me.setting);
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, me.onSelectionChanged);
|
|
|
- me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStarting);
|
|
|
+ me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
+ me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
},
|
|
|
onSelectionChanged: function (sender, info) {
|
|
|
let me = coeOprObj, that = gljAdjOprObj;
|
|
@@ -104,15 +115,192 @@ let coeOprObj = {
|
|
|
that.show(that.currentGljAdjList);
|
|
|
}
|
|
|
},
|
|
|
- onEditStarting: function (sender, args) {
|
|
|
- args.cancel = true;
|
|
|
+ onEditEnded: function (sender, args) {
|
|
|
+ let me = coeOprObj, addArr = [], updateArr = [], dataCode = me.setting.header[args.col].dataCode;
|
|
|
+ if(args.editingText && args.editingText.toString().trim().length > 0){
|
|
|
+ let inputT = args.editingText.toString().trim();
|
|
|
+ //update
|
|
|
+ if(args.row < me.currentCoeList.length){
|
|
|
+ let updateObj = me.currentCoeList[args.row];
|
|
|
+ if(updateObj[dataCode] != inputT){
|
|
|
+ if(dataCode === 'serialNo'){
|
|
|
+ if(me.isInt(inputT) && !me.hasTisNo(me.currentCoeList, inputT)){
|
|
|
+ me.currentMaxNo = me.currentMaxNo >= inputT ? me.currentMaxNo : inputT;
|
|
|
+ updateObj[dataCode] = inputT;
|
|
|
+ updateArr.push(updateObj);
|
|
|
+ me.save([], updateArr, [], true);
|
|
|
+ }
|
|
|
+ else if(!me.isInt(inputT)){
|
|
|
+ alert('编号只能为整数!');
|
|
|
+ args.sheet.setValue(args.row, args.col, updateObj[dataCode] + '');
|
|
|
+ }
|
|
|
+ else if(me.hasTisNo(me.currentCoeList, inputT)){
|
|
|
+ alert('该编号已存在!');
|
|
|
+ args.sheet.setValue(args.row, args.col, updateObj[dataCode] + '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ updateObj[dataCode] = inputT;
|
|
|
+ updateArr.push(updateObj);
|
|
|
+ me.save([], updateArr, [], true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //insert
|
|
|
+ else{
|
|
|
+ let newCoe = {};
|
|
|
+ if(dataCode === 'serialNo'){
|
|
|
+ if(me.isInt(inputT) && !me.hasTisNo(me.currentCoeList, inputT)){
|
|
|
+ me.currentMaxNo = me.currentMaxNo >= inputT ? me.currentMaxNo : inputT;
|
|
|
+ newCoe[dataCode] = inputT;
|
|
|
+ addArr.push(newCoe);
|
|
|
+ me.save(addArr, [], [], true, function (result) {
|
|
|
+ me.updateCurrentCoeList(result);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else if(!me.isInt(inputT)){
|
|
|
+ args.sheet.setValue(args.row, args.col, '');
|
|
|
+ alert('编号只能为整数!');
|
|
|
+ }
|
|
|
+ else if(me.hasTisNo(me.currentCoeList, inputT)){
|
|
|
+ args.sheet.setValue(args.row, args.col, '');
|
|
|
+ alert('该编号已存在!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ newCoe.serialNo = ++me.currentMaxNo;
|
|
|
+ newCoe[dataCode] = inputT;
|
|
|
+ addArr.push(newCoe);
|
|
|
+ me.save(addArr, [], [], true, function (result) {
|
|
|
+ me.updateCurrentCoeList(result);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onClipboardPasting: function (sender, info) {
|
|
|
- info.cancel = true;
|
|
|
+ let me = coeOprObj, maxCol = info.cellRange.col + info.cellRange.colCount - 1;
|
|
|
+ if(maxCol > me.setting.header.length){
|
|
|
+ info.cancel = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClipboardPasted: function (sender, info) {
|
|
|
+ let me = coeOprObj, addArr = [], updateArr = [];
|
|
|
+ let items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
+ let uniqItems = me.makeUniqItems(items);
|
|
|
+ for(let i = 0, len = uniqItems.length; i < len; i++){
|
|
|
+ let row = i + info.cellRange.row;
|
|
|
+ //update
|
|
|
+ if(row < me.currentCoeList.length){
|
|
|
+ let updateObj = me.currentCoeList[row];
|
|
|
+ for(let attr in uniqItems[i]){
|
|
|
+ if(attr === 'serialNo'){
|
|
|
+ if(me.isInt(uniqItems[i][attr]) && !me.hasTisNo(me.currentCoeList, uniqItems[i][attr])){
|
|
|
+ me.currentMaxNo = me.currentMaxNo >= uniqItems[i][attr] ? me.currentMaxNo : uniqItems[i][attr];
|
|
|
+ updateObj[attr] = uniqItems[i][attr];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ updateObj[attr] = uniqItems[i][attr];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ updateArr.push(updateObj);
|
|
|
+ }
|
|
|
+ //insert
|
|
|
+ else {
|
|
|
+ if(typeof uniqItems[i].serialNo !== 'undefined' && uniqItems[i] && me.isInt(uniqItems[i].serialNo) && !me.hasTisNo(me.currentCoeList, uniqItems[i].serialNo)){
|
|
|
+ me.currentMaxNo = me.currentMaxNo >= uniqItems[i].serialNo ? me.currentMaxNo : uniqItems[i].serialNo;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ uniqItems[i].serialNo = ++me.currentMaxNo;
|
|
|
+ }
|
|
|
+ addArr.push(uniqItems[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(addArr.length > 0 || updateArr.length > 0){
|
|
|
+ me.save(addArr, updateArr, [], true, function (result) {
|
|
|
+ me.updateCurrentCoeList(result);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onDelOpr: function (workBook, setting) {
|
|
|
+ let me = coeOprObj, that = gljAdjOprObj;
|
|
|
+ workBook.commandManager().register('coeListDel', function () {
|
|
|
+ let deleteArr = [];
|
|
|
+ let sheet = workBook.getSheet(0);
|
|
|
+ let sels = sheet.getSelections();
|
|
|
+ let idx = sels[0].row;
|
|
|
+ for(let i = 0, len = sels.length; i < len; i++){
|
|
|
+ if(idx > sels[i].row){
|
|
|
+ idx = sels[i].row;
|
|
|
+ }
|
|
|
+ if(sels[i].colCount === setting.header.length){//can del
|
|
|
+ for(let r = 0, rLen = sels[i].rowCount; r < rLen; r++){
|
|
|
+ let row = sels[i].row + r;
|
|
|
+ if(row < me.currentCoeList.length){
|
|
|
+ deleteArr.push({userId: me.currentCoeList[row].userId, compilationId: me.currentCoeList[row].compilationId, ID: me.currentCoeList[row].ID});
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.currentCoeList.splice(sels[i].row, sels[i].rowCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(deleteArr.length > 0){
|
|
|
+ me.save([], [], deleteArr, true);
|
|
|
+ me.currentCoe = typeof me.currentCoeList[idx] !== 'undefined' ? me.currentCoeList[idx] : null;
|
|
|
+ that.currentGljAdjList = me.currentCoe ? me.currentCoe.coes : [];
|
|
|
+ gljAdjOprObj.show(that.currentGljAdjList);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ workBook.commandManager().setShortcutKey('coeListDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ },
|
|
|
+ //粘贴的数据,编号唯一化,去除编号重复的项
|
|
|
+ makeUniqItems: function (items) {
|
|
|
+ let rst = [];
|
|
|
+ for(let i = 0, len = items.length; i < len; i++){
|
|
|
+ if(typeof items[i].serialNo !== 'undefined' && items[i].serialNo){
|
|
|
+ if(rst.length === 0){
|
|
|
+ rst.push(items[i]);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ let isExist = false;
|
|
|
+ for(let j = 0, jLen = rst.length; j < jLen; j++){
|
|
|
+ if(items[i].serialNo === rst[j].serialNo){
|
|
|
+ isExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!isExist){
|
|
|
+ rst.push(items[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ rst.push(items[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
},
|
|
|
isInt: function (num) {
|
|
|
return !isNaN(num) && num % 1 === 0;
|
|
|
},
|
|
|
+ hasTisNo: function (coeList, newSerialNo) {
|
|
|
+ let rst = false;
|
|
|
+ for(let i = 0, len = coeList.length; i < len; i++){
|
|
|
+ if(coeList[i].serialNo == newSerialNo){
|
|
|
+ rst = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ updateCurrentCoeList: function (newCoeList) {
|
|
|
+ let me = coeOprObj;
|
|
|
+ if(newCoeList){
|
|
|
+ me.currentCoeList = me.currentCoeList.concat(newCoeList);
|
|
|
+ }
|
|
|
+ },
|
|
|
sortCoeList: function (coeList) {
|
|
|
coeList.sort(function (a, b) {
|
|
|
let rst = 0;
|
|
@@ -123,12 +311,50 @@ let coeOprObj = {
|
|
|
},
|
|
|
getCoeList: function () {
|
|
|
let me = coeOprObj;
|
|
|
- CommonAjax.post('api/getCoeList', {libID: pageObj.libID}, function (rstData) {
|
|
|
- me.currentCoeList = rstData;
|
|
|
- me.sortCoeList(me.currentCoeList);
|
|
|
- me.currentMaxNo = me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
|
|
|
- pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
|
|
|
- me.workSheet.clearSelection();
|
|
|
+ $.ajax({
|
|
|
+ type: 'post',
|
|
|
+ url: 'api/getCoeList',
|
|
|
+ dataType: 'json',
|
|
|
+ timeout:20000,
|
|
|
+ success: function (result) {
|
|
|
+ if(!result.error){
|
|
|
+ me.currentCoeList = result.data;
|
|
|
+ me.sortCoeList(me.currentCoeList);
|
|
|
+ me.currentMaxNo = me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
|
|
|
+ pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
|
|
|
+ me.workSheet.clearSelection();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function(err){
|
|
|
+ alert("内部程序错误!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ save: function (addArr, updateArr, deleteArr, refresh, callback) {
|
|
|
+ let me = coeOprObj;
|
|
|
+ $.ajax({
|
|
|
+ type:"POST",
|
|
|
+ url:"api/saveCoeList",
|
|
|
+ data: {data: JSON.stringify({addArr: addArr, updateArr: updateArr, deleteArr: deleteArr})},
|
|
|
+ dataType:"json",
|
|
|
+ timeout:5000,
|
|
|
+ success:function(result){
|
|
|
+ if (result.error) {
|
|
|
+ alert(result.message);
|
|
|
+ } else{
|
|
|
+ if(callback){
|
|
|
+ callback(result.data);
|
|
|
+ }
|
|
|
+ if(refresh){
|
|
|
+ me.sortCoeList(me.currentCoeList);
|
|
|
+ me.currentMaxNo = me.currentCoeList.length > 0 ? me.currentCoeList[me.currentCoeList.length - 1].serialNo : 0;
|
|
|
+ pageObj.showData(me.workSheet, me.setting, me.currentCoeList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function(err){
|
|
|
+ alert("内部程序错误!");
|
|
|
+ }
|
|
|
});
|
|
|
}
|
|
|
};
|
|
@@ -137,18 +363,18 @@ let gljAdjOprObj = {
|
|
|
workBook: null,
|
|
|
workSheet: null,
|
|
|
currentGljAdjList: [],
|
|
|
- gljList: [],//只含编号和名称的总工料机列表
|
|
|
+ gljList: [],//总工料机列表, gljSelect中获取
|
|
|
setting: {
|
|
|
header: [
|
|
|
- {headerName:"调整类型", headerWidth:100, dataCode:"coeType", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
- {headerName:"人材机编码", headerWidth:100, dataCode:"gljCode", dataType: "String", formatter: '@', hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
+ {headerName:"调整类型", headerWidth:80, dataCode:"coeType", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
+ {headerName:"人材机编码", headerWidth:80, dataCode:"gljCode", dataType: "String", formatter: '@', hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
{headerName:"名称", headerWidth:100, dataCode:"gljName", dataType: "String", hAlign: "center", vAlign: "center", readOnly: true},
|
|
|
{headerName:"操作符", headerWidth:60, dataCode:"operator", dataType: "String", hAlign: "center", vAlign: "center", readOnly: false},
|
|
|
{headerName:"数量", headerWidth:80, dataCode:"amount", dataType: "String", hAlign: "center", vAlign: "center" , readOnly: false},
|
|
|
],
|
|
|
comboItems: {
|
|
|
//调整类型下拉菜单
|
|
|
- coeType: ['定额子目', '人工类', '材料类', '机械类', '主材类', '设备类', '单个工料机'],
|
|
|
+ coeType: ['定额', '人工', '材料', '机械', '主材', '设备', '单个工料机'],
|
|
|
//操作符下拉菜单
|
|
|
operator: ['+', '-', '*', '/', '=']
|
|
|
}
|
|
@@ -156,13 +382,16 @@ let gljAdjOprObj = {
|
|
|
buildSheet: function (container) {
|
|
|
let me = gljAdjOprObj;
|
|
|
me.workBook = sheetCommonObj.buildSheet(container, me.setting, 3);
|
|
|
- sheetCommonObj.spreadDefaultStyle(me.workBook);
|
|
|
me.workSheet = me.workBook.getSheet(0);
|
|
|
+ sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onEditStart, editEnded: me.onEditEnded}]);
|
|
|
me.workSheet.options.isProtected = true;
|
|
|
+ me.onDelOpr(me.workBook, me.setting);
|
|
|
me.workSheet.clearSelection();
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.EditStarting, me.onEditStart);
|
|
|
+ me.workSheet.bind(GC.Spread.Sheets.Events.EditEnded, me.onEditEnded);
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.EnterCell, me.onEnterCell);
|
|
|
me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
+ me.workSheet.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
|
},
|
|
|
buildBaseCell: function (sheet) {
|
|
|
let me = gljAdjOprObj;
|
|
@@ -192,10 +421,203 @@ let gljAdjOprObj = {
|
|
|
},
|
|
|
onEditStart: function (sender, args) {
|
|
|
let me = gljAdjOprObj;
|
|
|
- args.cancel = true;
|
|
|
+ if(!coeOprObj.currentCoe || args.row >= me.currentGljAdjList.length && args.col === 1
|
|
|
+ || args.row < me.currentGljAdjList.length && args.col === 1 && me.currentGljAdjList[args.row].coeType !== '单个工料机'){
|
|
|
+ args.cancel = true;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onEditEnded: function (sender, args) {
|
|
|
+ let me = gljAdjOprObj, isUpdate = false,
|
|
|
+ dataCode = me.setting.header[args.col].dataCode;
|
|
|
+ if(args.editingText && args.editingText.toString().trim().length > 0){
|
|
|
+ if(dataCode === 'amount' && isNaN(args.editingText)){
|
|
|
+ alert("只能输入数值!");
|
|
|
+ args.sheet.setValue(args.row, args.col, typeof me.currentGljAdjList[args.row] !== 'undefined' && typeof me.currentGljAdjList[args.row][dataCode] !== 'undefined'
|
|
|
+ ? me.currentGljAdjList[args.row][dataCode] + '' : '');
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //update
|
|
|
+ if(args.row < me.currentGljAdjList.length && args.editingText.toString().trim() !== me.currentGljAdjList[args.row][dataCode]){
|
|
|
+ let updateObj = me.currentGljAdjList[args.row];
|
|
|
+ if(dataCode === 'gljCode' && typeof updateObj.coeType !== 'undefined' && updateObj.coeType === '单个工料机'){
|
|
|
+ let gljName = me.getGljName(args.editingText, me.gljList);
|
|
|
+ if(gljName){
|
|
|
+ updateObj.gljCode = args.editingText;
|
|
|
+ updateObj.gljName = gljName;
|
|
|
+ isUpdate = true;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ alert("不存在编号为"+ args.editingText +"的工料机");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(dataCode === 'coeType'){
|
|
|
+ isUpdate = true;
|
|
|
+ updateObj[dataCode] = args.editingText;
|
|
|
+ updateObj.gljCode = '';
|
|
|
+ updateObj.gljName = '';
|
|
|
+ }
|
|
|
+ else if(dataCode !== 'gljCode') {
|
|
|
+ isUpdate = true;
|
|
|
+ updateObj[dataCode] = args.editingText;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //insert
|
|
|
+ else if(args.row >= me.currentGljAdjList.length){
|
|
|
+ isUpdate = true;
|
|
|
+ let newAdjGlj = {};
|
|
|
+ newAdjGlj[dataCode] = args.editingText;
|
|
|
+ me.currentGljAdjList.push(newAdjGlj);
|
|
|
+ }
|
|
|
+ if(isUpdate){
|
|
|
+ coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
|
|
|
+ console.log(me.currentGljAdjList);
|
|
|
+ me.show(me.currentGljAdjList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ args.sheet.setValue(args.row, args.col, typeof me.currentGljAdjList[args.row] !== 'undefined' && typeof me.currentGljAdjList[args.row][dataCode] !== 'undefined'
|
|
|
+ ? me.currentGljAdjList[args.row][dataCode] + '' : '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
onClipboardPasting: function (sender, info) {
|
|
|
- info.cancel = true;
|
|
|
+
|
|
|
+ },
|
|
|
+ getValidPasteDatas: function (pasteItems, info) {
|
|
|
+ let me = gljAdjOprObj;
|
|
|
+ let rst = [];
|
|
|
+ for(let i = 0, len = pasteItems.length; i < len; i++){
|
|
|
+ let row = i + info.cellRange.row;
|
|
|
+ let validObj = {};
|
|
|
+ //update
|
|
|
+ if(row < me.currentGljAdjList.length){
|
|
|
+ let updateObj = me.currentGljAdjList[row];
|
|
|
+ if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
|
|
|
+ let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
|
|
|
+ if(pasteItems[i].coeType === '单个工料机' && gljName){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ validObj.gljCode = pasteItems[i].gljCode;
|
|
|
+ validObj.gljName = gljName;
|
|
|
+ }
|
|
|
+ else if(pasteItems[i].coeType !== '单个工料机' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(typeof pasteItems[i].coeType === 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
|
|
|
+ let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
|
|
|
+ if(typeof updateObj.coeType !== 'undefined' && updateObj.coeType === '单个工料机' && gljName){
|
|
|
+ validObj.gljCode = pasteItems[i].gljCode;
|
|
|
+ validObj.gljName = gljName;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode === 'undefined'){
|
|
|
+ if(me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ if(validObj.coeType !== '单个工料机' && typeof updateObj.gljCode !== '单个工料机' && updateObj.gljCode.toString().trim().length > 0){
|
|
|
+ validObj.gljCode = '';
|
|
|
+ validObj.gljName = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
|
|
|
+ validObj.operator = pasteItems[i].operator;
|
|
|
+ }
|
|
|
+ if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
|
|
|
+ validObj.amount = pasteItems[i].amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ if(typeof pasteItems[i].coeType !== 'undefined' && typeof pasteItems[i].gljCode !== 'undefined'){
|
|
|
+ let gljName = me.getGljName(pasteItems[i].gljCode, me.gljList);
|
|
|
+ if(pasteItems[i].coeType === '单个工料机' && gljName){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ validObj.gljCode = pasteItems[i].gljCode;
|
|
|
+ validObj.gljName = gljName;
|
|
|
+ }
|
|
|
+ else if(pasteItems[i].coeType !== '单个工料机' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(typeof pasteItems[i].gljCode === 'undefined') {
|
|
|
+ if(typeof pasteItems[i].coeType !== 'undefined' && me.setting.comboItems.coeType.indexOf(pasteItems[i].coeType) !== -1){
|
|
|
+ validObj.coeType = pasteItems[i].coeType;
|
|
|
+ }
|
|
|
+ if(typeof pasteItems[i].operator !== 'undefined' && me.setting.comboItems.operator.indexOf(pasteItems[i].operator) !== -1){
|
|
|
+ validObj.operator = pasteItems[i].operator;
|
|
|
+ }
|
|
|
+ if(typeof pasteItems[i].amount !== 'undefined' && !isNaN(pasteItems[i].amount)){
|
|
|
+ validObj.amount = pasteItems[i].amount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Object.keys(validObj).length > 0){
|
|
|
+ rst.push(validObj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ },
|
|
|
+ onClipboardPasted: function (sender, info) {
|
|
|
+ let me = gljAdjOprObj, row;
|
|
|
+ let items = sheetCommonObj.analyzePasteData(me.setting, info);
|
|
|
+ let validDatas = me.getValidPasteDatas(items, info);
|
|
|
+ for(let i = 0, len = validDatas.length; i < len; i++){
|
|
|
+ row = i + info.cellRange.row;
|
|
|
+ //update
|
|
|
+ if(row < me.currentGljAdjList.length){
|
|
|
+ let updateObj = me.currentGljAdjList[row];
|
|
|
+ for(let attr in validDatas[i]){
|
|
|
+ updateObj[attr] = validDatas[i][attr];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //insert
|
|
|
+ else{
|
|
|
+ me.currentGljAdjList.push(validDatas[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(validDatas.length > 0){
|
|
|
+ coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
|
|
|
+ me.show(me.currentGljAdjList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ me.show(me.currentGljAdjList);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onDelOpr: function (workBook, setting) {
|
|
|
+ let me = gljAdjOprObj;
|
|
|
+ workBook.commandManager().register('gljAdjDel', function () {
|
|
|
+ let sheet = workBook.getSheet(0);
|
|
|
+ let sels = sheet.getSelections();
|
|
|
+ let isUpdate = false;
|
|
|
+ for(let i = 0, len = sels.length; i < len; i++){
|
|
|
+ if(sels[i].colCount === setting.header.length){//can del
|
|
|
+ if(sels[i].row < me.currentGljAdjList.length){
|
|
|
+ isUpdate = true;
|
|
|
+ me.currentGljAdjList.splice(sels[i].row, sels[i].rowCount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(isUpdate){
|
|
|
+ coeOprObj.save([], [coeOprObj.currentCoe], [], false, function () {
|
|
|
+ me.show(me.currentGljAdjList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ workBook.commandManager().setShortcutKey('gljAdjDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
|
+ },
|
|
|
+ getGljName: function (gljCode, gljList) {
|
|
|
+ let rst = null;
|
|
|
+ for(let i = 0, len = gljList.length; i < len; i++){
|
|
|
+ if(gljCode === gljList[i].code){
|
|
|
+ rst = gljList[i].name;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
},
|
|
|
show: function (coes) {
|
|
|
let me = gljAdjOprObj;
|
|
@@ -203,11 +625,23 @@ let gljAdjOprObj = {
|
|
|
},
|
|
|
getGljItemsOcc: function () {
|
|
|
let me = gljAdjOprObj;
|
|
|
- CommonAjax.post('api/getGljItemsOccupied', {gljLibId: pageObj.gljLibID, occupation: '-_id code name'}, function (rstData) {
|
|
|
- me.gljList = rstData;
|
|
|
+ $.ajax({
|
|
|
+ type: 'post',
|
|
|
+ url: '/stdGljRepository/api/getGljItemsOccupied',
|
|
|
+ data: {repId: pageObj.gljLibID, occupation: '-_id code name'},
|
|
|
+ dataType: 'json',
|
|
|
+ timeout: 5000,
|
|
|
+ success:function(result){
|
|
|
+ if (result.error) {
|
|
|
+ alert(result.message);
|
|
|
+ } else{
|
|
|
+ me.gljList = result.data;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function(err){
|
|
|
+ alert("内部程序错误!");
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|