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/Import/Viewsjs/FactoryCargoName/CargoNameIndex.js

528 lines
18 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('DsTruck');
DsTruck.CargoNameIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.CargoNameIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.CargoNameIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
VISIBLERANGE: 0,
OPERATERANGE: 0,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'FactoryNomb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Import/FactoryCargoName/GetFactoryNoList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "FactoryCargoName";
//this.InWorkFlow=false;
//枚举参照
this.column = [ {
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 100
}, {
sortable: true,
dataIndex: 'FACTORYNO',
header: '代码/名称',
width: 100
}, {
sortable: true,
dataIndex: 'COUNTRYID',
header: '国家代码',
width: 60
}, {
sortable: true,
dataIndex: 'COUNTRY',
header: '国家',
width: 100
}, {
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 120
}];
//定义Grid
this.ClientCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 45
});
this.gridList = new Ext.grid.GridPanel({
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
viewConfig: {
enableTextSelection: true
},
stateful: true,
selModel: this.ClientCB,
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);
//使用者id表名 中间column数组跳过一开始的几列
this.column.unshift(new Ext.grid.RowNumberer());
this.gridList.reconfigure(this.storeList, this.column);
////////////////////////////
this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
this.SelectedRecord = record;
this.OprationStatus = 'edit';
DsOpenEditWin("/Import/FactoryCargoName/Edit", "", "800", "1100","150","150");
}, this);
/* this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
alert(record.get("ContractNo"))
}, this);*/
//#region formSearch
this.storeCountry = Ext.create('DsExt.ux.RefTableStore', {
model: 'ConutryRef',
proxy: { url: '/CommMng/BasicDataRef/GetCountryRefList' }
});
this.storeCountry.load({ params: { condition: ""} });
this.comboxCountry = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '国家',
store: this.storeCountry,
name: 'COUNTRYID',id:"COUNTRYID",
valueField: 'countryid',
displayField: 'country_idandname',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeCargoinfo = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargoRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargoRefList' }
});
this.storeCargoinfo.load({ params: { condition: ""} });
this.comboxCargoinfo = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'HS代码',
store: this.storeCargoinfo,
name: 'Cargoinfo_id',id:"Cargoinfo_id",
valueField: 'id',
displayField: 'codeandname'
//HS代码
});
this.storeCargociq = Ext.create('DsExt.ux.RefTableStore', {
model: 'CargociqRef',
proxy: { url: '/CommMng/BasicDataRef/GetCargociqRefList' }
});
this.storeCargociq.load({ params: { condition: ""} });
this.comboxCargociq = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: 'ciq代码',
store: this.storeCargociq,
name: 'Cargociq_id',
id:"Cargociq_id",
valueField: 'id',
displayField: 'codeandname'
//ciq代码
});
this.formSearch = Ext.widget('form', {
frame: true,
region: 'center',
bodyPadding: 5,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 110,
msgTarget: 'qtip'
},
items: [
{//fieldset 1
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '厂号或备注中包含',
name: 'FactoryNo',
id: "FactoryNo",
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},this.comboxCountry
,{
fieldLabel: '品名中包含(中/英)',
name: 'CARGONAME', id: "CARGONAME",
enableKeyEvents: true,
listeners: {
keyup: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}
,this.comboxCargoinfo
//,this.comboxCargociq
,{xtype:'hiddenfield',flex:1}
]
}]
}, //end items(fieldset 1)
{//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}]
}, //end fieldset 2
{//fieldset 3
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
]
}]
}, //end items(fieldset 3)
{//fieldset 5
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: []
} //end items(fieldset 5)
]//end root items
});
//#endregion formSearch
_this = this;
this.CBMWorkFlow = new Ext.form.Checkbox({
fieldLabel: '只显示待处理业务',
labelwidth:200,
});
//查询工具条
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [{
text: "新建",
iconCls: "btnadd",
handler: function (button, event) {
//this.SelectedRecord = record;
this.OprationStatus = 'add';
DsOpenEditWin("/Import/FactoryCargoName/Edit", "", "620", "1000");
},
scope: this
},
{
text: '复制新建', //"复制新建",
iconCls: "btnadd", id: "COPYNEW",
handler: function (button, event) {
this.onCopyAdd(button, event);
},
scope: this
},
{
text: "删除",
iconCls: "btndelete",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick();
},
scope: this
},
{
text: "重置条件",
iconCls: "btnreset",
handler: function (button, event) {
this.onResetClick(button, event);
//alert(this.getCondition);
},
scope: this
},'-',
{
text: "打开",
iconCls: "btnright", id: "OPEN",
handler: function (button, event) {
this.onOpenClick(button, event);
},
scope: this
}, '-'
]
});
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.InitData();
//集中绑定事件
this.storeList.on('beforeload', function (store) {
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
checkHandler: function () {
alert('Checked a menu item');
},
onRefreshClick: function () {
var sql = this.getCondition();
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
//alert(this.storeList.getCount());
},
InitData: function () {
//var STEPNO=this.storeWorkFlowStep.getAt(index).get("STEPNO");
}, //end InitData
onOpenClick: 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;
}
if (selections.length >1) {
Ext.Msg.show({ title: '提示', msg: '请注意,将打开所选内容的第一条!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
this.SelectedRecord = selectedRecords[0];
this.OprationStatus = 'edit';
DsOpenEditWin("/Import/FactoryCargoName/Edit", "", "620", "1000");
}, //onDeleteClick
onCopyAdd: 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;
}
if (selections.length > 1) {
Ext.Msg.show({ title: '提示', msg: '请注意,将复制所选内容的第一条!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
var selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
this.SelectedRecord = selectedRecords[0];
this.OprationStatus = 'copynew';
DsOpenEditWin("/Import/FactoryCargoName/Edit", "", "620", "1000");
}, //onDeleteClick
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 _L = selections.length;
Ext.MessageBox.confirm('提示', '确定删除这' + _L + '条记录吗?', function (btn) {
if (btn == 'yes') {
//var record = selections[0];
for (var i = 0; i < _L; i++) {
var record = selections[i];
var ContractNo = record.data.ContractNo;
var HTH = record.data.HTH;
var sql = " BSNO='" + ContractNo + "'";
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/FactoryCargoName/Delete',
params: {
data: Ext.JSON.encode(record.data)
//,USERID: GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.storeList.remove(record);
//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.show({ title: '提示', msg: "数据删除结束", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
this.onRefreshClick();
}, this);
}, //onDeleteClick
getToday: function () {
var now = new Date();
var year = now.getFullYear(); //年
var month = now.getMonth() + 1; //月
var day = now.getDate(); //日
var clock = year + "-";
if (month < 10)
clock += "0";
clock += month + "-";
if (day < 10)
clock += "0";
clock += day + " ";
return (clock);
},
onResetClick: function (button, event) {
this.formSearch.getForm().reset();
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql="";
//CustCodeCOUNTRYID
var FactoryNo = Ext.getCmp("FactoryNo").getValue();
sql = sql + getAndConSql(sql, FactoryNo, "(FactoryNo like '%" + FactoryNo + "%' or remark like '%" + FactoryNo + "%')");
var COUNTRYID = Ext.getCmp("COUNTRYID").getValue();
sql = sql + getAndConSql(sql, COUNTRYID, " COUNTRYID = '" + COUNTRYID + "' ");
var CARGONAME = Ext.getCmp("CARGONAME").getValue();
sql = sql + getAndConSql(sql, CARGONAME, " GID in(select FactoryNOGID from import_cargoname where CNNAME like '%" + CARGONAME + "%' or ENNAME like '%" + CARGONAME + "%') ");
var Cargoinfo_id = Ext.getCmp("Cargoinfo_id").getValue();
sql = sql + getAndConSql(sql, Cargoinfo_id, " GID in(select FactoryNOGID from import_cargoname where HS_ID = '" + Cargoinfo_id + "' ) ");
//var Cargociq_id = Ext.getCmp("Cargociq_id").getValue();
//sql = sql + getAndConSql(sql, Cargociq_id, " GID in(select FactoryNOGID from import_cargoname where CIQ_ID = '" + Cargociq_id + "' ) ");
return sql;
},
onGetremind: function (field, newValue, oldValue) {
if (newValue != null) {
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: newValue },
waitMsg: "正在查询数据...",
scope: this
});
}
},
OprationSwap: function () {
var ret = new Array();
ret[0] = this.OprationStatus;
ret[1] = this.storeList;
ret[2] = this.SelectedRecord;
return ret;
},
});