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.

3953 lines
185 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');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
//#region 当前日期格式
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //cond
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
return format;
}
//#endregion
//#region 获取 YYYY-mm-dd 格式的日期
var xhr = new XMLHttpRequest();
var currdate = new Date();
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
}
}
xhr.send(null);
//#endregion
//#region 关闭窗口前的判断
function getSaved() {
var changelines = panelEdit.storeDetailList.getModifiedRecords();
var changecount = changelines.length;
var delcount = panelEdit.DelBody.length;
var AllDirty = true;
if (changecount == 0 && delcount == 0) { return false; }
if (panelEdit.formHead.getForm().isDirty() == true || AllDirty == true) { return true; }
else { return false };
}
//#endregion
Shipping.MsCwVouchersGlEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwVouchersGlEdit.superclass.constructor.call(this);
};
var _orderno = '';
Ext.extend(Shipping.MsCwVouchersGlEdit, Ext.Panel, {
opStatus: 'add',
ParentWin: null,
StoreList: null,
EditRecord: null,
sqlcontext: '',
btnRefresh: null,
tbVOUNO: null,
btnAddCwVouchersJK: null,
btnSelCwVouchersJK: null,
tbVOUCHERNO: null,
btnAddCwVouchers: null,
btnSelCwVouchers: null,
strCwSTARTGID: '',
initUIComponents: function () {
this.serialNo = 0;
this.itemindex = 1;
this.DelBody = [];
this.isF7 = 0;
this.ORDNO = getUrlParam('ordno');
Ext.Ajax.timeout = 1200000;
//权限范围
this.StoreOpRangeEdit = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRangeEdit.load({ params: { optype: "MODVOUCHERGL" } });
//#region formSearch 下拉框信息加载
//科目加载
this.storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
//proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGlAll' }
});
this.storeCwAccitems.load({ params: { condition: "DETAILED=1 and ISENABLE=1" } });
//this.storeCwAccitems.load();
this.comboxACCNAME = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '科目名称',
store: this.storeCwAccitems,
forceSelection: false, //输入值是否严格为待选列表中存在的值
id: 'ACCNAME',
name: 'ACCNAME',
valueField: 'ACCNAME',
//valueField: 'ACCIDNAME',
displayField: 'ACCIDNAME',
allowBlank: false,
matchFieldWidth: false, //下拉款自适应宽度
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': function (combo, eOpts) {
//fn: function (e) {
// e.expand();
// this.doQuery(this.allQuery, true);
//},
//buffer: 200
//if (combo.value != null) {
// var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
// var sACCID = selections[0].data.ACCID;
// var strOriginalValue = combo.value.toString();
// if (strOriginalValue.indexOf("▁") < 0) {
// var ayList = new Array();
// ayList = strOriginalValue.split("▁");
// var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', (sACCID + "-" + ayList[0].toString()));
// if (AccitemsList.length == 0) {
// AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayList[0].toString());
// }
// if (AccitemsList.length > 0) {
// var AccitemsRaw = AccitemsList.getAt(0);
// if (AccitemsRaw != null) {
// //combo.setValue((sACCID + "-" + ayList[0].toString()), combo.value.toString());
// combo.setValue(strOriginalValue);
// selections[0].set('ACCALL', strOriginalValue);
// }
// }
// }
//}
},
'blur': function blur(combo, eOpts) {
if (combo.value != null) {
var strOriginalValue = combo.value.toString();
var ayList = new Array();
ayList = strOriginalValue.split("▁");
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCNAME', ayList[0].toString());
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayList[0].toString());
if (AccitemsList.length == 0) {
var iLian = ayList[0].toString().indexOf("-");
var sACCID = ayList[0].toString().substr(0, iLian);
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', sACCID);
}
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw == null) {
combo.setValue("");
}
else {
//combo.setValue(AccitemsRaw.data.ACCIDNAME.toString());
if (this.isF7 == 1) {
this.isF7 = 0;
var AccitemsRaw2 = AccitemsList.getAt(0).raw;
this.onColumnsHidden(false, AccitemsRaw2.ISFCY);
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
selections[0].set('ACCID', AccitemsRaw2.ACCID.toString());
selections[0].set('DC', AccitemsRaw2.DC.toString());
//是不是外币都默认为RMB?
var ssCURRENCY = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw2.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
ssCURRENCY = selections[0].data.FCYNO.toString();
break;
}
if (options[i].data.CURRENCY.toString() == 'RMB') {
ssCURRENCY = 'RMB';
break;
}
ssCURRENCY = options[0].data.CURRENCY;
}
}
else {
ssCURRENCY = "RMB";
}
combo.setValue(ssCURRENCY); //选中
selections[0].set('FCYNO', ssCURRENCY);
selections[0].set('CURRENCY', ssCURRENCY); //FCYNO
},
async: false,
scope: this
});
if (AccitemsRaw2.ISFCY) {
//如果是外币,则默认传送''
var VOUDATE = this.formHead.getForm().findField('VOUDATE').getRawValue();
Ext.Ajax.request({
waitMsg: '正在查询汇率值...',
url: '/MvcShipping/MsCwVouchersGl/GetFCYEXRATEBYVOUDATE',
params: {
FCY: '',
LINKGID: AccitemsRaw2.GID.toString(),
VOUDATE: VOUDATE
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
var strArg = result.data.toString().split("");
var FCYNO = strArg[0].toString();
// var strFCYEXRATE = selections[0].data.FCYEXRATE;
var strFCYEXRATE = strArg[1].toString();
if (strFCYEXRATE == 1) {
strFCYEXRATE = Div(strArg[1].toString(), 1, 5);
}
selections[0].set('FCYEXRATE', strFCYEXRATE.toString());
selections[0].set('FCYNO', FCYNO);
selections[0].set('CURRENCY', FCYNO);
//
var AMTDR = selections[0].data.AMTDR;
var AMTCR = selections[0].data.AMTCR;
var AMT = 0;
if (AMTDR != 0) {
AMT = AMTDR;
}
if (AMTCR != 0) {
AMT = AMTCR;
}
selections[0].set('FCYAMT', Div(AMT, strFCYEXRATE, 2));
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
async: false,
scope: this
});
}
else {
selections[0].set('FCYEXRATE', 1);
selections[0].set('FCYNO', 'RMB');
selections[0].set('FCYAMT', 0);
}
if (AccitemsRaw2.ISDEPTACC || AccitemsRaw2.ISEMPLACC || AccitemsRaw2.ISCORPACC || AccitemsRaw2.ISITEMACC) {
var winaccitemsedit = Ext.getCmp('winaccitemsedit');
if (winaccitemsedit == undefined||!winaccitemsedit.show) {
var strOriginalValue = selections[0].get('ACCALL');
this.showContactForm(false, AccitemsRaw2.ACCIDNAME.toString(), strOriginalValue.toString(), AccitemsRaw2, selections, false);
}
}
else {
this.onNextKeyClick(4);
}
}
else {
this.isF7 = 0;
}
}
}
else {
combo.setValue("");
}
}
else {
combo.setValue("");
}
},
'select': function (combo, records, eOpts) {
if (combo.value.toString() != "") {
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', combo.rawValue.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
this.onColumnsHidden(false, AccitemsRaw.ISFCY);
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
//是不是外币都默认为RMB?
var ssCURRENCY = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
ssCURRENCY = selections[0].data.FCYNO.toString();
break;
}
if (options[i].data.CURRENCY.toString() == 'RMB') {
ssCURRENCY = 'RMB';
break;
}
ssCURRENCY = options[0].data.CURRENCY;
}
}
else {
ssCURRENCY = "RMB";
}
combo.setValue(ssCURRENCY); //选中
selections[0].set('FCYNO', ssCURRENCY);
},
async: false,
scope: this
});
// combo.setValue(combo.value.toString());
selections[0].set('ACCNAME', combo.value.toString());
selections[0].set('ACCID', AccitemsRaw.ACCID.toString());
selections[0].set('DC', AccitemsRaw.DC.toString());
//
if (AccitemsRaw.ISFCY) {
//如果是外币,则默认传送''
var VOUDATE = this.formHead.getForm().findField('VOUDATE').getRawValue();
Ext.Ajax.request({
waitMsg: '正在查询汇率值...',
url: '/MvcShipping/MsCwVouchersGl/GetFCYEXRATEBYVOUDATE',
params: {
FCY: '',
LINKGID: AccitemsRaw.GID.toString(),
VOUDATE: VOUDATE
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
var strArg = result.data.toString().split("");
var FCYNO = strArg[0].toString();
// var strFCYEXRATE = selections[0].data.FCYEXRATE;
var strFCYEXRATE = strArg[1].toString();
if (strFCYEXRATE == 1) {
strFCYEXRATE = Div(strArg[1].toString(), 1, 5);
}
selections[0].set('FCYEXRATE', strFCYEXRATE);
selections[0].set('FCYNO', ssCURRENCY); //FCYNO
selections[0].set('CURRENCY', ssCURRENCY); //FCYNO
//
var AMTDR = selections[0].data.AMTDR;
var AMTCR = selections[0].data.AMTCR;
var AMT = 0;
if (AMTDR != 0) {
AMT = AMTDR;
}
if (AMTCR != 0) {
AMT = AMTCR;
}
selections[0].set('FCYAMT', Div(AMT, strFCYEXRATE, 2));
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
async: false,
scope: this
});
}
else {
selections[0].set('FCYEXRATE', 1);
selections[0].set('FCYNO', 'RMB');
selections[0].set('FCYAMT', 0);
}
if (AccitemsRaw.ISDEPTACC || AccitemsRaw.ISEMPLACC || AccitemsRaw.ISCORPACC || AccitemsRaw.ISITEMACC) {
var winaccitemsedit = Ext.getCmp('winaccitemsedit');
if (winaccitemsedit == undefined ||!winaccitemsedit.show) {
var strOriginalValue = combo.value.toString();
this.showContactForm(false, combo.value.toString(), strOriginalValue.toString(), AccitemsRaw, selections, false);
}
}
else {
this.onNextKeyClick(4);
}
}
else {
combo.setValue("");
}
}
},
'keydown': {
fn: function (_field, e, eOpts) {
if (e.getKey() == 118) {//F7
this.isF7 = 1;
DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 150), (window.screen.availWidth / 2 - 500));
}
else if (e.getKey() == 13) {
var newValue = _field.rawValue.toString();
var inv = newValue.indexOf("-");
if (inv > -1) {
newValue = newValue.substr(inv + 1);
}
if (newValue != "") {
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', _field.rawValue.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
this.onColumnsHidden(false, AccitemsRaw.ISFCY);
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
selections[0].set('ACCID', AccitemsRaw.ACCID.toString());
selections[0].set('DC', AccitemsRaw.DC.toString());
//是不是外币都默认为RMB?
var ssCURRENCY = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
ssCURRENCY = selections[0].data.FCYNO.toString();
break;
}
if (options[i].data.CURRENCY.toString() == 'RMB') {
ssCURRENCY = 'RMB';
break;
}
ssCURRENCY = options[0].data.CURRENCY;
}
}
else {
ssCURRENCY = "RMB";
}
combo.setValue(ssCURRENCY); //选中
selections[0].set('FCYNO', ssCURRENCY);
selections[0].set('CURRENCY', ssCURRENCY); //FCYNO
},
async: false,
scope: this
});
if (AccitemsRaw.ISFCY) {
//如果是外币,则默认传送''
var VOUDATE = this.formHead.getForm().findField('VOUDATE').getRawValue();
Ext.Ajax.request({
waitMsg: '正在查询汇率值...',
url: '/MvcShipping/MsCwVouchersGl/GetFCYEXRATEBYVOUDATE',
params: {
FCY: '',
LINKGID: AccitemsRaw.GID.toString(),
VOUDATE: VOUDATE
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
var strArg = result.data.toString().split("");
var FCYNO = strArg[0].toString();
// var strFCYEXRATE = selections[0].data.FCYEXRATE;
var strFCYEXRATE = strArg[1].toString();
if (strFCYEXRATE == 1) {
strFCYEXRATE = Div(strArg[1].toString(), 1, 5);
}
selections[0].set('FCYEXRATE', strFCYEXRATE.toString());
selections[0].set('FCYNO', FCYNO);
selections[0].set('CURRENCY', FCYNO);
//
var AMTDR = selections[0].data.AMTDR;
var AMTCR = selections[0].data.AMTCR;
var AMT = 0;
if (AMTDR != 0) {
AMT = AMTDR;
}
if (AMTCR != 0) {
AMT = AMTCR;
}
selections[0].set('FCYAMT', Div(AMT, strFCYEXRATE, 2));
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
async: false,
scope: this
});
}
else {
selections[0].set('ACCNAME', newValue);
selections[0].set('ACCALL', newValue);
selections[0].set('FCYEXRATE', 1);
selections[0].set('FCYNO', 'RMB');
selections[0].set('FCYAMT', 0);
}
if (AccitemsRaw.ISDEPTACC || AccitemsRaw.ISEMPLACC || AccitemsRaw.ISCORPACC || AccitemsRaw.ISITEMACC) {
var strOriginalValue = selections[0].get('ACCALL');
this.showContactForm(false, AccitemsRaw.ACCIDNAME.toString(), strOriginalValue.toString(), AccitemsRaw, selections, false);
// this.showContactForm(false, AccitemsRaw2.ACCIDNAME.toString(), strOriginalValue.toString(), AccitemsRaw2, selections, false);
}
else {
this.onNextKeyClick(4);
}
}
else {
_field.setValue("");
}
}
//
}
},
scope: this
},
'render': function (_field, eOpts) {//自定义函数,定义双击事件
var _this = this;
_field.getEl().on('dblclick', function (e, t, eOpts) {
var selections = _this.gridList.getSelectionModel().getSelection(); //获得选中的项
var strOriginalValue = selections[0].get('ACCALL');
var strACCID = selections[0].get('ACCID');
if (strOriginalValue.indexOf("▁") > -1) {
var ayList = new Array();
ayList = strOriginalValue.split("▁");
var AccitemsList = DsStoreQueryBy(_this.storeCwAccitems, 'ACCID', strACCID);
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(_this.storeCwAccitems, 'ACCIDNAME', ayList[0].toString());
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
_this.showContactForm(false, ayList[0].toString(), strOriginalValue.toString(), AccitemsRaw, selections, true);
}
else {
_field.rawValue.setValue("");
}
}
});
}
}
});
//币别选项
this.storeCwAccitemsCurrency = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsCurrencyModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsCurrencyList' }
});
this.storeCwAccitemsCurrency.load({ params: { condition: "LINKGID=''"} });
this.comboxCodeCurrency = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '币别',
store: this.storeCwAccitemsCurrency,
forceSelection: true, //输入值是否严格为待选列表中存在的值
id: 'CURRENCY',
name: 'CURRENCY',
valueField: 'CURRENCY',
displayField: 'CURRENCY',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': function (_this, eOpts) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var strACCID = selections[0].get('ACCID');
var sCURRENCY = selections[0].data.FCYNO.toString().trim();
var sACCNAME = selections[0].data.ACCNAME.toString().trim();
if (sACCNAME == "") {
var ayList = new Array();
ayList = selections[0].data.ACCALL.toString().trim().split("▁");
sACCNAME = ayList[0].toString();
}
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', strACCID);
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', sACCNAME);
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
var ssCURRENCY = selections[0].data.FCYNO;
this.storeCwAccitemsCurrency.load({
params: { condition: "LINKGID='" + AccitemsRaw.GID + "'" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
var combo = Ext.getCmp("CURRENCY");
if (options.length > 0) {
for (var i = 0; i < options.length; i++) {
if (options[i].data.CURRENCY.toString() == selections[0].data.FCYNO.toString()) {
ssCURRENCY = selections[0].data.FCYNO.toString();
break;
}
if (options[i].data.CURRENCY.toString() == 'RMB') {
ssCURRENCY = 'RMB';
break;
}
ssCURRENCY = options[0].data.CURRENCY;
}
}
else {
ssCURRENCY = "RMB";
}
sCURRENCY = ssCURRENCY;
combo.setValue(ssCURRENCY); //选中
},
scope: this
});
selections[0].set('FCYNO', sCURRENCY);
selections[0].set('CURRENCY', sCURRENCY);
}
},
//'change': function (combo, records, eOpts, kk, hg) {
'select': function (combo, records, eOpts) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var strACCID = selections[0].get('ACCID');
if (combo.value != "RMB") {
var sACCNAME = selections[0].data.ACCNAME.toString().trim();
if (sACCNAME == "") {
var ayList = new Array();
ayList = selections[0].data.ACCALL.toString().trim().split("▁");
sACCNAME = ayList[0].toString();
}
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', strACCID);
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', sACCNAME);
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
//如果是外币则默认传送combo.value
if (AccitemsRaw.ISFCY) {
var VOUDATE = this.formHead.getForm().findField('VOUDATE').getRawValue();
Ext.Ajax.request({
waitMsg: '正在查询汇率值...',
url: '/MvcShipping/MsCwVouchersGl/GetFCYEXRATEBYVOUDATE',
params: {
FCY: combo.value,
LINKGID: AccitemsRaw.GID.toString(),
VOUDATE: VOUDATE
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
//
var strArg = result.data.toString().split("");
var FCYNO = strArg[0].toString();
// var strFCYEXRATE = selections[0].data.FCYEXRATE;
var strFCYEXRATE = strArg[1].toString();
if (strFCYEXRATE == 1) {
strFCYEXRATE = Div(strArg[1].toString(), 1, 5);
}
selections[0].set('FCYEXRATE', strFCYEXRATE);
selections[0].set('FCYNO', combo.value);
selections[0].set('CURRENCY', combo.value);
//
var AMTDR = selections[0].data.AMTDR;
var AMTCR = selections[0].data.AMTCR;
var AMT = 0;
if (AMTDR != 0) {
AMT = AMTDR;
}
if (AMTCR != 0) {
AMT = AMTCR;
}
selections[0].set('FCYAMT', Div(AMT, strFCYEXRATE, 2));
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
}
}
else {
selections[0].set('FCYEXRATE', 1);
selections[0].set('FCYNO', 'RMB');
selections[0].set('FCYAMT', 0);
}
},
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onNextKeyClick(5);
}
},
scope: this
}
}
});
//键值维护表_凭证字
this.storeCrmKeyCodeCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CrmKeyCodeModel',
proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' }
});
this.storeCrmKeyCodeCode.load({ params: { condition: " and KEYTYPE='凭证字'"} });
this.comboxVKNO = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '凭证字',
labelWidth: 50,
store: this.storeCrmKeyCodeCode,
forceSelection: true,
name: 'VKNO',
width: 100,
valueField: 'KEYVALUE',
displayField: 'KEYVALUE',
value: '记',
allowBlank: false
//
});
//#endregion
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
border: false,
region: 'north',
frame: true,
//bodyPadding: 5,
trackResetOnLoad: true, //是否记录字段原始值
fieldDefaults: {
labelAlign: 'right',
labelWidth: 40,
msgTarget: 'qtip'
//,style: 'font-size: 30px; color: #808000; vertical-align: text-bottom;'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{ xtype: 'label', flex: 1 }, {
xtype: 'label',
text: "记账凭证",
style: 'font-size: 30px; color: #808000;',
id: 'voutitle',
anchor: '100%',
align: 'center'
}, { xtype: 'label', flex: 1}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '凭证GID',
id: 'ORDNO',
name: 'ORDNO',
hidden: true,
value: '*'
}, {
fieldLabel: 'ISCOPY',
name: 'ISCOPY',
value: false,
hidden: true
}, {
fieldLabel: 'ISAUTO',
name: 'ISAUTO',
value: false,
hidden: true
}, {
fieldLabel: 'COPYORDNO',
name: 'COPYORDNO',
hidden: true
}, this.comboxVKNO, {
fieldLabel: '',
id: 'VOUNO',
name: 'VOUNO',
width: 60,
xtype: 'numberfield',
nanText: '请输入有效整数',
value: 0,
allowBlank: false
}, {
xtype: 'label',
id: 'VOUNO_HAO',
labelWidth: 50,
text: "号",
style: 'vertical-align: text-bottom;'
}, {
fieldLabel: '日期',
id: 'VOUDATE',
name: 'VOUDATE',
xtype: 'datefield',
format: 'Y-m-d',
value: currdate.format('yyyy-MM-dd'),
width: 140,
allowBlank: false
}, { xtype: 'label', flex: 1 }, {
xtype: 'displayfield',
id: 'lbTitle2',
name: 'lbTitle2',
width: 80,
value: "2015年第1期",
allowBlank: false
}, {
fieldLabel: '',
name: 'ISAUTOSTR',
width: 150,
// disabled: true,
flex: 0.5,
value:'手工',
readOnly: true,
allowBlank: false
}, { xtype: 'label', flex: 1 }, {
fieldLabel: '附单据',
id: 'ATTACHS',
labelWidth: 60,
name: 'ATTACHS',
width: 100,
xtype: 'numberfield',
nanText: '请输入有效整数',
value: 0,
allowBlank: false
}, {
xtype: 'label',
text: "张",
style: 'vertical-align: text-bottom;'
}]
}]//end items(fieldset 1)
});
//#endregion
//#region 编辑formBottom 基本信息
this.formBottom = Ext.widget('form', {
border: false,
region: 'south',
height: 40,
frame: true,
//bodyPadding: 5,
trackResetOnLoad: true, //是否记录字段原始值
fieldDefaults: {
labelAlign: 'right',
labelWidth: 80,
msgTarget: 'qtip'
//,style: 'font-size: 30px; color: #808000; vertical-align: text-bottom;'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '制单人',
name: 'CREATEUSERNAME',
width: 150,
value: SHOWNAME,
readOnly: true,
allowBlank: false
}, {
fieldLabel: '制单日期',
name: 'CREATETIME',
width: 210,
value: currdate.format('yyyy-MM-dd hh:mm:ss'),
readOnly: true,
allowBlank: false
}, { xtype: 'hiddenfield', flex: 1 }, {
fieldLabel: '改单人',
name: 'MODIFIEDUSERNAME',
width: 150,
value: SHOWNAME,
readOnly: true,
allowBlank: false
}, {
fieldLabel: '修改日期',
name: 'MODIFIEDTIME',
width: 210,
value: currdate.format('yyyy-MM-dd hh:mm:ss'),
readOnly: true,
allowBlank: false
}]
}]//end items(fieldset 1)
});
//#endregion
//#region 定义数据集
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
//proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' }
});
this.StoreOpRange.load({ params: { optype: "MsCwVouchersGlCHECKED"} });
this.StoreOpRange2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
//proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang4' }
});
this.StoreOpRange2.load({ params: { optype: "MsCwVouchersGlNotCHECKED"} });
//列表加载
this.storeDetailList = Ext.create('Ext.data.Store', {
model: 'MsCwVouitemsGlModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwVouchersGl/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: true,
dataIndex: 'GID',
header: '', //唯一编码
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'ITEMNO',
header: '行号',
align: 'center',
//style: "color: 'red'", //black
//color: "red",
width: 35
},
{
id: 'EXPLAN',
sortable: false,
dataIndex: 'EXPLAN',
header: '摘要',
//align: 'center',
width: 200,
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(3);
}
},
scope: this
}
}
}
},
{
sortable: false,
dataIndex: 'ACCALL',
header: '会计科目',
width: 260,
editor: this.comboxACCNAME
},
{
sortable: false,
dataIndex: 'FCYNO',
header: '原币币别',
align: 'center',
width: 60,
editor: this.comboxCodeCurrency
},
{
sortable: false,
dataIndex: 'FCYEXRATE',
header: '汇率',
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00000'),//
width: 60,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
decimalPrecision: 5, //允许保留的小数位数,并四舍五入
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00000,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(6);
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 5, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'FCYAMT',
header: '原币金额',
align: 'right',
width: 80,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
//minValue: 0,
//maxValue: 100000,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(7);
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
/*注释
//1.value是当前单元格的值
//2.cellmeta里保存的是cellId单元格idid不知道是干啥的似乎是列号css是这个单元格的css样式。
//3.record是这行的所有数据你想要什么record.data["id"]这样就获得了。
//4.rowIndex是行号不是从头往下数的意思而是计算了分页以后的结果。
//5.columnIndex列号太简单了。
//6.store这个厉害实际上这个是你构造表格时候传递的ds也就是说表格里所有的数据你都可以随便调用太厉害了。
*/
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
}
},
{
sortable: false,
dataIndex: 'AMTDR',
header: '借方金额',
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
minValue: -999999999.99,
maxValue: 999999999.99,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 32) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var AMTDR_OLD = _field.value;
var AMTCR_OLD = selections[0].data.AMTCR;
_field.setValue(AMTCR_OLD);
selections[0].set('AMTCR', AMTDR_OLD);
}
else if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == 13) {
this.onNextKeyClick(8);
}
},
scope: this
},
'render': function (_field, eOpts) {//自定义函数,定义双击事件
var _this = this;
_field.getEl().on('dblclick', function (e, t, eOpts) {
var dAMTDR = 0;
var dAMTCR = 0;
var iLength = _this.gridList.getStore().data.length;
if (iLength > 1) {
var records = _this.gridList.getStore().data.items;
for (var i = 0; i < iLength; i += 1) {
dAMTDR += records[i].data.AMTDR;
dAMTCR += records[i].data.AMTCR;
}
var dAMT = dAMTCR - (dAMTDR - (_field.value));
_field.setValue(dAMT);
}
});
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'AMTCR',
header: '贷方金额',
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
minValue: -999999999.99,
maxValue: 999999999.99,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 32) {
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
var AMTDR_OLD = selections[0].data.AMTDR;
var AMTCR_OLD = _field.value;
selections[0].set('AMTDR', AMTCR_OLD);
_field.setValue(AMTDR_OLD);
}
else if (e.getKey() == 40) {
this.onAddClick();
}
//else if (e.getKey() == 9) {
// this.onAddClick();
//}
else if (e.getKey() == 13) {
//this.onNextKeyClick(9);
this.onAddClick();
}
},
scope: this
},
'keydown': {
fn: function (_field, e) {
if (e.getKey() == 9) {
this.onAddClick();
}
},
scope: this
},
'render': function (_field, eOpts) {//自定义函数,定义双击事件
var _this = this;
_field.getEl().on('dblclick', function (e, t, eOpts) {
var dAMTDR = 0;
var dAMTCR = 0;
var iLength = _this.gridList.getStore().data.length;
if (iLength > 1) {
var records = _this.gridList.getStore().data.items;
for (var i = 0; i < iLength; i += 1) {
dAMTDR += records[i].data.AMTDR;
dAMTCR += records[i].data.AMTCR;
}
var dAMT = dAMTDR - (dAMTCR - (_field.value));
_field.setValue(dAMT);
}
});
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
/*注释
//1.value是当前单元格的值
//2.cellmeta里保存的是cellId单元格idid不知道是干啥的似乎是列号css是这个单元格的css样式。
//3.record是这行的所有数据你想要什么record.data["id"]这样就获得了。
//4.rowIndex是行号不是从头往下数的意思而是计算了分页以后的结果。
//5.columnIndex列号太简单了。
//6.store这个厉害实际上这个是你构造表格时候传递的ds也就是说表格里所有的数据你都可以随便调用太厉害了。
*/
//Ext.util.Format.number(value, '00.00');
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
id: 'ACCID',
sortable: false,
hidden: true,
dataIndex: 'ACCID',
header: '科目代码',
width: 0
},
{
id: 'DC',
sortable: false,
hidden: true,
dataIndex: 'DC',
header: '科目方向',
width: 0
}];
this.girdcolumslist = [{
sortable: true,
dataIndex: 'GID',
header: '', //唯一编码
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'ITEMNO',
header: '行号',
align: 'center',
//style: "color: 'red'", //black
//color: "red",
width: 35
},
{
id: 'EXPLAN',
sortable: false,
dataIndex: 'EXPLAN',
header: '摘要',
//align: 'center',
width: 200
},
{
sortable: false,
dataIndex: 'ACCALL',
header: '会计科目',
width: 260
},
{
sortable: false,
dataIndex: 'FCYNO',
header: '原币币别',
align: 'center',
width: 60
},
{
sortable: false,
dataIndex: 'FCYEXRATE',
header: '汇率',
align: 'right',
//renderer: Ext.util.Format.numberRenderer('00.00000'),//
width: 60,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 5, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'FCYAMT',
header: '原币金额',
align: 'right',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
/*注释
//1.value是当前单元格的值
//2.cellmeta里保存的是cellId单元格idid不知道是干啥的似乎是列号css是这个单元格的css样式。
//3.record是这行的所有数据你想要什么record.data["id"]这样就获得了。
//4.rowIndex是行号不是从头往下数的意思而是计算了分页以后的结果。
//5.columnIndex列号太简单了。
//6.store这个厉害实际上这个是你构造表格时候传递的ds也就是说表格里所有的数据你都可以随便调用太厉害了。
*/
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
}
},
{
sortable: false,
dataIndex: 'AMTDR',
header: '借方金额',
align: 'right',
width: 120,
summaryType: 'sum',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'AMTCR',
header: '贷方金额',
align: 'right',
width: 120,
summaryType: 'sum',
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
/*注释
//1.value是当前单元格的值
//2.cellmeta里保存的是cellId单元格idid不知道是干啥的似乎是列号css是这个单元格的css样式。
//3.record是这行的所有数据你想要什么record.data["id"]这样就获得了。
//4.rowIndex是行号不是从头往下数的意思而是计算了分页以后的结果。
//5.columnIndex列号太简单了。
//6.store这个厉害实际上这个是你构造表格时候传递的ds也就是说表格里所有的数据你都可以随便调用太厉害了。
*/
//Ext.util.Format.number(value, '00.00');
value = usMoney(value, 2, '', true);
if (parseFloat(value) < 0) {
return '<SPAN style="COLOR: red">' + value + '</SPAN>';
}
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
id: 'ACCID',
sortable: false,
hidden: true,
dataIndex: 'ACCID',
header: '科目代码',
width: 0
},
{
id: 'DC',
sortable: false,
hidden: true,
dataIndex: 'DC',
header: '科目方向',
width: 0
}];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridList = new Ext.grid.GridPanel({
region: 'center',
store: this.storeDetailList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
enableColumnHide: false, ///隐藏表头列
sortableColumns: false, ///隐藏表头排序
//disableSelection: false, //是否禁止选择表格行或列默认为false
//trackMouseOver: true, //高亮显示鼠标所在的行默认为true,
//stripeRows: true, //斑马线效果
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性
}],
listeners: {
scope: this,
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
if (e.colIdx == 3) {
var sACCID = e.record.data['ACCID'].toString();
var sACCALL = e.value;
var ayListA = new Array();
ayListA = sACCALL.split("▁");
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', sACCID);
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayListA[0].toString());
}
if (AccitemsList.length <= 0) {
e.record.set('ACCID', '');
e.record.set('ACCALL', '');
Ext.Msg.show({ title: '警告', msg: '此帐套无此科目信息,请重新填写!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
else
if (e.colIdx == 4) {
var sACCID = e.record.data['ACCID'].toString();
var sACCALL = e.record.data['ACCALL'].toString();
var ayListA = new Array();
ayListA = sACCALL.split("▁");
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', (sACCID + "-" + ayListA[0].toString()));
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayListA[0].toString());
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
if (!AccitemsRaw.ISFCY) {
e.record.set('FCYNO', 'RMB');
e.record.set('FCYEXRATE', 1);
e.record.set('FCYAMT', 0);
}
}
}
else if (e.colIdx == 5) {
var sACCID = e.record.data['ACCID'].toString();
var sACCALL = e.record.data['ACCALL'].toString();
var FCYNO = e.record.data['FCYNO'].toString();
var FCYEXRATE = e.record.data['FCYEXRATE'];
var FCYAMT = e.record.data['FCYAMT'];
var ayListA = new Array();
ayListA = sACCALL.split("▁");
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', (sACCID + "-" + ayListA[0].toString()));
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayListA[0].toString());
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
if (!AccitemsRaw.ISFCY) {
e.record.set('FCYNO', 'RMB');
e.record.set('FCYEXRATE', 1);
e.record.set('FCYAMT', 0);
}
else {
var amount = Mul(FCYEXRATE, FCYAMT);
if (AccitemsRaw.DC.toString() == "借") {
e.record.set('AMTDR', amount);
e.record.set('AMTCR', 0);
}
else {
e.record.set('AMTDR', 0);
e.record.set('AMTCR', amount);
}
}
}
}
else if (e.colIdx == 6) {
var sACCID = e.record.data['ACCID'].toString();
var FCYNO = e.record.data['FCYNO'].toString();
var FCYEXRATE = e.record.data['FCYEXRATE'];
var FCYAMT = e.record.data['FCYAMT'];
var sACCALL = e.record.data['ACCALL'].toString();
var ayListA = new Array();
ayListA = sACCALL.split("▁");
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', (sACCID + "-" + ayListA[0].toString()));
if (AccitemsList.length == 0) {
AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayListA[0].toString());
}
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
if (AccitemsRaw.ISFCY) {
var amount = Mul(FCYEXRATE, FCYAMT);
if (AccitemsRaw.DC.toString() == "借") {
e.record.set('AMTDR', amount);
e.record.set('AMTCR', 0);
}
else {
e.record.set('AMTDR', 0);
e.record.set('AMTCR', amount);
}
}
else {
if (AccitemsRaw.DC.toString() == "借") {
e.record.set('AMTDR', FCYAMT);
e.record.set('AMTCR', 0);
}
else {
e.record.set('AMTDR', 0);
e.record.set('AMTCR', FCYAMT);
}
e.record.set('FCYNO', 'RMB');
e.record.set('FCYEXRATE', 1);
e.record.set('FCYAMT', 0);
}
}
}
else if (e.colIdx == 7) {
var AMTDR = e.record.data['AMTDR'];
if (AMTDR != 0) {
e.record.set('AMTCR', 0);
var FCYNO = e.record.data['FCYNO'].toString();
var FCYEXRATE = e.record.data['FCYEXRATE'];
var FCYAMT = e.record.data['FCYAMT'];
if (FCYNO.toString().trim() != 'RMB') {
var amount = Div(AMTDR, FCYEXRATE);
if (FCYAMT != amount) {
e.record.set('FCYAMT', amount);
}
}
}
}
else if (e.colIdx == 8) {
var AMTCR = e.record.data['AMTCR'];
if (AMTCR != 0) {
e.record.set('AMTDR', 0);
var FCYNO = e.record.data['FCYNO'].toString();
var FCYEXRATE = e.record.data['FCYEXRATE'];
var FCYAMT = e.record.data['FCYAMT'];
if (FCYNO.toString().trim() != 'RMB') {
var amount = Div(AMTCR, FCYEXRATE);
if (FCYAMT != amount) {
e.record.set('FCYAMT', amount);
}
}
}
}
},
'beforeedit': function (editor, e, eOpts) {
//if (e.colIdx == 4) {
// var sACCID = e.record.data['ACCID'].toString();
// var sACCALL = e.record.data['ACCALL'].toString();
// var ayListA = new Array();
// ayListA = sACCALL.split("▁");
// var AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', (sACCID + "-" + ayListA[0].toString()));
// if (AccitemsList.length == 0) {
// AccitemsList = DsStoreQueryBy(this.storeCwAccitems, 'ACCIDNAME', ayListA[0].toString());
// }
// if (AccitemsList.length > 0) {
// var AccitemsRaw = AccitemsList.getAt(0).raw;
// if (AccitemsRaw.ISDEPTACC || AccitemsRaw.ISEMPLACC || AccitemsRaw.ISCORPACC || AccitemsRaw.ISITEMACC) {
// return false;
// }
// }
//}
return true;
}
}
});
//#endregion
//#region 明细表-单据图片档案管理需求编号SR2017062800004
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
border: false,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 200,
renderer: function (value, p, record) {
return '<a href="' + record.data.Driect_URL + '" style=' + '"text-decoration:none"' + ' >' + value + '</a>';
}
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '上传人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '上传时间',
width: 135
}]
});
this.panelDoc = new Ext.Panel({
id: "panelDoc",
layout: "border",
region: 'south',
height: 200,
frame: false,
split: true,
border: false,
items: [this.gridDocList]
});
//#endregion
//#region 按钮Toolbar/框架/加载
_this = this;
//this.EditBtn = new Ext.Button({
// text:'编 辑', //显示查询
// handler: function () {
// if (_this.EditBtn.text == '编 辑') {//隐藏查询
// _this.gridList.reconfigure(_this.storeDetailList, _this.girdcolums);
// _this.EditBtn.setText('禁止编辑'); //显示查询
// } else {
// _this.EditBtn.setText('编 辑'); //隐藏查询
// _this.gridList.reconfigure(_this.storeDetailList, _this.girdcolumslist);
// }
// }
//});
this.panelBtn = new Ext.Panel({
region: "north",
border: false,
tbar: [{
text: '添加明细',
tooltip: '添加明细',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick();
},
scope: this
}, {
text: '插入明细',
tooltip: '插入明细',
id: "btninsert",
iconCls: "btnadd",
handler: function (button, event) {
this.onInsertClick();
},
scope: this
}, {
text: '上移',
tooltip: '上移',
id: "btnup",
// iconCls: "btnadd",
handler: function (button, event) {
this.onUpClick();
},
scope: this
}, {
text: '下移',
tooltip: '下移',
id: "btndown",
// iconCls: "btnadd",
handler: function (button, event) {
this.onDownClick();
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}, '-', {
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
}, {
id: 'btnCopy',
text: "复制",
handler: function (button, event) {
this.GetCopyText();
},
scope: this
}, {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, '-', {
text: '打印',
tooltip: '打印',
id: "btnprint",
iconCls: "btnprint",
handler: function (button, event) {
this.Print(button, event);
},
scope: this
}, {
text: '删除凭证',
tooltip: '删除凭证',
id: "btndelAll",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-', {
text: "审核",
id: "btISCHECKED",
iconCls: "btislock",
handler: function (button, event) {
this.setISCHECKED(1);
},
scope: this
}, {
text: "返审",
id: "btNotISCHECKED",
iconCls: "btnotislock",
handler: function (button, event) {
this.setISCHECKED(0);
},
scope: this
}, '-', {
text: "上一条",
id: "btPrevious",
handler: function (button, event) {
this.setPreviousLast(1);
},
scope: this
}, {
text: "下一条",
id: "btLast",
handler: function (button, event) {
this.setPreviousLast(2);
},
scope: this
}
//, this.EditBtn
]
}); //end 按钮Toolbar
this.panelTop = new Ext.Panel({
border: false,
layout: "border",
region: "north",
height: 98,
items: [this.panelBtn, this.formHead]
});
this.panelTop2 = new Ext.Panel({
border: false,
layout: "border",
region: "center",
items: [this.gridList, this.formBottom]
});
Ext.apply(this, {
border: false,
items: [this.panelTop, this.panelTop2, this.panelDoc]
});
parentWin = window.parent.opener;
if (this.ORDNO == undefined) {
this.InitData();
} else {
this.opStatus = 'edit';
condition = "ORDNO='" + this.ORDNO + "'";
_orderno = this.ORDNO;
this.LoadData('edit', condition);
//需求编号SR2017062800004
var condition2 = "BSNO='" + this.ORDNO + "'";
this.storeDocList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: condition2 });
}, this);
this.storeDocList.load({ params: { condition: condition2 }, waitMsg: "正在刷新数据...", scope: this });
}
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/RptCwGenlegAccitems/GetData',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
return;
}
data = result.data;
var arrtmp = data.toString().split("&");
this.strCwSTARTGID = arrtmp[0].toString();
var strCwSTARTNAME = arrtmp[1].toString();
Ext.getCmp("voutitle").setText('('+strCwSTARTNAME+')记账凭证');
// var sZQ = "&nbsp;&nbsp;当前登录账套:“" + strCwSTARTNAME + "”&nbsp;&nbsp;当前财务账期:“" + sYear + "年第" + sMonth + "期”&nbsp;&nbsp;";
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwapJK();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.EditRecord = ret[2];
this.sqlcontext = ret[3];
this.btnRefresh = ret[4];
this.tbVOUNO = ret[5];
this.btnAddCwVouchersJK = ret[6];
this.btnSelCwVouchersJK = ret[7];
this.tbVOUCHERNO = ret[8];
this.btnAddCwVouchers = ret[9];
this.btnSelCwVouchers = ret[10];
}
//
if (this.opStatus == 'edit') {
condition = "ORDNO='" + this.EditRecord.data.ORDNO + "'";
_orderno = this.EditRecord.data.ORDNO;
this.LoadData('edit', condition);
//需求编号SR2017062800004
var condition2 = "BSNO='" + this.EditRecord.data.ORDNO + "'";
this.storeDocList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: condition2 });
}, this);
this.storeDocList.load({ params: { condition: condition2 }, waitMsg: "正在刷新数据...", scope: this });
} else if (this.opStatus == 'add') {
this.GetAddText();
} else if (this.opStatus == 'sel') {
condition = "ORDNO in (select top 1 ORDNO from cw_vouchers_gl where VOUALLNO='" + this.sqlcontext + "')";
this.LoadData('edit', condition);
this.setBtnStatusDisable(true);
//需求编号SR2017062800004
var condition2 = "BSNO='" + this.EditRecord.data.ORDNO + "'";
this.storeDocList.on('beforeload', function (store) {
Ext.apply(store.proxy.extraParams, { condition: condition2 });
}, this);
this.storeDocList.load({ params: { condition: condition2 }, waitMsg: "正在刷新数据...", scope: this });
}
}, //end InitData
LoadData: function (opStatus, condition) {
this.serialNo = 0;
//this.opStatus = opStatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCwVouchersGl/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.INFO, buttons: Ext.Msg.OK });
return;
}
//
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
this.formBottom.getForm().reset();
this.formBottom.getForm().setValues(data);
//
var strVOUDATE = data.VOUDATE.toString();
var strY = strVOUDATE.substring(0, 4);
var strM = strVOUDATE.substring(5, 7);
this.formHead.getForm().findField('lbTitle2').setValue(strY + "年第" + strM + "期");
//
this.storeDetailList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
if (data.FCY.toString() != "RMB") {
this.onColumnsHidden(true, true);
}
//
if (data.ISCHECKED) {
this.setBtnStatusDisable(false);
}
else {
this.setBtnStatusDisable(true);
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//this.GetEditStatus();
}, // end LoadDate
//#endregion
//#region 保存
Save: function (type) {
this.formHead.getForm().findField('ORDNO').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
this.formHead.getForm().findField('ORDNO').setDisabled(true);
//
var sStatus = this.opStatus;
if (this.opStatus == 'sel') {
sStatus = 'edit';
}
//
var sAMTDR = 0;
var sAMTCR = 0;
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
sAMTDR += this.storeDetailList.getAt(i).get("AMTDR");
sAMTCR += this.storeDetailList.getAt(i).get("AMTCR");
//var member = this.storeDetailList.getAt(i);
//bodydatas.push(member);
}
sAMTDR = usMoney(sAMTDR, 2, '', false);
sAMTCR = usMoney(sAMTCR, 2, '', false);
if (sAMTDR != sAMTCR) {
// alert("录入借贷不平!请重新调整数据!");
Ext.Msg.show({ title: '提示', msg:'录入借贷不平!请重新调整数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //费用名称不能为空!'
return;
}
//
var bodydatas = [];
// var records = this.storeDetailList.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据
// var phantoms = this.storeDetailList.getNewRecords(); //获得幻影行
// records = records.concat(phantoms); //将幻影数据与真实数据合并
// if (records.length != 0) {
// for (var i = 0; i < records.length; i += 1) {
// var member = records[i];
// bodydatas.push(member);
// }
// }
var errostr = '';
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
var records = DsStoreQueryBy(this.storeCwAccitems, 'ACCID', member.data.ACCID);
if (records.getCount() > 0) {
var accdata = records.getAt(0).data;
var ai = 0;
var corpi = 0;
var depti = 0;
var empli = 0;
var itemi = 0;
if (accdata.ISCORPACC) {
ai = ai + 1;
corpi = ai;
}
if (accdata.ISDEPTACC) {
ai = ai + 1;
depti = ai;
}
if (accdata.ISEMPLACC) {
ai = ai + 1;
empli = ai;
}
if (accdata.ISITEMACC) {
ai = ai + 1;
itemi = ai;
}
var accall = member.data.ACCALL;
var accallarry = accall.split('▁');
if (accdata.ISCORPACC){
if ((accallarry.length < corpi + 1) || (accallarry.length >= corpi + 1 && accall[corpi] == ''))
errostr = errostr + '科目:' + member.data.ACCID + ',行号:' + member.data.ITEMNO + ',核算客户不能为空!';
}
if (accdata.ISDEPTACC) {
if ((accallarry.length < depti + 1) || (accallarry.length >= depti + 1 && accall[depti] == '')) errostr = errostr + '科目:' + member.data.ACCID + ',行号:' + member.data.ITEMNO + ',核算部门不能为空!';
}
if (accdata.ISEMPLACC) {
if ((accallarry.length < empli + 1) || (accallarry.length >= empli + 1 && accall[empli] == '')) errostr = errostr + '科目:' + member.data.ACCID + ',行号:' + member.data.ITEMNO + ',核算人员不能为空!';
}
if (accdata.ISITEMACC) {
if ((accallarry.length < itemi + 1) || (accallarry.length >= itemi + 1 && accall[itemi] == '')) errostr = errostr + '科目:' + member.data.ACCID + ',行号:' + member.data.ITEMNO + ',核算项目不能为空!';
}
}
var EXPLAN = member.data.EXPLAN;
if (EXPLAN == '') {
Ext.Msg.show({ title:'提示', msg:'凭证摘要不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var ACCID = member.data.ACCID;
if (ACCID == '') {
Ext.Msg.show({ title: '提示', msg: '科目代码不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
//var AMTDR = member.data.AMTDR;
//var AMTCR = member.data.AMTCR;
//if (AMTDR ==0&&AMTCR==0) {
// Ext.Msg.show({ title: '提示', msg: '借方和贷方不能同时为0', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
//};
bodydatas.push(member);
}
if (errostr != '') {
// Ext.MessageBox.alert('提示', errostr);
Ext.Msg.show({ title: '提示', msg: errostr, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); //费用名称不能为空!'
return;
}
this.setBtnStatusDisable(false);
//
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
var DelBody = ConvertRecordsToJsonAll(this.DelBody);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwVouchersGl/SaveEdit',
params: {
opStatus: sStatus,
data: Ext.JSON.encode(data),
body: jsonBody,
DelBody: DelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
if (this.opStatus == 'add') {
this.opStatus = 'edit';
}
var returnData = jsonresult.Data;
var condition = "ORDNO='" + returnData.ORDNO + "'";
this.formHead.getForm().findField('ORDNO').setDisabled(false);
this.formHead.getForm().findField('ORDNO').setValue(returnData.ORDNO);
this.formHead.getForm().findField('VOUNO').setValue(returnData.VOUNO);
this.formHead.getForm().findField('VOUNO').show();
Ext.getCmp('VOUNO_HAO').show();
this.formHead.getForm().findField('ORDNO').setDisabled(true);
this.formBottom.getForm().reset();
this.formBottom.getForm().setValues(returnData);
this.DelBody = [];
//
if (this.ORDNO == undefined) {
if (this.btnRefresh == null) {
this.tbVOUCHERNO.setValue(returnData.VOUALLNO);
this.btnAddCwVouchers.hide();
this.btnSelCwVouchers.show();
}
else {
var btn = opener.document.getElementById(this.btnRefresh.id);
btn.click();
}
}
//
this.storeDetailList.load({
params: { condition: condition },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
if (type == '0') {
var strVOUDATE = returnData.VOUDATE.toString();
var strY = strVOUDATE.substring(0, 4);
var strM = strVOUDATE.substring(5, 7);
this.formHead.getForm().findField('lbTitle2').setValue(strY + "年第" + strM + "期");
} else if (type == '1') {
window.close();
} else if (type == '2') {
this.GetAddText();
}
},
scope: this
});
//
this.setBtnStatusDisable(true);
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
this.setBtnStatusDisable(true);
}
} else {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
this.setBtnStatusDisable(true);
}
},
scope: this
});
}
}, //end save
//#endregion
//#region 新增明细
onAddClick: function () {
var ORDNO = this.formHead.getForm().findField('ORDNO').getValue();
var n = this.storeDetailList.getCount();
var sEXPLAN = "";
if (n > 0) {
sEXPLAN = this.storeDetailList.getAt(n - 1).get("EXPLAN");
}
//
var record = Ext.create('MsCwVouitemsGlModel', {
GID: '*',
ORDNO: ORDNO,
ITEMNO: n + 1,
EXPLAN: sEXPLAN,
ACCALL: '',
FCYNO: '', //RMB
FCYEXRATE: 1,
FCYAMT: 0,
AMTDR: 0,
AMTCR: 0,
ACCID: '',
DC: 'D'
});
this.storeDetailList.add(record);
this.gridListCellEditing.startEditByPosition({ row: n, column: 2 }); //n - 1
},
onInsertClick: function () {
var ORDNO = this.formHead.getForm().findField('ORDNO').getValue();
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
var n = this.storeDetailList.indexOf(rec);
var sEXPLAN = "";
if (n > 0) {
sEXPLAN = this.storeDetailList.getAt(n - 1).get("EXPLAN");
}
for (var i = n+1; i < this.storeDetailList.getCount() ; i += 1) {
var member = this.storeDetailList.getAt(i);
member.set("ITEMNO", member.data.ITEMNO+1);
member.commit();
}
//
var record = Ext.create('MsCwVouitemsGlModel', {
GID: '*',
ORDNO: ORDNO,
ITEMNO: n + 2,
EXPLAN: sEXPLAN,
ACCALL: '',
FCYNO: '', //RMB
FCYEXRATE: 1,
FCYAMT: 0,
AMTDR: 0,
AMTCR: 0,
ACCID: '',
DC: 'D'
});
this.storeDetailList.insert(n+1,record);
this.gridListCellEditing.startEditByPosition({ row: n+1, column: 2 }); //n - 1
},
onDownClick: function () {
var ORDNO = this.formHead.getForm().findField('ORDNO').getValue();
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
var n = this.storeDetailList.indexOf(rec);
var member = this.storeDetailList.getAt(n+1);
member.set("ITEMNO", member.data.ITEMNO-1);
member.commit();
this.storeDetailList.remove(rec);
rec.data.ITEMNO = rec.data.ITEMNO + 1;
this.storeDetailList.insert(n + 1, rec);
this.gridListCellEditing.startEditByPosition({ row: n + 1, column: 2 }); //n - 1
},
onUpClick: function () {
var ORDNO = this.formHead.getForm().findField('ORDNO').getValue();
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
var n = this.storeDetailList.indexOf(rec);
if (n==0) return;
var member = this.storeDetailList.getAt(n - 1);
member.set("ITEMNO", member.data.ITEMNO+1);
member.commit();
this.storeDetailList.remove(rec);
rec.data.ITEMNO = rec.data.ITEMNO -1;
this.storeDetailList.insert(n - 1, rec);
this.gridListCellEditing.startEditByPosition({ row: n-1, column: 2 }); //n - 1
},
//#endregion
//#region 删除明细
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.ContractNo != "" || rec.ContractNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.DelBody.push(rec);
}
this.storeDetailList.remove(selectedRecords[i]);
}
},
//#endregion
//#region 删除凭证
onDeleteClick: function (button, event) {
var sError = "";
var gids = this.formHead.getForm().findField('ORDNO').getValue();
var iscopy = this.formHead.getForm().findField('ISCOPY').getValue();
if (gids.trim() == "") {
Ext.Msg.show({ title: '提示', msg: '请先保存凭证!' + sError, icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
else {
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCwVouchersGl/Delete',
params: {
gids: gids,
iscopy:iscopy
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.remove(record);
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message + sError, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
if (this.btnRefresh == null) {
this.tbVOUCHERNO.setValue("");
this.btnAddCwVouchers.show();
this.btnSelCwVouchers.hide();
}
else {
var btn = opener.document.getElementById(this.btnRefresh.id);
btn.click();
}
window.close();
}
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.WARNING, buttons: Ext.Msg.OK });
},
success: function (response, options) { },
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
},
//#endregion
//#region 新建
GetAddText: function () {
this.opStatus = 'add';
var ORDNO = '*';
this.formHead.getForm().findField('ORDNO').setDisabled(false);
this.formHead.getForm().findField('ORDNO').setValue('*');
this.formHead.getForm().findField('ORDNO').setDisabled(true);
//
this.storeDetailList.removeAll(); //清空所有;
this.onColumnsHidden(true, false);
var VKNO = this.formHead.getForm().findField('VKNO').getValue();
//
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsBaseInfo/GetCwVOUNO',
params: {
VKNO: VKNO
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
//
data = result.data;
var arrayList = new Array();
arrayList = data.split("~");
var strY = arrayList[0].toString();
var strM = arrayList[1].toString();
var sVOUNO = arrayList[2].toString();
var strVOUNO = arrayList[3].toString();
var strVOUDATE = arrayList[4].toString();
var strACCDATE = arrayList[5].toString();
this.formHead.getForm().findField('VOUNO').setValue(sVOUNO);
this.formHead.getForm().findField('lbTitle2').setValue(strY + "年第" + strM + "期");
//
this.formHead.getForm().findField('VOUDATE').setValue(strVOUDATE);
Ext.getCmp('VOUDATE').setMinValue(strACCDATE + "-01");
//
this.formHead.getForm().findField('VOUNO').hide();
Ext.getCmp('VOUNO_HAO').hide();
//
this.setBtnStatusDisable(true);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//
this.onAddClick();
},
GetCopyText: function () {
this.opStatus = 'add';
var ORDNO = '*';
this.formHead.getForm().findField('ORDNO').setDisabled(false);
this.formHead.getForm().findField('ORDNO').setValue('*');
this.formHead.getForm().findField('ORDNO').setDisabled(true);
for (var i =0; i < this.storeDetailList.getCount() ; i += 1) {
var member = this.storeDetailList.getAt(i);
member.set("GID",'*');
member.commit();
}
//
// this.storeDetailList.removeAll(); //清空所有;
// this.onColumnsHidden(true, false);
var VKNO = this.formHead.getForm().findField('VKNO').getValue();
//
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsBaseInfo/GetCwVOUNO',
params: {
VKNO: VKNO
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
//
data = result.data;
var arrayList = new Array();
arrayList = data.split("~");
var strY = arrayList[0].toString();
var strM = arrayList[1].toString();
var sVOUNO = arrayList[2].toString();
var strVOUNO = arrayList[3].toString();
var strVOUDATE = arrayList[4].toString();
var strACCDATE = arrayList[5].toString();
//this.formHead.getForm().findField('VOUNO').setValue(sVOUNO);
this.formHead.getForm().findField('VOUNO').setValue("");//复制时清空凭证号
this.formHead.getForm().findField('lbTitle2').setValue(strY + "年第" + strM + "期");
//
this.formHead.getForm().findField('VOUDATE').setValue(strVOUDATE);
Ext.getCmp('VOUDATE').setMinValue(strACCDATE + "-01");
//
this.formHead.getForm().findField('VOUNO').hide();
Ext.getCmp('VOUNO_HAO').hide();
//
this.setBtnStatusDisable(true);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
//
},
//#endregion
//#region 按钮函数
onColumnsHidden: function (isHide, blISFCY) {
if (blISFCY) {
this.gridList.columns[4].show();
this.gridList.columns[5].show();
this.gridList.columns[6].show();
}
else {
if (isHide) {
this.gridList.columns[4].hide();
this.gridList.columns[5].hide();
this.gridList.columns[6].hide();
}
}
},
GetEditStatus: function () {
var canedit = false;
_this = this;
Ext.Ajax.request({
waitMsg: '正在查询委托编号状态...',
url: '/MvcShipping/MsBaseInfo/GetRuleEdit',
params: {
rulename: '委托编号',
ruletype: '4'
},
callback: function (options, success, response) {
if (success) {
var custno = _this.formHead.getForm().findField('VOUALLNO');
custno.setReadOnly(true);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
Print: function (button, event) {
if (this.opStatus == "edit" || this.opStatus == "sel") {
var sql = "";
if (this.opStatus == "edit") {
var ORDNO = this.formHead.getForm().findField('ORDNO').getValue();
sql = "ORDNO='" + ORDNO + "'";
}
else if (this.opStatus == "sel") {
sql = "ORDNO in (select top 1 ORDNO from cw_vouchers_gl where VOUALLNO='" + this.sqlcontext + "')";
}
Ext.Ajax.request({
waitMsg: '正在组织数据, 请稍侯...',
url: '/MvcShipping/MsCwVouchersGl/GetDataListStr',
params: { condition: sql, printstr: 'true' },
callback: function (options, success, response) {
if (success) {
var ddd = Ext.MessageBox.isVisible();
if (Ext.MessageBox.isVisible()) {
Ext.MessageBox.hide();
}
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnStr = jsonresult.data;
var printType = 'MsCwVouchersGlIndex';
var sql1 = returnStr;
var sql2 = "";
var sql3 = "";
var sql4 = "";
var sql5 = "";
var sql6 = "";
PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6);
} 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
});
}
},
scope: this
});
}
},
setBtnStatusDisable: function (enable) {
var CREATEUSERNAME = this.formBottom.getForm().findField('CREATEUSERNAME').getValue();
_this = this;
var canedit = false;
if (enable) {
if (this.StoreOpRangeEdit.getCount() > 0) {
var records = DsStoreQueryBy(_this.StoreOpRangeEdit, 'OPID', CREATEUSERNAME);
if (records.getCount() > 0) {
this.setBtnStatus(true);
} else this.setBtnStatus(false);
} else {
this.StoreOpRangeEdit.load({
params: { optype: "MODVOUCHERGL" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRangeEdit, 'OPID', CREATEUSERNAME);
if (records.getCount() > 0) {
canedit = true;
} else {
canedit = false;
}
} else { canedit = false; }
_this.setBtnStatus(canedit);
}
}
});
}
} else this.setBtnStatus(enable);
},
setBtnStatus: function (enable) {
var sbtnadd = Ext.getCmp('btnadd');
var sbtnSave = Ext.getCmp('btnSave');
var sbtnSaveAndClose = Ext.getCmp('btnSaveAndClose');
var sbtnSaveAndNew = Ext.getCmp('btnSaveAndNew');
var sbtnNew = Ext.getCmp('btnNew');
var sbtndel = Ext.getCmp('btndel');
var sbtnprint = Ext.getCmp('btnprint');
var sbtISCHECKED = Ext.getCmp('btISCHECKED');
var sbtNotISCHECKED = Ext.getCmp('btNotISCHECKED');
var sbtPrevious = Ext.getCmp('btPrevious');
var sbtLast = Ext.getCmp('btLast');
var sbtndelAll = Ext.getCmp('btndelAll');
var sbtnCopy = Ext.getCmp('btnCopy');
var sbtninsert = Ext.getCmp('btninsert');
var sbtnup = Ext.getCmp('btnup');
var sbtndown = Ext.getCmp('btndown');
if (enable) {
sbtnadd.enable();
sbtnSave.enable();
sbtnSaveAndClose.enable();
sbtnSaveAndNew.enable();
sbtnNew.enable();
sbtndel.enable();
sbtnprint.enable();
sbtISCHECKED.enable();
sbtNotISCHECKED.disable();
sbtnCopy.enable();
sbtninsert.enable();
sbtnup.enable();
sbtndown.enable();
Ext.getCmp("btISCHECKED").show(); //显示按钮
Ext.getCmp("btNotISCHECKED").hide(); //隐藏按钮
sbtndelAll.hide();
if (this.opStatus == "add") {
sbtnprint.disable();
sbtISCHECKED.disable();
sbtNotISCHECKED.disable();
sbtPrevious.hide();
sbtLast.hide();
}
else if (this.opStatus == "edit") {
sbtPrevious.show();
sbtLast.show();
}
else if (this.opStatus == "sel") {
sbtnadd.hide();
sbtnSaveAndNew.hide();
sbtnNew.hide();
sbtPrevious.hide();
sbtLast.hide();
sbtndelAll.show();
}
} else {
sbtnadd.disable();
sbtnSave.disable();
sbtnSaveAndClose.disable();
sbtnSaveAndNew.disable();
sbtnNew.enable();
sbtndel.disable();
sbtnCopy.enable();
sbtninsert.disable();
sbtnup.disable();
sbtndown.disable();
sbtISCHECKED.disable();
sbtNotISCHECKED.enable();
Ext.getCmp("btISCHECKED").hide(); //隐藏按钮
Ext.getCmp("btNotISCHECKED").show(); //显示按钮
sbtndelAll.hide();
if (this.opStatus == "add") {
sbtnprint.disable();
sbtISCHECKED.disable();
sbtNotISCHECKED.disable();
sbtPrevious.hide();
sbtLast.hide();
}
else if (this.opStatus == "edit") {
sbtPrevious.show();
sbtLast.show();
}
else if (this.opStatus == "sel") {
sbtnadd.hide();
sbtnSaveAndNew.hide();
sbtnNew.hide();
sbtPrevious.hide();
sbtLast.hide();
sbtndelAll.show();
}
}
},
onNextKeyClick: function (col) {
var rows = this.gridList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridList.getStore();
var number = s.indexOf(row);
this.gridListCellEditing.startEditByPosition({ row: number, column: col });
},
//#endregion
//#region 审核/返审
setISCHECKED: function (iTYPE) {
if (this.opStatus == "edit" || this.opStatus == "sel") {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/RptCwGenlegAccitems/GetData',
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (!result.Success) {
return;
}
data = result.data;
var arrtmp = data.toString().split("&");
this.strCwSTARTGID = arrtmp[0].toString();
var strCwSTARTNAME = arrtmp[1].toString();
var strCwACCDATE = arrtmp[2].toString();
var sYear = arrtmp[3].toString();
var sMonth = arrtmp[4].toString();
//
var iError = 0;
if (this.EditRecord != null) {
//var kjqj = this.EditRecord.data.VOUDATE.toString().substr(0, 7);
var kjqj = this.formHead.getForm().findField('VOUDATE').getRawValue().toString().substr(0, 7);
//kjqj = "2015-03";
if (kjqj < strCwACCDATE) {
Ext.Msg.show({ title: '警告', msg: '已经结转的期间凭证,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
//
var sNAME = "审核";
if (iTYPE == 0) {
sNAME = "返审";
if (this.StoreOpRange2.getCount() == 0) {
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
else {
var records = DsStoreQueryBy(this.StoreOpRange2, 'OPID', SHOWNAME); //制单人this.EditRecord.data.PREPARED
if (records.getCount() > 0) {
} else {
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
}
else {//审核
if (this.StoreOpRange.getCount() == 0) {
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
else {
var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', SHOWNAME); //制单人this.EditRecord.data.PREPARED
if (records.getCount() > 0) {
} else {
Ext.Msg.show({ title: '警告', msg: '权限不足,不允许操作!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK });
return;
}
}
}
//
var strGIDs = this.formHead.getForm().findField('ORDNO').getValue(); //this.EditRecord.data.ORDNO
if (strGIDs.toString().trim() == "" || strGIDs.toString().trim() == "*") {
alert("请先保存凭证!");
return;
}
else {
//Ext.MessageBox.confirm('提示', '确定' + sNAME + '吗?', function (btn) {
//if (btn == 'yes') {
Ext.Msg.wait('正在' + sNAME + '...');
Ext.Ajax.request({
waitMsg: '正在' + sNAME + '...',
url: '/MvcShipping/MsCwVouchersGl/setISCHECKED',
params: {
gids: strGIDs,
iTYPE: iTYPE,
iOK: 0,
iSkip: 0
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//Ext.Msg.show({ title: '提示', msg: '操作完成!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
//if (jsonresult.Message.toString().indexOf("0条。") <0) {
if (sNAME == "审核") {
this.setBtnStatusDisable(false);
}
else {
this.setBtnStatusDisable(true);
}
//}
//else {
// Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, 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.WARNING, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
});
//}
//}, this);
}
} else {
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
else {
alert("请先保存凭证!");
return;
}
},
//#endregion
//#region 1.上一条 / 2.下一条
setPreviousLast: function (iTYPE) {
if (this.opStatus == "edit") {
var strORDNO = this.formHead.getForm().findField('ORDNO').getValue();
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCwVouchersGl/setPrevious',
params: {
iTYPE: iTYPE,
ORDNO: strORDNO,
strCondition: this.sqlcontext
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
//
condition = "ORDNO='" + result.Message.toString() + "'";
this.LoadData('edit', condition);
_orderno = result.Message.toString();
var condition2 = "BSNO='" + result.Message.toString() + "'";
this.Loading = true;
this.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
this.Loading = false;
}
});
} else {
Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.INFO, buttons: Ext.Msg.OK });
return;
//Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
},
//#endregion
//#region 层_显示信息
showContactForm: function (win, strValue, strOriginalValue, AccitemsRaw, selections, isFocus) {
var required = '<span style="color:red;font-weight:bold;" data-qtip="Required">*</span>';
if (!win) {
var strITEM = '';
//#region formSearch 下拉框信息加载
//科目加载
this.storeCwAccitems2 = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwAccitemsGlModel',
//proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' }
proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGlAll' }
});
this.storeCwAccitems2.loadData(this.storeCwAccitems.data.items);
// this.storeCwAccitems2.load({ params: { condition: "DETAILED=1 and ISENABLE=1" } });
this.comboxACCNAME2 = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '科目名称',
store: this.storeCwAccitems2,
forceSelection: true, //输入值是否严格为待选列表中存在的值
id: 'ACCNAME2',
name: 'ACCNAME2',
valueField: 'ACCNAME',
displayField: 'ACCIDNAME',
allowBlank: false,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (combo.value != "") {
var AccitemsList = DsStoreQueryBy(this.storeCwAccitems2, 'ACCIDNAME', combo.rawValue.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
if (AccitemsRaw.ISCORPACC) {
Ext.getCmp('CustNAME').show();
}
else {
Ext.getCmp('CustNAME').setValue("");
Ext.getCmp('CustNAME').hide();
}
if (AccitemsRaw.ISDEPTACC) {
Ext.getCmp('DeptName').show();
}
else {
Ext.getCmp('DeptName').setValue("");
Ext.getCmp('DeptName').hide();
}
if (AccitemsRaw.ISEMPLACC) {
Ext.getCmp('SALE').show();
}
else {
Ext.getCmp('SALE').setValue("");
Ext.getCmp('SALE').hide();
}
if (AccitemsRaw.ISITEMACC) {
Ext.getCmp('ITEMNAME').show();
}
else {
Ext.getCmp('ITEMNAME').setValue("");
Ext.getCmp('ITEMNAME').hide();
}
//是不是外币都默认为RMB
var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
if (AccitemsRaw.ISFCY) {
//如果是外币,则默认传送''
Ext.Ajax.request({
waitMsg: '正在查询汇率值...',
url: '/MvcShipping/MsCwVouchersGl/GetFCYEXRATEBYVOUDATE',
params: {
FCY: '',
LINKGID: AccitemsRaw.GID.toString()
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
var strArg = result.data.toString().split("");
var FCYNO = strArg[0].toString();
// var strFCYEXRATE = selections[0].data.FCYEXRATE;
var strFCYEXRATE = strArg[1].toString();
if (strFCYEXRATE == 1) {
strFCYEXRATE = Div(strArg[1].toString(), 1, 5);
}
selections[0].set('FCYEXRATE', strFCYEXRATE.toString());
selections[0].set('FCYNO', FCYNO);
selections[0].set('CURRENCY', FCYNO);
//
var AMTDR = selections[0].data.AMTDR;
var AMTCR = selections[0].data.AMTCR;
var AMT = 0;
if (AMTDR != 0) {
AMT = AMTDR;
}
if (AMTCR != 0) {
AMT = AMTCR;
}
selections[0].set('FCYAMT', Div(AMT, strFCYEXRATE, 2));
//
this.onColumnsHidden(false, AccitemsRaw.ISFCY);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
else {
selections[0].set('FCYEXRATE', 1);
selections[0].set('FCYNO', 'RMB');
selections[0].set('FCYAMT', 0);
}
}
}
//
},
//'keypress': {
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 118) {//F7
DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 300), (window.screen.availWidth / 2 - 500));
}
},
scope: this
}
}
});
//客户加载
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListRm' }
});
//this.storeCustCode.load({ params: { condition: "((FARCODE!='' and FARCODE is not null) or (FAPCODE!='' and FAPCODE is not null))"} });
// this.storeCustCode.load({ params: { condition: ""} });
this.comboxCust = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户',
store: this.storeCustCode,
forceSelection: true,
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
//focusOnToFront: true,
selectOnFocus: true,
id: 'CustNAME',
name: 'CustNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
//allowBlank: false,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': {
fn: function (e) {
e.expand();
//this.doQuery(this.allQuery, true);
},
buffer: 200
}
}
});
//部门加载
this.storeDept = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.DeptModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptListRm' }
});
//this.storeDept.load({ params: { condition: "(FINANCESOFTCODE!='' and FINANCESOFTCODE is not null)"} });
this.storeDept.load({ params: { condition: ""} });
this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '部门',
store: this.storeDept,
id: 'DeptName',
name: 'DeptName',
queryMode: 'remote',
minChars: 1,
queryParam: 'CODENAME',
valueField: 'DeptName',
displayField: 'NOANDNAME',
forceSelection: true,
//allowBlank: false,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': {
fn: function (e) {
e.expand();
//this.doQuery(this.allQuery, true);
},
buffer: 200
}
// 'keyup': {
// fn: function (_field, e) {
// if (e.getKey() == 118) {//F7
// DsOpenEditWin('../../ParameterSet/ATSysDeptSet.aspx?mod=modATSysDeptSet&ISFINANCESOFTCODE=true', "部门信息", "650", "900", (window.screen.availHeight / 2 - 300), (window.screen.availWidth / 2 - 500));
// }
// },
// scope: this
// },
// 'select': function (combo, records, eOpts) {
// Ext.Ajax.request({
// waitMsg: '正在查询是否已经维护财务代码...',
// url: '/MvcShipping/MsCwVouchersGl/GetISFINANCESOFTCODE',
// params: {
// TYPE: 'DeptName',
// VALUE: combo.value
// },
// 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.INFO, buttons: Ext.Msg.OK });
// combo.setValue("");
// return;
// }
// strFINANCESOFTCODE = result.data;
// combo.setValue(strFINANCESOFTCODE);
// } else {
// Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
// }
// },
// scope: this
// });
// }
}
});
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
//this.storeOpCode.load({ params: { condition: "(FINANCESOFTCODE!='' and FINANCESOFTCODE is not null)"} });
this.storeOpCode.load();
this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '人员',
store: this.storeOpCode,
id: 'SALE',
name: 'SALE',
valueField: 'UserName',
displayField: 'CodeAndName',
//value: SHOWNAME,
forceSelection: true,
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': {
fn: function (e) {
e.expand();
//this.doQuery(this.allQuery, true);
},
buffer: 200
}
// 'select': function (combo, records, eOpts) {
// Ext.Ajax.request({
// waitMsg: '正在查询是否已经维护财务代码...',
// url: '/MvcShipping/MsCwVouchersGl/GetISFINANCESOFTCODE',
// params: {
// TYPE: 'SALE',
// VALUE: combo.value
// },
// 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.INFO, buttons: Ext.Msg.OK });
// combo.setValue("");
// return;
// }
// strFINANCESOFTCODE = result.data;
// combo.setValue(strFINANCESOFTCODE);
// } else {
// Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
// }
// },
// scope: this
// });
// },
// 'keyup': {
// fn: function (_field, e) {
// if (e.getKey() == 118) {//F7
// DsOpenEditWin('../../ParameterSet/ATUserSet.aspx?mod=modATUser&ISFINANCESOFTCODE=true', "人员信息", "650", "900", (window.screen.availHeight / 2 - 300), (window.screen.availWidth / 2 - 500));
// }
// },
// scope: this
// }
}
});
//项目加载
this.storeCwItem = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CwItemModel',
proxy: { url: '/CommMng/BasicDataRef/GetCwItemList' }
});
this.storeCwItem.load();
//this.storeCwItem.load({ params: { condition: "(FINANCESOFTCODE!='' and FINANCESOFTCODE is not null)"} });
this.comboxCwItem = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '项目',
store: this.storeCwItem,
forceSelection: true,
id: 'ITEMNAME',
name: 'ITEMNAME',
valueField: 'ITEMNAME',
displayField: 'CodeAndName', //CodeAndName
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'focus': {
fn: function (e) {
e.expand();
//this.doQuery(this.allQuery, true);
},
buffer: 200
}
// 'select': function (combo, records, eOpts) {
// Ext.Ajax.request({
// waitMsg: '正在查询是否已经维护财务代码...',
// url: '/MvcShipping/MsCwVouchersGl/GetISFINANCESOFTCODE',
// params: {
// TYPE: 'ITEMNAME',
// VALUE: combo.value
// },
// 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.INFO, buttons: Ext.Msg.OK });
// combo.setValue("");
// return;
// }
// strFINANCESOFTCODE = result.data;
// combo.setValue(strFINANCESOFTCODE);
// } else {
// Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
// }
// },
// scope: this
// });
// }
}
});
//#endregion
//#region 编辑formDiv 基本信息
var formDiv = Ext.widget('form', {
id: 'formDiv',
border: false,
bodyPadding: 10,
fieldDefaults: {
labelAlign: 'right',
labelWidth: 60,
labelStyle: 'font-weight:bold'
},
items: [this.comboxACCNAME2, this.comboxCust, this.comboxDept, this.comboxSALE, this.comboxCwItem],
buttons: [{
text: '取消',
handler: function () {
//var selections = this.gridList.getSelectionModel().getSelection(); //获得选中的项
selections[0].set('ACCALL', strOriginalValue);
this.up('form').getForm().reset();
//this.up('window').hide();
this.up('window').close();
}
}, {
id: 'tijiao',
text: '提交',
handler: function (options, success, response) {
//var _this2 = Ext.getCmp('formDiv');
//if (!_this2.getForm().isValid()) {
// return;
//}
this.GetSubmit(win, selections, this, strITEM);
//#region GetSubmit函数前身
//var strACCNAME2 = this.up('form').getForm().findField('ACCNAME2').getValue();
//var ls = strACCNAME2;
//if (this.up('form').getForm().findField('CustNAME').getValue() != null) {
// var CustNAME = this.up('form').getForm().findField('CustNAME').getValue();
// if (CustNAME.toString().trim() != "") {
// ls += "▁" + CustNAME;
// }
//}
//if (this.up('form').getForm().findField('DeptName').getValue() != null) {
// var DeptName = this.up('form').getForm().findField('DeptName').getValue();
// if (DeptName.toString().trim() != "") {
// ls += "▁" + DeptName;
// }
//}
//if (this.up('form').getForm().findField('SALE').getValue() != null) {
// var SALE = this.up('form').getForm().findField('SALE').getValue();
// if (SALE.toString().trim() != "") {
// ls += "▁" + SALE;
// }
//}
//if (this.up('form').getForm().findField('ITEMNAME').getValue() != null) {
// var ITEMNAME = this.up('form').getForm().findField('ITEMNAME').getValue();
// if (ITEMNAME.toString().trim() != "") {
// ls += "▁" + ITEMNAME;
// }
//}
//selections[0].set('ACCALL', ls);
////
//this.up('form').getForm().reset();
//this.up('window').hide();
//#endregion
},
scope: this
}],
listeners: {
scope: this,
//'beforeload': function () {
'render': function (thisDiv, thisExtend) {
//#region 加载下拉框信息
// this.storeCwAccitems.load({ async: false, params: { condition: "DETAILED=1" }, scope: this });
// this.storeCustCode.load({ async: false, params: { condition: ""} });
this.storeDept.load({ async: false, params: { condition: ""} });
this.storeOpCode.load({ async: false });
this.storeCwItem.load({ async: false });
//#endregion
//#region 显示/隐藏下拉框
var sFocus = "";
Ext.getCmp('ACCNAME2').hide();
//var strITEM = "ACCNAME2";
strITEM = "ACCNAME2";
if (AccitemsRaw.ISCORPACC) {
//thisDiv.getForm().findField('CustNAME').hidden = false;
Ext.getCmp('CustNAME').show();
strITEM += "▁CustNAME";
sFocus += ",1";
}
else {
//thisDiv.getForm().findField('CustNAME').hidden = true;
Ext.getCmp('CustNAME').setValue("");
Ext.getCmp('CustNAME').hide();
}
//
if (AccitemsRaw.ISDEPTACC) {
Ext.getCmp('DeptName').show();
strITEM += "▁DeptName";
sFocus += ",2";
}
else {
Ext.getCmp('DeptName').setValue("");
Ext.getCmp('DeptName').hide();
}
//
if (AccitemsRaw.ISEMPLACC) {
Ext.getCmp('SALE').show();
strITEM += "▁SALE";
sFocus += ",3";
}
else {
Ext.getCmp('SALE').setValue("");
Ext.getCmp('SALE').hide();
}
//
if (AccitemsRaw.ISITEMACC) {
Ext.getCmp('ITEMNAME').show();
strITEM += "▁ITEMNAME";
sFocus += ",4";
}
else {
Ext.getCmp('ITEMNAME').setValue("");
Ext.getCmp('ITEMNAME').hide();
}
//
if (isFocus) {
if (strOriginalValue != "") {
var ayList = new Array();
ayList = strOriginalValue.split("▁");
var ayItem = new Array();
ayItem = strITEM.split("▁");
for (var i = 0; i < ayList.length; i++) {
Ext.getCmp(ayItem[i].toString()).setValue(ayList[i].toString());
//thisDiv.getForm().findField(ayItem[i].toString()).setValue(ayList[i].toString());
}
}
}
else {
if (strValue != "") {
Ext.getCmp('ACCNAME2').setValue(strValue);
}
}
//#endregion
//#region 设置下拉框焦点
var isFocus = Ext.getCmp('CustNAME');
if (sFocus.indexOf(",1") == 0) {
isFocus = Ext.getCmp('CustNAME');
}
else if (sFocus.indexOf(",2") == 0) {
isFocus = Ext.getCmp('DeptName');
}
else if (sFocus.indexOf(",3") == 0) {
isFocus = Ext.getCmp('SALE');
}
else if (sFocus.indexOf(",4") == 0) {
isFocus = Ext.getCmp('ITEMNAME');
}
isFocus.focus(true, true);
//#endregion
//#region 设置下拉框回车事件
var sFocus2 = sFocus.toString().substr(1);
var argItems = sFocus2.toString().split(",");
for (var i = 0; i < argItems.length; i++) {
if (argItems.length == 1 || (argItems.length - 1) == i) {
//#region 回车+提交事件
if (argItems[i].toString() == "1") {
this.comboxCust.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
//this.GetSubmit(win, selections, this);
isFocus = Ext.getCmp('tijiao');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i].toString() == "2") {
this.comboxDept.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
//this.GetSubmit(win, selections, this);
isFocus = Ext.getCmp('tijiao');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i].toString() == "3") {
this.comboxSALE.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
//this.GetSubmit(win, selections, this);
isFocus = Ext.getCmp('tijiao');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i].toString() == "4") {
this.comboxCwItem.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
//this.GetSubmit(win, selections, this);
isFocus = Ext.getCmp('tijiao');
isFocus.focus(true, true);
}
}, this);
}
//#endregion
}
else {
//#region 回车+焦点事件
if (argItems[i].toString() == "1") {
if (argItems[i + 1].toString() == "2") {
this.comboxCust.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('DeptName');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i + 1].toString() == "3") {
this.comboxCust.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('SALE');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i + 1].toString() == "4") {
this.comboxCust.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('ITEMNAME');
isFocus.focus(true, true);
}
}, this);
}
}
else if (argItems[i].toString() == "2") {
if (argItems[i + 1].toString() == "3") {
this.comboxDept.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('SALE');
isFocus.focus(true, true);
}
}, this);
}
else if (argItems[i + 1].toString() == "4") {
this.comboxDept.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('ITEMNAME');
isFocus.focus(true, true);
}
}, this);
}
}
else if (argItems[i].toString() == "3") {
if (argItems[i + 1].toString() == "4") {
this.comboxSALE.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
isFocus = Ext.getCmp('ITEMNAME');
isFocus.focus(true, true);
}
}, this);
}
}
else if (argItems[i].toString() == "4") {
this.comboxCwItem.addListener('keyup', function (dataview, record, item) {
if (record.getKey() == 13) {
//this.GetSubmit(win, selections, this);
isFocus = Ext.getCmp('tijiao');
isFocus.focus(true, true);
}
}, this);
}
//#endregion
}
}
//
isFocus = Ext.getCmp('tijiao');
isFocus.addListener('focus', function (dataview, record, item) {
//if (!this.up('form').getForm().isValid()) {
// return;
//}
if (!thisDiv.getForm().isValid()) {
return;
}
this.GetSubmit(win, selections, this, strITEM);
}, this);
//#endregion
}
}
});
//#endregion
win = Ext.widget('window', {
title: '辅助核算',
closeAction: 'destroy', //hide,
id:'winaccitemsedit',
width: 250,
height: 250,
layout: 'fit',
modal: true,
closable: false, //为false时tab上不显示叉号
resizable: false, //是否可改变列宽,默认为true
items: formDiv
//draggable: false,//不允许窗体被拖拽
//获取当前鼠标坐标并设置为其生产的初始位置
//x: 250,
//y: 150,
});
}
win.show();
},
GetSubmit: function (win, selections, _this, strITEM) {
//var strACCNAME2 = _this.up('form').getForm().findField('ACCNAME2').getValue();
//var strACCNAME2 = Ext.getCmp('ACCNAME2').getValue();
var strACCNAME2 = selections[0].data.ACCALL.toString();
var ls = strACCNAME2;
if (Ext.getCmp('CustNAME').getValue() != null) {
if (Ext.getCmp('CustNAME').getValue() != "") {
var CustNAME = Ext.getCmp('CustNAME').getValue();
var re = new RegExp(/^[A-Za-z]+$/);
var bl = re.test(CustNAME);
if (bl) {
if (CustNAME.indexOf("-") < 0) {
var AccitemsList = DsStoreQueryBy(this.storeCustCode, 'CustName', CustNAME.toString()); //CustCode
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
CustNAME = AccitemsRaw.data.CustName.toString();
}
else {
return false;
}
}
else {
return false;
}
}
else {
var AccitemsList = DsStoreQueryBy(this.storeCustCode, 'CodeAndName', CustNAME.toString().toUpperCase());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
CustNAME = AccitemsRaw.data.CustName.toString();
}
else {
return false;
}
}
else {
return false;
}
}
}
else {
if (CustNAME.indexOf("-") < 0) {
var AccitemsList = DsStoreQueryBy(this.storeCustCode, 'CustName', CustNAME.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
CustNAME = AccitemsRaw.data.CustName.toString();
}
else {
return false;
}
}
else {
return false;
}
}
else {
var AccitemsList = DsStoreQueryBy(this.storeCustCode, 'CodeAndName', CustNAME.toString().toUpperCase());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
CustNAME = AccitemsRaw.data.CustName.toString();
}
else {
return false;
}
}
else {
var AccitemsList = DsStoreQueryBy(this.storeCustCode, 'CustName', CustNAME.toString().toUpperCase());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
CustNAME = AccitemsRaw.data.CustName.toString();
}
else {
return false;
}
}
else {
return false;
}
}
}
}
if (CustNAME.toString().trim() != "") {
ls += "▁" + CustNAME;
}
}
else {
if (strITEM.toString().indexOf("CustNAME") > -1) {
return;
}
}
}
else {
if (strITEM.toString().indexOf("CustNAME") > -1) {
return;
}
}
if (Ext.getCmp('DeptName').getValue() != null) {
if (Ext.getCmp('DeptName').getValue() != "") {
var DeptName = Ext.getCmp('DeptName').getValue();
if (DeptName.indexOf("-") > -1) {
DeptName = DeptName.toString().substr(DeptName.indexOf("-") + 1);
}
if (DeptName.toString().trim() != "") {
ls += "▁" + DeptName;
}
}
else {
if (strITEM.toString().indexOf("DeptName") > -1) {
return;
}
}
}
else {
if (strITEM.toString().indexOf("DeptName") > -1) {
return;
}
}
if (Ext.getCmp('SALE').getValue() != null) {
if (Ext.getCmp('SALE').getValue() != "") {
var SALE = Ext.getCmp('SALE').getValue();
var re = new RegExp(/^[A-Za-z]+$/);
var bl = re.test(SALE);
if (bl) {
var AccitemsList = DsStoreQueryBy(this.storeOpCode, 'UserCode', SALE.toString().toUpperCase());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
SALE = AccitemsRaw.data.UserName.toString();
}
else {
return false;
}
}
else {
return false;
}
}
//
if (SALE.indexOf("-") > -1) {
SALE = SALE.toString().substr(SALE.indexOf("-") + 1);
}
if (SALE.toString().trim() != "") {
ls += "▁" + SALE;
}
}
else {
if (strITEM.toString().indexOf("SALE") > -1) {
return;
}
}
}
else {
if (strITEM.toString().indexOf("SALE") > -1) {
return;
}
}
if (Ext.getCmp('ITEMNAME').getValue() != null) {
if (Ext.getCmp('ITEMNAME').getValue() != "") {
var ITEMNAME = Ext.getCmp('ITEMNAME').getValue();
var re = new RegExp(/^[0-9a-zA-Z]+$/);
var bl = re.test(ITEMNAME);
if (bl) {
var AccitemsList = DsStoreQueryBy(this.storeCwItem, 'ITEMCODE', ITEMNAME.toString().toUpperCase());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0);
if (AccitemsRaw != null) {
ITEMNAME = AccitemsRaw.data.ITEMNAME.toString();
}
}
}
if (ITEMNAME.indexOf("-") > -1) {
ITEMNAME = ITEMNAME.toString().substr(ITEMNAME.indexOf("-") + 1);
}
if (ITEMNAME.toString().trim() != "") {
ls += "▁" + ITEMNAME;
}
}
else {
if (strITEM.toString().indexOf("ITEMNAME") > -1) {
return;
}
}
}
else {
if (strITEM.toString().indexOf("ITEMNAME") > -1) {
return;
}
}
selections[0].set('ACCALL', ls);
//
var rows = this.gridList.getSelectionModel().getSelection();
if (rows[0].data.FCYNO == "RMB") {
this.onNextKeyClick(7);
}
else {
this.onNextKeyClick(5);
}
//
var lsACCALL = rows[0].data.ACCALL.toString();
while (lsACCALL != ls) {
rows = this.gridList.getSelectionModel().getSelection();
var lsACCALL = rows[0].data.ACCALL.toString();
selections[0].set('ACCALL', ls);
}
//
//var win = Ext.getCmp("DivWin");
//var win = this.up("window");
//win.hide();
win.close();
},
onNextKeyClick: function (col) {
var rows = this.gridList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridList.getStore();
var number = s.indexOf(row);
this.gridListCellEditing.startEditByPosition({ row: number, column: col });
},
OprationSwap2: function () {
var ret = new Array();
ret[0] = this.gridList.getSelectionModel().getSelection();
ret[1] = this.comboxACCNAME;
ret[2] = this.comboxCust;
ret[3] = this.comboxDept;
ret[4] = this.comboxSALE;
return ret;
},
//#endregion
//#region 上传附件, 需求编号SR2017062800004
onUpLoadFileClick: function (button, event) {
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: '请先保存凭证!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var billno = this.EditRecord.get("VOUALLNO");
var sORDNO = _orderno;
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadFile',
name: 'LoadFile',
emptyText: '请选择文件',
fieldLabel: '文件',
buttonText: '选择文件',
allowBlank: false,
buttonCfg: { iconCls: 'uploaddialog' },
anchor: '98%'
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadFile').getValue();
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/MvcShipping/MsOpReceipt/UploadFile',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
CUSTNO: billno,
BSNO: sORDNO
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
var condition2 = "BSNO='" + sORDNO + "'";
me.Loading = true;
me.storeDocList.load({
params: { condition: condition2 },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
me.Loading = false;
}
});
var cnt = me.storeDocList.data.items.length + 1;
Ext.getCmp("ATTACHS").setValue(cnt);
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传文件",
width: 360,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
},
//#endregion
//#region 删除上传附件, 需求编号SR2017062800004
onDelFileClick: function (button, event) {
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: '请先保存凭证!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var feeGidSql = '';
var selectedRecords = [];
selectedRecords = this.DocCM.selected.items;
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择要删除的附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定要删除选中的附件吗?', function (btn) {
if (btn == 'yes') {
if (selectedRecords.length > 0) {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.data.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDocList.remove(selectedRecords[i]);
}
else {
var feeGId = "'" + rec.data.GID + "'";
if (feeGidSql == '') {
feeGidSql = feeGId;
} else {
feeGidSql = feeGidSql + "," + feeGId;
}
}
}
}
_this = this;
Ext.Msg.wait('正在删除数据...');
if (feeGidSql != '') {
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpReceipt/DeleteUploadFile',
params: {
data: feeGidSql
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < selectedRecords.length; i++) {
this.storeDocList.remove(selectedRecords[i]);
}
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
this.setAttachs();
}
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
});
} else {
Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
}
}, this);
},
//#endregion
//#region 根据上传删除的附件数更新凭证附单据张数需求编号SR2017062800004
setAttachs: function () {
if (this.opStatus == 'add') {
Ext.Msg.show({ title: '提示', msg: '请先保存凭证!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCwVouchersGl/setAttachs',
params: {
sORDNO: this.EditRecord.get("ORDNO")
},
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.INFO, buttons: Ext.Msg.OK });
return;
}
var condition = "ORDNO='" + this.EditRecord.get("ORDNO") + "'";
this.LoadData('edit', condition);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
//#endregion
});