cost add quert,export excel,detail modify

This commit is contained in:
qianhy
2023-01-11 16:53:05 +08:00
committed by lccsw
parent 376d84953b
commit b25d7c63f5
4 changed files with 712 additions and 42 deletions
+339 -19
View File
@@ -22,12 +22,109 @@ class Cost extends HD_Controller{
$this->lists();
}
private function get_where(&$params){
$where = [];
# ref \libraries\Ordersv2List.php private function orders($params = array()), 非lc_items_cost相关组装为in查询
//lc_items
//品牌 车系 车型
$where_items = $where_items_default = '1 = 1';
if ($params['brand_id']) {//品牌
//$where["brand_id"] = $params['brand_id'];
$where_items = $where_items." and brand_id = ".$params['brand_id'];
} else {
if (is_product()) {
//$where["brand_id<>"] = 3;//狸车品牌不显示
$where_items = $where_items." and brand_id <> 3";
}
$params['brand_id'] = '';
}
if ($params['s_id']) {//车系
//$where["s_id"] = $params['s_id'];
$where_items = $where_items." and s_id = ".$params['s_id'];
} else {
$params['s_id'] = '';
}
if ($params['v_id']) {//车型
$where["v_id"] = $params['v_id'];
$where_items = $where_items." and v_id = ".$params['v_id'];
} else {
$params['v_id'] = '';
}
if ($params['vin']) {
//$where["item_id in(select id from lc_items where vin like '%{$params['vin']}%')"] = null;
$where_items = $where_items." and vin like '%{$params['vin']}%'";
}
if ($where_items != $where_items_default){
$where["item_id in (select id from lc_items where $where_items)"] = null;
}
# lc_receiver_orders_v2
//销售员筛选
$where_orders = $where_orders_default = '1 = 1';
if ($params['admin_id']) {
//$where["sale_id"] = $params['admin_id'];
$where_orders = $where_orders.' and sale_id = '.$params['admin_id'];
}
else {
if ($params['biz_id_admin']) {//指定店铺所有销售员
//$where["biz_id"] = $params['biz_id_admin'];
$where_orders = $where_orders.' and biz_id = '.$params['biz_id_admin'];
}
else {
//指定城市的所有门店
$where_biz = array();
if ($params['county_id_admin']) {
$where_biz['county_id'] = $params['county_id_admin'];
}
else if ($params['city_id_admin']) {
$where_biz['city_id'] = $params['city_id_admin'];
}
if ($where_biz) {
$where_biz['status>-1'] = null;
$rows_biz = $this->biz_model->select($where_biz, 'id desc', 0, 0, 'id');
if ($rows_biz) {
$str_ids = implode(',', array_column($rows_biz, 'id'));
//$where["biz_id in({$str_ids})"] = null;
$where_orders = $where_orders." and biz_id in ({$str_ids})";
}
else {
//$where["biz_id"] = -1;
$where_orders = $where_orders.' and biz_id = -1';
}
}
}
!$params['city_id_admin'] && $params['city_id_admin'] = '';
!$params['county_id_admin'] && $params['county_id_admin'] = '';
!$params['biz_id_admin'] && $params['biz_id_admin'] = '';
$params['admin_id'] = '';
}
if ($where_orders != $where_orders_default){
$where["o_id in (select id from lc_receiver_orders_v2 where $where_orders)"] = null;
}
//开票时间
if ($params['bill_time']) {
$bill_time = explode(' ~ ', $params['bill_time']);
if ($bill_time[0]) {
$where["bill_time >="] = $bill_time[0] . ' 00:00:00';
}
if ($bill_time[1]) {
$where["bill_time <="] = $bill_time[1] . ' 23:59:59';
}
}
return $where;
}
public function lists(){
$params = $this->input->get();
$page = $params['page'] = $params['page'] ? intval($params['page']) : 1;
$size = $params['size'] = $params['size'] ? intval($params['size']) : 20;
$autoList = array();
$where = [];
$where = $this->get_where($params);
$count = $this->items_cost_model->count($where);
$lists = [];
if($count){
@@ -41,6 +138,19 @@ class Cost extends HD_Controller{
$map_item[$item['id']] = $item;
}
}
//订单(ref export
$o_ids = implode(',',array_column($rows,'o_id'));
$map_order = [];
if($o_ids){
$where = ["id in ($o_ids)" => null];
$fields = "id, (select biz_name from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_name";
$order_rows = $this->receiver_orders_v2_model->select($where,'','','',$fields);
foreach ($order_rows as $item) {
$map_order[$item['id']] = $item;
}
}
//品牌车型
$brand_arr = array_unique(array_column($item_rows, 'brand_id'));
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
@@ -60,8 +170,11 @@ class Cost extends HD_Controller{
$brand_name = isset($brands[$item['brand_id']]) ? $brands[$item['brand_id']][0]['name'] : '';
$series_name = isset($series[$item['s_id']]) ? $series[$item['s_id']][0]['name'] : '';
$v_name = isset($attr[$item['v_id']]) ? $attr[$item['v_id']][0]['title'] : '';
$srv_json = json_decode($val['srv_json'],true);
$order = $map_order[$val['o_id']];
$lists[] = [
'id' => $val['id'],
'biz_name' => $order['biz_name'],
'title' => "{$brand_name} {$series_name} {$v_name}",
'vin' => $item['vin'],
'sale_price' => $val['sale_price'],
@@ -74,6 +187,10 @@ class Cost extends HD_Controller{
'loan_price' => $val['loan_price'],
'srv_price' => $val['srv_price'],
'car_price' => $val['car_price'],
'dl_car_price' => $val['dl_car_price'],
'brand_car_price' => $val['brand_car_price'],
'if_pay' => $srv_json['if_pay'] ? intval($srv_json['if_pay']) : 0,
'if_pay_name' => $srv_json['if_pay'] == 1 ? '是' : '',
];
}
}
@@ -124,7 +241,8 @@ class Cost extends HD_Controller{
'ori_price' => $item_row['ori_price'],
'buy_price' => $item_row['buy_price'],
'company_name' => $company['short'],
'name' => $order_row['name']."({$order_row['mobile']})",
'name' => $order_row['owner_name']."({$order_row['owner_mobile']})", // 'name' => $order_row['name']."({$order_row['mobile']})",
'payway' => $order_row['payway'],
'biz_type' => $this->biz_model->type_ary($biz['type']),
'biz_name' => $biz['biz_name'],
'admin_name' => $admin['uname'],
@@ -160,6 +278,14 @@ class Cost extends HD_Controller{
if(!$row){
return $this->show_json(SYS_CODE_FAIL,'参数错误');
}
$item_row = $this->items_model->get(['id'=>$row['item_id']]);
$buy_price = $post_data['buy_price'] ? $post_data['buy_price'] : 0;
$res_item = 0;
if ($item_row && $item_row['buy_price'] != $buy_price){
$res_item = $this->items_model->update(array('buy_price'=>$buy_price),['id'=>$row['item_id']]);
}
$data = [
'price' => $post_data['price'] ? $post_data['price'] : 0,
'cost_json' => json_encode($post_data['cost_json'],JSON_UNESCAPED_UNICODE),
@@ -167,7 +293,7 @@ class Cost extends HD_Controller{
'srv_json' => json_encode($post_data['srv_json'],JSON_UNESCAPED_UNICODE),
];
$res = $this->items_cost_model->update($data,['id'=>$row['id']]);
if(is_numeric($res)){
if(is_numeric($res_item) || is_numeric($res)){
$this->items_cost_model->update_total($row['id']);
return $this->show_json(SYS_CODE_SUCCESS,'保存成功');
}else{
@@ -208,22 +334,42 @@ class Cost extends HD_Controller{
$params['size'] = 10000;
$data = $indexs = array();
$fileName = '整车成本';
$where = [];
$where = $this->get_where($params);
$count = $this->items_cost_model->count($where);
if($count){
$rows = $this->items_cost_model->select($where,'id desc',$params['page'],$params['size']);
//车辆
$item_ids = implode(',',array_column($rows,'item_id'));
$map_item = $item_rows = [];
if($item_ids){
$where = ["id in ($item_ids)" => null];
$item_rows = $this->items_model->select($where,'','','','id,brand_id,s_id,v_id,vin');
$item_rows = $this->items_model->select($where,'','','','id,brand_id,s_id,v_id,vin,ori_price,buy_price,(select short from lc_sys_company where id = lc_items.company_id) as cpmpany_name');
foreach ($item_rows as $item) {
$map_item[$item['id']] = $item;
}
}
//订单
$o_ids = implode(',',array_column($rows,'o_id'));
$map_order = [];
if($o_ids){
$where = ["id in ($o_ids)" => null];
$fields = "id, name, mobile, owner_name, owner_mobile, c_time, biz_id, admin_id, payway,
if(payway=1,'贷款','全款') as payway_name,
(select type from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_type,
(select biz_name from lc_biz where id = lc_receiver_orders_v2.biz_id) as biz_name,
(select uname from lc_app_licheb_users where id = lc_receiver_orders_v2.admin_id) as admin_name";
$order_rows = $this->receiver_orders_v2_model->select($where,'','','',$fields);
foreach ($order_rows as $item) {
$map_order[$item['id']] = $item;
}
}
//品牌车型
$brand_arr = array_unique(array_column($item_rows, 'brand_id'));
$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name');
//车系车型
$series_arr = array_unique(array_column($item_rows, 's_id'));
$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name');
@@ -240,42 +386,216 @@ class Cost extends HD_Controller{
$brand_name = isset($brands[$item['brand_id']]) ? $brands[$item['brand_id']][0]['name'] : '';
$series_name = isset($series[$item['s_id']]) ? $series[$item['s_id']][0]['name'] : '';
$v_name = isset($attr[$item['v_id']]) ? $attr[$item['v_id']][0]['title'] : '';
$order = $map_order[$val['o_id']];
// json字段防止为空
$promotion_json = json_decode($val['promotion_json'],true);
!$promotion_json['sale_price'] && $promotion_json['sale_price'] = 0;
!$promotion_json['other'] && $promotion_json['other'] = 0;
!$promotion_json['factory_price'] && $promotion_json['factory_price'] = 0;
$cost_json = json_decode($val['cost_json'],true);
!$cost_json['select_price'] && $cost_json['select_price'] = 0;
!$cost_json['labor_price'] && $cost_json['labor_price'] = 0;
$srv_json = json_decode($val['srv_json'],true);
!$srv_json['commission_price'] && $srv_json['commission_price'] = 0;
!$srv_json['back_price'] && $srv_json['back_price'] = 0;
!$srv_json['loan_offset_price'] && $srv_json['loan_offset_price'] = 0;
!$srv_json['loan_subsidy_price'] && $srv_json['loan_subsidy_price'] = 0;
!$srv_json['loan_in_price'] && $srv_json['loan_in_price'] = 0;
!$srv_json['loan_out_price'] && $srv_json['loan_out_price'] = 0;
!$srv_json['other_out_price'] && $srv_json['other_out_price'] = 0;
!$srv_json['other_in_price'] && $srv_json['other_in_price'] = 0;
!$srv_json['ori_price'] && $srv_json['ori_price'] = 0;
$sum = $this->app_liche_orders_model->sum('total_price', ['o_id'=>$val['o_id'],'status'=>1,'pay_price <>'=>0]);
$pay_price = $sum['total_price'] ? $sum['total_price'] : 0;
$need_price = $this->orders_v2_entity->recevable_price($val['o_id']);
$data[] = [
'id' => $val['id'],
'title' => "{$brand_name} {$series_name} {$v_name}",
'bill_name' => $val['bill_name'],
'biz_type' => $order['biz_type'],
'biz_type_name' => $this->biz_model->type_ary($order['biz_type']),
'vin' => $item['vin'],
'sale_price' => $val['sale_price'],
'buy_price' => $val['buy_price'],
'brand_name' => $brand_name,
'series_name' => "{$series_name} {$v_name}",
'ori_price' => $srv_json['ori_price'],
'owner_name' => $order['owner_name']."({$order['owner_mobile']})",
'admin_name' => $order['admin_name'],
'biz_name' => $order['biz_name'],
'bill_time' => date('Y-m-d',strtotime($val['bill_time'])),
'bill_price' => $val['bill_price'],
'bill_price_diff' => $val['price'] - $val['bill_price'],
'price' => $val['price'],
'price_fine_select' => $srv_json['price_fine_select'],
'sale_price' => $val['sale_price'], // $val['price'] + $srv_json['price_fine_select']
'order_time' => date('Y-m-d',$order['c_time']),
'price_floor' => $srv_json['price_floor'],
'profix_car_1' => $order['biz_type'] == 1 ? $srv_json['profix_car'] : 0,
'profix_car_1_not' => $order['biz_type'] != 1 ? $srv_json['profix_car'] : 0,
'company_name' => $item['cpmpany_name'],
'buy_price' => $item['buy_price'],
'select_price' => $cost_json['select_price'],
'labor_price' => $cost_json['labor_price'],
'buy_price_total' => $val['buy_price'],
'promotion_sale_price' => $promotion_json['sale_price'],
'promotion_other' => $promotion_json['other'],
'promotion_price' => $val['promotion_price'],
'factory_price' => $promotion_json['factory_price'],
'car_buy_price' => $val['car_buy_price'],
'car_profit_price' => $val['car_profit_price'],
'insurance_price' => $val['insurance_price'],
'fee_carno_price' => $val['fee_carno_price'],
'loan_price' => $val['loan_price'],
"business_product" => $srv_json['business_product'],
"business_price" => $srv_json['business_price'],
"business_fd" => $srv_json['business_fd'],
"business_ins_price" => $srv_json['business_ins_price'],
"insurance_price" => $srv_json['insurance_price'],
"insurance_fd" => $srv_json['insurance_fd'],
"insurance_ins_price" => $srv_json['insurance_ins_price'],
"back_price" => $srv_json['back_price'],
"insurance_price_pure" => $val['insurance_price'],
'fee_carno' => $srv_json['fee_carno'],
'cb_fee_carno' => $srv_json['cb_fee_carno'],
"fee_carno_price" => $val['fee_carno_price'],
'payway_name' => $order['payway_name'],
'loan_product' => $srv_json['loan_product'],
'loan_price' => $srv_json['loan_price'],
'loan_num' => $srv_json['loan_num'],
'loan_srv_price' => $srv_json['loan_srv_price'],
'loan_offset_price' => $srv_json['loan_offset_price'],
'loan_subsidy_price' => $srv_json['loan_subsidy_price'],
'commission_price' => $srv_json['commission_price'],
'loan_in_price' => $srv_json['loan_in_price'],
'loan_out_price' => $srv_json['loan_out_price'],
'loan_price_pure' => $val['loan_price'],
'other_in_price' => $srv_json['other_in_price'],
'other_out_price' => $srv_json['other_out_price'],
'other_price' => $srv_json['other_in_price'] - $srv_json['other_out_price'],
'srv_price' => $val['srv_price'],
'car_price' => $val['car_price'],
'dl_car_price' => $val['dl_car_price'],
'brand_car_price' => $val['brand_car_price'],
'need_price' => $need_price,
'pay_price' => $pay_price,
'if_pay' => $srv_json['if_pay'] == 1 ? '是' : '',
];
}
}
$headers = [
'owner_name' => array('title'=>'销售信息', 'column_num'=>10), // 从该indexs.key开始合并第一行的单元格数及显示标题
'price_floor' => array('title'=>'销售政策', 'column_num'=>3),
'company_name' => array('title'=>'采购成本', 'column_num'=>5),
'promotion_sale_price' => array('title'=>'促销成本', 'column_num'=>3),
'business_product' => array('title'=>'保险收入', 'column_num'=>9),
'fee_carno' => array('title'=>'挂牌收入', 'column_num'=>3),
'loan_product' => array('title'=>'分期付款业务', 'column_num'=>10),
'other_in_price' => array('title'=>'其他收入及成本', 'column_num'=>3),
'need_price' => array('title'=>'收款核对', 'column_num'=>3),
];
$indexs = [
'title' => '车辆',
'id' => '序号',
'bill_name' => '开票方',
//'biz_type' => 'biz_type',
'biz_type_name' => '门店类型',
'vin' => '车架号',
'brand_name' => '品牌',
'series_name' => '车型',
'ori_price' => '指导价',
'owner_name' => '车主', // 客户名称
'admin_name' => '销售顾问',
'biz_name' => '门店名称', // 销售归属地
'bill_time' => '开票日期',
'bill_price' => '开票价', // 开票金额
'bill_price_diff' => '实际售价与开票差额',
'price' => '实际售价',
'price_fine_select' => '选装实收',
'sale_price' => '销售收入合计',
'buy_price' => '采购及加装成本合计',
"promotion_price" => "促销成本合计",
'order_time' => '订单日期',
'price_floor' => '商务政策低价', // 商务政策销售价
'profix_car_1' => '直营店分润',
'profix_car_1_not' => '渠道分润',
'company_name' => '车辆归属', // 进货地(车辆归属)
'buy_price' => '采购成本',
'select_price' => '选装成本', // 选装单金额
'labor_price' => '选装工时费',
'buy_price_total' => '采购及加装成本合计',
'promotion_sale_price' => '销售佣金',
'promotion_other' => '其他',
'promotion_price' => '促销成本合计',
'factory_price' => '厂家补贴',
"car_buy_price" => "整车采购成本",
"car_profit_price" => "整车采购毛利",
"insurance_price" => "保险收入合计",
"business_product" => "保险公司",
"business_price" => "商业险金额",
"business_fd" => "商业险返点",
"business_ins_price" => "商业险佣金",
"insurance_price" => "交强险金额",
"insurance_fd" => "交强险返点",
"insurance_ins_price" => "交强险佣金",
"back_price" => "客户退点金额", // 退客户保险退点
"insurance_price_pure" => "保险收入合计", // 保险净收入
'fee_carno' => '挂牌收入',
'cb_fee_carno' => '挂牌成本',
"fee_carno_price" => "挂牌收入合计",
"loan_price" => "按揭收入合计",
"srv_price" => "水平业务总毛利 ",
"car_price" => "单车总毛利",
'payway_name' => '购车方式',
'loan_product' => '按揭银行',
'loan_price' => '按揭金额',
'loan_num' => '期数',
'loan_srv_price' => '按揭服务费',
'loan_offset_price' => '解抵服务费',
'loan_subsidy_price' => '利息补贴收入',
'commission_price' => '按揭手续费收入',
'loan_in_price' => '其他收入金额',
'loan_out_price' => '其他支出金额',
'loan_price_pure' => '按揭收入合计',
'other_in_price' => '其他收入',
'other_out_price' => '其他支出',
'other_price' => '其他合计',
'srv_price' => '水平业务总毛利',
'car_price' => '单车总毛利',
'dl_car_price' => '门店单车毛利',
'brand_car_price' => '品牌单车总毛利',
'need_price' => '应收款金额',
'pay_price' => '已收款金额',
'if_pay' => '是否齐款',
];
array_unshift($data, $indexs);
$this->load->library('excel');
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
#$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
$sheet_title = $fileName;
$filename = $fileName.'_' . date('YmdHis');
$this->excel->excel2($data, $indexs, $headers, $sheet_title, $filename);
}
// export old
public function export_(){
$params = $this->input->get();
$params['page'] = 1;
+34 -22
View File
@@ -70,7 +70,7 @@
<!-- 销售信息 -->
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">销售信息(销售收入合计:{{info.row.sale_price}})</span>
<span style="font-size: 20px" title="【销售收入合计】(实际售价+选装实收)">销售信息(销售收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a>:{{info.row.sale_price}})</span>
<span style="float:right;margin-top:5px">
</span>
</div>
@@ -176,7 +176,7 @@
</div>
<div class="am-panel am-panel-default">
<div class="am-panel-hd">
<span style="font-size: 20px">采购成本(采购及加装成本合计:{{info.row.buy_price}})</span>
<span style="font-size: 20px" title="【采购及加装成本合计】(采购成本 + 选装成本 + 选装工时费)">采购成本(采购及加装成本合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a>:{{info.row.buy_price}})</span>
<span style="float:right;margin-top:5px">
</span>
</div>
@@ -185,7 +185,8 @@
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">采购成本:</span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.buy_price}}</label>
<!-- <label class="am-para-label-con">{{info.buy_price}}</label>-->
<input type="number" v-model="info.buy_price" style="width: 150px;">
</div>
</div>
<div class="am-form-group am-u-lg-4">
@@ -240,19 +241,19 @@
</div>
<div class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">促销成本合计</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【促销成本合计】(销售佣金+其他)">促销成本合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.promotion_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">整车采购成本</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【整车采购成本】(采购成本-厂家补贴)">整车采购成本<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.car_buy_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">整车采购毛利</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【整车采购毛利】(销售收入合计(实际售价+选装实收) - 整车采购成本 - 促销成本合计 - 选装金额 -选装工时费">整车采购毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.car_profit_price}}</label>
</div>
@@ -324,7 +325,7 @@
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">保险收入合计</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【保险收入合计】(商业险佣金+交强险佣金-客户退点金额">保险收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.insurance_price}}</label>
</div>
@@ -347,14 +348,14 @@
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">挂牌收入合计</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【挂牌收入合计】(挂牌收入-挂牌成本)">挂牌收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.fee_carno_price}}</label>
</div>
</div>
</div>
<hr class="am-u-lg-12 wp90" style="margin: 10px">
<div class="am-form-inline">
<hr v-if="info.payway=='1'" class="am-u-lg-12 wp90" style="margin: 10px">
<div v-if="info.payway=='1'" class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭银行:</span></label>
<div class="am-para-input">
@@ -412,8 +413,6 @@
<div class="am-para-input">
</div>
</div>
</div>
<div class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭手续费收入:</span></label>
<div class="am-para-input">
@@ -421,7 +420,7 @@
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">按揭收入合计</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【按揭收入合计】(按揭服务费+解抵服务费+利息补贴收入+按揭手续费收入+其他收入金额-其他支出金额)">按揭收入合计<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.loan_price}}</label>
</div>
@@ -464,29 +463,41 @@
<div class="am-panel-bd am-g" style="margin-top: 10px;margin-bottom: 10px;">
<div class="am-form-inline">
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">整车采购成本</span></label>
<label class="am-para-label label-width" title="【整车采购成本】(采购成本-厂家补贴)"><span class="span-bold">整车采购成本<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.car_buy_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">整车采购毛利</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【整车采购毛利】(销售收入合计(实际售价+选装实收) - 整车采购成本 - 促销成本合计 - 选装金额 -选装工时费">整车采购毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.car_profit_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold">水平业务总毛利</span></label>
<label class="am-para-label label-width"><span class="span-bold" title="【水平业务总毛利】(保险收入合计+挂牌收入合计+按揭收入合计+其他收入-其他支出">水平业务总毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.srv_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-12">
<label class="am-para-label label-width"><span class="span-bold">单车总毛利</span></label>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold" title="【单车总毛利】(整车采购毛利+水平业务总毛利)">单车总毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.car_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold" title="【门店采购毛利】(根据门店类型取, 商务政策分润 - 选装金额 - 选装工时费 - 促销成本 + 水平业务总毛利 + (实际售价入 - 商务政策底价))">门店单车毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.dl_car_price}}</label>
</div>
</div>
<div class="am-form-group am-u-lg-4">
<label class="am-para-label label-width"><span class="span-bold" title="【品牌单车总毛利】(单车总毛利 - 直营店单车毛利/代理店单车毛利/合伙店采购毛利)">品牌单车总毛利<a href="javascript:void(0)" class="fa fa-info-circle ml5"></a></span></label>
<div class="am-para-input">
<label class="am-para-label-con">{{info.row.brand_car_price}}</label>
</div>
</div>
</div>
</div>
</div>
@@ -590,10 +601,11 @@
var vm = this;
var post_data = {};
post_data['id'] = vm.info.row.id;
post_data['promotion_json'] = vm.info.promotion_json
post_data['cost_json'] = vm.info.cost_json
post_data['srv_json'] = vm.info.srv_json
post_data['price'] = vm.info.price
post_data['promotion_json'] = vm.info.promotion_json;
post_data['cost_json'] = vm.info.cost_json;
post_data['srv_json'] = vm.info.srv_json;
post_data['price'] = vm.info.price;
post_data['buy_price'] = vm.info.buy_price;
$.ajax({
url: '/items/cost/edit',
type: 'post',
+247 -1
View File
@@ -51,6 +51,53 @@
<input type="text" name="vin" placeholder="车架号关键字" v-model="params.vin"/>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label w100">开票时间:</label>
<div class="am-form-group fl">
<div class="am-para-inline w300">
<input id="id-bill-time" name="bill_time" type="text" value="<?= $params['bill_time'] ?>"
placeholder="开票时间范围" autocomplete="off"/>
</div>
<div class="am-para-inline" style="padding-top: 5px;">
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today" data-btn="bill">今天</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday" data-btn="bill">昨日</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks" data-btn="bill">本周</a>
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month" data-btn="bill">本月</a>
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl">
<label class="am-para-label w100">归属门店:</label>
<div class="am-para-inline w120">
<select title="城市" name="city_id_admin" v-model="params.city_id_admin">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in admins.cityAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select title="行政区" name="county_id_admin" v-model="params.county_id_admin">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in admins.countyAry">{{v.name}}</option>
</select>
</div>
<div class="am-para-inline w120">
<select name="biz_id_admin" v-model="params.biz_id_admin">
<option value="">门店</option>
<template v-for="(v,i) in admins.bizAry">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
<div class="am-para-inline w120" style="display: none">
<select name="admin_id" v-model="params.admin_id">
<option value="">销售员</option>
<template v-for="(v,i) in admins.list">
<option :value="v.id">{{v.title}}</option>
</template>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl ml50">
<div class="am-form-group fl ml10">
@@ -67,6 +114,7 @@
<table class="am-table am-table-bordered">
<thead>
<tr>
<th>门店</th>
<th width="15%">车辆</th>
<th>销售收入合计</th>
<th>采购及加装成本合计</th>
@@ -78,11 +126,15 @@
<th>按揭收入合计</th>
<th>水平业务总毛利</th>
<th>单车总毛利</th>
<th>门店单车毛利</th>
<th>品牌单车总毛利</th>
<th>齐款</th>
</tr>
</thead>
<tbody>
<template v-for="(v,i) in lists">
<tr>
<td>{{v.biz_name}}</td>
<td>
<a href="javascript:void(0);" :data-open="'/items/cost/get?id='+v.id">
{{v.vin}}<br>{{v.title}}
@@ -98,6 +150,12 @@
<td>{{v.loan_price}}</td>
<td>{{v.srv_price}}</td>
<td>{{v.car_price}}</td>
<td>{{v.dl_car_price}}</td>
<td>{{v.brand_car_price}}</td>
<td>
<input v-if="v.if_pay == '1'" id="if_pay" type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" :data-id="v.id" checked onchange="edit_pay(this)"/>
<input v-if="v.if_pay != '1'" id="if_pay" type="checkbox" class="mui-switch mui-switch-anim va-mid" true-value="1" false-value="0" :data-id="v.id" onchange="edit_pay(this)"/>
</td>
</tr>
</template>
</tbody>
@@ -109,7 +167,74 @@
</div>
</div>
</div>
<script>
function edit_pay(obj){
// alert($(obj).get(0).dataset.id);
// alert($(obj).get(0).getAttribute('data-id'));
id = $(obj).get(0).dataset.id;
var value = '';
if($(obj).get(0).checked) {
value = 1;
}else{
value = 0;
}
var data = {'id':id,'status':value};
$.post('/items/cost/edit_pay',data,function(result){
if(result.code){
layer.msg(result.msg, {time: 2000,icon:1 }, function () {
$.form.reload();
});
}else{
layer.msg(result.msg,{icon:2});
}
},'json')
}
</script>
<script>
require(['laydate', 'autocomplete'], function (laydate) {
laydate.render({
elem: '#order-time', range: '~'
});
laydate.render({
elem: '#id-bill-time', range: '~'
});
$('.id-day-btn').click(function () {
var type = $(this).data('date'), date = '', nowDate = new Date();
var beginDate = '', endDate = '';
switch (type) {
case 'today':
endDate = beginDate = nowDate.Format('yyyy-MM-dd');
break;
case 'yesterday':
endDate = beginDate = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
break;
case 'weeks':
nowDate.setDate(nowDate.getDate() - nowDate.getDay() + 1);
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
nowDate.setDate(nowDate.getDate() + 6);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
break;
case 'month':
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-01";
var day = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, 0);
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + day.getDate();
break;
}
date = beginDate + ' ~ ' + endDate;
// $('#id-create-time').val(date);
switch ($(this).data('btn')) {
case 'bill':
$('#id-bill-time').val(date);
break;
case 'order':
$('#order-time').val(date);
break;
}
});
});
$(function () {
vue_obj = new Vue({
@@ -117,12 +242,15 @@
data: {
params: [],
lists: [],
modal_fine: {title: '', lists: [], selected: [], page: 1, size: 10, total: 0}
// modal_fine: {title: '', lists: [], selected: [], page: 1, size: 10, total: 0},
admins: {cityAry: [], countyAry: [], bizAry: [], list: []},
},
mounted: function () {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.lists = <?=json_encode($lists)?>;
vm.set_sery();
vm.init_citys();
},
methods: {
set_sery: function () {
@@ -149,8 +277,126 @@
vm.params.cor_id = '';
}
},
init_citys: function () {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
vm.admins.cityAry = JSON.parse(JSON.stringify(response.data));
}
}
});
},
reset: function () {
var that = this;
$("#vin").val('');
$("#id-bill-time").val('');
that.params.brand_id = '';
that.params.city_id_admin = '';
}
},
watch: {
'params.city_id_admin': function (nv, ov) {
var that = this;
if (nv == '') {
that.admins.countyAry = [];
that.params.county_id_admin = '';
} else {
if (nv.substring(0, 4) != that.params.county_id_admin.substring(0, 4)) {
that.params.county_id_admin = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key: 'county',
type: 1
},
success: function (response) {
if (response.code == 1) {
that.admins.countyAry = response.data;
}
}
});
}
},
'params.county_id_admin': function (nv, ov) {
var that = this;
if (nv == '') {
that.admins.bizAry = [];
that.params.biz_id_admin = '';
} else {
$.ajax({
type: 'post',
url: '/biz/store/store/json_lists',
dataType: 'json',
data: {
city_id: that.params.city_id_admin,
county_id: that.params.county_id_admin,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.admins.bizAry = response.data.list;
if (that.params.biz_id_admin > 0) {
var biz_id = '';
for (var i in that.admins.bizAry) {
if (that.params.biz_id_admin == that.admins.bizAry[i].id) {
biz_id = that.params.biz_id_admin;
break;
}
}
that.params.biz_id_admin = biz_id;
}
}
}
});
}
},
// 不虚线显示销售 biz_id_admin -> biz_id_admin_ 禁用
'params.biz_id_admin_': function (nv, ov) {
var that = this;
if (nv == '') {
that.admins.list = [];
that.params.admin_id = '';
} else {
$.ajax({
type: 'post',
url: '/app/licheb/member/json_lists',
dataType: 'json',
data: {
biz_id: nv,
status: 1
},
success: function (response) {
if (response.code == 1) {
that.admins.list = response.data.list;
if (that.params.admin_id > 0) {
var admin_id = '';
for (var i in that.admins.list) {
if (that.params.admin_id == that.admins.list[i].id) {
admin_id = that.params.admin_id;
break;
}
}
that.params.admin_id = admin_id;
}
}
}
});
}
}
}
});
+92
View File
@@ -240,4 +240,96 @@ class Excel extends PHPExcel
return fclose($fp);
}
/**
* 导出excel,第一行支持多列表头合并
* @param $data
* @param $indexs
* @param $headers
* @param $sheet_title
* @param $filename
* @return bool
*/
public function excel2($data, $indexs, $headers=array(), $sheet_title='sheet1', $filename=''){
!$sheet_title && $sheet_title = 'sheet1';
!$filename && $filename = 'excel_' . date('YmdHis');
set_time_limit(0); // 设置页面等待时间
ini_set('memory_limit', -1); // 不限制内存
$objPHPExcel = new PHPExcel();
$objPHPExcel->getDefaultStyle()->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT); // 单元格整体居右
$objPHPExcel->setActiveSheetIndex(0); // 选中默认的第一个sheet
$objPHPExcel->getActiveSheet()->setTitle($sheet_title); // 给 Sheet 设置名字
# 先生成表头
$i = 0;
$column_num = 0;
foreach ($indexs as $k => $v){
$columnkey = PHPExcel_Cell::stringFromColumnIndex($i);
if ($column_num || in_array($k, array_keys($headers))){
if (in_array($k, array_keys($headers)) && !$headers[$k]['is_create']){
$column_num = $headers[$k]['column_num'];
$title = $headers[$k]['title'];
$headers[$k]['is_create'] = 1;
# 第一行需合并多列的列
$columnkey2 = PHPExcel_Cell::stringFromColumnIndex($i + $column_num - 1);
$pRange = $columnkey.'1:'.$columnkey2.'1';
$pCoordinate = $columnkey.'1';
$objPHPExcel->getActiveSheet()->mergeCells($pRange);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $title);
# 水平居中
$objStyle = $objPHPExcel->getActiveSheet()->getStyle($pCoordinate); //获取要设置单元格的样式,括号里的内容也可是:('A1:E1')
$objAlign = $objStyle->getAlignment(); //用来设置对齐属性和单元格内文本换行的一个变量
$objAlign->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
# 第二行的列
$pCoordinate = $columnkey.'2';
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $v);
$column_num--;
}
else{
# 第一二行需合并的列
$pRange = $columnkey.'1:'.$columnkey.'2';
$pCoordinate = $columnkey.'1';
$objPHPExcel->getActiveSheet()->mergeCells($pRange);
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($pCoordinate, $v);
# 垂直居中
$objStyle = $objPHPExcel->getActiveSheet()->getStyle($pCoordinate);
$objAlign = $objStyle->getAlignment();
$objAlign->setVertical(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
}
$i++;
}
# 再生成数据
$data = array_slice($data, 1);
$j = 3;
foreach ($data as $val) {
$i = 0;
// 内循环产生每一行
foreach ($indexs as $k => $v){
// 数字列转换为字母列 如:27变为AA
$objPHPExcel->getActiveSheet()->setCellValue(PHPExcel_Cell::stringFromColumnIndex($i) . $j, $val[$k]);
$i++;
}
$j++;
}
$filename = iconv('UTF-8', 'UTF-8', $filename) . '.xls';
header('Pragma: public');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Type: application/force-download');
header('Content-Type: application/vnd.ms-execl');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header("Content-Disposition: attachment; filename=$filename");
header('Content-Transfer-Encoding: binary');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
return $objWriter->save('php://output');
}
}