运营补单
This commit is contained in:
parent
b40fb65203
commit
1cf64baf95
241
application/admin/controller/supplement/Orders.php
Normal file
241
application/admin/controller/supplement/Orders.php
Normal file
|
|
@ -0,0 +1,241 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller\supplement;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 补单记录管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Orders extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Orders模型对象
|
||||
* @var \app\admin\model\supplement\Orders
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $sources = null;
|
||||
protected $items = null;
|
||||
protected $itemsformattedTree = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\supplement\Orders;
|
||||
|
||||
|
||||
$sources = Db::name('source')
|
||||
->where('status', 1)
|
||||
->field(['id', 'title', 'key_word', 'pid'])
|
||||
->order('pid', 'asc')
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
$this->sources = $sources;
|
||||
$filtered = array_filter($sources, function ($item) {
|
||||
return $item['pid'] == 0;
|
||||
});
|
||||
|
||||
$pid_map = array_column($filtered, null, 'id');
|
||||
$res = [];
|
||||
foreach ($sources as $item) {
|
||||
if ($item['pid'] != 0 && isset($pid_map[$item['pid']])) {
|
||||
$res [] = [
|
||||
...$item, 'ptitle' => $pid_map[$item['pid']]['title']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$items = Db::name('item')
|
||||
->where('status', 1)
|
||||
->field(['id', 'title', 'key_word', 'pid'])
|
||||
->order('pid', 'asc')
|
||||
->order('sort', 'desc')
|
||||
->select();
|
||||
$tree = $this->buildTree($items);
|
||||
$formattedTree = $this->formatTree($tree);
|
||||
|
||||
$this->items = $items;
|
||||
$this->itemsformattedTree = $formattedTree;
|
||||
|
||||
|
||||
$this->view->assign("sources", $res);
|
||||
$this->view->assign("items", $formattedTree);
|
||||
|
||||
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//设置过滤方法
|
||||
$this->request->filter(['strip_tags', 'trim']);
|
||||
if (false === $this->request->isAjax()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
//如果发送的来源是 Selectpage,则转发到 Selectpage
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
|
||||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->with(['user' => function ($q) {
|
||||
$q->field('id,nickname');
|
||||
},
|
||||
'area' => function ($q) {
|
||||
$q->field('id,area_code,merge_name');
|
||||
},
|
||||
])
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
return $this->view->fetch();
|
||||
}
|
||||
$params = $this->request->post('row/a');
|
||||
if (empty($params)) {
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$params = $this->preExcludeFields($params);
|
||||
|
||||
if ($this->dataLimit && $this->dataLimitFieldAutoFill) {
|
||||
$params[$this->dataLimitField] = $this->auth->id;
|
||||
}
|
||||
$result = false;
|
||||
Db::startTrans();
|
||||
try {
|
||||
//是否采用模型验证
|
||||
if ($this->modelValidate) {
|
||||
$name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
||||
$validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
||||
$this->model->validateFailException()->validate($validate);
|
||||
}
|
||||
|
||||
$sources = $this->sources;
|
||||
$sources = array_column($sources, 'title', 'id');
|
||||
$params['source_name'] = $sources[$params['source']] ?? null;
|
||||
$params['source_id'] = $params['source'];
|
||||
|
||||
$params['item_name'] = $this->findElementByValue($this->itemsformattedTree, $params['item_id'] ?? null);
|
||||
|
||||
|
||||
$params['admin_id'] = ($params['admin_id'] ?? -1) == -1 ? $this->auth->id : $params['admin_id'];
|
||||
if (empty($params['admin_id'])) {
|
||||
$params['admin_id'] = $this->auth->id;
|
||||
}
|
||||
$params['status'] = 0;
|
||||
$params['created_at'] = date('Y-m-d H:i:s');
|
||||
$params['updated_at'] = date('Y-m-d H:i:s');
|
||||
// dd($params);
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException | PDOException | Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if ($result === false) {
|
||||
$this->error(__('No rows were inserted'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
|
||||
function findElementByValue($data, $targetValue, $path = [])
|
||||
{
|
||||
foreach ($data as $item) {
|
||||
// 将当前节点的 label 添加到路径中
|
||||
$newPath = array_merge($path, [$item['label']]);
|
||||
|
||||
// 如果找到目标值,返回路径
|
||||
if ($item['value'] == $targetValue) {
|
||||
return implode(' / ', $newPath);
|
||||
}
|
||||
|
||||
// 如果当前节点有 children,递归搜索
|
||||
if (isset($item['children']) && is_array($item['children'])) {
|
||||
$result = $this->findElementByValue($item['children'], $targetValue, $newPath);
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null; // 如果找不到返回 null
|
||||
}
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
if (!$ids) {
|
||||
if (request()->isPost()) {
|
||||
$ids = input('id');
|
||||
if (!$ids) {
|
||||
$this->error('缺少订单ID');
|
||||
}
|
||||
} else {
|
||||
$this->error('缺少订单ID');
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前ID对应的订单信息
|
||||
$order = $this->model->get($ids);
|
||||
if (!$order) {
|
||||
$this->error('订单不存在');
|
||||
}
|
||||
|
||||
// 判断是否为POST请求,进行更新操作
|
||||
if (request()->isPost()) {
|
||||
// 获取表单提交的数据
|
||||
$params = input('post.row/a');
|
||||
|
||||
$sources = $this->sources;
|
||||
$sources = array_column($sources, 'title', 'id');
|
||||
$params['source_name'] = $sources[$params['source']] ?? null;
|
||||
$params['source_id'] = $params['source'];
|
||||
|
||||
$params['item_name'] = $this->findElementByValue($this->itemsformattedTree, $params['item_id'] ?? null);
|
||||
|
||||
unset($params['source']);
|
||||
|
||||
$params['admin_id'] = ($params['admin_id'] ?? -1) == -1 ? $this->auth->id : $params['admin_id'];
|
||||
if (empty($params['admin_id'])) {
|
||||
$params['admin_id'] = $this->auth->id;
|
||||
}
|
||||
$params['updated_at'] = date('Y-m-d H:i:s');
|
||||
// 更新订单信息
|
||||
$order->save($params);
|
||||
|
||||
// 返回成功信息
|
||||
$this->success('更新成功', 'index');
|
||||
}
|
||||
$area = new \app\admin\model\Area();
|
||||
$area_name = $area->getNameByCode($order->area_id);
|
||||
$order->area_name = str_replace(',', '/', $area_name);
|
||||
|
||||
// 将订单数据传递到视图
|
||||
$this->assign('row', $order);
|
||||
// 渲染编辑页面
|
||||
return $this->fetch();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
27
application/admin/lang/zh-cn/supplement/orders.php
Normal file
27
application/admin/lang/zh-cn/supplement/orders.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'Id' => 'ID',
|
||||
'Area_id' => '区域 ID',
|
||||
'Area_name' => '地址',
|
||||
'Source_id' => '所属店铺 ID',
|
||||
'Source_name' => '所属店铺 ID',
|
||||
'Platform_order_no' => '平台订单编号',
|
||||
'Item_id' => '服务类型 ID',
|
||||
'Item_name' => '服务类型 ID',
|
||||
'Buyer_account' => '刷手账号',
|
||||
'Amount' => '支付金额',
|
||||
'Commission' => '刷单佣金',
|
||||
'Screenshots' => '截图 JSON(下单图、评价图等)',
|
||||
'Status' => '订单状态',
|
||||
'Status 0' => '待发货',
|
||||
'Set status to 0' => '设为待发货',
|
||||
'Status 1' => '待评价',
|
||||
'Set status to 1' => '设为待评价',
|
||||
'Status 2' => '评价超时',
|
||||
'Set status to 2' => '设为评价超时',
|
||||
'Admin_id' => '运营人员 ID',
|
||||
'Remark' => '备注信息',
|
||||
'Created_at' => '创建时间',
|
||||
'Updated_at' => '最后更新时间'
|
||||
];
|
||||
51
application/admin/model/supplement/Orders.php
Normal file
51
application/admin/model/supplement/Orders.php
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model\supplement;
|
||||
|
||||
use app\admin\model\Admin;
|
||||
use app\admin\model\Area;
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Orders extends Model
|
||||
{
|
||||
|
||||
// 表名
|
||||
protected $name = 'supplement_orders';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = false;
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['0' => __('Status 0'), '1' => __('Status 1'), '2' => __('Status 2'), '3' => '被驳回'];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
public function area(){
|
||||
return $this->belongsTo(Area::class,'area_id','area_code');
|
||||
}
|
||||
public function user(){
|
||||
return $this->belongsTo(Admin::class,'admin_id');
|
||||
}
|
||||
|
||||
}
|
||||
27
application/admin/validate/supplement/Orders.php
Normal file
27
application/admin/validate/supplement/Orders.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\validate\supplement;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Orders extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
||||
98
application/admin/view/supplement/orders/add.html
Normal file
98
application/admin/view/supplement/orders/add.html
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">店铺:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[source]" class="form-control selectpicker show-tick">
|
||||
{foreach $sources as $item}
|
||||
<option data-subtext="{$item['ptitle']}" value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">区域:</label>
|
||||
<div class='col-xs-12 col-sm-8'>
|
||||
<input id="c-city" data-rule="required" class="form-control" data-toggle="city-picker" type="text" value="" />
|
||||
<input id="area_id" style="display: none" class="form-control" name="row[area_id]" hidden type="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Platform_order_no')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-platform_order_no" data-rule="required" class="form-control" name="row[platform_order_no]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务类型:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input type="text" id="item_id" class="zd-input__inner">
|
||||
<input type="text" id="item_id_value" style="display: none" name="row[item_id]" class="zd-input__inner">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Buyer_account')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-buyer_account" data-rule="required" class="form-control" name="row[buyer_account]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Amount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-amount" data-rule="required" class="form-control" step="0.01" name="row[amount]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Commission')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-commission" data-rule="required" class="form-control" step="0.01" name="row[commission]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">图片:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-images" class="form-control" size="50" name="row[screenshots]" type="text">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-images"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-images"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" class="form-control " rows="5" name="row[remark]" cols="50"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<link rel="stylesheet" href="/assets/css/select.css">
|
||||
|
||||
<script>
|
||||
var items = {:json_encode($items); };
|
||||
</script>
|
||||
98
application/admin/view/supplement/orders/edit.html
Normal file
98
application/admin/view/supplement/orders/edit.html
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">店铺:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<select id="c-source" data-live-search="true" title="请选择" data-rule="required" name="row[source]" class="form-control selectpicker show-tick">
|
||||
{foreach $sources as $item}
|
||||
<option {if $item['id'] == $row.source_id} selected {/if} data-subtext="{$item['ptitle']}" value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">区域:</label>
|
||||
<div class='col-xs-12 col-sm-8'>
|
||||
<input id="c-city" value="{$row.area_name}" data-rule="required" class="form-control" data-toggle="city-picker" type="text" value="" />
|
||||
<input id="area_id" value="{$row.area_id}" style="display: none" class="form-control" name="row[area_id]" hidden type="text" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Platform_order_no')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-platform_order_no" value="{$row.platform_order_no}" data-rule="required" class="form-control" name="row[platform_order_no]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">服务类型:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input type="text" id="item_id" value="{$row.item_name}" data-value="{$row.item_name}" class="zd-input__inner">
|
||||
<input type="text" id="item_id_value" value="{$row.item_id}" style="display: none" name="row[item_id]" class="zd-input__inner">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Buyer_account')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-buyer_account" value="{$row.buyer_account}" data-rule="required" class="form-control" name="row[buyer_account]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Amount')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-amount" data-rule="required" value="{$row.amount}" class="form-control" step="0.01" name="row[amount]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Commission')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-commission" data-rule="required" value="{$row.commission}" class="form-control" step="0.01" name="row[commission]" type="number" value="0.00">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">图片:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-images" class="form-control" size="50" name="row[screenshots]" type="text">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="faupload-images" class="btn btn-danger faupload" data-input-id="c-images" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="true" data-preview-id="p-images"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-images" class="btn btn-primary fachoose" data-input-id="c-images" data-mimetype="image/*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-images"></span>
|
||||
</div>
|
||||
<ul class="row list-inline faupload-preview" id="p-images"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<div class="radio">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<label for="row[status]-{$key}"><input id="row[status]-{$key}" name="row[status]" type="radio" value="{$key}" {in name="key" value="0"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" value="{$row.remark}" class="form-control " rows="5" name="row[remark]" cols="50"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<link rel="stylesheet" href="/assets/css/select.css">
|
||||
|
||||
<script>
|
||||
var items = {:json_encode($items); };
|
||||
</script>
|
||||
46
application/admin/view/supplement/orders/index.html
Normal file
46
application/admin/view/supplement/orders/index.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<div class="panel panel-default panel-intro">
|
||||
|
||||
<div class="panel-heading">
|
||||
{:build_heading(null,FALSE)}
|
||||
<ul class="nav nav-tabs" data-field="status">
|
||||
<li class="{:$Think.get.status === null ? 'active' : ''}"><a href="#t-all" data-value="" data-toggle="tab">{:__('All')}</a></li>
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li class="{:$Think.get.status === (string)$key ? 'active' : ''}"><a href="#t-{$key}" data-value="{$key}" data-toggle="tab">{$vo}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="panel-body">
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="one">
|
||||
<div class="widget-body no-padding">
|
||||
<div id="toolbar" class="toolbar">
|
||||
<a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
|
||||
<a href="javascript:;" class="btn btn-success btn-add {:$auth->check('supplement/orders/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
|
||||
<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('supplement/orders/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
|
||||
<a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('supplement/orders/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('supplement/orders/multi')?'':'hide'}">
|
||||
<a class="btn btn-primary btn-more dropdown-toggle btn-disabled disabled" data-toggle="dropdown"><i class="fa fa-cog"></i> {:__('More')}</a>
|
||||
<ul class="dropdown-menu text-left" role="menu">
|
||||
{foreach name="statusList" item="vo"}
|
||||
<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:" data-params="status={$key}">{:__('Set status to ' . $key)}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
|
||||
data-operate-edit="{:$auth->check('supplement/orders/edit')}"
|
||||
data-operate-del="{:$auth->check('supplement/orders/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -110,7 +110,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function
|
|||
{field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
|
||||
{field: 'customer', title: __('Customer'), operate: 'LIKE'},
|
||||
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
|
||||
{field: 'area.merge_name', title: __('Area_id')},
|
||||
{field: 'area.merge_name', title: __('Area_id'),searchable:false},
|
||||
{
|
||||
field: 'address',
|
||||
title: __('Address'),
|
||||
|
|
|
|||
134
public/assets/js/backend/supplement/orders.js
Normal file
134
public/assets/js/backend/supplement/orders.js
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form','cascader'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
index_url: 'supplement/orders/index' + location.search,
|
||||
add_url: 'supplement/orders/add',
|
||||
edit_url: 'supplement/orders/edit',
|
||||
del_url: 'supplement/orders/del',
|
||||
multi_url: 'supplement/orders/multi',
|
||||
import_url: 'supplement/orders/import',
|
||||
table: 'supplement_orders',
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
pk: 'id',
|
||||
sortName: 'id',
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'user.nickname', title: '创建人'},
|
||||
{field: 'area.merge_name', title: '地区',searchable:false},
|
||||
{field: 'item_name', title: __('Item_name')},
|
||||
{field: 'source_name', title: __('Source_name')},
|
||||
{field: 'platform_order_no', title: __('Platform_order_no'), operate: 'LIKE'},
|
||||
{field: 'buyer_account', title: __('Buyer_account'), operate: 'LIKE'},
|
||||
{field: 'amount', title: __('Amount'), operate:'BETWEEN'},
|
||||
{field: 'commission', title: __('Commission'), operate:'BETWEEN'},
|
||||
{field: 'screenshots', title: '图片', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
|
||||
{field: 'created_at', title: __('Created_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'updated_at', title: __('Updated_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
||||
]
|
||||
]
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
Controller.api.map();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
Controller.api.map();
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
},
|
||||
map:function () {
|
||||
$("#c-city").on("cp:updated", function () {
|
||||
var citypicker = $(this).data("citypicker");
|
||||
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
||||
|
||||
$("#area_id").val(code);
|
||||
$("#area_name").val(citypicker.getVal());
|
||||
});
|
||||
// $("#area_map").data("callback", function (res) {
|
||||
// Form.api.target($('#c-address'));
|
||||
// });
|
||||
$(document).on('click', "#area_map", function (e) {
|
||||
const data = $("#c-city").val();
|
||||
if (!data){
|
||||
Toastr.error('请先选择区域');
|
||||
return false;
|
||||
}
|
||||
|
||||
var that = this;
|
||||
var callback = $(that).data('callback');
|
||||
var input_id = $(that).data("input-id") ? $(that).data("input-id") : "";
|
||||
var lat_id = $(that).data("lat-id") ? $(that).data("lat-id") : "";
|
||||
var lng_id = $(that).data("lng-id") ? $(that).data("lng-id") : "";
|
||||
var zoom_id = $(that).data("zoom-id") ? $(that).data("zoom-id") : "";
|
||||
var lat = lat_id ? $("#" + lat_id).val() : '';
|
||||
var lng = lng_id ? $("#" + lng_id).val() : '';
|
||||
var city_code = $("#c-city").val();
|
||||
var zoom = zoom_id ? $("#" + zoom_id).val() : '';
|
||||
var url = "/addons/address/index/select?a=1";
|
||||
url += (lat && lng) ? 'lat=' + lat + '&lng=' + lng +
|
||||
(input_id ? "&address=" + $("#" + input_id).val() : "")
|
||||
+(zoom ? "&zoom=" + zoom : "") : ''
|
||||
;
|
||||
if (city_code){
|
||||
url += city_code ? "&city_code=" + city_code : "";
|
||||
}
|
||||
// console.log(url);
|
||||
Fast.api.open(url, '位置选择', {
|
||||
callback: function (res) {
|
||||
input_id && $("#" + input_id).val(res.address).trigger("change");
|
||||
lat_id && $("#" + lat_id).val(res.lat).trigger("change");
|
||||
lng_id && $("#" + lng_id).val(res.lng).trigger("change");
|
||||
zoom_id && $("#" + zoom_id).val(res.zoom).trigger("change");
|
||||
|
||||
try {
|
||||
//执行回调函数
|
||||
if (typeof callback === 'function') {
|
||||
callback.call(that, res);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
var _data = items;
|
||||
|
||||
$('#item_id').zdCascader({
|
||||
data: _data,
|
||||
onChange: function ($this, data, allPathData) {
|
||||
// console.log(data,allPathData);
|
||||
$('#item_id_value').val(data.value);
|
||||
}
|
||||
});
|
||||
$('#item_id').val($('#item_id').data('value')).focus();
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user