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/Sys_Task_ProgressIndex.js

513 lines
16 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.Sys_Task_ProgressIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.Sys_Task_ProgressIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.Sys_Task_ProgressIndex, 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.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.comboxExecution = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '任务执行',
store: this.TaskExecutionstore,
forceSelection: true,
name: 'EXECUTIONID', id: "EXECUTIONIDcmb",
valueField: 'STATEKEY',
displayField: 'NAMEREF'
});
this.comboxStart = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '开始状态',
store: this.TaskStatestore,
forceSelection: true,
name: 'CURRENTSTATEID', id: "CURRENTSTATEIDcmb",
valueField: 'STATEKEY',
displayField: 'NAMEREF'
});
this.comboxEnd = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '结束状态',
store: this.TaskStatestore,
forceSelection: true,
name: 'FINISHSTATEID', id: "FINISHSTATEIDcmb",
valueField: 'STATEKEY',
displayField: 'NAMEREF'
});
//#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.Pagenum = 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();
}
}
}
});
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
//this.CBM = Ext.create('Ext.selection.CheckboxModel');
this.gridList = new Ext.grid.GridPanel({
store: this.TaskProgressIndexstore,
enableHdMenu: false,
region: 'center',
//title: '任务进度索引',
split: true,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
//selModel: this.CBM,
selType: 'cellmodel',
plugins: [this.cellEditing],
columns: [
new Ext.grid.RowNumberer(),
{
dataIndex: 'ID', hidden: true,
header: 'ID',
width: 80
},
{
dataIndex: 'EXECUTIONID',
header: '任务执行类型',
width: 120,
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: 120,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
},
{
dataIndex: 'CURRENTSTATEID',
header: '开始任务状态',
width: 120,
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: 120,
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
}
}
],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.TaskProgressIndexstore,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
var _this = this;
var _this = this;
this.panelBtn = new Ext.Panel({
region: "north",
title: '任务进度索引',
tbar: [{
//text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.TaskProgressIndexstore.load();
},
scope: this
}, {
//text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddClick();
},
scope: this
}, {
//text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelClick();
},
scope: this
}, '-', {
//text: '删除明细',
tooltip: '保存',
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick();
},
scope: this
}]
});
//#endregion
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 56,
items: [this.panelBtn]
});
this.panelBottom = new Ext.Panel({
layout: "border",
region: "center",
height: 80, split: true,
items: [this.gridList]
});
Ext.apply(this, {
items: [this.panelTop, this.panelBottom]
});
this.TaskExecutionstore.on('beforeload', function (store) {
//var sql = this.getCondition();
//Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.TaskStatestore.on('beforeload', function (store) {
//var sql = this.getCondition();
//Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.cellEditing.on('edit', function (editor, e, eOpts) {
this.StepAfterEdit(editor, e, eOpts);
}, this);
//this.TaskProgressIndexstore.on('edit', function (editor, e, eOpts) {
// this.StepAfterEdit(editor, e, eOpts);
//}, this);
//this.cellEdit.on('edit', function (editor, e, eOpts) {
// this.StepAfterEdit(editor, e, eOpts);
//}, this);
//this.TaskStatestore.on('edit', function (editor, e, eOpts) {
// this.StepAfterEdit(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.TaskExecutionstore.load();
this.TaskStatestore.load();
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);
// });
// }
//},
StepAfterEdit: function (editor, e, eOpts) {
if (e.field == 'EXECUTIONID') {
SetComboxValue(this.comboxExecution, e, 'EXECUTIONREF');
}
if (e.field == 'CURRENTSTATEID') {
SetComboxValue(this.comboxStart, e, 'CURRENTSTATEREF');
}
if (e.field == 'FINISHSTATEID') {
SetComboxValue(this.comboxEnd, e, 'FINISHSTATEREF');
}
},
onAddClick: function () {
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.cellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
onSaveClick: function () {
this.storeList='';
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' + 3,
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.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 () {
var selections = this.gridList.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/Delete3',
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();
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);
}
});