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/Import/Viewsjs/ReceiptIO/ReceiptIOIndex.js

697 lines
23 KiB
JavaScript

2 years ago
Ext.namespace('DsTruck');
DsTruck.ReceiptIOIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.ReceiptIOIndex.superclass.constructor.call(this);
};
Ext.extend(DsTruck.ReceiptIOIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
VISIBLERANGE: 0,
OPERATERANGE: 0,
initUIComponents: function () {
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'ReceiptIOmb',
remoteSort: false,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/Import/ReceiptIO/GetDataList',
reader: {
idProperty: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
this.formname = "ReceiptIOIndex";
//this.InWorkFlow=false;
//枚举参照
this.column = [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'TRANCNO',
header: '快递单号',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'CORPID',
header: 'CORPID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DEPTGID',
header: 'DEPTGID',
width: 80
},
{
sortable: true,
dataIndex: 'OP',
header: '操作人',
width: 80
},
{
sortable: true,
dataIndex: 'CREATETIME',
header: '收发时间',
width: 80
},
{
sortable: true,
dataIndex: 'REMARK',
header: '备注',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'IOTYPE',
header: 'IOTYPE',
width: 80
},
{
sortable: true,
dataIndex: 'IOTYPERef',
header: '收发方向',
width: 80
}];
//定义Grid
var _this = this;
this.Pagenum = Ext.create('Ext.form.field.Number', {
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.BXCB = 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.BXCB,
columns: [new Ext.grid.RowNumberer()],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
/////////////以下部分为获取存储的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/ReceiptIO/Edit", "", "620", "1000");
}, this);
/* this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) {
alert(record.get("ContractNo"))
}, this);*/
//#region formSearch
this.storeDEPT = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.DEPTRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptList' }
});
this.storeDEPT.load({ params: { condition: ""} });
this.comboxDEPT = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '部门',
store: this.storeDEPT,
name: 'DEPTID', id: "DEPTID",
valueField: 'GID',
displayField: 'DeptName',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: ""} });
this.comboxUser = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
store: this.storeUser,
name: 'OP',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
Ext.define('IOTYPEmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'IOTYPERef', type: 'string' }
]
});
var IOTYPEData = [{ "ID": "1", "IOTYPERef": "收" },
{ "ID": "0", "IOTYPERef": "发"}];
this.storeIOTYPE = Ext.create('Ext.data.Store', {
model: 'IOTYPEmb',
data: IOTYPEData
});
this.comboxIOTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收发方向',
store: this.storeIOTYPE,
name: 'IOTYPE', //id: "ISPAYED",
valueField: 'ID',
displayField: 'IOTYPERef',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeReceiptName = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeReceiptName.load({ params: { enumTypeId: 2} });
this.comboxReceiptName = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '单据类型',
store: this.storeReceiptName,
name: 'RECEIPTNAME',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustomerNameRef.load({ params: { condition: ""} });
this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeCustomerNameRef,
forceSelection: true,
fieldLabel: '购货商(客户)',
name: 'CUSTOMERNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
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.comboxReceiptName,
{
fieldLabel: '快递单号',
name: 'TRANCNO', id: "TRANCNO",
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, this.comboxIOTYPE,
{
fieldLabel: '从..日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CREATEDATE_min',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}, {
fieldLabel: '到..日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'CREATEDATE_max',
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
}]
}]
}, //end items(fieldset 1)
{//fieldset 2
xtype: 'container',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxUser
, this.comboxCustomerNameRef
, {
xtype: 'hiddenfield',
flex: 3
}]
}]
}, //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.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "新建",
iconCls: "btnadd", id: "NEW",
handler: function (button, event) {
this.OprationStatus = 'add';
DsOpenEditWin("/Import/ReceiptIO/Edit", "新建合同", "450", "800");
},
scope: this
},
{
text: "删除",
iconCls: "btndelete", id: "DEL",
handler: function (button, event) {
this.onDeleteClick(button, event);
},
scope: this
},
'-',
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
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
}, {
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
}, '-'
]
});
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 100,
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 (button, event) {
var sql = this.getCondition();
this.PageSize = this.Pagenum.getValue();
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: sql },
waitMsg: "正在查询数据...",
scope: this
});
//alert(this.storeList.getCount());
},
InitData: function () {
/*
Ext.Ajax.request({
waitMsg: '正在查询用户权限...',
url: '/CommMng/BasicDataRef/GetAuthorityRange',
params: {
modName: "mod_ReceiptList",
USERID: USERID
},
callback: function (options, success, response) {
if (success) {
var result = Ext.JSON.decode(response.responseText);
rec = result.data;
//alert(rec.VISIBLERANGE);
//alert(rec.OPERATERANGE);
//可操作为0则全都可见3为可提交/驳回,2为可审核/驳回1为只能看
this.VISIBLERANGE = rec.VISIBLERANGE;
this.OPERATERANGE = rec.OPERATERANGE;
if (this.OPERATERANGE == "0") {
Ext.getCmp("Submit").enable();
Ext.getCmp("Pass").enable();
Ext.getCmp("Refuse").enable();
Ext.getCmp("NEW").enable();
Ext.getCmp("DEL").enable();
Ext.getCmp("VOUCHER").enable();
} else
if (this.OPERATERANGE == "1") {
Ext.getCmp("Submit").disable();
Ext.getCmp("Pass").disable();
Ext.getCmp("Refuse").disable();
Ext.getCmp("NEW").disable();
Ext.getCmp("DEL").disable();
Ext.getCmp("VOUCHER").disable();
} else
if (this.OPERATERANGE == "2") {
Ext.getCmp("Submit").disable();
Ext.getCmp("Pass").enable();
Ext.getCmp("Refuse").enable();
Ext.getCmp("NEW").disable();
Ext.getCmp("DEL").enable();
Ext.getCmp("VOUCHER").enable();
} else {
Ext.getCmp("Submit").enable();
Ext.getCmp("Pass").disable();
Ext.getCmp("Refuse").enable();
Ext.getCmp("NEW").enable();
Ext.getCmp("DEL").enable();
Ext.getCmp("VOUCHER").disable();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
//var STEPNO=this.storeWorkFlowStep.getAt(index).get("STEPNO");
*/
}, //end InitData
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 selectedRecords = [];
selectedRecords = this.gridList.selModel.getSelection();
//var candelete = DsTruck.CheckBaoxiaoDelete(selectedRecords);
//if (candelete == false) {
// return;
//}
var record = selections[0];
Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/Import/ReceiptIO/Delete',
params: {
data: Ext.JSON.encode(record.data),
USERID: USERID
},
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
}
}, this);
InitData();
}, //onDeleteClick
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/ReceiptIO/Edit", "", "620", "1000");
}, //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 = ''; /*
if (this.VISIBLERANGE == "0")//查看权限 全部
{
var sql = '';
}else
if (this.VISIBLERANGE == "1")//分公司
{
var sql = " BX.company='" + COMPANYID + "'";
} else
if (this.VISIBLERANGE == "2")//部门
{
var sql = " BX.DEPTNAME ='" + DEPTGID + "'";
} else
if (this.VISIBLERANGE == "3")//个人
{
var sql = " BX.createuser='" + SHOWNAME + "'";
}
else {
sql = " 1<0";
}*/
//OPERATERANGE
var RECEIPTNAME = form.findField("RECEIPTNAME").getValue();
sql = sql + getAndConSql(sql, RECEIPTNAME, "RECEIPTNAME like '%" + RECEIPTNAME + "%'");
var TRANCNO = form.findField("TRANCNO").getValue();
sql = sql + getAndConSql(sql, TRANCNO, "TRANCNO like '%" + TRANCNO + "%' ");
var IOTYPE = form.findField("IOTYPE").getValue();
sql = sql + getAndConSql(sql, IOTYPE, "IOTYPE = '" + IOTYPE + "'");
var CREATEDATE_min = form.findField('CREATEDATE_min').getRawValue();
sql = sql + getAndConSql(sql, CREATEDATE_min, "CREATETIME >= '" + CREATEDATE_min + "'");
var CREATEDATE_max = form.findField('CREATEDATE_max').getRawValue();
sql = sql + getAndConSql(sql, CREATEDATE_max, "CREATETIME <= '" + CREATEDATE_max + " 23:59:59'");
var OP = form.findField('OP').getValue();
sql = sql + getAndConSql(sql, OP, "OP ='" + OP + "'");
var CUSTOMERNAME = form.findField("CUSTOMERNAME").getValue();
sql = sql + getAndConSql(sql, CUSTOMERNAME, " gid in(select IO_GID from OP_Receipt_IO_Body where bsno in(select bsno from v_op_bs where CUSTOMERNAME='" + CUSTOMERNAME + "'))");
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;
}
});