var UserStorageResource = require('../../common/UserStorageResource.js') export default { cloneField: function (field) { var fieldClone = { 'fieldName': field.fieldName, 'name': field.name, 'nameEng': field.nameEng, 'isShow': field.isShow, 'mandatory': field.mandatory, 'sortNo':field.sortNo, 'width':field.width, } return fieldClone }, // 获取InfoFilterField的Key getInfoFilterFieldKey: function(infoFilterFieldItem){ if(infoFilterFieldItem == undefined){ return undefined } return '#InfoFilterFieldItem_' + infoFilterFieldItem.id + '_' + infoFilterFieldItem.fieldName + '_' + infoFilterFieldItem.rowNumber }, saveInfoFilterFields: function (infoWindowNo, filterFields) { var key = 'InfoFilterFields_' + infoWindowNo var userStorageDtos = [ { key: key, value: JSON.stringify(filterFields), }, ] return new Promise(function (resolve, reject) { UserStorageResource.uploadUserStorage(userStorageDtos).then(successData => { resolve() }, errorData => { Common.processException(errorData) reject() }) }) }, saveInfoGridFields: function (infoWindowNo, filterGrids) { var key = 'InfoGridFields_' + infoWindowNo var userStorageDtos = [ { key: key, value: JSON.stringify(filterGrids), }, ] return new Promise(function (resolve, reject) { UserStorageResource.uploadUserStorage(userStorageDtos).then(successData => { resolve() }, errorData => { Common.processException(errorData) reject() }) }) }, restoreInfoFilterFields: function (infoWindowNo, localInfoFilterFields) { var key = 'InfoFilterFields_' + infoWindowNo if (localInfoFilterFields != null) { UserStorageResource.uniqueByKey(key).then(successData => { var remoteInfoFilterFields = null if (successData != null) { remoteInfoFilterFields = JSON.parse(successData) }else{ remoteInfoFilterFields = null } if (remoteInfoFilterFields != null) { localInfoFilterFields.forEach(localInfoFilterField => { remoteInfoFilterFields.forEach(remoteInfoFilterField => { if (remoteInfoFilterField != null && localInfoFilterField != null && localInfoFilterField.fieldName == remoteInfoFilterField.fieldName) { localInfoFilterField.isShow = remoteInfoFilterField.isShow localInfoFilterField.sortNo = remoteInfoFilterField.sortNo == null ? 0 : remoteInfoFilterField.sortNo } }) }) localInfoFilterFields.sort(function(item1, item2){ return item1.sortNo - item2.sortNo }) }else{ localInfoFilterFields.forEach(localInfoFilterField => { if(localInfoFilterField.sortNo == undefined){ localInfoFilterField.sortNo = SortNoUtil.newSortNo() } }) localInfoFilterFields.sort(function(item1, item2){ return item1.sortNo - item2.sortNo }) } }, errorData => { Common.processException(errorData) }) } }, restoreInfoGridFields: function (infoWindowNo, localInfoGridFields) { var key = 'InfoGridFields_' + infoWindowNo if (localInfoGridFields != null) { UserStorageResource.uniqueByKey(key).then(successData => { var remoteInfoGridFields = null if (successData != null) { remoteInfoGridFields = JSON.parse(successData) }else{ remoteInfoGridFields = null } if (remoteInfoGridFields != null && remoteInfoGridFields != undefined) { localInfoGridFields.forEach(localInfoGridField => { remoteInfoGridFields.forEach(remoteInfoGridField => { if (remoteInfoGridField != null && localInfoGridField != null && localInfoGridField.fieldName == remoteInfoGridField.fieldName) { localInfoGridField.isShow = remoteInfoGridField.isShow localInfoGridField.sortNo = remoteInfoGridField.sortNo == null ? 0 : remoteInfoGridField.sortNo localInfoGridField.width = remoteInfoGridField.width } }) }) localInfoGridFields.sort(function(item1, item2){ return item1.sortNo - item2.sortNo }) }else{ localInfoGridFields.forEach(localInfoGridField => { if(localInfoGridField.sortNo == undefined){ localInfoGridField.sortNo = SortNoUtil.newSortNo() } }) localInfoGridFields.sort(function(item1, item2){ return item1.sortNo - item2.sortNo }) } }, errorData => { Common.processException(errorData) }) } }, }