更新
This commit is contained in:
@@ -38,8 +38,9 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
// 不按 source 搜索:列表固定为「当前管理员后台上传」,避免请求参数覆盖权限条件
|
||||
return [
|
||||
'=' => ['type', 'source'],
|
||||
'=' => ['type'],
|
||||
'%like%' => ['name']
|
||||
];
|
||||
}
|
||||
@@ -79,7 +80,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->order('id', 'desc')
|
||||
->where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
// ->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->where('source_id', $this->adminId)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
@@ -102,7 +104,8 @@ class FileLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
return (new File())->where($this->searchWhere)
|
||||
->where($this->queryWhere())
|
||||
// ->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->where('source', FileEnum::SOURCE_ADMIN)
|
||||
->where('source_id', $this->adminId)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\lists\tcm;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\tcm\PrescriptionLibrary;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
|
||||
/**
|
||||
* 处方库列表
|
||||
*/
|
||||
class PrescriptionLibraryLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 设置搜索条件
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'%like%' => ['prescription_name'],
|
||||
'=' => ['is_public', 'creator_id']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = [
|
||||
'id', 'prescription_name', 'herbs', 'is_public',
|
||||
'creator_id', 'creator_name', 'create_time', 'update_time'
|
||||
];
|
||||
|
||||
$lists = PrescriptionLibrary::where($this->searchWhere)
|
||||
->where(function ($query) {
|
||||
// 只显示自己创建的或公开的处方
|
||||
$query->where('creator_id', $this->adminId)
|
||||
->whereOr('is_public', 1);
|
||||
})
|
||||
->field($field)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 解析药材JSON
|
||||
foreach ($lists as &$item) {
|
||||
if (!empty($item['herbs'])) {
|
||||
$item['herbs'] = json_decode($item['herbs'], true);
|
||||
} else {
|
||||
$item['herbs'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return PrescriptionLibrary::where($this->searchWhere)
|
||||
->where(function ($query) {
|
||||
// 只统计自己创建的或公开的处方
|
||||
$query->where('creator_id', $this->adminId)
|
||||
->whereOr('is_public', 1);
|
||||
})
|
||||
->count();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\adminapi\lists\tcm;
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\tcm\Prescription;
|
||||
|
||||
/**
|
||||
* 处方列表
|
||||
*/
|
||||
class PrescriptionLists extends BaseAdminDataLists implements ListsSearchInterface
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['is_shared'],
|
||||
'%like%' => ['prescription_name', 'patient_name', 'sn']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Prescription::where($this->searchWhere)
|
||||
->where(function ($query) {
|
||||
// 如果不是共享的,只能看到自己创建的
|
||||
$query->whereOr([
|
||||
['is_shared', '=', 1],
|
||||
['creator_id', '=', $this->adminId]
|
||||
]);
|
||||
})
|
||||
->whereNull('delete_time')
|
||||
->order('id', 'desc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
// 处理字段格式
|
||||
foreach ($lists as &$item) {
|
||||
// 设置默认值
|
||||
$item['usage_time'] = $item['usage_time'] ?? '饭前';
|
||||
$item['usage_way'] = $item['usage_way'] ?? '温水送服';
|
||||
$item['usage_notes'] = $item['usage_notes'] ?? '';
|
||||
$item['usage_days'] = $item['usage_days'] ?? 7;
|
||||
$item['is_shared'] = $item['is_shared'] ?? 0;
|
||||
|
||||
// 将 dietary_taboo 从逗号分隔的字符串转换为数组(前端需要数组格式)
|
||||
if (!empty($item['dietary_taboo']) && is_string($item['dietary_taboo'])) {
|
||||
$item['dietary_taboo'] = array_filter(explode(',', $item['dietary_taboo']));
|
||||
} else {
|
||||
$item['dietary_taboo'] = [];
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Prescription::where($this->searchWhere)
|
||||
->where(function ($query) {
|
||||
// 如果不是共享的,只能看到自己创建的
|
||||
$query->whereOr([
|
||||
['is_shared', '=', 1],
|
||||
['creator_id', '=', $this->adminId]
|
||||
]);
|
||||
})
|
||||
->whereNull('delete_time')
|
||||
->count();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user