店铺管理
This commit is contained in:
parent
60d4baae4e
commit
72523df3fa
|
|
@ -68,7 +68,7 @@ class Item extends Backend
|
|||
// dd($ruleList);
|
||||
$this->itemdata = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||
foreach ($this->itemdata as &$v) {
|
||||
$v['status'] = $v['status'] ?'normal' : 'aqua';
|
||||
$v['status'] = $v['status'] ?'normal' : 'hidden';
|
||||
}
|
||||
unset($v);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
|
@ -20,12 +21,40 @@ class Order extends Backend
|
|||
* @var \app\admin\model\Order
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
protected $sources = null;
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Order;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
|
||||
$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']
|
||||
];
|
||||
}
|
||||
}
|
||||
// dd($res);
|
||||
|
||||
// Tree::instance()->init($sources);
|
||||
// $data = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||
// dd($data);
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
$this->view->assign("sources", $res);
|
||||
//$this->view->assign("collectList", $this->model->getCollectList());
|
||||
//$this->view->assign("dispatchTypeList", $this->model->getDispatchTypeList());
|
||||
}
|
||||
|
|
@ -53,7 +82,7 @@ class Order extends Backend
|
|||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->field(['id','order_no','customer','tel','status','area_id','address',
|
||||
'source','source_uid','source','item_title','item_id',
|
||||
'source','source_shop','source_uid','source','item_title','item_id',
|
||||
'detail','remark','images','create_time','update_time'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
|
|
@ -86,7 +115,10 @@ class Order extends Backend
|
|||
$this->model->validateFailException()->validate($validate);
|
||||
}
|
||||
|
||||
$params['enter_admin_id'] = $this->auth->id;
|
||||
$sources = $this->sources;
|
||||
$sources = array_column($sources,'title','id');
|
||||
$params['source_shop'] = $sources[$params['source']] ?? null;
|
||||
$params['user_id'] = $this->auth->id;
|
||||
$params['status'] = 10;
|
||||
$params['order_no'] = $this->generateOrderNumber();
|
||||
$params['create_time'] = date('Y-m-d H:i:s');
|
||||
|
|
@ -129,6 +161,9 @@ class Order extends Backend
|
|||
// 获取表单提交的数据
|
||||
$data = input('post.row/a');
|
||||
$data['update_time'] = date('Y-m-d H:i:s');
|
||||
$sources = $this->sources;
|
||||
$sources = array_column($sources,'title','id');
|
||||
$data['source_shop'] = $sources[$data['source']] ?? null;
|
||||
// 更新订单信息
|
||||
$order->save($data);
|
||||
|
||||
|
|
|
|||
237
application/admin/controller/Source.php
Normal file
237
application/admin/controller/Source.php
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use fast\Tree;
|
||||
use think\Db;
|
||||
use think\exception\PDOException;
|
||||
use think\exception\ValidateException;
|
||||
|
||||
/**
|
||||
* 项目列管理
|
||||
*
|
||||
* @icon fa fa-circle-o
|
||||
*/
|
||||
class Source extends Backend
|
||||
{
|
||||
|
||||
/**
|
||||
* Source模型对象
|
||||
* @var \app\admin\model\Source
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\Source;
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if ($this->request->isAjax()) {
|
||||
// 必须将结果集转换为数组
|
||||
$search = request()->get('search') ?? false;
|
||||
// dd($where);
|
||||
$build = Db::name('source')
|
||||
->where('status',1);
|
||||
if ($search){
|
||||
$build->where(function ($query) use ($search){
|
||||
$query->where('title','like','%'.$search.'%')
|
||||
->whereOr('key_word','like','%'.$search.'%');
|
||||
});
|
||||
}
|
||||
|
||||
$ruleList = $build->field('id,pid,level,title,key_word,sort,status')
|
||||
// ->order('sort','desc')
|
||||
// ->fetchSql(true)
|
||||
->select();
|
||||
if ($search){
|
||||
$pids = array_column($ruleList,'pid') ;
|
||||
$pidData = Db::name('source')
|
||||
->where('status',1)->whereIn('id',$pids)
|
||||
->field('id,pid,level,title,key_word,sort,status')->select();
|
||||
$ruleList = array_values(array_reduce(array_merge($ruleList,$pidData), function ($carry, $source) {
|
||||
$carry[$source['id']] = $source;
|
||||
return $carry;
|
||||
}, []));
|
||||
}
|
||||
|
||||
Tree::instance()->init($ruleList)->icon = [' ', ' ', ' '];
|
||||
// dd($ruleList);
|
||||
$this->sourcedata = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title');
|
||||
foreach ($this->sourcedata as &$v) {
|
||||
$v['status'] = $v['status'] ?'normal' : 'aqua';
|
||||
}
|
||||
unset($v);
|
||||
|
||||
$list = $this->sourcedata;
|
||||
$total = count($this->sourcedata);
|
||||
$result = array("total" => $total, "rows" => $list);
|
||||
|
||||
return json($result);
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
|
||||
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
|
||||
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
|
||||
*/
|
||||
|
||||
public function add()
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
// 必须将结果集转换为数组
|
||||
$ruleList = \think\Db::name("source")
|
||||
->where('pid',0)
|
||||
->field('id,pid,level,title,key_word')
|
||||
->order('sort DESC,id ASC')->select();
|
||||
|
||||
Tree::instance()->init($ruleList)->icon = [' ', ' ', ' '];
|
||||
// dd($ruleList);
|
||||
$this->sourcedata = Tree::instance()->getTreeList(Tree::instance()
|
||||
->getTreeArray(0), 'title');
|
||||
$sourcedata = [0 => __('None')];
|
||||
foreach ($this->sourcedata as $k => $v) {
|
||||
$sourcedata[$v['id']] = $v['title'];
|
||||
unset($v['spacer']);
|
||||
}
|
||||
unset($v);
|
||||
|
||||
$this->view->assign('sourcedata', $sourcedata);
|
||||
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);
|
||||
}
|
||||
|
||||
$pid = $params['pid'];
|
||||
if ($pid > 0){
|
||||
$parent = $this->model->where('id',$pid)->find();
|
||||
if ($parent){
|
||||
$params['level'] = $parent->value('level') + 1;
|
||||
}
|
||||
}else{
|
||||
$params['level'] = 0;
|
||||
}
|
||||
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
public function search(){
|
||||
|
||||
$keyword = request()->get('keyword');
|
||||
if (!$keyword){
|
||||
$this->success(data:[]);
|
||||
}else{
|
||||
$data = model('source')
|
||||
->where('level','=',2)
|
||||
->where(function ($query)use ($keyword){
|
||||
$query->where('title','like','%'.$keyword.'%')
|
||||
->whereOr('key_word', 'like', "%{$keyword}%");
|
||||
})
|
||||
->order('level','desc')
|
||||
->field('title,id,key_word')
|
||||
->limit(0,10)
|
||||
->select();
|
||||
$this->success(data:$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
if (false === $this->request->isPost()) {
|
||||
// 必须将结果集转换为数组
|
||||
$ruleList = \think\Db::name("source")
|
||||
->where('pid',0)
|
||||
->field('id,pid,level,title,key_word')
|
||||
->order('sort DESC,id ASC')->select();
|
||||
|
||||
Tree::instance()->init($ruleList)->icon = [' ', ' ', ' '];
|
||||
// dd($ruleList);
|
||||
$this->sourcedata = Tree::instance()->getTreeList(Tree::instance()
|
||||
->getTreeArray(0), 'title');
|
||||
$sourcedata = [0 => __('None')];
|
||||
foreach ($this->sourcedata as $k => $v) {
|
||||
$sourcedata[$v['id']] = $v['title'];
|
||||
unset($v['spacer']);
|
||||
}
|
||||
unset($v);
|
||||
|
||||
$this->view->assign('sourcedata', $sourcedata);
|
||||
$this->view->assign('row', $row);
|
||||
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);
|
||||
$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 . '.edit' : $name) : $this->modelValidate;
|
||||
$row->validateFailException()->validate($validate);
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
Db::commit();
|
||||
} catch (ValidateException|PDOException|Exception $e) {
|
||||
Db::rollback();
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
if (false === $result) {
|
||||
$this->error(__('No rows were updated'));
|
||||
}
|
||||
$this->success();
|
||||
}
|
||||
|
||||
}
|
||||
16
application/admin/lang/zh-cn/source.php
Normal file
16
application/admin/lang/zh-cn/source.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'Id' => 'ID',
|
||||
'Pid' => 'PID',
|
||||
'Level' => '层级',
|
||||
'Title' => '服务名称',
|
||||
'Key_word' => '关键字',
|
||||
'Image' => '图标',
|
||||
'Sort' => '排序',
|
||||
'Status' => '状态',
|
||||
'Status 1' => '启用',
|
||||
'Set status to 1'=> '设为启用',
|
||||
'Status 0' => '关闭',
|
||||
'Set status to 0'=> '设为关闭'
|
||||
];
|
||||
49
application/admin/model/Source.php
Normal file
49
application/admin/model/Source.php
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
|
||||
class Source extends Model
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 表名
|
||||
protected $name = 'source';
|
||||
|
||||
// 自动写入时间戳字段
|
||||
protected $autoWriteTimestamp = false;
|
||||
|
||||
// 定义时间戳字段名
|
||||
protected $createTime = false;
|
||||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'status_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getStatusList()
|
||||
{
|
||||
return ['1' => __('Status 1'), '0' => __('Status 0')];
|
||||
}
|
||||
|
||||
|
||||
public function getStatusTextAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['status'] ?? '');
|
||||
$list = $this->getStatusList();
|
||||
return $list[$value] ?? '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
27
application/admin/validate/Source.php
Normal file
27
application/admin/validate/Source.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Source extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
||||
|
|
@ -42,19 +42,26 @@
|
|||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Source')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-source" data-rule="required" class="form-control" name="row[source]" type="number" value="0">
|
||||
<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-3">{:__('Item_title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-service_title" data-rule="required" class="form-control" name="row[service_title]" type="text" value="">
|
||||
<input id="c-service_title" data-rule="required" class="form-control" name="row[item_title]" type="text" value="">
|
||||
|
||||
<!-- 选项下拉框 -->
|
||||
<ul id="service-list" class="dropdown-menu" style="display: none;"></ul>
|
||||
|
||||
<!-- 存储选择的 area_code -->
|
||||
<input type="hidden" id="selected-service_id" name="row[service_id]">
|
||||
<input type="hidden" id="selected-service_id" name="row[item_id]">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -11,21 +11,21 @@
|
|||
<input type="hidden" name="id" value="{$row.id}"> <!-- 订单ID,用于提交编辑的对象 -->
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Customer')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Customer')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-customer" class="form-control" name="row[customer]" type="text" value="{$row.customer}">
|
||||
<input id="c-customer" data-rule="required" class="form-control" name="row[customer]" type="text" value="{$row.customer}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Tel')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Tel')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-tel" class="form-control" name="row[tel]" type="number" value="{$row.tel}">
|
||||
<input id="c-tel" data-rule="required" class="form-control" name="row[tel]" type="number" value="{$row.tel}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Area_id')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Area_id')}:</label>
|
||||
<div class='col-xs-12 col-sm-8'>
|
||||
<input id="c-area_id" class="form-control" type="text" value="{$row.area_name}" />
|
||||
<input id="c-area_id" data-rule="required" class="form-control" type="text" value="{$row.area_name}" />
|
||||
<!-- 选项下拉框 -->
|
||||
<ul id="address-list" class="dropdown-menu" style="display: none;"></ul>
|
||||
|
||||
|
|
@ -34,21 +34,25 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Address')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-address" class="form-control" name="row[address]" type="text" value="{$row.address}">
|
||||
<input id="c-address" data-rule="required" class="form-control" name="row[address]" type="text" value="{$row.address}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Source')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Source')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-source" class="form-control" name="row[source]" type="number" value="{$row.source}">
|
||||
<select id="c-source" data-live-search="true" data-value="{$row.source}" data-rule="required" name="row[source]" class="form-control selectpicker">
|
||||
{foreach $sources as $item}
|
||||
<option data-subtext="{$item['ptitle']}" {if $item['id'] == $row.source} selected {/if} value="{$item['id']}">{$item['title']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Item_title')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Item_title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-service_title" class="form-control" name="row[item_title]" type="text" value="{$row.item_title}">
|
||||
<input data-rule="required" id="c-service_title" class="form-control" name="row[item_title]" type="text" value="{$row.item_title}">
|
||||
|
||||
<!-- 选项下拉框 -->
|
||||
<ul id="service-list" class="dropdown-menu" style="display: none;"></ul>
|
||||
|
|
@ -58,19 +62,19 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Detail')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Detail')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-detail" rows="4" style="width: 100%;resize: vertical" class="form-control" name="row[detail]">{$row.detail}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Remark')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Remark')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<textarea id="c-remark" rows="4" style="width: 100%;resize: vertical" class="form-control" name="row[remark]">{$row.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Images')}:</label>
|
||||
<label class="control-label col-xs-12 col-sm-3">{:__('Images')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<div class="input-group">
|
||||
<input id="c-images" class="form-control" size="50" name="row[images]" type="text" value="{$row.images}">
|
||||
|
|
@ -84,7 +88,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<label class="control-label col-xs-12 col-sm-3"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<button type="submit" class="btn btn-primary btn-embossed">更新订单</button>
|
||||
</div>
|
||||
|
|
|
|||
54
application/admin/view/source/add.html
Normal file
54
application/admin/view/source/add.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<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">{:__('Pid')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{:build_select('row[pid]', $sourcedata, null, ['class'=>'form-control', 'required'=>''])}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Key_word')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-key_word" class="form-control" name="row[key_word]" type="text">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>-->
|
||||
<!-- <div class="col-xs-12 col-sm-8">-->
|
||||
<!-- <div class="input-group">-->
|
||||
<!-- <input id="c-image" class="form-control" size="50" name="row[image]" type="text">-->
|
||||
<!-- <div class="input-group-addon no-border no-padding">-->
|
||||
<!-- <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>-->
|
||||
<!-- <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <span class="msg-box n-right" for="c-image"></span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <ul class="row list-inline faupload-preview" id="p-image"></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="1"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</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">{:__('OK')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
59
application/admin/view/source/edit.html
Normal file
59
application/admin/view/source/edit.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<form id="edit-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">{:__('Pid')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
{:build_select('row[pid]', $sourcedata, $row.pid, ['class'=>'form-control', 'required'=>''])}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-title" data-rule="required" class="form-control" name="row[title]" type="text" value="{$row.title|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Key_word')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-key_word" class="form-control" name="row[key_word]" type="text" value="{$row.key_word|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Image')}:</label>-->
|
||||
<!-- <div class="col-xs-12 col-sm-8">-->
|
||||
<!-- <div class="input-group">-->
|
||||
<!-- <input id="c-image" class="form-control" size="50" name="row[image]" type="text" value="{$row.image|htmlentities}">-->
|
||||
<!-- <div class="input-group-addon no-border no-padding">-->
|
||||
<!-- <span><button type="button" id="faupload-image" class="btn btn-danger faupload" data-input-id="c-image" data-mimetype="image/gif,image/jpeg,image/png,image/jpg,image/bmp,image/webp" data-multiple="false" data-preview-id="p-image"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>-->
|
||||
<!-- <span><button type="button" id="fachoose-image" class="btn btn-primary fachoose" data-input-id="c-image" data-mimetype="image/*" data-multiple="false"><i class="fa fa-list"></i> {:__('Choose')}</button></span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <span class="msg-box n-right" for="c-image"></span>-->
|
||||
<!-- </div>-->
|
||||
<!-- <ul class="row list-inline faupload-preview" id="p-image"></ul>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="form-group">-->
|
||||
<!-- <label class="control-label col-xs-12 col-sm-2">{:__('Sort')}:</label>-->
|
||||
<!-- <div class="col-xs-12 col-sm-8">-->
|
||||
<!-- <input id="c-sort" data-rule="required" class="form-control" name="row[sort]" type="number" value="{$row.sort|htmlentities}">-->
|
||||
<!-- </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="$row.status"}checked{/in} /> {$vo}</label>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
</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>
|
||||
54
application/admin/view/source/index.html
Normal file
54
application/admin/view/source/index.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<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('item/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('item/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('item/del')?'':'hide'}"
|
||||
title="{:__('Delete')}"><i class="fa fa-trash"></i> {:__('Delete')}</a>
|
||||
|
||||
|
||||
<div class="dropdown btn-group {:$auth->check('item/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('item/edit')}"
|
||||
data-operate-del="{:$auth->check('item/del')}"
|
||||
width="100%">
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -156,13 +156,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
$(document).on('click', "input[name='row[ismenu]']", function () {
|
||||
var name = $("input[name='row[name]']");
|
||||
var ismenu = $(this).val() === 1;
|
||||
name.prop("placeholder", ismenu ? name.data("placeholder-menu") : name.data("placeholder-node"));
|
||||
$('div[data-type="menu"]').toggleClass("hidden", !ismenu);
|
||||
});
|
||||
$("input[name='row[ismenu]']:checked").trigger("click");
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
},
|
||||
{field: 'work_tel_id', title: __('Work_tel_id')},
|
||||
// {field: 'worker_id', title: __('Worker_id')},
|
||||
{field: 'source', title: __('Source')},
|
||||
{field: 'source_shop', title: __('Source')},
|
||||
// {field: 'source_uid', title: __('Source_uid'), operate: 'LIKE'},
|
||||
{field: 'item_title', title: __('Item_title'), operate: 'LIKE'},
|
||||
{
|
||||
|
|
|
|||
164
public/assets/js/backend/source.js
Normal file
164
public/assets/js/backend/source.js
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function ($, undefined, Backend, Table, Form, Template) {
|
||||
|
||||
var Controller = {
|
||||
index: function () {
|
||||
// 初始化表格参数配置
|
||||
Table.api.init({
|
||||
extend: {
|
||||
"index_url": "source/index" + location.search,
|
||||
"add_url": "source/add",
|
||||
"edit_url": "source/edit",
|
||||
"del_url": "source/del",
|
||||
"multi_url": "source/multi",
|
||||
"table": "source"
|
||||
}
|
||||
});
|
||||
|
||||
var table = $("#table");
|
||||
|
||||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
// sortName: 'id',
|
||||
// escape: true,
|
||||
fixedColumns: true,
|
||||
fixedRightNumber: 1,
|
||||
columns: [
|
||||
[
|
||||
{field: 'state', checkbox: true,},
|
||||
// {field: 'id', title: 'ID'},
|
||||
{field: 'title', title: __('Title'), align: 'left', formatter: Controller.api.formatter.title, clickToSelect: !false},
|
||||
{field: 'key_word', title: __('Key_word'), align: 'left', formatter: Controller.api.formatter.content},
|
||||
// {field: 'sort', title: __('Sort')},
|
||||
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
|
||||
{
|
||||
field: 'operate',
|
||||
title: __('Operate'),
|
||||
table: table,
|
||||
events: Table.api.events.operate,
|
||||
formatter: Table.api.formatter.operate
|
||||
}
|
||||
]
|
||||
],
|
||||
pagination: false,
|
||||
search: true,
|
||||
commonSearch: false,
|
||||
rowAttributes: function (row, index) {
|
||||
return row.pid === 0 ? {} : {style: "display:none"};
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
|
||||
var btnSuccessEvent = function (data, ret) {
|
||||
if ($(this).hasClass("btn-change")) {
|
||||
var index = $(this).data("index");
|
||||
var row = Table.api.getrowbyindex(table, index);
|
||||
row.ismenu = $("i.fa.text-gray", this).length > 0 ? 1 : 0;
|
||||
table.bootstrapTable("updateRow", {index: index, row: row});
|
||||
} else if ($(this).hasClass("btn-delone")) {
|
||||
if ($(this).closest("tr[data-index]").find("a.btn-node-sub.disabled").length > 0) {
|
||||
$(this).closest("tr[data-index]").remove();
|
||||
} else {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
} else if ($(this).hasClass("btn-dragsort")) {
|
||||
table.bootstrapTable('refresh');
|
||||
}
|
||||
Fast.api.refreshmenu();
|
||||
return false;
|
||||
};
|
||||
|
||||
//表格内容渲染前
|
||||
table.on('pre-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = true;
|
||||
});
|
||||
|
||||
//当内容渲染完成后
|
||||
table.on('post-body.bs.table', function (e, data) {
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
options.escape = false;
|
||||
|
||||
//点击切换/排序/删除操作后刷新左侧菜单
|
||||
$(".btn-change[data-id],.btn-delone,.btn-dragsort").data("success", btnSuccessEvent);
|
||||
|
||||
});
|
||||
|
||||
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
||||
//显示隐藏子节点
|
||||
$(">tbody>tr[data-index] > td", this).on('click', "a.btn-node-sub", function () {
|
||||
var status = $(this).data("shown") ? true : false;
|
||||
$("a[data-pid='" + $(this).data("id") + "']").each(function () {
|
||||
$(this).closest("tr").toggle(!status);
|
||||
});
|
||||
if (status) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$(this).data("shown", !status);
|
||||
$("i", this).toggleClass("fa-caret-down").toggleClass("fa-caret-right");
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
//隐藏子节点
|
||||
$(document).on("collapse", ".btn-node-sub", function () {
|
||||
if ($("i", this).length > 0) {
|
||||
$("a[data-pid='" + $(this).data("id") + "']").trigger("collapse");
|
||||
}
|
||||
$("i", this).removeClass("fa-caret-down").addClass("fa-caret-right");
|
||||
$(this).data("shown", false);
|
||||
$(this).closest("tr").toggle(false);
|
||||
});
|
||||
|
||||
//批量删除后的回调
|
||||
$(".toolbar > .btn-del,.toolbar .btn-more~ul>li>a").data("success", function (e) {
|
||||
Fast.api.refreshmenu();
|
||||
});
|
||||
|
||||
//展开隐藏一级
|
||||
$(document.body).on("click", ".btn-toggle", function (e) {
|
||||
$("a[data-id][data-pid][data-pid!=0].disabled").closest("tr").hide();
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-chevron-down");
|
||||
$("i", that).toggleClass("fa-chevron-down", !show).toggleClass("fa-chevron-up", show);
|
||||
$("a[data-id][data-pid][data-pid!=0]").not('.disabled').closest("tr").toggle(show);
|
||||
$(".btn-node-sub[data-pid=0]").data("shown", show);
|
||||
});
|
||||
|
||||
//展开隐藏全部
|
||||
$(document.body).on("click", ".btn-toggle-all", function (e) {
|
||||
var that = this;
|
||||
var show = $("i", that).hasClass("fa-plus");
|
||||
$("i", that).toggleClass("fa-plus", !show).toggleClass("fa-minus", show);
|
||||
$(".btn-node-sub:not([data-pid=0])").closest("tr").toggle(show);
|
||||
$(".btn-node-sub").data("shown", show);
|
||||
$(".btn-node-sub > i").toggleClass("fa-caret-down", show).toggleClass("fa-caret-right", !show);
|
||||
});
|
||||
},
|
||||
add: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
edit: function () {
|
||||
Controller.api.bindevent();
|
||||
},
|
||||
api: {
|
||||
formatter: {
|
||||
title: function (value, row, index) {
|
||||
value = value.toString().replace(/(&|&)nbsp;/g, ' ');
|
||||
var caret = row.pid === 0 ? '<i class="fa fa-caret-right"></i>' : '';
|
||||
value = value.indexOf(" ") > -1 ? value.replace(/(.*) /, "$1" + caret) : caret + value;
|
||||
|
||||
value = row.status === 0 ? "<span class='text-muted'>" + value + "</span>" : value;
|
||||
return '<a href="javascript:;" data-id="' + row.id + '" data-pid="' + row.pid + '" class="'
|
||||
+ (row.pid !== 0 ? 'text-primary' : 'disabled') + ' btn-node-sub">' + value + '</a>';
|
||||
},
|
||||
},
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user