diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index e81ec9e..be5da90 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -204,11 +204,21 @@ class Order extends Backend public function add() { - if (false === $this->request->isPost()) { return $this->view->fetch(); } $params = $this->request->post('row/a'); + + // 数据验证 + $validate = $this->validate($params, \app\admin\validate\Order::class . '.add'); + if ($validate !== true) { + $this->error($validate); + } + + if (!$params['set_time']) { + $params['plan_time'] = null; + } + $params = array_filter($params, function ($val) { return $val != ''; }); @@ -249,7 +259,6 @@ class Order extends Backend $params['update_time'] = date('Y-m-d H:i:s'); $result = $this->model->allowField(true)->save($params); - if ($params['dispatch_type'] == 2) { AutoDispatchLogic::autoDispatch($this->model, $this->auth); } @@ -288,6 +297,20 @@ class Order extends Backend if (request()->isPost()) { // 获取表单提交的数据 $params = input('post.row/a'); + + // 数据验证 + $validate = $this->validate($params, \app\admin\validate\Order::class . '.edit'); + if ($validate !== true) { + $this->error($validate); + } + + if (!$params['set_time']) { + $params['plan_time'] = null; + } + + //移除无用字段:是否设置上门时间 + unset($params['set_time']); + $params['update_time'] = date('Y-m-d H:i:s'); $sources = $this->sources; $sources = array_column($sources, 'title', 'id'); diff --git a/application/admin/validate/Order.php b/application/admin/validate/Order.php index e0565c2..353541e 100644 --- a/application/admin/validate/Order.php +++ b/application/admin/validate/Order.php @@ -10,18 +10,67 @@ class Order extends Validate * 验证规则 */ protected $rule = [ + 'source' => 'require', + 'item_id' => 'require', + 'customer' => 'require|max:32', + 'tel' => 'require|number|max:32', + 'area_id' => 'require', + 'address' => 'require|max:255', + 'lng' => 'require', + 'lat' => 'require', + 'online_amount|收款金额' => 'require|number|between:0.01,10000000', + 'plan_time|上门时间' => 'requireIf:set_time,1|date' ]; /** * 提示消息 */ protected $message = [ + 'source.require' => '请选择订单渠道', + 'item_id.require' => '请选择服务项目', + + 'customer.require' => '请输入客户昵称', + 'customer.max' => '客户昵称不能超过 32 个字符', + + 'tel.require' => '请输入客户电话', + 'area_id.require' => '请选择地区', + + 'address.require' => '请选择详细地址', + 'address.max' => '详细地址不能超过 255 个字符', + + 'lng.require' => '请选择详细地址', + 'lat.require' => '请选择详细地址', + + 'online_amount.require' => '请输入收款金额', + 'online_amount.number' => '收款金额不正确', ]; /** * 验证场景 */ protected $scene = [ - 'add' => [], - 'edit' => [], + 'add' => [ + 'source', + 'item_id', + 'customer', + 'tel', + 'area_id', + 'address', + 'lng', + 'lat', + 'online_amount', + 'plan_time', + ], + 'edit' => [ + 'source', + 'item_id', + 'customer', + 'tel', + 'area_id', + 'address', + 'lng', + 'lat', + 'online_amount', + 'plan_time', + ], ]; - + } diff --git a/application/admin/view/order/add.html b/application/admin/view/order/add.html index 2644c32..1ffa24b 100644 --- a/application/admin/view/order/add.html +++ b/application/admin/view/order/add.html @@ -1,283 +1,446 @@ - -
-
-
- -
-
-
-
-
-
- -
- -
-
-
- -
- -
-
- - -
- -
- - -
-
-
- -
-
- -
地图查找
-
- - - -
-
- -
- -
- - - -
-
- -
- -
- -
-
- -
- -
- -
-
- -
- -
-
- -
- - -
- -
-
    -
    -
    -
    - -
    - -
    - -
    - -
    -
    - - - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - - -
    - -
    - -
    -
    - -
    - -
    - -
    -
    - - - -
    - -
    - -
    -
    -
    - -
    - -
    -
    - -
    - -
    - - -
    -
    - - -
    - -
    -
    快速输入:
    -
    -
    - -
    -
    -
    - -
    -
    - -
    -
    -
    +
    +
    +
    +
    + +
    +
    +
    *订单渠道:
    +
    + +
    +
    +
    *服务项目:
    +
    + + +
    +
    +
    +
    +
    +
    *客户昵称:
    +
    + +
    +
    +
    +
    *客户电话:
    +
    + +
    +
    +
    +
    +
    *地区:
    +
    + + +
    +
    +
    +
    +
    *详细地址:
    +
    +
    地图查找
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    收款方式:
    +
    + +
    +
    +
    +
    *收款金额:
    +
    + +
    +
    +
    +
    +
    +
    优惠:
    +
    + +
    +
    +
    + +
    +
    +
    上门时间:
    +
    + {:build_radios('row[set_time]', ['1'=>'有', '0'=>'无'], 1)} +
    +
    +
    +
    *设置时间:
    +
    + +
    +
    +
    +
    +
    +
    订单备注:
    +
    +
    + +
    +
    +
    +
    +
    录单员:
    +
    + +
    +
    +
    +
    +
    图片上传:
    +
    +
    + +
    + + +
    + +
    +
      +
      +
      +
      +
      +
      +
      快速录入:
      +
      +
      +
      +
      + +
      +
      +
      +
      + + 智能识别 +
      +
      +
      +
      + + + + + +
      +
      +
      - - \ No newline at end of file + var items = {:json_encode($items); }; + window.addEventListener('DOMContentLoaded', function () { + setTimeout(function () { + const container = document.querySelector('.body-hidden'); + if (container) { + container.classList.remove('body-hidden'); + container.classList.add('body-shown'); + } + }, 500); + }); + + + + + + + + + + + + + + + + diff --git a/application/admin/view/order/copy.html b/application/admin/view/order/copy.html index b6268f4..4ea015b 100644 --- a/application/admin/view/order/copy.html +++ b/application/admin/view/order/copy.html @@ -1,266 +1,369 @@ - -
      -
      -
      - -
      -
      -
      -
      -
      -
      - -
      - -
      -
      -
      - -
      - -
      -
      - -
      - -
      - - -
      -
      -
      - -
      -
      - -
      地图查找
      -
      - - - -
      -
      - -
      - -
      - - -
      -
      - -
      - -
      - -
      -
      - -
      - -
      - -
      -
      - -
      - -
      -
      - -
      - - -
      - -
      -
        -
        -
        - -
        - - -
        -
        - -
        - -
        -
        - - - -
        - -
        - -
        -
        - - -
        - -
        - -
        -
        - - -
        - -
        - -
        -
        - -
        - -
        - -
        -
        - - - - - -
        - -
        - -
        -
        - - -
        - -
        - -
        -
        - -
        - -
        - -
        -
        - - - -
        - - - -
        -
        +
        +
        +
        +
        + +
        +
        +
        *订单渠道:
        +
        +
        +
        +
        +
        *服务项目:
        +
        + + +
        +
        +
        +
        +
        *客户昵称:
        +
        + +
        +
        +
        +
        *客户电话:
        +
        + +
        +
        +
        +
        +
        *地区:
        +
        + + +
        +
        +
        +
        +
        *详细地址:
        +
        +
        地图查找
        +
        +
        +
        + + + + +
        +
        +
        +
        +
        收款方式:
        +
        + +
        +
        +
        +
        *收款金额:
        +
        + +
        +
        +
        +
        +
        +
        优惠:
        +
        + +
        +
        +
        + +
        +
        +
        上门时间:
        +
        + {:build_radios('row[set_time]', ['1'=>'有', '0'=>'无'], $row.plan_time === '' || $row.plan_time === null ? 0 : 1)} +
        +
        +
        +
        *设置时间:
        +
        + +
        +
        +
        +
        +
        +
        订单备注:
        +
        +
        + +
        +
        +
        +
        +
        录单员:
        +
        + +
        +
        +
        + +
        +
        图片上传:
        +
        +
        + +
        + + +
        + +
        +
          +
          +
          +
          + +
          - + - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/application/admin/view/order/edit.html b/application/admin/view/order/edit.html index 1df3deb..5e3a09b 100644 --- a/application/admin/view/order/edit.html +++ b/application/admin/view/order/edit.html @@ -1,262 +1,368 @@ - -
          -
          -
          - -
          -
          -
          -
          -
          -
          - -
          - -
          -
          -
          - -
          - -
          -
          - -
          - -
          - - -
          -
          -
          - -
          -
          - -
          地图查找
          -
          - - - -
          -
          - -
          - -
          - - -
          -
          - -
          - -
          - -
          -
          - -
          - -
          - -
          -
          - -
          - -
          -
          - -
          - - -
          - -
          -
            -
            -
            - -
            - - -
            -
            - -
            - -
            -
            - - - -
            - -
            - -
            -
            - - -
            - -
            - -
            -
            - - -
            - -
            - -
            -
            - -
            - -
            - -
            -
            - -
            - -
            - -
            -
            - - -
            - -
            - -
            -
            - -
            - -
            - -
            -
            - - - -
            - - - -
            -
            +
            +
            +
            +
            +
            +
            +
            *订单渠道:
            +
            +
            +
            +
            +
            *服务项目:
            +
            + + +
            +
            +
            +
            +
            *客户昵称:
            +
            + +
            +
            +
            +
            *客户电话:
            +
            + +
            +
            +
            +
            +
            *地区:
            +
            + + +
            +
            +
            +
            +
            *详细地址:
            +
            +
            地图查找
            +
            +
            +
            + + + + +
            +
            +
            +
            +
            收款方式:
            +
            + +
            +
            +
            +
            *收款金额:
            +
            + +
            +
            +
            +
            +
            +
            优惠:
            +
            + +
            +
            +
            + +
            +
            +
            上门时间:
            +
            + {:build_radios('row[set_time]', ['1'=>'有', '0'=>'无'], $row.plan_time === '' || $row.plan_time === null ? 0 : 1)} +
            +
            +
            +
            *设置时间:
            +
            + +
            +
            +
            +
            +
            +
            订单备注:
            +
            +
            + +
            +
            +
            +
            +
            录单员:
            +
            + +
            +
            +
            + +
            +
            图片上传:
            +
            +
            + +
            + + +
            + +
            +
              +
              +
              +
              + +
              - + - - - \ No newline at end of file + + + + + + + + + + + + + + diff --git a/public/assets/img/automation.png b/public/assets/img/automation.png new file mode 100644 index 0000000..943f600 Binary files /dev/null and b/public/assets/img/automation.png differ diff --git a/public/assets/js/addons.js b/public/assets/js/addons.js index 6299f6b..0f3bdcb 100755 --- a/public/assets/js/addons.js +++ b/public/assets/js/addons.js @@ -1,7 +1,6 @@ define([], function () { require([], function () { //绑定data-toggle=addresspicker属性点击事件 - $(document).on('click', "[data-toggle='addresspicker']", function () { var that = this; var callback = $(that).data('callback'); diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 0122db0..50a3c39 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -424,6 +424,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function } return false; }); + $("#mysubmit").on("click", function () { const res = $("form[role=form]").isValid(); if (res){ @@ -433,7 +434,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function } return false; }); - Form.api.bindevent($("form[role=form]")); + $("#smart").on("click", function () { $.ajax({ url: "order/smart", // 你的 API 地址 @@ -478,13 +479,30 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function } }); }); + Controller.api.bindevent(); Controller.api.map(); }, edit: function () { + // 未选择上门时间时,隐藏时间选择框 + var planTime = $('input[name="row[plan_time]"]').val() + if (planTime === '' || planTime === 'null') { + $('#set-time').hide(); + } else { + $('#set-time').show(); + } + Controller.api.bindevent(); Controller.api.map(); }, copy: function () { + // 未选择上门时间时,隐藏时间选择框 + var planTime = $('input[name="row[plan_time]"]').val() + if (planTime === '' || planTime === 'null') { + $('#set-time').hide(); + } else { + $('#set-time').show(); + } + Controller.api.bindevent(); Controller.api.map(); }, @@ -531,6 +549,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); + + $('input[name="row[set_time]"]').on('change', function () { + var val = $(this).val(); + if (val == 1) { + $('#set-time').show(); + } else { + $('#set-time').hide(); + } + }); }, map:function () { $("#c-city").on("cp:updated", function () {