You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/Import/Viewsjs/Comm/SaveGridPanel.js

439 lines
16 KiB
JavaScript

3 years ago
Ext.namespace('DsTruck');
Ext.define('GridPanelShowmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'USERID', type: 'string' },
{ name: 'FORMNAME', type: 'string' },
{ name: 'DATAORDER', type: 'string' },
{ name: 'dataIndex', type: 'string' },
{ name: 'header', type: 'string' },
{ name: 'width', type: 'string' },
{ name: 'hidden', type: 'string' },
{ name: 'sortable', type: 'string'}/*,
{ name: 'editor', type: 'string' },
{ name: 'renderer', type: 'string' }*/
]
});
DsTruck.SaveGridPanel = function (USERID, FORMNAME, gridcolumns) {
var savecolumn = gridcolumns;
var storeGridPanel = Ext.create('Ext.data.Store', {
model: 'GridPanelShowmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/GridPanelShow/GetDataList',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
}
});
var _i = 0;
Ext.each(savecolumn, function (item) {
var hidden = '0';
var sortable = '0';
if (item.hidden == true) {
hidden = '1';
}
if (item.sortable == true) {
sortable = '1';
}
if (item.dataIndex != "") {
var record = Ext.create('GridPanelShowmb', {
'USERID': USERID,
'FORMNAME': FORMNAME,
'DATAORDER': _i,
'dataIndex': item.dataIndex,
'header': item.text,
'text': item.text,
'width': item.width,
'hidden': hidden,
'sortable': sortable
});
storeGridPanel.add(record);
_i++;
}
if (item.items.length != 0) {
var columnsitems = item.items.items;
Ext.each(columnsitems, function (item) {
var hidden = '0';
var sortable = '0';
if (item.hidden == true) {
hidden = '1';
}
if (item.sortable == true) {
sortable = '1';
}
if (item.dataIndex != "") {
var record = Ext.create('GridPanelShowmb', {
'USERID': USERID,
'FORMNAME': FORMNAME,
'DATAORDER': _i,
'dataIndex': item.dataIndex,
'header': item.text,
'text': item.text,
'width': item.width,
'hidden': hidden,
'sortable': sortable
});
storeGridPanel.add(record);
_i++;
}
});
}
}); //循环end
var GridPaneldatas = [];
for (var i = 0; i < storeGridPanel.getCount(); i += 1) {
var member = storeGridPanel.getAt(i);
GridPaneldatas.push(member);
}
var GridPanelBody = ConvertRecordsToJsonAll(GridPaneldatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/GridPanelShow/Save',
scope: this,
async: false,
params: {
GridPanelBody: GridPanelBody,
USERID: USERID,
FORMNAME: FORMNAME
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
};
DsTruck.SaveGridPanel = function (USERID, FORMNAME, gridcolumns, midcolumn, start, havecheckbox) {
var savecolumn = gridcolumns;
var _midcolumn = midcolumn;
var storeGridPanel = Ext.create('Ext.data.Store', {
model: 'GridPanelShowmb',
remoteSort: false,
proxy: {
type: 'ajax',
url: '/Import/GridPanelShow/GetDataList',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
}
});
var _i = 0;
Ext.each(savecolumn, function (item) {
var hidden = '0';
var sortable = '0';
if (item.hidden == true) {
hidden = '1';
}
if (item.sortable == true) {
sortable = '1';
}
if (item.dataIndex != "") {
var record = Ext.create('GridPanelShowmb', {
//'id': _midcolumn[_i].id, //item.id,
'USERID': USERID,
'FORMNAME': FORMNAME,
'DATAORDER': _i,
'dataIndex': item.dataIndex,
'header': item.text,
'text': item.text,
'width': item.width,
'hidden': hidden,
'sortable': sortable
});
storeGridPanel.add(record);
_i++;
}
if (item.items.length != 0) {
var columnsitems = item.items.items;
Ext.each(columnsitems, function (item) {
var hidden = '0';
var sortable = '0';
if (item.hidden == true) {
hidden = '1';
}
if (item.sortable == true) {
sortable = '1';
}
if (item.dataIndex != "") {
var record = Ext.create('GridPanelShowmb', {
'USERID': USERID,
'FORMNAME': FORMNAME,
'DATAORDER': _i,
'dataIndex': item.dataIndex,
'header': item.text,
'text': item.text,
'width': item.width,
'hidden': hidden,
'sortable': sortable
});
storeGridPanel.add(record);
_i++;
}
});
}
}); //循环end
var GridPaneldatas = [];
for (var i = 0; i < storeGridPanel.getCount(); i += 1) {
var member = storeGridPanel.getAt(i);
if (member.data.header != '&#160;')
GridPaneldatas.push(member);
}
var GridPanelBody = ConvertRecordsToJsonAll(GridPaneldatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/Import/GridPanelShow/Save',
scope: this,
async: false,
params: {
GridPanelBody: GridPanelBody,
USERID: USERID,
FORMNAME: FORMNAME
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
/*
for (var _i = 0; _i < returnData.length; _i++) {
_midcolumn[_i + start].id = returnData[_i].id;
_midcolumn[_i + start].dataIndex = returnData[_i].dataIndex;
_midcolumn[_i + start].text = returnData[_i].header;
_midcolumn[_i + start].header = returnData[_i].header;
_midcolumn[_i + start].width = parseInt(returnData[_i].width);
if (returnData[_i].hidden == "True") {
_midcolumn[_i + start].hidden = true;
} else {
_midcolumn[_i + start].hidden = false;
}
if (returnData[_i].sortable == "True") {
_midcolumn[_i + start].sortable = true;
} else {
_midcolumn[_i + start].sortable = false;
}
}*/
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
//return _midcolumn;
};
DoSaveGridPanel = function (USERID, FORMNAME, store, grid, midcolumn, start, havecheckbox) {
result = DsTruck.SaveGridPanel(USERID, FORMNAME, grid.columns, midcolumn, start, havecheckbox);
grid.reconfigure = (store, result);
return result;
};
DoResetGridPanel = function (USERID, FORMNAME, store, grid, initcolumn, start, havecheckbox) {
grid.reconfigure = (store, initcolumn);
result = DsTruck.SaveGridPanel(USERID, FORMNAME, grid.columns, initcolumn, start, havecheckbox);
return result;
};
DsTruck.GetGridPanel = function (USERID, FORMNAME, gridcolumn, start) {
var returnData = [];
var temprec = { id: '' };
var gridc = [];
for (var _i = 0; _i < gridc.length; _i++) {
gridc[_i].id = '';
}
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/Import/GridPanelShow/GetDataList',
scope: this,
async: false,
params: { USERID: USERID, FORMNAME: FORMNAME },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
returnData = jsonresult.data;
var itemreturnData = jsonresult.data;
if (returnData.length > 0) {
for (var _i = 0; _i < returnData.length; _i++) {
for (var j = 0; j < gridcolumn.length; j++) {
if (gridcolumn[j].dataIndex == returnData[_i].dataIndex) {
gridcolumn[j].width = parseFloat(returnData[_i].width);
if (returnData[_i].hidden == "True") {
gridcolumn[j].hidden = true;
} else {
gridcolumn[j].hidden = false;
}
if (returnData[_i].sortable == "True") {
gridcolumn[j].sortable = true;
} else {
gridcolumn[j].sortable = false;
}
if (gridcolumn[j].columns != undefined) {
for (var m = 0; m < gridcolumn[j].columns.length; m++) {
for (var n = 0; n < itemreturnData.length; n++) {
if (gridcolumn[j].columns[m].dataIndex == itemreturnData[n].dataIndex) {
gridcolumn[j].columns[m].width = parseFloat(itemreturnData[n].width);
if (itemreturnData[n].hidden == "True") {
gridcolumn[j].columns[m].hidden = true;
} else {
gridcolumn[j].columns[m].hidden = false;
}
if (itemreturnData[n].sortable == "True") {
gridcolumn[j].columns[m].sortable = true;
} else {
gridcolumn[j].columns[m].sortable = false;
}
}
}
}
}
gridc.push(gridcolumn[j]);
}
}
}
var HostHave = false;
for (var j = 0; j < gridcolumn.length; j++) {
HostHave = false;
for (var _i = 0; _i < returnData.length; _i++) {
if (gridcolumn[j].dataIndex == returnData[_i].dataIndex) {
HostHave = true;
break;
}
}
if (HostHave == false && gridcolumn[j].dataIndex!="") {
gridc.push(gridcolumn[j]);
}
}
} else gridc = gridcolumn;
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});
return gridc;
};
//DsTruck.GetGridPanel = function (USERID, FORMNAME, gridcolumn, start) {
// var returnData = [];
// var temprec = { id: '' };
// var gridc = [];
// var gridc = gridcolumn;
// for (var _i = 0; _i < gridc.length; _i++) {
// gridc[_i].id = '';
// }
// Ext.Ajax.request({
// waitMsg: '正在查询数据...',
// url: '/Import/GridPanelShow/GetDataList',
// scope: this,
// async: false,
// params: { USERID: USERID, FORMNAME: FORMNAME },
// waitMsg: "正在查询数据...",
// callback: function (options, success, response) {
// if (success) {
// var jsonresult = Ext.JSON.decode(response.responseText);
// returnData = jsonresult.data;
// for (var _i = 0; _i < returnData.length; _i++) {
// gridc[_i + start].id = returnData[_i].id;
// gridc[_i + start].dataIndex = returnData[_i].dataIndex;
// gridc[_i + start].text = returnData[_i].header;
// gridc[_i + start].header = returnData[_i].header;
// gridc[_i + start].width = parseInt(returnData[_i].width);
// if (returnData[_i].hidden == "True") {
// gridc[_i + start].hidden = true;
// } else {
// gridc[_i + start].hidden = false;
// }
// if (returnData[_i].sortable == "True") {
// gridc[_i + start].sortable = true;
// } else {
// gridc[_i + start].sortable = false;
// }
// //gridc[_i].sortable = returnData[_i].sortable;
// }
// } else {
// Ext.Msg.show({ title: '请重试',
// msg: '服务器响应出错',
// icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
// });
// return;
// }
// }
// });
// return gridc;
//};