mirror of
https://github.com/crmeb/CRMEB.git
synced 2025-12-16 14:22:48 +00:00
添加物流公司管理
This commit is contained in:
parent
4caf1e18cc
commit
8ffa1831d5
131
application/admin/controller/system/Express.php
Normal file
131
application/admin/controller/system/Express.php
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace app\admin\controller\system;
|
||||||
|
|
||||||
|
use service\FormBuilder as Form;
|
||||||
|
use service\UtilService as Util;
|
||||||
|
use service\JsonService as Json;
|
||||||
|
use think\Request;
|
||||||
|
use think\Url;
|
||||||
|
use app\admin\model\system\Express as ExpressModel;
|
||||||
|
use app\admin\controller\AuthController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 物流公司管理控制器
|
||||||
|
* Class SystemMenus
|
||||||
|
* @package app\admin\controller\system
|
||||||
|
*/
|
||||||
|
class Express extends AuthController
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示资源列表
|
||||||
|
*
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$params = Util::getMore([
|
||||||
|
['keyword','']
|
||||||
|
],$this->request);
|
||||||
|
$this->assign(ExpressModel::systemPage($params));
|
||||||
|
$this->assign(compact('params'));
|
||||||
|
return $this->fetch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示创建资源表单页.
|
||||||
|
*
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function create($cid = 0)
|
||||||
|
{
|
||||||
|
$formbuider = [
|
||||||
|
Form::input('name','公司名称')->required('公司名称名称必填'),
|
||||||
|
Form::input('code','编码'),
|
||||||
|
Form::number('sort','排序',0),
|
||||||
|
Form::radio('is_show','是否启用',1)->options([['value'=>0,'label'=>'隐藏'],['value'=>1,'label'=>'启用']]),
|
||||||
|
];
|
||||||
|
$form = Form::make_post_form('添加物流公司',$formbuider,Url::build('save'),2);
|
||||||
|
$this->assign(compact('form'));
|
||||||
|
return $this->fetch('public/form-builder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存新建的资源
|
||||||
|
*
|
||||||
|
* @param \think\Request $request
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function save(Request $request)
|
||||||
|
{
|
||||||
|
$data = Util::postMore([
|
||||||
|
'name',
|
||||||
|
'code',
|
||||||
|
['sort',0],
|
||||||
|
['is_show',0]],$request);
|
||||||
|
if(!$data['name']) return Json::fail('请输入公司名称');
|
||||||
|
ExpressModel::set($data);
|
||||||
|
return Json::successful('添加公司成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示编辑资源表单页.
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$menu = ExpressModel::get($id);
|
||||||
|
if(!$menu) return Json::fail('数据不存在!');
|
||||||
|
$formbuider = [
|
||||||
|
Form::input('name','公司名称',$menu['name']),
|
||||||
|
Form::input('code','编码',$menu['code']),
|
||||||
|
Form::number('sort','排序',$menu['sort']),
|
||||||
|
Form::radio('is_show','是否启用',$menu['is_show'])->options([['value'=>0,'label'=>'隐藏'],['value'=>1,'label'=>'启用']])
|
||||||
|
];
|
||||||
|
$form = Form::make_post_form('添加物流公司',$formbuider,Url::build('update',array('id'=>$id)),2);
|
||||||
|
$this->assign(compact('form'));
|
||||||
|
return $this->fetch('public/form-builder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存更新的资源
|
||||||
|
*
|
||||||
|
* @param \think\Request $request
|
||||||
|
* @param int $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$data = Util::postMore([
|
||||||
|
'name',
|
||||||
|
'code',
|
||||||
|
['sort',0],
|
||||||
|
['is_show',0]],$request);
|
||||||
|
if(!$data['name']) return Json::fail('请输入公司名称');
|
||||||
|
if(!ExpressModel::get($id)) return Json::fail('编辑的记录不存在!');
|
||||||
|
ExpressModel::edit($data,$id);
|
||||||
|
return Json::successful('修改成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除指定资源
|
||||||
|
*
|
||||||
|
* @param int $id
|
||||||
|
* @return \think\Response
|
||||||
|
*/
|
||||||
|
public function delete($id)
|
||||||
|
{
|
||||||
|
if(!$id) return $this->failed('参数错误,请重新打开');
|
||||||
|
$res = ExpressModel::destroy($id);
|
||||||
|
if(!$res)
|
||||||
|
return Json::fail(ExpressModel::getErrorInfo('删除失败,请稍候再试!'));
|
||||||
|
else
|
||||||
|
return Json::successful('删除成功!');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,53 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace app\admin\controller\system;
|
|
||||||
|
|
||||||
use app\admin\controller\AuthController;
|
|
||||||
use service\CacheService;
|
|
||||||
use service\JsonService as Json;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清除缓存
|
|
||||||
* Class Clear
|
|
||||||
* @package app\admin\controller
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
class systemClear extends AuthController
|
|
||||||
{
|
|
||||||
public function index()
|
|
||||||
{
|
|
||||||
return $this->fetch();
|
|
||||||
}
|
|
||||||
public function refresh_cache(){
|
|
||||||
`php think optimize:schema`;
|
|
||||||
`php think optimize:autoload`;
|
|
||||||
`php think optimize:route`;
|
|
||||||
`php think optimize:config`;
|
|
||||||
return Json::successful('数据缓存刷新成功!');
|
|
||||||
}
|
|
||||||
public function delete_cache(){
|
|
||||||
$this->delDirAndFile("./runtime/temp");
|
|
||||||
$this->delDirAndFile("./runtime/cache");
|
|
||||||
return Json::successful('清除缓存成功!');
|
|
||||||
}
|
|
||||||
public function delete_log(){
|
|
||||||
$this->delDirAndFile("./runtime/log");
|
|
||||||
return Json::successful('清除日志成功!');
|
|
||||||
}
|
|
||||||
function delDirAndFile($dirName,$subdir=true){
|
|
||||||
if ($handle = opendir("$dirName")){
|
|
||||||
while(false !== ($item = readdir($handle))){
|
|
||||||
if($item != "." && $item != ".."){
|
|
||||||
if(is_dir("$dirName/$item"))
|
|
||||||
$this->delDirAndFile("$dirName/$item",false);
|
|
||||||
else
|
|
||||||
@unlink("$dirName/$item");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($handle);
|
|
||||||
if(!$subdir) @rmdir($dirName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
27
application/admin/model/system/Express.php
Normal file
27
application/admin/model/system/Express.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author: xaboy<365615158@qq.com>
|
||||||
|
* @day: 2017/11/11
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace app\admin\model\system;
|
||||||
|
|
||||||
|
use traits\ModelTrait;
|
||||||
|
use basic\ModelBasic;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class SystemAdmin
|
||||||
|
* @package app\admin\model\system
|
||||||
|
*/
|
||||||
|
class Express extends ModelBasic
|
||||||
|
{
|
||||||
|
use ModelTrait;
|
||||||
|
public static function systemPage($params)
|
||||||
|
{
|
||||||
|
$model = new self;
|
||||||
|
if($params['keyword'] !== '') $model = $model->where('name|code','LIKE',"%$params[keyword]%");
|
||||||
|
$model = $model->order('sort DESC,id DESC');
|
||||||
|
return self::page($model,$params);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,23 +12,6 @@
|
|||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="m-b m-l">
|
<div class="m-b m-l">
|
||||||
<?php /* <form action="" class="form-inline">
|
|
||||||
<i class="fa fa-search" style="margin-right: 10px;"></i>
|
|
||||||
<select name="is_show" aria-controls="editable" class="form-control input-sm">
|
|
||||||
<option value="">是否显示</option>
|
|
||||||
<option value="1" {eq name="params.is_show" value="1"}selected="selected"{/eq}>显示</option>
|
|
||||||
<option value="0" {eq name="params.is_show" value="0"}selected="selected"{/eq}>不显示</option>
|
|
||||||
</select>
|
|
||||||
<select name="access" aria-controls="editable" class="form-control input-sm">
|
|
||||||
<option value="">子管理员是否可用</option>
|
|
||||||
<option value="1" {eq name="params.access" value="1"}selected="selected"{/eq}>可用</option>
|
|
||||||
<option value="0" {eq name="params.access" value="0"}selected="selected"{/eq}>不可用</option>
|
|
||||||
</select>
|
|
||||||
<div class="input-group">
|
|
||||||
<input type="text" name="keyword" value="{$params.keyword}" placeholder="请输入关键词" class="input-sm form-control"> <span class="input-group-btn">
|
|
||||||
<button type="submit" class="btn btn-sm btn-primary"> 搜索</button> </span>
|
|
||||||
</div>
|
|
||||||
</form> */ ?>
|
|
||||||
<form action="" class="form-inline">
|
<form action="" class="form-inline">
|
||||||
|
|
||||||
<select name="status" aria-controls="editable" class="form-control input-sm">
|
<select name="status" aria-controls="editable" class="form-control input-sm">
|
||||||
|
|||||||
91
application/admin/view/system/express/index.php
Normal file
91
application/admin/view/system/express/index.php
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
{extend name="public/container"}
|
||||||
|
{block name="content"}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="ibox">
|
||||||
|
<div class="ibox-title">
|
||||||
|
<button type="button" class="btn btn-w-m btn-primary" onclick="$eb.createModalFrame(this.innerText,'{:Url('create')}')">添加物流公司</button>
|
||||||
|
<div class="ibox-tools">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="ibox-content">
|
||||||
|
<div class="row">
|
||||||
|
<div class="m-b m-l">
|
||||||
|
<form action="" class="form-inline">
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<input type="text" name="keyword" value="{$params.keyword}" placeholder="请输入物流公司名称或者编码" class="input-sm form-control"> <span class="input-group-btn">
|
||||||
|
<button type="submit" class="btn btn-sm btn-primary"> <i class="fa fa-search" ></i>搜索</button> </span>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-striped table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<th class="text-center">编号</th>
|
||||||
|
<th class="text-center">物流公司名称</th>
|
||||||
|
<th class="text-center">编目</th>
|
||||||
|
<th class="text-center">排序</th>
|
||||||
|
<th class="text-center">状态</th>
|
||||||
|
<th class="text-center">操作</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="">
|
||||||
|
{volist name="list" id="vo"}
|
||||||
|
<tr>
|
||||||
|
<td class="text-center">
|
||||||
|
{$vo.id}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
{$vo.name}
|
||||||
|
</td>
|
||||||
|
<td class="text-center" >
|
||||||
|
{$vo.code}
|
||||||
|
</td>
|
||||||
|
<td class="text-center" >
|
||||||
|
{$vo.sort}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<i class="fa {eq name='vo.is_show' value='1'}fa-check text-navy{else/}fa-close text-danger{/eq}"></i>
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
<button class="btn btn-info btn-xs" type="button" onclick="$eb.createModalFrame('编辑','{:Url('edit',array('id'=>$vo['id']))}')"><i class="fa fa-paste"></i> 编辑</button>
|
||||||
|
<button class="btn btn-warning btn-xs" data-url="{:Url('delete',array('id'=>$vo['id']))}" type="button"><i class="fa fa-warning"></i> 删除
|
||||||
|
</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/volist}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
{include file="public/inner_page"}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/block}
|
||||||
|
{block name="script"}
|
||||||
|
<script>
|
||||||
|
$('.btn-warning').on('click',function(){
|
||||||
|
window.t = $(this);
|
||||||
|
var _this = $(this),url =_this.data('url');
|
||||||
|
$eb.$swal('delete',function(){
|
||||||
|
$eb.axios.get(url).then(function(res){
|
||||||
|
console.log(res);
|
||||||
|
if(res.status == 200 && res.data.code == 200) {
|
||||||
|
$eb.$swal('success',res.data.msg);
|
||||||
|
_this.parents('tr').remove();
|
||||||
|
}else
|
||||||
|
return Promise.reject(res.data.msg || '删除失败')
|
||||||
|
}).catch(function(err){
|
||||||
|
$eb.$swal('error',err);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{/block}
|
||||||
Loading…
x
Reference in New Issue
Block a user