liche update for admin company manger
This commit is contained in:
@@ -46,6 +46,9 @@ class Brand extends HD_Controller
|
||||
public function get()
|
||||
{
|
||||
$id = $this->input->get('id');
|
||||
|
||||
$this->load->model("sys/sys_company_model", 'company_model');
|
||||
|
||||
if ($id) {
|
||||
$info = $this->bizBrand->get(array('id' => $id));
|
||||
if (!$info || empty($info)) {
|
||||
@@ -53,13 +56,20 @@ class Brand extends HD_Controller
|
||||
}
|
||||
$action = '/biz/brand/brand/edit';
|
||||
} else {
|
||||
$info = array('type' => 0);
|
||||
$info = array('type' => 0, 'company_id' => 0);
|
||||
$action = '/biz/brand/brand/add';
|
||||
}
|
||||
|
||||
//获取公司ID列表
|
||||
$where = array('status' => 1);
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title';
|
||||
$map_company = $this->company_model->map('id', 'title', $where, $orderby, 0, 0, $select);
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['action'] = $action;
|
||||
$this->data['typeAry'] = $this->bizBrand->type_ary();
|
||||
$this->data['companyAry'] = $map_company;
|
||||
$this->data['_title'] = $id ? '编辑品牌' : '新增品牌';
|
||||
return $this->show_view('biz/brand/edit');
|
||||
}
|
||||
@@ -102,6 +112,7 @@ class Brand extends HD_Controller
|
||||
'brand_name' => $brand_name,
|
||||
'brand_logo' => $img,
|
||||
'type' => intval($type),
|
||||
'company_id' => intval($info['company_id']),
|
||||
'c_time' => time()
|
||||
);
|
||||
$brand_id = $this->bizBrand->add($add_brand_data);
|
||||
@@ -139,6 +150,7 @@ class Brand extends HD_Controller
|
||||
'brand_name' => $brand_name,
|
||||
'brand_logo' => $img,
|
||||
'type' => intval($type),
|
||||
'company_id' => intval($info['company_id']),
|
||||
);
|
||||
$this->bizBrand->update($add_brand_data, array('id' => $id));
|
||||
return $this->show_json(SYS_CODE_SUCCESS, '保存成功');
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/7/29
|
||||
* Time: 17:38
|
||||
*/
|
||||
class Company extends HD_Controller{
|
||||
|
||||
protected $log_dir;
|
||||
|
||||
function __construct(){
|
||||
parent::__construct();
|
||||
|
||||
$this->load->model("sys/sys_company_model", 'company_model');
|
||||
|
||||
$this->log_dir = 'sys_' . get_class($this);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
return $this->lists();
|
||||
}
|
||||
|
||||
public function lists(){
|
||||
$params = $this->input->get();
|
||||
|
||||
$where = array();
|
||||
if ($params['keyword']){
|
||||
$where["(title like '%{$params['keyword']}%' or short like '%{$params['keyword']}%')"] = null;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
$statusAry = $this->company_model->status_ary();
|
||||
|
||||
$count = $this->company_model->count($where);
|
||||
$lists = array();
|
||||
if($count){
|
||||
$orderby = 'id desc';
|
||||
$select = 'id, title, short, status';
|
||||
$rows = $this->company_model->select($where, $orderby, $page, $size, $select);
|
||||
foreach($rows as $k => $v){
|
||||
$lists[] = array(
|
||||
'id' => $v['id'],
|
||||
'title' => $v['title'],
|
||||
'short' => $v['short'],
|
||||
'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($count/$size),'curr'=>$page,'totle'=>$count);
|
||||
$this->data['_title'] = '公司管理';
|
||||
$this->show_view('sys/company/lists',true);
|
||||
}
|
||||
|
||||
public function get(){
|
||||
$id = $this->input->get('id');
|
||||
if($id){
|
||||
$row = $this->company_model->get(array('id' => $id));
|
||||
$info = array(
|
||||
'id' => $row['id'],
|
||||
'title' => $row['title'],
|
||||
'short' => $row['short'],
|
||||
'status' => $row['status'],
|
||||
);
|
||||
$action = '/sys/company/edit';
|
||||
$title = '编辑公司';
|
||||
} else {
|
||||
$info = array(
|
||||
'title' => '',
|
||||
'short' => '',
|
||||
'status' => 0,
|
||||
);
|
||||
$action = '/sys/company/add';
|
||||
$title = '新增公司';
|
||||
}
|
||||
|
||||
$this->data['info'] = $info;
|
||||
$this->data['action'] = $action;
|
||||
$this->data['statusAry'] = $this->company_model->status_ary();
|
||||
$this->data['_title'] = $title;
|
||||
$this->show_view('sys/company/get');
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司名称');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null);
|
||||
$count = $this->company_model->count($where);
|
||||
if($count>0){
|
||||
return $this->show_json(SYS_CODE_FAIL, '公司已存在');
|
||||
}
|
||||
|
||||
$add = array(
|
||||
'title' => $title,
|
||||
'short' => $info['short'] ? $info['short'] : '',
|
||||
'status' => intval($info['status'])
|
||||
);
|
||||
|
||||
$id = $this->company_model->add($add);
|
||||
if(!$id){
|
||||
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, '保存成功');
|
||||
}
|
||||
|
||||
public function edit(){
|
||||
$info = $this->input->post('info');
|
||||
$title = trim($info['title']);
|
||||
if(!$title){
|
||||
return $this->show_json(SYS_CODE_FAIL, '请输入公司名称');
|
||||
}
|
||||
|
||||
$where = array("title like '{$title}'" => null, "id<>{$info['id']}" => null);
|
||||
$count = $this->company_model->count($where);
|
||||
if($count>0){
|
||||
return $this->show_json(SYS_CODE_FAIL, '公司已存在');
|
||||
}
|
||||
|
||||
$upd = array(
|
||||
'title' => $title,
|
||||
'short' => $info['short'] ? $info['short'] : '',
|
||||
'status' => intval($info['status'])
|
||||
);
|
||||
|
||||
$ret = $this->company_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->company_model->update($upd, $where);
|
||||
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, '保存成功');
|
||||
}
|
||||
|
||||
public function del(){
|
||||
// TODO: Implement del() method.
|
||||
}
|
||||
|
||||
public function batch(){
|
||||
// TODO: Implement batch() method.
|
||||
}
|
||||
|
||||
public function export(){
|
||||
// TODO: Implement export() method.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,13 +24,22 @@
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">类型:</label>
|
||||
<div class="am-para-input wp20">
|
||||
<div class="am-para-input wp50">
|
||||
<select name="type" v-model="info.type">
|
||||
<option value="0">选择类型</option>
|
||||
<option v-for="(v,i) in typeAry" :value="i">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label">公司:</label>
|
||||
<div class="am-para-input wp60">
|
||||
<select name="type" v-model="info.company_id">
|
||||
<option value="0">选择公司</option>
|
||||
<option v-for="(v,i) in companyAry" :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>
|
||||
@@ -53,6 +62,7 @@
|
||||
vm.info = <?=json_encode($info)?>;
|
||||
vm.action = '<?=$action?>';
|
||||
vm.typeAry = <?=json_encode($typeAry)?>;
|
||||
vm.companyAry = <?=json_encode($companyAry)?>;
|
||||
},
|
||||
methods:{
|
||||
saveEdit:function(){
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<th width="15%"><span>城市ID</span></th>
|
||||
<th width="15%"><span>城市名称</span></th>
|
||||
<th width="10%"><span>操作</span></th>
|
||||
<th width=""><span class="mr10">区域</span><button data-title="保存" type="button" class="am-btn am-btn-success am-btn-xs" @click="save_area">保存</button></th>
|
||||
<th width=""><span>区域</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -37,14 +37,17 @@
|
||||
<a data-ajax="post" data-action="/sys/city/city/del" :data-params-id="v.id" class="am-btn am-btn-danger am-btn-xs">删除</a>
|
||||
</td>
|
||||
<td style="text-align: left">
|
||||
<span class="mr20">
|
||||
<input type="checkbox" v-model="v.checked" @change="set_city(i)"/>全选
|
||||
</span>
|
||||
<span class="mr5" v-for="(county, j) in v.countys">
|
||||
<input type="checkbox" v-model="county.checked" @change="set_area(i)"/>{{county.county_name}}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"></td>
|
||||
<td style="text-align: left">
|
||||
<button data-title="保存" type="button" class="am-btn am-btn-success am-btn-xs" @click="save_area">保存区域设置</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<form id="vue-edit" class="am-form am-form-horizontal" action="/sys/city/city/add" 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"><input type="text" placeholder="请输入公司简称" name="short" v-model="info.short"/></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.statusAry = <?=json_encode($statusAry)?>;
|
||||
vm.action = '<?=$action?>';
|
||||
},
|
||||
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,89 @@
|
||||
|
||||
<div class="coms-table-wrap">
|
||||
<div class="coms-table-hd clearfix no-border">
|
||||
<form action="/sys/company/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="keyword" id="input" placeholder="输入名称或者简称关键字" v-model="params.keyword"/>
|
||||
</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="/sys/company/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=""><span>操作</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(v,i) in lists">
|
||||
<td>{{v.id}}</td>
|
||||
<td>{{v.title}}</td>
|
||||
<td>{{v.short}}</td>
|
||||
<td>{{v.status_name}}</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" :data-modal="'sys/company/get?id='+v.id"
|
||||
class="am-btn am-btn-primary am-btn-xs">编辑</a>
|
||||
<a data-ajax="post" data-action="/sys/company/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/company/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:[]
|
||||
},
|
||||
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>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
/**
|
||||
* 公司
|
||||
* Created by PhpStorm.
|
||||
* User: xuxb
|
||||
* Date: 2021/7/29
|
||||
* Time: 17:32
|
||||
*/
|
||||
class Sys_company_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_sys_company';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->table_name, 'default');
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态
|
||||
* @return array
|
||||
*/
|
||||
function status_ary(){
|
||||
$statusAry = array(/*'-1' => '删除',*/ '0' => '关闭', '1' => '开启');
|
||||
|
||||
return $statusAry;
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -40,7 +40,8 @@ create table lc_biz_brand (
|
||||
u_time timestamp not null default current_timestamp on update current_timestamp,
|
||||
primary key (id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='品牌表';
|
||||
alter table lc_biz_brand add column type tinyint(1) not null default 0 comment '类型:1-直营店,2-二网,3-合作店' after brand_logo;
|
||||
alter table lc_biz_brand add column type tinyint(1) not null default 0 comment '类型:1-直营店,2-二网,3-合作店' after brand_logo;
|
||||
alter table lc_biz_brand add column company_id int not null default 0 comment '公司ID' after type;
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:商家标签关系
|
||||
|
||||
+17
@@ -187,3 +187,20 @@ create table lc_sys_tag_category (
|
||||
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='系统标签分类表';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Title:公司管理
|
||||
-- Author:xusir
|
||||
-- Table:lc_sys_company
|
||||
-- ---------------------------
|
||||
drop table if exists lc_sys_company;
|
||||
create table lc_sys_company (
|
||||
id int(10) unsigned not null auto_increment comment '自增id',
|
||||
title varchar(64) not null comment '公司名称',
|
||||
short varchar(32) not null default '' 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='公司管理';
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user