feat: 新增发票抬头、晒单、钱包日志等模型及后台管理功能
- 新增 invoice_title、showcase、wallet_log 模型及对应语言包 - 新增后台控制器、视图及搜索字段配置 - 修复服务类目删除保护逻辑 - 优化后台登录页面文案及样式 - 新增前端角色切换逻辑及页面拦截 - 新增 SVG 图标及样式变量 - 修复接口权限及下拉框默认值问题
这个提交包含在:
@@ -17,26 +17,33 @@ class SkillDict extends Backend
|
||||
* @var \app\admin\model\SkillDict
|
||||
*/
|
||||
protected $model = null;
|
||||
protected $searchFields = 'id,name,category';
|
||||
protected $relationSearch = true;
|
||||
protected $searchFields = 'id,name,category,master.realname';
|
||||
|
||||
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');
|
||||
|
||||
$categorySearchList = [];
|
||||
foreach ($categoryList as $catName) {
|
||||
$categorySearchList[$catName] = $catName;
|
||||
}
|
||||
|
||||
$this->view->assign("categoryList", $categoryList);
|
||||
$this->assignconfig("categorySearchList", $categorySearchList);
|
||||
$this->view->assign("sourceList", $this->model->getSourceList());
|
||||
$this->view->assign("statusList", $this->model->getStatusList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看技能列表
|
||||
* 查看技能列表(支持 category_id 跳转过滤,并统计持证师傅人数)
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
@@ -47,15 +54,40 @@ class SkillDict extends Backend
|
||||
if ($this->request->request('keyField')) {
|
||||
return $this->selectpage();
|
||||
}
|
||||
$catIdParam = (int)$this->request->get('category_id', 0);
|
||||
[$where, $sort, $order, $offset, $limit] = $this->buildparams();
|
||||
$list = $this->model
|
||||
$query = $this->model
|
||||
->with(['master'])
|
||||
->where($where)
|
||||
->order($sort, $order)
|
||||
->paginate($limit);
|
||||
->where($where);
|
||||
if ($catIdParam > 0) {
|
||||
$query->where('skill_dict.category_id', $catIdParam);
|
||||
}
|
||||
$list = $query->order($sort, $order)->paginate($limit);
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
return json($result);
|
||||
$rows = $list->items();
|
||||
$names = [];
|
||||
foreach ($rows as $r) {
|
||||
if (!empty($r['name'])) {
|
||||
$names[] = (string)$r['name'];
|
||||
}
|
||||
}
|
||||
$masterCountMap = [];
|
||||
if ($names) {
|
||||
$stats = Db::name('master_skill')
|
||||
->where('skill_name', 'in', array_unique($names))
|
||||
->field('skill_name, COUNT(DISTINCT master_id) AS cnt')
|
||||
->group('skill_name')
|
||||
->select();
|
||||
foreach ($stats as $st) {
|
||||
$masterCountMap[$st['skill_name']] = (int)$st['cnt'];
|
||||
}
|
||||
}
|
||||
foreach ($rows as &$item) {
|
||||
$item['master_count'] = $masterCountMap[$item['name']] ?? 0;
|
||||
}
|
||||
unset($item);
|
||||
|
||||
return json(['total' => $list->total(), 'rows' => $rows]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,6 +113,7 @@ class SkillDict extends Backend
|
||||
}
|
||||
$this->error(__('Parameter %s can not be empty', ''));
|
||||
}
|
||||
$this->view->assign('defaultCategoryId', (int)$this->request->get('category_id', 0) ?: '');
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
@@ -114,4 +147,27 @@ class SkillDict extends Backend
|
||||
$this->view->assign("row", $row);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除保护:已被师傅绑定的技能禁止物理删除
|
||||
*/
|
||||
public function del($ids = null)
|
||||
{
|
||||
if (false === $this->request->isPost()) {
|
||||
$this->error(__('Invalid parameters'));
|
||||
}
|
||||
$ids = $ids ?: $this->request->post('ids');
|
||||
$idArr = array_values(array_filter(array_map('intval', explode(',', (string)$ids))));
|
||||
if (!$idArr) {
|
||||
$this->error(__('Parameter %s can not be empty', 'ids'));
|
||||
}
|
||||
$names = Db::name('skill_dict')->where('id', 'in', $idArr)->column('name');
|
||||
if ($names) {
|
||||
$usedCnt = (int)Db::name('master_skill')->where('skill_name', 'in', $names)->count();
|
||||
if ($usedCnt > 0) {
|
||||
$this->error('所选技能已被 ' . $usedCnt . ' 条师傅档案绑定,禁止物理删除,请改为「隐藏停用」');
|
||||
}
|
||||
}
|
||||
return parent::del($ids);
|
||||
}
|
||||
}
|
||||
|
||||
在新工单中引用
屏蔽一个用户