|
楼主 |
发表于 2013-12-4 16:09:18
|
显示全部楼层
fengwei 发表于 2013-12-4 15:40
你这是在做什么操作,js代码放出来看一下
var startActivity = {};
function mdMainxforms_model_construct_done(event) {
var data = justep.xbl('dBuyApplyM');
var sData1 = justep.Context.getProcessData1();
if (sData1 == null || sData1 == undefined) {
data.newData();
} else {
data.filters
.setFilter("flowFilter", "OA_AS_BuyApplyM='" + sData1 + "'");
data.refreshData();
}
}
function dBuyApplyMValueChanged(event) {
var data = justep.xbl('dBuyApplyM');
if (event.column == "fApplyDeptID") {
var rowid = data.getCurrentRowId();
data.setValue("fApplyPsnID", "", rowid);
data.setValue("fApplyPsnName", "", rowid);
}
}
// 人员下拉事件
function treeSltPsmDropdown(event) {
var data = justep.xbl('dBuyApplyM');
var applyDeptID = data.getValue("fApplyDeptID");
var personData = justep.xbl('dPsm');
personData.filters.setFilter("psmFilter", "SA_OPOrg.sFID like '%/"
+ applyDeptID + ".%'");
personData.refreshData();
}
function dBuyApplyDAfterDelete(event) {
sumAmount();
}
function dBuyApplyDValueChanged(event) {
var data = justep.xbl('dBuyApplyD');
if (event.column == "fBuyNum" || event.column == "fPrice") {
var rowid = data.getCurrentRowId();
var fPrice = data.getValue("fPrice", rowid);
var fBuyNum = data.getValue("fBuyNum", rowid);
var fAmount = parseFloat((fPrice * fBuyNum).toFixed(2));
data.setValue("fAmount", fAmount, rowid);
sumAmount();
}
}
function tabFlowChartxforms_select(event) {
var control = justep.xbl("processChart");
var process = justep.Context.getCurrentProcess();
var bizData = justep.xbl('dBuyApplyM').getCurrentRowId();
control.loadByData(process, bizData);
}
function sumAmount() {
var mainData = justep.xbl('dBuyApplyM');
var buyApplyData = justep.xbl('dBuyApplyD');
var totleAmount = 0;
var length = buyApplyData.getCount();
for (var i = 0; i < length; i++) {
var mID = buyApplyData.getRowId(i);
if (typeof mID == "undefined") {
continue;
}
var fAmount = buyApplyData.getValue("fAmount", mID);
totleAmount = parseFloat(totleAmount - (-fAmount)).toFixed(2);
}
mainData.setValue("fAmount", totleAmount, mainData.getCurrentRowId());
}
startActivity.trgPrintClick = function(event){
var process = justep.Context.getCurrentProcess();
var activity = justep.Context.getCurrentActivity();
var rowid = justep.xbl("dBuyApplyM").getCurrentRowId();
if (rowid && (rowid != "")) {
var url = "/OA/asset/process/assetReport/BuyApplyReport/BuyApplyReport.w?process="
+ process + "&activity=" + activity + "&rowid=" + rowid;
justep.Portal.openWindow("打印", url);
}
};
/**
name:treeSelect#onCloseup
description: <b>[回调事件]</b> 关闭下拉事件
@param event 事件属性:<br/>{"source":XFExtSelect对象,"label":选择的label,"rowID":行ID,"grid":下拉表格对象,"instance":下拉instance对象,"value":选择的value,"valueChanged":value是否改变}
*/
startActivity.treeSltPsmCloseup = function(event){
var sFID = event.grid.fields.sFID.getValue();
var sFName = event.grid.fields.sFName.getValue();
var data = justep.xbl('dBuyApplyM');
data.setValue("fApplyPsnFID",sFID);
data.setValue("fApplyPsnFName",sFName);
};
/**
name:process#onBeforeAdvanceQuery
description: <b>[回调型事件]</b>流转查询之前
@param event 它的结构如下:<br/>{"source":组件的js对象,"task":任务标识,"cancel":false}
*/
startActivity.assetBuyApplyProcessBeforeAdvanceQuery = function(data){
var len = justep.xbl('dBuyApplyD').getCount();
if (len == 0) {
data.cancel = "true";
alert('请填写资产明细!');
}
};
startActivity.trigger1Click = function(event){
var cgDlgtri= justep.xbl("windowDialog1");
cgDlgtri.initEveryTimes = true;
cgDlgtri.open();
};
/**
name:windowDialog#onReceive
@event {"source":组件的js对象,"data":传回的数据}
description: <b>[回调型事件]</b> 对话框返回数据,该事件函数有一个参数event,是对话框返回的数据
*/
function cgDlgReceive(event){
var doc = event.data.getSimpleStore();
}
function dlgBuyApplyReceive(evt) {
var doc = evt.data.getSimpleStore();
var data = justep.xbl('dAssetInD');
var len = doc.rowsBuffer.length;
var fIningNum;
if (len > 0) {
for (var i = 0; i < len; i++) {
fIningNum = doc.getValueByName("fBuyNum", i)
- doc.getValueByName("fInNum", i);
for (var j = 0; j < fIningNum; j++) {
data.newData();
var date = justep.Date.toString(justep.System.datetime(),"YYYYMMDD");
data.setValue('fCode', "临时:"+appCommon.ToolUtils.createNextSeqString(
date+'-' + doc.getValueByName("fKindCode", i) + '-',
'000'));//资产编码
data.setValue('fName', doc.getValueByName("fName", i));//名称
data.setValue('fSpecType', doc.getValueByName("fSpecType", i));//规格型号
data.setValue('fKindID', doc.getValueByName("fKindID", i));
//data.setValue('fKindCode', doc.getValueByName("fKindCode", i));
data.setValue('fKind', doc.getValueByName("fKind", i));//资产类别名称
data.setValue('fUnitID', doc.getValueByName("fUnitID", i));//单位
data.setValue('fUnit', doc.getValueByName("fUnit", i));
data.setValue('fAmount', doc.getValueByName("fPrice", i));//金额
data.setValue('fBuyDetailID', doc.getRowId(i));//采购明细ID
data.setValue('fBuyApplyID', doc.getValueByName(//采购单ID
"fMasterID", i));
data.setValue('fBuyApplyNO', doc.getValueByName("fNO", i));//采购单号
}
}
totleAmount();
}
}
/**
name:windowDialog#onReceive
@event {"source":组件的js对象,"data":传回的数据}
description: <b>[回调型事件]</b> 对话框返回数据,该事件函数有一个参数event,是对话框返回的数据
*/
startActivity.windowDialog1Receive = function(event){
var dBuyApplyD = justep.xbl('dBuyApplyD');
var doc = justep.xbl('PurchaseInfoData');
var id = event.data[0].rowid;
//绑定固资采购单与合同关系
var dBuyApplyM = justep.xbl('dBuyApplyM');
dBuyApplyM.setValue("fConcractID", id); //合同主从关系
var data = justep.xbl('concractData');
data.filters.setFilter("Filter", "IT_ProcureConcract= '"+ id +"'");
data.refreshData();
doc.loadDataByMaster();
doc.refreshData();
var len = doc.getCount();
if (len > 0) {
for ( var i = 0; i < len; i++) {
var id = doc.getRowId(i);
debugger;
// if (xforms('grdBuyApplyD').grid.getIndex() == -1){
dBuyApplyD.newData();
dBuyApplyD.setValue('fName', doc.getValue("fPropertyName", id));
dBuyApplyD.setValue('fSpecType', doc.getValue("fStandardType", id));
dBuyApplyD.setValue('fKind', doc.getValue("fPropertyType", id));
dBuyApplyD.setValue('fUnit', doc.getValue("fUnit", id));
var fBuyNum = doc.getValue("fAmount", id)-doc.getValue("fBuyNum", id)
dBuyApplyD.setValue('fBuyNum',fBuyNum ); //fAmount,fBuyNum:数量,采购数量
dBuyApplyD.setValue('fPrice', doc.getValue("fPrice", id));
dBuyApplyD.setValue('fAmount', doc.getValue("fMoney", id));
dBuyApplyD.setValue('fRemark', doc.getValue("fRemark1", id));
// }
}
totalAmount();
}
};
function totalAmount(){
var data = justep.xbl('dBuyApplyD');
var len = data.getCount();
if (len > 0) {
var sum = 0;
for ( var i = 0; i < len; i++) {
var id = data.getRowId(i);
var fConsultAmount = data.getValue("fAmount", id);
if (fConsultAmount > 0) {
sum += parseFloat(fConsultAmount);
}
//alert(baseInfo.getValue("fStock"));
}
justep.xbl('dBuyApplyM').setValue("fAmount", sum);
}
};
//startActivity.trigger2Click = function(event){
// var id = justep.xbl('concractData').getCurrentID();
// var data = justep.xbl('dBuyApplyD');
// var len = data.getCount();
// var items="";
// if (len > 0) {
// var sum = 0;
// for ( var i = 0; i < len; i++) {
// var id = data.getRowId(i);
// var fName = data.getValue("fName", id);
// var fBuyNum = data.getValue("fBuyNum", id);
//
// if(i==len-1){
// items += fName+":"+fBuyNum;
// }else{
// items += fName+":"+fBuyNum+",";
// }
// }
// var param = new justep.Request.ActionParam();
// param.setString("id", id);
// param.setString("items", items);
//
// justep.Request.sendBizRequest2({
// action: "updataContractByassetBuyAction",
// parameters: param
// });
// }
//};
startActivity.trigger2Click = function(event){
justep.Portal.closeWindow();
};
|
|