liche update for admin auto and goods edit

This commit is contained in:
xxb
2021-08-20 20:25:48 +08:00
committed by xiaoyu
parent a5fc02b073
commit 5a759d2919
18 changed files with 944 additions and 30 deletions
+11 -5
View File
@@ -1401,14 +1401,20 @@ class Common extends CI_Controller
$v_id = $this->input->post('v_id');
$cor_id = $this->input->post('cor_id');
$incor_id = $this->input->post('incor_id');
$vin = $this->input->post('vin');
$page = $this->input->post('page') ? intval($this->input->post('page')) : 1;
$size = $this->input->post('size') ? intval($this->input->post('size')) : 10;
$where = "status=1 ";
$brand_id && $where .= " and brand_id=$brand_id";
$s_id && $where .= " and s_id=$s_id";
$v_id && $where .= " and v_id=$v_id";
$cor_id && $where .= " and cor_id=$cor_id";
$incor_id && $where .= " and incor_id=$incor_id";
if($vin){
$where .= " and vin='{$vin}'";
} else {
$brand_id && $where .= " and brand_id=$brand_id";
$s_id && $where .= " and s_id=$s_id";
$v_id && $where .= " and v_id=$v_id";
$cor_id && $where .= " and cor_id=$cor_id";
$incor_id && $where .= " and incor_id=$incor_id";
}
if ($select_id) {
$fhwhere = [
"($where) or (id=$select_id)" => null
+23
View File
@@ -27,10 +27,32 @@ class Attr extends HD_Controller{
$size = 20;
$where["status > -1"] = null;
$params['title'] && $where["title like '%{$params['title']}%'"] = null;
if($params['s_id']){
$where['s_id'] = $params['s_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){
$sery_ids = array_column($rows_sery, 'id');
$str_ids = implode(',', $sery_ids);
$where["s_id in ({$str_ids})"] = null;
} else {
$where['s_id'] = -1;
}
}
!$params['s_id'] && $params['s_id'] = '';
!$params['brand_id'] && $params['brand_id'] = '';
$count = $this->auto_attr_model->count($where);
$rows = $this->auto_attr_model->select($where, 'id desc', $page, $size);
$type_arr = $this->auto_attr_model->get_type();
$status_arr = $this->auto_brand_model->get_status();
//获取品牌map
$where_brand = array('status > -1' => null);
$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');
@@ -48,6 +70,7 @@ class Attr extends HD_Controller{
}
$this->data['lists'] = $list;
$this->data['params'] = $params;
$this->data['brandAry'] = $map_brand;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$this->data['_title'] = '属性管理';
$this->show_view('auto/attr/lists', true);
+27
View File
@@ -316,4 +316,31 @@ class Cars extends HD_Controller{
// TODO: Implement export() method.
}
/**
* 获取车型库信息
* @return bool
*/
function json_get(){
$brand_id = $this->input->post('brand_id');
$s_id = $this->input->post('s_id');
$attrs = $this->input->post('attrs');
$where = array(
'status' => 1,
'brand_id' => $brand_id,
's_id' => $s_id,
'attrs' => $attrs
);
$row = $this->auto_cars_model->get($where);
$data = array(
'id' => $row['id'],
'price_car' => $row['price_car']
);
$this->data = $data;
return $this->show_json(SYS_CODE_SUCCESS);
}
}
+12 -3
View File
@@ -26,15 +26,23 @@ class Series extends HD_Controller{
$size = 20;
$where["status > -1"] = null;
$params['title'] && $where["name like '%{$params['title']}%'"] = null;
if($params['brand_id']){
$where['brand_id'] = $params['brand_id'];
} else {
$params['brand_id'] = '';
}
$count = $this->auto_series_model->count($where);
$rows = $this->auto_series_model->select($where, 'id desc', $page, $size);
$status_arr = $this->auto_series_model->get_status();
$list = [];
//获取品牌map
$where_brand = array('status > -1' => null);
$map_brand = $this->auto_brand_model->map('id', 'name', $where_brand, 'id desc', 0 , 0, 'id, name');
if($rows){
$brand_arr = array_column($rows,'brand_id');
$brand_rows = $this->auto_brand_model->get_map_by_ids($brand_arr,'id,name');
foreach($rows as $key=>$val){
$brand_name = $brand_rows[$val['brand_id']] ? $brand_rows[$val['brand_id']][0]['name'] : '';
$brand_name = $map_brand[$val['brand_id']] ? $map_brand[$val['brand_id']] : '';
$list[] = [
'id' => $val['id'],
'brand_name' => $brand_name,
@@ -47,6 +55,7 @@ class Series extends HD_Controller{
}
$this->data['lists'] = $list;
$this->data['params'] = $params;
$this->data['brandAry'] = $map_brand;
$this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count);
$this->data['_title'] = '车系列表';
$this->show_view('auto/series/lists', true);
+19
View File
@@ -109,9 +109,24 @@ class Goods extends HD_Controller
$autoList[4] = $this->mdAutoAttr->select(array('type' => 0, 's_id' => $re['s_id']), 'id desc', 0, 0, 'id,title as name');
$autoList[5] = $this->mdAutoAttr->select(array('type' => 2, 's_id' => $re['s_id']), 'id desc', 0, 0, 'id,title as name');
}
if($info['addr_id']){
$this->load->model("sys/sys_addr_model", 'addr_model');
$row_addr = $this->addr_model->get(array('id' => $info['addr_id']));
$info['city_id'] = $row_addr['city_id'];
$info['county_id'] = $row_addr['county_id'];
} else {
$info['city_id'] = '';
$info['county_id'] = '';
$info['addr_id'] = '';
}
$_title = '编辑商品';
$edit_url = '/items/goods/goods/edit';
} else {
$info['city_id'] = '';
$info['county_id'] = '';
$info['addr_id'] = '';
$_title = '新增商品';
$edit_url = '/items/goods/goods/add';
}
@@ -209,6 +224,8 @@ class Goods extends HD_Controller
$addData['out_time'] = $info['out_time'] ? $info['out_time'] : '0000-00-00 00:00:00';
$addData['bill_time'] = $info['bill_time'] ? $info['bill_time'] : '0000-00-00 00:00:00';
$addData['c_time'] = time();
//存货地址
$addData['addr_id'] = $info['addr_id'] ? $info['addr_id'] : 0;
$id = $this->mdItems->add($addData);
if (!$id) {
return $this->show_json(SYS_CODE_FAIL, '添加失败!');
@@ -248,6 +265,8 @@ class Goods extends HD_Controller
$editData['p_time'] = $info['p_time'];
$editData['out_time'] = $info['out_time'];
$editData['bill_time'] = $info['bill_time'];
//存货地址
$editData['addr_id'] = $info['addr_id'] ? $info['addr_id'] : 0;
$ret = $this->mdItems->update($editData, array('id' => $info['id']));
if (!$ret) {
return $this->show_json(SYS_CODE_FAIL, '修改失败!');
+281
View File
@@ -0,0 +1,281 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2021/8/20
* Time: 17:46
*/
class Addr extends HD_Controller{
protected $log_dir;
function __construct(){
parent::__construct();
$this->load->model("sys/sys_addr_model", 'addr_model');
$this->load->model("area_model");
$this->log_dir = 'sys_' . get_class($this);
}
public function index(){
return $this->lists();
}
public function lists(){
$params = $this->input->get();
$page = $params['page'];
$page = !$page ? 1 : $page;
$size = $params['size'];
$size = !$size ? 20 : $size;
$where = array('province_id' => '350');
if($params['title']){
$where["title like '%{$params['title']}%'"] = null;
}
if($params['city_id']){
$where['city_id'] = $params['city_id'];
} else {
$params['city_id'] = '';
}
if($params['county_id']){
$where['county_id'] = $params['county_id'];
} else {
$params['county_id'] = '';
}
if(strlen($params['status'])>0){
$where['status'] = $params['status'];
} else {
$where['status>-1'] = null;
$params['status'] = '';
}
$total = $this->addr_model->count($where);
$lists = array();
if($total){
$orderby = 'id desc';
$select = 'id, title, city_name, county_name, status';
$rows = $this->addr_model->select($where, $orderby, $page, $size, $select);
foreach($rows as $v){
$lists[] = array(
'id' => $v['id'],
'title' => $v['title'],
'city_name' => $v['city_name'],
'county_name' => $v['county_name'],
'status' => $v['status'],
'status_name' => 1 == $v['status'] ? '开启' : '停用',
);
}
}
$this->data['params'] = $params;
$this->data['lists'] = $lists;
$this->data['pager'] = array('count'=>ceil($total/$size),'curr'=>$page,'totle'=>$total);
$this->data['_title'] = '地址管理';
$this->show_view('sys/addr/lists',true);
}
function json_lists(){
$params = $this->input->get();
$page = $params['page'];
$size = $params['size'];
$where = array('province_id' => '350');
if($params['title']){
$where["title like '%{$params['title']}%'"] = null;
}
if($params['city_id']){
$where['city_id'] = $params['city_id'];
} else {
$params['city_id'] = '';
}
if($params['county_id']){
$where['county_id'] = $params['county_id'];
} else {
$params['county_id'] = '';
}
if(strlen($params['status'])>0){
$where['status'] = $params['status'];
} else {
$where['status>-1'] = null;
$params['status'] = '';
}
$total = $this->addr_model->count($where);
$lists = array();
if($total){
$orderby = 'id desc';
$select = 'id, title';
$rows = $this->addr_model->select($where, $orderby, $page, $size, $select);
foreach($rows as $v){
$lists[] = array(
'id' => $v['id'],
'title' => $v['title'],
);
}
}
$this->data['lists'] = $lists;
$this->data['total'] = $total;
return $this->show_json(SYS_CODE_SUCCESS);
}
public function get(){
$id = $this->input->get('id');
if($id){
$row = $this->addr_model->get(array('id' => $id));
$info = array(
'id' => $row['id'],
'title' => $row['title'],
'city_id' => $row['city_id'],
'county_id' => $row['county_id'],
);
$action = '/sys/addr/edit';
$title = '编辑地址';
} else {
$info = array(
'title' => '',
'city_id' => '',
'county_id' => '',
);
$action = '/sys/addr/add';
$title = '新增地址';
}
$this->data['info'] = $info;
$this->data['action'] = $action;
$this->data['_title'] = $title;
$this->show_view('sys/addr/get');
}
public function add(){
$info = $this->input->post('info');
$title = trim($info['title']);
$city_id = $info['city_id'];
$county_id = $info['county_id'];
if(!$title){
return $this->show_json(SYS_CODE_FAIL, '请输入地址');
}
if(!$city_id){
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
if(!$county_id){
return $this->show_json(SYS_CODE_FAIL, '请选行政区');
}
$where = array("title like '{$title}'" => null);
$count = $this->addr_model->count($where);
if($count>0){
return $this->show_json(SYS_CODE_FAIL, '地址已存在');
}
//获取行政区信息
$where = array('county_id' => $county_id);
$row_area = $this->area_model->get($where);
if(!$row_area){
return $this->show_json(SYS_CODE_FAIL, '行政区不存在');
}
$add = array(
'title' => $title,
'province_id' => $row_area['province_id'],
'province_name' => $row_area['province_name'],
'city_id' => $row_area['city_id'],
'city_name' => $row_area['city_name'],
'county_id' => $row_area['county_id'],
'county_name' => $row_area['county_name'],
'status' => 1
);
$ret = $this->addr_model->add($add);
if(!$ret){
debug_log("[error]# " . $this->addr_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');
$title = trim($info['title']);
$city_id = $info['city_id'];
$county_id = $info['county_id'];
if(!$title){
return $this->show_json(SYS_CODE_FAIL, '请输入地址');
}
if(!$city_id){
return $this->show_json(SYS_CODE_FAIL, '请选择城市');
}
if(!$county_id){
return $this->show_json(SYS_CODE_FAIL, '请选行政区');
}
$where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
$count = $this->addr_model->count($where);
if($count>0){
return $this->show_json(SYS_CODE_FAIL, '地址已存在');
}
//获取行政区信息
$where = array('county_id' => $county_id);
$row_area = $this->area_model->get($where);
if(!$row_area){
return $this->show_json(SYS_CODE_FAIL, '行政区不存在');
}
$upd = array(
'title' => $title,
'province_id' => $row_area['province_id'],
'province_name' => $row_area['province_name'],
'city_id' => $row_area['city_id'],
'city_name' => $row_area['city_name'],
'county_id' => $row_area['county_id'],
'county_name' => $row_area['county_name'],
);
$ret = $this->addr_model->update($upd, array('id' => $info['id']));
if(!$ret){
debug_log("[error]# " . $this->company_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->addr_model->update($upd, $where);
if(!$ret){
debug_log("[error]# " . $this->addr_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.
}
}
+75
View File
@@ -7,6 +7,24 @@
<input type="text" name="title" value="<?=$params['title'] ?>"/>
</div>
</div>
<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 ml10">
<button type="submit" class="am-btn am-btn-success w100">搜索</button>
</div>
@@ -55,5 +73,62 @@
</div>
</div>
</div>
<script>
var vue_obj;
var loading = 0;
$(function(){
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params:[],
brandAry:[],
seryAry:[]
},
mounted:function() {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.brandAry = <?=json_encode($brandAry)?>;
},
methods:{},
watch:{
'params.brand_id':function(nv, ov){
var vm = this;
vm.seryAry = {};
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;
if(vm.params.s_id>0 && undefined == seryAry[vm.params.s_id]){
vm.params.s_id = '';
}
}
},
complete: function () {
loading = 0;
layer.closeAll('loading');
}
});
} else {
vm.params.s_id = '';
}
}
}
});
});
<?php page_script($pager) ?>
</script>
+5 -1
View File
@@ -214,7 +214,6 @@
'params.brand_id':function(nv, ov){
var vm = this;
vm.seryAry = {};
vm.params.s_id = '';
if(nv > 0){
$.ajax({
url: '/auto/series/json_lists',
@@ -231,6 +230,9 @@
seryAry[row.id] = row.name;
}
vm.seryAry = seryAry;
if(vm.params.s_id>0 && undefined == seryAry[vm.params.s_id]){
vm.params.s_id = '';
}
}
},
complete: function () {
@@ -238,6 +240,8 @@
layer.closeAll('loading');
}
});
} else {
vm.params.s_id = '';
}
}
}
+31
View File
@@ -7,6 +7,15 @@
<input type="text" name="title" value="<?=$params['title'] ?>"/>
</div>
</div>
<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 ml10">
<button type="submit" class="am-btn am-btn-success w100">搜索</button>
</div>
@@ -61,5 +70,27 @@
</div>
</div>
</div>
<script>
var vue_obj;
var loading = 0;
$(function(){
vue_obj = new Vue({
el: '.coms-table-wrap',
data: {
params:[],
brandAry:[]
},
mounted:function() {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.brandAry = <?=json_encode($brandAry)?>;
},
methods:{},
watch:{}
});
});
<?php page_script($pager) ?>
</script>
+130 -14
View File
@@ -34,8 +34,7 @@
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">车型</div>
<select style="width: 200px;"
v-model="info.v_id">
<select style="width: 200px;" v-model="info.v_id" @change="set_attr">
<option value="0">选择车型</option>
<template v-for="(v,i) in showInfo['autoList'][3]">
<option :value="v.id">{{v.name}}</option>
@@ -45,17 +44,10 @@
</td>
</tr>
<tr>
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">精品加装</div>
<input type="text" v-model="info.if_pack" placeholder="请输入精品加装">
</div>
</td>
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">车身色</div>
<select style="width: 200px;"
v-model="info.cor_id">
<select style="width: 200px;" v-model="info.cor_id" @change="set_attr">
<option value="0">选择车身色</option>
<template v-for="(v,i) in showInfo['autoList'][4]">
<option :value="v.id">{{v.name}}</option>
@@ -66,8 +58,7 @@
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">内饰色</div>
<select style="width: 200px;"
v-model="info.incor_id">
<select style="width: 200px;" v-model="info.incor_id" @change="set_attr">
<option value="0">选择内饰色</option>
<template v-for="(v,i) in showInfo['autoList'][5]">
<option :value="v.id">{{v.name}}</option>
@@ -75,6 +66,12 @@
</select>
</div>
</td>
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">精品加装</div>
<input type="text" v-model="info.if_pack" placeholder="请输入精品加装">
</div>
</td>
</tr>
<tr>
<td class="table-td">
@@ -90,8 +87,19 @@
</td>
<td class="table-td" colspan="2">
<div class="input-group">
<div class="input-group-addon">送货地址</div>
<input type="text" v-model="info.address" placeholder="请输入送货地址">
<div class="input-group-addon">存放地址</div>
<select title="城市" style="display: inline;width: 20%" name="" v-model="info.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
<select title="行政区" name="county_id" style="display: inline;width: 20%" v-model="info.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</option>
</select>
<select title="地址" name="addr_id" style="display: inline;width: 60%" v-model="info.addr_id">
<option value="">选择地址</option>
<option :value="v.id" v-for="(v,i) in addrAry">{{v.title}}</option>
</select>
</div>
</td>
</tr>
@@ -213,11 +221,15 @@
data: {
info: {},
showInfo: {'autoList': []},
cityAry:[],
countyAry:[],
addrAry:[]
},
mounted: function () {
var that = this;
that.info = <?=json_encode($info)?>;
that.showInfo = <?=json_encode($showInfo)?>;
that.init_citys();
},
computed: {},
created: function () {
@@ -328,6 +340,110 @@
},
});
},
set_attr:function(){
var vm = this;
if(parseFloat(vm.info.ori_price) > 0){
//价格为空才联动获取裸车价
return;
}
if(vm.info.v_id > 0 && vm.info.cor_id>0 && vm.info.incor_id>0){
var attrs = vm.info.cor_id+'_'+ vm.info.v_id + '_' + vm.info.incor_id;
$.ajax({
url: '/auto/cars/json_get',
type: 'post',
dataType: 'json',
data: {
brand_id: vm.info.brand_id,
s_id: vm.info.s_id,
attrs: attrs
},
success: function (res) {
if (res.data) {
vm.info.ori_price = res.data.price_car;
vm.$forceUpdate();
}
}
});
}
},
init_citys:function() {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
}
});
}
},
watch:{
'info.city_id':function(nv, ov){
var that = this;
if(nv == ''){
that.countyAry = [];
that.info.county_id = '';
} else {
if(nv.substring(0,4) != that.info.county_id.substring(0, 4)){
that.info.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key:'county',
type:1
},
success:function(response){
if (response.code == 1) {
that.countyAry = response.data;
}
}
});
}
},
'info.county_id':function(nv, ov){
var that = this;
if(nv == ''){
that.addrAry = [];
that.info.addr_id = '';
} else {
$.ajax({
type: 'get',
url: '/sys/addr/json_lists',
dataType: 'json',
data: {
county_id: nv,
status:1
},
success:function(response){
if (response.code == 1) {
that.addrAry = response.data.lists;
if(that.info.addr_id>0){
var addr_id = '';
for(var i in that.addrAry){
if(that.info.addr_id == thayt.addrAry[i].id){
addr_id = that.info.addr_id;
break;
}
}
that.info.addr_id = addr_id;
}
}
}
});
}
}
}
});
});
+2 -3
View File
@@ -178,8 +178,8 @@
<tr>
<td class="table-td">
<div class="input-group">
<div class="input-group-addon">城市</div>
<select style="width: 120px; display: inline" v-model="info.city_id">
<div class="input-group-addon">地区</div>
<select class="mr5" style="width: 120px; display: inline" v-model="info.city_id">
<option value="">选择城市</option>
<template v-for="(v,i) in cityAry">
<option :value="v.id">{{v.name}}</option>
@@ -485,7 +485,6 @@
watch:{
'info.city_id':function(nv, ov){
var that = this;
console.log(that.info);
if(nv == ''){
that.countyAry = [];
that.info.county_id = '';
+5 -3
View File
@@ -115,9 +115,10 @@
s_id: '',
v_id: '',
cor_id: '',
incor_id: ''
incor_id: '',
vin:''
},
mounted() {
mounted:function() {
var that = this;
that.info = <?=json_encode($info, JSON_UNESCAPED_UNICODE)?>;
that.brand_id = <?=$info['brand_id']?>,
@@ -193,7 +194,8 @@
s_id: vm.s_id,
v_id: vm.v_id,
cor_id: vm.cor_id,
incor_id: vm.incor_id
incor_id: vm.incor_id,
vin:vm.vin
},
success: function (re) {
var carslist = re.data.list;
+6 -1
View File
@@ -181,7 +181,12 @@
</select>
</div>
</div>
<div class="am-form-group fl">
<label class="am-para-label" style="width:auto">车架号:</label>
<div class="am-para-inline w80">
<input type="text" v-model="vin" />
</div>
</div>
<div class="am-form-group fl">
<div class="am-form-group fl ml5">
<a href="javascript:;" @click="carModal" class="am-btn am-btn-success am-btn-sm w100">搜索</a>
+127
View File
@@ -0,0 +1,127 @@
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/addr/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 wp50">
<select style="display: inline;width: 45%" name="city_id" v-model="info.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
<select name="county_id" style="display: inline;width: 50%" v-model="info.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</option>
</select>
</div>
</div>
<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" 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:{},
cityAry:[],
countyAry:[],
action:''
},
mounted:function(){
var vm = this;
vm.info = <?=json_encode($info)?>;
vm.action = '<?=$action?>';
vm.init_citys();
},
methods:{
init_citys:function() {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
}
});
},
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.city_id':function(nv, ov){
var that = this;
if(nv == ''){
that.countyAry = [];
that.info.county_id = '';
} else {
if(nv.substring(0,4) != that.info.county_id.substring(0, 4)){
that.info.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key:'county',
type:1
},
success:function(response){
if (response.code == 1) {
that.countyAry = response.data;
}
}
});
}
}
}
});
});
</script>
+152
View File
@@ -0,0 +1,152 @@
<div class="coms-table-wrap">
<div class="coms-table-hd clearfix no-border">
<form action="/sys/addr/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 fl">
<div class="am-para-inline w200">
<select style="display: inline;width: 45%" name="city_id" v-model="params.city_id">
<option value="">选择城市</option>
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
</select>
<select style="display: inline;width: 50%" name="county_id" v-model="params.county_id">
<option value="">选择行政区</option>
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</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="/sys/addr/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="15%"><span>ID</span></th>
<th width="25%"><span>地址</span></th>
<th width="10%"><span>城市</span></th>
<th width="10%"><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.city_name}}</td>
<td>{{v.county_name}}</td>
<td>{{v.status_name}}</td>
<td>
<a href="javascript:void(0);" :data-modal="'sys/addr/get?id='+v.id"
class="am-btn am-btn-primary am-btn-xs">编辑</a>
<a data-ajax="post" data-action="/sys/addr/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="/sys/addr/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:[],
cityAry:[],
countyAry:[],
statusAry:{}
},
mounted:function() {
var vm = this;
vm.params = <?=json_encode($params)?>;
vm.lists = <?=json_encode($lists)?>;
vm.statusAry = {'0':'关闭', '1':'开启'};
vm.init_citys();
},
methods:{
init_citys:function() {
var vm = this;
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: '350',
key: 'city',
type: 1
},
success: function (response) {
if (response.code == 1) {
vm.cityAry = response.data;
}
}
});
}
},
watch:{
'params.city_id':function(nv, ov){
var that = this;
if(nv == ''){
that.countyAry = [];
that.params.county_id = '';
} else {
if(nv.substring(0,4) != that.params.county_id.substring(0, 4)){
that.params.county_id = '';
}
$.ajax({
type: 'get',
url: '/common/area',
dataType: 'json',
data: {
id: nv,
key:'county',
type:1
},
success:function(response){
if (response.code == 1) {
that.countyAry = response.data;
}
}
});
}
}
}
});
<?php page_script($pager) ?>
});
</script>
+16
View File
@@ -0,0 +1,16 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* Created by PhpStorm.
* User: xuxb
* Date: 2021/8/20
* Time: 17:43
*/
class Sys_addr_model extends HD_Model{
private $table_name = 'lc_sys_addr';
public function __construct()
{
parent::__construct($this->table_name, 'default');
}
}
+1
View File
@@ -35,4 +35,5 @@ create table lc_items (
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='商品表';
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;
+21
View File
@@ -228,3 +228,24 @@ create table lc_sys_finance (
primary key (id)
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='金融产品';
-- ----------------------------
-- Title:地址管理
-- Author:xusir
-- Table:lc_sys_addr
-- ---------------------------
drop table if exists lc_sys_addr;
create table lc_sys_addr (
id int(10) unsigned not null auto_increment comment '自增id',
title varchar(128) not null comment '公司名称',
province_id int(10) unsigned not null comment '省id',
province_name varchar(32) not null comment '省名称',
city_id int(10) unsigned not null comment '城市id',
city_name varchar(32) not null comment '城市名称',
county_id int(10) unsigned not null comment '区id',
county_name varchar(32) not null comment '区名称',
status tinyint(1) not null default '1' comment '状态:-1删除,0关闭,1开启',
primary key (id)
) ENGINE=INNODB DEFAULT CHARSET=UTF8MB4 COLLATE=UTF8MB4_0900_AI_CI COMMENT='地址管理';