Parcourir la source

fix: bug修复

zhengzhibin il y a 1 an
Parent
commit
6e0aeb58f8

+ 15 - 5
app/admin/controller/Appointment.php

@@ -43,6 +43,7 @@ class Appointment extends Permissions
             $data = $model->where($where)->page($post['page']??0, $post['limit']??15)->order('id desc')->select();
             foreach ($data as $key => $value) {
                 $value['specialist_name'] = $value->specialist->name;
+                $value['appointment_date_text'] = $value->appointment_date_text;
                 $data[$key] = $value;
             }
             return array('code' => 0, 'count' => $count, 'data' => $data);
@@ -107,7 +108,6 @@ class Appointment extends Permissions
 
             $weeks = $post['weeks']??[];
             $weeks = array_keys($weeks);
-            $weeks = empty($weeks) ? "" : implode(',', $weeks);
         }
 
         $model = $this->getModel();
@@ -120,10 +120,9 @@ class Appointment extends Permissions
 
                 if (empty($weeks)) {
                     //按时间跨度排号
-                    //判断是否时间跨度重叠
                     $exits = (new \app\common\model\AppointmentTicket())->where(['provider_id' => $pid, 'appointment_daytime' => [['>=', $post['start_time']], ['<=', $post['end_time']]]])->count();
                     if ($exits > 0) {
-                        $this->error('该时间跨度内,已存在排号,请重新选择时间');
+                        $this->error('该时间跨度内,已存在排号,请重新选择放号时间,或删除旧的排号');
                     }
                     //保存放号设置
                     if (false == $model->allowField(true)->save($post)) {
@@ -150,10 +149,21 @@ class Appointment extends Permissions
                     }
 
                 } else {
-                    //按工作日排号,保存放号设置
+                    //按工作日排号
+                    $appoints = (new \app\common\model\Appointment())->where(['provider_id' => $pid, 'weeks' => ['<>', '']])->select();
+                    foreach ($appoints as $appoint) {
+                        foreach ($weeks as $week) {
+                            if (in_array($week, explode(',', $appoint->weeks))) {
+                                $week_text = \app\common\model\Appointment::WEEK_TEXTS[$week];
+                                $this->error("{$week_text} 已存在放号设置,请重新选择时间");
+                            }
+                        }
+                    }
+
+                    //保存放号设置
                     $post['start_time'] = 0;
                     $post['end_time'] = 0;
-                    $post['weeks'] = $weeks;
+                    $post['weeks'] = implode(',', $weeks);
                     if (false == $model->allowField(true)->save($post)) {
                         $this->error('添加失败');
                     }

+ 1 - 6
app/admin/view/appointment/index.html

@@ -82,12 +82,7 @@
                 , page: true //开启分页
                 , cols: [[ //表头
                     {type: 'checkbox'},
-                    {field: "start_time", title: '排号日期',width: 200,templet:function (row) {
-                        if(row.weeks!=""){
-                            return "每周"+row.weeks;
-                        }
-                        return row.start_time + ' ~ ' + row.end_time;
-                    }},
+                    {field: "appointment_date_text", title: '排号日期',width: 200},
                     {field: "specialist_name", title: '专家名字'},
                     {field: "morning_num", title: '上午放号个数'},
                     {field: "afternoon_num", title: '下午放号个数'},

+ 23 - 1
app/admin/view/appointment/publish.html

@@ -42,7 +42,7 @@
 
 
     <div style="margin-top: 20px;"></div>
-    <form class="layui-form" id="publish" method="post">
+    <form class="layui-form" id="publish" method="post" lay-filter="myform">
 
         <div class="layui-tab">
             <ul class="layui-tab-title">
@@ -153,6 +153,28 @@
 
             $(window).on('load', function () {
                 form.on('submit(admin)', function (data) {
+
+                    if($('#publish .layui-this').text() == '按时间跨度排号'){
+                        //给表单赋值
+                        form.val("myform", { //即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
+                            "weeks[1]": false // "name": "value"
+                            ,"weeks[2]": false
+                            ,"weeks[3]": false
+                            ,"weeks[4]": false
+                            ,"weeks[5]": false
+                            ,"weeks[6]": false
+                            ,"weeks[7]": false
+                        });
+                    }else{
+                        //获取表单区域所有值
+                        var data = form.val("myform");
+                        if (data['weeks[1]'] == null && data['weeks[2]'] == null && data['weeks[3]'] == null && data['weeks[4]'] == null && data['weeks[5]'] == null && data['weeks[6]'] == null && data['weeks[7]'] == null) {
+                            layer.msg('请选择排号的工作日');
+                            return false;
+                        }
+                    }
+
+
                     $.ajax({
                         url: "{:url('publish')}",
                         data: $('#publish').serialize(),

+ 8 - 0
app/api/controller/接口文档.md

@@ -3,6 +3,8 @@
 
 接口地址: /api/index/siteinfo
 
+更新时间: 2023-05-01
+
 请求方式:get / post
 
 请求数据:无
@@ -326,6 +328,8 @@
 
 接口地址:/api/appointment/getTicketByAddressId
 
+更新时间: 2023-05-01
+
 请求方式:get / post
 
 请求数据:
@@ -466,8 +470,12 @@
 
 接口地址:/api/user/application
 
+更新时间: 2023-05-01
+
 请求方式:get / post
 
+请求数据:
+
 | 参数名 | 说明  | 备注  |
 | ---   | ---   | ---  |
 | x-token   | 登入令牌jwt |  require必填 |

+ 17 - 0
app/common/model/Appointment.php

@@ -14,6 +14,23 @@ class Appointment extends Model
     const STATUS_OPEN = 1;
     const STATUS_CLOSE = 0;
 
+    const WEEK_TEXTS = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日'];
+
+    //appointment_date_text
+    public function getAppointmentDateTextAttr($value, $data)
+    {
+        if ($this->isWeekMode()) {
+            $weeks = explode(',', $this->weeks);
+            $week_texts = [];
+            foreach ($weeks as $week) {
+                $week_texts[] = self::WEEK_TEXTS[$week]??'';
+            }
+            return '每' . implode(',', $week_texts);
+        } else {
+            return $this->start_time . ' ~ ' . $this->end_time;
+        }
+    }
+
 
     //start_time
     public function getStartTimeAttr($value, $data)