修改4s品牌多选
This commit is contained in:
@@ -22,6 +22,7 @@ class Store extends HD_Controller
|
||||
$this->load->library('bizAccount');
|
||||
$this->load->helper('db');
|
||||
$this->load->model('auto/auto_brand_model');
|
||||
$this->load->model('biz/biz_car_brand_model');
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -73,10 +74,10 @@ class Store extends HD_Controller
|
||||
$count = $this->biz_model->count($where);
|
||||
$bizlists = [];
|
||||
$account = new BizAccount();
|
||||
$brandAry = $this->auto_brand_model->select(['status>'=>0], 'initial asc', 0, 0, 'id,name');
|
||||
if($biz_lists){
|
||||
$brandAry = $this->auto_brand_model->select(['status>' => 0], 'initial asc', 0, 0, 'id,name');
|
||||
if ($biz_lists) {
|
||||
$map = [];
|
||||
foreach($brandAry as $item) {
|
||||
foreach ($brandAry as $item) {
|
||||
$map[$item['id']] = null !== $item['name'] ? $item['name'] : '';
|
||||
}
|
||||
foreach ($biz_lists as $v) {
|
||||
@@ -118,6 +119,14 @@ class Store extends HD_Controller
|
||||
$biz['avatar'] = build_qiniu_image_url($biz['headimg'], 200, 200);
|
||||
$biz['car_brand_id'] = $biz['car_brand_id'] ? intval($biz['car_brand_id']) : '';
|
||||
|
||||
$carBrands = $this->biz_car_brand_model->select(['biz_id' => $id], '', '', 'brand_id');
|
||||
$carBrandsIds = [];
|
||||
if ($carBrands) {
|
||||
foreach ($carBrands as $item) {
|
||||
$carBrandsIds[] = intval($item['brand_id']);
|
||||
}
|
||||
}
|
||||
$biz['car_brand_ids'] = $carBrandsIds;
|
||||
$this->data['biz'] = $biz;
|
||||
} else {
|
||||
$map_city = $this->city_ary();
|
||||
@@ -145,7 +154,7 @@ class Store extends HD_Controller
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
$car_brand_ids = $this->input->post('car_brand_ids');
|
||||
$biz['status'] = 1;
|
||||
$biz['biz_name'] = $this->input->post('biz_name', true);
|
||||
if (!$biz['biz_name']) {
|
||||
@@ -176,7 +185,17 @@ class Store extends HD_Controller
|
||||
if (!$id) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
|
||||
if (is_array($car_brand_ids)) {
|
||||
$carBrandData = [];
|
||||
foreach ($car_brand_ids as $item) {
|
||||
$carBrandData[] = [
|
||||
'biz_id' => $id,
|
||||
'brand_id' => $item,
|
||||
'c_time' => time()
|
||||
];
|
||||
}
|
||||
$carBrandData && $this->biz_car_brand_model->replace_batch($carBrandData);
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
@@ -188,7 +207,7 @@ class Store extends HD_Controller
|
||||
$id = intval($this->input->post('id'));
|
||||
$company_id = intval($this->input->post('company_id', true));
|
||||
$srv_company_id = intval($this->input->post('srv_company_id', true));
|
||||
|
||||
$car_brand_ids = $this->input->post('car_brand_ids');
|
||||
$biz['biz_name'] = $this->input->post('biz_name', true);
|
||||
if (!$biz['biz_name']) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '门店不能为空');
|
||||
@@ -215,7 +234,19 @@ class Store extends HD_Controller
|
||||
if (!$res) {
|
||||
return $this->show_json(SYS_CODE_FAIL, '添加失败');
|
||||
}
|
||||
|
||||
if (is_array($car_brand_ids)) {
|
||||
$carBrandData = [];
|
||||
foreach ($car_brand_ids as $item) {
|
||||
$carBrandData[] = [
|
||||
'biz_id' => $id,
|
||||
'brand_id' => $item,
|
||||
'c_time' => time()
|
||||
];
|
||||
}
|
||||
$carBrandData && $this->biz_car_brand_model->replace_batch($carBrandData);
|
||||
} else {
|
||||
$this->biz_car_brand_model->delete(['biz_id' => $id]);
|
||||
}
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '操作成功');
|
||||
}
|
||||
|
||||
|
||||
@@ -135,14 +135,15 @@
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">门店:</label>
|
||||
<div class="am-para-input"><input type="text" placeholder="(最多 30 个字符)" name="biz_name"
|
||||
value="<?= $biz['biz_name'] ?>"/></div>
|
||||
v-model="info.biz_name"/></div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">门店地址:</label>
|
||||
<div class="am-para-input">
|
||||
<div class="am-form-inline">
|
||||
<div class="am-form-group">
|
||||
<select name="province_id" style="width: 200px;" data-toggle="next-select"
|
||||
<select name="province_id" v-model="info.province_id" style="width: 200px;"
|
||||
data-toggle="next-select"
|
||||
data-refurl="/common/area?key=city&id={value}&url=edit" data-next="#bd-hd-city">
|
||||
<option value="0">省份</option>
|
||||
<?php if ($provinces) {
|
||||
@@ -154,7 +155,8 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<select id="bd-hd-city" name="city_id" style="width: 200px;" data-toggle="next-select"
|
||||
<select id="bd-hd-city" name="city_id" v-model="info.city_id" style="width: 200px;"
|
||||
data-toggle="next-select"
|
||||
data-refurl="/common/area?key=county&id={value}" data-next="#bd-hd-county">
|
||||
<option value="0">城市</option>
|
||||
<?php if ($citys) {
|
||||
@@ -168,7 +170,7 @@
|
||||
<div class="am-form-group">
|
||||
<!--<select id="bd-hd-county" name="county_id" style="width: 200px;" data-toggle="next-select"-->
|
||||
<!-- data-refurl="/common/area?key=street&id={value}" data-next="#bd-hd-street">-->
|
||||
<select id="bd-hd-county" name="county_id" style="width: 200px;">
|
||||
<select id="bd-hd-county" name="county_id" v-model="info.county_id" style="width: 200px;">
|
||||
<option value="0">行政区</option>
|
||||
<?php if ($countys) {
|
||||
foreach ($countys as $value) { ?>
|
||||
@@ -179,7 +181,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group" style="display: none">
|
||||
<select id="bd-hd-street" name="street_id" style="width: 200px;">
|
||||
<select id="bd-hd-street" name="street_id" v-model="info.street_id" style="width: 200px;">
|
||||
<option value="0">街道/乡镇</option>
|
||||
<?php if ($street) {
|
||||
foreach ($street as $value) { ?>
|
||||
@@ -190,7 +192,7 @@
|
||||
</select>
|
||||
</div>
|
||||
<div class="am-form-group" style="display: none">
|
||||
<select name="area_id" style="width: 200px;" id="bd-hd-area">
|
||||
<select name="area_id" style="width: 200px;" v-model="info.area_id" id="bd-hd-area">
|
||||
<option value="0">商圈</option>
|
||||
<?php if ($areas) {
|
||||
foreach ($areas as $value) { ?>
|
||||
@@ -207,7 +209,7 @@
|
||||
<div class="am-para-input">
|
||||
<div class="am-input-group am-input-group-primary">
|
||||
<input type="text" placeholder="详细地址" id="address" name="address"
|
||||
value="<?= $biz['address'] ?>"/>
|
||||
v-model="info.address"/>
|
||||
<span class="am-input-group-btn">
|
||||
<button id="addr-btn" class="am-btn am-btn-primary" type="button"><span
|
||||
class="am-icon-search"></span></button>
|
||||
@@ -251,7 +253,7 @@
|
||||
|
||||
<input type="hidden" name="headimg"
|
||||
onchange="$(this).next('img').attr('src', $(this).data('srcs') || this.value)"
|
||||
value="<?= $biz['headimg'] ?>" class="layui-input">
|
||||
value="<?= $biz['headimg'] ?>" class="layui-input" id="biz_headimg">
|
||||
<img data-tips-image style="height:auto;max-height:32px;min-width:32px"
|
||||
src="<?= $biz['avatar'] ?>"/>
|
||||
</div>
|
||||
@@ -269,18 +271,29 @@
|
||||
<template v-if="info.type==5">
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">车型品牌:</label>
|
||||
<div class="am-para-input wp20">
|
||||
<div class="am-para-input wp40">
|
||||
<el-select name="car_brand_ids" style="width: 100%" v-model="info.car_brand_ids"
|
||||
placeholder="请选择" filterable clearable multiple sear>
|
||||
<el-option
|
||||
v-for="(v,i) in auto_brands"
|
||||
:key="v.id"
|
||||
:label="v.name"
|
||||
:value="v.id">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<!--
|
||||
<select name="car_brand_id" v-model="info.car_brand_id">
|
||||
<option v-for="(v,i) in auto_brands" :value="v.id">
|
||||
{{v.name}}
|
||||
</option>
|
||||
</select>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="am-form-group" style="margin-bottom: 2rem">
|
||||
<div class="am-para-input">
|
||||
<button class="am-btn am-btn-success" type="submit">提交</button>
|
||||
<button class="am-btn am-btn-success" type="button" @click="submit">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -390,7 +403,7 @@
|
||||
url: '/common/brands',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {status: 1,size:1000},
|
||||
data: {status: 1, size: 1000},
|
||||
beforeSend: function () {
|
||||
},
|
||||
success: function (data) {
|
||||
@@ -403,6 +416,26 @@
|
||||
layer.closeAll('loading');
|
||||
}
|
||||
});
|
||||
},
|
||||
submit() {
|
||||
let vm = this;
|
||||
let url = '/biz/store/store/edit';
|
||||
if (!this.info.id) {
|
||||
url = '/biz/store/store/add'
|
||||
}
|
||||
vm.info.headimg = $('#biz_headimg').val();
|
||||
vm.info.lng = $("#biz-edit-lng").val();
|
||||
vm.info.lat = $("#biz-edit-lat").val();
|
||||
console.log(vm.info)
|
||||
$.post(url, vm.info, function (result) {
|
||||
if (result.code) {
|
||||
layer.msg(result.msg, {time: 2000, icon: 1}, function () {
|
||||
$.form.reload();
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, {icon: 2});
|
||||
}
|
||||
}, 'json')
|
||||
}
|
||||
},
|
||||
created: function () {
|
||||
|
||||
@@ -75,8 +75,10 @@ class Common extends CI_Controller
|
||||
public function allBiz()
|
||||
{
|
||||
$this->load->model('biz/biz_model');
|
||||
$this->load->model('biz/biz_car_brand_model');
|
||||
$this->load->model('agent/auto_product_model');
|
||||
$this->biz_model->set_db('ssdb');
|
||||
$this->biz_car_brand_model->set_db('ssdb');
|
||||
$productId = intval($this->input->get('productId'));
|
||||
$types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE;
|
||||
$where = [
|
||||
@@ -85,7 +87,10 @@ class Common extends CI_Controller
|
||||
if ($productId) {
|
||||
$product = $this->auto_product_model->get(['id' => $productId]);
|
||||
$brandId = $product['brandId'] ?: 0;
|
||||
$where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
$brandBizList = $this->biz_car_brand_model->select(['brand_id' => $brandId], '', '', '', 'biz_id');
|
||||
$bizIdArray = array_column($brandBizList, 'biz_id');
|
||||
$bizIdString = $bizIdArray ? implode(',', $bizIdArray) : 0;
|
||||
$where["(id in ({$bizIdString}) and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
} else {
|
||||
$where["type in ({$types})"] = null;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,10 @@ class Common extends CI_Controller
|
||||
public function allBiz()
|
||||
{
|
||||
$this->load->model('biz/biz_model');
|
||||
$this->load->model('biz/biz_car_brand_model');
|
||||
$this->load->model('agent/auto_product_model');
|
||||
$this->biz_model->set_db('ssdb');
|
||||
$this->biz_car_brand_model->set_db('ssdb');
|
||||
$productId = intval($this->input->get('productId'));
|
||||
$types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE;
|
||||
$where = [
|
||||
@@ -88,7 +90,10 @@ class Common extends CI_Controller
|
||||
if ($productId) {
|
||||
$product = $this->auto_product_model->get(['id' => $productId]);
|
||||
$brandId = $product['brandId'] ?: 0;
|
||||
$where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
$brandBizList = $this->biz_car_brand_model->select(['brand_id' => $brandId], '', '', '', 'biz_id');
|
||||
$bizIdArray = array_column($brandBizList, 'biz_id');
|
||||
$bizIdString = $bizIdArray ? implode(',', $bizIdArray) : 0;
|
||||
$where["(id in ({$bizIdString}) and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
} else {
|
||||
$where["type in ({$types})"] = null;
|
||||
}
|
||||
|
||||
@@ -78,8 +78,10 @@ class Common extends CI_Controller
|
||||
public function allBiz()
|
||||
{
|
||||
$this->load->model('biz/biz_model');
|
||||
$this->load->model('biz/biz_car_brand_model');
|
||||
$this->load->model('agent/auto_product_model');
|
||||
$this->biz_model->set_db('ssdb');
|
||||
$this->biz_car_brand_model->set_db('ssdb');
|
||||
$productId = intval($this->input->get('productId'));
|
||||
$types = Biz_model::BIZ_TYPE_4s . ',' . Biz_model::BIZ_TYPE_SPACE;
|
||||
$where = [
|
||||
@@ -88,7 +90,10 @@ class Common extends CI_Controller
|
||||
if ($productId) {
|
||||
$product = $this->auto_product_model->get(['id' => $productId]);
|
||||
$brandId = $product['brandId'] ?: 0;
|
||||
$where["(car_brand_id={$brandId} and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
$brandBizList = $this->biz_car_brand_model->select(['brand_id' => $brandId], '', '', '', 'biz_id');
|
||||
$bizIdArray = array_column($brandBizList, 'biz_id');
|
||||
$bizIdString = $bizIdArray ? implode(',', $bizIdArray) : 0;
|
||||
$where["(id in ({$bizIdString}) and type=" . Biz_model::BIZ_TYPE_4s . " or type=" . Biz_model::BIZ_TYPE_SPACE . ")"] = null;
|
||||
} else {
|
||||
$where["type in ({$types})"] = null;
|
||||
}
|
||||
@@ -168,7 +173,7 @@ class Common extends CI_Controller
|
||||
$children[$key]['children'] = [];
|
||||
}
|
||||
}
|
||||
if($newChildren){
|
||||
if ($newChildren) {
|
||||
$resList[] = [
|
||||
'value' => $item['value'],
|
||||
'label' => $item['label'],
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Biz_car_brand_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_biz_car_brand';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user