liche update for admin auto cars manage
This commit is contained in:
@@ -0,0 +1,300 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/8/6
|
||||
* Time: 11:15
|
||||
*/
|
||||
class Cars extends HD_Controller{
|
||||
|
||||
protected $log_dir;
|
||||
|
||||
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');
|
||||
$this->load->model('auto/auto_cars_model');
|
||||
|
||||
$this->log_dir = "auto_" . get_class($this);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return $this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
|
||||
$where = array();
|
||||
if($params['brand_id']){
|
||||
$where['brand_id'] = $params['brand_id'];
|
||||
} else{
|
||||
$params['brand_id'] = '';
|
||||
}
|
||||
|
||||
if($params['s_id']){
|
||||
$where['s_id'] = $params['s_id'];
|
||||
} else{
|
||||
$params['s_id'] = '';
|
||||
}
|
||||
if(strlen($params['status']) > 0){
|
||||
$where['status'] = $params['status'];
|
||||
} else {
|
||||
$params['status'] = '';
|
||||
}
|
||||
|
||||
$page = $params['page'];
|
||||
$page = !$page ? 1 : $page;
|
||||
$size = $params['size'];
|
||||
$size = !$size ? 20 : $size;
|
||||
|
||||
//获取品牌map
|
||||
$where_brand = array('status > -1' => null);
|
||||
$map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name');
|
||||
//状态
|
||||
$statusAry = array('0' => '关闭', '1' => '开启');
|
||||
|
||||
$total = $this->auto_cars_model->count($where);
|
||||
$lists = array();
|
||||
if($total){
|
||||
$orderby = 'id desc';
|
||||
$select = 'id,brand_id,s_id,attrs,status';
|
||||
$rows = $this->auto_cars_model->select($where, $orderby, $page, $size, $select);
|
||||
if($rows){
|
||||
$s_ids = array();
|
||||
$attr_ids = array();
|
||||
foreach($rows as $v){
|
||||
!in_array($v['s_id'], $s_ids) && $s_ids[] = $v['s_id'];
|
||||
$ids = explode('_', $v['attrs']);
|
||||
$attr_ids = array_merge($attr_ids, $ids);
|
||||
}
|
||||
$attr_ids = array_unique($attr_ids);
|
||||
//获取车系列表
|
||||
$map_sery = array();
|
||||
if($s_ids){
|
||||
$str_ids = implode(',', $s_ids);
|
||||
$where_sery = array("id in ({$str_ids})" => null);
|
||||
$map_sery = $this->auto_series_model->map('id', 'name', $where_sery, 'id desc', 0, 0, 'id,name');
|
||||
}
|
||||
$map_attr = array();
|
||||
if($attr_ids){
|
||||
$str_ids = implode(',', $attr_ids);
|
||||
$where_attr = array("id in ({$str_ids})" => null);
|
||||
$map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title');
|
||||
}
|
||||
|
||||
foreach($rows as $v){
|
||||
$attr_ids = explode('_', $v['attrs']);
|
||||
$attr_title = '';
|
||||
foreach($attr_ids as $attr_id){
|
||||
$attr_title .= $map_attr[$attr_id] . '-';
|
||||
}
|
||||
$attr_title = trim($attr_title, '-');
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'brand_name' => $map_brand[$v['brand_id']],
|
||||
'sery_name' => $map_sery[$v['s_id']],
|
||||
'attr_title' => $attr_title,
|
||||
'status' => $v['status'],
|
||||
'status_name' => $statusAry[$v['status']]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['params'] = $params;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['statusAry'] = $statusAry;
|
||||
$this->data['brandAry'] = $map_brand;
|
||||
$this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total);
|
||||
$this->data['_title'] = '车型库管理';
|
||||
$this->show_view('auto/cars/lists',true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
|
||||
//获取品牌map
|
||||
$where_brand = array('status > -1' => null);
|
||||
$map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name');
|
||||
//状态
|
||||
$statusAry = array('0' => '关闭', '1' => '开启');
|
||||
if($id){
|
||||
$row = $this->auto_cars_model->get(array('id' => $id));
|
||||
|
||||
//获取属性列表
|
||||
$attr_ids = explode('_', $row['attrs']);
|
||||
$str_ids = implode(',', $attr_ids);
|
||||
$where_attr = array("id in ({$str_ids})" => null);
|
||||
$map_attr = $this->auto_attr_model->map('id', 'title', $where_attr, 'id desc', 0 , 0, 'id, title');
|
||||
//属性分类
|
||||
$attr_types = $this->auto_attr_model->get_type();
|
||||
$attr = "";
|
||||
foreach($attr_ids as $k => $attr_id){
|
||||
$attr .= $map_attr[$attr_id]. "({$attr_types[$k]})-";
|
||||
}
|
||||
$attr = trim($attr, '-');
|
||||
//车系
|
||||
$row_sery = $this->auto_series_model->get(array('id' => $row['s_id']));
|
||||
|
||||
$info = array(
|
||||
'id' => $row['id'],
|
||||
'brand_name' => $map_brand[$row['brand_id']],
|
||||
'sery_name' => $row_sery['name'],
|
||||
'attr' => $attr,
|
||||
'price_car' => $row['price_car'] > 0 ? $row['price_car'] : '',
|
||||
'price_insure' => $row['price_insure'] > 0 ? $row['price_insure'] : '',
|
||||
'price_fine' => $row['price_fine'] > 0 ? $row['price_fine'] : '',
|
||||
'price_finance' => $row['price_finance'] > 0 ? $row['price_finance'] : '',
|
||||
'first_pay' => $row['first_pay'] > 0 ? $row['first_pay'] : '',
|
||||
'price_coplus' => $row['price_coplus'] > 0 ? $row['price_coplus'] : '',
|
||||
'brokerage_1' => $row['brokerage_1'] > 0 ? $row['brokerage_1'] : '',
|
||||
'brokerage_2' => $row['brokerage_2'] > 0 ? $row['brokerage_2'] : '',
|
||||
'status' => $row['status'],
|
||||
);
|
||||
|
||||
$title = '编辑车型库';
|
||||
$view = 'auto/cars/get';
|
||||
} else {
|
||||
//新增车型库
|
||||
$info = array('brand_id' => '', 's_id' => '');
|
||||
$title = '新增车型库';
|
||||
$view = 'auto/cars/add';
|
||||
}
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['statusAry'] = $statusAry;
|
||||
$this->data['brandAry'] = $map_brand;
|
||||
$this->data['_title'] = $title;
|
||||
$this->show_view($view);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$info = $this->input->post('info');
|
||||
$brand_id = $info['brand_id'];
|
||||
$s_id = $info['s_id'];
|
||||
|
||||
$where = array('s_id' => $s_id);
|
||||
$orderby = 'type asc, id asc';
|
||||
$select = 'id,type';
|
||||
$map = $this->auto_attr_model->map('type', '', $where, $orderby, 0, 0, $select);
|
||||
$count = count($map);
|
||||
if(!$count){
|
||||
return $this->show_json(SYS_CODE_FAIL, '该车系暂无属性!');
|
||||
}
|
||||
$attrs = array_column($map[0], 'id');//属性组合
|
||||
for($i=1; $i<$count; $i++){
|
||||
$arr1 = $attrs;
|
||||
$arr2 = $map[$i];
|
||||
$attrs = array();
|
||||
foreach($arr1 as $k1 => $v1){
|
||||
foreach($arr2 as $k2 => $v2){
|
||||
$attrs[] = "{$v1}_{$v2['id']}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//车型库现有数据
|
||||
$where = array('s_id' => $s_id);
|
||||
$map_cars = $this->auto_cars_model->map('attrs', '*', $where);
|
||||
$adds = array();
|
||||
foreach($attrs as $attr){
|
||||
if($map_cars[$attr]){
|
||||
$map_cars[$attr]['ok'] = 1;//保留
|
||||
} else {
|
||||
$adds[] = array(
|
||||
'brand_id' => $brand_id,
|
||||
's_id' => $s_id,
|
||||
'attrs' => $attr,
|
||||
'c_time' => time()
|
||||
);
|
||||
}
|
||||
}
|
||||
//获取需要删除的车型库
|
||||
$del_ids = array();
|
||||
foreach($map_cars as $v){
|
||||
if(!$v['ok']){
|
||||
$del_ids[] = $v['id'];
|
||||
}
|
||||
}
|
||||
|
||||
//删除旧库
|
||||
if($del_ids){
|
||||
$str_ids = implode(',', $del_ids);
|
||||
$where = array("id in ({$str_ids})" => null);
|
||||
$ret = $this->auto_cars_model->delete($where);
|
||||
if(!$ret){
|
||||
debug_log("[error]#" . $this->auto_cars_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '更新失败!');
|
||||
}
|
||||
}
|
||||
|
||||
//新增库
|
||||
if($adds){
|
||||
$ret = $this->auto_cars_model->add_batch($adds);
|
||||
if(!$ret){
|
||||
debug_log("[error]#" . $this->auto_cars_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '更新失败!');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '更新成功!');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
|
||||
$upd = array(
|
||||
'price_car' => floatval($info['price_car']),
|
||||
'price_insure' => floatval($info['price_insure']),
|
||||
'price_fine' => floatval($info['price_fine']),
|
||||
'price_finance' => floatval($info['price_finance']),
|
||||
'first_pay' => floatval($info['first_pay']),
|
||||
'price_coplus' => floatval($info['price_coplus']),
|
||||
'brokerage_1' => floatval($info['brokerage_1']),
|
||||
'brokerage_2' => floatval($info['brokerage_2']),
|
||||
'status' => $info['status'],
|
||||
);
|
||||
|
||||
$where = array('id' => $info['id']);
|
||||
$ret = $this->auto_cars_model->update($upd, $where);
|
||||
if(!$ret){
|
||||
debug_log("[error]#" . $this->auto_cars_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '更新失败!');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '更新成功!');
|
||||
}
|
||||
|
||||
function edit_status(){
|
||||
$id = $this->input->post('id');
|
||||
$status = $this->input->post('status');
|
||||
|
||||
$upd = array('status' => $status);
|
||||
$where = array('id' => $id);
|
||||
|
||||
$ret = $this->auto_cars_model->update($upd, $where);
|
||||
if(!$ret){
|
||||
debug_log("[error]# " . $this->auto_cars_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '保存失败');
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
// TODO: Implement del() method.
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
// TODO: Implement batch() method.
|
||||
}
|
||||
|
||||
public function export(){
|
||||
// TODO: Implement export() method.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,6 +52,38 @@ class Series extends HD_Controller{
|
||||
$this->show_view('auto/series/lists', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据列表
|
||||
* @return bool
|
||||
*/
|
||||
public function json_lists(){
|
||||
$brand_id = $this->input->post('brand_id');
|
||||
$page = $this->input->post('page');
|
||||
$size = $this->input->post('size');
|
||||
|
||||
$where = array('status > -1' => null);
|
||||
$brand_id && $where['brand_id'] = $brand_id;
|
||||
$orderby = 'id desc';
|
||||
|
||||
$total = $this->auto_series_model->count($where);
|
||||
|
||||
$lists = array();
|
||||
if($total){
|
||||
$select = 'id, name';
|
||||
$rows = $this->auto_series_model->select($where, $orderby, $page, $size, $select);
|
||||
|
||||
foreach($rows as $v){
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'name' => $v['name'],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->data = array('total' => $total, 'list' => $lists);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/auto/cars/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">品牌:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="status" v-model="info.brand_id">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in brandAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">车系:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="status" v-model="info.s_id">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in seryAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
var loading = 0;
|
||||
var vue_obj;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info:{},
|
||||
brandAry:[],
|
||||
seryAry:[],
|
||||
action:'auto/cars/add'
|
||||
},
|
||||
mounted:function(){
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.brandAry = <?=json_encode($brandAry)?>;
|
||||
},
|
||||
methods:{
|
||||
saveEdit:function(){
|
||||
var vm = this;
|
||||
if(1 == loading){
|
||||
return 0;
|
||||
}
|
||||
loading = 1;
|
||||
|
||||
$.ajax({
|
||||
url: vm.action,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {info:vm.info},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = 0;
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
'info.brand_id':function(nv, ov){
|
||||
var vm = this;
|
||||
vm.seryAry = {};
|
||||
vm.info.s_id = '';
|
||||
if(nv > 0){
|
||||
$.ajax({
|
||||
url: '/auto/series/json_lists',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
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){
|
||||
var row = lists[i];
|
||||
seryAry[row.id] = row.name;
|
||||
}
|
||||
vm.seryAry = seryAry;
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,141 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/auto/cars/edit" data-auto="true" method="post" style="width: 90%;padding:25px 30px 20px 0;margin: 0 auto;overflow-y: auto;height: 400px">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">品牌:</label>
|
||||
<div class="am-para-input">{{info.brand_name}}</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">车系:</label>
|
||||
<div class="am-para-input">{{info.sery_name}}</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">属性:</label>
|
||||
<div class="am-para-input">{{info.attr}}</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">裸车报价:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入裸车报价" name="price_car" v-model="info.price_car" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">保险报价:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入保险报价" name="price_insure" v-model="info.price_insure" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">精品报价:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入精品报价" name="price_fine" v-model="info.price_fine" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">金融报价:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入金融报价" name="wx_mchid" v-model="info.price_finance" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">分期首付:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入分期首付" name="first_pay" v-model="info.first_pay" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">公司加价:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入公司加价" name="price_coplus" v-model="info.price_coplus" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">一级佣金:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入一级分销佣金" name="brokerage_1" v-model="info.brokerage_1" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">二级佣金:</label>
|
||||
<div class="am-para-input">
|
||||
<input type="text" placeholder="请输入二级分销佣金" name="brokerage_2" v-model="info.brokerage_2" style="display: inline;width: 60%"/>
|
||||
<span>元</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">状态:</label>
|
||||
<div class="am-para-input wp50">
|
||||
<select name="status" v-model="info.status">
|
||||
<option v-for="(v,i) in statusAry" :value="i">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input"><button class="am-btn am-btn-secondary" type="button" @click="saveEdit">提交</button></div>
|
||||
</div>
|
||||
</form>
|
||||
<script>
|
||||
var loading = 0;
|
||||
var vue_obj;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info:{},
|
||||
statusAry:[],
|
||||
action:'auto/cars/edit'
|
||||
},
|
||||
mounted:function(){
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
},
|
||||
methods:{
|
||||
saveEdit:function(){
|
||||
var vm = this;
|
||||
if(1 == loading){
|
||||
return 0;
|
||||
}
|
||||
loading = 1;
|
||||
|
||||
vm.info.img_seal = $('#img-seal').val();
|
||||
|
||||
$.ajax({
|
||||
url: vm.action,
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {info:vm.info},
|
||||
beforeSend: function () {
|
||||
layer.load(1, {
|
||||
shade: [0.1, '#fff'] //0.1透明度的白色背景
|
||||
});
|
||||
},
|
||||
success: function (data) {
|
||||
loading = 0;
|
||||
if (data['code']) {
|
||||
layer.msg(data.msg, {
|
||||
icon: 1,
|
||||
time: 2000
|
||||
}, function () {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(data.msg, {icon: 2});
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
watch:{}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,136 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/auto/cars/lists" class="form-search" onsubmit="return false">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">品牌:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="brand_id" v-model="params.brand_id">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in brandAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">车系:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="s_id" v-model="params.s_id">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in seryAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label">状态:</label>
|
||||
<div class="am-para-inline w150">
|
||||
<select name="status" v-model="params.status">
|
||||
<option value="">请选择</option>
|
||||
<option :value="i" v-for="(v,i) in statusAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml20">
|
||||
<button type="submit" class="am-btn am-btn-sm am-btn-success w100">搜索</button>
|
||||
<button data-modal="/auto/cars/get" data-title="更新车型库" type="button" class="am-btn am-btn-success w100 am-btn-sm">更新车型库</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="coms-table-bd">
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%"><span>ID</span></th>
|
||||
<th width="15%"><span>品牌</span></th>
|
||||
<th width="15%"><span>车系</span></th>
|
||||
<th width="25%"><span>车型-车身-内饰</span></th>
|
||||
<th width="10%"><span>状态</span></th>
|
||||
<th width=""><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(v,i) in lists">
|
||||
<td>{{v.id}}</td>
|
||||
<td>{{v.brand_name}}</td>
|
||||
<td>{{v.sery_name}}</td>
|
||||
<td>{{v.attr_title}}</td>
|
||||
<td>{{v.status_name}}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" :data-modal="'auto/cars/get?id='+v.id"
|
||||
class="am-btn am-btn-primary am-btn-xs">编辑</a>
|
||||
<a data-ajax="post" data-action="/auto/cars/edit_status" class="am-btn am-btn-danger am-btn-xs"
|
||||
:data-params-id="v.id" :data-params-status="0" v-if="1==v.status">关闭</a>
|
||||
<a data-ajax="post" data-action="/auto/cars/edit_status" class="am-btn am-btn-success am-btn-xs"
|
||||
:data-params-id="v.id" :data-params-status="1" v-if="0==v.status">开启</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var vue_obj;
|
||||
var loading = 0;
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params:[],
|
||||
lists:[],
|
||||
statusAry:[],
|
||||
brandAry:[],
|
||||
seryAry:[]
|
||||
},
|
||||
mounted:function() {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
vm.brandAry = <?=json_encode($brandAry)?>;
|
||||
},
|
||||
methods:{},
|
||||
watch:{
|
||||
'params.brand_id':function(nv, ov){
|
||||
var vm = this;
|
||||
vm.seryAry = {};
|
||||
vm.params.s_id = '';
|
||||
if(nv > 0){
|
||||
$.ajax({
|
||||
url: '/auto/series/json_lists',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
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){
|
||||
var row = lists[i];
|
||||
seryAry[row.id] = row.name;
|
||||
}
|
||||
vm.seryAry = seryAry;
|
||||
}
|
||||
},
|
||||
complete: function () {
|
||||
loading = 0;
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -8,7 +8,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*/
|
||||
class Auto_attr_model extends HD_Model{
|
||||
private $table_name = 'lc_auto_attr';
|
||||
private $type_arr = [ 0 => '颜色', 1 => '型号', 2 => '内饰颜色'];
|
||||
private $type_arr = [ 0 => '车身颜色', 1 => '型号', 2 => '内饰颜色'];
|
||||
private $status_arr = [ '-1' => '删除',0 => '下架',1 => '正常'];
|
||||
|
||||
public function __construct()
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* 车型库
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/8/6
|
||||
* Time: 11:13
|
||||
*/
|
||||
class Auto_cars_model extends HD_Model{
|
||||
private $table_name = 'lc_auto_cars';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -47,3 +47,31 @@ create table lc_auto_attr (
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车型属性';
|
||||
alter table lc_auto_attr add status tinyint(1) not null default 1 comment '状态(-1删除 0禁用 1正常)' after jsondata;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:车型库
|
||||
-- Author:xusir
|
||||
-- Table:lc_auto_cars
|
||||
-- ----------------------------
|
||||
-- attrs:属性组合,颜色ID_型号ID_内饰ID
|
||||
-- ----------------------------
|
||||
drop table if exists lc_auto_cars;
|
||||
create table lc_auto_cars (
|
||||
id int(10) not null auto_increment comment '自增id',
|
||||
brand_id int(11) not null comment '品牌id',
|
||||
s_id int(10) not null comment '车系id',
|
||||
attrs char(30) not null comment '属性组合:{type0id}_{type1id}_{type2id}',
|
||||
price_car double(10,2) not null default 0.0 comment '裸车报价',
|
||||
price_insure double(10,2) not null default 0.0 comment '保险报价',
|
||||
price_fine double(10,2) not null default 0.0 comment '精品报价',
|
||||
price_finance double(10,2) not null default 0.0 comment '金融报价',
|
||||
first_pay double(10,2) not null default 0.0 comment '分期首付',
|
||||
price_coplus double(10,2) not null default 0.0 comment '公司加价',
|
||||
brokerage_1 double(10,2) not null default 0.0 comment '一级分销佣金',
|
||||
brokerage_2 double(10,2) not null default 0.0 comment '二级分销佣金',
|
||||
status tinyint(1) not null default '0' comment '状态(1开启 0关闭 -1删除)',
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp comment '更新时间',
|
||||
c_time int(10) not null default '0' comment '创建时间',
|
||||
primary key (id),
|
||||
unique(attrs)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车型库';
|
||||
|
||||
Reference in New Issue
Block a user