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.

429 lines
17 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, ""); }
Shipping.MsCtDesignStartusingIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCtDesignStartusingIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCtDesignStartusingIndex, Ext.Panel, {
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "formMsCtDesignStartusingIndex"; //页面名称
//#region formSearch 下拉框信息加载
//所属账套
this.storeSTARTNAME = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCwDesignStartusingModel',
proxy: { url: '/MvcShipping/MsCtDesignStartusing/GetCtSTARTGID' }
});
this.storeSTARTNAME.load({ params: { condition: ""} });
this.comboxSTARTNAME = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '所属账套',
store: this.storeSTARTNAME,
forceSelection: true, //输入值是否严格为待选列表中存在的值
disabled: true,
id: 'STARTNAME',
name: 'STARTNAME',
valueField: 'GID',
displayField: 'STARTNAME',
allowBlank: false
});
//#endregion
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCtDesignStartusingModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCtDesignStartusing/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
text: '唯一编码',
hidden: true,
width: 0
}, {
sortable: false,
dataIndex: 'ISENABLE',
header: '是否启用',
xtype: "booleancolumn",
align: 'center',
width: 60,
trueText: "是",
falseText: " "
}, {
sortable: false,
id: 'STARTMONTH',
dataIndex: 'STARTMONTH',
format: 'Y-m',
header: '启用年月',
editor: {
xtype: 'monthfield',
allowBlank: false,
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m'),
width: 80
}, {
sortable: false,
dataIndex: 'STARTNAME',
header: '所属账套',
width: 200,
editor: {
xtype: 'textfield',
allowBlank: false,
selectOnFocus: true
}
//,editor: this.comboxSTARTNAME
}, {
sortable: false,
dataIndex: 'STARTGID',
header: '所属账套GID',
hidden: true,
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.storeList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
listeners: {
scope: this,
'edit': function (editor, e, eOpts) {
if (e.value == e.originalValue) { return; }
if (e.colIdx == 2) {
var sSTARTMONTH = e.record.data['STARTMONTH'].toString();
sSTARTMONTH = Ext.util.Format.date(sSTARTMONTH, 'Y-m');
//Ext.Ajax.request({
// waitMsg: '正在查询...',
// url: '/MvcShipping/MsCtDesignStartusing/GetInitData',
// params: {
// 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 "";
// }
// var strArg = result.data.toString().split("");
// var strSTARTNAME = strArg[0].toString();
// var strACCDATE = strArg[1].toString();
// var strYM = new Date(sSTARTMONTH + "-01");
// var strYM2 = new Date(strACCDATE + "-01");
// if (strYM < strYM2) {
// //var strYM3 = Ext.util.Format.date(strYM2, "Y-m"); //new Date(strYM2).format("Y-m");
// //_field.setValue("");
// e.record.set('STARTMONTH', strACCDATE);
// }
// } else {
// Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
// }
// },
// scope: this
//});
}
}
}
});
this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, this);
this.storeList.load({ params: { condition: "" }, waitMsg: "正在查询数据...", scope: this });
//#endregion
//#region 按钮工具条/页面布局
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: '添加',
tooltip: '添加',
id: "btnadd",
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick(button, event);
},
scope: this
}, {
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
text: '删除',
tooltip: '删除',
id: "btndel",
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick(button, event);
},
scope: this
}, '-', {
text: '启用',
tooltip: '启用',
id: "btnISENABLE",
handler: function (button, event) {
this.onISENABLE(button, event);
},
scope: this
}, '-', {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
}]
}); //end 按钮Toolbar
Ext.apply(this, {
items: [this.panelBtn, this.gridList]
});
//#endregion
this.onRefreshClick();
}, //end initUIComponents
//#region 加载事件_返回财务当前账套和会计期间
InitData: function () {
Ext.Ajax.request({
waitMsg: '正在查询...',
url: '/MvcShipping/MsCtDesignStartusing/GetInitData',
params: {
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 "";
}
var strArg = result.data.toString().split("");
strSTARTNAME = strArg[0].toString();
strACCDATE = strArg[1].toString();
//
return result.data.toString();
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
return "";
},
//#endregion
//#region 按钮函数
Save: function () {
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
var sName = member.data.STARTNAME.toString();
var comboxList = DsStoreQueryBy(this.storeSTARTNAME, 'STARTNAME', sName);
if (comboxList.length > 0) {
var comboxRaw = comboxList.getAt(0).raw;
member.set("STARTGID", comboxRaw.GID.toString());
}
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCtDesignStartusing/Save',
scope: this,
params: {
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//var returnData = jsonresult.Data;
} 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 });
}
this.onRefreshClick();
}
});
}
}, //end save
onAddClick: function () {
Ext.Ajax.request({
waitMsg: '正在查询...',
url: '/MvcShipping/MsCtDesignStartusing/GetInitData',
params: {
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 "";
}
var strArg = result.data.toString().split("");
strSTARTNAME = strArg[0].toString();
strACCDATE = strArg[1].toString();
var record = Ext.create('MsCtDesignStartusingModel', {
GID: '*',
ISENABLE: false,
STARTMONTH: strACCDATE,
STARTNAME: strSTARTNAME,
STARTGID: ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCtDesignStartusing/Delete',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.remove(rec);
this.onRefreshClick();
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
onRefreshClick: function (button, event) {
this.storeList.load({
params: { condition: "" },
waitMsg: "正在刷新数据...",
callback: function (options, success, response) {
if (success) {
if (this.storeList.getCount() > 0) {
Ext.getCmp('btnadd').hide();
}
else {
Ext.getCmp('btnadd').show();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
onISENABLE: function () {
var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length==0)
{
Ext.Msg.show({ title: '错误', msg: "请先保存数据!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0];
if (rec.data.GID.toString().trim() == "*" || rec.data.GID.toString().trim() == "")
{
Ext.Msg.show({ title: '错误', msg: "请先保存数据!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
return;
}
Ext.MessageBox.confirm('提示', '确定启用此期间为当前账期吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在操作数据...');
Ext.Ajax.request({
waitMsg: '正在操作数据...',
url: '/MvcShipping/MsCtDesignStartusing/onISENABLE',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeList.remove(rec);
this.onRefreshClick();
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}
//#endregion
});