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.

890 lines
29 KiB
JavaScript

10 months ago
Ext.namespace('Shipping');
Shipping.SysTaskIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.SysTaskIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.SysTaskIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 30
});
//#region 任务状态
this.TaskStatestore = Ext.create('Ext.data.Store', {
model: 'SysTaskStatemb',
remoteSort: true,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/SysMng/SysTask/GetTaskState',
reader: {
idProperty: 'ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.TaskStatestore2 = Ext.create('Ext.data.Store', {
model: 'SysTaskStatemb'
});
this.column1 = [
{
dataIndex: 'ID', hidden: true,
header: 'ID',
width: 80
},
{
dataIndex: 'STATEKEY', //hidden: true,
header: 'KEY',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
dataIndex: 'NAME',
header: '名称',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'DESCRIPTION',
header: '说明',
width: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP1',
header: '属性1',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP2',
header: '属性2',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP3', hidden: true,
header: '属性3',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP4', hidden: true,
header: '属性4',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP5',hidden:true,
header: '属性5',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
this.Pagenum1 = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick(1);
}
}
}
});
this.cellEdit1 = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
//this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.TaskStateList = new Ext.grid.GridPanel({
store: this.TaskStatestore,
enableHdMenu: false,
//width: 300,
region: 'center',
title:'任务状态',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
//selModel: this.MainCB,
viewConfig: {
enableTextSelection: true
},
plugins: [this.cellEdit1],
columns: [],
tbar: [{
//text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.TaskStatestore.load({
callback: function (r, options, success) {
this.LoadCombox(1);
},
scope: this
});
},
scope: this
}, {
//text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(1);
},
scope: this
}, {
//text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelClick(1);
},
scope: this
},'-', {
//text: '删除明细',
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(1);
},
scope: this
}],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.TaskStatestore,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum1]
});
this.column1.unshift(new Ext.grid.RowNumberer());
this.TaskStateList.reconfigure(this.TaskStatestore, this.column1);
//#endregion
//#region 任务执行
this.TaskExecutionstore = Ext.create('Ext.data.Store', {
model: 'SysTaskExecutionmb',
remoteSort: true,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/SysMng/SysTask/GetTaskExecution',
reader: {
idProperty: 'ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.TaskExecutionstore2 = Ext.create('Ext.data.Store', {
model: 'SysTaskExecutionmb'
});
this.column2 = [
{
dataIndex: 'ID', hidden: true,
header: 'ID',
width: 80
},
{
dataIndex: 'DESCRIPTION',
header: '名称',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP1',
header: '属性1',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP2',
header: '属性2',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP3', hidden: true,
header: '属性3',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP4', hidden: true,
header: '属性4',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP5', hidden: true,
header: '属性5',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
this.Pagenum2 = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick(2);
}
}
}
});
//this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.cellEdit2 = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.TaskExecutionList = new Ext.grid.GridPanel({
store: this.TaskExecutionstore,
enableHdMenu: false,
width: 300,
region: 'west',
title: '任务执行类型',
//bodyStyle: 'border-width:0 0 0 0;',
//columnWidth: 180,
//width: 180,
//height: 500,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
//selModel: this.MainCB,
viewConfig: {
enableTextSelection: true
},
plugins: [this.cellEdit2],
columns: [],
tbar: [{
//text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.TaskExecutionstore.load({
callback: function (r, options, success) {
this.LoadCombox(2);
},
scope: this
});
},
scope: this
}, {
//text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(2);
},
scope: this
}, {
//text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelClick(2);
},
scope: this
}, '-', {
//text: '删除明细',
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(2);
},
scope: this
}],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.TaskExecutionstore,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum2]
});
this.column2.unshift(new Ext.grid.RowNumberer());
this.TaskExecutionList.reconfigure(this.TaskExecutionstore, this.column2);
//#endregion
//#region 下拉框参照
this.comboxExecution = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '任务执行',
store: this.TaskExecutionstore2,
name: 'EXECUTIONID', id: "EXECUTIONIDcmb",
valueField: 'ID',
displayField: 'DESCRIPTION'
});
this.comboxStart = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '开始状态',
store: this.TaskStatestore2,
name: 'CURRENTSTATEID', id: "CURRENTSTATEIDcmb",
valueField: 'ID',
displayField: 'NAME'
});
this.comboxEnd = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '结束状态',
store: this.TaskStatestore2,
name: 'FINISHSTATEID', id: "FINISHSTATEIDcmb",
valueField: 'ID',
displayField: 'NAME'
});
//#endregion
//#region 任务进度索引
this.TaskProgressIndexstore = Ext.create('Ext.data.Store', {
model: 'SysTaskProgressIndexmb',
remoteSort: true,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/SysMng/SysTask/GetTaskProgressIndex',
reader: {
idProperty: 'ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column3 = [
{
dataIndex: 'ID',hidden:true,
header: 'ID',
width: 80
},
{
dataIndex: 'EXECUTIONID',
header: '任务执行类型',
width: 80,
editor: this.comboxExecution,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.EXECUTIONREF;
}
},
{
dataIndex: 'EXECUTIONREF', hidden: true,
header: 'EXECUTIONREF',
width: 80
},
{
dataIndex: 'DESCRIPTION',
header: '说明',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'CURRENTSTATEID',
header: '开始任务状态',
width: 80,
editor: this.comboxStart,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.CURRENTSTATEREF;
}
},
{
dataIndex: 'CURRENTSTATEREF', hidden: true,
header: 'CURRENTSTATEREF',
width: 80
},
{
dataIndex: 'FINISHSTATEID',
header: '结束任务状态',
width: 80,
editor: this.comboxEnd,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.FINISHSTATEREF;
}
},
{
dataIndex: 'FINISHSTATEREF', hidden: true,
header: 'FINISHSTATEREF',
width: 80
},
{
dataIndex: 'PROP1',
header: '属性1',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP2',
header: '属性2',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP3',
header: '属性3',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP4',
header: '属性4',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'PROP5',
header: '属性5',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
this.Pagenum3 = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick(2);
}
}
}
});
//this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.cellEdit3 = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.TaskProgressIndexList = new Ext.grid.GridPanel({
store: this.TaskProgressIndexstore,
enableHdMenu: false,
//columnWidth: 1,
region: 'center',
title: '任务进度索引',
//bodyStyle: 'border-width:0 0 0 0;',
//columnWidth: 180,
//width: 180,
//height: 500,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
//selModel: this.MainCB,
viewConfig: {
enableTextSelection: true
},
plugins: [this.cellEdit3],
columns: [this.column3],
tbar: [{
//text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.TaskProgressIndexstore.load();
},
scope: this
}, {
//text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick(3);
},
scope: this
}, {
//text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelClick(3);
},
scope: this
}, '-', {
//text: '删除明细',
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(3);
},
scope: this
}],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.TaskProgressIndexstore,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum2]
});
this.column3.unshift(new Ext.grid.RowNumberer());
this.TaskProgressIndexList.reconfigure(this.TaskProgressIndexstore, this.column3);
//#endregion
Ext.apply(this, {
layout: "border",
bodyStyle: 'border-width:0 0 0 0;',
//items: [this.TaskStateList
// , this.TaskExecutionList, this.TaskProgressIndexList
//]
items: [this.TaskStateList]
});
this.TaskProgressIndexList.on('edit', function (editor, e, eOpts) {
this.AfterEdit(editor, e, eOpts);
}, this);
this.Loaddata();
//#endregion
}, //end initUIComponents
Loaddata: function () {
this.TaskStatestore.load({
callback: function (r, options, success) {
this.LoadCombox(1);
},
scope: this
});
this.TaskExecutionstore.load({
callback: function (r, options, success) {
this.LoadCombox(2);
},
scope: this
});
this.TaskProgressIndexstore.load();
},
LoadCombox: function (type) {
_this = this;
if (type == 1) {
this.TaskStatestore2.removeAll();
this.TaskStatestore.each(function(record) {
_this.TaskStatestore2.add(record);
});
}
if (type == 2) {
this.TaskExecutionstore2.removeAll();
this.TaskExecutionstore.each(function (record) {
_this.TaskExecutionstore2.add(record);
});
}
},
AfterEdit: function (editor, e, eOpts) {
if (e.field == 'EXECUTIONID') {
SetComboxValue(this.TaskExecutionstore, e, 'ID', 'DESCRIPTION', 'EXECUTIONREF');
}
if (e.field == 'CURRENTSTATEID') {
SetComboxValue(this.TaskStatestore, e, 'ID', 'NAME', 'CURRENTSTATEREF');
}
if (e.field == 'FINISHSTATEID') {
SetComboxValue(this.TaskStatestore, e, 'ID', 'NAME', 'FINISHSTATEREF');
}
},
onAddClick: function (type) {
if (type == 1) {
var record = Ext.create('SysTaskStatemb', {
'ID': '0',
'NAME': '',
'DESCRIPTION': '',
'PROP1': '',
'PROP2': '',
'PROP3': '',
'PROP4': '',
'PROP5': ''
});
this.TaskStatestore.add(record);
var n = this.TaskStatestore.getCount();
this.cellEdit1.startEditByPosition({ row: n - 1, column: 2 });
}
if (type == 2) {
var record = Ext.create('SysTaskExecutionmb', {
'ID': '0',
//'NAME': '',
'DESCRIPTION': '',
'PROP1': '',
'PROP2': '',
'PROP3': '',
'PROP4': '',
'PROP5': ''
});
this.TaskExecutionstore.add(record);
var n = this.TaskExecutionstore.getCount();
this.cellEdit2.startEditByPosition({ row: n - 1, column: 2 });
}
if (type == 3) {
var record = Ext.create('SysTaskProgressIndexmb', {
'ID': '0',
'EXECUTIONID': '',
'EXECUTIONREF': '',
'DESCRIPTION': '',
'CURRENTSTATEID': '',
'CURRENTSTATEREF': '',
'FINISHSTATEID': '',
'FINISHSTATEREF': '',
'PROP1': '',
'PROP2': '',
'PROP3': '',
'PROP4': '',
'PROP5': ''
});
this.TaskProgressIndexstore.add(record);
var n = this.TaskProgressIndexstore.getCount();
this.cellEdit3.startEditByPosition({ row: n - 1, column: 2 });
}
},
onSaveClick: function (type) {
this.storeList='';
if (type == 1) {
var names = [];
for (var i = 0; i < this.TaskStatestore.getCount() ; i += 1) {
r = this.TaskStatestore.getAt(i);
data = r.data;
if (Ext.Array.indexOf(names, data.NAME, 0) > 0) {
alert("名称重复");
return;
} else {
Ext.Array.include(names, data.NAME);
}
}
this.storeList = this.TaskStatestore;
}
if (type == 2) {
var names = [];
for (var i = 0; i < this.TaskExecutionstore.getCount() ; i += 1) {
r = this.TaskExecutionstore.getAt(i);
data = r.data;
if (Ext.Array.indexOf(names, data.DESCRIPTION, 0) > 0) {
alert("名称重复");
return;
} else {
Ext.Array.include(names, data.DESCRIPTION);
}
}
this.storeList = this.TaskExecutionstore;
}
if (type == 3) {
this.storeList = this.TaskProgressIndexstore;
}
var datas = [];
for (var i = 0; i < this.storeList.getCount() ; i += 1) {
data = this.storeList.getAt(i);
if (data.dirty == true) {
//if (this.checkinput(data.data) == true) {
datas.push(data);
//} else {
// return;
//}
}
}
SaveBody = ConvertRecordsToJsonAll(datas);
if (SaveBody == "") return;
//var jsonBody = ConvertRecordsToJson(data);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SysMng/SysTask/Save' + type,
scope: this,
params: {
data: SaveBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
if (type == 1) {
this.TaskStatestore.load({
callback: function (r, options, success) {
this.LoadCombox(1);
},
scope: this
});
}
if (type == 2) {
this.TaskExecutionstore.load({
callback: function (r, options, success) {
this.LoadCombox(2);
},
scope: this
});
}
if (type == 3) {
this.TaskProgressIndexstore.load();
}
} 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
});
}
}
});
},
onDelClick: function (type) {
if (type == 1) {
var selections = this.TaskStateList.getSelectionModel().getSelection();
}
if (type == 2) {
var selections = this.TaskExecutionList.getSelectionModel().getSelection();
}
if (type == 3) {
var selections = this.TaskProgressIndexList.getSelectionModel().getSelection();
}
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选中一条数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var record = selections[0];
Ext.MessageBox.confirm('提示!', '注意!将会删除一条数据\n确定删除该记录吗', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/SysMng/SysTask/Delete'+type,
params: {
data: Ext.JSON.encode(record.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.hide();
if (type == 1) {
this.TaskStatestore.remove(record);
this.LoadCombox(1);
}
if (type == 2) {
this.TaskExecutionstore.remove(record);
this.LoadCombox(2);
}
if (type == 3) {
this.TaskProgressIndexstore.remove(record);
}
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
});