|
|
@@ -16,9 +16,12 @@ namespace app\adminapi\lists\works;
|
|
|
|
|
|
|
|
|
use app\adminapi\lists\BaseAdminDataLists;
|
|
|
+use app\common\model\property\PropertyOrder;
|
|
|
use app\common\model\works\IssueWork;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
use think\db\Query;
|
|
|
+use think\facade\Db;
|
|
|
+use think\facade\Log;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -29,7 +32,7 @@ use think\db\Query;
|
|
|
class IssueWorkLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
{
|
|
|
|
|
|
-
|
|
|
+ public $queryExists = null;
|
|
|
/**
|
|
|
* @notes 设置搜索条件
|
|
|
* @return \string[][]
|
|
|
@@ -65,6 +68,49 @@ class IssueWorkLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
}
|
|
|
return $where;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取数据权限
|
|
|
+ * $this->adminInfo['data_rules']
|
|
|
+ * province city admin_id sale_group_id sale_id property_head_id
|
|
|
+ */
|
|
|
+ public function queryDataWhere(){
|
|
|
+ $where = [];
|
|
|
+ $data_rules = $this->adminInfo['data_rules'];
|
|
|
+ $this->queryExists = function (Query $query) use ($data_rules) { $query->name('service_work')->where('id','>', 0)->field('id'); };
|
|
|
+ if (isset($data_rules['province']) && !empty($data_rules['province'])) {
|
|
|
+ $this->queryExists = function (Query $query) {
|
|
|
+ $p_table = $query->getTable().$query->getName();
|
|
|
+ $query->name('service_work')->alias('b')
|
|
|
+ ->where('province','in', $data_rules['province'])
|
|
|
+ ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
|
|
|
+ ->field('id');
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (isset($data_rules['city']) && !empty($data_rules['city'])) {
|
|
|
+ $this->queryExists = function (Query $query) use ($data_rules) {
|
|
|
+ $p_table = $query->getTable().$query->getName();
|
|
|
+ $query->name('service_work')->alias('b')
|
|
|
+ ->where('city','in', $data_rules['city'])
|
|
|
+ ->where($p_table.'.service_work_id', '=', Db::raw('b.id'))
|
|
|
+ ->field('id');
|
|
|
+ };
|
|
|
+ }
|
|
|
+ if (isset($data_rules['sale_group_id']) && !empty($data_rules['sale_group_id'])) {
|
|
|
+ $work_ids = PropertyOrder::where('sale_group_id','in',$data_rules['sale_group_id'])->column('work_id')??[];
|
|
|
+ $where[] = ['service_work_id','in' ,$work_ids];
|
|
|
+ }
|
|
|
+ if (isset($data_rules['sale_id']) && !empty($data_rules['sale_id'])) {
|
|
|
+ $work_ids = PropertyOrder::where('sale_id','in',$data_rules['sale_id'])->column('work_id')??[];
|
|
|
+ $where[] = ['service_work_id','in' ,$work_ids];
|
|
|
+ }
|
|
|
+ if (isset($data_rules['property_head_id']) && !empty($data_rules['property_head_id'])) {
|
|
|
+ $work_ids = PropertyOrder::where('property_head_id','in',$data_rules['property_head_id'])->column('work_id')??[];
|
|
|
+ $where[] = ['service_work_id','in' ,$work_ids];
|
|
|
+ }
|
|
|
+ return $where;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @notes 获取列表
|
|
|
* @return array
|
|
|
@@ -91,6 +137,8 @@ class IssueWorkLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
])
|
|
|
->where($this->searchWhere)
|
|
|
->where($this->querySearch())
|
|
|
+ ->where($this->queryDataWhere())
|
|
|
+ ->whereExists($this->queryExists)
|
|
|
->field(['id', 'work_sn', 'service_work_id', 'master_worker_id','user_id', 'issue_approval', 'complaint_status', 'responsible', 'complaint_details', 'complaint_images', 'finished_time', 'approval_admin_id', 'approval_time', 'create_time', 'update_time','appeal_info'])
|
|
|
->limit($this->limitOffset, $this->limitLength)
|
|
|
->order(['id' => 'desc'])
|
|
|
@@ -107,7 +155,7 @@ class IssueWorkLists extends BaseAdminDataLists implements ListsSearchInterface
|
|
|
*/
|
|
|
public function count(): int
|
|
|
{
|
|
|
- return IssueWork::where($this->searchWhere)->where($this->querySearch())->count();
|
|
|
+ return IssueWork::where($this->searchWhere)->where($this->querySearch())->where($this->queryDataWhere())->whereExists($this->queryExists)->count();
|
|
|
}
|
|
|
|
|
|
}
|