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/MsCrmQuotation/MsCrmQuotationEdit.js

1413 lines
55 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('Shipping');
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
//#region 当前日期格式
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //cond
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
return format;
}
//#endregion
//#region 获取 YYYY-mm-dd 格式的日期
var xhr = new XMLHttpRequest();
var currdate = new Date();
xhr.open("HEAD", location.href, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var datestr = xhr.getResponseHeader("Date");
currdate = new Date(datestr);
}
}
xhr.send(null);
//#endregion
Shipping.MsCrmQuotationEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.MsCrmQuotationEdit.superclass.constructor.call(this);
};
Ext.extend(Shipping.MsCrmQuotationEdit, Ext.Panel, {
ParentWin: null,
opStatus: 'add',
StoreList: null,
editRecord: null,
initUIComponents: function () {
this.bodyDel = [];
this.itemindex = 1;
this.myDate = new Date();
this.accdatesameetd = 0;
this.MsPeriod = null;
//#region formSearch 下拉框信息加载
//权限范围
this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsOP',
proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' }
});
this.StoreOpRange.load({ params: { optype: "MsCrmQuotation"} });
//人员信息加载
this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeOpCode.load();
//报价人
this.comboxSALE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '报价人',
store: this.storeOpCode,
forceSelection: true,
name: 'SALE',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME
});
//录入人
this.comboxCREATEUSER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '录入人',
store: this.storeOpCode,
forceSelection: true,
name: 'CREATEUSER',
valueField: 'UserName',
displayField: 'CodeAndName',
value: SHOWNAME,
readOnly: true
});
//品名code_msds//需求编号SR2017072600008-1
this.storeCodeGoodsList = Ext.create('DsExt.ux.RefTableStore', {
model: 'CodeMsdsModel',
proxy: { url: '/MvcShipping/MsCrmQuotation/GetCodeMsdsList' }
});
this.storeCodeGoodsList.load();
this.comboxGOODSNAME = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '品名',
store: this.storeCodeGoodsList,
matchFieldWidth: false, //下拉款自适应宽度
name: 'GOODSNAME',
valueField: 'CHEMICALCGOODSNAME', //GOODNAME
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {//需求编号SR2017080400003
if (combo.value.toString() != "") {
var AccitemsList = DsStoreQueryBy(this.storeCodeGoodsList, 'CodeAndName', combo.rawValue.toString());
if (AccitemsList.length > 0) {
var AccitemsRaw = AccitemsList.getAt(0).raw;
this.formHead.getForm().findField('UNNO').setValue(AccitemsRaw.UNNO);
this.formHead.getForm().findField('DCLASS').setValue(AccitemsRaw.DCLASS);
}
}
},
'render': function (_field, eOpts) {//自定义函数,定义双击事件
_field.getEl().on('dblclick', function (e, t, eOpts) {
var sValue = t.value.toString();
var sLen = sValue.indexOf("|");
if (sLen > -1) {
sValue = sValue.substring(0, (sLen - 1));
}
else {
sValue = "";
}
//
var openSet = "height=700, width=1224, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " + (screen.height - 750) / 2 + ",Left= " + (screen.width - 1100) / 2
var openType = "_blank";
var openUrl = "";
openUrl = "../../MvcContainer/MsCodeMSDS/MsdsView?handle=check&goodsname=" + sValue;
window.open(openUrl, openType, openSet);
});
}
}
});
//客户名称
this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} });
this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '客户名称',
store: this.storeCustCode,
matchFieldWidth: false, //下拉款自适应宽度
forceSelection: true,
name: 'SHORTNAME',
valueField: 'CustName',
displayField: 'CodeAndName',
listeners: {
scope: this,
'select': function (combo, records, eOpts) {
if (records.length > 0) {
this.formHead.getForm().findField('EMAIL').setValue(records[0].data.EMAIL);
this.formHead.getForm().findField('TEL').setValue(records[0].data.TEL);
}
}
}
});
//船公司
this.storeCARRIER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeCARRIER.load({ params: { condition: "ISCARRIER='1'"} });
this.comboxCARRIER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '船公司',
store: this.storeCARRIER,
matchFieldWidth: false, //下拉款自适应宽度
forceSelection: true,
name: 'CARRIER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//订舱代理
this.storeFORWARDER = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CustomRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' }
});
this.storeFORWARDER.load({ params: { condition: "ISAGENT='1'"} });
this.comboxFORWARDER = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '使用代理',
store: this.storeFORWARDER,
matchFieldWidth: false, //下拉款自适应宽度
forceSelection: true,
name: 'FORWARDER',
valueField: 'CustName',
displayField: 'CodeAndName'
});
//枚举维护表tSysEnumValue_货物类别97028//需求编号SR2017072600008-3
this.storeTSysEnumValueCode = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.TSysEnumValueDataModel',
proxy: { url: '/CommMng/BasicDataRef/GetTSysEnumValueList' }
});
this.storeTSysEnumValueCode.load({ params: { condition: " and EnumTypeID=97028"} }); //货物类别
this.comboxGOODSTYPE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '产品类别',
store: this.storeTSysEnumValueCode,
forceSelection: true,
name: 'GOODSTYPE',
value: '普通货',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//国内港口(起运港)//需求编号SR2017072600008-4
this.storeCodeLoadport = Ext.create('DsExt.ux.RefTableStore', {
//model: 'DsShipping.ux.CodeLoadportModel',
//proxy: { url: '/CommMng/BasicDataRef/GetCodeLoadportList' }
//需求编号SR2017071700006-5
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeLoadport.load();
this.comboxPORTLOAD = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '起运港',
store: this.storeCodeLoadport,
matchFieldWidth: false, //下拉款自适应宽度
name: 'PORTLOAD',
valueField: 'PORT',
displayField: 'PORT', //'CodeAndName',
forceSelection: true
});
//国际港口(目的港)
this.storeCodeDisport = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeDisportModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeDisportList' }
});
this.storeCodeDisport.load();
this.comboxPORTDISCHARGE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '目的港',
store: this.storeCodeDisport,
name: 'PORTDISCHARGE',
matchFieldWidth: false, //下拉款自适应宽度
valueField: 'PORT',
displayField: 'PORT', //'CodeAndName',
forceSelection: true
});
//集装箱
this.storeCodeCtn = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.CodeCtnModel',
proxy: { url: '/CommMng/BasicDataRef/GetCodeCtnList' }
});
this.storeCodeCtn.load();
this.comboxCTNALL = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '箱型',
store: this.storeCodeCtn,
name: 'CTNCODE',
valueField: 'CTN',
displayField: 'CTN'
});
//箱状态(同代理报价中的箱状态)
this.StoreCTNSTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.StoreCTNSTATUS.load({ params: { enumTypeId: 97029} });
this.comboxCTNSTATUS = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCTNSTATUS,
fieldLabel: '箱状态',
forceSelection: true,
name: 'CTNSTATUS',
valueField: 'EnumValueName',
displayField: 'EnumValueName'
});
//运输条款
this.storeSERVICE = Ext.create('DsExt.ux.RefTableStore', {
model: 'CODE_SERVICE',
proxy: { url: '/CommMng/BasicDataRef/GetCodeServiceList' }
});
this.storeSERVICE.load({ params: { condition: ""} });
this.comboxSERVICE = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '运输条款',
store: this.storeSERVICE,
forceSelection: true,
name: 'SERVICE',
valueField: 'SERVICE',
displayField: 'SERVICE'
});
//费用名称
this.storeFeeName = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.FeeTypeRefModel',
proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' }
});
this.storeFeeName.load();
this.comboxFeeName = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storeFeeName,
forceSelection: true,
name: 'FEENAME',
valueField: 'Name',
displayField: 'CodeAndName',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onNextKeyClick(2);
}
},
scope: this
}
}
});
//币别选项
this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeCurr',
proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' }
});
this.StoreCurr.load({ params: { condition: ""} });
this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreCurr,
forceSelection: true,
name: 'CURRENCY',
valueField: 'CURR',
displayField: 'CURR',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onNextKeyClick(3);
}
},
scope: this
}
}
});
//费用单位
this.StoreUnit = Ext.create('DsExt.ux.RefTableStore', {
model: 'MsFeeUnit',
proxy: { url: '/MvcShipping/MsChFee/GetCtnUnitList' }
});
this.StoreUnit.load({ params: { bsno: "", bstype: ""} });
this.comboxUnit = Ext.create('DsExt.ux.RefTableCombox', {
store: this.StoreUnit,
name: 'UNIT',
valueField: 'UNIT',
displayField: 'SUNIT',
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 13) {
this.onNextKeyClick(4);
}
},
scope: this
}
}
});
//#endregion
//#region 编辑formHead 基本信息
this.formHead = Ext.widget('form', {
border: false,
region: 'north',
frame: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
},
items: [{
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '惟一值',
name: 'GID',
hidden: true
},
{
fieldLabel: '报价编号',
name: 'QUOTATIONCODE',
readOnly: true
}, this.comboxCustCode,
{
fieldLabel: '联系方式',
name: 'TEL'
},
{
fieldLabel: '邮箱',
name: 'EMAIL'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxSALE, this.comboxCREATEUSER,
{
fieldLabel: '录入时间',
name: 'CREATETIME',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
value: currdate.format('yyyy-MM-dd'),
readOnly: true
}, this.comboxCARRIER]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxPORTLOAD, this.comboxPORTDISCHARGE, this.comboxCTNALL,
{
fieldLabel: '箱量',
name: 'CTNNUM',
value: '0',
blankText: '请填写数值!',
allowBlank: false,
regex: /^\d+$/,
regexText: '请输入正确的数值类型!'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [this.comboxGOODSTYPE, this.comboxGOODSNAME, {
fieldLabel: 'UN',
name: 'UNNO'//需求编号SR2017080400003
}, {
fieldLabel: '危险品等级',
name: 'DCLASS'//需求编号SR2017080400003
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '报价时间',
name: 'QUOTATIONDATE',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
value: currdate.format('yyyy-MM-dd')
}, {
fieldLabel: '有效期',
name: 'VALIDDATE',
format: 'Y-m-d',
xtype: 'datefield',
allowBlank: false,
value: currdate.format('yyyy-MM-dd')
}, this.comboxSERVICE, this.comboxCTNSTATUS]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '起运港免箱天数',
name: 'FBPPORTLOAD',
value: '0',
blankText: '请填写数值!',
allowBlank: false,
regex: /^\d+$/,
regexText: '请输入正确的数值类型!'
},
{
fieldLabel: '起运港超期标准',
name: 'CQPORTLOAD'
}, this.comboxFORWARDER,
{
fieldLabel: '佣金比率',
name: 'COMMISSIONRATE',
value: '0',
blankText: '请填写数值!',
allowBlank: false,
regex: /^\d+(\.\d{1,4})?$/,
regexText: '请输入正确的数值类型!'
}]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '目的港免箱天数',
name: 'FBPPORTDISCHARGE',
value: '0',
blankText: '请填写数值!',
allowBlank: false,
regex: /^\d+$/,
regexText: '请输入正确的数值类型!'
}, {
fieldLabel: '目的港超期标准',
name: 'CQPORTDISCHARGE'
}, {
fieldLabel: '备注',
flex: 2,
name: 'REMARK'
}
//{ xtype: 'hiddenfield'}
]
}]
}]
});
//#endregion
//#region 定义数据集
this.storeDetailList = Ext.create('Ext.data.Store', {
model: 'CrmQuotationDetailModel',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/MvcShipping/MsCrmQuotation/GetDetailList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//#endregion
//#region 列定义
this.girdcolums = [{
sortable: false,
dataIndex: 'GID',
header: '', //唯一编码
hidden: true,
width: 0
},
{
sortable: false,
dataIndex: 'FEENAME',
header: '费用名称',
align: 'center',
width: 200,
editor: this.comboxFeeName
},
{
sortable: false,
dataIndex: 'CURRENCY',
header: '币别',
align: 'center',
width: 80,
editor: this.comboxCurr
},
{
sortable: false,
dataIndex: 'UNIT',
header: '单位',
align: 'center',
width: 80,
editor: this.comboxUnit
},
{
sortable: false,
dataIndex: 'UNITPRICE',
header: '金额',
align: 'right',
width: 120,
editor: {
xtype: 'numberfield',
allowBlank: false,
selectOnFocus: true, //得到焦点时自动选择文本
allowDecimals: true, //允许输入小数
nanText: '请输入有效小数',
minValue: -999999999.99,
maxValue: 999999999.99,
value: 0.00,
keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值
hideTrigger: true, //是否隐藏上下调节按钮
mouseWheelEnabled: false, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值
//step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小
enableKeyEvents: true, //激活键盘事件
listeners: {
scope: this,
'keyup': {
fn: function (_field, e) {
if (e.getKey() == 40) {
this.onAddClick();
}
else if (e.getKey() == e.ENTER) {
this.onAddClick();
}
else if (e.getKey() == e.TAB) {
this.onAddClick();
}
},
scope: this
}
}
},
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'RMBHJ',
header: 'RMB金额', //需求编号SR2017071700006-2、3、4
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
},
{
sortable: false,
dataIndex: 'USDHJ',
header: '折合USD金额', //需求编号SR2017071700006-2、3、4
align: 'right',
width: 120,
summaryType: 'sum',
//summaryRenderer: Ext.util.Format.numberRenderer('00.00'),
renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
},
summaryRenderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
value = usMoney(value, 2, '', true);
return value;
}
}, {
sortable: false,
dataIndex: 'LINKGID',
header: '', //唯一编码
hidden: true,
width: 0
}];
//#endregion
//#region gridList列表显示信息
this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1 //1单击2双击
});
this.gridList = new Ext.grid.GridPanel({
border: false,
region: 'center',
store: this.storeDetailList,
enableHdMenu: false, //是否显示表格列的菜单
hideHeaders: false, //是否隐藏表头
enableColumnHide: false, ///隐藏表头列
sortableColumns: false, ///隐藏表头排序
rowLines: true,
columnLines: true,
loadMask: { msg: "数据加载中,请稍等..." },
plugins: [this.gridListCellEditing],
selType: 'cellmodel',
columns: this.girdcolums,
features: [{
ftype: 'summary'//Ext.grid.feature.Summary表格汇总特性//需求编号SR2017071700006-2、3、4
}]
});
//#endregion
//#region 明细表-单据图片档案管理
_this = this;
this.storeDocList = Ext.create('Ext.data.Store', {
model: 'ReceiptDocmb',
remoteSort: true,
proxy: {
type: 'ajax',
url: '/Import/ReceiptDoc/GetDocList',
reader: {
id: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//明细表表格
this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.DocCM = Ext.create('Ext.selection.CheckboxModel');
this.gridDocList = new Ext.grid.GridPanel({
store: this.storeDocList,
enableHdMenu: false,
region: 'center',
// width: 350,
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
plugins: [this.DocListCellEditing],
selModel: this.DocCM,
selType: 'cellmodel',
tbar: [{
text: '删除',
tooltip: '删除',
iconCls: "btndeletedetail",
id: 'btnEDelDoc',
handler: function (button, event) {
this.onDelFileClick(button, event);
},
scope: this
}, '-', {
text: '上传附件',
tooltip: '上传附件',
iconCls: "btnadddetail",
id: 'btnEAddDoc',
handler: function (button, event) {
this.onUpLoadFileClick(button, event);
},
scope: this
}],
columns: [{
sortable: true, hidden: true,
dataIndex: 'GID',
header: 'GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'R_GID',
header: 'R_GID',
width: 80
},
{
sortable: true, hidden: true,
dataIndex: 'BSNO',
header: 'BSNO',
width: 80
},
{
sortable: true,
dataIndex: 'URL',
header: '文件名',
width: 140,
renderer: function (value, p, record) {
return '<a href="' + record.data.Driect_URL + '" style=' + '"text-decoration:none" target="_blank"' + '>' + value + '</a>';
}
},
{
sortable: true, hidden: true,
dataIndex: 'Driect_URL',
header: 'Driect_URL',
width: 80
}, {
xtype: 'actioncolumn',
width: 50,
text: '图片预览', //操作
items: [{
icon: '/images/icons/btnSearch.gif', // Use a URL in the icon config
tooltip: '预览',
handler: function (grid, rowIndex, colIndex) {
var rec = grid.getStore().getAt(rowIndex);
var filePath = rec.get('Driect_URL') + '?a=' + Math.random();
var imgView = new Shipping.FileView({ filePath: filePath, height: 600, width: 800 });
imgView.show();
}
}]
},
{
sortable: true, hidden: true,
dataIndex: 'MODIFIEDUSER',
header: 'MODIFIEDUSER',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDUSERRef',
header: '上传人',
width: 80
},
{
sortable: true,
dataIndex: 'MODIFIEDTIME',
header: '上传时间',
width: 135
}
]
});
this.panelDoc = new Ext.Panel({
id: "panelDoc",
layout: "border",
region: "east",
width: 400,
title: '附件', //autoScroll: true,
frame: false,
split: true,
items: [this.gridDocList]
});
//#endregion
//#region 按钮工具条/页面布局
this.panelBtn = new Ext.Panel({
border: false,
region: "north",
tbar: [{
id: 'btnESave',
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
}, {
id: 'btnESaveAndClose',
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}, {
id: 'btnESaveAndNew',
text: "保存并新建",
handler: function (button, event) {
this.Save('2');
},
scope: this
}, {
id: 'btnECopyNew',
text: "复制新建",
handler: function (button, event) {
this.opStatus = "add";
this.onBtnAdd(this.opStatus, 2);
},
scope: this
}, '-', {
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}, {
text: "新建",
handler: function (button, event) {
this.opStatus = "add";
this.onBtnAdd(this.opStatus, 1);
},
scope: this
}, '-', {
text: "打印",
iconCls: "btnprint",
handler: function (button, event) {
this.Print();
},
scope: this
}]
}); //end 按钮Toolbar
this.panelTop = new Ext.Panel({
border: false,
layout: "border",
region: "north",
height: 240,
items: [this.panelBtn, this.formHead]
});
this.panelBtn2 = new Ext.Panel({
region: "north",
//border: false,
tbar: [{
id: "btnAddDetail",
text: '添加明细',
tooltip: '添加明细',
iconCls: "btnadd",
handler: function (button, event) {
this.onAddClick();
},
scope: this
}, {
id: "btnSaveDetail",
text: "保存明细",
iconCls: "btnsave",
handler: function (button, event) {
this.onSaveClick();
},
scope: this
}, '-', {
id: "btnDelDetail",
text: '删除明细',
tooltip: '删除明细',
iconCls: "btndelete",
handler: function (button, event) {
this.onDelClick();
},
scope: this
}, '-', {
//需求编号SR2017071700006-1
id: "btnAddDetail2",
text: '引入费用',
tooltip: '引入费用',
iconCls: "btnadd",
handler: function (button, event) {
DsOpenEditWin("/MvcShipping/MsCrmQuotation/HistryFeeAgentIndex", "历史引入费用");
},
scope: this
}]
}); //end 按钮Toolbar
this.panelTop2 = new Ext.Panel({
border: false,
layout: "border",
region: "center",
items: [this.panelBtn2, this.gridList, this.panelDoc]
});
Ext.apply(this, {
border: false,
items: [this.panelTop, this.panelTop2]
});
//#endregion
//#region 页面加载
parentWin = window.parent.opener;
this.InitData();
//#endregion
}, //end initUIComponents
//#region 加载事件
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = ret[0];
this.StoreList = ret[1];
this.editRecord = ret[2];
}
if (this.opStatus == 'edit') {
condition = "GID='" + this.editRecord.get('GID') + "'";
this.LoadData(condition);
}
else {
this.onBtnAdd(this.opStatus, 1);
}
}, //end InitData
LoadData: function (condition) {
this.bodyDel = [];
if (this.opStatus == 'edit') {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/MvcShipping/MsCrmQuotation/GetData',
params: {
handle: this.opStatus,
condition: condition
},
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;
}
data = result.data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(data);
this.formHead.getForm().findField('CREATETIME').setValue(data.CREATETIME.toString().substring(0, 10));
this.formHead.getForm().findField('QUOTATIONDATE').setValue(data.QUOTATIONDATE.toString().substring(0, 10));
this.formHead.getForm().findField('VALIDDATE').setValue(data.VALIDDATE.toString().substring(0, 10));
//
var condition = "LINKGID='" + data.GID.toString() + "'";
this.storeDetailList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
this.GetEditStatus();
this.storeDocList.load({
params: { condition: "BSNO='" + data.GID.toString() + "' AND RECEIPTTYPE='报价维护'" },
waitMsg: "正在查询数据...",
scope: this,
callback: function () {
}
});
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}
},
//#endregion
//#region 编辑时按钮等的状态
GetEditStatus: function () {
var canedit = false;
var inputby = this.formHead.getForm().findField('CREATEUSER').getValue();
_this = this;
this.StoreOpRange.load({ params: { optype: "MsCrmQuotation" },
callback: function (r, options, success) {
if (success) {
if (r.length != 0) {
var records = DsStoreQueryBy(_this.StoreOpRange, 'OPID', inputby);
if (records.getCount() > 0) { canedit = true; }
else { canedit = false; }
}
else { canedit = false; }
_this.setSaveBtnStatus(canedit);
}
}
});
},
setSaveBtnStatus: function (enable) {
var btnESave = Ext.getCmp('btnESave');
var btnESaveAndClose = Ext.getCmp('btnESaveAndClose');
var btnESaveAndNew = Ext.getCmp('btnESaveAndNew');
var btnEAddDetail = Ext.getCmp('btnAddDetail');
var btnESaveDetail = Ext.getCmp('btnSaveDetail');
var btnEDelDetail = Ext.getCmp('btnDelDetail');
var btnEAddDetail2 = Ext.getCmp('btnAddDetail2');
if (enable) {
btnESave.enable();
btnESaveAndClose.enable();
btnESaveAndNew.enable();
btnEAddDetail.enable();
btnESaveDetail.enable();
btnEDelDetail.enable();
btnEAddDetail2.enable();
} else {
btnESave.disable();
btnESaveAndClose.disable();
btnESaveAndNew.disable();
btnEAddDetail.disable();
btnESaveDetail.disable();
btnEDelDetail.disable();
btnEAddDetail2.disable();
}
},
//#endregion
//#region 新建
onBtnAdd: function (strOpStatus, type) {
this.bodyDel = [];
if (strOpStatus == 'add') {
var basicForm = this.formHead.getForm();
if (type == 1) {
basicForm.reset();
}
basicForm.findField('GID').setDisabled(false);
var field = basicForm.findField('GID');
field.setValue("*");
basicForm.findField('GID').setDisabled(true);
field = basicForm.findField('QUOTATIONCODE');
field.setValue('');
field = basicForm.findField('CREATEUSER');
field.setValue(SHOWNAME);
field = basicForm.findField('SALE');
field.setValue(SHOWNAME);
field = basicForm.findField('CREATETIME');
field.setValue(currdate.format('yyyy-MM-dd'));
field = basicForm.findField('QUOTATIONDATE');
field.setValue(currdate.format('yyyy-MM-dd'));
field = basicForm.findField('VALIDDATE');
field.setValue(currdate.format('yyyy-MM-dd'));
}
},
//#endregion
//#region 保存
Save: function (type) {
var basicForm2 = this.formHead.getForm();
if (!basicForm2.isValid()) {
return;
}
//
this.formHead.getForm().findField('GID').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
//
var jsonBody;
var bodydatas = [];
//需求编号SR2017072600008-2
// var records = this.storeDetailList.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据
// var phantoms = this.storeDetailList.getNewRecords(); //获得幻影行
// records = records.concat(phantoms); //将幻影数据与真实数据合并
// if (records.length != 0) {
// for (var i = 0; i < records.length; i += 1) {
// var member = records[i];
// bodydatas.push(member);
// }
// }
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
bodydatas.push(member);
}
if (bodydatas.length > 0) {
jsonBody = ConvertRecordsToJsonAll(bodydatas);
}
//
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCrmQuotation/Save',
scope: this,
params: {
opStatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var returnData = jsonresult.Data;
this.formHead.getForm().reset();
this.formHead.getForm().setValues(returnData);
this.formHead.getForm().findField('CREATETIME').setValue(returnData.CREATETIME.toString().substring(0, 10));
this.formHead.getForm().findField('QUOTATIONDATE').setValue(returnData.QUOTATIONDATE.toString().substring(0, 10));
this.formHead.getForm().findField('VALIDDATE').setValue(returnData.VALIDDATE.toString().substring(0, 10));
//
if (this.opStatus == 'add') {
var arrNewRecords = this.StoreList.add(returnData);
this.editRecord = arrNewRecords[0];
}
else if (this.opStatus == 'edit') {
var editp = Ext.create('MsCrmQuotationEntity', returnData);
this.editRecord.fields.each(function (field) {
if (field.persist) {
name = field.name;
if (name != 'id')
this.editRecord.set(name, editp.get(name));
}
}, this);
this.editRecord.commit();
}
if (type == '0') {
this.opStatus = 'edit';
} else if (type == '1') {
this.opStatus = 'edit';
window.close();
} else if (type == '2') {
this.opStatus = 'add';
this.onBtnAdd(this.opStatus, 1);
}
//
var condition = "LINKGID='" + returnData.GID.toString() + "'";
this.storeDetailList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
} 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 });
}
}
});
},
//#endregion
//#region 新增明细
onAddClick: function () {
var sLINKGID = this.formHead.getForm().findField('GID').getValue();
var n = this.storeDetailList.getCount();
var record = Ext.create('CrmQuotationDetailModel', {
GID: '*',
FEENAME: '',
CURRENCY: 'RMB',
UNIT: '',
UNITPRICE: 0,
RMBHJ: 0, //需求编号SR2017071700006-2、3、4
USDHJ: 0, //需求编号SR2017071700006-2、3、4
LINKGID: sLINKGID
});
this.storeDetailList.add(record);
this.gridListCellEditing.startEditByPosition({ row: n, column: 1 }); //n - 1
},
//#endregion
//#region 删除明细
onDelClick: function () {
var selectedRecords = this.gridList.getSelectionModel().getSelection();
//var selectedRecords = this.gridList.selModel.getSelection();
if (selectedRecords.length == 0) {
Ext.Msg.show({ title: '提示', msg: '请先选择费用!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var rec = selectedRecords[0].data;
if (rec.GID == "" || rec.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台
{
this.storeDetailList.remove(selectedRecords[0]);
}
else {
var sLINKGID = rec.LINKGID;
Ext.MessageBox.confirm('提示', '确定删除该费用吗?', function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在删除数据...');
Ext.Ajax.request({
waitMsg: '正在删除数据...',
url: '/MvcShipping/MsCrmQuotation/DeleteDetail',
params: {
gids: rec.GID
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var condition = "LINKGID='" + sLINKGID + "'";
this.storeDetailList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
Ext.Msg.hide();
//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 });
},
scope: this
});
}
}, this);
}
},
//#endregion
//#region 保存明细
onSaveClick: function () {
this.formHead.getForm().findField('GID').setDisabled(false);
var data = this.formHead.getForm().getValues(false, false, false);
var sLINKGID = "";
if (data.GID.toString().trim() == "" || data.GID.toString().trim() == "*") {
this.Save('0');
}
else {
sLINKGID = data.GID.toString().trim();
var bodydatas = [];
//需求编号SR2017072600008-2
// var records = this.storeDetailList.getUpdatedRecords(); // 获取修改的行的数据,无法获取幻影数据
// var phantoms = this.storeDetailList.getNewRecords(); //获得幻影行
// records = records.concat(phantoms); //将幻影数据与真实数据合并
// if (records.length != 0) {
// for (var i = 0; i < records.length; i += 1) {
// var member = records[i];
// bodydatas.push(member);
// }
// }
for (var i = 0; i < this.storeDetailList.getCount(); i += 1) {
var member = this.storeDetailList.getAt(i);
bodydatas.push(member);
}
if (bodydatas.length > 0) {
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/MvcShipping/MsCrmQuotation/SaveDetail',
scope: this,
params: {
body: jsonBody,
sLINKGID: sLINKGID
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
var condition = "LINKGID='" + sLINKGID + "'";
this.storeDetailList.load({ params: { condition: condition }, waitMsg: "正在刷新数据...", scope: this });
} 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 });
}
}
});
}
}
},
//#endregion
onNextKeyClick: function (col) {
var rows = this.gridList.getSelectionModel().getSelection();
var row = rows[rows.length - 1];
var s = this.gridList.getStore();
var number = s.indexOf(row);
this.gridListCellEditing.startEditByPosition({ row: number, column: col });
},
OprationSwap2: function () {
var ret = new Array();
ret[0] = this.storeDetailList;
ret[1] = this.editRecord;
return ret;
}
//上传附件按钮
, onUpLoadFileClick: function (button, event) {
if(this.opStatus == 'add')
{
Ext.Msg.show({ title: '错误', msg: '请先保存该业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var billno = this.editRecord.get('GID');
me = this;
var imgform = new Ext.FormPanel({
region: 'center',
labelWidth: 40,
frame: true,
bodyStyle: 'padding:5px 5px 0',
autoScroll: true,
border: false,
fileUpload: true,
items: [{
xtype: 'fileuploadfield',
id: 'LoadFile',
name: 'LoadFile',
emptyText: '请选择文件',
fieldLabel: '文件',
buttonText: '选择文件',
allowBlank: false,
buttonCfg:
{
iconCls: 'uploaddialog'
},
anchor: '98%'
}],
buttons: [{
text: '上传',
type: 'submit',
handler: function () {
var UserFilePath = Ext.getCmp('LoadFile').getValue();
// if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) {
// Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
// return;
// }
if (!imgform.form.isValid()) { return; }
imgform.form.submit({
url: '/MvcShipping/MsOpReceipt/UploadFile',
waitMsg: '正在上传',
method: 'POST',
submitEmptyText: false,
async: false,
params: {
CUSTNO: billno,
BSNO: billno,
TYPE: '报价维护'
},
success: function (form, action) {
win.close(this);
Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
me.storeDocList.reload();
},
failure: function (form, action) {
form.reset();
if (action.failureType == Ext.form.Action.SERVER_INVALID)
Ext.MessageBox.alert('警告', action.result.errors.msg);
}
});
}
}, {
text: '关闭',
type: 'submit',
handler: function () {
win.close(this);
}
}]
});
var win = new Ext.Window({
title: "上传文件",
width: 360,
height: 120,
modal: true,
resizable: false,
border: false,
items: imgform
});
win.show();
}
});