UNPKG

flexbiz-server

Version:

Flexible Server

7 lines (6 loc) 2.77 kB
var model=global.getModel("dmnhnv"),dmbp=global.getModel("dmbp"),dmdoi=global.getModel("dmdoi"),dmto=global.getModel("dmto"),Participant=global.getModel("participant");const async=require("async"),controller=require("../../controllers/controller"); module.exports=function($router$$){(new controller($router$$,model,"dmnhnv",{sort:{ma_bp:1,ma_doi:1,ma_to:1,ma_nh_nv:1},notNeedRight:($user$$,$options$$={})=>($options$$.action||"").toLowerCase()=="view"?!0:!1,unique:["ma_nh_nv"],onView:function($user$$,$items$$,$next$$){async.series({dp:function($callback$$){$items$$.joinModel2($user$$.current_id_app,dmbp,[{where:{ma_bp:"ma_bp"},fields:["ten_bp"]}],function(){$callback$$(null,$items$$)})},doi:function($callback$$){$items$$.joinModel2($user$$.current_id_app, dmdoi,[{where:{ma_doi:"ma_doi",ma_bp:"ma_bp"},fields:["ten_doi"]}],function(){$callback$$(null,$items$$)})},to:function($callback$$){$items$$.joinModel2($user$$.current_id_app,dmto,[{where:{ma_doi:"ma_doi",ma_bp:"ma_bp",ma_to:"ma_to"},fields:["ten_to"]}],function(){$callback$$(null,$items$$)})},pt:function($callback$$){$items$$.joinModel2($user$$.current_id_app,Participant,[{where:{phu_trach:"email"},fields:[{ten_phu_trach:"name"}]}],function(){$callback$$(null,$items$$)})},ph:function($callback$$){$items$$.joinModel2($user$$.current_id_app, Participant,[{where:{phoi_hop:"email"},fields:[{ten_phoi_hop:"name"}]}],function(){$callback$$(null,$items$$)})}},()=>{$next$$(null,$items$$)})},onRightByItem:($user$$,$condition$$,$next$$)=>{async.parallel({phu_trach_bp:$callback$$=>{dmbp.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().then($bps$$=>{$callback$$(null,$bps$$)}).catch($e$$=>{$callback$$($e$$)})},phu_trach_doi:$callback$$=>{dmdoi.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().then($bps$$=>{$callback$$(null, $bps$$)}).catch($e$$=>{$callback$$($e$$)})},phu_trach_to:$callback$$=>{dmto.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().then($bps$$=>{$callback$$(null,$bps$$)}).catch($e$$=>{$callback$$($e$$)})}},($_condition_bps$jscomp$3_e$$,$$or_rs_tos$$)=>{if($_condition_bps$jscomp$3_e$$)return $next$$($_condition_bps$jscomp$3_e$$);$_condition_bps$jscomp$3_e$$=$$or_rs_tos$$.phu_trach_bp.map($bp$$=>$bp$$.ma_bp);var $_c_dois$$=$$or_rs_tos$$.phu_trach_doi.map($doi$$=>$doi$$.ma_doi);$$or_rs_tos$$= $$or_rs_tos$$.phu_trach_to.map($to$$=>$to$$.ma_to);$$or_rs_tos$$=[{ma_bp:{$in:$_condition_bps$jscomp$3_e$$}},{ma_doi:{$in:$_c_dois$$}},{ma_to:{$in:$$or_rs_tos$$}}];$_condition_bps$jscomp$3_e$$=[];for(let $k$$ in $condition$$)$_c_dois$$={},$_c_dois$$[$k$$]=$condition$$[$k$$],$_condition_bps$jscomp$3_e$$.push($_c_dois$$);$$or_rs_tos$$.push({$and:$_condition_bps$jscomp$3_e$$});$next$$(null,{$or:$$or_rs_tos$$})})}})).route()};