增加cps品牌和bootstrap-select搜索插件

This commit is contained in:
lcc
2024-12-19 08:22:43 +08:00
parent 865e00f8ef
commit 9ccbffa083
14 changed files with 480 additions and 15 deletions
+13
View File
@@ -52,8 +52,21 @@ class Orders extends HD_Controller
}
$result = $this->orderslist->lists($params['status_pid'], $params);
$this->data = $result;
//获取品牌
$brand_rows = $this->auto_brand_model->select(['status>'=>0], 'status desc, id asc', 0, 0, 'id,name');
$brands = [];
if($brand_rows){
foreach ($brand_rows as $v) {
$brands[] = array(
'id' => $v['id'],
'name' => $v['name'],
);
}
}
$this->data['brands'] = $brands;
$this->data['provinces'] = $this->province_ary();
$this->data['status_arr'] = $status_arr;
$this->data['cps_types'] = Receiver_orders_model::CPS_TYPES;
$this->data['_title'] = '订单列表';
return $this->show_view('receiver/order/lists', true);
}
+138
View File
@@ -0,0 +1,138 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Brand extends HD_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model("sys/sys_cps_model");
$this->load->model("auto/auto_brand_model");
}
public function index()
{
return $this->lists();
}
public function lists()
{
$params = $this->input->get();
$params['page'] = $params['page'] ? intval($params['page']) : 1;
$params['size'] = $params['size'] ? intval($params['size']) : 20;
!strlen($params['status']) && $params['status'] = '';
$lists = array();
$where = [];
strlen($params['status']) && $where['status'] = intval($params['status']);
$status_lists = Sys_cps_model::STATUS_LISTS;
$count = $this->sys_cps_model->count($where);
if ($count) {
$res = $this->sys_cps_model->select($where, "id desc", $params['page'], $params['size']);
foreach ($res as $key => $value) {
$brand = $this->auto_brand_model->get(['id' => $value['brand_id']]);
$value['brand_name'] = $brand['name'];
$value['type_name'] = Sys_cps_model::TYPES[$value['type']];
$value['status_name'] = $status_lists[$value['status']];
$lists[] = $value;
}
}
$this->data['lists'] = $lists;
$this->data['params'] = $params;
$this->data['status_lists'] = $status_lists;
$this->data['_title'] = 'cps列表';
$this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count);
$this->show_view('sys/cps/lists', true);
}
public function get()
{
$id = intval($this->input->get('id'));
$info = ['brand_id' => '', 'type' => Sys_cps_model::TYPE_IMPORTANT];
if ($id) {
$info = $this->sys_cps_model->get(['id' => $id]);
}
$brand_rows = $this->auto_brand_model->select(['status' => 1], 'id asc', 0, 0, 'id,name');
$brands = [];
if ($brand_rows) {
foreach ($brand_rows as $v) {
$brands[] = array(
'id' => $v['id'],
'name' => $v['name'],
);
}
}
$this->data['brands'] = $brands;
$this->data['info'] = $info;
$this->data['types'] = Sys_cps_model::TYPES;
$this->data['_title'] = $id ? '编辑' : '新增';
return $this->show_view('sys/cps/edit', true);
}
public function add()
{
$info = $this->input->post();
if (!$info['brand_id'] || !$info['type'] || !$info['s_time'] || !$info['e_time']) {
return $this->show_json(SYS_CODE_FAIL, '参数错误');
}
$data = [
'brand_id' => $info['brand_id'],
'type' => $info['type'],
's_time' => $info['s_time'],
'e_time' => $info['e_time'],
];
$res = $this->sys_cps_model->add($data);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
public function edit()
{
$info = $this->input->post();
$row = $this->sys_cps_model->get(['id' => $info['id']]);
if (!$row) return $this->show_json(SYS_CODE_FAIL, '数据不存在');
$up_data = [
'brand_id' => $info['brand_id'],
'type' => $info['type'],
's_time' => $info['s_time'],
'e_time' => $info['e_time'],
];
$res = $this->sys_cps_model->update($up_data, ['id' => $info['id']]);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
public function del()
{
}
public function batch()
{
return false;
}
public function export()
{
return false;
}
public function edit_status()
{
$id = $this->input->post('id');
$row = $this->sys_cps_model->get(['id' => $id]);
if (!$row) return $this->show_json(SYS_CODE_FAIL, '数据不存在');
$status = $row['status'] ? 0 : 1;
$up_data = [
'status' => $status
];
$res = $this->sys_cps_model->update($up_data, ['id' => $id]);
if (!$res) {
return $this->show_json(SYS_CODE_FAIL, '保存失败');
}
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
}
}
+11 -3
View File
@@ -119,9 +119,9 @@ class OrdersList
$rows_od = $this->ci->mdOrderData->select($where_od, '', 0, 0, 'o_id');
$rows_od && $str_ids = implode(',', array_column($rows_od, 'o_id'));
if($params['iscontract'] == 1){
if ($params['iscontract'] == 1) {
$where["id in({$str_ids})"] = null;
}else{
} else {
$where["id not in({$str_ids})"] = null;
}
@@ -151,6 +151,10 @@ class OrdersList
$params['brand_id'] && $where['brand_id'] = $params['brand_id'];
$params['series_id'] && $where['series_id'] = $params['series_id'];
$params['car_id'] && $where['car_id'] = $params['car_id'];
!strlen($params['cps_type']) && $params['cps_type'] = '';
if (strlen($params['cps_type'])) {
$where['cps_type'] = intval($params['cps_type']);
}
//销售员筛选
if ($params['admin_id']) {
$where["sale_id"] = $params['admin_id'];
@@ -188,7 +192,7 @@ class OrdersList
if (strlen($params['status'])) {
$where['status'] = $params['status'];
}
if($params['admin_biz_str']){
if ($params['admin_biz_str']) {
$where["biz_id in ({$params['admin_biz_str']})"] = null;
}
$orderby = "c_time desc";
@@ -291,6 +295,9 @@ class OrdersList
$sale = $this->ci->mdLichebUsers->get(['id' => $val['sale_id']], 'uname');
$fields['admin_name'] = $sale['uname'];
}
$fields['cps_type_name'] = Receiver_orders_model::CPS_TYPES[$val['cps_type']];
} else {
$fields['car_name'] .= "<br><span class='btn btn-xs btn-success'>" . Receiver_orders_model::CPS_TYPES[$val['cps_type']] . "</span>";
}
$lists[] = $fields;
}
@@ -342,6 +349,7 @@ class OrdersList
!$fields['order_time'] && $fields['order_time'] = ['title' => '下定时间'];
!$fields['bill_time'] && $fields['bill_time'] = ['title' => '开票时间'];
!$fields['contract'] && $fields['contract'] = ['title' => '购车合同'];
$fields['cps_type_name'] = ['title' => 'CPS品牌'];
}
return $fields;
}
+4 -1
View File
@@ -20,6 +20,9 @@
<link rel="stylesheet" type="text/css" href="/static/css/switch.css">
<link rel="stylesheet" type="text/css" href="/static/js/plugin/viewer/viewer.css?t=3">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-select.min.css">
<script type="text/javascript" src="/static/js/plugin/bootstrap-select/popper.min.js"></script>
<script type="text/javascript" src="/static/js/common/jquery-3.0.0.js"></script>
<script type="text/javascript" src="/static/js/common/vue.min.js"></script>
<script type="text/javascript" src="/AmazeUI/assets/js/amazeui.js"></script>
@@ -154,7 +157,7 @@
</body>
<script type="text/javascript" src="/static/js/plugin/require/require.js"></script>
<script type="text/javascript" src="/static/js/common/app.js"></script>
<script type="text/javascript" src="/static/js/common/app.js?v=1"></script>
<script type="text/javascript">
//查看图片控件
function showViewer(obj){
+27 -11
View File
@@ -91,8 +91,8 @@
<div class="am-para-inline w100">
<select name="iscontract">
<option value="">请选择</option>
<option value="1" <?php if($params['iscontract'] == 1){ ?>selected <?php }?>>是</option>
<option value="2" <?php if($params['iscontract'] == 2){ ?>selected <?php }?>>否</option>
<option value="1" <?php if ($params['iscontract'] == 1){ ?>selected <?php } ?>>是</option>
<option value="2" <?php if ($params['iscontract'] == 2){ ?>selected <?php } ?>>否</option>
</select>
</div>
</div>
@@ -101,17 +101,20 @@
<div class="am-para-inline w100">
<select name="isbill">
<option value="">请选择</option>
<option value="1" <?php if($params['isbill'] == 1){ ?>selected <?php }?>>是</option>
<option value="2" <?php if($params['isbill'] == 2){ ?>selected <?php }?>>否</option>
<option value="1" <?php if ($params['isbill'] == 1){ ?>selected <?php } ?>>是</option>
<option value="2" <?php if ($params['isbill'] == 2){ ?>selected <?php } ?>>否</option>
</select>
</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 name="brand_id" v-model="params.brand_id">
<option :value="v.id" v-for="(v,i) in brandAry">{{v.name}}</option>
<div class="am-para-inline">
<select class="selectpicker" name="brand_id" v-model="params.brand_id" data-live-search="true">
<option value="0">所有品牌</option>
<? foreach ($brands as $v) { ?>
<option value="<?= $v['id'] ?>"><?= $v['name'] ?></option>
<? } ?>
</select>
</div>
<div class="am-para-inline w120">
@@ -172,6 +175,15 @@
</select>
</div>
</div>
<div class="am-form-group fl ml10">
<label class="am-para-label w100">CPS品牌:</label>
<div class="am-para-inline w100">
<select name="cps_type" v-model="params.cps_type">
<option value=''>请选择</option>
<option v-for="(v,i) in cps_types" :value="i">{{v}}</option>
</select>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 0px;"></div>
<div class="am-form-group fl" style="margin-bottom: 0px;">
<div class="am-form-group fl ml10">
@@ -220,7 +232,7 @@
</div>
</div>
<script>
require(['laydate', 'autocomplete'], function (laydate) {
require(['laydate', 'autocomplete', 'bootstrap-select'], function (laydate) {
laydate.render({
elem: '#id-create-time', range: '~'
});
@@ -269,8 +281,9 @@
break;
}
});
});
$('.selectpicker').selectpicker();
});
$(function () {
vue_obj = new Vue({
el: '.coms-table-wrap',
@@ -286,23 +299,25 @@
cityAry: [],
countyAry: [],
bizAry: [],
list: []
list: [],
},
lists: [],
of2Ary: [],
cps_types: [],
},
mounted: function () {
var vm = this;
vm.lists = <?=json_encode($lists)?>;
vm.params = <?=json_encode($params)?>;
vm.show_info = <?=json_encode($show_info)?>;
vm.init_brands();
// vm.init_brands();
if (vm.params.series_id) {
this.get_series()
}
if (vm.params.car_id) {
this.get_car()
}
vm.cps_types = <?=json_encode($cps_types, JSON_UNESCAPED_UNICODE)?>;
},
methods: {
export_out: function (type) {
@@ -358,6 +373,7 @@
that.params.county_id_id_admin = '';
that.params.biz_id_id_admin = '';
that.params.qdjl_id = '';
that.params.cps_type = '';
}
},
watch: {
+111
View File
@@ -0,0 +1,111 @@
<form id="vue-app" class="am-form am-form-horizontal" action="/biz/store/store/add?>" data-auto="true" method="post"
style="width: 90%;padding-top: 10px">
<div class="am-form-group">
<label class="am-para-label">品牌:</label>
<div class="am-para-input w200">
<select class="selectpicker" v-model="info.brand_id" data-live-search="true">
<option v-for="value in brands" :value="value.id">{{value.name}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">类型:</label>
<div class="am-para-input w200">
<select v-model="info.type">
<option v-for="(value,index) in types" :value="index">{{value}}</option>
</select>
</div>
</div>
<div class="am-form-group">
<label class="am-para-label">有效时间:</label>
<div class="am-para-input wp60">
<div class="am-para-inline w200">
<input type="text" placeholder="开始时间" v-model="info.s_time" name="s_time"
id="datetimepicker1" autocomplete="off">
</div>
<div class="am-para-inline w200">
<input type="text" placeholder="结束时间" v-model="info.e_time" name="e_time" id="datetimepicker2"
autocomplete="off">
</div>
</div>
</div>
<div class="am-form-group" style="margin-bottom: 2rem">
<div class="am-para-input">
<button class="am-btn am-btn-success" type="button" @click="submit">提交</button>
</div>
</div>
</form>
<script>
var vm = new Vue({
el: '#vue-app',
data: {
info: <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>,
brands: <?=json_encode($brands, JSON_UNESCAPED_UNICODE)?>,
types: <?=json_encode($types, JSON_UNESCAPED_UNICODE)?>,
},
mounted: function () {
},
methods: {
submit: function () {
let url = "sys/cps/brand/add"
if (this.info.id) {
url = "sys/cps/brand/edit"
}
var brand_id = $('.selectpicker').val();
if (!brand_id) {
layer.msg("请选择品牌", {icon: 2})
return
}
if (!this.info.type) {
layer.msg("请选择类型", {icon: 2})
return
}
if (!this.info.s_time || !this.info.e_time) {
layer.msg("请选择有效期时间", {icon: 2})
return
}
this.info.brand_id = brand_id
$.post(url, this.info, function (data) {
if (data.code) {
layer.msg(data.msg, {
icon: 1, end: function () {
window.onhashchange.call();
}
});
} else {
layer.msg(data.msg, {icon: 2});
}
})
},
set_Stime: function (value) {
this.info.s_time = value
},
set_Etime: function (value) {
this.info.e_time = value
}
},
created: function () {
},
watch: {}
});
require(['laydate', 'bootstrap-select'], function (laydate, bootstrapSelect) {
//日期范围
laydate.render({
elem: '#datetimepicker1',
type: 'date',
done: function (value, date) {
vm.set_Stime(value)
}
});
laydate.render({
elem: '#datetimepicker2',
type: 'date',
done: function (value, date) {
vm.set_Etime(value)
}
});
$('.selectpicker').selectpicker();
});
</script>
+91
View File
@@ -0,0 +1,91 @@
<div class="coms-table-wrap mt10" id="vue-app">
<form class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
action="sys/cps/brand">
<div class="am-form am-form-horizontal">
<div class="am-form-group fl">
<label class="am-para-label w80">状态:</label>
<div class="am-para-inline w120">
<select name="status" v-model="params.status">
<option value="">选择状态</option>
<option v-for="(value,key) in status_lists" :value="key">
{{value}}
</option>
</select>
</div>
</div>
<div class="am-form-group fl ml30">
<div class="am-form-group fl ml10">
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
</div>
<div class="am-form-group fl ml10">
<button data-open="/sys/cps/brand/get" type="button" data-title="新增"
class="am-btn am-btn-success am-btn-sm w100">
新增
</button>
</div>
</div>
</div>
</form>
<div class="coms-table-bd" id="vue-show">
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
<table class="am-table am-table-bordered">
<thead>
<tr>
<th width="8%"><span>id</span></th>
<th><span>品牌</span></th>
<th width="15%"><span>开始时间</span></th>
<th width="15%"><span>结束时间</span></th>
<th width="10%"><span>类型</span></th>
<th width="10%"><span>状态</span></th>
<th width="10%"><span>操作</span></th>
</tr>
</thead>
<tbody>
<template v-for="value in lists">
<tr>
<td>{{value.id}}</td>
<td>{{value.brand_name}}</td>
<td>{{value.s_time}}</td>
<td>{{value.e_time}}</td>
<td>{{value.type_name}}</td>
<td>{{value.status_name}}</td>
<td>
<button data-action="/sys/cps/brand/edit_status" data-ajax="post" :data-params-id="value.id"
class="am-btn am-btn-danger am-btn-xs">
{{value.status==1?'禁用':'启用'}}
</button>
<button :data-open="'/sys/cps/brand/get?id='+value.id" class="am-btn am-btn-success am-btn-xs">
修改
</button>
</td>
</tr>
</template>
</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;
$(function () {
vue_obj = new Vue({
el: '#vue-app',
data: {
params: <?=json_encode($params, JSON_UNESCAPED_UNICODE)?>,
status_lists: <?=json_encode($status_lists, JSON_UNESCAPED_UNICODE)?>,
lists: <?=json_encode($lists, JSON_UNESCAPED_UNICODE)?>,
},
mounted: function () {
},
methods: {},
watch: {}
});
<?php page_script($pager) ?>
});
</script>
@@ -114,6 +114,7 @@ class Cusorder extends Wxapp
$money_json['register_amount'] = $register_amount ? $register_amount : 0;
}
$data['money_json'] = json_encode($money_json, JSON_UNESCAPED_UNICODE);
$data['cps_type'] = $this->orders_model->get_cps_type($car_row['brand_id']);
$o_id = $this->orders_model->add($data);
if (is_numeric($o_id)) {
//更新客户
@@ -7,9 +7,20 @@ class Receiver_orders_model extends HD_Model
private $status_arr = [0 => '签约下定', 1 => '发票开具', 2 => '车辆交付', 3 => '已完成'];
const CPS_TYPE_OTHER = 0; //其它车型
const CPS_TYPE_IMPORTANT = 1; //重点品牌
const CPS_TYPE_NORMAl = 2; //常规品牌
const CPS_TYPES = [
self::CPS_TYPE_OTHER => '其它品牌',
self::CPS_TYPE_IMPORTANT => '重点品牌',
self::CPS_TYPE_NORMAl => '常规品牌',
];
public function __construct()
{
parent::__construct($this->table_name, 'default');
$this->load->model("sys/sys_cps_model");
}
/**
@@ -35,4 +46,28 @@ class Receiver_orders_model extends HD_Model
return $array;
}
}
/**
* @param $brand_id
* @param $time
* @return int
*/
public function get_cps_type($brand_id, $time = 0)
{
$cps_type = self::CPS_TYPE_OTHER;
!$time && $time = time();
if ($brand_id) {
$where = [
'brand_id' => $brand_id,
's_time>=' => date('Y-m-d', $time),
'e_time<=' => date('Y-m-d', $time),
'status' => Sys_cps_model::STATUS_NORMAL,
];
$row = $this->sys_cps_model->get($where);
if ($row) {
$cps_type = $row['type'];
}
}
return $cps_type;
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Sys_cps_model extends HD_Model
{
private $table_name = 'lc_sys_cps';
const TYPE_IMPORTANT = 1; //重点品牌
const TYPE_NORMAL = 2; //常规品牌
const TYPES = [
self::TYPE_IMPORTANT => '重点品牌',
self::TYPE_NORMAL => '常规品牌',
];
const STATUS_DISABLE = 0; //禁用
const STATUS_NORMAL = 1; //正常
const STATUS_LISTS = [
self::STATUS_DISABLE => '禁用',
self::STATUS_NORMAL => '正常',
];
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
File diff suppressed because one or more lines are too long
+1
View File
@@ -23,6 +23,7 @@ require.config({
// bootstrap
'bootstrap': ['../plugin/bootstrap/js/bootstrap.min'],
'bootstrap.multiselect': ['../plugin/bootstrap-multiselect/bootstrap-multiselect'],
'bootstrap-select': ['../plugin/bootstrap-select/bootstrap-select.min'],
// UI
'amazeui':['../../../AmazeUI/assets/js/amazeui.min'],
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long