diff --git a/superadmin/application/admin/controller/Aicustomerservicefirmstorelist.php b/superadmin/application/admin/controller/Aicustomerservicefirmstorelist.php new file mode 100644 index 0000000..e03a891 --- /dev/null +++ b/superadmin/application/admin/controller/Aicustomerservicefirmstorelist.php @@ -0,0 +1,73 @@ +model = new \app\admin\model\Aicustomerservicefirmstorelist; + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + + /** + * 查看 + */ + public function index() + { + //当前是否为关联查询 + $this->relationSearch = true; + //设置过滤方法 + $this->request->filter(['strip_tags', 'trim']); + if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) { + return $this->selectpage(); + } + list($where, $sort, $order, $offset, $limit) = $this->buildparams(); + + $list = $this->model + ->with(['aicustomerservice','firm']) + ->where($where) + ->order($sort, $order) + ->paginate($limit); + + foreach ($list as $row) { + $row->visible(['id','status','total_managed_people','total_managed_groups','reply_times','update_time']); + $row->visible(['aicustomerservice']); + $row->visible(['firm']); + $row->getRelation('firm')->visible(['name']); + } + + $result = array("total" => $list->total(), "rows" => $list->items()); + + return json($result); + } + return $this->view->fetch(); + } + +} diff --git a/superadmin/application/admin/controller/Firm.php b/superadmin/application/admin/controller/Firm.php index c2fb215..fd6c710 100755 --- a/superadmin/application/admin/controller/Firm.php +++ b/superadmin/application/admin/controller/Firm.php @@ -48,4 +48,69 @@ class Firm extends Backend ->select(); return json(['list'=>$info,'total'=>$info]); } + + public function add() + { + if (false === $this->request->isPost()) { + 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; + } + 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)->insertGetId($params); + $addaicustomerswrvicelistResult = $this->addaicustomerswrvicelist($params,$result); + if (!$addaicustomerswrvicelistResult['res']){ + $this->error($addaicustomerswrvicelistResult['text']); + Db::rollback(); + } + Db::table('fa_aicustomerservicefirmstorelist')->insertAll($addaicustomerswrvicelistResult['data']); + 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 $params + * @param $firm_id + * @return void + */ + public function addaicustomerswrvicelist($params,$firm_id){ + $aicustomerservice_ids = explode(',',$params['aicustomerservice_ids']); + if (!$firm_id){ + return ['res'=>false,'text'=>'企业添加失败,请重新操作']; + } + if(count($aicustomerservice_ids) < 1 ){ + return ['res'=>false,'text'=>'请添加机器人']; + } + $data = []; + foreach ($aicustomerservice_ids as $key=>$val){ + $data[$key]['firm_id'] = $firm_id; + $data[$key]['aicustomerservice_id'] = $val; + $data[$key]['status'] = 'yes'; + $data[$key]['create_time'] = $params['create_time']; + $data[$key]['update_time'] = $params['create_time']; + } + return ['res'=>true,'data'=>$data]; + } } diff --git a/superadmin/application/admin/lang/zh-cn/aicustomerservicefirmstorelist.php b/superadmin/application/admin/lang/zh-cn/aicustomerservicefirmstorelist.php new file mode 100644 index 0000000..fdaa7ba --- /dev/null +++ b/superadmin/application/admin/lang/zh-cn/aicustomerservicefirmstorelist.php @@ -0,0 +1,19 @@ + 'ID', + 'Aicustomerservice_id' => 'AI 客服 ', + 'Firm_id' => '所属企业 ', + 'Status' => '状态', + 'Status yes' => '在线', + 'Set status to yes' => '设为在线', + 'Status no' => '离线', + 'Set status to no' => '设为离线', + 'Total_managed_people' => '管理总人数/个', + 'Total_managed_groups' => '管理总群数/个', + 'Reply_times' => '回复时间/秒', + 'Create_time' => '创建时间', + 'Update_time' => '更新时间', + 'Aicustomerservice.name' => 'AI客服名称', + 'Firm.name' => '所属企业名称' +]; diff --git a/superadmin/application/admin/model/Aicustomerservicefirmstorelist.php b/superadmin/application/admin/model/Aicustomerservicefirmstorelist.php new file mode 100644 index 0000000..921baf0 --- /dev/null +++ b/superadmin/application/admin/model/Aicustomerservicefirmstorelist.php @@ -0,0 +1,58 @@ + __('Status yes'), 'no' => __('Status no')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); + $list = $this->getStatusList(); + return isset($list[$value]) ? $list[$value] : ''; + } + + + + + public function aicustomerservice() + { + return $this->belongsTo('Aicustomerservice', 'aicustomerservice_id', 'id', [], 'LEFT')->setEagerlyType(0); + } + + public function firm() + { + return $this->belongsTo('Firm', 'firm_id', 'id', [], 'LEFT')->setEagerlyType(0); + } +} diff --git a/superadmin/application/admin/validate/Aicustomerservicefirmstorelist.php b/superadmin/application/admin/validate/Aicustomerservicefirmstorelist.php new file mode 100644 index 0000000..ff86e4b --- /dev/null +++ b/superadmin/application/admin/validate/Aicustomerservicefirmstorelist.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/superadmin/application/admin/view/aicustomerservicefirmstorelist/add.html b/superadmin/application/admin/view/aicustomerservicefirmstorelist/add.html new file mode 100644 index 0000000..48fc009 --- /dev/null +++ b/superadmin/application/admin/view/aicustomerservicefirmstorelist/add.html @@ -0,0 +1,45 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/superadmin/application/admin/view/aicustomerservicefirmstorelist/edit.html b/superadmin/application/admin/view/aicustomerservicefirmstorelist/edit.html new file mode 100644 index 0000000..60709d7 --- /dev/null +++ b/superadmin/application/admin/view/aicustomerservicefirmstorelist/edit.html @@ -0,0 +1,63 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ {foreach name="statusList" item="vo"} + + {/foreach} +
+ +
+
+ + + + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + +
diff --git a/superadmin/application/admin/view/aicustomerservicefirmstorelist/index.html b/superadmin/application/admin/view/aicustomerservicefirmstorelist/index.html new file mode 100644 index 0000000..d1ef983 --- /dev/null +++ b/superadmin/application/admin/view/aicustomerservicefirmstorelist/index.html @@ -0,0 +1,46 @@ +
+ +
+ {:build_heading(null,FALSE)} + +
+ + +
+
+
+
+
+ + {:__('Add')} + + + + + + + +
+ +
+
+
+ +
+
+
diff --git a/superadmin/application/admin/view/firmcustomer/add.html b/superadmin/application/admin/view/firmcustomer/add.html index b8ed834..b4f3ea7 100755 --- a/superadmin/application/admin/view/firmcustomer/add.html +++ b/superadmin/application/admin/view/firmcustomer/add.html @@ -16,7 +16,7 @@
- +
diff --git a/superadmin/public/assets/js/backend/aicustomerservicefirmstorelist.js b/superadmin/public/assets/js/backend/aicustomerservicefirmstorelist.js new file mode 100644 index 0000000..04732b3 --- /dev/null +++ b/superadmin/public/assets/js/backend/aicustomerservicefirmstorelist.js @@ -0,0 +1,59 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'aicustomerservicefirmstorelist/index' + location.search, + add_url: 'aicustomerservicefirmstorelist/add', + edit_url: 'aicustomerservicefirmstorelist/edit', + del_url: 'aicustomerservicefirmstorelist/del', + multi_url: 'aicustomerservicefirmstorelist/multi', + import_url: 'aicustomerservicefirmstorelist/import', + table: 'aicustomerservicefirmstorelist', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'aicustomerservice.name', title: __('Aicustomerservice.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'firm.name', title: __('Firm.name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'status', title: __('Status'), searchList: {"yes":__('Status yes'),"no":__('Status no')}, formatter: Table.api.formatter.status}, + {field: 'total_managed_people', title: __('Total_managed_people')}, + {field: 'total_managed_groups', title: __('Total_managed_groups')}, + {field: 'reply_times', title: __('Reply_times')}, + {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +});