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/WMSImport/WMSPriceIndex.js

768 lines
26 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('Shipping');
Shipping.WMSPriceIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.WMSPriceIndex.superclass.constructor.call(this);
};
Ext.extend(Shipping.WMSPriceIndex, Ext.Panel, {
PageSize: 30,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.formname = "WMSPriceForm";
Ext.define('WMSPricemb', {
extend: 'Ext.data.Model',
idProperty: '',
fields: [
{ name: 'GID', type: 'string' },
{ name: 'CUSTOMERNAME', type: 'string' },
{ name: 'PRICEDATE', type: 'date' },
{ name: 'PRICE_PAY', type: 'string' },
{ name: 'PRICE_RECV', type: 'string' },
{ name: 'remark', type: 'string' }
]
});
Ext.define('Tradermb', {
extend: 'Ext.data.Model',
idProperty: 'gid',
fields: [
{ name: 'gid', type: 'string' },
{ name: 'name', type: 'string' },
{ name: 'codename', type: 'string' }
]
});
//定义数据集
this.storeCustomerName = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeCustomerName.load({ params: { condition: ""} });
this.comboxCustomerName = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '客户',
id: "CustomerName", //hidden: true,
forceSelection: true,
store: this.storeCustomerName,
name: 'CUSTOMERNAME',
valueField: 'name',
displayField: 'codename'
});
/////////////////////////////////////////
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
model: 'WMSPricemb',
remoteSort: true,
groupField: 'CUSTOMERNAME',
proxy: {
type: 'ajax',
//url: '/TruckMng/MsRptPcHeadOperate/QryData_ADL',
url: '/MvcShipping/WMSPrice/GetDataList',
//this.storeList.proxy.url = '/TruckMng/MsRptPcHeadOperate/QryData_ADL';
reader: {
id: '',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.column = [
{
sortable: true, hidden: true,
dataIndex: 'GId',
header: 'GId',
width: 130
}, {
dataIndex: 'CUSTOMERNAME',
header: '客户名称',
width: 120,
editor: this.comboxCustomerName
},
{
dataIndex: 'PRICEDATE',
header: '费率日期',
width: 100,
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
editor: {
xtype: 'datefield'
}
},
{
dataIndex: 'PRICE_PAY',
header: '付费费率',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
dataIndex: 'PRICE_RECV',
header: '收费费率',
width: 80,
editor: {
xtype: 'numberfield',
selectOnFocus: true
}
},
{
dataIndex: 'remark',
header: '备注',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}
];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 40
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.MainCB,
columns: this.column,
plugins: [this.cellEditing],
features: [{
id: 'group',
ftype: 'grouping',
groupHeaderTpl: '{name}',
hideGroupedHeader: false,
enableGroupingMenu: true
}],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
/////////////以下部分为获取存储的gridpanel显示样式
this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column);
//使用者id表名 中间column数组
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//#region formSearch
//#region formSearch枚举参照相关
this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.FeeTypeRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' }
});
this.storeFeeNameRef.load({ params: { condition: "ISTRUCKING='1' "} });
this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '不含此费用',
store: this.storeFeeNameRef,
name: 'FeeName',
valueField: 'Name',
displayField: 'CodeAndName'//, flex: 2
});
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户',
typeAhead: true,
store: this.storeCustCode,
name: 'CustName',
valueField: 'CustName',
displayField: 'CodeAndName'
});
Ext.define('PCSTATUSmd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'STATUSNAME', type: 'string' }
]
});
var PCSTATUSData = [{ "ID": "0", "STATUSNAME": "接单" },
{ "ID": "1", "STATUSNAME": "派车" },
{ "ID": "2", "STATUSNAME": "完成"}];
this.storePCSTATUS = Ext.create('Ext.data.Store', {
model: 'PCSTATUSmd',
data: PCSTATUSData
});
this.comboxPCSTATUS = Ext.create('Ext.ux.form.field.BoxSelect', {
fieldLabel: '状态',
autosize: true,
bodyPadding: 5,
flex: 2,
//width: 500,
labelWidth: 85,
store: this.storePCSTATUS,
queryMode: 'local',
triggerOnClick: false,
valueField: 'ID',
displayField: 'STATUSNAME'
});
//#endregion
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 85,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '从..日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'DATEBGN'
}, {
fieldLabel: '到..日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'DATEEND'
}
//, this.comboxFeeNameRef
, { xtype: 'hiddenfield', flex: 3 }
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
//#endregion formSearch
var menu1 = new Ext.menu.Menu({
id: 'basicMenu',
items: [{
text: '批量设为完成',
handler: clickEnd
}, {
text: '批量设为未完成',
handler: clickNotEnd
}]
});
function clickEnd() {
panelTest.SetEnd("1");
};
function clickNotEnd() {
panelTest.SetEnd("0");
};
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建", id: "btnadd", //hidden: true,
iconCls: "btnadd",
handler: function (button, event) {
//this.OprationStatus = 'add';
//DsOpenEditWin("/TruckMng/MsWlPc/Edit_ADL", "", "700", "1000");
this.onAddPCClick();
},
scope: this
}, {
text: "删除", id: "btndelete", //hidden: true,
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
}, '-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
}, {
text: "导出Excel",
id: "btnExportExcel",
iconCls: 'btnexportexcel',
handler: function (button, event) {
this.onExportClick(button, event);
},
scope: this
}, '-', /*{
id: "btnFeeAuditReject",
text: '驳回提交费用业务',
tooltip: '驳回提交费用业务',
iconCls: "btnrefuse",
handler: function (button, event) {
this.onAuditRefuseClick(button, event);
},
scope: this
},*/
{text: "批量设置完成", menu: menu1, scope: this },
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
var formname = this.formname;
var tempcolumns = this.gridList.columns;
DsTruck.SaveGridPanel(USERID, formname, tempcolumns, this.column, 0, false);
},
scope: this
}, {
text: "保存修改", id: "SaveBtn",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick(button, event);
},
scope: this
}
//,this.CB_EditMode
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 75,
items: [this.formSearch, this.panelBtn]
});
Ext.apply(this, {
items: [this.panelTop, this.gridList, this.gridList_edit]
});
///以下集中绑定事件
this.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
this.gridList.on('edit', function (editor, e, eOpts) {
this.PCAfterEdit(editor, e, eOpts);
}, this);
this.cellEditing.on('beforeedit', function (editor, e) {
return this.PCBeforeEdit(editor, e);
}, this);
this.LoadInitData();
}, //end initUIComponents
LoadInitData: function () {
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
},
onAuditRefuseClick: function (button, event) {
var sql = " A.GID in (select bsno from ch_fee where FEESTATUS=6)";
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
},
onRefreshClick: function (button, event) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
//}
},
onDeleteClick: function (button, event) {
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 DelList = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
DelList.push(rec)
}
var jsonBody = ConvertRecordsToJsonAll(DelList);
if (jsonBody == '') {
return;
}
//var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/WMSPrice/Delete',
params: {
data: jsonBody
},
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 });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
}, //onDeleteClick
getCondition: function () {
var form = this.formSearch.getForm();
var sql = '';
/*
var mblNo = form.findField('PS_MBLNO').getValue();
sql = sql + getAndConSql(sql, mblNo, " (MblNo like '%" + mblNo + "%' or MBLNOse like '%" + mblNo + "%') ");
var drvName = form.findField('PS_DRVNAME').getValue();
sql = sql + getAndConSql(sql, drvName, " (DrvName like '%" + drvName + "%' or TruckNo='" + drvName + "') ");
var DstArea = form.findField('DstArea').getValue();
sql = sql + getAndConSql(sql, DstArea, " (DstArea like '%" + DstArea + "%' or DetiNation like '%" + DstArea + "%') ");
var VoyVeg = form.findField('VoyVeg').getValue();
sql = sql + getAndConSql(sql, VoyVeg, " (VoyVeg like '%" + VoyVeg + "%' ) ");
var pcBillNo = form.findField('PS_BILLNO').getValue();
sql = sql + getAndConSql(sql, pcBillNo, " BillNo like '%" + pcBillNo + "%'");
var billNo = form.findField('PS_REFBILLNO').getValue();
sql = sql + getAndConSql(sql, billNo, " (RefBillNo like '%" + billNo + "%' or RefBillNose like '%" + billNo + "%')");
*/
var DATEBGN = form.findField('DATEBGN').getRawValue();
sql = sql + getAndConSql(sql, DATEBGN, " PRICEDATE>='" + DATEBGN + "'");
var DATEEND = form.findField('DATEEND').getRawValue();
sql = sql + getAndConSql(sql, DATEEND, " PRICEDATE<='" + DATEEND + " 23:59:59'");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
if (this.OprationStatus == "add") {
ret[3] = "";
} else {
ret[3] = this.SelectedRecord.data.REFBILLNO;
}
ret[4] = "MsRptPcHeadQryIndex";
ret[5] = formtype;
return ret;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
SetEnd: function (isEnd) {
selectedRecords = this.gridList.selModel.getSelection();
var GIDList = "";
var needalert = false;
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.get('TruckNo') != "") {
if (GIDList == "") { GIDList = "'" + rec.get('GId') + "'"; }
else {
GIDList = GIDList + ",'" + rec.get('GId') + "'";
}
}
else { needalert = true; }
}
if (needalert == true) {
alert("不能将接单状态的业务设置为完成");
}
if (GIDList == "") {
return;
}
Ext.Ajax.request({
waitMsg: '正在查询毛利数据...',
url: '/TruckMng/MsWlPc/SetEnd',
async: false,
params: {
GIDList: GIDList,
isEnd: isEnd
},
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.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var _count = result.data;
this.onRefreshClick();
if (needalert == true) {
alert("注意,未派车(未选择车号)的业务不能设置为完成。");
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
}
,
onSaveClick: function () {
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
};
var jsonBody = ConvertRecordsToJson(bodyList);
if (jsonBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/WMSPrice/SaveList',
scope: this,
params: {
data: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//this.storeEditList.commitChanges();
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
});
}
//alert('03');
}
});
}
,
onAddPCClick: function (button, event) {
var record = Ext.create('WMSPricemb', {
'GID': '',
'CUSTOMERNAME': "",
'PRICEDATE': "2016-01-01",
'PRICE_PAY': '0.0',
'PRICE_RECV': '0.0',
'remark': ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 2 });
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
}
,
PCAfterEdit: function (editor, e, eOpts) {
//if (e.value == e.originalValue) { return; }
if (e.field == 'ContainerType') {//箱号
var CTNrecords = DsStoreQueryBy(this.storeContainerType, 'CtnCode', e.value);
if (CTNrecords.getCount() > 0) {
var CTNdata = CTNrecords.getAt(0).data;
e.record.set('ContainerType_Ref', CTNdata.CtnName);
} else {
e.record.set('ContainerType_Ref', '');
}
}
if (e.field == 'YardCode') {
var Yardrecords = DsStoreQueryBy(this.storeYardCode, 'CustCode', e.value);
if (Yardrecords.getCount() > 0) {
var Yarddata = Yardrecords.getAt(0).data;
e.record.set('YardCode_Ref', Yarddata.CodeAndName);
} else {
e.record.set('YardCode_Ref', '');
}
}
if (e.field == 'RtnYardCode') {
var Yardrecords = DsStoreQueryBy(this.storeRtnYardCode, 'CustCode', e.value);
if (Yardrecords.getCount() > 0) {
var Yarddata = Yardrecords.getAt(0).data;
e.record.set('RtnYardCode_Ref', Yarddata.CodeAndName);
} else {
e.record.set('RtnYardCode_Ref', '');
}
}
if (e.field == 'DrvName') {
/*
var Yardrecords = DsStoreQueryBy(this.storeRtnYardCode, 'CustCode', e.value);
if (Yardrecords.getCount() > 0) {
var Yarddata = Yardrecords.getAt(0).data;
e.record.set('RtnYardCode_Ref', Yarddata.CodeAndName);
} else {
e.record.set('RtnYardCode_Ref', '');
}*/
}
if (e.field == 'TruckNo') {
var _datas = DsStoreQueryBy(this.storeTruckNo, 'TruckNo', e.value);
if (_datas.getCount() > 0) {
var _t = _datas.getAt(0).data;
e.record.set('DrvName', _t.DrvName);
e.record.set('Mobile', _t.Mobile);
} else {
e.record.set('DrvName', "");
e.record.set('Mobile', "");
}
}
if (e.field == 'F_CustomerName') {
var _datas = DsStoreQueryBy(this.storeF_CustomerName, 'name', e.value);
if (_datas.getCount() > 0) {
var _t = _datas.getAt(0).data;
e.record.set('DetiNation', _t.ADDR);
} else {
e.record.set('DrvName', "");
}
}
}
,
PCBeforeEdit: function (editor, e, eOpts) {
if (e.field == 'TruckNo') {//箱号
this.SetTruckNo();
}
}
,
SetTruckNo: function () {
var TruckNoList = "";
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
if (member.data.PCSTATUSREF != "完成" && member.data.TruckNo != "") {
if (TruckNoList == "") {
TruckNoList = "('" + member.data.TruckNo + "'";
} else {
TruckNoList = TruckNoList + ",'" + member.data.TruckNo + "'";
}
}
};
if (TruckNoList != "") {
TruckNoList = TruckNoList + ")";
this.storeTruckNo.load({ params: { condition: " and A.truckno not in " + TruckNoList} });
} else {
//this.storeTruckNo.load({ params: { condition: " A.truckno not in (select DISTINCT truckno from tMsWlPcHead where isnull(isend,0)=0 ) "} });
}
}
});