| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- import UserStorageResource from '../../common/UserStorageResource.js';
- import Common from '../../common/Common.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 => {
- // if(successData.errorCode != 0) {
- // Notify.error('提示', successData.errorMessage, false);
- // return;
- // }
- var remoteInfoFilterFields = null;
- if (successData.data != null) {
- remoteInfoFilterFields = JSON.parse(successData.data);
- }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 = 10;
- }
- });
- 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 => {
- // if(successData.errorCode != 0) {
- // Notify.error('提示', successData.errorMessage, false);
- // return;
- // }
- var remoteInfoGridFields = null;
- if (successData.data != null) {
- remoteInfoGridFields = JSON.parse(successData.data);
- }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 = 10;
- }
- });
- localInfoGridFields.sort(function(item1, item2){
- return item1.sortNo - item2.sortNo;
- });
- }
- }, errorData => {
- Common.processException(errorData);
- });
- }
- },
- };
|