Merge pull request 'update' (#105) from zhangwei into dev
Reviewed-on: #105
This commit is contained in:
commit
a5178a76b0
@ -13,13 +13,13 @@
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\adminapi\controller\custom_service;
|
||||
namespace app\adminapi\controller\custom;
|
||||
|
||||
|
||||
use app\adminapi\controller\BaseAdminController;
|
||||
use app\adminapi\lists\custom_service\CustomServiceLists;
|
||||
use app\adminapi\logic\custom_service\CustomServiceLogic;
|
||||
use app\adminapi\validate\custom_service\CustomServiceValidate;
|
||||
use app\adminapi\lists\custom\CustomServiceLists;
|
||||
use app\adminapi\logic\custom\CustomServiceLogic;
|
||||
use app\adminapi\validate\custom\CustomServiceValidate;
|
||||
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ class CustomServiceController extends BaseAdminController
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function edit()
|
||||
public function solve(): \think\response\Json
|
||||
{
|
||||
$params = (new CustomServiceValidate())->post()->goCheck('edit');
|
||||
$result = CustomServiceLogic::edit($params);
|
||||
@ -75,21 +75,7 @@ class CustomServiceController extends BaseAdminController
|
||||
}
|
||||
return $this->fail(CustomServiceLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @return \think\response\Json
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$params = (new CustomServiceValidate())->post()->goCheck('delete');
|
||||
CustomServiceLogic::delete($params);
|
||||
return $this->success('删除成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
@ -12,14 +12,17 @@
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\lists\custom_service;
|
||||
namespace app\adminapi\lists\custom;
|
||||
|
||||
|
||||
use app\adminapi\lists\BaseAdminDataLists;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom_service\CustomService;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomService;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use think\facade\Db;
|
||||
|
||||
@ -41,7 +44,8 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
public function setSearch(): array
|
||||
{
|
||||
return [
|
||||
'=' => ['cs.project_id', 'cs.custom_id', 'cs.approve_id', 'cs.contacts', 'cs.phone', 'cs.date', 'cs.classification', 'cs.urgency', 'cs.receiver', 'cs.processed_admin_id', 'cs.name'],
|
||||
'=' => ['project_id', 'custom_id', 'classification', 'urgency'],
|
||||
'%like%' => []
|
||||
];
|
||||
}
|
||||
|
||||
@ -57,26 +61,27 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
return Db::name('CustomService')->alias('cs')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('cs.delete_time')
|
||||
->leftJoin('orgs o','o.id = cs.org_id')
|
||||
->leftJoin('dept d','d.id = cs.dept_id')
|
||||
->field('cs.*, d.name as dept_name, o.name as org_name')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order(['cs.id' => 'desc'])
|
||||
->select()->each(function($item, $key){
|
||||
//关联数据后续添加
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name')->where('id',$item['custom_id'])->findOrEmpty();
|
||||
$admin = Admin::field('name')->where('id',$item['processed_admin_id'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['custom_name'] = $custom['name'];
|
||||
$item['processed_admin_name'] = $admin['name'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
return CustomService::field('id,project_id,custom_id,contract_id,name,receiver,date,classification,processing_result,urgency,processed_user,is_solve,done_date,score')
|
||||
->where($this->searchWhere)->limit($this->limitOffset, $this->limitLength)->order(['id' => 'desc'])
|
||||
->select()->each(function($item){
|
||||
$item['classification'] = $item->classification_text;
|
||||
$item['processing_result'] = $item->processing_result_text;
|
||||
$item['urgency'] = $item->urgency_text;
|
||||
$item['is_solve'] = $item->is_solve_text;
|
||||
$project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name,master_name,master_phone')->where('id',$item['custom_id'])->findOrEmpty();
|
||||
$contract = Contract::field('contract_code')->where('id',$item['contract_id'])->findOrEmpty();
|
||||
$admin = Admin::field('name')->where('id',$item['processed_user'])->findOrEmpty();
|
||||
$item['project_name'] = $project['name'];
|
||||
$item['project_code'] = $project['project_code'];
|
||||
$item['custom_name'] = $custom['name'];
|
||||
$item['custom_master_name'] = $custom['master_name'];
|
||||
$item['custom_master_phone'] = $custom['master_phone'];
|
||||
$item['contract_code'] = $contract['contract_code'];
|
||||
$item['processed_user'] = $admin['name'];
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
}
|
||||
|
||||
|
||||
@ -88,11 +93,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Db::name('CustomService')->alias('cs')
|
||||
->where($this->searchWhere)
|
||||
->whereNull('cs.delete_time')
|
||||
->leftJoin('orgs o','o.id = cs.org_id')
|
||||
->leftJoin('dept d','d.id = cs.dept_id')->count();
|
||||
return CustomService::where($this->searchWhere)->count();
|
||||
}
|
||||
|
||||
}
|
@ -72,7 +72,6 @@ class CustomContactsLogic extends BaseLogic
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$data = CustomContacts::field('annex')->where('id',$params['id'])->findOrEmpty();
|
||||
CustomContacts::where('id', $params['id'])->update([
|
||||
'custom_id' => $params['custom_id'],
|
||||
'name' => $params['name'],
|
||||
@ -81,7 +80,7 @@ class CustomContactsLogic extends BaseLogic
|
||||
'telephone' => $params['telephone'] ?? '',
|
||||
'email' => $params['email'] ?? '',
|
||||
'notes' => $params['notes'] ?? '',
|
||||
'annex' => $params['annex'] ?? $data['annex'],
|
||||
'annex' => !empty($params['annex']) ? $params['annex'] :null,
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
|
@ -18,6 +18,9 @@ namespace app\adminapi\logic\custom;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\custom\CustomContacts;
|
||||
use app\common\model\GeoArea;
|
||||
use app\common\model\GeoCity;
|
||||
use app\common\model\GeoProvince;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
@ -168,6 +171,12 @@ class CustomLogic extends BaseLogic
|
||||
$custom['dept_name'] = $custom->dept->name;
|
||||
$custom['custom_type_text'] = $custom->custom_type_text;
|
||||
$custom['credit_rating_text'] = $custom->credit_rating_text;
|
||||
$province = GeoProvince::field('province_name')->where('province_code',$custom['province'])->findOrEmpty();
|
||||
$city = GeoCity::field('city_name')->where('city_code',$custom['city'])->findOrEmpty();
|
||||
$area = GeoArea::field('area_name')->where('area_code',$custom['area'])->findOrEmpty();
|
||||
$custom['province_name'] = $province['province_name'];
|
||||
$custom['city_name'] = $city['city_name'];
|
||||
$custom['area_name'] = $area['area_name'];
|
||||
unset($custom['org'],$custom['dept']);
|
||||
return $custom->toArray();
|
||||
}
|
||||
|
151
app/adminapi/logic/custom/CustomServiceLogic.php
Normal file
151
app/adminapi/logic/custom/CustomServiceLogic.php
Normal file
@ -0,0 +1,151 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\custom;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\custom\CustomService;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\project\Project;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* CustomService逻辑
|
||||
* Class CustomServiceLogic
|
||||
* @package app\adminapi\logic\custom_service
|
||||
*/
|
||||
class CustomServiceLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomService::create([
|
||||
'org_id' => $params['org_id'],
|
||||
'dept_id' => $params['dept_id'],
|
||||
'project_id' => $params['project_id'],
|
||||
'custom_id' => $params['custom_id'],
|
||||
'contract_id' => $params['contract_id'],
|
||||
'date' => strtotime($params['date']),
|
||||
'classification' => $params['classification'],
|
||||
'urgency' => $params['urgency'],
|
||||
'receiver' => $params['receiver'],
|
||||
'processed_user' => $params['processed_user'],
|
||||
'name' => $params['name'],
|
||||
'description' => $params['description'] ?? '',
|
||||
'notes' => $params['notes'] ?? '',
|
||||
'annex' => $params['annex'] ?? null
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomService::where('id', $params['id'])->update([
|
||||
'processing_result' => $params['processing_result'],
|
||||
'processing_process' => $params['processing_process'] ?? '',
|
||||
'processing_hours' => $params['processing_hours'],
|
||||
'done_date' => strtotime($params['done_date']),
|
||||
'score' => $params['score'],
|
||||
'is_solve' => $params['is_solve'],
|
||||
'feedback' => $params['feedback'] ?? '',
|
||||
'update_time' => time()
|
||||
]);
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CustomService::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$field = 'id,org_id,dept_id,project_id,custom_id,contract_id,date,classification,urgency,receiver,processed_user,name,description,notes,annex,processing_result,processing_process,processing_hours,done_date,score,is_solve,feedback';
|
||||
$data = CustomService::field($field)->findOrEmpty($params['id']);
|
||||
$org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty();
|
||||
$dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty();
|
||||
$project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty();
|
||||
$custom = Custom::field('name,master_name,master_phone')->where('id',$data['custom_id'])->findOrEmpty();
|
||||
$contract = Contract::field('contract_code')->where('id',$data['contract_id'])->findOrEmpty();
|
||||
$admin = Admin::field('name')->where('id',$data['processed_user'])->findOrEmpty();
|
||||
$data['org_name'] = $org['name'];
|
||||
$data['dept_name'] = $dept['name'];
|
||||
$data['project_name'] = $project['name'];
|
||||
$data['project_code'] = $project['project_code'];
|
||||
$data['custom_name'] = $custom['name'];
|
||||
$data['custom_master_name'] = $custom['master_name'];
|
||||
$data['custom_master_phone'] = $custom['master_phone'];
|
||||
$data['contract_code'] = $contract['contract_code'];
|
||||
$data['processed_user_name'] = $admin['name'];
|
||||
$data['classification_text'] = $data->classification_text;
|
||||
$data['urgency_text'] = $data->urgency_text;
|
||||
$data['processing_result_text'] = $data->processing_result_text;
|
||||
$data['is_solve_text'] = $data->is_solve_text;
|
||||
return $data->toArray();
|
||||
}
|
||||
}
|
@ -1,142 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\logic\custom_service;
|
||||
|
||||
|
||||
use app\common\model\custom_service\CustomService;
|
||||
use app\common\logic\BaseLogic;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* CustomService逻辑
|
||||
* Class CustomServiceLogic
|
||||
* @package app\adminapi\logic\custom_service
|
||||
*/
|
||||
class CustomServiceLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function add(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomService::create([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'project_id' => $params['project_id'] ?? 0,
|
||||
'custom_id' => $params['custom_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'contacts' => $params['contacts'] ?? '',
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'date' => strtotime($params['date']),
|
||||
'classification' => $params['classification'] ?? 0,
|
||||
'urgency' => $params['urgency'] ?? 0,
|
||||
'receiver' => $params['receiver'] ?? '',
|
||||
'processed_admin_id' => $params['processed_admin_id'] ?? 0,
|
||||
'name' => $params['name'] ?? '',
|
||||
'description' => $params['description'] ?? 0,
|
||||
'notes' => $params['notes'] ?? '',
|
||||
'annex' => $params['annex'] ?? ''
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function edit(array $params): bool
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
CustomService::where('id', $params['id'])->update([
|
||||
'org_id' => $params['org_id'] ?? 0,
|
||||
'dept_id' => $params['dept_id'] ?? 0,
|
||||
'project_id' => $params['project_id'] ?? 0,
|
||||
'custom_id' => $params['custom_id'] ?? 0,
|
||||
'approve_id' => $params['approve_id'] ?? 0,
|
||||
'contacts' => $params['contacts'] ?? '',
|
||||
'phone' => $params['phone'] ?? '',
|
||||
'date' => strtotime($params['date']),
|
||||
'classification' => $params['classification'] ?? 0,
|
||||
'urgency' => $params['urgency'] ?? 0,
|
||||
'receiver' => $params['receiver'] ?? '',
|
||||
'processed_admin_id' => $params['processed_admin_id'] ?? 0,
|
||||
'name' => $params['name'] ?? '',
|
||||
'description' => $params['description'] ?? 0,
|
||||
'notes' => $params['notes'] ?? '',
|
||||
'annex' => $params['annex'] ?? ''
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function delete(array $params): bool
|
||||
{
|
||||
return CustomService::destroy($params['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public static function detail($params): array
|
||||
{
|
||||
$customService = CustomService::findOrEmpty($params['id']);
|
||||
$customService->project;
|
||||
$customService->custom;
|
||||
$customService->org;
|
||||
$customService->dept;
|
||||
$customService->annex = json_decode($customService->annex, true);
|
||||
return $customService->toArray();
|
||||
}
|
||||
}
|
239
app/adminapi/validate/custom/CustomServiceValidate.php
Normal file
239
app/adminapi/validate/custom/CustomServiceValidate.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\custom;
|
||||
|
||||
|
||||
use app\common\model\auth\Admin;
|
||||
use app\common\model\contract\Contract;
|
||||
use app\common\model\custom\Custom;
|
||||
use app\common\model\dept\Dept;
|
||||
use app\common\model\dept\Orgs;
|
||||
use app\common\model\dict\DictData;
|
||||
use app\common\model\project\Project;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CustomService验证器
|
||||
* Class CustomServiceValidate
|
||||
* @package app\adminapi\validate\custom_service
|
||||
*/
|
||||
class CustomServiceValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'org_id' => 'require|checkOrg',
|
||||
'dept_id' => 'require|checkDept',
|
||||
'project_id' => 'require|checkProject',
|
||||
'custom_id' => 'require|checkCustom',
|
||||
'contract_id' => 'require|checkContract',
|
||||
'date' => 'require|dateFormat:Y-m-d',
|
||||
'classification' => 'require|checkClassify',
|
||||
'urgency' => 'require|checkUrgency',
|
||||
'receiver' => 'require',
|
||||
'processed_user' => 'require|checkProUser',
|
||||
'name' => 'require',
|
||||
'annex' => 'checkAnnex',
|
||||
'processing_result' => 'require|checkProRes',
|
||||
'processing_hours' => 'require|float|egt:0',
|
||||
'done_date' => 'require|dateFormat:Y-m-d',
|
||||
'score' => 'require|integer|egt:0',
|
||||
'is_solve' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '缺少必要参数',
|
||||
'org_id.require' => '请选择组织',
|
||||
'dept_id.require' => '请选择部门',
|
||||
'project_id.require' => '请选择项目',
|
||||
'custom_id.require' => '请选择客户',
|
||||
'contract_id.require' => '请选择项目合同',
|
||||
'date.require' => '请选择日期',
|
||||
'date.dateFormat' => '日期格式错误',
|
||||
'classification.require' => '请选择分类',
|
||||
'urgency.require' => '请选择紧急程度',
|
||||
'receiver.require' => '请填写接待人',
|
||||
'processed_user.require' => '请选择指定处理人',
|
||||
'name.require' => '请填写投诉主题',
|
||||
'annex' => 'checkAnnex',
|
||||
'processing_result.require' => '请填写处理结果',
|
||||
'processing_hours.require' => '请填写花费工时',
|
||||
'processing_hours.float' => '花费工时值必须是数字',
|
||||
'processing_hours.egt' => '花费工时值必须大于等于0',
|
||||
'done_date.require' => '请选择完成日期',
|
||||
'done_date.dateFormat' => '完成日期格式错误',
|
||||
'score.require' => '请填写评分',
|
||||
'score.integer' => '评分值必须是整数',
|
||||
'score.egt' => '评分值必须大于等于0',
|
||||
'is_solve.require' => '请选择问题是否解决',
|
||||
'is_solve.in' => '问题是否解决选项值错误',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['org_id','dept_id','project_id','custom_id','contract_id','date','classification','urgency','processed_user','name']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','processing_result','processing_hours','done_date','score','is_solve']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function checkOrg($value): bool|string
|
||||
{
|
||||
$org = Orgs::where('id',$value)->findOrEmpty();
|
||||
if($org->isEmpty()){
|
||||
return '组织不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkDept($value,$rule,$data): bool|string
|
||||
{
|
||||
$dept = Dept::where('id',$value)->findOrEmpty();
|
||||
if($dept->isEmpty()){
|
||||
return '部门不存在';
|
||||
}
|
||||
if($dept['org_id'] != $data['org_id']){
|
||||
return '部门无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProject($value): bool|string
|
||||
{
|
||||
$project = Project::where('id',$value)->findOrEmpty();
|
||||
if($project->isEmpty()){
|
||||
return '项目不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkCustom($value,$rule,$data): bool|string
|
||||
{
|
||||
$custom = Custom::where('id',$value)->findOrEmpty();
|
||||
if($custom->isEmpty()){
|
||||
return '客户不存在';
|
||||
}
|
||||
$project = Project::where('id',$data['project_id'])->findOrEmpty();
|
||||
if($value != $project['custom_id']){
|
||||
return '客户信息与项目客户信息不一致';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkContract($value,$rule,$data): bool|string
|
||||
{
|
||||
$contract = Contract::where('id',$value)->findOrEmpty();
|
||||
if($contract->isEmpty()){
|
||||
return '项目合同不存在';
|
||||
}
|
||||
if($contract['project_id'] != $data['project_id']){
|
||||
return '该合同不属于选择的项目';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkClassify($value): bool|string
|
||||
{
|
||||
$dictData = DictData::where('type_value','classification')->column('value');
|
||||
if(!in_array($value,$dictData)){
|
||||
return '分类无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkUrgency($value): bool|string
|
||||
{
|
||||
$dictData = DictData::where('type_value','urgency')->column('value');
|
||||
if(!in_array($value,$dictData)){
|
||||
return '紧急程度无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProUser($value): bool|string
|
||||
{
|
||||
$admin = Admin::where('id',$value)->findOrEmpty();
|
||||
if($admin->isEmpty()){
|
||||
return '指定处理人不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAnnex($value): bool|string
|
||||
{
|
||||
if(!empty($value) && $value != ''){
|
||||
$annex = json_decode($value,true);
|
||||
if(empty($annex) || !is_array($annex)){
|
||||
return '附件格式错误';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkProRes($value): bool|string
|
||||
{
|
||||
$dictData = DictData::where('type_value','custom_service_solv_result')->column('value');
|
||||
if(!in_array($value,$dictData)){
|
||||
return '处理结果无效';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\adminapi\validate\custom_service;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* CustomService验证器
|
||||
* Class CustomServiceValidate
|
||||
* @package app\adminapi\validate\custom_service
|
||||
*/
|
||||
class CustomServiceValidate extends BaseValidate
|
||||
{
|
||||
|
||||
/**
|
||||
* 设置校验规则
|
||||
* @var string[]
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'project_id' => 'require',
|
||||
'custom_id' => 'require',
|
||||
'approve_id' => 'require',
|
||||
'receiver' => 'require',
|
||||
'processed_admin_id' => 'require',
|
||||
'name' => 'require',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* 参数描述
|
||||
* @var string[]
|
||||
*/
|
||||
protected $field = [
|
||||
'id' => 'id',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 添加场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->remove('id', true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 编辑场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 删除场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneDelete()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情场景
|
||||
* @return CustomServiceValidate
|
||||
* @author likeadmin
|
||||
* @date 2023/11/12 14:00
|
||||
*/
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
}
|
@ -12,10 +12,11 @@
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\custom_service;
|
||||
namespace app\common\model\custom;
|
||||
|
||||
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\dict\DictData;
|
||||
use think\model\concern\SoftDelete;
|
||||
|
||||
|
||||
@ -30,41 +31,40 @@ class CustomService extends BaseModel
|
||||
protected $name = 'custom_service';
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
public function getDateAttr($value)
|
||||
public function getDateAttr($value): string
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d', $value);
|
||||
}
|
||||
|
||||
public function custom()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\custom\Custom::class, 'custom_id');
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(\app\common\model\project\Project::class, 'project_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 关联org
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 11:01
|
||||
*/
|
||||
public function org()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Orgs::class, 'id', 'org_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 关联dept
|
||||
* @return \think\model\relation\HasOne
|
||||
* @author likeadmin
|
||||
* @date 2023/12/20 11:01
|
||||
*/
|
||||
public function dept()
|
||||
{
|
||||
return $this->hasOne(\app\common\model\dept\Dept::class, 'id', 'dept_id');
|
||||
}
|
||||
|
||||
public function getDoneDateAttr($value): string
|
||||
{
|
||||
return empty($value) ? '' : date('Y-m-d', $value);
|
||||
}
|
||||
|
||||
public function getClassificationTextAttr($value,$data){
|
||||
$dictData = DictData::where('type_value','classification')->column('name','value');
|
||||
return $dictData[$data['classification']];
|
||||
}
|
||||
|
||||
public function getUrgencyTextAttr($value,$data){
|
||||
$dictData = DictData::where('type_value','urgency')->column('name','value');
|
||||
return $dictData[$data['urgency']];
|
||||
}
|
||||
|
||||
public function getProcessingResultTextAttr($value,$data){
|
||||
$dictData = DictData::where('type_value','custom_service_solv_result')->column('name','value');
|
||||
return $dictData[$data['processing_result']];
|
||||
}
|
||||
|
||||
public function getIsSolveTextAttr($value,$data): string
|
||||
{
|
||||
$is_solve = [0=>'未解决',1=>'已解决'];
|
||||
return $is_solve[$data['is_solve']];
|
||||
}
|
||||
|
||||
public function getAnnexAttr($value)
|
||||
{
|
||||
return empty($value) ? null : json_decode($value,true);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user