diff --git a/application/admin/command/AreaPinyinCommand.php b/application/admin/command/AreaPinyinCommand.php new file mode 100644 index 0000000..2feeb71 --- /dev/null +++ b/application/admin/command/AreaPinyinCommand.php @@ -0,0 +1,40 @@ +setName('area:pinyin') + ->setDescription('批量生成区域名称的拼音'); + } + + protected function execute(Input $input, Output $output) + { + $pinyin = new Pinyin(); + + // 读取 `area` 表所有数据 + $areas = Db::name('areas')->where('id','>',0)->select(); + + foreach ($areas as $area) { + $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']) + ->update(['pinyin' => $fullPinyin, 'abbr' => $abbrPinyin]); + + $output->writeln("更新: {$area['merge_name']} -> {$fullPinyin} ({$abbrPinyin})"); + } + + $output->writeln("拼音转换完成!"); + } +} diff --git a/application/admin/controller/Area.php b/application/admin/controller/Area.php index 89edbe1..be5df7e 100644 --- a/application/admin/controller/Area.php +++ b/application/admin/controller/Area.php @@ -19,9 +19,22 @@ class Area extends Backend $this->success(data:[]); }else{ $data = model('area') - ->where('merge_name','like','%'.$keyword.'%') ->where('level','=',3) + ->where(function ($query)use ($keyword){ + $query->where('merge_name','like','%'.$keyword.'%') + ->whereOr('pinyin', 'like', "%{$keyword}%") + ->whereOr('abbr', 'like', "%{$keyword}%"); + }) + ->field('area_code, merge_name') + ->orderRaw( + "CASE + WHEN name LIKE '{$keyword}%' THEN 1 + WHEN pinyin LIKE '{$keyword}%' THEN 2 + WHEN abbr LIKE '{$keyword}%' THEN 3 + ELSE 4 + END" + ) ->limit(0,10) ->select(); $this->success(data:$data); 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 36cdcdb..d25305d 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -52,6 +52,9 @@ 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_title', + 'detail','remark','images','create_time','update_time']) ->where($where) ->order($sort, $order) ->paginate($limit); @@ -86,7 +89,8 @@ class Order extends Backend $params['enter_admin_id'] = $this->auth->id; $params['status'] = 10; $params['order_no'] = $this->generateOrderNumber(); - + $params['create_time'] = date('Y-m-d H:i:s'); + $params['update_time'] = date('Y-m-d H:i:s'); $result = $this->model->allowField(true)->save($params); Db::commit(); @@ -100,6 +104,73 @@ class Order extends Backend $this->success(); } + public function edit($ids = null) + { + + if (!$ids) { + if (request()->isPost()){ + $ids = input('id'); + if (!$ids){ + $this->error('缺少订单ID'); + } + }else{ + $this->error('缺少订单ID'); + } + } + + // 获取当前ID对应的订单信息 + $order = $this->model->get($ids); + if (!$order) { + $this->error('订单不存在'); + } + + // 判断是否为POST请求,进行更新操作 + if (request()->isPost()) { + // 获取表单提交的数据 + $data = input('post.row/a'); + $data['update_time'] = date('Y-m-d H:i:s'); + // 更新订单信息 + $order->save($data); + + // 返回成功信息 + $this->success('更新成功', 'index'); + } + $area = new \app\admin\model\Area(); + $area_name = $area->getNameByCode($order->area_id); + $order->area_name = $area_name; + + // 将订单数据传递到视图 + $this->assign('row', $order); + + // 渲染编辑页面 + return $this->fetch(); + } + + + public function copy($ids = null) + { + if (!$ids) { + $this->error('缺少订单ID'); + } + + // 获取当前ID对应的订单信息 + $order = $this->model->get($ids); + if (!$order) { + $this->error('订单不存在'); + } + + + $area = new \app\admin\model\Area(); + $area_name = $area->getNameByCode($order->area_id); + $order->area_name = $area_name; + + // 将订单数据传递到视图 + $this->assign('row', $order); + + // 渲染编辑页面 + return $this->fetch(); + } + function generateOrderNumber($prefix = 'ORD') { // 获取当前时间戳(精确到毫秒) $timestamp = microtime(true); 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/Area.php b/application/admin/model/Area.php index 68bc67c..94919f6 100644 --- a/application/admin/model/Area.php +++ b/application/admin/model/Area.php @@ -10,6 +10,11 @@ class Area extends Model // 表名 protected $name = 'areas'; + + + public function getNameByCode($code){ + return $this->where('area_code',$code)->find()->value('merge_name'); + } } 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 @@ +
+ +
+ +
+ {:build_select('row[pid]', $itemdata, null, ['class'=>'form-control', 'required'=>''])} +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ + +
+ +
+
    +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    + {foreach name="statusList" item="vo"} + + {/foreach} +
    + +
    +
    + +
    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 @@ +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      + {foreach name="statusList" item="vo"} + + {/foreach} +
      + +
      +
      + +
      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 @@ +
      + +
      + {:build_heading(null,FALSE)} + +
      + + +
      +
      +
      +
      +
      + + {:__('Add')} + {:__('Edit')} + {:__('Delete')} + + + + + +
      + +
      +
      +
      + +
      +
      +
      diff --git a/application/admin/view/order/add.html b/application/admin/view/order/add.html index e9e4804..cb76525 100644 --- a/application/admin/view/order/add.html +++ b/application/admin/view/order/add.html @@ -87,7 +87,8 @@ diff --git a/application/admin/view/order/copy.html b/application/admin/view/order/copy.html new file mode 100644 index 0000000..e5a0a5b --- /dev/null +++ b/application/admin/view/order/copy.html @@ -0,0 +1,164 @@ +
      +
      +
      + +
      +
      +
      +
      复制订单
      +
      + + + +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + + + + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      + + + + + + + +
      +
      +
      + +
      + +
      +
      +
      + +
      + +
      +
      +
      + +
      +
      + +
      + + +
      + +
      +
        +
        +
        + +
        +
        +
        +
        + + +
        +
        快速输入
        +
        + +
        +
        +
        +
        + + \ No newline at end of file diff --git a/application/admin/view/order/edit.html b/application/admin/view/order/edit.html index cbb1e00..92d63d0 100644 --- a/application/admin/view/order/edit.html +++ b/application/admin/view/order/edit.html @@ -1,245 +1,164 @@ -
        +
        +
        +
        + +
        +
        +
        +
        编辑订单
        + -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        - {foreach name="statusList" item="vo"} - - {/foreach} -
        + -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        - -
        -
        -
        - -
        -
        - -
        - - +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + + + + + + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        + + + + + + + +
        +
        +
        + +
        + +
        +
        +
        + +
        + +
        +
        +
        + +
        +
        + +
        + + +
        + +
        +
          +
          +
          + +
          -
          -
            -
            -
            - -
            - - + +
            +
            快速输入
            +
            + +
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - - +
            -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            -
            - -
            - -
            -
            - - + \ No newline at end of file diff --git a/application/admin/view/order/index.html b/application/admin/view/order/index.html index 7209a05..ef078d8 100644 --- a/application/admin/view/order/index.html +++ b/application/admin/view/order/index.html @@ -1,15 +1,4 @@
            - -
            - {:build_heading(null,FALSE)} - -
            -
            @@ -22,14 +11,14 @@ {:__('Delete')} - + + + + + + + +
            diff --git a/application/command.php b/application/command.php index ab4178a..ba52d02 100755 --- a/application/command.php +++ b/application/command.php @@ -17,4 +17,5 @@ return [ 'app\admin\command\Min', 'app\admin\command\Addon', 'app\admin\command\Api', + 'app\admin\command\AreaPinyinCommand', ]; diff --git a/composer.json b/composer.json index 68fca10..64a383d 100755 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "topthink/think-queue": "1.1.6", "topthink/think-helper": "^1.0.7", "karsonzhang/fastadmin-addons": "~1.4.0", - "overtrue/pinyin": "^3.0", + "overtrue/pinyin": "^5.3", "phpoffice/phpspreadsheet": "^1.29.1", "overtrue/wechat": "^4.6", "ext-json": "*", diff --git a/composer.lock b/composer.lock index cae54f9..2d00e40 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "da8316e5b18922be071cdeaf00c4d962", + "content-hash": "fe3829381cb87e4cad3751a2d797da6e", "packages": [ { "name": "composer/pcre", @@ -790,31 +790,63 @@ }, { "name": "overtrue/pinyin", - "version": "3.0.6", + "version": "5.3.3", + "source": { + "type": "git", + "url": "https://github.com/overtrue/pinyin.git", + "reference": "bff15b27cf3e1cc416464b678576f4da9899692e" + }, "dist": { "type": "zip", - "url": "https://mirrors.cloud.tencent.com/repository/composer/overtrue/pinyin/3.0.6/overtrue-pinyin-3.0.6.zip", - "reference": "3b781d267197b74752daa32814d3a2cf5d140779", - "shasum": "" + "url": "https://api.github.com/repos/overtrue/pinyin/zipball/bff15b27cf3e1cc416464b678576f4da9899692e", + "reference": "bff15b27cf3e1cc416464b678576f4da9899692e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] }, "require": { - "php": ">=5.3" + "php": ">=8.0.2" }, "require-dev": { - "phpunit/phpunit": "~4.8" + "brainmaestro/composer-git-hooks": "^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "laravel/pint": "^1.10", + "nunomaduro/termwind": "^1.0|^2.0", + "phpunit/phpunit": "^10.0|^11.2" }, + "bin": [ + "bin/pinyin" + ], "type": "library", + "extra": { + "hooks": { + "pre-push": [ + "composer pint", + "composer test" + ], + "pre-commit": [ + "composer pint", + "composer test" + ] + } + }, "autoload": { "psr-4": { "Overtrue\\Pinyin\\": "src/" } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ { - "name": "Carlos", + "name": "overtrue", + "email": "anzhengchao@gmail.com", "homepage": "http://github.com/overtrue" } ], @@ -827,9 +859,15 @@ ], "support": { "issues": "https://github.com/overtrue/pinyin/issues", - "source": "https://github.com/overtrue/pinyin/tree/master" + "source": "https://github.com/overtrue/pinyin/tree/5.3.3" }, - "time": "2017-07-10T07:20:01+00:00" + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "time": "2024-08-01T08:19:06+00:00" }, { "name": "overtrue/socialite", @@ -2592,6 +2630,6 @@ "ext-pdo": "*", "ext-bcmath": "*" }, - "platform-dev": [], - "plugin-api-version": "2.3.0" + "platform-dev": {}, + "plugin-api-version": "2.6.0" } diff --git a/public/assets/js/backend/item.js b/public/assets/js/backend/item.js new file mode 100644 index 0000000..9e93c48 --- /dev/null +++ b/public/assets/js/backend/item.js @@ -0,0 +1,57 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'item/index' + location.search, + add_url: 'item/add', + edit_url: 'item/edit', + del_url: 'item/del', + multi_url: 'item/multi', + import_url: 'item/import', + table: 'item', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'pid', title: __('Pid')}, + {field: 'level', title: __('Level')}, + {field: 'title', title: __('Title'), operate: 'LIKE'}, + {field: 'key_word', title: __('Key_word'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image}, + {field: 'sort', title: __('Sort')}, + {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status}, + {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; +}); diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 14c7fb8..6b93845 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -11,12 +11,12 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin del_url: 'order/del', multi_url: 'order/multi', import_url: 'order/import', + push_url: 'order/status', table: 'order', } }); var table = $("#table"); - // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, @@ -31,41 +31,104 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin {field: 'order_no', title: __('Order_no'), operate: 'LIKE'}, {field: 'customer', title: __('Customer'), operate: 'LIKE'}, {field: 'tel', title: __('Tel'), operate: 'LIKE'}, - {field: 'status', title: __('Status'), searchList: {"10":__('Status 10'),"20":__('Status 20'),"30":__('Status 30'),"40":__('Status 40'),"50":__('Status 50'),"-10":__('Status -10'),"-20":__('Status -20'),"-30":__('Status -30')}, formatter: Table.api.formatter.status}, + { + field: 'status', + title: __('Status'), + searchList: { + "10": __('Status 10'), + "20": __('Status 20'), + "30": __('Status 30'), + "40": __('Status 40'), + "50": __('Status 50'), + "-10": __('Status -10'), + "-20": __('Status -20'), + "-30": __('Status -30') + }, + formatter: Table.api.formatter.status + }, {field: 'area_id', title: __('Area_id')}, - {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + { + field: 'address', + title: __('Address'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, {field: 'work_tel_id', title: __('Work_tel_id')}, {field: 'worker_id', title: __('Worker_id')}, {field: 'source', title: __('Source')}, {field: 'source_uid', title: __('Source_uid'), operate: 'LIKE'}, - {field: 'item_id', title: __('Item_id')}, - {field: 'item_title', title: __('Item_title'), operate: 'LIKE'}, - {field: 'detail', title: __('Detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images}, - {field: 'collect', title: __('Collect'), searchList: {"0":__('Collect 0'),"1":__('Collect 1')}, formatter: Table.api.formatter.normal}, - {field: 'collect_remark', title: __('Collect_remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'enter_admin_id', title: __('Enter_admin_id')}, - {field: 'dispatch_admin_id', title: __('Dispatch_admin_id')}, - {field: 'dispatch_type', title: __('Dispatch_type'), searchList: {"10":__('Dispatch_type 10'),"11":__('Dispatch_type 11'),"20":__('Dispatch_type 20')}, formatter: Table.api.formatter.normal}, - {field: 'total', title: __('Total'), operate:'BETWEEN'}, - {field: 'cost', title: __('Cost'), operate:'BETWEEN'}, - {field: 'performance', title: __('Performance'), operate:'BETWEEN'}, - {field: 'sb_amount', title: __('Sb_amount'), operate:'BETWEEN'}, - {field: 'real_amount', title: __('Real_amount'), operate:'BETWEEN'}, - {field: 'cancel_reason_id', title: __('Cancel_reason_id')}, - {field: 'cancel_detail', title: __('Cancel_detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'abolish_reason_id', title: __('Abolish_reason_id')}, - {field: 'abolish_detail', title: __('Abolish_detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, - {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'payment_time', title: __('Payment_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'finishe_time', title: __('Finishe_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'dispatch_time', title: __('Dispatch_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'delete_time', title: __('Delete_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, - {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, - - buttons:[ + {field: 'service_title', title: __('Service_title'), operate: 'LIKE'}, + { + field: 'detail', + title: __('Detail'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, + { + field: 'remark', + title: __('Remark'), + operate: 'LIKE', + table: table, + class: 'autocontent', + formatter: Table.api.formatter.content + }, + { + field: 'images', + title: __('Images'), + operate: false, + events: Table.api.events.image, + formatter: Table.api.formatter.images + }, + { + field: 'create_time', + title: __('Create_time'), + operate: 'RANGE', + addclass: 'datetimerange', + autocomplete: false + }, + { + 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, + buttons: [ + { + name: 'edit', + icon: 'fa fa-pencil', + title: __('Edit'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-success btn-editone' + }, + { + name: 'del', + icon: 'fa fa-trash', + title: __('Del'), + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-danger btn-delone' + }, + { + name: 'push', + icon: 'fa fa-copy', + title: '复制', + url: 'order/copy', + extend: 'data-toggle="tooltip" data-container="body"', + classname: 'btn btn-xs btn-info btn-dialog', + callback: function ($data){ + console.log($data); + } + }, { name:"income", text:"新增收款", @@ -81,10 +144,10 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin }, refresh:true, } - ] + ], } ] - ] + ], }); // 为表格绑定事件 @@ -96,15 +159,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin edit: function () { Controller.api.bindevent(); }, + copy: function () { + Controller.api.bindevent(); + }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; + function parseAndFill() { // 获取左侧输入框的内容 } + let $input = $("#c-area_id"); let $dropdown = $("#address-list"); let $hiddenField = $("#selected-area-code"); @@ -124,7 +192,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin $.ajax({ url: "/admin/area/search", // 你的 API 地址 type: "GET", - data: { keyword: keyword }, + data: {keyword: keyword}, dataType: "json", success: function (data) { renderDropdown(data.data); @@ -133,17 +201,18 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin console.error("请求失败"); } }); - }, 200); // 500 毫秒防抖 + }, 400); // 500 毫秒防抖 }); + // 渲染城市下拉选项 function renderDropdown(data) { $dropdown.empty(); // 清空列表 - if (data.length === 0){ + if (data.length === 0) { let $option = $("") .text('未搜索到结果') .attr("data-value", 0); $dropdown.append($option); - }else{ + } else { data.forEach(item => { let $option = $("") .text(item.merge_name) @@ -163,10 +232,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } - let $inputService = $("#c-service_title"); let $dropdownService = $("#service-list"); - let $hiddenFieldService = $("#c-service_id"); + let $hiddenFieldService = $("#selected-service_id"); let timerService = null; // 定义定时器 $inputService.on("input", function () { @@ -181,9 +249,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin // 延迟 500 毫秒后执行 AJAX 查询(防止过快触发) timerService = setTimeout(() => { $.ajax({ - url: "/admin/area/search", // 你的 API 地址 + url: "/admin/item/search", // 你的 API 地址 type: "GET", - data: { keyword: keyword }, + data: {keyword: keyword}, dataType: "json", success: function (data) { renderDropdownService(data.data); @@ -192,24 +260,24 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin console.error("请求失败"); } }); - }, 200); // 500 毫秒防抖 + }, 400); // 500 毫秒防抖 }); // 渲染城市下拉选项 function renderDropdownService(data) { $dropdownService.empty(); // 清空列表 - if (data.length === 0){ + if (data.length === 0) { let $option = $("") .text('未搜索到结果') .attr("data-value", 0); $dropdownService.append($option); - }else{ + } else { data.forEach(item => { let $option = $("") - .text(item.merge_name) - .attr("data-value", item.area_code) // 绑定 area_code + .text(item.title) + .attr("data-value", item.id) // 绑定 area_code .on("click", function () { - $inputService.val(item.merge_name); // 选中后填充输入框 + $inputService.val(item.title); // 选中后填充输入框 $hiddenFieldService.val($(this).attr("data-value")); // 存储 area_code $dropdownService.hide(); }); @@ -222,8 +290,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin } - - // 点击外部隐藏下拉框 $(document).on("click", function (e) { if (!$(e.target).closest("#c-address, #address-list").length) { diff --git a/public/index.html b/public/index.html index a19ad97..1ad1f56 100755 --- a/public/index.html +++ b/public/index.html @@ -1 +1 @@ -

            12312321

            \ No newline at end of file +

            123123ttttt21

            \ No newline at end of file