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/TruckMng/Viewsjs/MsWlTruck/MsWlTruckTeamIndex.js

792 lines
27 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.MsWlTruckTeamIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.MsWlTruckTeamIndex.superclass.constructor.call(this);
};
//201403060002
//13号
Ext.extend(DsTruck.MsWlTruckTeamIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.bodyDel = [];
this.ORGCODE = "";
this.TEAMGID = "";
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
idProperty: 'GID',
model: 'MsWlTruckTeammb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/TruckMng/MsWlTruckTeam/GetDataList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "MsWlTruckTeam";
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({ params: { condition: ""} });
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '所属分公司',
forceSelection: true,
store: this.storeCompany,
name: 'ORGCODE',
valueField: 'code',
displayField: 'name'
});
this.column = [{
sortable: true,
dataIndex: '',
header: '',
width: 120
}, {
sortable: true,
dataIndex: 'GID', hidden: true,
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'ORGCODE',
header: '所属分公司',
width: 95,
editor: this.comboxCompany,
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.COMPANYNAME;
}
},
{
sortable: true, hidden: true,
dataIndex: 'COMPANYNAME',
header: 'COMPANYNAME',
width: 80
},
{
sortable: true,
dataIndex: 'TEAMNAME',
header: '车辆组名称',
width: 100,
editor: { xtype: 'textfield' }
}, {
sortable: true,
dataIndex: 'INSERTED', hidden: true,
header: 'INSERTED',
width: 80
}];
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.TruckTeamCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
//定义Grid
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '车辆组明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.cellEditing],
stateful: false,
selModel: this.TruckTeamCBModel,
selType: 'cellmodel',
columns: [new Ext.grid.RowNumberer()],
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, 1);
//使用者id表名 中间column数组跳过一开始的几列
this.gridList.reconfigure(this.storeList, this.column);
this.gridList.columns[0] = new Ext.grid.RowNumberer();
////////////////////////////
//#region formSearch
this.storeCompany_Search = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany_Search.load({ params: { condition: ""} });
this.comboxCompany_Search = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所属分公司',
forceSelection: true,
store: this.storeCompany_Search,
name: 'ORGCODE',
valueField: 'code',
displayField: 'name'
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxCompany_Search,
{
fieldLabel: '车辆组名',
name: 'TEAMNAME', flex: 1
}, {
xtype: 'hiddenfield', flex: 2
}
]
}
]//end items(fieldset 1)
}, //end fieldset 1
{//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}
]//end items(fieldset 2)
}//end fieldset 2
, {//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}]//end items(fieldset 2)
}//end fieldset 2
]//end root items
});
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
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
},
{
text: "保存列表样式",
id: "btntest",
handler: function (button, event) {
this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, true);
//alert(this.column[0].id);
},
scope: this
}, '-', {
text: '增加明细',
tooltip: '增加明细',
iconCls: "btnadddetail",
handler: function (button, event) {
this.onAddTruckTeamClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '注意,删除车辆组会让本组车辆变成无所属车辆组!',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelTruckTeamClick(button, event);
},
scope: this
}, {
id: "btnSave",
text: '保存更改',
tooltip: '保存更改',
iconCls: "btnsave",
handler: function (button, event) {
this.Save();
//alert(USERID);
},
scope: this
}, '-'
]
});
//#endregion
//#region 右侧上半 本组车辆 右侧下半 待添加车辆
this.storeTeamTruck = Ext.create('DsExt.ux.RefTableStore', {
model: 'Truckmb',
pageSize: 500,
proxy: { url: '/TruckMng/MsWlTruckTeam/GetTruckNoList' }
});
//this.storeTruckNo.load({ params: { condition: " TEAMGID='"+TEAMGID+"' "} });
this.storeTruck = Ext.create('DsExt.ux.RefTableStore', {
model: 'Truckmb',
pageSize: 500,
proxy: { url: '/TruckMng/MsWlTruckTeam/GetTruckNoList' }
});
//this.storeTruckNo.load({ params: { condition: " ORGCODE='"+ORGCODE+"' and TEAMGID='"+TEAMGID+"' "} });
var _this = this;
this.TeamTruckCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridTeamTruck = new Ext.grid.GridPanel({
store: this.storeTeamTruck,
enableHdMenu: false,
layout: "border",
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '本组车辆',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
//plugins: [this.cellEditing],
stateful: false,
selModel: this.TeamTruckCBModel,
selType: 'cellmodel',
tbar: [
{
//id: 'pcindexbtnAdd',
text: "从本组删除",
iconCls: "btndelete",
handler: function (button, event) {
//this.OprationStatus = 'add';
//this.TabPanel.setActiveTab(1);
this.OnDelTruck();
},
scope: this
}
],
columns: [new Ext.grid.RowNumberer(),
{
sortable: true,
dataIndex: 'TruckNo',
header: '车号',
width: 80
}, {
sortable: true,
dataIndex: 'COMPANYNAME',
header: '所属分公司',
width: 80
}, {
sortable: true,
dataIndex: 'TEAMNAME',
header: '所属车辆组',
width: 80
}
],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeTeamTruck,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
this.TruckCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
this.gridTruck = new Ext.grid.GridPanel({
store: this.storeTruck,
enableHdMenu: false,
region: 'center',
trackResetOnLoad: true,
//height: 160,
title: '本公司非本组车辆',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
//plugins: [this.cellEditing],
stateful: false,
selModel: this.TruckCBModel,
selType: 'cellmodel',
tbar: [
{
//id: 'pcindexbtnAdd',
text: "添加至该车辆组",
iconCls: "btnadd",
handler: function (button, event) {
//this.OprationStatus = 'add';
//this.TabPanel.setActiveTab(1);
this.OnAddTruck();
},
scope: this
}
],
columns: [new Ext.grid.RowNumberer(),
{
sortable: true,
dataIndex: 'TruckNo',
header: '车号',
width: 80
}, {
sortable: true,
dataIndex: 'COMPANYNAME',
header: '所属分公司',
width: 80
}, {
sortable: true,
dataIndex: 'TEAMNAME',
header: '所属车辆组',
width: 80
}
],
bbar: Ext.create('Ext.PagingToolbar', {
store: this.storeTruck,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
})
});
//#endregion
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
items: [this.formSearch, this.panelBtn]
});
this.panelgridList = new Ext.Panel({
layout: "border",
region: "west",
width: 300,
split: true,
items: [this.gridList]
});
this.panelTeamTruck = new Ext.Panel({
layout: "border",
region: "center",
split: true,
items: [this.gridTeamTruck]
});
this.panelTruck = new Ext.Panel({
layout: "border",
region: "south",
height: 300,
split: true,
items: [this.gridTruck]
});
this.panelRight = new Ext.Panel({
layout: "border",
region: "center",
split: true,
items: [this.panelTeamTruck
, this.panelTruck
]
});
Ext.apply(this, {
//items: [this.panelTop, this.panelgridList, this.panelRight]
items: [this.panelTop, this.panelgridList
, this.panelRight
]
});
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.TruckTeamAfterEdit(editor, e, eOpts);
}, this);
var _this = this;
this.gridList.getSelectionModel().on('select', function (model, record, index) {
_this.ORGCODE = record.data.ORGCODE;
_this.TEAMGID = record.data.GID;
_this.storeTeamTruck.load({ params: { condition: " TEAMGID ='" + _this.TEAMGID + "' "} });
_this.storeTruck.load({ params: { condition: " ORGCODE='" + _this.ORGCODE + "' and isnull(TEAMGID,'') <>'" + _this.TEAMGID + "' "} });
});
this.onRefreshClick();
}, //end initUIComponents
TruckTeamAfterEdit: function (editor, e, eOpts) {
if (e.field == 'ORGCODE') {
var records = DsStoreQueryBy(this.storeCompany, 'code', e.value);
if (records.getCount() > 0) {
var data = records.getAt(0).data;
e.record.set('COMPANYNAME', data.name);
} else {
e.record.set('COMPANYNAME', '');
}
}
},
onAddTruckTeamClick: function (button, event) {
function newID() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";
}
return guid.toUpperCase();
}
var record = Ext.create('MsWlTruckTeammb', {
'GID': newID(),
'ORGCODE': '',
'COMPANYNAME': '',
'INSERTED': ''
});
this.storeList.add(record);
var n = this.storeList.getCount();
this.cellEditing.startEditByPosition({ row: n - 1, column: 2 });
},
onDelTruckTeamClick: function (button, event) {
var selectedRecords = this.gridList.selModel.getSelection();
Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) {
if (btn == 'yes') {
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (rec.INSERTED != "") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.bodyDel.push(rec);
}
this.storeList.remove(selectedRecords[i]);
}
}
}, this);
},
OnAddTruck: function (button, event) {//添加双背
var selections = this.gridTruck.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择车辆!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//var selections2 = this.gridList.getSelectionModel().getSelection();
if (this.ORGCODE == "" || this.TEAMGID == "") {
Ext.Msg.show({ title: '提示', msg: '请先选择一个车辆组!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
//var record = selections[0];
var TRUCKNO = ""; //record.data.TruckNo;
var _TRUCKNOList = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
Ext.Array.include(_TRUCKNOList, rec.get('TruckNo'));
}
var _this = this;
Ext.Array.forEach(_TRUCKNOList, function (str, index, array) { //单纯的遍历数组
//alert(str);
Ext.Msg.wait('正在添加数据...');
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/TruckMng/MsWlTruckTeam/AddTeamTruck',
params: {
TEAMGID: _this.TEAMGID,
TRUCKNO: str
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//两个数据集都需要load一下
_this.storeTeamTruck.load({ params: { condition: " TEAMGID ='" + _this.TEAMGID + "' "} });
_this.storeTruck.load({ params: { condition: " ORGCODE='" + _this.ORGCODE + "' and isnull(TEAMGID,'') <>'" + _this.TEAMGID + "' "} });
//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
});
Ext.Msg.hide();
},
OnDelTruck: function (button, event) {//添加双背
var selections = this.gridTeamTruck.getSelectionModel().getSelection();
if (selections.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择车辆!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var _TRUCKNOList = [];
for (var i = 0; i < selections.length; i++) {
var rec = selections[i];
Ext.Array.include(_TRUCKNOList, rec.get('TruckNo'));
}
var _this = this;
Ext.Array.forEach(_TRUCKNOList, function (str, index, array) { //单纯的遍历数组
Ext.Msg.wait('正在添加数据...');
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/TruckMng/MsWlTruckTeam/DelTeamTruck',
params: {
TRUCKNO: str
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//两个数据集都需要load一下
if (_this.ORGCODE == "" || _this.TEAMGID == "") { }
else {
_this.storeTeamTruck.load({ params: { condition: " TEAMGID ='" + _this.TEAMGID + "' "} });
_this.storeTruck.load({ params: { condition: " ORGCODE='" + _this.ORGCODE + "' and isnull(TEAMGID,'') <>'" + _this.TEAMGID + "' "} });
}
//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
});
Ext.Msg.hide();
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
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
});
this.bodyDel = [];
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var ORGCODE = form.findField('ORGCODE').getValue();
sql = sql + getAndConSql(sql, ORGCODE, "ORGCODE = '" + ORGCODE + "'");
var TEAMNAME = form.findField('TEAMNAME').getValue();
sql = sql + getAndConSql(sql, TEAMNAME, "TEAMNAME like '%" + TEAMNAME + "%'");
return sql;
},
checkSearchCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return false;
}
return true;
},
onExportClick: function (button, event) {
GridExportExcelPage(this.gridList);
},
getStrValue: function (list) {
var _list = [];
for (var _i = 0; _i < list.length; _i++) {
_list.push("'" + list[_i] + "'");
}
return _list;
},
Save: function (type) {
//费用
var bodyList = [];
for (i = 0; i < this.storeList.getCount(); i += 1) {
var member = this.storeList.getAt(i);
bodyList.push(member);
var ORGCODE = member.data.ORGCODE;
var TEAMNAME = member.data.TEAMNAME;
if (ORGCODE == '' || TEAMNAME == '') {
Ext.Msg.show({ title: '警告',
msg: '分公司和车辆组名称均不允许为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
/*
Ext.Ajax.request({
waitMsg: '正在查询数据...',
url: '/OA/Project/GetData',
scope: this,
async:false,
params: {PROJECTNO: PROJECTNO,BLNO:BLNO,FEEID:FEEID },
waitMsg: "正在查询数据...",
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
var returnData = jsonresult.data;
//alert(returnData.Count);
ProjectCount=parseInt(returnData.Count);
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
}
});*/
};
/*
if (ProjectCount!=0){
alert("提单号/船名和项目编号均不允许重复");
return;
}*/
var jsonBody = ConvertRecordsToJson(bodyList);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
if (jsonBody == '' && jsonDelBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/TruckMng/MsWlTruckTeam/Save',
scope: this,
params: {
ProjectBody: jsonBody,
ProjectDelBody: jsonDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
//alert("保存成功");
var returnData = jsonresult.Data;
this.storeList.commitChanges();
} 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');
}
});
}
});