hzd il y a 4 mois
Parent
commit
4bdb19c747

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

@@ -758,6 +758,180 @@ class Orders extends Auth {
 
         }
     }
+
+    public function editOrder() {
+        $id = input('id', 0);
+        if (request()->isPost()) {
+            $data = request()->post();
+            $data['user_id'] = $this->userId;
+            $data['org_id'] = $this->orgId;
+            $data['images'] = isset($data['images']) && !empty($data['images']) ? implode(',', $data['images']) : '';
+
+            $res = $this->model->editSave($data);
+            if ($res) {
+                $this->success('操作成功');
+            }
+            else {
+                $this->error($this->model->getError());
+            }
+        }
+        else {
+            $order = Db::name('orders')->where('id',$id)->find();
+
+            $mode = $order['work_type_mode'];
+            $tsDh = model('Config')->getConfig('org_config_ts',$this->orgId);
+            $this->assign('tsDh',$tsDh);
+            $user = Db::name('user')
+                ->where('id',$this->userId)
+                ->find();
+            $this->assign('user',$user);
+            if($mode==0){//创建一键呼叫
+                $dep = $this->getTableField('user_dep', ['user_id' => $this->userId], 'dep_id');
+                $depList = (new \app\common\model\Dep())->getList();
+                $this->assign('dep_id', $dep);
+                $this->assign('dep_list', $depList);
+
+                $order_type = (new \app\common\model\OrderType())->getList();
+                $address = (new \app\common\model\Address())->getListByType(1);
+                $this->assign('order_type_list', $order_type);
+                $this->assign('address_list', $address);
+                $order_repair = Db::name('order_repair')
+                    ->where('order_id', $id)
+                    ->find();
+                $this->assign('order_repair', $order_repair);
+
+                $workType = Db::name('work_type_mode')
+                    ->where('type',1)
+                    ->select();
+                $config = Db::name('config')
+                    ->where('name','web_order_transfer_type')
+                    ->value('value');
+                if(empty($config)){
+                    $workType = [];
+                }else{
+                    $ll = explode('|',$config);
+                    foreach ($workType as $kk=>$vv){
+                        if(!in_array($vv['id'],$ll)){
+                            unset($workType[$kk]);
+                        }
+                    }
+                }
+
+                if(!is_admin($this->userId)){
+                    $auth = get_dispatch_auth($this->userId);
+                    if(empty($auth)){
+                        $workType = [];
+                    }else{
+                        foreach ($workType as $kk=>$vv){
+                            if(!in_array($vv['id'],$auth)){
+                                unset($workType[$kk]);
+                            }
+                        }
+                    }
+
+                }
+                foreach ($workType as $k=>$v){
+                    $this->assign('send_user_num'.$v['id'], $this->model->sendUserNum($v['id'], $this->orgId));
+                    $this->assign('user_list'.$v['id'], (new \app\common\model\WorkTypeMode())->getRolesUserByNum($v['id'], $this->orgId, 1));
+                    $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $v['id']);
+                    $this->assign('dispatch_roles'.$v['id'], $two_dispatch_roles);
+                }
+
+                $this->assign('dispatch_type', check_two_dispatch($this->userId));
+                $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
+                $this->assign('workType', $workType);
+                $address = (new \app\common\model\Address())->getListByType(2);
+                $conveyCate = (new \app\common\model\ConveyCate());
+                $priority = $conveyCate->priority;
+                $order_convey = $conveyCate->getList();
+                $order_device = (new \app\common\model\ConveyDevice())->getList();
+                $this->assign('address', $address);
+                $this->assign('priority', $priority);
+                $this->assign('order_convey_type', $order_convey);
+                $this->assign('order_device', $order_device);
+                $oCid = Db::name('order_convey')
+                    ->where('order_id',$id)
+                    ->find();
+                $opt = Db::name('order_convey_patient')
+                    ->where('order_id',$id)
+                    ->find();
+
+                $this->assign('ocid',$oCid);
+                $this->assign('opt',$opt);
+                $this->assign('ps',empty($opt)?1:0);
+                $this->assign('id', $id);
+                $this->assign('mode', $mode);
+                $this->assign('order',$order);
+
+                return $this->fetch('yjhj_dispatch_edit');
+
+            }else{
+
+                $dep = $this->getTableField('user_dep', ['user_id' => $this->userId], 'dep_id');
+                $depList = (new \app\common\model\Dep())->getList();
+                $order_type = (new \app\common\model\OrderType())->getList();
+                $address = (new \app\common\model\Address())->getListByType(1);
+                $this->assign('dep_id', $dep);
+                $this->assign('dep_list', $depList);
+                $this->assign('order_type_list', $order_type);
+                $this->assign('mode', $mode);
+                $this->assign('send_user_num', $this->model->sendUserNum($mode, $this->orgId));
+                $this->assign('user_list', (new \app\common\model\WorkTypeMode())->getRolesUserByNum($mode, $this->orgId,1));
+                $this->assign('address_list', $address);
+                $this->assign('address_id', '');
+                if ($mode == 3) {
+                    $address = (new \app\common\model\Address())->getListByType(2);
+                    $conveyCate = (new \app\common\model\ConveyCate());
+                    $priority = $conveyCate->priority;
+                    $order_convey = $conveyCate->getList();
+                    $order_device = (new \app\common\model\ConveyDevice())->getList();
+                    $this->assign('address', $address);
+                    $this->assign('priority', $priority);
+                    $this->assign('order_convey_type', $order_convey);
+                    $this->assign('order_device', $order_device);
+
+                    $orderconvey = Db::name('order_convey')->where('order_id',$id)->find();
+                    $this->assign('orderconvey',$orderconvey);
+
+                    $orderconveypatient = Db::name('order_convey_patient')->where('order_id',$id)->find();
+                    $this->assign('orderconveypatient',$orderconveypatient);
+
+                    $addrs = Db::name('order_convey_end')->where('order_id',$id)->column('addr');
+                    $this->assign('addrs',$addrs?implode(',',$addrs):'');
+                }else if($mode == 1){
+                    $orderrepair = Db::name('order_repair')->where('order_id',$id)->find();
+                    $this->assign('orderrepair',$orderrepair);
+                }
+
+                if ($id > 0) {
+//                    $phoneInfo = Db::name('phone_monitor_record')
+//                        ->where('id', $id)
+//                        ->find();
+                    $this->assign('address_id', 0);
+//                    $depId = Db::name('user_dep')
+//                        ->where('user_id', $phoneInfo['user_id'])
+//                        ->value('dep_id');
+                    $this->assign('dep_id', 0);
+                }
+                $two_dispatch_roles = model('user')->get_two_dispatch_role($this->orgId, $mode);
+                $this->assign('dispatch_roles', $two_dispatch_roles);
+                $this->assign('dispatch_type', check_two_dispatch($this->userId));
+                $this->assign('two_dispatch_off', two_dispatch_off($this->orgId));
+                $this->assign('id', $id);
+
+
+                $this->assign('order',$order);
+                if ($mode == 3) {
+                    return $this->fetch('dispatch_edit3');
+                }
+                else {
+                    return $this->fetch('dispatch_edit');
+                }
+            }
+
+        }
+    }
+
     //调度查看订单详情
     public function detail2($id) {
         if (!$id) {

+ 90 - 0
application/admin/view/orders/dispatch_edit.html

@@ -0,0 +1,90 @@
+{extend name="common/common2" /}
+{block name="main"}
+<div class="row">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('editOrder',[],'')}/mode/{$mode}?id={$id}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$order['id']}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">任务内容<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <textarea name="content" class="form-control" cols="30" rows="3"  >{$order['content']}</textarea>
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">所在科室/部门</label>
+                        <div class="col-sm-6">
+                            {:widget('common/select',['name'=>'dep_id','lists'=>$dep_list,'value'=>$order['dep_id']])}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">图片</label>
+                        <div class="col-sm-6">
+                            {:widget('common/upimg',['name'=>'images','multi'=>1,'val'=>$order['images']])}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">执行人<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            {:widget('common/user-group-select',['name'=>'to_user_id','lists'=>$user_list,'multi'=>$send_user_num,'val'=>'','msg'=>''])}
+                        </div>
+                    </div>
+                    {if $mode==1}
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">报修事项<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            {:widget('common/select',['name'=>'type_id','lists'=>$order_type_list,'value'=>isset($orderrepair['type_id'])?$orderrepair['type_id']:''])}
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">报修地址</label>
+                        <div class="col-sm-6">
+                            {:widget('common/select',['name'=>'address_id','lists'=>$address_list,'value'=>isset($orderrepair['address_id'])?$orderrepair['address_id']:''])}
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">报修紧急程度<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                        <select name="repair_priority" class="form-control" >
+                            <option value="2" {if isset($orderrepair['repair_priority']) && $orderrepair['repair_priority'] == 2}selected{/if}>普通</option>
+                            <option value="1" {if isset($orderrepair['repair_priority']) && $orderrepair['repair_priority'] == 1}selected{/if}>可延缓</option>
+                            <option value="3" {if isset($orderrepair['repair_priority']) && $orderrepair['repair_priority'] == 2}selected{/if}>紧急</option>
+                        </select>
+                    </div>
+                    </div>
+                    {/if}
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">备注</label>
+                        <div class="col-sm-6">
+                            <textarea name="todo_content" class="form-control" cols="30" rows="3" ></textarea>
+                        </div>
+                    </div>
+                    <div class="hr-line-dashed"></div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button  class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    function setType(val) {
+        if(val==1){
+            $("#type1").css('display','block')
+            $("#type2").css('display','none')
+        }else {
+            $("#type2").css('display','block')
+            $("#type1").css('display','none')
+        }
+    }
+</script>
+{/block}

+ 482 - 0
application/admin/view/orders/dispatch_edit3.html

@@ -0,0 +1,482 @@
+{extend name="common/common2" /}
+{block name="main"}
+<style>
+    .rr{
+        padding-right: 10px;
+    }
+</style>
+<div class="row" id="formApp">
+    <div class="col-sm-12">
+        <div class="ibox float-e-margins">
+            <div class="ibox-content">
+                <form method="post" action="{:url('editOrder',[],'')}/mode/{$mode}?id={$id}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$order['id']}">
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">部门</label></br>
+                            <input type="hidden" name="dep_id" id="dep" value="{$order['dep_id']|default=0}">
+                            <el-select v-model="dep_id" size="small" clearable style="width: 100%" filterable placeholder="请选择">
+                                <el-option
+                                        v-for="item in dep"
+                                        :key="item.id"
+                                        :label="item.title"
+                                        :value="item.id.toString()">
+                                </el-option>
+                            </el-select>
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">执行人<span class="text-danger">*</span></label></br>
+                            {if $send_user_num==0} <!--多选-->
+                            <input type="hidden" name="to_user_id" id="user_id">
+                            <el-select v-model="user_id" filterable clearable multiple placeholder="请选择" size="small"
+                                       style="width:100%">
+                                <el-option-group
+                                        v-for="group in user"
+                                        :key="group.id"
+                                        :label="group.name">
+                                    <el-option
+                                            v-for="item in group.user"
+                                            :key="item.id"
+                                            :label="item.real_name"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-option-group>
+                            </el-select>
+                            {else}<!--单选-->
+                            <input type="hidden" name="to_user_id" id="user_id">
+                            <el-select v-model="user_id" filterable clearable placeholder="请选择" size="small"
+                                       style="width:100%">
+                                <el-option-group
+                                        v-for="group in user"
+                                        :key="group.id"
+                                        :label="group.name">
+                                    <el-option
+                                            v-for="item in group.user"
+                                            :key="item.id"
+                                            :label="item.real_name"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-option-group>
+                            </el-select>
+                            {/if}
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">运送类型<span class="text-danger">*</span></label></br>
+                            <div class="rr">
+
+                            <input type="hidden" name="type" id="type" value="{$orderconvey['type']|default=''}">
+                            <div>
+                                <el-select v-model="type" size="small" clearable  style="width: 100%" filterable placeholder="请选择">
+                                    <el-option
+                                            v-for="item in types"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+                        </div>
+                        </div>
+                    </div>
+
+
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">优  &nbsp;先 &nbsp;级</label></br>
+                            <input type="hidden" name="priority" id="priority" value="{$orderconvey['type']|default=''}">
+                            <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 class="rr">
+                                    <input type="text" class="form-control" name="bed_number" value="{$orderconveypatient['bed_number']|default=''}">
+                                </div>
+                            </div>
+                        </div>
+                        <div class="col-sm-6">
+                            <div class="form-group">
+                                <label class="control-label">姓名</label></br>
+                                <div class="rr">
+                                    <input type="text" class="form-control" name="p_name" value="{$orderconveypatient['name']|default=''}">
+                                </div>
+                            </div>
+                        </div>
+<!--                        <div class="col-sm-4">-->
+
+<!--                            <div class="form-group">-->
+<!--                                <label class="control-label">病案号</label></br>-->
+<!--                                <div class="rr">-->
+<!--                                    <input type="text" class="form-control" name="ba_number">-->
+<!--                                </div>-->
+<!--                            </div>-->
+<!--                        </div>-->
+<!--                        <div class="col-sm-6">-->
+<!--                            <div class="form-group">-->
+<!--                                <label class="control-label">性别</label></br>-->
+<!--                                <div class="rr">-->
+<!--                                    <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">开始地点<span class="text-danger">*</span></label></br>
+                            <input type="hidden"  value="{$user.addr_id==0?'':$user.addr_id}" name="start" id="start" value="{$orderconvey['start']|default=''}">
+                            <div class="rr">
+                                <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>
+                            </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="end" id="end" value="{$orderconvey['end']|default=''}">
+                                <el-select v-model="end" size="small" clearable style="width: 100%" filterable placeholder="请选择">
+                                    <el-option
+                                            v-for="item in ends"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+                    </div>
+
+                    <div class="col-sm-12">
+                        <div class="form-group">
+                            <label class="control-label">途径地点</label></br>
+                            <div style="padding-right: 10px">
+                                <input type="hidden" name="way_addr" id="way_addr" value="{$addrs|default=''}">
+                                <el-select v-model="way_addr" size="small" collapse-tags style="width: 100%" multiple placeholder="请选择">
+                                    <el-option
+                                            v-for="item in way_addrs"
+                                            :key="item.id"
+                                            :label="item.title"
+                                            :value="item.id.toString()">
+                                    </el-option>
+                                </el-select>
+                            </div>
+                        </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" value="{$orderconvey['device_id']|default=''}">
+                            <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.toString()">
+                                </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" value="{$orderconvey['xq_time']|default=''}">
+                                <div class="rr">
+                                    <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"
+                                            @change="xqDateChange"
+                                            placeholder="选择日期时间">
+                                    </el-date-picker>
+                                </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" value="{$orderconvey['ywc_time']|default=''}">
+                                <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 class="rr">-->
+<!--                                    <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-12">
+                        <div class="form-group">
+                            <label class="control-label">派单备注</label></br>
+                            <textarea name="todo_content" class="form-control" cols="30" rows="3" ></textarea>
+                        </div>
+                    </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" value="{$order['content']}">
+
+                        </div>
+                    </div>
+                    <div class="col-sm-12">
+                        <div class="hr-line-dashed">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <div class="col-sm-6 col-sm-offset-2">
+                            <button class="btn btn-primary ajax-post" data-layer="1" target-form="form-horizontal" type="submit">确 定</button>
+                            <button class="btn cancel-btn btn-default" type="button">取 消</button>
+                        </div>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    function setType(val) {
+        if(val==1){
+            $("#type1").css('display','block')
+            $("#type2").css('display','none')
+        }else {
+            $("#type2").css('display','block')
+            $("#type1").css('display','none')
+        }
+    }
+    $(document).ready(function(){
+        formSetValue("back", {$info.back|default=0});
+        $("#yy").css('display','block');
+    });
+    $('#patient').hide();
+    var vdevices = {:json_encode($order_device)};
+    new Vue({
+        el: '#formApp',
+        data: function() {
+            return {
+                starts: [],
+                start: "",
+                ends: [],
+                end: '{$orderconvey?$orderconvey["end"]:""}',
+                way_addrs: {:json_encode($address)},
+                way_addr:'',
+                types: {:json_encode($order_convey_type)},
+                type: '',
+                prioritys:{:json_encode($priority)},
+                priority: "",
+                devices: {:json_encode($order_device)},
+                device: '{$orderconvey?$orderconvey["device_id"]:""}',
+                xq_time: '{$orderconvey?$orderconvey["xq_time"]:""}',
+                ywc_time:'{$orderconvey?$orderconvey["ywc_time"]:""}',
+                dep: {:json_encode($dep_list)},
+                dep_id: '{$order?$order["dep_id"]:""}',
+                user: {:json_encode($user_list)},
+                user_id: '',
+                to_roles: {:json_encode($dispatch_roles)},
+                to_roles_id: '',
+                roles_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):'';
+                    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}').toString():"";
+                        }
+                    }
+                        if(item.ends >0){
+                            this.end = parseInt(item.ends).toString();
+                        }else {
+                            if(item.endList.length ==0){
+                                this.end= parseInt('{$user.addr_id}') >0?parseInt('{$user.addr_id}').toString():"";
+                            }
+                        }
+                    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();
+                    }
+
+                        $("#yy").css('display','block')
+                        // if(item.cate==4){
+                        //     $("#yy").css('display','block')
+                        // }else {
+                        //     $("#yy").css('display','none')
+                        //
+                        // }
+                }
+            });
+            },
+            start: function (newtype, oldtype) {
+                $('#start').val(newtype);
+            },
+            end: function (newtype, oldtype) {
+                $('#end').val(newtype);
+            },
+            way_addr: function (newtype, oldtype) {
+                $('#way_addr').val(newtype);
+            },
+            priority: function (newtype, oldtype) {
+                $('#priority').val(newtype);
+            },
+            device: function (newtype, oldtype) {
+                $('#device').val(newtype);
+            },
+            xq_time: function (newtype, oldtype) {
+                // var that = this;
+                // $.post("{:url('getTime')}",{type:this.type,'start':newtype},function (res){
+                //     if(res.code == 1){
+                //         that.xq_time = res.data.xq_time;
+                //         that.ywc_time = res.data.ywc_time;
+                //     }
+                //
+                // })
+                $('#xqtime').val(newtype);
+            },
+            ywc_time: function (newtype, oldtype) {
+                $('#ywctime').val(newtype);
+            },
+            dep_id: function (newtype, oldtype) {
+                $('#dep').val(newtype);
+            },
+            user_id: function (newtype, oldtype) {
+                if("{$send_user_num}"==="0"){
+                    $('#user_id').val(newtype.join(','));
+                }else {
+                    $('#user_id').val(newtype);
+                }
+            },
+            roles_id: function (newtype, oldtype) {
+                $('#to_roles_id').val(newtype);
+            },
+        },
+        created(){
+            let t = '{$orderconvey?$orderconvey["type"]:""}';
+            if(t){
+                this.type = t;
+            }
+
+            let way = '{$addrs?$addrs:""}';
+            if(way){
+                this.way_addr = way.split(",");
+            }
+
+            let s = '{$orderconvey?$orderconvey["start"]:""}';
+            if(s){
+                this.start = s;
+            }
+
+            let e = '{$orderconvey?$orderconvey["end"]:""}';
+            if(e){
+                this.end = e;
+            }
+
+            let pp = '{$orderconvey?$orderconvey["priority"]:""}';
+            if(pp){
+                this.priority = pp;
+            }
+        },
+        methods: {
+            xqDateChange(e){
+                var that = this;
+                $.post("{:url('getTime')}",{type:this.type,'start':e},function (res){
+                    if(res.code == 1){
+                        that.xq_time = res.data.xq_time;
+                        that.ywc_time = res.data.ywc_time;
+                    }
+
+                })
+                $('#xqtime').val(e);
+            }
+        }
+
+    })
+
+    $('.cancel-btn').click(function () {
+        parent.layer.closeAll();
+    })
+</script>
+{/block}

+ 5 - 0
application/admin/view/orders/index.html

@@ -167,12 +167,17 @@
                     var detail_url = "{:url('detail2',[],'')}/id/"+c.id;
                     var del_url = "{:url('del',[],'')}/id/"+c.id;
                     var reject_url =  "{:url('rejectTodoList',[],'')}/orderId/"+c.id;
+
                    // var btn = '<a  href="'+detail_url+'" ><span class="label label-primary" title="详情">详情</span></a>&nbsp;';
                         var btn = '<a url="'+detail_url+'" href="javascript:;" data-title="详情" onclick="layer_open(this,1)"><span class="label label-primary" title="详情">详情</span></a>&nbsp;';
 
                         if(c.order_mode == 4 && c.bh_nums >0){
                             btn += '<a url="'+reject_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="驳回工单">驳回工单</span></a>&nbsp;';
                         }
+                        if(c.order_mode == 2 || c.order_mode == 3){
+                            var edit_url =  "{:url('editOrder',[],'')}/id/"+c.id;
+                            btn += '<a url="'+edit_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="修改">修改</span></a>&nbsp;';
+                        }
                         btn += '<a {if !btnAuth(session("user_auth.id"),"Orders/del?mode=$mode")} style="display:none"  {/if} href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
 
                         return btn;

+ 4 - 0
application/admin/view/orders/index0.html

@@ -181,6 +181,10 @@
                         if(c.order_mode == 4 && c.bh_nums >0){
                         btn += '<a url="'+reject_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="驳回工单">驳回工单</span></a>&nbsp;';
                     }
+                        if(c.order_mode == 2 || c.order_mode == 3){
+                            var edit_url =  "{:url('editOrder',[],'')}/id/"+c.id;
+                            btn += '<a url="'+edit_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="修改">修改</span></a>&nbsp;';
+                        }
                         btn += '<a {if !btnAuth(session("user_auth.id"),"Orders/del?mode=$mode")} style="display:none"  {/if} href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
                     return btn;
                 }},

+ 4 - 0
application/admin/view/orders/index1.html

@@ -181,6 +181,10 @@
                             btn+= '<a url="'+setType+'" href="javascript:;" data-title="设置报修事项" onclick="layer_open(this,1)"><span class="label label-primary" title="设置报修事项">设置报修事项</span></a>&nbsp;';
 
                         }
+                        if(c.order_mode == 2 || c.order_mode == 3){
+                            var edit_url =  "{:url('editOrder',[],'')}/id/"+c.id;
+                            btn += '<a url="'+edit_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="修改">修改</span></a>&nbsp;';
+                        }
                         return btn;
                 }},
             ],

+ 4 - 0
application/admin/view/orders/index3.html

@@ -187,6 +187,10 @@
                         // if(c.order_mode == 5 ||c.order_mode == 6){
                         //     btn += '<a {if !btnAuth(session("user_auth.id"),"Orders/del?mode=$mode")} style="display:none"  {/if} href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
                         // }
+                        if(c.order_mode == 2 || c.order_mode == 3){
+                            var edit_url =  "{:url('editOrder',[],'')}/id/"+c.id;
+                            btn += '<a url="'+edit_url+'" href="javascript:;" onclick="layer_open(this,1)" ><span class="label label-success" data-title="修改">修改</span></a>&nbsp;';
+                        }
                         btn += '<a {if !btnAuth(session("user_auth.id"),"Orders/del?mode=$mode")} style="display:none"  {/if} href="'+del_url+'" class="confirm ajax-get" data-confirm="确定要删除吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
                         return btn;
                 }},

+ 201 - 0
application/common/model/Orders.php

@@ -521,6 +521,207 @@ class Orders extends Base {
             return false;
         }
     }
+
+    public function editSave($data){
+        $order = Db::name('orders')->where('id',$data['id'])->find();
+        if(!$order || $order['del'] == 1){
+            $this->error = '订单不存在';
+            return false;
+        }
+        if($order['order_mode'] != 2 && $order['order_mode'] != 3){
+            $this->error = '只能修改已取消的订单';
+            return false;
+        }
+        if(empty($data['to_user_id'])){
+            $this->error = '请选择执行人';
+            return false;
+        }
+        if($order['work_type_mode'] ==1){
+            if(empty($data['type_id'])){
+                $this->error = '请选择报修事项';
+                return false;
+            }
+            if(empty($data['repair_priority'])){
+                $this->error = '请选择报修紧急程度';
+                return false;
+            }
+        }else if($order['work_type_mode'] == 3){
+            if(empty($data['type'])){
+                $this->error = '请选择运送类型';
+                return false;
+            }
+            if(empty($data['priority'])){
+                $this->error = '请选择优先级';
+                return false;
+            }
+            if(empty($data['start'])){
+                $this->error = '请选择开始地点';
+                return false;
+            }
+            if(empty($data['end'])){
+                $this->error = '请选择结束地点';
+                return false;
+            }
+            if(empty($data['xq_time'])){
+                $this->error = '请选择需求时间';
+                return false;
+            }
+            if(empty($data['ywc_time'])){
+                $this->error = '请选择应完成时间';
+                return false;
+            }
+        }
+
+        Db::startTrans();
+        try{
+            $ret = Db::name('orders')->where('id',$data['id'])->update([
+                'content' => $data['content'],
+                'order_mode' => 4,
+                'images' => $data['images'],
+                'dep_id' => $data['dep_id'],
+                'send_time' => getTime()
+            ]);
+            if(!$ret){
+                \exception("操作失败");
+            }
+
+            if($order['work_type_mode'] == 1){
+                $repair = Db::name('order_repair')->where('order_id',$order['id'])->find();
+                if($repair){
+                    Db::name("order_repair")->where('id',$repair['id'])->update([
+                        'type_id' => $data['type_id'],
+                        'address_id' => empty($data['address_id'])?0:$data['address_id'],
+                        'repair_priority' => $data['repair_priority'],
+                        'update_time' => getTime()
+                    ]);
+                }else{
+                    Db::name("order_repair")->insertGetId([
+                        'order_id' => $order['id'],
+                        'type_id' => $data['type_id'],
+                        'address_id' => empty($data['address_id'])?0:$data['address_id'],
+                        'repair_priority' => $data['repair_priority'],
+                        'update_time' => getTime()
+                    ]);
+                }
+            }else if($order['work_type_mode'] == 3){
+                $conveyCate = Db::name('convey_cate')->where('id',$data['type'])->find();
+                if($conveyCate['cate'] == 1){
+                    $ocp = Db::name('order_convey_patient')->where('order_id',$data['id'])->find();
+                    if($ocp){
+                        Db::name('order_convey_patient')->where('id',$ocp['id'])->update([
+                            'order_id' => $data['id'],
+                            'bed_number' => $data['bed_number'],
+                            'name' => $data['p_name'],
+                        ]);
+                    }else{
+                        Db::name('order_convey_patient')->insertGetId([
+                            'order_id' => $data['id'],
+                            'bed_number' => $data['bed_number'],
+                            'name' => $data['p_name'],
+                        ]);
+                    }
+                }
+
+                $oc = Db::name('order_convey')->where('order_id',$data['id'])->find();
+                if($oc){
+                    Db::name('order_convey')->where('id',$oc['id'])->update([
+                        'order_id' => $data['id'],
+                        'type' => $data['type'],
+                        'start' => $data['start'],
+                        'end' => $data['end'],
+                        'xq_time' => $data['xq_time'],
+                        'ywc_time' => $data['ywc_time'],
+                        'device_id' => $data['device_id'],
+                        'priority' => $data['priority'],
+                    ]);
+                }else{
+                    Db::name('order_convey')->insertGetId([
+                        'order_id' => $data['id'],
+                        'type' => $data['type'],
+                        'start' => $data['start'],
+                        'end' => $data['end'],
+                        'xq_time' => $data['xq_time'],
+                        'ywc_time' => $data['ywc_time'],
+                        'device_id' => $data['device_id'],
+                        'priority' => $data['priority'],
+                    ]);
+                }
+
+                Db::name('order_convey_end')->where('order_id',$data['id'])->delete();
+                $addrs = empty($data['way_addr'])?[]:explode(',',$data['way_addr']);
+                foreach ($addrs as $k=>$v){
+                    Db::name('order_convey_end')->insertGetId([
+                        'order_id' => $data['id'],
+                        'addr' => $v,
+                        'create_time' => getTime()
+                    ]);
+                }
+            }
+
+            $uids = explode(',',$data['to_user_id']);
+            $uids = array_unique($uids);
+
+            $pusharr = [];
+            $sns = [];
+            foreach ($uids as $k=>$v){
+                $todoData = [
+                    'order_id' => $order['id'],
+                    'org_id' => $order['org_id'],
+                    'work_type_mode' => $order['work_type_mode'],
+                    'to_user_id' => $v,
+                    'todo_content' => $data['todo_content'],
+                    'create_user_id' => $data['user_id'],
+                    'create_time' => getTime(),
+                    'todo_mode' => 1,
+                    'create_yyyy' => date("Y"),
+                    'create_yyyymm' => date("Ym"),
+                    'create_yyyymmdd' => date("Ymd"),
+                ];
+
+                $todoData['sn'] = get_unique_sn(get_config('sn_prefix'));
+                while (true){
+                    if(in_array($todoData['sn'],$sns)){
+                        $todoData['sn'] = get_unique_sn(get_config('sn_prefix'));
+                    }else{
+                        $sns[] = $todoData['sn'];
+                        break;
+                    }
+                }
+                $res = Db::name('todo')->insertGetId($todoData);
+                if (!$res) {
+                    \exception('执行人:' . $v . '派单失败');
+                }
+                $pusharr[] = [
+                    'user_id' => $v,
+                    'todo_id' => $res
+                ];
+                $taskData['user_id'] = $v;
+                $taskData['bus_id'] = $res;
+                $res = Db::name('task')->insert($taskData);
+                if (!$res) {
+                    \exception('执行人:' . $v . '任务保存失败');
+                }
+            }
+
+            if($pusharr){
+                foreach ($pusharr as $k=>$v){
+                    // 极光推送
+                    send_jpush([$v['user_id']],AppMsg::PUSH_WORKER_ORDER_SEND,'',['id'=>$v['todo_id']]);
+                }
+            }
+
+            Db::commit();
+
+            return true;
+        }catch (\Exception $e){
+            Db::rollback();
+            $this->error = $e->getMessage();
+            return false;
+        }
+
+
+
+    }
     //后台格式化订单详情
     public function formatOrder($v, $is_list = 0) {
         $v['order_type'] = '';