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/MvcShipping/Viewsjs/MsCwAccitemsGl/MsCwAccitemsGlEdit.js

947 lines
42 KiB
JavaScript

2 years ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCwAccitemsGlEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwAccitemsGlEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCwAccitemsGlEdit, Ext.Panel, {
ParentWin: null,
OpType: '',
opStatus: 'add',
StoreList: null,
editRecord: null,
Editdata: null,
initUIComponents: function () {
this.serialNo = 0;
this.itemindex = 1;
//#region formSearch 下拉框、复选框等信息加载
//科目加载
this.storeCwAccitemsGl = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
});
//this.storeCwAccitemsGl.load({ params: { condition: "PACCGID='" + this.OpType + "'"} });
this.storeCwAccitemsGl.load({
waitMsg: '正在查询数据...',
scope: this,
callback: function (options, success, response) {
var record = Ext.create('DsShipping.ux.CwAccitemsGlModel', {
GID: 'ext-record-207',
ACCID: '',
ACCNAME: '',
ACCIDNAME: '',
DETAILED: false,
DC: '',
ISFCY: false,
ISDEPTACC: false, //核算部门,按规则设置生成
ISEMPLACC: false, //核算人员,按规则设置生成
ISCORPACC: false, //核算客户,按规则设置生成
ISITEMACC: false, //核算项目,按规则设置生成
REMARKS: '',
YEAR: '',
MONTH: '',
PACCGID: '',
ACCATTRIBUTE: '', //科目属性(资产、负债、共同、权益、成本、损益)
//ISENABLE: '',
id: 'ext-record-207',
NAME: '',
ACCTYPE: '', //科目类别
leaf: false,
expanded: false,
DR: 0,
CR: 0,
PACCNAME: '',
ISBANK: false,
ISSETTLEMENT: false,
});
this.storeCwAccitemsGl.add(record);
}
});
this.comboxPACCID = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '父类科目',
store: this.storeCwAccitemsGl,
//forceSelection: true,
id: 'PACCID',
name: 'PACCID',
valueField: 'ACCID',
displayField: 'ACCIDNAME',
//allowBlank: false
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (combo.value.toString() != "") {
if (this.opStatus == "edit") {
if (this.editRecord.data.PACCGID.toString() == "ZC" || this.editRecord.data.PACCGID.toString() == "FZ" || this.editRecord.data.PACCGID.toString() == "GT" || this.editRecord.data.PACCGID.toString() == "QY" || this.editRecord.data.PACCGID.toString() == "CB" || this.editRecord.data.PACCGID.toString() == "SY") {
combo.setValue("");
Ext.Msg.show({ title: '提示', msg: "父类科目不允许改为子科目!", icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK });
}
}
}
this.onBtnDisable();
},
'blur': function (combo, records, eOpts) {
this.onBtnDisable();
}
}
});
//科目类别
Ext.define('ACCATTRIBUTEModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] });
var dataACCATTRIBUTE = [{ "Name": "资产" }, { "Name": "负债" }, { "Name": "共同" }, { "Name": "权益" }, { "Name": "成本" }, { "Name": "损益"}];
this.storeACCATTRIBUTE = Ext.create('Ext.data.Store', { model: 'ACCATTRIBUTEModel', data: dataACCATTRIBUTE });
this.comboxACCATTRIBUTE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '科目类别',
forceSelection: true,
store: this.storeACCATTRIBUTE,
id: 'ACCATTRIBUTE',
name: 'ACCATTRIBUTE',
valueField: 'Name',
displayField: 'Name',
value: '资产',
allowBlank: false,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (combo.value.toString() != "") {
this.onACCTYPE();
}
}
}
});
//科目属性
Ext.define('ACCTYPEModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] });
var dataACCTYPE = [{ "Name": "流动资产" }, { "Name": "长期资产" }, { "Name": "流动负债" }, { "Name": "长期负债" }, { "Name": "共同" }, { "Name": "所有者权益" }, { "Name": "成本" }, { "Name": "营业收入" }, { "Name": "营业成本与税金" }, { "Name": "期间费用" }, { "Name": "其他收益" }, { "Name": "其他损失" }, { "Name": "以前年度损益调整" }, { "Name": "所得税"}];
this.storeACCTYPE = Ext.create('Ext.data.Store', { model: 'ACCTYPEModel', data: dataACCTYPE });
this.comboxACCTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '科目属性',
forceSelection: true,
store: this.storeACCTYPE,
id: 'ACCTYPE',
name: 'ACCTYPE',
valueField: 'Name',
displayField: 'Name',
value: '流动资产',
allowBlank: false
});
//借贷方向
Ext.define('DCModel', { extend: 'Ext.data.Model', fields: [{ name: 'Name', type: 'string'}] });
var dataDC = [{ "Name": "借" }, { "Name": "贷"}];
this.storeDC = Ext.create('Ext.data.Store', { model: 'DCModel', data: dataDC });
this.comboxDC = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '借贷方向',
forceSelection: true,
store: this.storeDC,
id: 'DC',
name: 'DC',
valueField: 'Name',
displayField: 'Name',
allowBlank: false
});
//币别
this.storeCodeCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCurrencyModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCurrencyList' }
});
//币别选项
this.storeCwAccitemsCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsCurrencyModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsCurrencyList' }
});
//#endregion
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
border: false,
region: 'north',
frame: true,
bodyPadding: 5,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
labelWidth: 100,
flex: 1,
msgTarget: 'qtip'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '自动编号',
name: 'GID',
hidden: true,
value: NewGuid().toString()
}, this.comboxPACCID]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '科目代码',
id: 'ACCID',
name: 'ACCID',
allowBlank: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '科目名称',
id: 'ACCNAME',
name: 'ACCNAME',
allowBlank: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxACCATTRIBUTE]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxACCTYPE]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxDC]
}, { xtype: 'hiddenfield', height: '10px' }, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'label',
text: "科目类型:",
style: 'font-size: 16px; color: #808000;',
anchor: '100%'
//,align: 'center'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否银行类科目',
id: 'ISBANK',
name: 'ISBANK',
xtype: 'checkbox',
checked: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否结算类科目',
id: 'ISSETTLEMENT',
name: 'ISSETTLEMENT',
xtype: 'checkbox',
checked: false
}]
}, { xtype: 'hiddenfield', height: '10px' }, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
xtype: 'label',
text: "核算项目:",
style: 'font-size: 16px; color: #808000;',
anchor: '100%'
//,align: 'center'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否核算部门',
id: 'ISDEPTACC',
name: 'ISDEPTACC',
xtype: 'checkbox',
checked: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否核算人员',
id: 'ISEMPLACC',
name: 'ISEMPLACC',
xtype: 'checkbox',
checked: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否核算客户',
id: 'ISCORPACC',
name: 'ISCORPACC',
xtype: 'checkbox',
checked: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否核算项目',
id: 'ISITEMACC',
name: 'ISITEMACC',
xtype: 'checkbox',
checked: false
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '是否核算外币',
id: 'ISFCY',
name: 'ISFCY',
xtype: 'checkbox',
checked: false,
listeners: {
'change': function (field, newValue, oldValue, eOpts) {
if (field.checked.toString() == "false") {
try {
var sMyGroup = Ext.getCmp('myGroup');
for (var i = 0; i < sMyGroup.items.length; i++) {
var sid = sMyGroup.items.items[i].id;
sMyGroup.setValue(sid, false);
}
Ext.getCmp('myGroup').hide();
}
catch (e) {
}
}
else {
if (this.opStatus == 'add') {
this.LoadData2(this.opStatus, "*");
}
else {
try {
Ext.getCmp('myGroup').show();
}
catch (e) {
this.LoadData2(this.opStatus, this.editRecord.data.GID.toString());
}
}
}
},
scope: this
}
}]
}]//end items(fieldset 1)
});
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
id: 'btnSave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: 'btnSaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, {
id: 'btnSaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
id: 'btnNew',
text: "新建",
handler: function (button, event) {
this.GetAddText();
},
scope: this
}, {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}]
}); //end 按钮Toolbar
//#endregion
//#region 框架/加载
Ext.apply(this, {
border: false,
items: [this.panelBtn, this.formHead]
});
parentWin = window.parent.opener;
this.InitData();
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
_this = this;
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
this.OpType = ret[3];
}
//
if (this.opStatus == 'add') {
this.GetAddText();
//this.LoadData2(this.opStatus, "*");
}
else {
condition = "GID='" + this.editRecord.get('GID') + "'";
this.LoadData('edit', condition);
//
if (this.editRecord != null) {
var sACCID = this.editRecord.get('ACCID');
Ext.Ajax.request({
waitMsg: '正在查询...',
url: '/MvcShipping/MsCwAccitemsGl/GetIsDisable',
params: {
sACCID: sACCID
},
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;
}
//
data = result.data;
if (data == "true") {
this.setBtnStatusDisable(false);
}
else {
this.setBtnStatusDisable(true);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}
//
this.onACCTYPE();
this.onBtnDisable();
}, //end InitData
LoadData: function (opStatus, condition) {
this.serialNo = 0;
this.opStatus = opStatus;
Ext.Ajax.request({
async: false, //同步请求数据
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCwAccitemsGl/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;
}
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
//
if (data.ISFCY == true) {
this.LoadData2(this.opStatus, data.GID.toString());
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
LoadData2: function (opStatus, sGID) {
this.storeCodeCurrency.load({ params: { condition: "" }, //CODENAME<>'RMB'
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var checkboxitems = "[";
for (i = 0; i < this.storeCodeCurrency.getCount(); i += 1) {
var memberyf = this.storeCodeCurrency.getAt(i);
if (i == 0) {
var checkboxSingleItem = "{boxLabel:'" + memberyf.data.CODENAME + "',inputValue:'1',name:'" + memberyf.data.CODENAME + "',id:'" + memberyf.data.CODENAME + "',width: 50";
checkboxSingleItem += "}";
} else {
var checkboxSingleItem = ",{boxLabel:'" + memberyf.data.CODENAME + "',inputValue:'1',name:'" + memberyf.data.CODENAME + "',id:'" + memberyf.data.CODENAME + "',width: 50";
checkboxSingleItem += "}";
}
checkboxitems += checkboxSingleItem;
};
checkboxitems += "]";
//
_this.myCheckboxGroup = new Ext.form.CheckboxGroup({
id: 'myGroup',
xtype: 'checkboxgroup',
fieldLabel: '币别选项',
items: eval(checkboxitems)
});
this.formHead.add(_this.myCheckboxGroup);
this.formHead.doLayout();
//
if (sGID != "*") {
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID = '" + sGID + "'" },
callback: function (r, options, success) {
if (success) {
for (i = 0; i < r.length; i++) {
for (j = 0; j < _this.myCheckboxGroup.items.items.length; j++) {
if (r[i].data.CURRENCY == _this.myCheckboxGroup.items.items[j].id) {
_this.myCheckboxGroup.items.items[j].setValue(true);
}
};
};
}
}
});
}
}
}
},
scope: this
});
}, // end LoadDate
//#endregion
//#region 保存
Save: function (type) {
if (!this.formHead.getForm().isValid()) {
return;
}
this.formHead.getForm().findField('GID').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
data.PACCID = this.formHead.getForm().findField('PACCID').getValue();
data.ACCID = this.formHead.getForm().findField('ACCID').getValue();
data.ACCNAME = this.formHead.getForm().findField('ACCNAME').getValue();
data.ACCATTRIBUTE = this.formHead.getForm().findField('ACCATTRIBUTE').getValue();
data.ACCTYPE = this.formHead.getForm().findField('ACCTYPE').getValue();
data.DC = this.formHead.getForm().findField('DC').getValue();
data.ISDEPTACC = this.formHead.getForm().findField('ISDEPTACC').getValue() ? 1 : 0;
data.ISEMPLACC = this.formHead.getForm().findField('ISEMPLACC').getValue() ? 1 : 0;
data.ISCORPACC = this.formHead.getForm().findField('ISCORPACC').getValue() ? 1 : 0;
data.ISITEMACC = this.formHead.getForm().findField('ISITEMACC').getValue() ? 1 : 0;
data.ISFCY = this.formHead.getForm().findField('ISFCY').getValue() ? 1 : 0;
data.ISBANK = this.formHead.getForm().findField('ISBANK').getValue() ? 1 : 0;
data.ISSETTLEMENT = this.formHead.getForm().findField('ISSETTLEMENT').getValue() ? 1 : 0;
this.formHead.getForm().findField('GID').setDisabled(true);
//
//您正在为科目 招行科技园支行 新增第一个下级科目,系统将把该科目的数据全部转移到新增的下级科目中,该流程不可逆,您是否要继续?
if (this.opStatus == "add") {
var sPACCID = this.formHead.getForm().findField('PACCID').getValue();
var AccitemsList = DsStoreQueryBy(this.storeCwAccitemsGl, 'ACCID', sPACCID);
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
if (AccitemsRaw.DETAILED.toString().trim() == "true") {
Ext.MessageBox.confirm('提示', '您正在为一个末级科目新增第一个下级科目,<br/>系统将把该科目的数据全部转移到新增的下<br/>级科目中,该流程不可逆转,您确定要继续吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwAccitemsGl/SaveDetailed',
scope: this,
params: {
data: Ext.JSON.encode(data),
PGID: AccitemsRaw.GID,
PACCID: AccitemsRaw.ACCID,
PACCNAME: AccitemsRaw.ACCNAME
},
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.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (type == '0') {
this.opStatus = 'edit';
if (returnData.ISFCY == true) {
this.LoadData2(this.opStatus, returnData.GID.toString());
}
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.GetAddText();
}
} 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});
}
}
});
return;
}
else {
return false;
}
}, this);
}
else {
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwAccitemsGl/Save',
scope: this,
params: {
opStatus: this.opStatus,
data: Ext.JSON.encode(data),
optype: this.OpType
},
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.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCwAccitemsGlModel', 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';
if (returnData.ISFCY == true) {
this.LoadData2(this.opStatus, returnData.GID.toString());
}
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.GetAddText();
}
} 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 });
}
}
});
}
}
else {
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwAccitemsGl/Save',
scope: this,
params: {
opStatus: this.opStatus,
data: Ext.JSON.encode(data),
optype: this.OpType
},
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.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
//var arrNewRecords = this.StoreList.add(returnData);
//this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCwAccitemsGlModel', 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';
if (returnData.ISFCY == true) {
this.LoadData2(this.opStatus, returnData.GID.toString());
}
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.GetAddText();
}
} 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
});
}
}
});
}
}
else {
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwAccitemsGl/Save',
scope: this,
params: {
opStatus: this.opStatus,
data: Ext.JSON.encode(data),
optype: this.OpType
},
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.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
//
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
//var arrNewRecords = this.StoreList.add(returnData);
//this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCwAccitemsGlModel', 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';
if (returnData.ISFCY == true) {
this.LoadData2(this.opStatus, returnData.GID.toString());
}
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.GetAddText();
}
} 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
//#endregion
//#region 编辑时按钮等的状态
onBtnDisable: function () {
var sPACCID = Ext.getCmp('PACCID').getValue();
if (sPACCID == null) {
Ext.getCmp('ACCATTRIBUTE').enable();
Ext.getCmp('ACCTYPE').enable();
Ext.getCmp('ISBANK').enable();
Ext.getCmp('ISSETTLEMENT').enable();
} else {
if (sPACCID.toString() == "") {
Ext.getCmp('ACCATTRIBUTE').enable();
Ext.getCmp('ACCTYPE').enable();
Ext.getCmp('ISBANK').enable();
Ext.getCmp('ISSETTLEMENT').enable();
} else {
Ext.getCmp('ACCATTRIBUTE').disable();
Ext.getCmp('ACCTYPE').disable();
Ext.getCmp('ISBANK').disable();
Ext.getCmp('ISSETTLEMENT').disable();
}
}
},
onACCTYPE: function () {
var sACCATTRIBUTE = Ext.getCmp('ACCATTRIBUTE').getValue();
if (sACCATTRIBUTE.toString() == "资产") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '流动资产' });
this.storeACCTYPE.add(record);
var record2 = Ext.create('ACCTYPEModel', { Name: '长期资产' });
this.storeACCTYPE.add(record2);
Ext.getCmp('ACCTYPE').setValue("流动资产");
}
else if (sACCATTRIBUTE.toString() == "负债") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '流动负债' });
this.storeACCTYPE.add(record);
var record2 = Ext.create('ACCTYPEModel', { Name: '长期负债' });
this.storeACCTYPE.add(record2);
Ext.getCmp('ACCTYPE').setValue("流动负债");
}
else if (sACCATTRIBUTE.toString() == "共同") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '共同' });
this.storeACCTYPE.add(record);
Ext.getCmp('ACCTYPE').setValue("共同");
}
else if (sACCATTRIBUTE.toString() == "权益") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '所有者权益' });
this.storeACCTYPE.add(record);
Ext.getCmp('ACCTYPE').setValue("所有者权益");
}
else if (sACCATTRIBUTE.toString() == "成本") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '成本' });
this.storeACCTYPE.add(record);
Ext.getCmp('ACCTYPE').setValue("成本");
}
else if (sACCATTRIBUTE.toString() == "损益") {
this.storeACCTYPE.removeAll();
var record = Ext.create('ACCTYPEModel', { Name: '营业收入' });
this.storeACCTYPE.add(record);
var record2 = Ext.create('ACCTYPEModel', { Name: '营业成本与税金' });
this.storeACCTYPE.add(record2);
var record3 = Ext.create('ACCTYPEModel', { Name: '期间费用' });
this.storeACCTYPE.add(record3);
var record4 = Ext.create('ACCTYPEModel', { Name: '其他收益' });
this.storeACCTYPE.add(record4);
var record5 = Ext.create('ACCTYPEModel', { Name: '其他损失' });
this.storeACCTYPE.add(record5);
var record6 = Ext.create('ACCTYPEModel', { Name: '以前年度损益调整' });
this.storeACCTYPE.add(record6);
var record7 = Ext.create('ACCTYPEModel', { Name: '所得税' });
this.storeACCTYPE.add(record7);
Ext.getCmp('ACCTYPE').setValue("营业收入");
}
},
setBtnStatusDisable: function (enable) {
if (enable) {
Ext.getCmp('PACCID').enable();
//Ext.getCmp('ACCID').enable();
//Ext.getCmp('ACCNAME').enable();
Ext.getCmp('DC').enable();
Ext.getCmp('ISDEPTACC').enable();
Ext.getCmp('ISEMPLACC').enable();
Ext.getCmp('ISCORPACC').enable();
Ext.getCmp('ISITEMACC').enable();
} else {
Ext.getCmp('PACCID').disable();
//Ext.getCmp('ACCID').disable();
//Ext.getCmp('ACCNAME').disable();
Ext.getCmp('ACCATTRIBUTE').disable();
Ext.getCmp('ACCTYPE').disable();
Ext.getCmp('DC').disable();
Ext.getCmp('ISDEPTACC').disable();
Ext.getCmp('ISEMPLACC').disable();
Ext.getCmp('ISCORPACC').disable();
Ext.getCmp('ISITEMACC').disable();
//var ibl = this.formHead.getForm().findField('ISFCY').getValue();
//if (ibl) {
// Ext.getCmp('ISFCY').disable();
//}
}
},
GetAddText: function () {
this.storeCwAccitemsGl.load();
this.opStatus = 'add';
var PGID = "";
var sPACCID = "";
if (this.editRecord != null) {
PGID = this.editRecord.get('GID');
sPACCID = this.editRecord.get('ACCID');
Ext.getCmp('PACCID').setValue(sPACCID);
}
//
Ext.Ajax.request({
waitMsg: '正在查询...',
url: '/MvcShipping/MsCwAccitemsGl/GetACCID',
params: {
PGID: PGID,
PACCID: sPACCID,
OpType: this.OpType
},
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 returnData = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
async: false,
scope: this
});
}
//#endregion
});