wangsaitao 8 mēneši atpakaļ
vecāks
revīzija
d32529430a

+ 30 - 0
application/admin/controller/Orders.php

@@ -67,6 +67,8 @@ class Orders extends Auth {
             $this->assign('mode', $mode);
             $order_mode = Db::name('order_mode')->select();
             $this->assign('order_mode_list', $order_mode);
+            $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
+            $this->assign('tsDh',$tsDh);
             if ($mode == 1) {
                 return $this->fetch('selfIndex1');
             }
@@ -117,6 +119,8 @@ class Orders extends Auth {
                 ->where('id',$this->userId)
                 ->find();
             $this->assign('user',$user);
+            $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
+            $this->assign('tsDh',$tsDh);
             if ($mode == 3) {
                 return $this->fetch('self_add3');
             }
@@ -125,6 +129,32 @@ class Orders extends Auth {
             }
         }
     }
+
+    public function getAddr(){
+        $id = input('id/d',0);
+        $info = Db::name('convey_cate')
+            ->where('id',$id)
+            ->find();
+
+        if(!empty($info['starts'])){
+            $st = explode(',',$info['starts']);
+            $s = (new \app\common\model\Address())->getListByTypes($st,2);
+        }else{
+            $s = (new \app\common\model\Address())->getListByType(2);
+        }
+        if(!empty($info['ends'])){
+            $ent = explode(',',$info['ends']);
+            $en = (new \app\common\model\Address())->getListByTypes($ent,2);
+        }else{
+            $en = (new \app\common\model\Address())->getListByType(2);
+        }
+        $a = [
+            's'=>$s,
+            'e'=>$en,
+        ];
+        $this->success('','',$a);
+
+    }
     //用户取消订单
     public function cancel($id) {
         $res = $this->model->cancel($id, $this->userId);

+ 5 - 2
application/admin/view/orders/selfIndex3.html

@@ -4,10 +4,13 @@
 <div class="ibox">
     <div class="ibox-content">
         <div class="row">
-            <div class="col-xs-3">
+            <div class="col-xs-6">
                 <a href="javascript:;" url="{:url('selfAdd',[],'')}/mode/{$mode}" data-title="创建{$m_name}订单" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">创建{$m_name}订单</a>
+                {if $tsDh}
+                <span style="color: red;font-size: 15px">{$tsDh}</span>
+                {/if}
             </div>
-            <div class="col-xs-9" style="text-align: right;">
+            <div class="col-xs-6" style="text-align: right;">
                 <form class="form-inline" id="form-search" action="{:url('selfIndex')}?mode={$mode}">
                     <div class="input-group">
                         <input type="text" class="form-control" name="sn" placeholder="订单编号">

+ 171 - 146
application/admin/view/orders/self_add3.html

@@ -5,12 +5,7 @@
         <div class="ibox float-e-margins">
             <div class="ibox-content">
                 <form method="post" action="{:url('selfAdd',[],'')}/mode/{$mode}" class="form-horizontal">
-                    <div class="col-sm-12">
-                        <div class="form-group">
-                            <label class="control-label">任务内容</label></br>
-                            <textarea name="content" class="form-control" cols="30" rows="3"  id="value"></textarea>
-                        </div>
-                    </div>
+
                     <div class="col-sm-12">
                         <div class="form-group">
                             <label class="control-label">部门</label></br>
@@ -25,7 +20,7 @@
                             </el-select>
                         </div>
                     </div>
-                    <div class="col-sm-6">
+                    <div class="col-sm-12">
                         <div class="form-group">
                             <label class="control-label">运送类型<span class="text-danger">*</span></label></br>
                             <input type="hidden" name="type" id="type">
@@ -41,44 +36,83 @@
                             </div>
                         </div>
                     </div>
-                    <div class="col-sm-6">
+                    <div class="col-sm-12">
                         <div class="form-group">
-                            <label class="control-label">始发空间<span class="text-danger">*</span></label></br>
-                            <input type="hidden" value="{$user.addr_id==0?'':$user.addr_id}" name="start" id="start">
-                            <div >
-                                <el-select v-model="start" size="small" clearable style="width: 100%" filterable placeholder="请选择">
-                                    <el-option
-                                            v-for="item in starts"
-                                            :key="item.id"
-                                            :label="item.title"
-                                            :value="item.id.toString()">
-                                    </el-option>
-                                </el-select>
+                            <label class="control-label">优  &nbsp;先 &nbsp;级</label></br>
+                            <input type="hidden" name="priority" id="priority">
+                            <div style="padding-right: 10px">
+                                <el-radio v-model="priority" label="2">常规</el-radio>
+                                <el-radio v-model="priority" label="3">紧急</el-radio>
                             </div>
+
                         </div>
                     </div>
+                    <div id="patient">
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">床号</label></br>
+                                <div style="padding-right: 10px">
 
-
+                                    <input type="text" class="form-control" name="bed_number">
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">姓名</label></br>
+                                <div style="padding-right: 10px">
+                                    <input type="text" class="form-control" name="p_name">
+                                </div>
+                            </div>
+                        </div>
+                        <!--                        <div class="col-sm-4">-->
+                        <!--                            <div class="form-group">-->
+                        <!--                                <label class="control-label">病案号</label></br>-->
+                        <!--                                <input type="text" class="form-control" name="ba_number">-->
+                        <!--                            </div>-->
+                        <!--                        </div>-->
+                        <!--                        <div class="col-sm-6">-->
+                        <!--                            <div class="form-group">-->
+                        <!--                                <label class="control-label">性别</label></br>-->
+                        <!--                                <div style="padding-right: 10px">-->
+                        <!--                                    <select name="gender" class="form-control">-->
+                        <!--                                        <option value="0">未知</option>-->
+                        <!--                                        <option value="1">男</option>-->
+                        <!--                                        <option value="2">女</option>-->
+                        <!--                                    </select>-->
+                        <!--                                </div>-->
+                        <!--                            </div>-->
+                        <!--                        </div>-->
+                        <!--                        <div class="col-sm-6">-->
+                        <!--                            <div class="form-group">-->
+                        <!--                                <label class="control-label">是否往返</label></br>-->
+                        <!--                                <select name="back" class="form-control">-->
+                        <!--                                    <option value="0">否</option>-->
+                        <!--                                    <option value="1">是</option>-->
+                        <!--                                </select>-->
+                        <!--                            </div>-->
+                        <!--                        </div>-->
+                    </div>
                     <div class="col-sm-6">
                         <div class="form-group">
-                            <label class="control-label">优  &nbsp;先 &nbsp;级</label></br>
-                            <input type="hidden" name="priority" id="priority">
+                            <label class="control-label">开始地点<span class="text-danger">*</span></label></br>
+                            <input type="hidden" value="{$user.addr_id==0?'':$user.addr_id}" name="start" id="start">
                             <div style="padding-right: 10px">
-                                <el-select v-model="priority" size="small" clearable style="width: 100%" placeholder="请选择">
+                                <el-select v-model="start" size="small" clearable style="width: 100%" filterable placeholder="请选择">
                                     <el-option
-                                            v-for="(item,index) in prioritys"
-                                            :key="index"
-                                            :label="item"
-                                            :value="index.toString()">
+                                            v-for="item in starts"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id">
                                     </el-option>
                                 </el-select>
                             </div>
-
                         </div>
                     </div>
+
                     <div class="col-sm-6">
                         <div class="form-group">
-                            <label class="control-label">目的空间<span class="text-danger">*</span></label></br>
+                            <label class="control-label">结束地点<span class="text-danger">*</span></label></br>
                             <input type="hidden" name="end" id="end">
                             <div >
                                 <el-select v-model="end" size="small" clearable style="width: 100%" filterable placeholder="请选择">
@@ -93,29 +127,47 @@
                         </div>
                     </div>
 
-                    <div class="col-sm-12">
-                        <div class="form-group">
-                            <label class="control-label">运送设备</label></br>
-                            <input type="hidden" name="device_id" id="device">
-                            <el-select v-model="device" size="small" style="width: 100%" clearable filterable placeholder="请选择">
-                                <el-option
-                                        v-for="item in devices"
-                                        :key="item.id"
-                                        :label="item.title"
-                                        :value="item.id">
-                                </el-option>
-                            </el-select>
+                    <!--                    <div class="col-sm-12">-->
+                    <!--                        <div class="form-group">-->
+                    <!--                            <label class="control-label">运送设备</label></br>-->
+                    <!--                            <input type="hidden" name="device_id" id="device">-->
+                    <!--                            <el-select v-model="device" size="small" style="width: 100%" clearable filterable placeholder="请选择">-->
+                    <!--                                <el-option-->
+                    <!--                                        v-for="item in devices"-->
+                    <!--                                        :key="item.id"-->
+                    <!--                                        :label="item.title"-->
+                    <!--                                        :value="item.id">-->
+                    <!--                                </el-option>-->
+                    <!--                            </el-select>-->
+                    <!--                        </div>-->
+                    <!--                    </div>-->
+                    <div id="yy" style="display:none;">
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">需求时间<span class="text-danger">*</span></label></br>
+                                <input type="hidden" name="xq_time" id="xqtime">
+                                <div style="padding-right: 10px">
+                                    <el-date-picker
+                                            style="width: 100%"
+                                            size="small"
+                                            v-model="xq_time"
+                                            type="datetime"
+                                            :editable="false"
+                                            value-format="yyyy-MM-dd HH:mm"
+                                            :clearable="true"
+                                            placeholder="选择日期时间">
+                                    </el-date-picker>
+                                </div>
+                            </div>
                         </div>
-                    </div>
-                    <div class="col-sm-6">
-                        <div class="form-group">
-                            <label class="control-label">需求时间<span class="text-danger">*</span></label></br>
-                            <input type="hidden" name="xq_time" id="xqtime">
-                            <div style="padding-right: 10px">
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">应完成时间<span class="text-danger">*</span></label></br>
+                                <input type="hidden" name="ywc_time" id="ywctime">
                                 <el-date-picker
                                         style="width: 100%"
                                         size="small"
-                                        v-model="xq_time"
+                                        v-model="ywc_time"
                                         type="datetime"
                                         :editable="false"
                                         value-format="yyyy-MM-dd HH:mm"
@@ -124,81 +176,26 @@
                                 </el-date-picker>
                             </div>
                         </div>
+                        <!--                        <div class="col-sm-6">-->
+                        <!--                            <div class="form-group">-->
+                        <!--                                <label class="control-label">联系人</label></br>-->
+                        <!--                                <div style="padding-right: 10px">-->
+                        <!--                                    <input type="text" class="form-control" name="name">-->
+                        <!--                                </div>-->
+                        <!--                            </div>-->
+                        <!--                        </div>-->
+                        <!--                        <div class="col-sm-6">-->
+                        <!--                            <div class="form-group">-->
+                        <!--                                <label class="control-label">联系电话</label></br>-->
+                        <!--                                <input type="text" class="form-control" name="phone">-->
+                        <!--                            </div>-->
+                        <!--                        </div>-->
                     </div>
-                    <div class="col-sm-6">
-                        <div class="form-group">
-                            <label class="control-label">应完成时间<span class="text-danger">*</span></label></br>
-                            <input type="hidden" name="ywc_time" id="ywctime">
-                            <el-date-picker
-                                    style="width: 100%"
-                                    size="small"
-                                    v-model="ywc_time"
-                                    type="datetime"
-                                    :editable="false"
-                                    value-format="yyyy-MM-dd HH:mm"
-                                    :clearable="true"
-                                    placeholder="选择日期时间">
-                            </el-date-picker>
-                        </div>
-                    </div>
-                    <div class="col-sm-6">
-                        <div class="form-group">
-                            <label class="control-label">联系人</label></br>
-                            <div style="padding-right: 10px">
-                                <input type="text" class="form-control" name="name">
-                            </div>
-                        </div>
-                    </div>
-                    <div class="col-sm-6">
-                        <div class="form-group">
-                            <label class="control-label">联系电话</label></br>
-                            <input type="text" class="form-control" name="phone">
-                        </div>
-                    </div>
-                    <div id="patient">
-                        <div class="col-sm-4">
-                            <div class="form-group">
-                                <label class="control-label">床号</label></br>
-                                <div style="padding-right: 10px">
 
-                                    <input type="text" class="form-control" name="bed_number">
-                                </div>
-                            </div>
-                        </div>
-                        <div class="col-sm-4">
-                            <div class="form-group">
-                                <label class="control-label">姓名</label></br>
-                                <div style="padding-right: 10px">
-                                    <input type="text" class="form-control" name="p_name">
-                                </div>
-                            </div>
-                        </div>
-                        <div class="col-sm-4">
-                            <div class="form-group">
-                                <label class="control-label">病案号</label></br>
-                                <input type="text" class="form-control" name="ba_number">
-                            </div>
-                        </div>
-                        <div class="col-sm-6">
-                            <div class="form-group">
-                                <label class="control-label">性别</label></br>
-                                <div style="padding-right: 10px">
-                                    <select name="gender" class="form-control">
-                                        <option value="0">未知</option>
-                                        <option value="1">男</option>
-                                        <option value="2">女</option>
-                                    </select>
-                                </div>
-                            </div>
-                        </div>
-                        <div class="col-sm-6">
-                            <div class="form-group">
-                                <label class="control-label">是否往返</label></br>
-                                <select name="back" class="form-control">
-                                    <option value="0">否</option>
-                                    <option value="1">是</option>
-                                </select>
-                            </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">任务备注</label></br>
+                          <input type="text"  placeholder="{$tsDh}" class="form-control" name="content">
                         </div>
                     </div>
                     <div class="col-sm-12">
@@ -228,47 +225,75 @@
         el: '#formApp',
         data: function() {
             return {
-                starts: {:json_encode($address)},
-                start: "{$user.addr_id==0?'':$user.addr_id}",
-                ends: {:json_encode($address)},
+                starts: [],
+                start: "",
+                ends: [],
                 end: '',
                 types: {:json_encode($order_convey_type)},
-                type: '',
+            type: '',
                 prioritys:{:json_encode($priority)},
-                priority: '',
+            priority: "2",
                 devices: {:json_encode($order_device)},
-                device: '',
+            device: '',
                 xq_time: '',
                 ywc_time:'',
                 dep: {:json_encode($dep_list)},
-                dep_id: '{$dep_id}',
+            dep_id: '{$dep_id}',
         }
         },
         watch: {
             type: function (newtype, oldtype) {
+                var that  = this;
+                $.post('{:url("getAddr")}',{id:newtype},function (res){
+                    that.starts = res.data.s;
+                    that.ends = res.data.e;
+                },'json')
                 $('#type').val(newtype);
                 this.types.forEach((item) => {
                     if(item.id == newtype){
-                    console.log(item);
-                    this.end = item.ends > 0?parseInt(item.ends):'';
-                    this.xq_time = item.xq_time?item.xq_time:'';
-                    this.ywc_time = item.ywc_time?item.ywc_time:'';
-                    this.priority = item.priority > 0?item.priority.toString():'';
-                    if(item.cate == 1){
-                        let devices = [];
-                        vdevices.forEach((item) => {
-                            if(item.patient == 1){
-                            devices.push(item);
+                        console.log(item);
+                       // this.end = item.ends > 0?parseInt(item.ends):'';
+                        //this.start = item.starts > 0?parseInt(item.starts):'';
+                        if(item.starts >0){
+                            this.start = parseInt(item.starts);
+                        }else {
+                            if(item.startList.length ==0){
+                                this.start= parseInt('{$user.addr_id}') >0?parseInt('{$user.addr_id}'):"";
+                            }
+                        }
+                        if(item.ends >0){
+                            this.end = parseInt(item.ends);
+                        }else {
+                            if(item.endList.length ==0){
+                                this.end= parseInt('{$user.addr_id}') >0?parseInt('{$user.addr_id}'):"";
+                            }
+                        }
+                        this.xq_time = item.xq_time?item.xq_time:'';
+                        this.ywc_time = item.ywc_time?item.ywc_time:'';
+                        this.priority = item.priority > 0?item.priority.toString():'';
+                        if(item.cate == 1){
+                            let devices = [];
+                            vdevices.forEach((item) => {
+                                if(item.patient == 1){
+                                    devices.push(item);
+                                }
+                            });
+                            this.devices = devices;
+                            $('#patient').show();
+                        }else{
+                            this.devices = vdevices;
+                            $('#patient').hide();
+                        }
+                        if(item.cate==4){
+                            $("#yy").css('display','block')
+                        }else {
+                            $("#yy").css('display','none')
+
                         }
-                    });
-                        this.devices = devices;
-                        $('#patient').show();
-                    }else{
-                        this.devices = vdevices;
-                        $('#patient').hide();
                     }
-                }
-            });
+
+                });
+
             },
             start: function (newtype, oldtype) {
                 $('#start').val(newtype);

+ 19 - 0
application/common/model/Address.php

@@ -62,7 +62,26 @@ class Address extends Base
             ->select();
         return $lists?$lists:[];
     }
+    public function getListByTypes($maps,$type,$orgId=0){
+        if($orgId >0){
+            $map[] = ['org_id','=',$orgId];
+        }else{
+            $map[] = ['org_id','=',cur_org_id()];
+        }
+        $map[] = ['del','=',0];
+        $map[] = ['enable','=',1];
+        if(!empty($maps)){
+            $map[] = ['id','in',$maps];
 
+        }
+        $map[]=['','exp',Db::raw("FIND_IN_SET($type,types)")];
+        $lists = Db::name('address')
+            ->where($map)
+            ->order('id desc')
+            ->field('id,title,remark,sn,x,y')
+            ->select();
+        return $lists?$lists:[];
+    }
     /**
      * 根据类型获取地点数量
      * @param $type

+ 10 - 2
application/common/model/ConveyCate.php

@@ -9,8 +9,8 @@ class ConveyCate extends Base
         1=>"病人",
         2=>"普通",
         3=>"限时",
-        4=>"预约检查",
-        5=>"药品运送"
+        4=>"预约",
+        5=>"药品"
     ];
     public $priority = [
         1=>"可延缓的",
@@ -66,11 +66,19 @@ class ConveyCate extends Base
                 $list[$k]['ywc_time'] = '';
             }
             $ends = $v['ends']?explode(',',$v['ends']):[];
+            $starts = $v['starts']?explode(',',$v['starts']):[];
+            $list[$k]['endList'] = $ends;
+            $list[$k]['startList'] = $starts;
             $list[$k]['ends'] = 0;
+            $list[$k]['starts'] = 0;
             if(count($ends) == 1){
                 $list[$k]['ends'] = $ends[0];
             }
+            if(count($starts) == 1){
+                $list[$k]['starts'] = $starts[0];
+            }
         }
+        $list = model("UserConveyCate")->sortUserCates($list,is_login());
         return $list;
     }
 

+ 30 - 20
application/common/model/Orders.php

@@ -214,42 +214,52 @@ class Orders extends Base {
                     $this->error = '取件与送达地点不能是同一地点';
                     return false;
                 }
-                if (!$data['xq_time'] || !$data['ywc_time']) {
-                    $this->error = '应完成时间应和需求时间不能为空';
-                    return false;
-                }
-                if ($data['xq_time'] >= $data['ywc_time']) {
-                    $this->error = '应完成时间应大于需求时间';
-                    return false;
-                }
-                if (strtotime($data['xq_time']) < time() - 10 * 60) {
-                    $this->error = '需求时间已过时';
-                    return false;
-                }
                 if (!$data['type']) {
                     $this->error = '运送类型不能为空';
                     return false;
                 }
+                $conveyCate = Db::name('convey_cate')
+                    ->where('id', $data['type'])
+                    ->find();
+                if($conveyCate['cate']==4){
+                    if (!$data['xq_time'] || !$data['ywc_time']) {
+                        $this->error = '应完成时间应和需求时间不能为空';
+                        return false;
+                    }
+                    if ($data['xq_time'] >= $data['ywc_time']) {
+                        $this->error = '应完成时间应大于需求时间';
+                        return false;
+                    }
+                    if (strtotime($data['xq_time']) < time() - 10 * 60) {
+                        $this->error = '需求时间已过时';
+                        return false;
+                    }
+                }
                 $ysData = array(
                     'order_id' => $orderId,
                     'type' => $data['type'],
                     'start' => $data['start'],
                     'end' => $data['end'],
-                    'xq_time' => $data['xq_time'],
-                    'ywc_time' => $data['ywc_time'],
-                    'name' => $data['name'],
-                    'phone' => $data['phone'],
+                    'xq_time' => isset($data['xq_time'])?$data['xq_time']:"",
+                    'ywc_time' => isset($data['ywc_time'])?$data['ywc_time']:"",
+                    'name' => isset($data['name'])?$data['name']:"",
+                    'phone' => isset($data['phone'])?$data['phone']:"",
                     'device_id' => isset($data['device_id']) ? (int)$data['device_id'] : 0,
-                    'priority' => empty($data['priority']) ? 0 : $data['priority']
+                    'priority' => empty($data['priority']) ? 0 : $data['priority'],
+                    'score'=>$conveyCate['score']
                 );
+                if(empty($ysData['xq_time'])){
+                    unset($ysData['xq_time']);
+                }
+                if(empty($ysData['ywc_time'])){
+                    unset($ysData['ywc_time']);
+                }
                 $oCid = Db::name('order_convey')
                     ->insertGetId($ysData);
                 if (!$oCid) {
                     exception('运送信息保存失败');
                 }
-                $conveyCate = Db::name('convey_cate')
-                    ->where('id', $data['type'])
-                    ->find();
+
                 if ($conveyCate['cate'] == 1) {
                     $patient = [
                         'order_id' => $orderId,

+ 56 - 0
application/common/model/UserConveyCate.php

@@ -0,0 +1,56 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use tools\Phptree;
+
+class UserConveyCate extends Base
+{
+
+    // 更新用户常用运送类型
+    public function updateCate($userId,$conveyCateId){
+        $info = Db::name('user_convey_cate')->where('user_id',$userId)->where($conveyCateId)->find();
+        if($info){
+            $ret = Db::name('user_convey_cate')->where('id',$info['id'])->setInc('nums',1);
+        }else{
+            $ret = Db::name('user_convey_cate')->insert([
+                'user_id' => $userId,
+                'convey_cate_id' => $conveyCateId,
+                'nums' => 1
+            ]);
+        }
+        return $ret?true:false;
+    }
+
+    // 获取用户常用运送类型
+    public function getUserCates($userId){
+        $lists = Db::name('user_convey_cate')->where('user_id',$userId)->order('nums desc,id asc')->column('convey_cate_id');
+        return $lists?$lists:[];
+    }
+
+    public function sortUserCates($lists,$userId){
+        $cates = $this->getUserCates($userId);
+        if(!$cates){
+            return $lists;
+        }
+        $list1 = [];
+        foreach ($cates as $k=>$v){
+            foreach ($lists as $k1=>$v1){
+                if($v1['id'] == $v){
+                    $list1[] = $v1;
+                    break;
+                }
+            }
+        }
+        foreach ($lists as $k=>$v){
+            if(!in_array($v['id'],$cates)){
+                $list1[] = $v;
+                break;
+            }
+        }
+
+        return $list1;
+    }
+
+
+}