attr_531
This commit is contained in:
@@ -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']);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">标题:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="title" value="<?=$params['title'] ?>"/>
|
||||
<input type="text" name="title" value="<?= $params['title'] ?>"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
@@ -29,7 +29,9 @@
|
||||
<button type="submit" class="am-btn am-btn-success w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" data-title="新增车系" data-open="/auto/attr/get" class="am-btn am-btn-success w100">新增</button>
|
||||
<button type="button" data-title="新增车系" data-open="/auto/attr/get" class="am-btn am-btn-success w100">
|
||||
新增
|
||||
</button>
|
||||
</div>
|
||||
<div class="am-form-group fr" style="font-size: 15px;padding-right: 20px;padding-top: 6px;">
|
||||
共有<?= $pager['totle'] ?>条数据
|
||||
@@ -60,7 +62,15 @@
|
||||
<td><?= $v['c_time'] ?></td>
|
||||
<td>
|
||||
<a href="javascript:void (0);" data-title="编辑车系" data-open="/auto/attr/get?id=<?= $v['id'] ?>"
|
||||
class="am-text-primary"><?= '编辑' ?></a>
|
||||
class="am-text-primary"><?= '编辑' ?></a> |
|
||||
<?php if ($v['status'] == 1) { ?>
|
||||
<a href="javascript:void (0);" data-ajax="post" data-action="/auto/attr/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="0">禁用</a>
|
||||
<?php } else { ?>
|
||||
<a style="color: red" href="javascript:void (0);" data-ajax="post"
|
||||
data-action="/auto/attr/del"
|
||||
data-params-id="<?= $v['id'] ?>" data-params-status="1">恢复</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
@@ -76,41 +86,42 @@
|
||||
<script>
|
||||
var vue_obj;
|
||||
var loading = 0;
|
||||
$(function(){
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params:[],
|
||||
brandAry:[],
|
||||
seryAry:[]
|
||||
params: [],
|
||||
brandAry: [],
|
||||
seryAry: []
|
||||
},
|
||||
mounted:function() {
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.brandAry = <?=json_encode($brandAry)?>;
|
||||
},
|
||||
methods:{},
|
||||
watch:{
|
||||
'params.brand_id':function(nv, ov){
|
||||
methods: {},
|
||||
watch: {
|
||||
'params.brand_id': function (nv, ov) {
|
||||
var vm = this;
|
||||
vm.seryAry = {};
|
||||
if(nv > 0){
|
||||
if (nv > 0) {
|
||||
$.ajax({
|
||||
url: '/auto/series/json_lists',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {brand_id:nv},
|
||||
beforeSend: function () {},
|
||||
data: {brand_id: nv},
|
||||
beforeSend: function () {
|
||||
},
|
||||
success: function (data) {
|
||||
if (1 == data.code) {
|
||||
var lists = data.data.list;
|
||||
var seryAry = {};
|
||||
for (var i in lists){
|
||||
for (var i in lists) {
|
||||
var row = lists[i];
|
||||
seryAry[row.id] = row.name;
|
||||
}
|
||||
vm.seryAry = seryAry;
|
||||
if(vm.params.s_id>0 && undefined == seryAry[vm.params.s_id]){
|
||||
if (vm.params.s_id > 0 && undefined == seryAry[vm.params.s_id]) {
|
||||
vm.params.s_id = '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,6 @@ class Customers extends Wxapp
|
||||
$tags = [$row['level'] . '级用户'];
|
||||
$status_name = $this->customers_model->get_status();
|
||||
$tip = $status_name[$row['status']] ? $status_name[$row['status']] : '';
|
||||
|
||||
$other_data = [
|
||||
'客户等级' => $row['level'],
|
||||
'客户来源' => $this->get_cfTitle($row),
|
||||
@@ -338,20 +337,24 @@ class Customers extends Wxapp
|
||||
$visit_time = $this->input_param('visit_time');//计划回访时间
|
||||
$row = $this->customers_model->get(['id' => $id]);
|
||||
if (!$row) {
|
||||
throw new Exception('数据不存在', ERR_PARAMS_ERROR);
|
||||
throw new Exception('数据不存在!', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$check_admin_id = true;//检查销售
|
||||
if ($this->session['group_id'] == 2 || $this->session['group_id'] == 3) {//店长、老板可以操作其他人的客户
|
||||
$check_admin_id = false;
|
||||
}
|
||||
if ($check_admin_id && $row['admin_id'] != $uid) {
|
||||
throw new Exception('无权限操作该客户!', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$up_data = [];
|
||||
//变成到店
|
||||
if (!$row['admin_id'] && $status == 1) {
|
||||
$up_data['admin_id'] = $uid;
|
||||
}
|
||||
if ($row['admin_id'] != $uid) {
|
||||
throw new Exception('无法操作该客户', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$log_0 = $log_4 = $log_9 = '';
|
||||
if ($status == 3) {
|
||||
if (!$defeat_reason) {
|
||||
throw new Exception('请输入战败理由', ERR_PARAMS_ERROR);
|
||||
throw new Exception('请输入战败理由!', ERR_PARAMS_ERROR);
|
||||
}
|
||||
$jsondata = $row['jsondata'] ? json_decode($row['jsondata'], true) : array();
|
||||
$jsondata['defeat']['time'] = date("Y-m-d H:i:s");
|
||||
@@ -437,7 +440,7 @@ class Customers extends Wxapp
|
||||
if ($result) {
|
||||
throw new Exception('操作成功', API_CODE_SUCCESS);
|
||||
} else {
|
||||
throw new Exception('操失败', ERR_PARAMS_ERROR);
|
||||
throw new Exception('操失败!', ERR_PARAMS_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user