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/OA/Viewsjs/GoodsValue/GoodsValueIndex.js

849 lines
28 KiB
JavaScript

2 years ago
//集运管理-路单查询
Ext.namespace('DsTruck');
DsTruck.GoodsValueIndex = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.GoodsValueIndex.superclass.constructor.call(this);
};
//201403060002
//13号
Ext.extend(DsTruck.GoodsValueIndex, Ext.Panel, {
PageSize: 500,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
initUIComponents: function () {
this.bodyDel = [];
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
pageSize: this.PageSize,
idProperty: 'GID',
model: 'GoodsValuemd',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/OA/GoodsValue/GetDataList',
reader: {
id: 'NID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
Ext.define('BLNOTYPEmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'BLNOTYPEID', type: 'string' },
{ name: 'BLNOTYPEName', type: 'string' }
]
});
var PayTypeData = [{ "BLNOTYPEID": "1", "BLNOTYPEName": "提单号" },
{ "BLNOTYPEID": "2", "BLNOTYPEName": "船名"}/*,
{ "PayTypeID": "2", "PayTypeName": "原单原转"}*/];
this.storeBLNOTYPE = Ext.create('Ext.data.Store', {
model: 'BLNOTYPEmb',
data: PayTypeData
});
this.comboxBLNOTYPE = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '单号类型',
forceSelection: true,
store: this.storeBLNOTYPE,
name: 'BLNOTYPE',
valueField: 'BLNOTYPEName',
displayField: 'BLNOTYPEName'
});
this.comboxBLNOTYPE_1 = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '单号类型',
forceSelection: true,
store: this.storeBLNOTYPE,
name: 'BLNOTYPE',
valueField: 'BLNOTYPEName',
displayField: 'BLNOTYPEName'
});
Ext.define('TFmb', {
extend: 'Ext.data.Model',
fields: [
{ name: 'TFID', type: 'string' },
{ name: 'TFName', type: 'string' }
]
});
var TFData = [{ "TFID": "0", "TFName": "否" },
{ "TFID": "1", "TFName": "是"}/*,
{ "PayTypeID": "2", "PayTypeName": "原单原转"}*/];
this.storeTF = Ext.create('Ext.data.Store', {
model: 'TFmb',
data: TFData
});
this.comboxTF = Ext.create('DsExt.ux.RefEnumCombox', {
//fieldLabel: '是否',
forceSelection: true,
store: this.storeTF,
name: 'ISOVER',
valueField: 'TFID',
displayField: 'TFName'
});
this.comboxTF_1 = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '已经完成',
forceSelection: true,
store: this.storeTF,
name: 'ISOVER',
valueField: 'TFID',
displayField: 'TFName'
});
this.formname = "OA_GoodsValue";
/*
this.storeBLNO = Ext.create('DsExt.ux.RefTableStore', {
model: 'BLNOmb',
proxy: { url: '/OA/Project/GetBLNO' }
});
this.storeBLNO.load({ params: { condition: ""} });
this.comboxBLNO = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '委托单位',
store: this.storeBLNO,
name: 'BLNO',
valueField: 'BLNO',
displayField: 'BLNO'
});*/
this.column = [{
sortable: true,
dataIndex: '',
header: '',
width: 120
}, {
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'NID',
header: 'NID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'WMSDATE',
header: '入库时间',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTOMERNAME',
header: '客户名',
width: 80
},
{
sortable: true,
dataIndex: 'BLNO',
header: '提单号',
width: 80
},
{
sortable: true,
dataIndex: 'CUSTNO',
header: '委托编号',
width: 80
},
{
sortable: true,
dataIndex: 'INPUTBY',
header: '录入人',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'USERID',
header: 'USERID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'COMPANYID',
header: 'COMPANYID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'DEPTID',
header: 'DEPTID',
width: 80
},
{
sortable: true,
dataIndex: 'STORAGENAME',
header: '仓库名称',
width: 80
},
{
sortable: true,
dataIndex: 'GOODSNAME',
header: '货名',
width: 80
},
{
sortable: true,
dataIndex: 'GOODSSTOCK',
header: '库存量',
width: 80
},
{
sortable: true,
dataIndex: 'BANKVALUE',
header: '银行单价',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
},
{
sortable: true,
dataIndex: 'OPTIME_1',
header: '银行单价时间',
width: 80
},
{
sortable: true,
dataIndex: 'MARKETVALUE',
header: '市场单价',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
},
{
sortable: true,
dataIndex: 'OPTIME_2',
header: '市场单价时间',
width: 80
},
{
sortable: true,
dataIndex: 'BANKPRICE',
header: '银行货值',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
},
{
sortable: true,
dataIndex: 'MARKETPRICE',
header: '市场货值',
width: 80,
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
try {
var lsValue = usMoney(value, 2, '', false);
if (lsValue != "NaN") {
value = lsValue; if (parseFloat(lsValue) < 0) {
return '<SPAN style="COLOR: red">' + lsValue + '</SPAN>';
}
}
else {
return value;
}
}
catch (e) {
return value;
}
return value;
}
}
];
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, {
width: 50
});
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.ProjectCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true });
//定义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.ProjectCBModel,
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.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: [
{
fieldLabel: '提单号/船名航次',
name: 'BLNO', flex: 1
}, {
fieldLabel: '委托编号',
name: 'CUSTNO', flex: 1
}, {
fieldLabel: '货物名',
name: 'GOODSNAME', flex: 1
}, {
fieldLabel: '从..入库日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'WMSDate_min'
}, {
fieldLabel: '到..入库日',
format: 'Y-m-d',
xtype: 'datefield',
name: 'WMSDate_max'
}
]
}
]//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.onAddProjectClick(button, event);
},
scope: this
}, {
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndeletedetail",
handler: function (button, event) {
this.onDelProjectClick(button, event);
},
scope: this
}, {
id: "btnSave",
text: '保存更改',
tooltip: '保存更改',
iconCls: "btnsave",
handler: function (button, event) {
this.Save();
//alert(USERID);
},
scope: this
}, '-', {
text: "更改货值",
iconCls: "btnadd",
handler: function (button, event) {
var form = this.formChangeShow.getForm();
var MarketValue = form.findField('MarketValue');
var BankValue = form.findField('BankValue');
var ChangeDate = form.findField('ChangeDate');
this.thisday = this.getToday();
ChangeDate.setRawValue(this.thisday)
this.winChangeShow.show();
},
scope: this
}
]
});
//#endregion
//#region 更改货值对话框
this.formChangeShow = 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: [{
fieldLabel: '市场货值',
//format: 'Y-m-d',
xtype: 'numberfield',
name: 'MarketValue'
}, {
fieldLabel: '银行货值',
xtype: 'numberfield',
name: 'BankValue'
}
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '更改日期',
format: 'Y-m-d',
xtype: 'datefield',
name: 'ChangeDate'
}
]
}
]//end items(fieldset 1)
}//end fieldset 1
]//end root items
});
me = this;
this.winChangeShow = Ext.create('Ext.window.Window', {
title: "更改货值",
width: 450,
//height : 120,
//plain : true,
iconCls: "addicon",
resizable: false,
// 是否可以拖动
// draggable:false,
collapsible: true, // 允许缩放条
closeAction: 'close',
closable: true,
modal: 'true',
buttonAlign: "center",
bodyStyle: "padding:0 0 0 0",
items: [this.formChangeShow],
buttons: [{
text: "更改货值",
minWidth: 70,
handler: function () {
var selectedRecords = me.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '没有选择要更改货值的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
var form = me.formChangeShow.getForm();
var ChangeDate = form.findField('ChangeDate').getRawValue();
if (ChangeDate == '' || ChangeDate == null || ChangeDate == undefined) {
Ext.Msg.show({ title: '提示', msg: '必须填写修改日期!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
me.onChangeClick();
}
}, {
text: "关闭",
minWidth: 70,
handler: function () {
me.winChangeShow.close();
}
}]
});
//#endregion
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.storeList.on('beforeload', function (store) {
if (!this.checkSearchCondition())
return;
var sql = this.getCondition();
Ext.apply(store.proxy.extraParams, { condition: sql });
}, this);
}, //end initUIComponents
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
});
},
getCondition: function () {
var form = this.formSearch.getForm();
if (!form.isValid()) {
Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
return '';
}
var sql = '';
var BLNO = form.findField('BLNO').getValue();
sql = sql + getAndConSql(sql, BLNO, "BLNO like '%" + BLNO + "%'");
var CUSTNO = form.findField('CUSTNO').getValue();
sql = sql + getAndConSql(sql, CUSTNO, "CUSTNO like '%" + CUSTNO + "%'");
var GOODSNAME = form.findField('GOODSNAME').getValue();
sql = sql + getAndConSql(sql, GOODSNAME, "GOODSNAME like '%" + GOODSNAME + "%'");
var WMSDate_min = form.findField('WMSDate_min').getRawValue();
sql = sql + getAndConSql(sql, WMSDate_min, "WMSDate >= '" + WMSDate_min + "'");
var WMSDate_max = form.findField('WMSDate_max').getRawValue();
sql = sql + getAndConSql(sql, WMSDate_max, "WMSDate <= '" + WMSDate_max + " 23:59:59'");
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 BLNO = member.data.BLNO;
var PROJECTNO = member.data.PROJECTNO;
if (BLNO == '' || PROJECTNO == '') {
Ext.Msg.show({ title: '警告',
msg: '项目单号和项目编码均不允许为空,请修改后再保存',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
return;
}
};
var jsonBody = ConvertRecordsToJson(bodyList);
var jsonDelBody = ConvertRecordsToJsonAll(this.bodyDel);
if (jsonBody == '' && jsonDelBody == '') {
return;
}
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/OA/Project/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');
}
});
},
onChangeClick: function (button, event) {
var BSNOSql = '';
var selectedRecords = this.gridList.selModel.getSelection();
var form = this.formChangeShow.getForm();
/*
if (selectedRecords.length != 1) {
Ext.Msg.show({ title: '提示', msg: '只能每报销单生成一个凭证', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};*/
var this_deptid = "";
var BSNOSql = "";
for (var i = 0; i < selectedRecords.length; i++) {
var rec = selectedRecords[i];
if (BSNOSql == "") {
BSNOSql = "'" + rec.data.NID + "'";
}else
BSNOSql = BSNOSql +",'" + rec.data.NID + "'";
}
if (BSNOSql == '') {
Ext.Msg.show({ title: '提示', msg: '没有选择要更改货值的业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
};
BSNOSql = " (" + BSNOSql + ")";
var ChangeDate = form.findField('ChangeDate').getRawValue();
var MarketValue = form.findField('MarketValue').getValue();
var BankValue = form.findField('BankValue').getValue();
//var BankValue = form.findField('BankValue').getValue();
Ext.Ajax.request({
waitMsg: '正在添加数据...',
url: '/OA/GoodsValue/ChangeGoodsValue',
params: {
ChangeDate: ChangeDate,
MarketValue: MarketValue,
BankValue: BankValue,
BSNOSql: BSNOSql
},
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;
} else {
this.winChangeShow.close();
this.onRefreshClick();
}
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
},
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);
}
});