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.

398 lines
15 KiB
JavaScript

12 months ago
Ext.namespace('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
Shipping.MsCwDesignStartusingIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCwDesignStartusingIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCwDesignStartusingIndex, Ext.Panel, {
initUIComponents: function () {
this.formname = "formMsCwDesignStartusingIndex"; //总账账套启用页面
//#region 定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'MsCwDesignStartusingModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCwDesignStartusing/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
text: '唯一编码',
hidden: true,
width: 0
}, {
sortable: false,
dataIndex: 'ISLOGIN',
header: '是否登录',
align: 'center',
width: 60
}, {
sortable: false,
dataIndex: 'ISENABLE',
header: '是否启用',
xtype: "booleancolumn",
align: 'center',
width: 60,
trueText: "是",
falseText: " "
}, {
sortable: false,
dataIndex: 'STARTNAME',
header: '账套名称',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true,
allowBlank: false
}
}, {
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: 'FINANCESOFTCODE',
header: '财务接口代码',
width: 200,
editor: {
xtype: 'textfield',
selectOnFocus: true,
allowBlank: false
}
}, {
sortable: false,
id: 'MODIFIEDUSERNAME',
dataIndex: 'MODIFIEDUSERNAME',
format: 'Y-m',
header: '最后更改人',
width: 80
}];
//#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
});
this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, 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
}, {
text: '保存',
tooltip: '保存',
id: "btnSave",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
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);
this.onISENABLE(1);
},
scope: this
}, {
text: "取消启用",
id: "btnNotSTARTMONTH",
handler: function (button, event) {
this.onISENABLE(0);
},
scope: this
}, '-', {
text: '登录',
tooltip: '登录',
id: "btnISLOGIN",
handler: function (button, event) {
this.onISLOGIN(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 刷新
onRefreshClick: function () {
this.storeList.load({
params: { condition: "" },
async: false,
waitMsg: "正在查询数据...",
callback: function (options, response, success) {
if (success) {
//如果0条账套数据则隐藏启用、登录按钮
if (options.length == 0) {
Ext.getCmp("btnISENABLE").disable(); //置灰
Ext.getCmp("btnNotSTARTMONTH").disable(); //置灰
Ext.getCmp("btnISLOGIN").disable(); //置灰
}
else {
Ext.getCmp("btnISENABLE").enable();
Ext.getCmp("btnNotSTARTMONTH").enable();
Ext.getCmp("btnISLOGIN").enable();
}
//如果大于2条账套数据则隐藏添加按钮
//if (options.length < 2) {
// Ext.getCmp("btnadd").show(); //显示按钮
//}
//else {
// Ext.getCmp("btnadd").hide(); //隐藏
//}
}
},
scope: this
});
},
//#endregion
//#region 添加
onAddClick: function () {
var n = this.storeList.getCount();
//if (n < 2) {
var record = Ext.create('MsCwDesignStartusingModel', {
GID: '*',
ISLOGIN: false,
ISENABLE: false,
STARTNAME: '',
STARTMONTH: '',
MODIFIEDUSERNAME: ''
});
this.storeList.add(record);
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
//}
},
//#endregion
//#region 保存
onSaveClick: function () {
var j = 0;
var bodydatas = [];
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCwDesignStartusing/onSave',
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) {
Ext.Msg.hide();
} 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
//#endregion
//#region 删除
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
var strISENABLE = rec.data.ISENABLE.toString();
var strISLOGIN = rec.data.ISLOGIN.toString();
if (strISENABLE == "true" || strISLOGIN == "true") {
Ext.Msg.show({ title: '警告', msg: '已经启用或登录的账套,不允许操作!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCwDesignStartusing/onDelete',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
this.onRefreshClick();
},
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
//#region 启用
onISENABLE: function (isSTART) {
var selectedRecords = this.gridList.selModel.getSelection();
var rec = selectedRecords[0];
var str = "确定启用此账期吗?";
if (isSTART == 0) {
str = "确定“取消启用”此账期吗?";
}
//
Ext.MessageBox.confirm('提示', str, function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在操作数据...');
Ext.Ajax.request({
waitMsg: '正在操作数据...',
url: '/MvcShipping/MsCwDesignStartusing/onISENABLE',
params: {
data: Ext.JSON.encode(rec.data),
isSTART: isSTART
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
this.onRefreshClick();
},
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
//#region 登录
onISLOGIN: 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/MsCwDesignStartusing/onISLOGIN',
params: {
data: Ext.JSON.encode(rec.data)
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
Ext.Msg.hide();
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
this.onRefreshClick();
},
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
});