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/SysMng/ViewJs/SysTask/ExecutionIndex.js

371 lines
12 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
Shipping.SysTaskExecution = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.SysTaskExecution.superclass.constructor.call(this);
};
Ext.extend(Shipping.SysTaskExecution, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { //行号
width: 30
});
//#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.column2 = [
{
dataIndex: 'ID',
header: 'ID',
width: 40,
hidden: true,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
}, {
dataIndex: 'STATEKEY',
header: 'KEY',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
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: '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.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
Ext.apply(this, {
layout: "border",
bodyStyle: 'border-width:0 0 0 0;',
items: [//this.TaskStateList
this.TaskExecutionList
//, this.TaskProgressIndexList
]
});
this.Loaddata();
}, //end initUIComponents
Loaddata: function () {
this.TaskExecutionstore.load({
callback: function (r, options, success) {
},
scope: this
});
},
onAddClick: function () {
var record = Ext.create('SysTaskExecutionmb', {
'ID': '0',
'STATEKEY':'0',
'NAME': '',
'DESCRIPTION': '',
'PROP1': '',
'PROP2': ''
});
this.TaskExecutionstore.add(record);
var n = this.TaskExecutionstore.getCount();
this.cellEdit2.startEditByPosition({ row: n - 1, column: 2 });
},
onSaveClick: function (type) {
this.storeList='';
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;
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/Save2' ,
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) {
this.TaskExecutionstore.load({
callback: function (r, options, success) {
//this.LoadCombox(2);
},
scope: this
});
} 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);
}
});