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/SoftMng/Viewsjs/MsSoftSysTable/MsSoftSysTableEdit.js

1156 lines
38 KiB
JavaScript

3 years ago
Ext.namespace('Shipping');
Shipping.MsSoftSysTableEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsSoftSysTableEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsSoftSysTableEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
editFactryRecord: null,
FactryStatus: 'add',
initUIComponents: function () {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.Loading = true;
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
region: 'center',
frame: true,
bodyPadding: 5,
autoScroll: true,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 70,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID', flex: 0, hidden: true, margins: '0'
}, {
fieldLabel: '表名',
allowBlank: true,
flex: 1,
name: 'TBLNAME'
}, {
fieldLabel: '中文名',
allowBlank: true,
flex: 1,
name: 'TBLCNAME'
}, {
fieldLabel: '相关模块',
allowBlank: true,
flex: 1,
name: 'MODULENAME'
}]
}, { xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'textareafield',
grow: true,
flex: 2,
height: 50,
fieldLabel: '说明',
name: 'REMARKS',
anchor: '100%'
}, {
xtype: 'container',
layout: 'anchor',
flex: 1,
defaultType: 'textfield',
items: [{
fieldLabel: '录入人',
readOnly: true,
disabled: true,
name: 'INPUTBYREF'
}, {
fieldLabel: '录入日期',
readOnly: true,
disabled: true,
name: 'INPUTTIME'
}]
}]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
id: 'btnEPrev',
text: "上一条",
// iconCls: "btnsave",
handler: function (button, event) {
this.PrevRecord();
},
scope: this
}, {
id: 'btnENext',
text: "下一条",
// iconCls: "btnsave",
handler: function (button, event) {
this.NextRecord();
},
scope: this
}, {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
},
'-',
{
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
},
'-',
{
id: 'btnECopyNew',
text: "复制新建",
handler: function (button, event) {
var basicForm = this.formEdit.getForm();
this.opStatus = 'add';
basicForm.findField('GID').setDisabled(false);
var field = basicForm.findField('GID');
field.setValue(NewGuid());
basicForm.findField('GID').setDisabled(true);
field = basicForm.findField('INPUTBYREF');
field.setValue(SHOWNAME);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("VERGID", '*');
memberbody.commit();
};
},
scope: this
}, '-', {
id: 'btnSubmitAudit',
text: '提交审核',
tooltip: '提交审核',
handler: function (button, event) {
this.onSubmitAuditClick();
},
scope: this
}, '-', {
id: 'btnSubmitAuditBack',
text: '撤销审核',
tooltip: '撤销审核',
handler: function (button, event) {
this.onSubmitAuditBackClick();
},
scope: this
}, '-', {
text: "审核通过",
id: 'btnAudit',
iconCls: "btnadd",
handler: function (button, event) {
this.onAuditClick();
},
scope: this
},
'-',
{
text: "驳回提交",
id: 'btnAuditBack',
iconCls: "btndelete",
handler: function (button, event) {
this.onAuditBackClick();
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 字段
this.storeBodyList = Ext.create('Ext.data.Store', {
model: 'MsSysTableDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/SoftMng/MsSoftSysTable/GetTableDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.storeTBLNAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsSysTable',
proxy: { url: '/SoftMng/MsSoftSysTable/GetDataList' }
});
this.storeTBLNAME.load();
this.comboTBLNAME = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeTBLNAME,
forceSelection: true,
name: 'LNKTBL',
valueField: 'TBLNAME',
displayField: 'TBLNAME',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
var recs = DsStoreQueryBy(this.storeTBLNAME, 'GID', records[0].data.GID);
if (recs.getCount() > 0) {
var data = recs.getAt(0).data;
var s = "TBLGID='" + data.GID + "'";
this.storeTBLFIELDNAME.load({ params: { condition: s} });
} else {
}
}
}
}
});
this.storeTBLFIELDNAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsSysTableDetail',
proxy: { url: '/SoftMng/MsSoftSysTable/GetTableDetailList' }
});
this.comboTBLFIELDNAME = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeTBLFIELDNAME,
forceSelection: true,
name: 'LNKFIELDNAME',
valueField: 'FIELDNAME',
displayField: 'FIELDNAME'
});
//明细表表格
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.StoreFIELDTYPE = Ext.create('Ext.data.Store', {
fields: ['FieldType']
});
this.StoreFIELDTYPE.add({ "FieldType": "bit" });
this.StoreFIELDTYPE.add({ "FieldType": "char" });
this.StoreFIELDTYPE.add({ "FieldType": "date" });
this.StoreFIELDTYPE.add({ "FieldType": "datetime" });
this.StoreFIELDTYPE.add({ "FieldType": "decimal" });
this.StoreFIELDTYPE.add({ "FieldType": "float" });
this.StoreFIELDTYPE.add({ "FieldType": "image" });
this.StoreFIELDTYPE.add({ "FieldType": "int" });
this.StoreFIELDTYPE.add({ "FieldType": "nchar" });
this.StoreFIELDTYPE.add({ "FieldType": "ntext" });
this.StoreFIELDTYPE.add({ "FieldType": "varchar" });
this.StoreFIELDTYPE.add({ "FieldType": "nvarchar" });
this.StoreFIELDTYPE.add({ "FieldType": "real" });
this.StoreFIELDTYPE.add({ "FieldType": "smalldatetime" });
this.StoreFIELDTYPE.add({ "FieldType": "text" });
this.comboxFIELDTYPE = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreFIELDTYPE,
forceSelection: true,
name: 'FIELDTYPE',
valueField: 'FieldType',
displayField: 'FieldType'
});
this.StoreBool = Ext.create('Ext.data.Store', {
fields: ['BL', 'NUM']
});
this.StoreBool.add({ "BL": "是", "NUM": "1" });
this.StoreBool.add({ "BL": "否", "NUM": "0" });
this.comboxBool = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreBool,
forceSelection: true,
valueField: 'NUM',
displayField: 'BL'
});
this.gridListTableItems = new Ext.grid.GridPanel({
store: this.storeBodyList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
tbar: [{
text: '增加明细',
tooltip: '增加明细',
id: "btnadddetail",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetail();
},
scope: this
}, '-', {
text: '提取表结构',
tooltip: '增加明细',
id: "btnadddetail2",
iconCls: "btnadddetail",
handler: function (button, event) {
this.addDetailDef();
},
scope: this
}, '-', {
text: '删除明细',
tooltip: '删除明细',
id: "btndeldetail",
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelTableClick();
},
scope: this
}],
columns: [{
sortable: true,
dataIndex: 'GID',
header: '编号',
hidden: true,
width: 0
}, {
sortable: true,
dataIndex: 'TBLGID',
header: '业务编号',
hidden: true,
width: 0
}, {
dataIndex: 'FIELDNAME',
header: '字段名',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'FIELDCNAME',
header: '中文名',
width: 100,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'FIELDTYPE',
header: '字段类型',
width: 90,
editor: this.comboxFIELDTYPE
}, {
dataIndex: 'FIELDLEN',
header: '长度',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'ISKEY',
header: '是否主键',
width: 90,
editor: this.comboxBool,
renderer: function (value, p, record) {
if (value == '1')
return '是';
else return '否';
}
}, {
sortable: true,
dataIndex: 'ISNULL',
header: '允许为空',
width: 90,
editor: this.comboxBool,
renderer: function (value, p, record) {
if (value == '1')
return '是';
else return '否';
}
}, {
dataIndex: 'DEFVALUE',
header: '默认值',
width: 60,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
dataIndex: 'LNKTBL',
header: '关联表',
width: 140,
editor: this.comboTBLNAME
}, {
dataIndex: 'LNKFIELDNAME',
header: '关联字段',
width: 120,
editor: this.comboTBLFIELDNAME
}, {
dataIndex: 'SORT',
header: '排序',
width: 40,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
}, {
sortable: true,
dataIndex: 'REMARKS',
hidded: true,
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true,
enableKeyEvents: true
},
width: 150
}]
});
// this.gridListTableItems.on('edit', function (editor, e, eOpts) {
// this.gridListAfterEdit(editor, e, eOpts);
// }, this);
this.panelTableItems = new Ext.Panel({
title: '字段明细',
layout: "border",
region: 'center',
animate: true,
frame: false,
items: [this.gridListTableItems]
});
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 160,
items: [this.panelBtn, this.formEdit]
});
this.tabWTpanel = new Ext.TabPanel({
activeTab: 0,
autoWidth: true,
border: true,
frame: false,
region: 'center',
enableTabScroll: true,
items:
[
this.panelTableItems
]
});
Ext.apply(this, {
items: [this.panelTop, this.tabWTpanel]
});
//#endregion
//绑定查询窗体
this.storeBodyList.on('beforeload', function (store) {
var acondition = " VERGID='" + this.editRecord.get('GID') + "'";
Ext.apply(store.proxy.extraParams, { condition: acondition });
}, this);
this.ParentWin = window.parent.opener;
//初始化数据
this.InitData();
var btnAudit = Ext.getCmp('btnAudit');
var btnAuditBack = Ext.getCmp('btnAuditBack');
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "AUDITSQL"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
btnAudit.disable();
btnAuditBack.disable();
} else {
btnAudit.enable();
btnAuditBack.enable();
}
} else {
}
},
scope: this
});
//绑定事件
}, //end initUIComponents
InitData: function () {
this.opStatus = 'add';
this.FactryStatus = 'add';
var condition = '';
if (this.ParentWin) {
var ret = this.ParentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit')
condition = " GID='" + this.editRecord.get('GID') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
LoadData: function (opstatus, condition) {
this.serialNo = 0;
this.workSerialNo = 0;
this.bodyDel = [];
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SoftMng/MsSoftSysTable/GetData',
params: {
handle: opstatus,
condition: condition
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
if (this.opStatus == 'edit') {
var acondition = " TBLGID='" + this.editRecord.get('GID') + "'";
this.storeBodyList.load({ params: { condition: acondition} });
}
this.GetEditStatus();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
if (!basicForm.isValid()) {
return;
}
basicForm.findField('GID').setDisabled(false);
var data = basicForm.getValues();
basicForm.findField('GID').setDisabled(true);
if (this.opStatus == 'add') {
data.GID = NewGuid();
}
var bodydatas = [];
for (var i = 0; i < this.storeBodyList.getCount(); i += 1) {
var member = this.storeBodyList.getAt(i);
bodydatas.push(member);
}
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SoftMng/MsSoftSysTable/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.insert(0, returnData);
this.editRecord = this.StoreList.getAt(0);
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysTable', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
basicForm.findField('GID').setDisabled(true);
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("TBLGID", this.editRecord.get('GID'));
memberbody.commit();
};
} else if (type == '1') {
for (var j = 0; j < this.storeBodyList.getCount(); j += 1) {
var memberbody = this.storeBodyList.getAt(j);
memberbody.set("TBLGID", this.editRecord.get('GID'));
memberbody.commit();
};
window.close();
} else {
this.LoadData('add', '');
basicForm.findField('GID').setDisabled(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
});
}
}
});
}, //end save
addDetail: function () {
var MSDSID = this.formEdit.getForm().findField('GID').getValue();
//var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo);
var record = Ext.create('MsSysTableDetail', {
GID: NewGuid(),
TBLGID: '*',
FIELDNAME: '',
FIELDCNAME: '',
FIELDTYPE: 'varchar',
FIELDLEN: '60',
ISNULL: '1',
ISKEY: '0',
LNKTBL: '',
LNKFIELDNAME: '',
REMARKS: ''
});
this.storeBodyList.add(record);
var n = this.storeBodyList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 });
},
addDetailDef: function () {
var TABLENAME = this.formEdit.getForm().findField('TBLNAME').getValue();
var storedefdetail = Ext.create('Ext.data.Store', {
model: 'MsSysTableDetail',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/SoftMng/MsSoftSysTable/GetDefTableDetailList',
reader: {
id: 'FIELDNAME',
root: 'data',
totalProperty: 'totalCount'
}
}
});
storedefdetail.load({ params: { tablename: TABLENAME },
callback: function (r, options, success) {
if (success) {
var jsonresult = Ext.JSON.decode(options.response.responseText);
if (storedefdetail.getCount() > 0) {
for (var j = 0; j < storedefdetail.getCount(); j += 1) {
var member = storedefdetail.getAt(j);
var selectrecords = DsStoreQueryBy(_this.storeBodyList, 'FIELDNAME', member.data.FIELDNAME);
if (selectrecords.length > 0) {
} else {
var record = Ext.create('MsSysTableDetail', {
GID: NewGuid(),
TBLGID: '*',
FIELDNAME: member.data.FIELDNAME,
FIELDCNAME: member.data.FIELDCNAME,
FIELDTYPE: member.data.FIELDTYPE,
FIELDLEN: member.data.FIELDLEN,
ISNULL: member.data.ISNULL,
ISKEY: member.data.ISKEY,
LNKTBL: '',
LNKFIELDNAME: '',
SORT: member.data.SORT,
REMARKS: member.data.REMARKS
});
_this.storeBodyList.add(record);
}
}
}
}
}
}
);
},
onDelTableClick: function () {
var selections = this.gridListTableItems.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
var GID = this.formEdit.getForm().findField('GID').getValue();
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
var bodyAddDatas = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
bodyAddDatas.push(rec);
}
var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas);
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/SoftMng/MsSoftSysTable/DeleteTableDetail',
params: {
data: jsonbodyAddDatas
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var acondition = " TBLGID='" + GID + "'";
this.storeBodyList.load({ params: { condition: acondition} });
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
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);
},
onSubmitAuditClick: function () {
var Duino = this.formEdit.getForm().findField('GID').getValue();
var billstatus = this.formEdit.getForm().findField('UPSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存语句,然后才能提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if ((billstatus != '新增') && (billstatus != '驳回提交')) {
Ext.Msg.show({ title: '提示', msg: '当前状态无法提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/SoftMng/MsSoftUpGrade/SubmitAudit',
params: {
bill: Duino,
type: 2
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
var returnData = result.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysUpdateSql', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.GetEditStatus();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onSubmitAuditBackClick: function () {
var Duino = this.formEdit.getForm().findField('GID').getValue();
var billstatus = this.formEdit.getForm().findField('UPSTATUS').getValue();
if (Duino == '*') {
Ext.Msg.show({ title: '提示', msg: '请先保存语句,然后才能撤销提交审核!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
if (billstatus != '提交审核') {
Ext.Msg.show({ title: '提示', msg: '当前状态无法撤销提交!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
_this = this;
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/SoftMng/MsSoftUpGrade/SubmitAudit',
params: {
bill: Duino,
type: 1
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
Ext.Msg.show({
title: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
} else {
var returnData = result.Data;
this.formEdit.getForm().setValues(returnData);
if (this.opStatus == 'edit') {
var editp = Ext.create('MsSysUpdateSql', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
this.GetEditStatus();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
// #region 根据权限和状态判断是否允许修改
GetEditStatus: function () {
var canedit = false;
var btnESubmitAudit = Ext.getCmp('btnSubmitAudit');
var btnESubmitAuditBack = Ext.getCmp('btnSubmitAuditBack');
var bsStatus = '新增';
var op = this.formEdit.getForm().findField('INPUTBYREF').getValue();
_this = this;
if (SHOWNAME == op) {
if (bsStatus == '提交审核') {
btnESubmitAuditBack.enable();
btnESubmitAudit.disable();
_this.setSaveBtnStatus(false);
} else if (bsStatus == '新增' || bsStatus == '新建' || bsStatus == '驳回提交') {
btnESubmitAuditBack.disable();
btnESubmitAudit.enable();
_this.setSaveBtnStatus(true);
} else {
btnESubmitAuditBack.disable();
btnESubmitAudit.disable();
_this.setSaveBtnStatus(false);
}
} else {
btnESubmitAudit.disable();
btnESubmitAuditBack.disable();
_this.setSaveBtnStatus(false);
}
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnadddetail');
var btnEDeleteDetail = Ext.getCmp('btndeldetail');
this.canedit = enable;
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnEDeleteDetail.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnEDeleteDetail.disable();
}
},
// #endregion
PrevRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == 0) {
Ext.Msg.show({ title: '警告', msg: '已是最前一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
if (j == this.StoreList.count) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j - 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
NextRecord: function () {
var modifystr = this.getIsModify();
if (modifystr != "") {
Ext.Msg.show({ title: '警告', msg: modifystr + '未保存,如果离开此页,将丢失未保存的更改 ', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var j = this.StoreList.indexOf(this.editRecord);
if (j == (this.StoreList.data.length - 1)) {
Ext.Msg.show({ title: '警告', msg: '已是最后一票', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var condition = '';
j = j + 1;
this.editRecord = this.StoreList.getAt(j);
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
//this.storeBodyList.load({ params: { condition: condition} });
}
this.LoadData(this.opStatus, condition);
},
getIsModify: function () {
if (panelEdit.formEdit.getForm().isDirty() == true) {
return '升级信息';
}
else return '';
} //
});