项目:
==国际重工==
单据:
==服务工单-三包维修配件申请单==
代码主要页面:
1.code/worksheet/plugin/worksheetsave.lib
2.code/worksheet/xml/worksheetsaver.xml
3.code/www/js/tdetail.js
4.code/www/js/worksheet/worksheetedit.php
5.code/www/js/worksheet/worksheetajax.php
6.code/www/js/worksheet/worksheetitemajax.php
1--点击用户资产放大镜,只显示带有明细的用户。
在
code/www/js/worksheet/worksheetedit.php
添加内容:
1》
//编辑资产放大镜
$layout->setAttributeEditFunc("Worksheet.Asset", "gblPageTabObject[gblCurrentTabName]._getAssetItem"); //资产
编辑或者添加$layout->setAttributeEditFunc(“属性名”,“js调用方法名”);
2》
gblPageTabObject[gblCurrentTabName]._getAssetItem = function (attrname, dataObj)
{
var ddo = tui.dd.getDDO(attrname);
var value = eval("dataObj."+name2cname(attrname));
addID = eval("dataObj."+name2cname(ddo.ReferredBy));
var refNameAttrName = tui.dd.getNameAttrName(tui.dd.getObjectTypeByName(ddo.ReferObjName))
if(isObject(value))
value = eval("value."+lastName(refNameAttrName));
else
value = "";
var vname = name2var(ddo.ReferredBy);
var item1 = tui.getObjectSelectItem(vname, ddo.ReferObjName,addID, value, "EditObjectSelectCB", "", "", "", "",true, false);
item1.allowBlank = true;
if ((ddo.EditCols < tui.w)||isBlank(ddo.EditCols))
item1.width = tui.w;
else
item1.width = ddo.EditCols;
if (ddo.IsRequired||ddo.SysRequired)
item1.allowBlank = false;
retItem = item1;
retItem.SelectAPC = gblPageTabObject[gblCurrentTabName]._GetCurrentAccount;
return retItem;
}
gblPageTabObject[gblCurrentTabName]._GetCurrentAccount = function (nomsg)
{
var ele =Ext.get(name2IDName(gblPageTabObject[gblCurrentTabName].CUR_OBJECT_NAME+".AccountID"));
var value = "";
if(isObject(ele))
value = ele.getValue();
if(!isValidID(value))
value = "";
else
{
value = "Asset.AccountID:"+value;
}
//AJAX
var url = "/worksheet/worksheetajax.php";
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", url,false);
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
conn.send();
var response = conn.responseText;
var responseObj = Ext.util.JSON.decode(conn.responseText);
if(responseObj.prodids != "")//拼凑sql语句 TDD_OPER_INC含义为 包含
value += ";Asset.ID:" + responseObj.prodids + ":" + TDD_OPER_INC;
//END
return value;
}
3》
编写ajax处理数据页面
code/www/js/worksheet/worksheetajax.php
内容:
include_once("tglobal.lib");
$debug = new CrmDebug();
global $gblDB;
$result = array();
//拼写sql语句。
$arrProd_id = array();
$stmt = new TSQLStmt();
$stmt->Table("tc_asset", "a");
$stmt->Table("tc_asset_d", "d");
$stmt->Join("a", "asset_id", "d", "asset_id");
$stmt->SelectString("distinct a.asset_id", "asset_id");
$stmt->Cond("a", "asset_id",0,"<>");
$stmt->Cond("d", "is_deleted",0,"=");
$sql = $stmt->SQLGen();
$rs = $gblDB->query($sql);
if ($gblDB->getErrNo()) {
throw new TDBException($gblDB->getErrNo());
}
if ($rs) {
while($rs->fetchRecord()) {
$arrProd_id[] = $rs->getFieldValueByName("asset_id");
}
$rs->close();
}
$prodids = "";
if(count($arrProd_id) > 0)
$prodids = implode(",", $arrProd_id);
$result['success'] = true;
$result['prodids'] = $prodids;
//返回值为查询语句where后的条件。
echo json_encode($result);
?>
《END 只显示包含明细的用户资产过滤完成》
2.点击明细零件名称放大镜,只显示该用户下的设备。
1》//
在地址:code/www/js/tdetail.js 中添加,修改内容
//开始放大镜
function TD_MultiSelectObject(attrVarName)//(objType,dataObj,rowIdx,listIdx,actIdx)
{
Ext.EventObject.stopEvent();
var objName = removeTabID(attrVarName.substr(0,attrVarName.search("_")));
var curObj = getGridDtlEditorByName(objName);
var TypeID=curObj.MainDo.TypeID;
//添加过滤条件
if(objName=="WorksheetItem" && TypeID=="72"){
Ext.EventObject.stopEvent();
var ddo = tui.dd.getDDO(curObj.mainAttr);
var apc = "";
var param = "";
var objName = ddo.ReferObjName;
var e = Ext.get(addTabID("Worksheet__AssetID"));
if (e)
AssetID = e.dom.value;
if (isValidID(AssetID)){
var url = "/worksheet/worksheetitemajax.php";
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", url,false);
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
conn.send("AssetID="+AssetID);
var response = conn.responseText;
var responseObj = Ext.util.JSON.decode(response);
if(responseObj.prodids != "")
apc += "Product.ID:" + responseObj.prodids + ":" + TDD_OPER_INC;
}
OpenMuiltiSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),"TD_MultiSelectCallBack",'',apc,param,false,false,false,true,curObj.condRelation);
}
else{
var ddo = tui.dd.getDDO(curObj.mainAttr);
if(ddo && ddo.IsRefObj)
{
//var attr = curObj.adaptor.selAttrName;
var apc = "";
if(curObj.condFunc)
{
apc = eval(curObj.condFunc+'()');
if(isBlank(apc) && (objName != "OpportunityItem")) return;
}
var param = "";
if(curObj.paramFunc)
{
param = eval(curObj.paramFunc+'()');
if(isBlank(param) && (objName != "OpportunityItem")) return;
}
var objName = ddo.ReferObjName;
if((ddo.ReferObjName == 'Product')&&(!curObj.isProduct) )
objName = 'PricebookItem';
OpenMuiltiSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),"TD_MultiSelectCallBack",'',apc,param,false,false,false,true,curObj.condRelation);
}
return false;
}
}
// 添加行删除前放大镜 (1674,0,0,"TD_SingleSelectObject",0,"WorksheetItem")
function TD_ActionClick(recordId,listIdx, rowIndex, funcname, actIdx,objName)
{
var curObj = getGridDtlEditorByName(objName);
//var list = getPageListObject(listIdx);
//添加过滤条件--start
var TypeID=curObj.MainDo.TypeID;
if(objName=="WorksheetItem" && funcname=="TD_SingleSelectObject" && TypeID=="72"){
Ext.EventObject.stopEvent();
var ddo = tui.dd.getDDO(curObj.mainAttr);
var apc = "";
var param = "";
var objName = ddo.ReferObjName;
var e = Ext.get(addTabID("Worksheet__AssetID"));
if (e)
AssetID = e.dom.value;
if (isValidID(AssetID)){
var url = "/worksheet/worksheetitemajax.php";
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", url,false);
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
conn.send("AssetID="+AssetID);
var response = conn.responseText;
var responseObj = Ext.util.JSON.decode(response);
if(responseObj.prodids != "")
apc += "Product.ID:" + responseObj.prodids + ":" + TDD_OPER_INC;
}
var currentStore = curObj.gridPanel.getStore();
for(var i=0;i{
if(currentStore.data.keys[i] == recordId)
{
rowIndex=i;
break;
}
}
curObj.focusRowNumber = rowIndex;
OpenSingleSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),curObj.CBName,'',apc,param,"",false,false,false,curObj.condRelation);
//END
}else{
if( funcname=="TD_SingleSelectObject" ){
var NewcurObj = getGridDtlEditorByName(objName);
var currentStore = NewcurObj.gridPanel.getStore();
for(var i=0;i{
if(currentStore.data.keys[i] == recordId)
{
rowIndex=i;
break;
}
}
NewcurObj.focusRowNumber = rowIndex;
if (this.xtype == "combo")
{
var pEl = this.el.dom.parentElement.parentElement;
pEl.setAttribute("style","z-index:1;position: absolute");
}
if(isBlank(objName))
{
objName = removeTabID(this.el.dom.id.substr(0,this.el.dom.id.search("_")));
var curObj = getGridDtlEditorByName(objName);
}
else
var curObj = getGridDtlEditorByName(objName);
var ddo = tui.dd.getDDO(curObj.mainAttr);
if(ddo && ddo.IsRefObj)
{
var apc = "";
if(curObj.condFunc)
{
apc = eval(curObj.condFunc+'()');
if(isBlank(apc) && (objName != "OpportunityItem")) return;
}
else if(typeof this.SelectAPC == "function")
apc = this.SelectAPC();
else apc = this.SelectAPC;
var param = "";
if(curObj.paramFunc)
{
param = eval(curObj.paramFunc+'()');
if(isBlank(param) && (objName != "OpportunityItem")) return;
}
var objName = ddo.ReferObjName;
if((ddo.ReferObjName == 'Product')&&(!curObj.isProduct) )
objName = 'PricebookItem';
OpenSingleSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),curObj.CBName,'',apc,param,"",false,false,false,curObj.condRelation);//TD_detailPopSelCB
}
return false;
}else{
var curObj = getGridDtlEditorByName(objName);
//var list = getPageListObject(listIdx);
var currentStore = curObj.gridPanel.getStore();
for(var i=0;i{
if(currentStore.data.keys[i] == recordId)
{
rowIndex=i;
break;
}
}
curObj.focusRowNumber = rowIndex;
return eval(funcname+"('',curObj.gridPanel.getStore().getAt(rowIndex).json,rowIndex,0,actIdx,objName)");
}
}
}
//添加行零件名称放大镜
function TD_SingleSelectObject(objType,dataObj,rowIdx,listIdx,actIdx,objName)
{
objName = removeTabID(this.el.dom.id.substr(0,this.el.dom.id.search("_")));
var curObj = getGridDtlEditorByName(objName);
var TypeID=curObj.MainDo.TypeID;
if(objName=="WorksheetItem" && TypeID=="72"){
//过滤修改
Ext.EventObject.stopEvent();
var ddo = tui.dd.getDDO(curObj.mainAttr);
var apc = "";
var param = "";
var objName = ddo.ReferObjName;
var e = Ext.get(addTabID("Worksheet__AssetID"));
if (e)
AssetID = e.dom.value;
if (isValidID(AssetID)){
var url = "/worksheet/worksheetitemajax.php";
var conn = Ext.lib.Ajax.getConnectionObject().conn;
conn.open("POST", url,false);
conn.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
conn.send("AssetID="+AssetID);
var response = conn.responseText;
var responseObj = Ext.util.JSON.decode(response);
if(responseObj.prodids != "")
apc += "Product.ID:" + responseObj.prodids + ":" + TDD_OPER_INC;
}
OpenSingleSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),curObj.CBName,'',apc,param,"",false,false,false,curObj.condRelation);//TD_detailPopSelCB
return false;
}else{
if (this.xtype == "combo")
{
var pEl = this.el.dom.parentElement.parentElement;
pEl.setAttribute("style","z-index:1;position: absolute");
}
if(isBlank(objName))
{
objName = removeTabID(this.el.dom.id.substr(0,this.el.dom.id.search("_")));
var curObj = getGridDtlEditorByName(objName);
}
else
var curObj = getGridDtlEditorByName(objName);
var ddo = tui.dd.getDDO(curObj.mainAttr);
if(ddo && ddo.IsRefObj)
{
var apc = "";
if(curObj.condFunc)
{
apc = eval(curObj.condFunc+'()');
if(isBlank(apc) && (objName != "OpportunityItem")) return;
}
else if(typeof this.SelectAPC == "function")
apc = this.SelectAPC();
else apc = this.SelectAPC;
var param = "";
if(curObj.paramFunc)
{
param = eval(curObj.paramFunc+'()');
if(isBlank(param) && (objName != "OpportunityItem")) return;
}
var objName = ddo.ReferObjName;
if((ddo.ReferObjName == 'Product')&&(!curObj.isProduct) )
objName = 'PricebookItem';
OpenSingleSelectWindow(objName,curObj.mainAttr.replace(/\./g,"_"),curObj.CBName,'',apc,param,"",false,false,false,curObj.condRelation);//TD_detailPopSelCB
}
return false;
}
}
2》ajax文件
创建ajax文件:code/www/js/worksheet/worksheetitemajax.php
内容:
include_once("tglobal.lib");
$dd = TDD_GetDatadict();
global $gblDB;
$zlhID = $_POST['AssetID']?$_POST['AssetID']:$_GET['AssetID'];
$result = array();
$arrProd_id = array();
$stmt = new TSQLStmt();
$stmt->Table("tc_asset", "c");
$stmt->Table("tc_asset_d", "d");
$stmt->Join("c", "asset_id", "d", "asset_id");
$stmt->SelectString("distinct d.prod_id", "prod_id");
$stmt->Cond("c", "asset_id", $zlhID);
$sql = $stmt->SQLGen();
$rs = $gblDB->query($sql);
if ($gblDB->getErrNo()) {
throw new TDBException($gblDB->getErrNo());
}
if ($rs) {
while($rs->fetchRecord()) {
$arrProd_id[] = $rs->getFieldValueByName("prod_id");
}
$rs->close();
}
$prodids = "";
if(count($arrProd_id) > 0)
$prodids = implode(",", $arrProd_id);
$result['success'] = true;
$result['prodids'] = $prodids;
echo json_encode($result);
?>
《END明细过滤完成》
3--点击保存后进行对保修时间的效验,检验提交保修的设备是否已经过了保修期
1.只添加一条明细,配件已经过了保修期提示:” 已经过了保修期 “ 。2.添加多条明细,其中有配件已经过了保修期提示:“ 选中配件中有经过了保修期的配件 ”。1》代码位置code/worksheet/plugin/worksheetsave.lib
添加方法:
class BeforeSaveOutServiceDate extends TPrimitive
{
public function execute()
{
global $gblDB;
$prod_id = array();
$arrProd_id = array();
$do = $this->getTarget();
$asset_id=$do->AssetID;
$itemdo= $tdldo->subObj_Detail;
foreach ($do->subObj_Detail as $k=>$dtldo){
$prod_id[$k]=$dtldo->ProductID;
}
if(count($prod_id) > 0){
$prodids = implode(",", $prod_id);
}
$stmt = new TSQLStmt();
$stmt->Table("tc_asset_d", "c");
$stmt->SelectString("c.out_service_date", "outdate");
$stmt->Cond("c", "asset_id", $asset_id , "=");
$stmt->Cond("c", "prod_id","" ," IN($prodids)" );
$sql = $stmt->SQLGen();
$num=strlen($sql)-4;
$newsql=substr($sql,0,$num);
$sl=") ";
$sql=$newsql."".$sl;
$rs = array();
$rs = $gblDB->query($sql);
if ($gblDB->getErrNo()) {
throw new TDBException($gblDB->getErrNo());
}
if ($rs) {
while($rs->fetchRecord()) {
$arrProd_id[] = $rs->getFieldValueByName("outdate");
}
$rs->close();
}
$day=array();
$dd = TDD_GetDatadict();
foreach($arrProd_id as $data){
if(strtotime($data)
2》
添加xml位置code/worksheet/xml/worksheetsaver.xml
添加效验节点
:
《END时间效验完成》