From 04cb00948de3ccc3b6fa10d3ffdd04053e4b0302 Mon Sep 17 00:00:00 2001 From: wh <382379437@qq.com> Date: Thu, 27 Mar 2025 19:45:35 +0800 Subject: [PATCH] fixed --- .../admin/controller/Firmcustomer.php | 13 +- .../controller/Firmcustomerfollowuprecord.php | 130 +++++++++++++++++- .../Firmcustomerfollowuptimelist.php | 103 ++++++++++++++ .../application/admin/controller/Firmduty.php | 2 +- .../admin/controller/Firmstore.php | 1 + .../admin/controller/Firmstoreprojectsone.php | 2 +- .../admin/controller/Firmstoreprojectstwo.php | 2 +- .../application/admin/controller/Firmtags.php | 8 ++ .../admin/controller/general/Profile.php | 5 +- .../admin/view/firmcustomer/add.html | 6 +- .../admin/view/firmcustomer/edit.html | 6 +- .../view/firmcustomerfollowuprecord/add.html | 24 ++-- .../view/firmcustomerfollowuprecord/edit.html | 13 +- .../firmcustomerfollowuprecord/index.html | 24 ++-- .../firmcustomerfollowuptimelist/add.html | 5 +- .../firmcustomerfollowuptimelist/index.html | 6 +- .../admin/view/firmstoreprojectsone/add.html | 1 - .../admin/view/firmstoreprojectsone/edit.html | 1 - .../admin/view/general/profile/index.html | 2 +- admin/application/api/controller/Wxgroup.php | 2 +- .../public/assets/js/backend/firmcustomer.js | 17 +-- .../js/backend/firmcustomerfollowuprecord.js | 18 ++- .../backend/firmcustomerfollowuptimelist.js | 17 ++- 23 files changed, 343 insertions(+), 65 deletions(-) diff --git a/admin/application/admin/controller/Firmcustomer.php b/admin/application/admin/controller/Firmcustomer.php index 18ad263..859b372 100755 --- a/admin/application/admin/controller/Firmcustomer.php +++ b/admin/application/admin/controller/Firmcustomer.php @@ -17,6 +17,7 @@ use wanghua\general_utility_tools_php\tool\Tools; */ class Firmcustomer extends Backend { + protected $noNeedRight = ['firmcustomerGetList']; /** * Firmcustomer模型对象 @@ -57,7 +58,7 @@ class Firmcustomer extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $this->model->where('firmcustomer.firm_id',session_admin_firm_id()); - $this->model->where('firmcustomer.firmstore_id',session_admin_firmstore_id()); + //$this->model->where('firmcustomer.firmstore_id',session_admin_firmstore_id()); $list = $this->model ->with(['firmstoreprojectstwo','firmcustomerorigin']) ->where($where) @@ -65,7 +66,7 @@ class Firmcustomer extends Backend ->paginate($limit); foreach ($list as $row) { - $row->visible(['id','customer_name','age','phone','rel_wx','rel_group','firmtags_ids','headimage','remark','responsible_pm','return_visit_content','status','create_time','admin_id']); + $row->visible(['id','name','firmcustomer_id','age','phone','rel_wx','rel_group','firmtags_ids','headimage','remark','responsible_pm','return_visit_content','status','create_time','admin_id']); $row->visible(['firmstoreprojectstwo']); $row->getRelation('firmstoreprojectstwo')->visible(['name']); $row->visible(['firmcustomerorigin']); @@ -194,4 +195,12 @@ class Firmcustomer extends Backend //cache('cache_ai_customer_config_'.session_admin_firm_id(),$ai_config,86400); return json(Tools::set_ok('设置成功')); } + + function firmcustomerGetList(){ + + $data = Db::table('fa_firmcustomer') + ->where('firm_id',session_admin_firm_id()) + ->select(); + return json(['list' => $data, 'total' => count($data)]); + } } diff --git a/admin/application/admin/controller/Firmcustomerfollowuprecord.php b/admin/application/admin/controller/Firmcustomerfollowuprecord.php index 1dcd3ea..469dee1 100755 --- a/admin/application/admin/controller/Firmcustomerfollowuprecord.php +++ b/admin/application/admin/controller/Firmcustomerfollowuprecord.php @@ -3,6 +3,10 @@ namespace app\admin\controller; use app\common\controller\Backend; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 客户回访记录 @@ -11,6 +15,7 @@ use app\common\controller\Backend; */ class Firmcustomerfollowuprecord extends Backend { + //protected $selectpageFields = 'name,store_project_name'; /** * Firmcustomerfollowuprecord模型对象 @@ -41,6 +46,8 @@ class Firmcustomerfollowuprecord extends Backend */ public function index() { + $ids = input('ids'); + $this->assignconfig('firmcustomer_id',$ids); //当前是否为关联查询 $this->relationSearch = false; //设置过滤方法 @@ -52,6 +59,10 @@ class Firmcustomerfollowuprecord extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $firmcustomer_id = input('firmcustomer_id'); + if($firmcustomer_id){ + $this->model->where('firmcustomer_id',$firmcustomer_id); + } $list = $this->model ->where($where) @@ -59,8 +70,7 @@ class Firmcustomerfollowuprecord extends Backend ->paginate($limit); foreach ($list as $row) { - $row->visible(['id','name','store_project_name','remark','notes','visit_msg','feedback','send_time','status','create_time']); - + $row->visible(['id','name','firmcustomer_id','store_project_name','remark','notes','visit_msg','feedback','send_time','status','create_time']); } $result = array("total" => $list->total(), "rows" => $list->items()); @@ -70,4 +80,120 @@ class Firmcustomerfollowuprecord extends Backend return $this->view->fetch(); } + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + $firmcustomer_id = input('ids'); + $this->assign('firmcustomer_id',$firmcustomer_id); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $params['name'] = Db::table('fa_firmcustomer') + ->where('id',$params['firmcustomer_id']) + ->value('name'); + $title_one = Db::table('fa_firmstoreprojectsone') + ->where('id',$params['firmstoreprojectsone_id']) + ->value('name'); + $title_two = Db::table('fa_firmstoreprojectstwo') + ->where('id',$params['firmstoreprojectstwo_id']) + ->value('name'); + $params['store_project_name'] = $title_one . ' - ' .$title_two; + $params['notes'] = Db::table('fa_firmnotespoints') + ->where('id',$params['firmnotespoints_id']) + ->value('name'); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params['name'] = Db::table('fa_firmcustomer') + ->where('id',$params['firmcustomer_id']) + ->value('name'); + $title_one = Db::table('fa_firmstoreprojectsone') + ->where('id',$params['firmstoreprojectsone_id']) + ->value('name'); + $title_two = Db::table('fa_firmstoreprojectstwo') + ->where('id',$params['firmstoreprojectstwo_id']) + ->value('name'); + $params['store_project_name'] = $title_one . ' - ' .$title_two; + $params['notes'] = Db::table('fa_firmnotespoints') + ->where('id',$params['firmnotespoints_id']) + ->value('name'); + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } } diff --git a/admin/application/admin/controller/Firmcustomerfollowuptimelist.php b/admin/application/admin/controller/Firmcustomerfollowuptimelist.php index d15d9f6..022fb96 100755 --- a/admin/application/admin/controller/Firmcustomerfollowuptimelist.php +++ b/admin/application/admin/controller/Firmcustomerfollowuptimelist.php @@ -3,6 +3,10 @@ namespace app\admin\controller; use app\common\controller\Backend; +use think\Db; +use think\Exception; +use think\exception\PDOException; +use think\exception\ValidateException; /** * 回访发送时间列管理 @@ -12,6 +16,7 @@ use app\common\controller\Backend; class Firmcustomerfollowuptimelist extends Backend { + //protected $selectpageFields = 'name,store_project_name'; /** * Firmcustomerfollowuptimelist模型对象 * @var \app\admin\model\Firmcustomerfollowuptimelist @@ -50,6 +55,10 @@ class Firmcustomerfollowuptimelist extends Backend } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + $record_id = input('record_id'); + if ($record_id){ + $this->model->where('firmcustomerfollowuprecord_id',$record_id); + } $list = $this->model ->with(['firmcustomerfollowuprecord']) ->where($where) @@ -60,13 +69,107 @@ class Firmcustomerfollowuptimelist extends Backend $row->visible(['id','day','followup_time']); $row->visible(['firmcustomerfollowuprecord']); $row->getRelation('firmcustomerfollowuprecord')->visible(['name']); + } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } + + $ids = input('ids'); + $this->assignconfig('record_id',$ids); return $this->view->fetch(); } + /** + * 添加 + * + * @return string + * @throws \think\Exception + */ + public function add() + { + if (false === $this->request->isPost()) { + $ids = input('ids'); + $this->assign('record_id',$ids); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function edit($ids = null) + { + $row = $this->model->get($ids); + if (!$row) { + $this->error(__('No Results were found')); + } + $adminIds = $this->getDataLimitAdminIds(); + if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) { + $this->error(__('You have no permission')); + } + if (false === $this->request->isPost()) { + $this->view->assign('row', $row); + return $this->view->fetch(); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + $result = false; + Db::startTrans(); + try { + //是否采用模型验证 + if ($this->modelValidate) { + $name = str_replace("\\model\\", "\\validate\\", get_class($this->model)); + $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate; + $row->validateFailException()->validate($validate); + } + $result = $row->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if (false === $result) { + $this->error(__('No rows were updated')); + } + $this->success(); + } } diff --git a/admin/application/admin/controller/Firmduty.php b/admin/application/admin/controller/Firmduty.php index ffe331a..c72163d 100755 --- a/admin/application/admin/controller/Firmduty.php +++ b/admin/application/admin/controller/Firmduty.php @@ -12,6 +12,7 @@ use app\common\controller\Backend; class Firmduty extends Backend { + protected $noNeedRight = ['firmdutyGetList']; /** * Firmduty模型对象 * @var \app\admin\model\Firmduty @@ -23,7 +24,6 @@ class Firmduty extends Backend parent::_initialize(); $this->model = new \app\admin\model\Firmduty; $this->model->where('firm_id',session_admin_firm_id()); - $this->model->where('firmstore_id',session_admin_firmstore_id()); } diff --git a/admin/application/admin/controller/Firmstore.php b/admin/application/admin/controller/Firmstore.php index 89e0364..50e5c0f 100755 --- a/admin/application/admin/controller/Firmstore.php +++ b/admin/application/admin/controller/Firmstore.php @@ -12,6 +12,7 @@ use think\Db; */ class Firmstore extends Backend { + protected $noNeedRight = ['firmstoreGetList']; /** * Firmstore模型对象 diff --git a/admin/application/admin/controller/Firmstoreprojectsone.php b/admin/application/admin/controller/Firmstoreprojectsone.php index b82cf7c..a37dd7d 100755 --- a/admin/application/admin/controller/Firmstoreprojectsone.php +++ b/admin/application/admin/controller/Firmstoreprojectsone.php @@ -24,7 +24,7 @@ class Firmstoreprojectsone extends Backend $this->model = new \app\admin\model\Firmstoreprojectsone; $this->model->where('firm_id',session_admin_firm_id()); - $this->model->where('firmstore_id',session_admin_firmstore_id()); + //$this->model->where('firmstore_id',session_admin_firmstore_id()); } diff --git a/admin/application/admin/controller/Firmstoreprojectstwo.php b/admin/application/admin/controller/Firmstoreprojectstwo.php index 9794611..ebf8b6d 100755 --- a/admin/application/admin/controller/Firmstoreprojectstwo.php +++ b/admin/application/admin/controller/Firmstoreprojectstwo.php @@ -51,7 +51,7 @@ class Firmstoreprojectstwo extends Backend list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $this->model->where('firmstoreprojectstwo.firm_id',session_admin_firm_id()); - $this->model->where('firmstoreprojectstwo.firmstore_id',session_admin_firmstore_id()); + //$this->model->where('firmstoreprojectstwo.firmstore_id',session_admin_firmstore_id()); $list = $this->model ->with(['firmstoreprojectsone']) ->where($where) diff --git a/admin/application/admin/controller/Firmtags.php b/admin/application/admin/controller/Firmtags.php index 03f43bc..1457f68 100755 --- a/admin/application/admin/controller/Firmtags.php +++ b/admin/application/admin/controller/Firmtags.php @@ -15,6 +15,7 @@ use think\exception\ValidateException; */ class Firmtags extends Backend { + protected $noNeedRight=['firmtagsGetList']; /** * Firmtags模型对象 @@ -127,4 +128,11 @@ class Firmtags extends Backend //将转义的代码还原 return json(['html'=>($html)]); } + + function firmtagsGetList(){ + $data = Db::table('fa_firmtags') + ->where('firm_id',session_admin_firm_id()) + ->select(); + return json(['list' => $data, 'total' => count($data)]); + } } diff --git a/admin/application/admin/controller/general/Profile.php b/admin/application/admin/controller/general/Profile.php index cd6eef6..9d873d2 100755 --- a/admin/application/admin/controller/general/Profile.php +++ b/admin/application/admin/controller/general/Profile.php @@ -40,6 +40,9 @@ class Profile extends Backend return json($result); } + + $admin = Admin::get($this->auth->id); + $this->assign('admin', $admin); return $this->view->fetch(); } @@ -53,7 +56,7 @@ class Profile extends Backend $params = $this->request->post("row/a"); $params = array_filter(array_intersect_key( $params, - array_flip(array('email', 'nickname', 'password', 'avatar')) + array_flip(array('email', 'nickname', 'password', 'avatar','firm_id','firmstore_id','firmduty_id')) )); unset($v); if (!Validate::is($params['email'], "email")) { diff --git a/admin/application/admin/view/firmcustomer/add.html b/admin/application/admin/view/firmcustomer/add.html index 5d7b9c1..6c0285f 100755 --- a/admin/application/admin/view/firmcustomer/add.html +++ b/admin/application/admin/view/firmcustomer/add.html @@ -19,7 +19,7 @@