mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
修改快递公司管理
This commit is contained in:
parent
f7b7ff982f
commit
a85c63c7f9
@ -5,6 +5,7 @@ namespace app\data\controller\base\postage;
|
||||
use app\data\model\BasePostageCompany;
|
||||
use app\data\service\ExpressService;
|
||||
use think\admin\Controller;
|
||||
use think\admin\helper\QueryHelper;
|
||||
use think\exception\HttpResponseException;
|
||||
|
||||
/**
|
||||
@ -24,18 +25,13 @@ class Company extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->title = '快递公司管理';
|
||||
|
||||
// 加载对应数据
|
||||
$map = ['deleted' => 0];
|
||||
$this->type = input('get.type', 'index');
|
||||
if ($this->type === 'index') $map['status'] = 1;
|
||||
if ($this->type === 'recycle') $map['status'] = 0;
|
||||
|
||||
// 列表显示分页
|
||||
$query = BasePostageCompany::mQuery();
|
||||
$query->like('name,code')->equal('status')->dateBetween('craete_at');
|
||||
$query->where($map)->order('sort desc,id desc')->page();
|
||||
BasePostageCompany::mQuery()->layTable(function () {
|
||||
$this->title = '快递公司管理';
|
||||
}, function (QueryHelper $query) {
|
||||
$query->where(['deleted' => 0, 'status' => intval($this->type === 'index')]);
|
||||
$query->like('name,code_1|code_3#code')->equal('status')->dateBetween('create_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -58,6 +54,20 @@ class Company extends Controller
|
||||
BasePostageCompany::mForm('form');
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步字段编号
|
||||
* @param array $data
|
||||
* @return void
|
||||
*/
|
||||
protected function _form_filter(array &$data)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
if (empty($data['code_2'])) {
|
||||
$data['code_2'] = $data['code_3'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改快递公司状态
|
||||
* @auth true
|
||||
@ -89,7 +99,11 @@ class Company extends Controller
|
||||
$result = ExpressService::instance()->company();
|
||||
if (empty($result['code'])) $this->error($result['info']);
|
||||
foreach ($result['data'] as $vo) BasePostageCompany::mUpdate([
|
||||
'code_1' => $vo['code_1'], 'code_2' => $vo['code_2'], 'code_3' => $vo['code_3'], 'name' => $vo['title'], 'deleted' => 0,
|
||||
'name' => $vo['title'],
|
||||
'code_1' => $vo['code_1'],
|
||||
'code_2' => $vo['code_2'],
|
||||
'code_3' => $vo['code_3'],
|
||||
'deleted' => 0,
|
||||
], 'code_1');
|
||||
$this->success('同步快递公司成功!');
|
||||
} catch (HttpResponseException $exception) {
|
||||
|
@ -11,5 +11,13 @@ use think\admin\Model;
|
||||
*/
|
||||
class BasePostageCompany extends Model
|
||||
{
|
||||
|
||||
/**
|
||||
* 格式化创建时间
|
||||
* @param string $value
|
||||
* @return string
|
||||
*/
|
||||
public function getCreateAtAttr(string $value): string
|
||||
{
|
||||
return format_datetime($value);
|
||||
}
|
||||
}
|
@ -1,29 +1,29 @@
|
||||
<form action="{:sysuri()}" autocomplete="off" class='layui-form layui-card' data-auto="true" method="post" onsubmit="return false;">
|
||||
<form action="{:sysuri()}" class='layui-form layui-card' data-auto="true" data-table-id="DataTable" method="post">
|
||||
|
||||
<div class="layui-card-body padding-left-40">
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<span class="help-label"><b>快递公司名称</b>Name</span>
|
||||
<input class="layui-input" name="name" placeholder="请输入快递公司名称" required value='{$vo.name|default=""}'>
|
||||
<p class="color-desc">必填,快递公司名称用于显示快递配送的公司标识,请尽量保持其精准性。</p>
|
||||
<span class="color-desc">必填,快递公司名称用于显示快递配送的公司标识,请尽量保持其精准性。</span>
|
||||
</label>
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<span class="help-label"><b>快递鸟接口查询编码</b>Code01</span>
|
||||
<input class="layui-input" name="code_1" placeholder="请输入快递鸟接口查询编码" required value='{$vo.code_1|default=""}'>
|
||||
<p class="color-desc">必填,快递公司对应在快递鸟接口的编码,可以从快递鸟官方接口文档中获取到。</p>
|
||||
<span class="color-desc">必填,快递公司对应在快递鸟接口的编码,可以从快递鸟官方接口文档中获取到。</span>
|
||||
</label>
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<label class="layui-form-item layui-hide">
|
||||
<span class="help-label"><b>快递100百度查询编码</b>Code02</span>
|
||||
<input class="layui-input" name="code_2" placeholder="请输入快递100百度查询编码" value='{$vo.code_2|default=""}'>
|
||||
<p class="color-desc">可选,快递公司在百度快递100应用程序搜索时使用的编码,需要使用网络模拟请求抓取。</p>
|
||||
<span class="color-desc">可选,快递公司在百度快递100应用程序搜索时使用的编码,需要使用网络模拟请求抓取。</span>
|
||||
</label>
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
<span class="help-label"><b>快递100接口查询编码</b>Code03</span>
|
||||
<input class="layui-input" name="code_3" placeholder="请输入快递100接口查询编码" value='{$vo.code_3|default=""}'>
|
||||
<p class="color-desc">必填,快递公司对应在快递100接口的编码,可以从快递100官方接口文档中获取到。</p>
|
||||
<input class="layui-input" name="code_3" placeholder="请输入快递100接口查询编码" required value='{$vo.code_3|default=""}'>
|
||||
<span class="color-desc">必填,快递公司对应在快递100接口的编码,可以从快递100官方接口文档中获取到。</span>
|
||||
</label>
|
||||
|
||||
<label class="layui-form-item block relative">
|
||||
|
@ -1,4 +1,4 @@
|
||||
{extend name="../../admin/view/main"}
|
||||
{extend name="../../admin/view/table"}
|
||||
|
||||
{block name="button"}
|
||||
<!--{if auth("sync") and $type eq 'index'}-->
|
||||
@ -10,15 +10,15 @@
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("state") and $type eq 'index'}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("state")}' data-confirm="确定要禁用快递公司?" data-rule="id#{key};status#0">批量禁用</button>
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="DataTable" data-action='{:url("state")}' data-rule="id#{id};status#0">批量禁用</button>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("state") and $type eq 'recycle'}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("state")}' data-rule="id#{key};status#1">批量启用</button>
|
||||
<!--{if auth("state") and $type neq 'index'}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="DataTable" data-action='{:url("state")}' data-rule="id#{id};status#1">批量启用</button>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove") and $type eq 'recycle'}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-action='{:url("remove")}' data-csrf="{:systoken('remove')}" data-rule="id#{key}">批量删除</button>
|
||||
<!--{if auth("remove") and $type neq 'index'}-->
|
||||
<button class='layui-btn layui-btn-sm layui-btn-primary' data-table-id="DataTable" data-action='{:url("remove")}' data-rule="id#{id}">批量删除</button>
|
||||
<!--{/if}-->
|
||||
{/block}
|
||||
|
||||
@ -34,59 +34,67 @@
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
{include file='base/postage/company/index_search'}
|
||||
<table class="layui-table" lay-skin="line">
|
||||
{notempty name='list'}
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='list-table-check-td think-checkbox'>
|
||||
<label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
|
||||
</th>
|
||||
<th class='list-table-sort-td'>
|
||||
<button class="layui-btn layui-btn-xs" data-reload type="button">刷 新</button>
|
||||
</th>
|
||||
<th class='text-left nowrap'>快递名称</th>
|
||||
<th class='text-center nowrap'>快递鸟接口编码</th>
|
||||
<th class='text-center nowrap'>快递100百度编码</th>
|
||||
<th class='text-center nowrap'>快递100接口编码</th>
|
||||
<th class="text-center">创建时间</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
{/notempty}
|
||||
<tbody>
|
||||
{foreach $list as $key=>$vo}
|
||||
<tr data-dbclick>
|
||||
<td class='list-table-check-td think-checkbox'>
|
||||
<label><input class="list-check-box" type='checkbox' value='{$vo.id}'></label>
|
||||
</td>
|
||||
<td class='list-table-sort-td'>
|
||||
<label><input class="list-sort-input" data-action-blur="{:sysuri()}" data-loading="false" data-value="id#{$vo.id};action#sort;sort#{value}" value="{$vo.sort}"></label>
|
||||
</td>
|
||||
<td class='text-left nowrap'>{$vo.name|default=''}</td>
|
||||
<td class='text-center nowrap'>{$vo.code_1|default='-'}</td>
|
||||
<td class='text-center nowrap'>{$vo.code_2|default='-'}</td>
|
||||
<td class='text-center nowrap'>{$vo.code_3|default='-'}</td>
|
||||
<td class='text-center nowrap'>{$vo.create_at|format_datetime}</td>
|
||||
<td class='text-left nowrap'>
|
||||
<!--{if auth("edit") and $type eq 'index'}-->
|
||||
<a class="layui-btn layui-btn-sm" data-dbclick data-modal='{:url("edit")}?id={$vo.id}' data-title="编辑快递公司">编 辑</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if $vo.status eq 1 and auth("state")}-->
|
||||
<a class="layui-btn layui-btn-warm layui-btn-sm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0">禁 用</a>
|
||||
<!--{elseif auth("state")}-->
|
||||
<a class="layui-btn layui-btn-warm layui-btn-sm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1">激 活</a>
|
||||
<!--{/if}-->
|
||||
|
||||
<!--{if auth("remove") and $type eq 'recycle'}-->
|
||||
<a class="layui-btn layui-btn-danger layui-btn-sm" data-action="{:url('remove')}" data-confirm="确定要删除数据吗?" data-value="id#{$vo.id}">删 除</a>
|
||||
<!--{/if}-->
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
|
||||
<table id="DataTable" data-url="{:sysuri()}" data-target-search="form.form-search"></table>
|
||||
</div>
|
||||
</div>
|
||||
{/block}
|
||||
|
||||
|
||||
{block name='script'}
|
||||
<script>
|
||||
$(function () {
|
||||
$('#DataTable').layTable({
|
||||
even: true, height: 'full',
|
||||
sort: {field: 'sort desc,id', type: 'desc'},
|
||||
where: {type: '{$type|default="index"}'},
|
||||
cols: [[
|
||||
{checkbox: true},
|
||||
{field: 'sort', title: '排序权重', width: 100, align: 'center', sort: true, templet: '#SortInputTpl'},
|
||||
{field: 'code_1', title: '快递鸟编码', align: "left", minWidth: 100},
|
||||
{field: 'code_3', title: '快递100编码', align: "left", minWidth: 100},
|
||||
{field: 'name', title: '公司名称', align: "left", minWidth: 100},
|
||||
{field: 'status', title: '使用状态', align: 'center', minWidth: 110, templet: '#StatusSwitchTpl'},
|
||||
{field: 'create_at', title: '添加时间', align: 'center', minWidth: 170},
|
||||
{toolbar: '#toolbar', title: '操作面板', align: 'center', fixed: 'right'}
|
||||
]]
|
||||
});
|
||||
|
||||
// 数据状态切换操作
|
||||
layui.form.on('switch(StatusSwitch)', function (obj, data) {
|
||||
data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
|
||||
$.form.load("{:url('state')}", data, 'post', function (ret) {
|
||||
if (ret.code < 1) $.msg.error(ret.info, 3, function () {
|
||||
$('#DataTable').trigger('reload');
|
||||
}); else {
|
||||
$('#DataTable').trigger('reload');
|
||||
}
|
||||
return false;
|
||||
}, false);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- 排序权重模板 -->
|
||||
<script type="text/html" id="SortInputTpl">
|
||||
<input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}" data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}" class="layui-input text-center">
|
||||
</script>
|
||||
|
||||
<!-- 状态切换模板 -->
|
||||
<script type="text/html" id="StatusSwitchTpl">
|
||||
<!--{if auth("state")}-->
|
||||
<input type="checkbox" value="{{d.id}}" lay-skin="switch" lay-text="已激活|已禁用" lay-filter="StatusSwitch" {{d.status>0?'checked':''}}>
|
||||
<!--{else}-->
|
||||
{{d.status ? '<b class="color-red">已激活</b>' : '<b class="color-green">已禁用</b>'}}
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
|
||||
<!-- 操作面板模板 -->
|
||||
<script type="text/html" id="toolbar">
|
||||
<!--{if auth("edit") and $type eq 'index'}-->
|
||||
<a class="layui-btn layui-btn-sm" data-modal="{:url('edit')}?id={{d.id}}" data-title="编辑快递公司">编 辑</a>
|
||||
<!--{/if}-->
|
||||
<!--{if auth("remove") and $type neq 'index'}-->
|
||||
<a class="layui-btn layui-btn-sm layui-btn-danger" data-action="{:url('remove')}" data-value="id#{{d.id}}" data-confirm="确定要删除该用户吗?">删 除</a>
|
||||
<!--{/if}-->
|
||||
</script>
|
||||
{/block}
|
@ -1,6 +1,6 @@
|
||||
<fieldset>
|
||||
<legend>条件搜索</legend>
|
||||
<form action="{:url('index')}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">
|
||||
<form action="{:sysuri()}" autocomplete="off" class="layui-form layui-form-pane form-search" method="get" onsubmit="return false">
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label">快递名称</label>
|
||||
<label class="layui-input-inline">
|
||||
|
Loading…
x
Reference in New Issue
Block a user