You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/MvcShipping/Viewsjs/MsCwDesignStartusing/多账套列表MsCwDesignStartusingIn...

397 lines
16 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.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 formSearch 下拉框信息加载
Ext.define('SubComp', {
extend: 'Ext.data.Model',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'ENNAME', type: 'string' }
]
});
this.StoreSubComp = Ext.create('DsExt.ux.RefTableStore', {
model: 'SubComp',
proxy: { url: '/MvcShipping/MsBaseInfo/GetCompanyEN' }
});
this.StoreSubComp.load({ params: { condition: ""} });
this.comboxSubComp = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '所属公司',
store: this.StoreSubComp,
name: 'SUBCOMP',
valueField: 'GID',
displayField: 'NAME',
value: COMPANYNAME,
allowBlank: false
});
//#endregion
//#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,
text: '是否启用',
dataIndex: 'ISENABLE',
xtype: "booleancolumn",
align: 'center',
trueText: "是",
falseText: " ",
width: 60
}, {
sortable: false,
text: '账套名称',
dataIndex: 'STARTNAME',
width: 200,
//align: 'center',
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}, {
sortable: false,
text: '启用年月',
id: 'STARTMONTH',
dataIndex: 'STARTMONTH',
align: 'center',
format: 'Y-m',
editor: {
xtype: 'monthfield',
selectOnFocus: true,
allowBlank: false
},
renderer: Ext.util.Format.dateRenderer('Y-m'),
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
});
//#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: "启用",
id: "btnSTARTMONTH",
iconCls: "btnsubmit",
handler: function (button, event) {
this.onSTARTMONTHClick(1);
},
scope: this
}, {
text: "取消启用",
id: "btnNotSTARTMONTH",
iconCls: "btnsubmit",
handler: function (button, event) {
this.onSTARTMONTHClick(0);
},
scope: this
}, '-', {
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
}]
});
Ext.apply(this, {
items: [this.panelBtn, this.gridList]
});
//#endregion
this.storeList.load({ params: { condition: "" }, waitMsg: "正在查询数据...", scope: this });
}, //end initUIComponents
//#region 按钮函数
onRefreshClick: function () {
this.storeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this });
},
Save: 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/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;
this.onRefreshClick();
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
});
}
}, //end save
onAddClick: function () {
//获取当前日期(到秒)
var curDate = new Date()
//格式化;
var strACCDATE = Ext.Date.format(curDate, 'Y-m');
var record = Ext.create('MsCwDesignStartusingModel', {
GID: '*',
ISENABLE: false,
STARTNAME: '',
STARTMONTH: strACCDATE
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 0 });
},
onDelClick: function () {
var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length <= 0) {
Ext.Msg.show({ title: '警告', msg: '请先选中要操作的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCwDesignStartusing/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.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
});
}
}, this);
},
onSTARTMONTHClick: function (isSTART) {
var sSTARTMONTH = Ext.getCmp('STARTMONTH');
if (sSTARTMONTH.rawValue == null) {
Ext.MessageBox.alert('提示', '请先选择帐套启用年月!');
return;
}
else {
if (sSTARTMONTH.rawValue.toString().trim() == "") {
Ext.MessageBox.alert('提示', '请先选择帐套启用年月!');
return;
}
}
//
if (isSTART == 1) {
Ext.MessageBox.confirm('提示', '确定启用帐套吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在启用帐套...');
Ext.Ajax.request({
waitMsg: '正在启用帐套...',
url: '/MvcShipping/MsCwDesignStartusing/setSTARTMONTH',
params: {
isSTART: isSTART,
STARTMONTH: sSTARTMONTH.rawValue.toString().trim()
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("STARTMONTH").disable(); //置灰
Ext.getCmp("btnSTARTMONTH").hide(); //隐藏
Ext.getCmp("btnNotSTARTMONTH").show(); //显示按钮
//
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);
}
else {
Ext.MessageBox.confirm('提示', '确定取消已启用的帐套吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在取消帐套...');
Ext.Ajax.request({
waitMsg: '正在取消帐套...',
url: '/MvcShipping/MsCwDesignStartusing/setSTARTMONTH',
params: {
isSTART: isSTART,
STARTMONTH: sSTARTMONTH.rawValue.toString().trim()
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.getCmp("STARTMONTH").enable(); //置灰
Ext.getCmp("btnSTARTMONTH").show();
Ext.getCmp("btnNotSTARTMONTH").hide();
//
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);
}
},
onISENABLE: 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/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
});