From a5d8e735f14502a2c8328f49e592f2a40a842a99 Mon Sep 17 00:00:00 2001 From: dengbw Date: Tue, 31 May 2022 16:16:06 +0800 Subject: [PATCH] attr_531 --- admin/controllers/Common.php | 6 +- admin/controllers/auto/Attr.php | 100 ++++++++++++--------- admin/views/auto/attr/lists.php | 43 +++++---- api/controllers/wxapp/licheb/Customers.php | 17 ++-- 4 files changed, 98 insertions(+), 68 deletions(-) diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index c870aa39..76cc6188 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -1463,12 +1463,12 @@ class Common extends CI_Controller $res = $this->mdAutoSeries->select(array('status' => 1, 'brand_id' => $pid), 'id desc', 0, 0, 'id,name'); } else if ($type == 3) { $tp == 0 && $lists[] = array('id' => 0, 'name' => $name ? $name : '选择车型'); - $res = $this->mdAutoAttr->select(array('type' => 1, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name'); + $res = $this->mdAutoAttr->select(array('status>' => -1, 'type' => 1, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name'); } if ($tp == 1 && $type == 3) { $lists[3] = $res;//车型 - $lists[4] = $this->mdAutoAttr->select(array('type' => 0, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//车身颜色 - $lists[5] = $this->mdAutoAttr->select(array('type' => 2, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//内饰颜色 + $lists[4] = $this->mdAutoAttr->select(array('status>' => -1, 'type' => 0, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//车身颜色 + $lists[5] = $this->mdAutoAttr->select(array('status>' => -1, 'type' => 2, 's_id' => $pid), 'id desc', 0, 0, 'id,title as name');//内饰颜色 } else { foreach ($res as $key => $value) { $lists[] = array('id' => $value['id'], 'name' => $value['name']); diff --git a/admin/controllers/auto/Attr.php b/admin/controllers/auto/Attr.php index c00a2387..46bacf53 100644 --- a/admin/controllers/auto/Attr.php +++ b/admin/controllers/auto/Attr.php @@ -7,20 +7,24 @@ */ defined('BASEPATH') OR exit('No direct script access allowed'); -class Attr extends HD_Controller{ +class Attr extends HD_Controller +{ - public function __construct(){ + public function __construct() + { parent::__construct(); $this->load->model('auto/auto_brand_model'); $this->load->model('auto/auto_series_model'); $this->load->model('auto/auto_attr_model'); } - public function index(){ + public function index() + { $this->lists(); } - public function lists(){ + public function lists() + { $params = $this->input->get(); $page = $this->input->get('page'); !$page && $page = 1; @@ -28,12 +32,13 @@ class Attr extends HD_Controller{ $where["status > -1"] = null; $params['title'] && $where["title like '%{$params['title']}%'"] = null; - if($params['s_id']){ + if ($params['s_id']) { $where['s_id'] = $params['s_id']; - }if($params['brand_id']){ + } + if ($params['brand_id']) { $where_sery = array('status > -1' => null, 'brand_id' => $params['brand_id']); $rows_sery = $this->auto_series_model->select($where_sery, 'id desc', 0, 0, 'id'); - if($rows_sery){ + if ($rows_sery) { $sery_ids = array_column($rows_sery, 'id'); $str_ids = implode(',', $sery_ids); $where["s_id in ({$str_ids})"] = null; @@ -51,20 +56,21 @@ class Attr extends HD_Controller{ //获取品牌map $where_brand = array('status > -1' => null); - $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name'); + $map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0, 0, 'id, name'); $list = []; - if($rows){ - $series_arr = array_column($rows,'s_id'); - $series_rows = $this->auto_series_model->get_map_by_ids($series_arr,'id,name'); - foreach($rows as $key=>$val){ + if ($rows) { + $series_arr = array_column($rows, 's_id'); + $series_rows = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name'); + foreach ($rows as $key => $val) { $list[] = [ 'id' => $val['id'], 'title' => $val['title'], 's_name' => $series_rows[$val['s_id']] ? $series_rows[$val['s_id']][0]['name'] : '', 'status_name' => $status_arr[$val['status']], + 'status' => $val['status'], 'type_cn' => $type_arr[$val['type']], - 'c_time' => date('Y-m-d H:i:s',$val['c_time']) + 'c_time' => date('Y-m-d H:i:s', $val['c_time']) ]; } } @@ -76,7 +82,8 @@ class Attr extends HD_Controller{ $this->show_view('auto/attr/lists', true); } - public function get(){ + public function get() + { $id = $this->input->get('id'); $info = [ @@ -87,11 +94,11 @@ class Attr extends HD_Controller{ if (!$info || empty($info)) { return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } - $info['jsondata'] = json_decode($info['jsondata'],true); + $info['jsondata'] = json_decode($info['jsondata'], true); $info['jsondata']['img'] && $info['jsondata']['s_img'] = build_qiniu_image_url($info['jsondata']['img']); } - $brand_id= ''; - if($info['s_id']){ + $brand_id = ''; + if ($info['s_id']) { $row_sery = $this->auto_series_model->get(array('id' => $info['s_id'])); $brand_id = $row_sery['brand_id']; } @@ -103,10 +110,11 @@ class Attr extends HD_Controller{ $this->data['type_arr'] = $type_arr; $this->data['info'] = $info; $this->data['_title'] = $id ? '编辑' : '新增'; - return $this->show_view('auto/attr/edit',true); + return $this->show_view('auto/attr/edit', true); } - public function add(){ + public function add() + { if (!$this->if_ajax) { return $this->show_json(SYS_CODE_FAIL, '提交出错!'); } @@ -120,7 +128,7 @@ class Attr extends HD_Controller{ 'type' => $post['type'], 'c_time' => time() ]; - $post['jsondata'] && $add_data['jsondata'] = json_encode($post['jsondata'],JSON_UNESCAPED_UNICODE); + $post['jsondata'] && $add_data['jsondata'] = json_encode($post['jsondata'], JSON_UNESCAPED_UNICODE); $result = $this->auto_attr_model->add($add_data); if (!$result) { return $this->show_json(SYS_CODE_FAIL, '添加失败'); @@ -128,13 +136,14 @@ class Attr extends HD_Controller{ return $this->show_json(SYS_CODE_SUCCESS, '添加成功'); } - public function edit(){ + public function edit() + { if (!$this->if_ajax) { return $this->show_json(SYS_CODE_FAIL, '提交出错!'); } $post = $this->input->post(); - $row = $this->auto_attr_model->get(['id'=>$post['id']]); - if(!$row){ + $row = $this->auto_attr_model->get(['id' => $post['id']]); + if (!$row) { return $this->show_json(SYS_CODE_FAIL, '数据不存在'); } if (!$post['title']) { @@ -145,22 +154,33 @@ class Attr extends HD_Controller{ 's_id' => $post['s_id'], 'type' => $post['type'], ]; - $post['jsondata'] && $update['jsondata'] = json_encode($post['jsondata'],JSON_UNESCAPED_UNICODE); - $result = $this->auto_attr_model->update($update,['id'=>$row['id']]); + $post['jsondata'] && $update['jsondata'] = json_encode($post['jsondata'], JSON_UNESCAPED_UNICODE); + $result = $this->auto_attr_model->update($update, ['id' => $row['id']]); if (!$result) { return $this->show_json(SYS_CODE_FAIL, '保存失败'); } return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } - public function del(){ + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $stauts = $this->input->post('status'); + $where = ['id' => $id]; + $this->auto_attr_model->update(['status' => $stauts], $where); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); } - public function batch(){ + public function batch() + { } - public function export(){ + public function export() + { } @@ -168,39 +188,35 @@ class Attr extends HD_Controller{ * 属性选项列表 * @return bool */ - function json_lists(){ + function json_lists() + { $s_id = $this->input->get_post('s_id'); $status = $this->input->get_post('status'); $type = $this->input->get_post('type'); $page = $this->input->get_post('page'); $size = $this->input->get_post('size'); - $where = array(); $s_id && $where['s_id'] = $s_id; strlen($type) > 0 && $where['type'] = $type; - if(strlen($status) > 0){ - $where['status'] = $status; - } else { - $where['status>-1'] = null; - } - +// if (strlen($status) > 0) { +// $where['status'] = $status; +// } else { +// $where['status>-1'] = null; +// } + $where['status>-1'] = null; $total = $this->auto_attr_model->count($where); - - $lists = array(); - if($total){ + if ($total) { $orderby = 'id desc'; $select = 'id, title'; $rows = $this->auto_attr_model->select($where, $orderby, $page, $size, $select); - - foreach($rows as $v){ + foreach ($rows as $v) { $lists[] = array( 'id' => $v['id'], 'title' => $v['title'], ); } } - $this->data = array('total' => $total, 'list' => $lists); return $this->show_json(SYS_CODE_SUCCESS); } diff --git a/admin/views/auto/attr/lists.php b/admin/views/auto/attr/lists.php index bd5486a1..fe452af4 100755 --- a/admin/views/auto/attr/lists.php +++ b/admin/views/auto/attr/lists.php @@ -4,7 +4,7 @@
- +
@@ -29,7 +29,9 @@
- +
共有条数据 @@ -60,7 +62,15 @@ + class="am-text-primary"> | + + 禁用 + + 恢复 + @@ -76,41 +86,42 @@