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/MsOpSeaPlugin/OpSeaCover.js

651 lines
22 KiB
JavaScript

Ext.namespace('Shipping');
var BSNO = '';
var PluginCoverOBJ;
var stroplb = '';
Shipping.OpSeaCover = function (config, type) {
Ext.applyIf(this, config);
if (type == 0) {
stroplb = '海运进口';
} else if (type == 1) {
stroplb = '海运出口';
}
this.initUIComponents();
Shipping.OpSeaCover.superclass.constructor.call(this);
};
Ext.regModel('CertType', {
fields: [{ name: 'value' }, { name: 'text'}]
})
Ext.extend(Shipping.OpSeaCover, Ext.Panel, {
PageSize: 100,
layout: "border",
titile: "COVER",
initUIComponents: function () {
_this = this;
PluginCoverOBJ = this;
//#region Cover(上)
this.panelBtn = new Ext.Panel({
region: "center",
tbar: [{
text: '新建',
iconCls: "btnadd",
handler: function (button, event) {
if (BSNO == '') {
Ext.Msg.show({ title: '提示', msg: '请先选择一票业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.OprationStatus = 'add';
var coverEdit = new Shipping.OpSeaCoverEdit(null, BSNO, '');
coverEdit.show();
},
scope: this
}, {
text: '删除',
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick();
},
scope: this
}, '-',
{
text: "刷新",
iconCls: "btnrefresh",
handler: function (button, event) {
if (BSNO == '') {
Ext.Msg.show({ title: '提示', msg: '请先选择一票业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
this.onRefreshClick(button, event);
},
scope: this
}]
});
//数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'OpSeaCoverModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsOpSeaPlugin/GetCoverDataList',
reader: {
id: 'CID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//列
this.girdcolums = [{
sortable: true,
dataIndex: 'BSNO',
header: '业务编号',
hidden: true
}, {
sortable: true,
dataIndex: 'COVERTITLE',
header: '内容',
width: 300,
renderer: function (value, p, record) {
return Ext.String.format(
'<b><a>{0}</a></b><br><p><a>&nbsp;&nbsp;&nbsp;&nbsp;{1}</a></p>',
value,
record.data.COVERCONTEXT
);
}
}, {
sortable: true,
dataIndex: 'OPTIME',
header: '创建时间'
}, {
sortable: true,
dataIndex: 'OPERATOR',
header: '创建人'
}, {
sortable: true,
dataIndex: 'ISSYS',
header: '系统生成',
renderer: function (value, meta) {
if (value == '1') {
return '是'
}
}
}, {
sortable: true,
dataIndex: 'CID',
header: '主键',
hidden: true
}];
//分页
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 10000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: '数据正在加载中...' },
trackMouseOver: true,
disableSelection: false,
columns: this.girdcolums,
selModel: this.GridCheckBoxModel,
viewConfig: {
enableTextSelection: true, //允许复制数据
autoFill: true
},
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', //'当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: '没有数据' //"没有数据"
}), this.Pagenum]
});
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
var coverEdit = new Shipping.OpSeaCoverEdit(null, BSNO, record.data.CID, record.data.COVERTITLE, record.data.COVERCONTEXT, record.data.ISSYS);
coverEdit.show();
}, this);
//#endregion
//#region Cover(下) OpStatus
//人员信息加载
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='" + stroplb + "'"} });
this.comboxOPSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeOpStatus,
forceSelection: true,
name: 'STATUS',
valueField: 'OPSTATUS',
displayField: 'OPSTATUS'
});
this.storeList2 = 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.girdcolums2 = [{
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: 'datetimefield',
format: 'Y-m-d',
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: 'REMARK',
header: '备注',
editor: {
xtype: 'textfield',
selectOnFocus: true
},
width: 150
}
];
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel2 = Ext.create('Ext.selection.CheckboxModel');
//定义Grid
//分页
this.Pagenum2 = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 10000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick2();
}
}
}
});
this.gridList2 = new Ext.grid.GridPanel({
store: this.storeList2,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.gridListCellEditing],
selModel: this.CheckBoxModel2,
selType: 'cellmodel',
columns: this.girdcolums2,
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', //'当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据" //"没有数据"
}), this.Pagenum2]
});
//查询工具条
this.panelBtn2 = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
this.addDetail();
},
scope: this
},
{
text: "删除",
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.onRefreshClick2(button, event);
},
scope: this
}
]
});
this.panelTop2 = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn2]
});
//#endregion STATE
//布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 30,
items: [this.panelBtn]
});
this.panelBottom = new Ext.Panel({
layout: "border",
region: "south",
title: "业务状态",
height: 260,
items: [this.panelTop2, this.gridList2]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.panelBottom]
});
this.storeList.on('beforeload', function (store) {
var sql = "BSNO = '" + BSNO + "'";
sqlcontext = '';
if (BSNO != '') {
sqlcontext = sql;
} else {
sql = "BSNO = '1234455'";
}
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.storeList2.on('beforeload', function (store) {
var sql = "BSNO = '" + BSNO + "'";
if (BSNO == '') {
sql = "BSNO = '1234455'";
}
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
},
loadCoverWithBSNO: function (bsno) {
BSNO = bsno;
this.onRefreshClick();
this.onRefreshClick2();
},
onRefreshClick: function () {
if (BSNO == '') {
return;
}
sqlcontext = '';
if (BSNO != '') {
var sql = "BSNO = '" + BSNO + "'";
sqlcontext = sql;
}
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sqlcontext },
waitMsg: '正在查询数据...', //"正在查询数据...",
scope: this
});
}, onDeleteClick: function () {
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择记录!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
for (var i = 0; i < selectedRecords.length; i++) {
if (selectedRecords[i].data.ISSYS == '1') {
Ext.Msg.show({ title: '提示', msg: '系统生成消息,不允许删除!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
}
var selectStores = [];
for (var i = 0; i < selectedRecords.length; i++) {
if (selectedRecords[i].data.ISSYS != '1')
selectStores.push(selectedRecords[i].data);
}
if (selectStores.length == 0) {
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/MsOpSeaPlugin/DeleteCover',
params: {
data: Ext.JSON.encode(selectStores),
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(selections);
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
});
}
}, this);
},
//#region 下方状态区事件
onRefreshClick2: function (button, event) {
if (BSNO == '') {
return;
}
var sql = "BSNO='" + BSNO + "'";
this.storeList2.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
addDetail: function () {
var newSerialno = DsGetNewSerialNo(this.storeList2, 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: '',
COMPTIME: mydatestr,
COMPOP: SHOWNAME,
REMARK: ''
});
this.storeList2.add(record);
var n = this.storeList2.getCount();
this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
deleteDetail: function () {
var selectedRecords = this.CheckBoxModel2.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.storeList2.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: 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.storeList2.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) {
if (BSNO == '') {
Ext.Msg.show({ title: '提示',
msg: '请先选择业务!',
buttons: Ext.Msg.OK
});
return;
}
var bodyDrChFeeDatas = [];
var i;
for (i = 0; i < this.storeList2.getCount(); i += 1) {
var memberyf = this.storeList2.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: '状态不能为空,请修改后再保存',
buttons: Ext.Msg.OK
});
return;
}
};
var jsonChFeeBody = ConvertFeeRecordsToJson(bodyDrChFeeDatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsOpStatus/Save',
scope: this,
params: {
bsno: 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.storeList2.getCount(); i += 1) {
var member = this.storeList2.getAt(i);
member.set("BSNO", BSNO);
member.commit();
}
Ext.Msg.show({ title: '提示',
msg: '保存成功',
icon: Ext.Msg.OK,
buttons: Ext.Msg.OK
});
} else {
Ext.Msg.show({ title: '提示', msg: '没有更改!', buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
}
//#endregion 下方状态区事件
});