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.

537 lines
17 KiB
JavaScript

Ext.namespace('Shipping');
Shipping.MsOpStatusIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsOpStatusIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsOpStatusIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
EditRecord: null,
BsNo: "",
stroplb: "",
initUIComponents: function () {
//定义数据集
// var mainform = window.parent._this;
var mainform = window.parent.panelEdit;
this.EditRecord = mainform.editRecord;
this.stroplb = mainform.stroplb;
this.BsNo = this.EditRecord.get('BSNO');
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOpCode.load();
//客服
this.comboxCUSTSERVICE = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpCode,
forceSelection: true,
name: 'COMPOP',
valueField: 'UserName',
displayField: 'CodeAndName'
});
this.storeOpStatus = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsCodeOpStatusDetail',
proxy: { url: '/MvcShipping/MsCodeOpStatus/GetBodyList' }
});
this.storeOpStatus.load({ params: { condition: "OPTYPE='" + this.stroplb + "'"} });
this.comboxOPSTATUS= Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpStatus,
forceSelection: true,
name: 'STATUS',
valueField: 'OPSTATUS',
displayField: 'OPSTATUS'
});
this.storeISOPEN = Ext.create('Ext.data.Store', {
fields: ['FSTATUS', 'NAME']
});
this.storeISOPEN.add({ "FSTATUS": "1", "NAME": "公开" });
this.storeISOPEN.add({ "FSTATUS": "0", "NAME": "不公开" });
this.comboxISOPEN = Ext.create('DsExt.ux.RefTableCombox', {
// fieldLabel: '海运费',
store: this.storeISOPEN,
valueField: 'FSTATUS',
displayField: 'NAME',
// flex: 0.7,
// labelWidth: 55,
forceSelection: true,
name: 'ISOPEN'
});
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'MsOpStatus',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpStatus/GetListData',
reader: {
id: 'ST_ID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.girdcolums = [{
sortable: true,
dataIndex: 'ST_ID',
header: 'ST_ID',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true,
width: 150
}, {
sortable: true,
dataIndex: 'STATUS',
header: '业务状态',
editor: this.comboxOPSTATUS,
width: 120
}, {
sortable: true,
dataIndex: 'COMPTIME',
header: '完成时间',
editor: {
xtype: 'datefield',
format: 'Y-m-d H:i:s',
selectOnFocus: true
},
renderer: Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
width: 120
}, {
sortable: true,
dataIndex: 'COMPOP',
header: '完成人',
editor: this.comboxCUSTSERVICE,
width: 80
}, {
sortable: true,
dataIndex: 'ISOPEN',
header: '是否公开',
editor: this.comboxISOPEN,
width: 80,
renderer: function (value, cellmeta) {
if (value == '1') {
return "公开";
} else return "不公开";
}
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 150
}
];
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selModel: this.CheckBoxModel,
selType: 'cellmodel',
columns: this.girdcolums,
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.storeList.on('beforeload', function (store) {
var sql = "BSNO='" + this.BsNo + "'";
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.addDetail();
},
scope: this
},
{
text: "删除",
id:'btndelete',
iconCls: "btndelete",
handler: function (button, event) {
this.deleteDetail();
},
scope: this
},
'-',
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.onPostDetailClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
},
scope: this
},
'-',
{
text: "微信通知客户",
id:'WxOpStatusMsg',
iconCls: "btnrefresh",
handler: function (button, event) {
this.WxMsgSendDetail();
},
scope: this
}
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList]
});
this.onRefreshClick();
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "modWxOpStatusMsg"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
var btnEdit = Ext.getCmp('WxOpStatusMsg');
btnEdit.setVisible(false);
} else {
var btnEdit = Ext.getCmp('WxOpStatusMsg');
btnEdit.setVisible(true);
}
} else {
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '',
url: '/MvcShipping/MsBaseInfo/GetUserModuleEnable',
params: {
modulename: "modOpStatusDel"
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
if (result.Success != true) {
var btnEdit = Ext.getCmp('btndelete');
btnEdit.setVisible(false);
} else {
var btnEdit = Ext.getCmp('btndelete');
btnEdit.setVisible(true);
}
} else {
}
},
scope: this
});
},
onRefreshClick: function (button, event) {
var sql = "BSNO='" + this.BsNo + "'";
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
addDetail: function () {
var newSerialno = DsGetNewSerialNo(this.storeList, 0);
var n = this.storeList.getCount();
var myDate = new Date();
var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d H:i:s');
var record = Ext.create('MsOpStatus', {
ST_ID: NewGuid(),
BSNO: '*',
ORDNO: n + 1,
STATUS: '',
ISOPEN: '0',
ISOPENREF: '不公开',
COMPTIME: mydatestr,
COMPOP: SHOWNAME,
REMARK: ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
var selectedRecords = this.CheckBoxModel.selected.items;
Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.BSNO == "" || rec.BSNO == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeList.remove(selectedRecords[i]);
} else {
bodyDatas.push(rec);
}
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsOpStatus/Delete',
params: {
bsno: _this.BsNo,
data: jsonBody
},
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.storeList.remove(selectedRecords[i]);
}
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
},
onPostDetailClick: function (button, event) {
var bodyDrChFeeDatas = [];
var i;
for (i = 0; i < this.storeList.getCount(); i += 1) {
var memberyf = this.storeList.getAt(i);
memberyf.data.COMPTIME = Ext.util.Format.date(memberyf.data.COMPTIME, 'Y-m-d H:i:s');
bodyDrChFeeDatas.push(memberyf);
var STATUS = memberyf.data.STATUS;
if (STATUS == '') {
Ext.Msg.show({ title: '警告',
msg: '状态不能为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas);
_this = this;
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpStatus/Save',
scope: this,
params: {
bsno: _this.BsNo,
body: jsonChFeeBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
for (var i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
member.set("BSNO", _this.BsNo);
member.commit();
}
} 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
WxMsgSendDetail: function () {
var selectedRecords = this.CheckBoxModel.selected.items;
Ext.MessageBox.confirm('提示', '确定要选中状态发送给客户吗?', function (btn) {
if (btn == 'yes') {
var bodyDatas = [];
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
bodyDatas.push(rec);
}
var jsonBody = ConvertRecordsToJsonAll(bodyDatas);
_this = this;
Ext.Msg.wait('正在发送数据...');
Ext.Ajax.request({
waitMsg: '正在发送数据...',
url: '/MvcShipping/MsOpStatus/WxMsgSend',
params: {
bsno: _this.BsNo,
data: jsonBody
},
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 });
}
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
}); //end Ext.Ajax.request
}
}, this);
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
}
});