liche update for admin goods add auto_fine
This commit is contained in:
@@ -0,0 +1,243 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/8/25
|
||||
* Time: 11:35
|
||||
*/
|
||||
class Fine extends HD_Controller{
|
||||
protected $log_dir;
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model('auto/auto_fine_model');
|
||||
|
||||
$this->log_dir = "auto_" . get_class($this);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return $this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
|
||||
$statusAry = array(0 => '关闭', 1 => '开启');
|
||||
|
||||
$where = array();
|
||||
|
||||
if($params['title']){
|
||||
$where["title like '%{$params['title']}%'"] = null;
|
||||
}
|
||||
if(strlen($params['status']) > 0){
|
||||
$where['status'] = $params['status'];
|
||||
} else{
|
||||
$where['status>-1'] = null;
|
||||
$params['status'] = '';
|
||||
}
|
||||
|
||||
$page = $params['page'];
|
||||
$page = !$page ? 1 : $page;
|
||||
$size = $params['size'];
|
||||
$size = !$size ? 20 : $size;
|
||||
|
||||
$total = $this->auto_fine_model->count($where);
|
||||
$lists = array();
|
||||
if($total){
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title, status';
|
||||
$rows = $this->auto_fine_model->select($where, $orderby, $page, $size, $select);
|
||||
foreach($rows as $v){
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'title' => $v['title'],
|
||||
'status' => $v['status'],
|
||||
'status_name' => $statusAry[$v['status']],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$this->data['params'] = $params;
|
||||
$this->data['lists'] = $lists;
|
||||
$this->data['statusAry'] = $statusAry;
|
||||
$this->data['pager'] = array('count' => ceil($total / $size), 'curr' => $page, 'totle' => $total);
|
||||
$this->data['_title'] = '车辆精品管理';
|
||||
$this->show_view('auto/fine/lists',true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
if($id){
|
||||
$row = $this->auto_fine_model->get(array('id' => $id));
|
||||
$info = array(
|
||||
'id' => $row['id'],
|
||||
'title' => $row['title'],
|
||||
'status' => $row['status']
|
||||
);
|
||||
$title = '编辑车辆精品';
|
||||
$action = 'auto/fine/edit';
|
||||
} else {
|
||||
$info = array(
|
||||
'title' => '',
|
||||
'status' => 1,
|
||||
);
|
||||
$title = '新增车辆精品';
|
||||
$action = 'auto/fine/add';
|
||||
}
|
||||
|
||||
$statusAry = array(0 => '关闭', 1 => '开启');
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['statusAry'] = $statusAry;
|
||||
$this->data['action'] = $action;
|
||||
$this->data['_title'] = $title;
|
||||
$this->show_view('auto/fine/get');
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增精品
|
||||
* @return bool
|
||||
*/
|
||||
public function add(){
|
||||
$info = $this->input->post('info');
|
||||
if(!$info['title']){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入精品名称');
|
||||
}
|
||||
|
||||
$where = array("title" => trim($info['title']));
|
||||
$old = $this->auto_fine_model->get($where);
|
||||
if($old && $old['status'] > -1){
|
||||
return $this->show_json(SYS_CODE_FAIL, '精品已经存在');
|
||||
} else if(-1 == $old['status']) {
|
||||
//旧数据存在,更新
|
||||
$upd = array('status' => $info['status']);
|
||||
$ret = $this->auto_fine_model->update($upd, array('id' => $old['id']));
|
||||
if(!$ret){
|
||||
debug_log('[error]# update fail; ' . $this->auto_fine_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
} else {
|
||||
$add = array(
|
||||
'title' => $info['title'],
|
||||
'status' => $info['status'],
|
||||
'c_time' => time(),
|
||||
);
|
||||
$ret = $this->auto_fine_model->add($add);
|
||||
if(!$ret){
|
||||
debug_log('[error]# add fail; ' . $this->auto_fine_model->db->last_query(), __FUNCTION__, $this->log_dir);
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @return bool
|
||||
*/
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
if(!$info['title']){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入精品名称');
|
||||
}
|
||||
|
||||
$where = array(
|
||||
"title" => trim($info['title']),
|
||||
"id<>{$info['id']}" => null,
|
||||
"status>-1" => null
|
||||
);
|
||||
$old = $this->auto_fine_model->get($where);
|
||||
if($old){
|
||||
return $this->show_json(SYS_CODE_FAIL, '精品已经存在');
|
||||
}
|
||||
|
||||
$upd = array('title' => $info['title'], 'status' => $info['status']);
|
||||
$ret = $this->auto_fine_model->update($upd, array('id' => $info['id']));
|
||||
if(!$ret){
|
||||
debug_log('[error]# update fail; ' . $this->auto_fine_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');
|
||||
$stauts = $this->input->post('status');
|
||||
if (!$id) {
|
||||
$this->show_json(SYS_CODE_FAIL, '参数错误');
|
||||
}
|
||||
$where = array('id' => $id);
|
||||
$this->auto_fine_model->update(array('status' => $stauts), $where);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
$id = $this->input->post('id');
|
||||
if (!$id) {
|
||||
$this->show_json(SYS_CODE_FAIL, '参数错误');
|
||||
}
|
||||
$where = array('id' => $id);
|
||||
$ret = $this->auto_fine_model->update(array('status' => -1), $where);
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
// TODO: Implement batch() method.
|
||||
}
|
||||
|
||||
public function export(){
|
||||
// TODO: Implement export() method.
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
function json_lists(){
|
||||
$id = $this->input->post('id');
|
||||
$title = trim($this->input->post('title'));
|
||||
$status = $this->input->post('status');
|
||||
$page = $this->input->post('page');
|
||||
$size = $this->input->post('size');
|
||||
|
||||
$where = array();
|
||||
if($id){
|
||||
if(is_numeric($id)){
|
||||
$where['id'] = $id;
|
||||
} else {
|
||||
if(is_array($id)){
|
||||
$id = implode(',', $id);
|
||||
}
|
||||
$where["id in ({$id})"] = null;
|
||||
}
|
||||
} else {
|
||||
$title && $where["title like '%{$title}%'"] = null;
|
||||
if(strlen($status) > 0){
|
||||
$where['status'] = $status;
|
||||
} else {
|
||||
$where['status>-1'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
$total = $this->auto_fine_model->count($where);
|
||||
$lists = array();
|
||||
if($total){
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title';
|
||||
$rows = $this->auto_fine_model->select($where, $orderby, $page, $size, $select);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ class Goods extends HD_Controller
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('items/items_model', 'mdItems');
|
||||
$this->load->model('items/items_relate_model');
|
||||
$this->load->model('auto/auto_brand_model', 'mdAutoBrand');
|
||||
$this->load->model('auto/auto_series_model', 'mdAutoSeries');
|
||||
$this->load->model('auto/auto_attr_model', 'mdAutoAttr');
|
||||
@@ -167,12 +168,19 @@ class Goods extends HD_Controller
|
||||
$info['addr_id'] = '';
|
||||
}
|
||||
|
||||
//获取精品加装
|
||||
$where = array('item_id' => $id, 'type' => 1, 'status' => 1);
|
||||
$rows_fine = $this->items_relate_model->select($where, '', 0, 0, 'type_id');
|
||||
$fine_ids = $rows_fine ? array_column($rows_fine, 'type_id') : array();
|
||||
$info['fine_ids'] = $fine_ids;
|
||||
|
||||
$_title = '编辑商品';
|
||||
$edit_url = '/items/goods/goods/edit';
|
||||
} else {
|
||||
$info['city_id'] = '';
|
||||
$info['county_id'] = '';
|
||||
$info['addr_id'] = '';
|
||||
$info['fine_ids'] = array();
|
||||
$_title = '新增商品';
|
||||
$edit_url = '/items/goods/goods/add';
|
||||
}
|
||||
@@ -224,6 +232,13 @@ class Goods extends HD_Controller
|
||||
} else {
|
||||
$info['address'] = '';
|
||||
}
|
||||
|
||||
//获取精品加装
|
||||
$where = array('item_id' => $id, 'type' => 1, 'status' => 1);
|
||||
$rows_fine = $this->items_relate_model->select($where, '', 0, 0, 'type_id');
|
||||
$fine_ids = $rows_fine ? array_column($rows_fine, 'type_id') : array();
|
||||
$info['fine_ids'] = $fine_ids;
|
||||
|
||||
$this->data['info'] = $info;
|
||||
return $this->show_view('/items/goods/get_info');
|
||||
}
|
||||
@@ -282,6 +297,21 @@ class Goods extends HD_Controller
|
||||
if (!$id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败!');
|
||||
}
|
||||
|
||||
//保存精品
|
||||
if($info['fine_ids']){
|
||||
$adds = array();
|
||||
foreach($info['fine_ids'] as $fine_id){
|
||||
$adds[] = array(
|
||||
'item_id' => $id,
|
||||
'type' => 1,
|
||||
'type_id' => $fine_id,
|
||||
'status' => 1
|
||||
);
|
||||
}
|
||||
$ret = $this->items_relate_model->add_batch($adds);
|
||||
}
|
||||
|
||||
$this->data['status'] = 1;
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '添加成功!');
|
||||
}
|
||||
@@ -390,6 +420,32 @@ class Goods extends HD_Controller
|
||||
if (!$ret) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '修改失败!');
|
||||
}
|
||||
|
||||
//保存精品
|
||||
$where = array('item_id' => $info['id'], 'type' => 1);
|
||||
//删除旧数据
|
||||
$this->items_relate_model->update(array('status' => -1), $where);
|
||||
$map_relate = $this->items_relate_model->map('type_id', 'status', $where);
|
||||
if($info['fine_ids']){
|
||||
$adds = array();
|
||||
foreach($info['fine_ids'] as $fine_id){
|
||||
if(!$map_relate[$fine_id]){
|
||||
//新增
|
||||
$adds[] = array(
|
||||
'item_id' => $info['id'],
|
||||
'type' => 1,
|
||||
'type_id' => $fine_id,
|
||||
'status' => 1
|
||||
);
|
||||
} else {
|
||||
//启用旧数据
|
||||
$where = array('item_id' => $info['id'], 'type' => 1, 'type_id' => $fine_id);
|
||||
$this->items_relate_model->update(array('status' => 1), $where);
|
||||
}
|
||||
}
|
||||
$adds && $this->items_relate_model->add_batch($adds);
|
||||
}
|
||||
|
||||
$this->data['status'] = 2;
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '修改成功!');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/auto/fine/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"><span class="com-must-star">*</span>名称:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="请输入名称" name="title" v-model="info.title"/></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:''
|
||||
},
|
||||
mounted:function(){
|
||||
var vm = this;
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.action = '<?=$action?>';
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
},
|
||||
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:{}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,90 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/auto/fine/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 w200">
|
||||
<input type="text" name="title" id="input" placeholder="输入关键字" v-model="params.title"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<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/fine/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">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%"><span>ID</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.title}}</td>
|
||||
<td>{{v.status_name}}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" :data-modal="'auto/fine/get?id='+v.id"
|
||||
class="am-btn am-btn-primary am-btn-xs">编辑</a>
|
||||
<a data-ajax="post" data-action="/auto/fine/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/fine/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>
|
||||
<a data-ajax="post" data-action="/auto/fine/del" class="am-btn am-btn-danger am-btn-xs"
|
||||
:data-params-id="v.id">删除</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:[],
|
||||
statusAry:[],
|
||||
lists:[]
|
||||
},
|
||||
mounted:function() {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.lists = <?=json_encode($lists)?>;
|
||||
vm.statusAry = <?=json_encode($statusAry)?>;
|
||||
},
|
||||
methods:{},
|
||||
watch:{}
|
||||
});
|
||||
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,3 +1,41 @@
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/appitem/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/appitem/AdminLTE.min.css">
|
||||
<style>
|
||||
.label-group-wrap {
|
||||
margin-top: 10px;
|
||||
font-size: 0;
|
||||
}
|
||||
.label-group {
|
||||
display: inline-block;
|
||||
margin-right: 4px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.label-group-wrap .label, .label-group>.label {
|
||||
font-size: 10px;
|
||||
font-weight: normal;
|
||||
margin-right: 1px;
|
||||
white-space: normal;
|
||||
line-height: 1.4;
|
||||
}
|
||||
.label {
|
||||
font-weight: normal;
|
||||
}
|
||||
.label-group>span+a.label {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
border-left: 1px solid #fff;
|
||||
margin-left: -3px;
|
||||
}
|
||||
.label-group-wrap .label, .label-group>.label {
|
||||
font-size: 10px;
|
||||
font-weight: normal;
|
||||
margin-right: 1px;
|
||||
white-space: normal;
|
||||
line-height: 1.4;
|
||||
}
|
||||
</style>
|
||||
<div class="am-form am-form-horizontal" style="width: 100%;padding: 10px">
|
||||
<div id="vue-edit">
|
||||
<div class="am-panel am-panel-default">
|
||||
@@ -66,10 +104,20 @@
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td class="table-td">
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="table-td" colspan="2">
|
||||
<div class="input-group">
|
||||
<div class="input-group-addon">精品加装</div>
|
||||
<input type="text" v-model="info.if_pack" placeholder="请输入精品加装">
|
||||
<div class="label-group-wrap label-group-sortable" style="display: inline">
|
||||
<div class="label-group" v-for="(v,i) in fines">
|
||||
<span class="label label-default sort-shop-list" :data-id="v.id" :data-name="v.title"
|
||||
:data-sort="i">{{v.title}}</span>
|
||||
<a href="javascript:void(0);" @click="rm_fine(i)" class="label label-default"><i
|
||||
class="fa fa-remove"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="am-btn am-btn-default am-btn-sm" @click="fine_modal">+</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -211,6 +259,62 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="fine-modal" style="display: none;">
|
||||
<div class="modal-body">
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td width="20%">ID</td>
|
||||
<td width="35%" style="font-weight: bold;padding-left: 8px;">精品</td>
|
||||
<td width="40%" style="padding-right: 8px;"><label class="sr-only" for="search">搜精品</label>
|
||||
<div class="input-group input-group-sm">
|
||||
<input type="text" class="form-control" style="font-size: 1.2rem;font-weight: bold;"
|
||||
v-model='modal_fine.title' placeholder="精品关键字">
|
||||
<div class="input-group-btn">
|
||||
<button type="button" @click='get_fines(0);' class="btn btn-default">搜</button>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div style="border-bottom: 1px solid #ddd;height: 1px;margin-top: 8px;"></div>
|
||||
<table class="table table-middle">
|
||||
<colgroup>
|
||||
<col width="15%"/>
|
||||
<col width="45%"/>
|
||||
<col width="20%"/>
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr v-for="(v,i) in modal_fine.lists">
|
||||
<td>{{v.id}}</td>
|
||||
<td>{{v.title}}</td>
|
||||
<td class="text-right">
|
||||
<a v-if="v.checked==0 || !v.checked" href="javascript:void(0);" @click="set_fine(i,1)"
|
||||
class="btn btn-primary btn-sm">选择</a>
|
||||
<a v-else-if="v.checked==1" href="javascript:void(0);" @click="set_fine(i,0)"
|
||||
class="btn btn-default btn-sm">移除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="clearfix">
|
||||
<span class="pull-left text-muted">第{{modal_fine.page}}页(每页{{modal_fine.size}}条,共{{modal_fine.total}}条)</span>
|
||||
<nav class="pull-right" aria-label="Page navigation">
|
||||
<ul class="pagination pagination-sm">
|
||||
<li v-if="modal_fine.page>1">
|
||||
<a href="javascript:void(0);" @click="get_fines(-1);" aria-label="上一页">
|
||||
<span class="glyphicon glyphicon-menu-left"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="modal_fine.next>0">
|
||||
<a href="javascript:void(0);" @click="get_fines(1);" aria-label="下一页">
|
||||
<span class="glyphicon glyphicon-menu-right"></span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
@@ -223,13 +327,16 @@
|
||||
showInfo: {'autoList': []},
|
||||
cityAry:[],
|
||||
countyAry:[],
|
||||
addrAry:[]
|
||||
addrAry:[],
|
||||
fines:[],
|
||||
modal_fine:{title:'', lists:[], selected:[], page:1, size:10, total:0}
|
||||
},
|
||||
mounted: function () {
|
||||
var that = this;
|
||||
that.info = <?=json_encode($info)?>;
|
||||
that.showInfo = <?=json_encode($showInfo)?>;
|
||||
that.init_citys();
|
||||
that.init_fines();
|
||||
},
|
||||
computed: {},
|
||||
created: function () {
|
||||
@@ -305,6 +412,14 @@
|
||||
vm.info.p_time = $('#p_time_id').val();
|
||||
vm.info.out_time = $('#out_time_id').val();
|
||||
vm.info.bill_time = $('#bill_time_id').val();
|
||||
|
||||
//获取精品
|
||||
var fine_ids = [];
|
||||
for(var i in vm.fines){
|
||||
fine_ids.push(vm.fines[i]['id']);
|
||||
}
|
||||
vm.info.fine_ids = fine_ids;
|
||||
|
||||
$.ajax({
|
||||
url: <?=json_encode($edit_url)?>,
|
||||
type: 'post',
|
||||
@@ -383,6 +498,110 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
init_fines:function(){
|
||||
var vm = this;
|
||||
if(vm.info.fine_ids.length > 0){
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/auto/fine/json_lists',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: vm.info.fine_ids.join(','),
|
||||
status:1
|
||||
},
|
||||
success:function(response){
|
||||
if (response.code == 1) {
|
||||
vm.fines = response.data.list;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
fine_modal:function(){
|
||||
//选择门店
|
||||
var vm = this;
|
||||
var selects = JSON.parse(JSON.stringify(vm.fines));
|
||||
vm.modal_fine = {title:'', lists:[], selected:selects, page:1, size:10, total:0, next:0};
|
||||
vm.get_fines();
|
||||
layer.open({
|
||||
type: 1,
|
||||
area: ['50%', '80%'], //宽高
|
||||
content: $('#fine-modal'),
|
||||
title: '选取精品',
|
||||
shade: false,
|
||||
btn: ['选好了'],
|
||||
yes: function (index) {
|
||||
layer.close(index);
|
||||
vm.fines = JSON.parse(JSON.stringify(vm.modal_fine.selected));
|
||||
}
|
||||
});
|
||||
},
|
||||
get_fines:function(page){
|
||||
var vm = this;
|
||||
if(0 == page){
|
||||
vm.modal_fine.page = 1;
|
||||
vm.modal_fine.total = 0;
|
||||
vm.modal_fine.next = 0;
|
||||
} else if(1 == page){
|
||||
vm.modal_fine.page+=1;
|
||||
} else if(-1 == page) {
|
||||
vm.modal_fine.page-=1;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/auto/fine/json_lists',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
page: vm.modal_fine.page,
|
||||
size: vm.modal_fine.size,
|
||||
status:1,
|
||||
title:vm.modal_fine.title
|
||||
},
|
||||
success:function(response){
|
||||
if (response.code == 1) {
|
||||
vm.modal_fine.lists = response.data.list;
|
||||
vm.modal_fine.total = response.data.total;
|
||||
if(vm.modal_fine.page * vm.modal_fine.size < vm.modal_fine.total){
|
||||
vm.modal_fine.next=1;
|
||||
} else {
|
||||
vm.modal_fine.next=0;
|
||||
}
|
||||
for(var i in vm.modal_fine.lists){
|
||||
var fine = vm.modal_fine.lists[i];
|
||||
fine.checked = 0;
|
||||
for(var j in vm.modal_fine.selected){
|
||||
var selected = vm.modal_fine.selected[j];
|
||||
if(fine.id == selected.id){
|
||||
fine.checked = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
set_fine:function(index, checked){
|
||||
var vm = this;
|
||||
var fine = vm.modal_fine.lists[index];
|
||||
fine.checked = checked;
|
||||
if(checked == 1){
|
||||
var selected = {id:fine.id, title:fine.title};
|
||||
vm.modal_fine.selected.push(selected);
|
||||
} else {
|
||||
for(var i in vm.modal_fine.selected){
|
||||
selected = vm.modal_fine.selected[i];
|
||||
if(fine.id == selected.id){
|
||||
vm.modal_fine.selected.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
vm.$forceUpdate();
|
||||
},
|
||||
rm_fine:function(index){
|
||||
var vm = this;
|
||||
vm.fines.splice(index, 1);
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
@@ -432,7 +651,7 @@
|
||||
if(that.info.addr_id>0){
|
||||
var addr_id = '';
|
||||
for(var i in that.addrAry){
|
||||
if(that.info.addr_id == thayt.addrAry[i].id){
|
||||
if(that.info.addr_id == that.addrAry[i].id){
|
||||
addr_id = that.info.addr_id;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,8 +26,10 @@
|
||||
<td class="table-td">
|
||||
内饰色:<?= $info['incor_name'] ?>
|
||||
</td>
|
||||
<td class="table-td">
|
||||
精品加装:<?= $info['if_pack_name'] ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="table-td" colspan="3">
|
||||
精品加装:{{auto_fine}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -102,3 +104,48 @@
|
||||
font-size: 1.6rem;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$(function(){
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-edit',
|
||||
data: {
|
||||
info: {},
|
||||
auto_fine:""
|
||||
},
|
||||
mounted: function () {
|
||||
var that = this;
|
||||
that.info = <?=json_encode($info)?>;
|
||||
that.init_fine();
|
||||
},
|
||||
computed: {},
|
||||
created: function () {
|
||||
},
|
||||
updated: function () {
|
||||
},
|
||||
methods: {
|
||||
init_fine:function(){
|
||||
var vm = this;
|
||||
if(vm.info.fine_ids.length > 0){
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/auto/fine/json_lists',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: vm.info.fine_ids.join(','),
|
||||
status:1
|
||||
},
|
||||
success:function(response){
|
||||
if (response.code == 1) {
|
||||
for(var i in response.data.list){
|
||||
vm.auto_fine += ' ' + response.data.list[i]['title'];
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
watch:{}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/8/25
|
||||
* Time: 10:51
|
||||
*/
|
||||
class Auto_fine_model extends HD_Model{
|
||||
private $table_name = 'lc_auto_fine';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/8/25
|
||||
* Time: 11:32
|
||||
*/
|
||||
class Items_relate_model extends HD_Model{
|
||||
private $table_name = 'lc_items_relate';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
@@ -77,3 +77,21 @@ create table lc_auto_cars (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车型库';
|
||||
alter table lc_auto_cars add column month_pay double(10,2) not null default 0.0 comment '月供' after first_pay;
|
||||
alter table lc_auto_cars add column price_book double(10,2) not null default 0.0 comment '定金' after price_car;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:车辆精品
|
||||
-- Author:xusir
|
||||
-- Table:lc_auto_fine
|
||||
-- ---------------------------
|
||||
drop table if exists lc_auto_fine;
|
||||
create table lc_auto_fine (
|
||||
id int(10) not null auto_increment comment '自增id',
|
||||
title varchar(50) not null default '' 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)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='车辆精品';
|
||||
|
||||
|
||||
|
||||
@@ -37,3 +37,17 @@ alter table lc_items drop column frame_num;
|
||||
alter table lc_items modify if_pack varchar(256) not null default '' comment '精品加装';
|
||||
alter table lc_items add column addr_id int unsigned not null default 0 comment '存放地址ID' after address;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:商品关联
|
||||
-- Author:xusir
|
||||
-- Table:lc_items_relate
|
||||
-- ---------------------------
|
||||
drop table if exists lc_items_relate;
|
||||
create table lc_items_relate (
|
||||
item_id int unsigned not null comment '商品id',
|
||||
type varchar(50) not null default '0' comment '1-精品',
|
||||
type_id int unsigned not null comment '类型ID',
|
||||
status tinyint(1) not null default 1 comment '状态:-1删除,1正常',
|
||||
primary key (item_id,type,type_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商品关联';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user