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/Account/Viewsjs/Chfee_management/C_MView.js

604 lines
19 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.

///<reference path="../../../../Views/../TruckMng/Scripts/vswd-ext_2.0.2.js" />
Ext.namespace('DsTruck');
var C_cargoinfo_id="";
var HTHCount=0;
DsTruck.Chfee_managementView = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.Chfee_managementView.superclass.constructor.call(this);
};
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(), //second
"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;
}
var xhr = new XMLHttpRequest();
var currdate = new Date();
if (!xhr) {
//...其他生成xmlhttprequest方法
}
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);
// alert(currdate.format('yyyy-MM-dd'));
}
}
xhr.send(null);
Ext.extend(DsTruck.Chfee_managementView, Ext.Panel, {
parentWin: null,
OpStatus: 'add',
StoreList: null,
editRecord: null,
// parentfunction: null,
_First: true,
initUIComponents: function () {
this.feeSerialNo = 0;
this.feeBodyDel = [];
//枚举参照相关(编辑form)
Ext.define('FeeTypeMd', {
extend: 'Ext.data.Model',
fields: [
{ name: 'FeeTypeID', type: 'string' },
{ name: 'FeeTypeName', type: 'string' }
]
});
var FeeTypeData = [{ "FeeTypeID": "1", "FeeTypeName": "收入" },
{ "FeeTypeID": "2", "FeeTypeName": "支出"}];
var storeFeeType = Ext.create('Ext.data.Store', {
model: 'FeeTypeMd',
data: FeeTypeData
});
this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '收付类型',
store: storeFeeType,
name: 'FEETYPE',
valueField: 'FeeTypeID',
displayField: 'FeeTypeName'
});
this.storeUser = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsTruckMng.ux.UserRefModel',
proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' }
});
this.storeUser.load({ params: { condition: " 1=1 "} });
this.comboxCreator = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '制单人',
store: this.storeUser,
name: 'CREATOR',
valueField: 'GID',
displayField: 'CodeAndName',
allowBlank: false
});
this.comboxAuditor = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '审核人',
store: this.storeUser,
name: 'AUDITOR',
id: "AUDITOR",
valueField: 'UserCode',
displayField: 'CodeAndName'
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '币别',
store: this.storecurr,
name: 'CURRENCY',
valueField: 'codename',
displayField: 'codename',
value: "RMB"
});
this.storeFEESTATUS = Ext.create('DsExt.ux.RefEnumStore', {});
this.storeFEESTATUS.load({ params: { enumTypeId: 99024} });
this.comboxFEESTATUS = Ext.create('DsExt.ux.RefEnumCombox', {
fieldLabel: '费用状态',
store: this.storeFEESTATUS,
name: 'FEESTATUS',
disabled: true,
id: "STATUS"
});
this.storeAccitems = Ext.create('DsExt.ux.RefTableStore', {
model: 'Accitemsmb',
proxy: { url: '/CommMng/BasicDataRef/GetMngAccitems' }
});
this.storeAccitems.load({ params: { condition: ""} });
this.comboxBANK = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '收支科目',//收支的银行账户
store: this.storeAccitems,
name: 'OPERATORSIDE',
valueField: 'ACCID',
displayField: 'ACCIDNAME',
flex:1
});
//////////////////
//编辑form:formEdit
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'center',
frame: true,
bodyPadding: 5,
trackResetOnLoad: true,
fieldDefaults: {
margins: '2 2 2 2',
labelAlign: 'right',
flex: 1,
labelWidth: 90,
msgTarget: 'qtip'
//,split:true
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{//container_1
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '管理费单号',
// allowBlank: false,
disabled: true,
name: 'Feeid'
}, this.comboxFeeTypeRef, this.comboxCreator, {
fieldLabel: '制单时间',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'CREATEDATE'
},
//this.comboxFEENAME,
{
fieldLabel: '时间戳',
name: 'TimeMark', flex: 0, hidden: true, margins: '0'
}
]
}, //container_1 end
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
{
fieldLabel: '金额',
//allowBlank: false,
disabled: true,
id: "AMOUNT_ALL",
name: 'AMOUNT',
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;
}
}, this.comboxcurr, {
fieldLabel: '汇率',
allowBlank: false,
disabled: false,
name: 'EXCHANGERATE'
}, {
fieldLabel: '费用发生时间',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'FEEDATE'
}
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [
this.comboxFEESTATUS,
this.comboxAuditor, {
fieldLabel: '审核时间',
format: 'Y-m-d',
xtype: 'datefield',
renderer: Ext.util.Format.dateRenderer('Y-m-d'),
name: 'AUDITDATE'
,id: "AUDITDATE"
}, {
fieldLabel: '凭证号',
xtype: 'textfield',
name: 'VOUCHERSNO'
}]
}, /*{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: []
},*/{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '会计期间',
allowBlank: false,
xtype: 'monthfield',
name: 'ACCDATE',
flex: 1
},this.comboxBANK, {
fieldLabel: '备注',
name: 'REMARK',
flex: 2
}]
}
]
}
]
});
//////////////////////////////////
//明细 <<<< 收支费用明细 >>>>
//
this.comboxAccitems = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '费用科目',
store: this.storeAccitems,
name: 'FEENAME',
valueField: 'ACCID',
displayField: 'ACCIDNAME'
});
this.storeTrader = Ext.create('DsExt.ux.RefTableStore', {
model: 'Tradermb',
proxy: { url: '/CommMng/BasicDataRef/GetTrader' }
});
this.storeTrader.load({ params: { condition: " 1=1 "} });
this.comboxTrader = Ext.create('DsExt.ux.RefTableCombox', {
//fieldLabel: '关系人',
store: this.storeTrader,
name: 'CUSTOMERSIDE',
valueField: 'name',
displayField: 'codename'
});
this.storecurr = Ext.create('DsExt.ux.RefTableStore', {
model: 'currRef',
proxy: { url: '/CommMng/BasicDataRef/GetcurrRefList' }
});
this.storecurr.load({ params: { condition: ""} });
this.comboxcurr = Ext.create('DsExt.ux.RefTableCombox', {
store: this.storecurr,
name: 'currid',
valueField: 'gid',
displayField: 'codename'
//币别
});
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'
});
//数据集
this.storeFeeBody = Ext.create('Ext.data.Store', {
model: 'FeeBodymb',
remoteSort: false,
pruneModifiedRecords: true,
proxy: {
type: 'ajax',
url: '/Account/Chfee_management/GetFeeList',
reader: {
id: 'id,ContractNo',
root: 'data',
totalProperty: 'totalCount'
}
}
});
//表格
this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});
this.CheckBoxModel = Ext.create('Ext.selection.CheckboxModel');
this.formFeeBody = new Ext.grid.GridPanel({
store: this.storeFeeBody,
enableHdMenu: false,
region: 'north',
trackResetOnLoad: true,
//height: 160,
title: '费用明细',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
selModel: this.CheckBoxModel,
selType: 'cellmodel',
columns: [
{ dataIndex: 'gid', header: 'gid', width: 80, hidden: true },
{ dataIndex: 'Feeid', header: 'Feeid', width: 80, hidden: true },
{
dataIndex: 'CUSTOMERSIDE',
header: '关系人',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.CUSTOMERSIDE; //此处是FeeBody中的字段如果需要则是def之类的查询字段
},
editor: this.comboxTrader,
width: 140
},
{
dataIndex: 'FEENAME',
header: '费用名称',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.FEENAMEREF;
},
editor: this.comboxAccitems,
width: 200
},
{
dataIndex: 'AMOUNT',
header: '金额',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
},
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;
}
},
{
dataIndex: 'DEPTGID',
header: '所属部门',
renderer: function (value, p, record) {
if (value == null || value == '') return '';
else return record.data.DEPTNAME;
},
editor: this.comboxDEPT,
width: 140
},
{
dataIndex: 'REMARK',
header: '备注',
width: 80,
editor: {
xtype: 'textfield',
selectOnFocus: true
}
}]
});
//////////////////////////////////////////////明细<<<< 收支费用明细 >>>>结束
//公共按钮Toolbar:panelBtn
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
// id: "saveandclose",
text: "关闭",
handler: function (button, event) {
window.close();
},
scope: this
}
]
}); //end 按钮Toolbar
//布局
/* 3 */
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 32,
items: [this.panelBtn]//, this.formEdit]
});
this.page_1 = new Ext.Panel({
title: "管理费用",
items: [this.formEdit, this.formFeeBody]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [
this.page_1
//, this.page_2
//, this.page_3
//, this.page_4
]
})
Ext.apply(this, {
items: [this.panelTop, this.MainTab]
});
parentWin = window.parent.opener._this;
this.InitData();
//集中绑定编辑后事件
this.formFeeBody.on('edit', function (editor, e, eOpts) {
this.FeeAfterEdit(editor, e, eOpts);
}, this);
}, //end initUIComponents
parentfunction: function (button, event) {
var ret1 = window.parent.opener.OprationSwap();
// alert(this.First);
ret1[3]();
},
InitData: function () {
this.opStatus = 'add';
var condition = '';
if (parentWin) {
var ret = parentWin.OprationSwap();
this.opStatus = 'edit';
this.StoreList = ret[1];
this.editRecord = ret[2];
// this.parentfunction = ret[3];
}
if (this.opStatus == 'edit')
condition = " cm.Feeid='" + this.editRecord.get('BILLNO') + "'";
this.LoadData(this.opStatus, condition);
}, //end InitData
//载入数据
LoadData: function (opstatus, condition) {
this.opStatus = opstatus;
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/Account/Chfee_management/GetData',
params: {
handle: 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;
}
var data = result.data;
// this.formEdit.getForm().reset();
if (data.CREATEDATE == "") { data.CREATEDATE = currdate.format('yyyy-MM-dd') };
if (data.CREATOR == "") { data.CREATOR = usercode };
if (data.CURRENCY == "") { data.CURRENCY = "RMB" };
if (data.FEETYPE == "0") { data.FEETYPE ="2" };
if (data.EXCHANGERATE == "") { data.EXCHANGERATE = "1" };
this.formEdit.getForm().setValues(data);
//alert(data.TimeMark);
if (this.opStatus == 'add') {
Ext.getCmp("STATUS").setValue('1');
}
function setsave() { saved = true; }
var task = new Ext.util.DelayedTask(setsave);
task.delay(500);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
}); //request over
if (this.opStatus == 'edit') {
this.formEdit.getForm().findField('Feeid').setDisabled(false);
this.storeFeeBody.load({ params: { condition: "cfm.Feeid = '"+this.editRecord.get('BILLNO')+"'"} });
this.formEdit.getForm().findField('Feeid').setDisabled(true);
}
}, // end LoadDate
checkedit: function (status) {
if (status != 1 && status != 2 && status != 6) {
alert("只有 录入状态/提交审核/驳回提交 的费用才能保存");
return false;
} else { return true; }
}
});