| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- var UserStorageResource = require("../../common/UserStorageResource.js");
- module.exports = {
- 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);
- });
- }
- },
- }
|