diff --git a/application/admin/command/AreaPinyinCommand.php b/application/admin/command/AreaPinyinCommand.php index d49b6ee..2feeb71 100644 --- a/application/admin/command/AreaPinyinCommand.php +++ b/application/admin/command/AreaPinyinCommand.php @@ -22,11 +22,11 @@ class AreaPinyinCommand extends Command $pinyin = new Pinyin(); // 读取 `area` 表所有数据 - $areas = Db::name('areas')->where('id','>',1738)->select(); + $areas = Db::name('areas')->where('id','>',0)->select(); foreach ($areas as $area) { - $fullPinyin = strtolower(str_replace(' ','',$pinyin->name($area['short_name'],Converter::TONE_STYLE_NONE))); // 全拼 - $abbrPinyin = strtolower(str_replace(' ','',$pinyin->abbr($area['short_name']))); // 首字母 + $fullPinyin = strtolower(str_replace(' ','',$pinyin->name($area['merge_name'],Converter::TONE_STYLE_NONE))); // 全拼 + $abbrPinyin = strtolower(str_replace(' ','',$pinyin->abbr($area['merge_name']))); // 首字母 // 更新数据库 Db::name('areas') ->where('id', $area['id']) diff --git a/application/admin/controller/Item.php b/application/admin/controller/Item.php new file mode 100644 index 0000000..2f33226 --- /dev/null +++ b/application/admin/controller/Item.php @@ -0,0 +1,123 @@ +model = new \app\admin\model\Item; + + + // 必须将结果集转换为数组 + $ruleList = \think\Db::name("item")->field('id,pid,level,title')->order('sort DESC,id ASC')->select(); + + Tree::instance()->init($ruleList)->icon = [' ', ' ', ' ']; +// dd($ruleList); + $this->rulelist = Tree::instance()->getTreeList(Tree::instance()->getTreeArray(0), 'title'); + $itemdata = [0 => __('None')]; + foreach ($this->rulelist as $k => $v) { + $itemdata[$v['id']] = $v['title']; + } + unset($v); + + $this->view->assign('itemdata', $itemdata); + + $this->view->assign("statusList", $this->model->getStatusList()); + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + 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; + } + $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); + } + + $pid = $params['pid']; + if ($pid > 0){ + $parent = $this->model->where('id',$pid)->find(); + if ($parent){ + $params['level'] = $parent->value('level') + 1; + } + }else{ + $params['level'] = 0; + } + + + $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(); + } + + public function search(){ + + $keyword = request()->get('keyword'); + if (!$keyword){ + $this->success(data:[]); + }else{ + $data = model('item') +// ->where('level','=',3) + ->where(function ($query)use ($keyword){ + $query->where('title','like','%'.$keyword.'%') + ->whereOr('key_word', 'like', "%{$keyword}%"); + }) + ->order('level','desc') + ->field('title,id') + ->limit(0,10) + ->select(); + $this->success(data:$data); + } + + } +} diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index 3828f91..d25305d 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -53,7 +53,7 @@ class Order extends Backend [$where, $sort, $order, $offset, $limit] = $this->buildparams(); $list = $this->model ->field(['id','order_no','customer','tel','status','area_id','address', - 'work_tel_id','worker_id','source','source_uid','service_id','service_title', + 'work_tel_id','worker_id','source','source_uid','service_title', 'detail','remark','images','create_time','update_time']) ->where($where) ->order($sort, $order) diff --git a/application/admin/lang/zh-cn/item.php b/application/admin/lang/zh-cn/item.php new file mode 100644 index 0000000..fd5908f --- /dev/null +++ b/application/admin/lang/zh-cn/item.php @@ -0,0 +1,16 @@ + 'ID', + 'Pid' => 'PID', + 'Level' => '层级', + 'Title' => '服务名称', + 'Key_word' => '关键字', + 'Image' => '图标', + 'Sort' => '排序', + 'Status' => '状态', + 'Status 1' => '启用', + 'Set status to 1'=> '设为启用', + 'Status 0' => '关闭', + 'Set status to 0'=> '设为关闭' +]; diff --git a/application/admin/model/Item.php b/application/admin/model/Item.php new file mode 100644 index 0000000..4314b80 --- /dev/null +++ b/application/admin/model/Item.php @@ -0,0 +1,49 @@ + __('Status 1'), '0' => __('Status 0')]; + } + + + public function getStatusTextAttr($value, $data) + { + $value = $value ?: ($data['status'] ?? ''); + $list = $this->getStatusList(); + return $list[$value] ?? ''; + } + + + + +} diff --git a/application/admin/validate/Item.php b/application/admin/validate/Item.php new file mode 100644 index 0000000..4bdb62f --- /dev/null +++ b/application/admin/validate/Item.php @@ -0,0 +1,27 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/item/add.html b/application/admin/view/item/add.html new file mode 100644 index 0000000..c7067f5 --- /dev/null +++ b/application/admin/view/item/add.html @@ -0,0 +1,60 @@ +
diff --git a/application/admin/view/item/edit.html b/application/admin/view/item/edit.html new file mode 100644 index 0000000..ad4c48d --- /dev/null +++ b/application/admin/view/item/edit.html @@ -0,0 +1,65 @@ + diff --git a/application/admin/view/item/index.html b/application/admin/view/item/index.html new file mode 100644 index 0000000..a597675 --- /dev/null +++ b/application/admin/view/item/index.html @@ -0,0 +1,46 @@ +