UNPKG

flexbiz-server

Version:

Flexible Server

7 lines (6 loc) 2.87 kB
'use strict';const dvcs=global.getModel("dvcs"),account=global.getModel("account"),dmdt=global.getModel("dmdt"),dmphi=global.getModel("dmphi"),contract=global.getModel("contract"),customer=global.getModel("customer"),dmkho=global.getModel("dmkho"),model=global.getModel("kbbtpb"),controller=require("../../controllers/controller"),async=require("async"),ma_ct="KBBTPB"; module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,sort:{stt:1}});$contr_router$$.route();$contr_router$$.creating=function($user$$,$obj$$,$next$$){$next$$(null,$obj$$)};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){$next$$(null,$data$$,$obj$$)};$contr_router$$.view=function($user$$,$items$$,$fn$$){const $id_app$$=$user$$.current_id_app;async.series({dv:function($callback$$){$items$$.filter($item$$=>$item$$.ma_dvcs).joinModel2($id_app$$, dvcs,[{where:{ma_dvcs:"_id"},fields:["ten_dvcs"]}],function(){$callback$$()})},tkco:function($callback$$){$items$$.filter($item$$=>$item$$.tk_co).joinModel2($id_app$$,account,[{where:{tk_co:"tk"},fields:[{ten_tk_co:"ten_tk"}]}],function(){$callback$$()})},details_tk_no:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).joinModel2($id_app$$,account,[{where:{tk_no:"tk"},fields:[{ten_tk_no:"ten_tk"}]},{where:{tk_no1:"tk"},fields:[{ten_tk_no1:"ten_tk"}]},{where:{tk_co1:"tk"}, fields:[{ten_tk_co1:"ten_tk"}]}],function(){$callback1$$()})},function(){$callback$$()})},details_dt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_dt).joinModel2($id_app$$,dmdt,[{where:"ma_dt",fields:["ten_dt"]}],function(){$callback1$$()})},function(){$callback$$()})},details_contract:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_hd).joinModel2($id_app$$, contract,[{where:{ma_hd:"so_hd"},fields:["ten_hd"]}],function(){$callback1$$()})},function(){$callback$$()})},details_phi:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_phi).joinModel2($id_app$$,dmphi,[{where:"ma_phi",fields:["ten_phi"]}],function(){$callback1$$()})},function(){$callback$$()})},details_kh:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$, customer,[{where:"ma_kh",fields:["ten_kh"]}],function(){$callback1$$()})},function(){$callback$$()})},details_kho:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||[]).filter($item$$=>$item$$.ma_kho).joinModel2($id_app$$,dmkho,[{where:"ma_kho",fields:["ten_kho"]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};