feat: 重构后台服务字典与商品独立定价体系及前后端交互优化

这个提交包含在:
2026-11-10 11:01:05 +08:00
父节点 3ebd795cbb
当前提交 e2b0044b64
共有 66 个文件被更改,包括 6628 次插入 和 2137 次删除

查看文件

@@ -3,15 +3,15 @@
namespace app\admin\controller\service;
use app\common\controller\Backend;
use think\Db;
/**
* 服务类目
*
* @icon fa fa-circle-o
* @icon fa fa-th-large
*/
class Cat extends Backend
{
/**
* Cat模型对象
* @var \app\admin\model\service\Cat
@@ -25,13 +25,38 @@ class Cat extends Backend
$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
->where($where)
->order($sort, $order)
->paginate($limit);
$rows = $list->items();
if (!empty($rows)) {
$catCountRows = Db::name('service')
->field('cat_id, count(id) as cnt')
->group('cat_id')
->select();
$catCounts = [];
foreach ($catCountRows as $cr) {
$catCounts[(int)$cr['cat_id']] = (int)$cr['cnt'];
}
foreach ($rows as &$r) {
$cid = (int)$r['id'];
$r['goods_count'] = isset($catCounts[$cid]) ? (int)$catCounts[$cid] : 0;
}
unset($r);
}
/**
* 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
* 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
* 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
*/
return json(['total' => $list->total(), 'rows' => $rows]);
}
}