flexbiz-server
Version:
Flexible Server
6 lines (5 loc) • 2.02 kB
JavaScript
'use strict';const PostBook=require("../../libs/post-book"),dmgiaban=global.getModel("dmgiaban"),dmvt=global.getModel("dmvt"),dmkho=global.getModel("dmkho"),model=global.getModel("banggiaban"),controller=require("../../controllers/controller"),trangthai=global.getModel("trangthai"),async=require("async"),ma_ct="BGB";
module.exports=function($contr_router$$){$contr_router$$=new controller($contr_router$$,model,ma_ct.toLowerCase(),{isVoucher:!0,sort:{ngay_ct:-1,so_ct:-1},unique:["so_ct"]});$contr_router$$.route();$contr_router$$.post=function($obj$$,$fn$$){$fn$$||($fn$$=function(){});async.series({post_dmgiaban:function($callback$jscomp$0$$){(new PostBook($obj$$,[...$obj$$.details],dmgiaban,async function($_detail$$,$callback$$){$callback$$({...$_detail$$})})).run(function($e$$,$rs$$){$callback$jscomp$0$$($e$$,
$rs$$)})}},function($e$$,$rs$$){$fn$$($e$$,$rs$$)})};$contr_router$$.creating=function($user$$,$obj$$,$next$$){$obj$$.details||($obj$$.details=[]);$next$$(null,$obj$$)};$contr_router$$.updating=function($user$$,$data$$,$obj$$,$next$$){$next$$(null,$data$$,$obj$$)};$contr_router$$.view=function($user$$,$items$$,$fn$$){let $id_app$$=$user$$.current_id_app;async.series({kho:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kho).joinModel2($id_app$$,dmkho,[{where:"ma_kho",fields:["ten_kho"]}],
function(){$callback$$()})},customer:function($callback$$){$items$$.filter($item$$=>$item$$.ma_kh).joinModel2($id_app$$,"customer",[{where:"ma_kh",fields:["ten_kh"]}],function(){$callback$$()})},trangthai:function($callback$$){$items$$.filter($item$$=>$item$$.trang_thai).joinModel2(null,trangthai,[{where:{trang_thai:"ma_trang_thai",ma_ct:"ma_ct"},fields:["ten_trang_thai","color"]}],function(){$callback$$()})},details_vt:function($callback$$){async.mapSeries($items$$,function($r$$,$callback1$$){($r$$.details||
[]).joinModel2($id_app$$,dmvt,[{where:"ma_vt",fields:[{name:"ten_vt",value:"ten_vt"}]}],function(){$callback1$$()})},function(){$callback$$()})}},function(){$fn$$(null,$items$$)})}};