feat(admin): 重构服务管理模块新增增值服务功能
- 新增增值服务管理模块,支持按类目筛选绑定 - 新增工项服务定价和规格独立定价功能 - 优化前端订单页增值服务展示逻辑 - 升级版本号至1.0.19
这个提交包含在:
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\controller;
|
||||
|
||||
use app\common\controller\Backend;
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
* 技能列表管理
|
||||
*
|
||||
* @icon fa fa-tags
|
||||
*/
|
||||
class SkillDict extends Backend
|
||||
{
|
||||
/**
|
||||
* SkillDict模型对象
|
||||
* @var \app\admin\model\SkillDict
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $searchFields = 'id,name,category';
|
||||
|
||||
public function _initialize()
|
||||
{
|
||||
parent::_initialize();
|
||||
$this->model = new \app\admin\model\SkillDict;
|
||||
|
||||
// 从真实技能分类表中拉取分类列表
|
||||
$categoryList = Db::name('skill_category')
|
||||
->where('status', 'normal')
|
||||
->order('weigh desc, id asc')
|
||||
->column('name', 'id');
|
||||
|
||||
$this->view->assign("categoryList", $categoryList);
|
||||
$this->view->assign("sourceList", $this->model->getSourceList());
|
||||
$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();
|
||||
}
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
->with(['master'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加技能
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if (!empty($params['category_id'])) {
|
||||
$cat = Db::name('skill_category')->where('id', $params['category_id'])->find();
|
||||
if ($cat) {
|
||||
$params['category'] = $cat['name'];
|
||||
}
|
||||
}
|
||||
$result = $this->model->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($this->model->getError());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑技能
|
||||
*/
|
||||
public function edit($ids = null)
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
if ($this->request->isPost()) {
|
||||
$params = $this->request->post("row/a");
|
||||
if ($params) {
|
||||
if (!empty($params['category_id'])) {
|
||||
$cat = Db::name('skill_category')->where('id', $params['category_id'])->find();
|
||||
if ($cat) {
|
||||
$params['category'] = $cat['name'];
|
||||
}
|
||||
}
|
||||
$result = $row->allowField(true)->save($params);
|
||||
if ($result !== false) {
|
||||
$this->success();
|
||||
} else {
|
||||
$this->error($row->getError());
|
||||
}
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户