ss 5 månader sedan
förälder
incheckning
b3b95ca725

+ 7 - 0
application/admin/controller/Address.php

@@ -87,6 +87,13 @@ class Address extends Auth
                     'title' => $v
                 ];
             }
+
+            $bjUserList = model('User')->getWorkTypeModeUser(2,$this->orgId,-1);
+            $ysUserList = model('User')->getWorkTypeModeUser(3,$this->orgId,-1);
+
+            $this->assign('bjUserList',$bjUserList);
+            $this->assign('ysUserList',$ysUserList);
+
             $dep = model('dep')->getList();
             $this->assign('dep',$dep);
             $this->assign('types',$types);

+ 123 - 0
application/admin/controller/CleaningType.php

@@ -0,0 +1,123 @@
+<?php
+namespace app\admin\controller;
+
+use think\App;
+use think\Db;
+use think\Exception;
+
+class CleaningType extends Auth
+{
+
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->table='cleaning_type';
+        $this->model= new \app\common\model\CleaningType();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','id','trim');      //排序列
+            $sort = input('sord','desc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+
+            $title = input('title','','trim');
+            if($title){
+                $map[] = ['title','like','%'.$title.'%'];
+            }
+            $enable = input('enable','','trim');
+            if($enable != ''){
+                $map[] = ['enable','=',$enable];
+            }
+
+            $map[] = ['del','=',0];
+            $map[] = ['org_id','=',$this->orgId];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = db($this->table)->where($map)->limit($start,$length)
+                ->order(['sort'=>'desc','id'=>'desc'])
+                ->select();
+
+            //数据返回
+            $totalCount = db($this->table)->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        if(request()->isPost()){
+            $res = $this->model->updates($this->orgId);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($this->model->getError());
+            }
+        }else{
+            if($id){
+                $info =db($this->table)->where('id',$id)->find();
+                $this->assign('info',$info);
+            }
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    public function changeSort($id=0,$sort=0){
+        if($id<0||$sort<0){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+}

+ 230 - 0
application/admin/controller/ModeCate.php

@@ -0,0 +1,230 @@
+<?php
+namespace app\admin\controller;
+
+use think\App;
+use think\Db;
+use think\Exception;
+
+class ModeCate extends Auth
+{
+
+    public function __construct(App $app = null) {
+        parent::__construct($app);
+        $this->table='mode_cate';
+        $this->model= new \app\common\model\ModeCate();
+    }
+    public function index(){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','id','trim');      //排序列
+            $sort = input('sord','desc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+
+            $title = input('title','','trim');
+            if($title){
+                $map[] = ['title','like','%'.$title.'%'];
+            }
+            $enable = input('enable','','trim');
+            if($enable != ''){
+                $map[] = ['enable','=',$enable];
+            }
+
+            $map[] = ['del','=',0];
+            $map[] = ['org_id','=',$this->orgId];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = db($this->table)
+                ->where($map)
+                ->limit($start,$length)
+                ->order([$sortRow=>$sort,'id'=>'desc'])
+                ->select();
+
+            foreach ($lists as $k=>$v){
+                $lists[$k]['cateTypes'] = Db::name('mode_cate_type')
+                    ->where('cate_id',$v['id'])
+                    ->select();
+
+            }
+
+            //数据返回
+            $totalCount = db($this->table)->where($map)->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 新增/编辑
+     */
+    public function add($id=0){
+        if(request()->isPost()){
+            $res = $this->model->updates($this->orgId);
+            if($res){
+                $this->success('操作成功',url('index'));
+            }else{
+                $this->error($this->model->getError());
+            }
+        }else{
+            if($id){
+                $info =db($this->table)->where('id',$id)->find();
+
+                $busIds = Db::name('mode_cate_type')->where('mode',2)->where('cate_id',$info['id'])->column('bus_id');
+                $busIds1 = Db::name('mode_cate_type')->where('mode',3)->where('cate_id',$info['id'])->column('bus_id');
+                $info['bus_ids'] = $busIds ? $busIds:[];
+                $info['bus_ids1'] = $busIds1 ? $busIds1:[];
+                $this->assign('info',$info);
+            }
+
+
+            $cleaningType = model('CleaningType')->getList($this->orgId);
+
+            $this->assign('cleaningType',$cleaningType);
+
+            $conveyType = model('ConveyCate')->getList3($this->orgId);
+            $this->assign('conveyType',$conveyType);
+
+            return $this->fetch();
+        }
+    }
+
+    /**
+     * 删除记录
+     * @param int $id
+     */
+    public function del($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField('del',1);
+        if($res){
+            $this->success('删除成功');
+        }else{
+            $this->error('删除失败');
+        }
+    }
+
+    /**
+     * 改变字段值
+     * @param int $fv
+     * @param string $fn
+     * @param int $fv
+     */
+    public function changeField($id=0,$fn='',$fv=0){
+        if(!$fn||!$id){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField($fn,$fv);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    public function changeSort($id=0,$sort=0){
+        if($id<0||$sort<0){
+            $this->error('参数错误');
+        }
+        $res = db($this->table)->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+
+    public function cateType($id=0,$mode=2){
+        if(request()->isAjax()){
+            //分页参数
+            $length = input('rows',10,'intval');   //每页条数
+            $page = input('page',1,'intval');      //第几页
+            $start = ($page - 1) * $length;     //分页开始位置
+            //排序
+            $sortRow = input('sidx','id','trim');      //排序列
+            $sort = input('sord','desc','trim');        //排序方式
+            $order = $sortRow.' '.$sort;
+
+            if($mode == 2){
+                $atable = 'cleaning_type b';
+            }else{
+                $atable = 'convey_cate b';
+            }
+
+            $map[] = ['a.mode','=',$mode];
+            $map[] = ['a.cate_id','=',$id];
+            $map= empty($map) ? true: $map;
+            //数据查询
+            $lists = db('mode_cate_type')
+                ->alias('a')
+                ->field('a.*,b.title')
+                ->join($atable,'a.bus_id=b.id')
+                ->where($map)
+                ->limit($start,$length)
+                ->order('a.sort desc,a.id desc')
+                ->select();
+
+
+            //数据返回
+            $totalCount = db('mode_cate_type')
+                ->alias('a')
+                ->join($atable,'a.bus_id=b.id')
+                ->where($map)
+                ->count();
+            $totalPage = ceil($totalCount/$length);
+            $result['page'] = $page;
+            $result['total'] = $totalPage;
+            $result['records'] = $totalCount;
+            $result['rows'] = $lists;
+            return json($result);
+        }else{
+            $this->assign('id',$id);
+            $this->assign('mode',$mode);
+            $m = '';
+            if($mode == 2){
+                $m = '保洁';
+            }elseif ($mode == 3){
+                $m = '运送';
+            }
+
+            $this->assign('m_name',$m.'类型');
+            return $this->fetch();
+        }
+    }
+
+
+    public function changeSortType($id=0){
+        $sort = input('sort');
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db('mode_cate_type')->where('id',$id)->setField('sort',$sort);
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+
+    public function delCateType($id=0){
+        if(!$id){
+            $this->error('参数错误');
+        }
+        $res = db('mode_cate_type')->where('id',$id)->delete();
+        if($res){
+            $this->success('操作成功');
+        }else{
+            $this->error('操作失败');
+        }
+    }
+}

+ 43 - 0
application/admin/view/address/add.html

@@ -61,6 +61,37 @@
                             <input type="text" class="form-control" name="user" value="{$info.user|default=''}">
                         </div>
                     </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">是否是手术室</label>
+                        <div class="col-sm-6">
+                            <label class="cr-inline">
+                                <input type="radio" value="1" name="is_sss" onclick="clickIssss(1)">是&nbsp;&nbsp;
+                            </label>
+                            <label class="cr-inline">
+                                <input type="radio" value="0" name="is_sss" onclick="clickIssss(0)">否
+                            </label>
+                        </div>
+                    </div>
+
+                    <div id="issss" style="display:none ">
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">保洁负责人</label>
+                            <div class="col-sm-6">
+                                {:widget_view('common/select',['name'=>'bj_user_id','lists' => $bjUserList, 'value' => isset($info)?$info['bj_user_id']:''])}
+                            </div>
+                        </div>
+
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">运送负责人</label>
+                            <div class="col-sm-6">
+                                {:widget_view('common/select',['name'=>'ys_user_id','lists' => $ysUserList, 'value' => isset($info)?$info['ys_user_id']:''])}
+                            </div>
+                        </div>
+
+                    </div>
+
+
                     <div class="hr-line-dashed"></div>
                     <div class="form-group">
                         <div class="col-sm-6 col-sm-offset-2">
@@ -78,6 +109,18 @@
     $(document).ready(function(){
         formSetValue("enable", {$info.enable|default=1});
     });
+    $(document).ready(function(){
+        formSetValue("is_sss", {$info.is_sss|default=0});
+        clickIssss({$info.is_sss|default=0});
+    });
+
+    function clickIssss(e){
+        if(e === 1){
+            $('#issss').css('display','block');
+        }else{
+            $('#issss').css('display','none');
+        }
+    }
 
 </script>
 {/block}

+ 58 - 0
application/admin/view/cleaning_type/add.html

@@ -0,0 +1,58 @@
+{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('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">名称<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">颜色</label>
+                        <div class="col-sm-6">
+                            {:widget_view('common/color-picker',['name'=>'color', 'value' => isset($info)?$info['color']:''])}
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">排序</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="sort" value="{$info.sort|default='50'}">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">状态</label>
+                        <div class="col-sm-6">
+                            <label class="cr-inline">
+                                <input type="radio" value="1" name="enable">正常&nbsp;&nbsp;
+                            </label>
+                            <label class="cr-inline">
+                                <input type="radio" value="0" name="enable">禁用
+                            </label>
+                        </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>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+</script>
+{/block}

+ 104 - 0
application/admin/view/cleaning_type/index.html

@@ -0,0 +1,104 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增时间代码" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="title" placeholder="名称">
+                    </div>
+                    <div class="input-group">
+                        <select name="enable" class="form-control">
+                            <option value="">选择状态</option>
+                            <option value="0">禁用</option>
+                            <option value="1">正常</option>
+                        </select>
+                    </div>
+                    <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                    </span> &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                    </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'名称',name:'title',index:'title',width:80,editable: false,sortable: false},
+                {label:'颜色',name:'color',index:'color',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        return '<div style="width: 20px;height: 20px;background-color:'+a+' "></div>';
+                    }},
+
+                {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
+                        return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSort')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
+                    }},
+                {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a == 0){
+                            var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
+                            return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
+                        } else{
+                            var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
+                            return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
+                        }
+                    }},
+                {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
+                        var editurl = "{:url('add',[],'')}/id/"+c.id;
+                        var delurl = "{:url('del',[],'')}/id/"+c.id;
+                        var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑时间代码" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
+                        //btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"保洁类型列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+
+</script>
+{/block}

+ 19 - 0
application/admin/view/common/color-picker.html

@@ -0,0 +1,19 @@
+<div id="{$name}">
+    <input type="hidden" name="{$name}" v-model="value">
+    <el-color-picker v-model="value"></el-color-picker>
+</div>
+<script>
+    new Vue({
+        el: '#{$name}',
+        data: function() {
+            return {
+                value:"{$value}"
+            }
+        },
+        watch: {
+            value: function (newVal, oldVal) {
+                $('input[name={$name}').val(newVal);
+            }
+        }
+    })
+</script>

+ 60 - 0
application/admin/view/convey_cate/add.html

@@ -81,6 +81,51 @@
                             </label>
                         </div>
                     </div>
+
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">是否是手术室</label>
+                        <div class="col-sm-6">
+                            <label class="cr-inline">
+                                <input type="radio" value="1" name="is_sss" onclick="clickIssss(1)">是&nbsp;&nbsp;
+                            </label>
+                            <label class="cr-inline">
+                                <input type="radio" value="0" name="is_sss" onclick="clickIssss(0)">否
+                            </label>
+                        </div>
+                    </div>
+
+
+
+                    <div id="issss" style="display:none ">
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">类型</label>
+                            <div class="col-sm-6">
+                                <label class="cr-inline">
+                                    <input type="radio" value="1" name="type" onclick="clickIssss(1)">外送&nbsp;&nbsp;
+                                </label>
+                                <label class="cr-inline">
+                                    <input type="radio" value="0" name="type" onclick="clickIssss(0)">收取
+                                </label>
+                            </div>
+                        </div>
+
+                        <div class="form-group">
+                            <label class="col-sm-2 control-label">运送地点</label>
+                            <div class="col-sm-6">
+                                {:widget_view('common/select',['name'=>'addr_id','lists' => $ends, 'value' => isset($info)?$info['addr_id']:''])}
+                            </div>
+                        </div>
+
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">颜色</label>
+                        <div class="col-sm-6">
+                            {:widget_view('common/color-picker',['name'=>'color', 'value' => isset($info)?$info['color']:''])}
+                        </div>
+                    </div>
+
                     <div class="hr-line-dashed"></div>
                     <div class="form-group">
                         <div class="col-sm-6 col-sm-offset-2">
@@ -99,6 +144,21 @@
     $(document).ready(function(){
         formSetValue("enable", {$info.enable|default=1});
     });
+    $(document).ready(function(){
+        formSetValue("type", {$info.type|default=0});
+    });
+    $(document).ready(function(){
+        formSetValue("is_sss", {$info.is_sss|default=0});
+        clickIssss({$info.is_sss|default=0});
+    });
+
+    function clickIssss(e){
+        if(e === 1){
+            $('#issss').css('display','block');
+        }else{
+            $('#issss').css('display','none');
+        }
+    }
 
 </script>
 {/block}

+ 4 - 0
application/admin/view/convey_cate/index.html

@@ -138,6 +138,10 @@
                         return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
                     }
                 }},
+                {label:'颜色',name:'color',index:'color',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        return '<div style="width: 20px;height: 20px;background-color:'+a+' "></div>';
+                    }},
+
                 {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
                     var editurl = "{:url('add',[],'')}/id/"+c.id;
                     var delurl = "{:url('del',[],'')}/id/"+c.id;

+ 4 - 4
application/admin/view/index/def.html

@@ -237,10 +237,10 @@
 <!--                        <img src="{:url('Qrcode/qrcode',['code'=>$xshopcode,'type'=>1])}" alt="商城客户端二维码">-->
 <!--                        <div class="title">商城客户端二维码</div>-->
 <!--                    </div>-->
-<!--                    <div class="qrcode2">-->
-<!--                        <img src="{:url('Qrcode/qrcode',['code'=>$phcode,'type'=>1])}" alt="陪护客户端二维码">-->
-<!--                        <div class="title">陪护客户端二维码</div>-->
-<!--                    </div>-->
+                    <div class="qrcode2">
+                        <img src="{:url('Qrcode/qrcode',['code'=>$phcode,'type'=>1])}" alt="陪护客户端二维码">
+                        <div class="title">陪护客户端二维码</div>
+                    </div>
 <!--                    {notempty name="wxcode"}-->
 <!--                    <div class="qrcode2">-->
 <!--                        <img src="{$wxcode}" alt="小程序二维码">-->

+ 97 - 0
application/admin/view/mode_cate/add.html

@@ -0,0 +1,97 @@
+{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('add')}" class="form-horizontal">
+                    <input type="hidden" name="id" value="{$info['id']|default='0'}">
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">名称<span class="text-danger">*</span></label>
+                        <div class="col-sm-6">
+                            <input type="text" class="form-control" name="title" value="{$info.title|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">类型</label>
+                        <div class="col-sm-6">
+                            <label class="cr-inline">
+                                <input type="radio" value="2" name="mode" onclick="clickMode(2)">保洁&nbsp;&nbsp;
+                            </label>
+                            <label class="cr-inline">
+                                <input type="radio" value="3" name="mode" onclick="clickMode(3)">运送
+                            </label>
+                        </div>
+                    </div>
+
+                    <div class="form-group" id="bjType" style="display: block">
+                        <label class="col-sm-2 control-label">保洁类型</label>
+                        <div class="col-sm-6">
+                            {:widget_view('common/multiselect',['name'=>'bus_ids','lists' => $cleaningType, 'val' => isset($info)?$info['bus_ids']:[]])}
+                        </div>
+                    </div>
+
+                    <div class="form-group" id="ysType" style="display: none">
+                        <label class="col-sm-2 control-label">运送类型</label>
+                        <div class="col-sm-6">
+                            {:widget_view('common/multiselect',['name'=>'bus_ids1','lists' => $conveyType, 'val' => isset($info)?$info['bus_ids1']:[]])}
+                        </div>
+                    </div>
+
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">排序</label>
+                        <div class="col-sm-6">
+                            <input type="number" class="form-control" name="sort" value="{$info.sort|default='0'}">
+                        </div>
+                    </div>
+                    <div class="form-group">
+                        <label class="col-sm-2 control-label">状态</label>
+                        <div class="col-sm-6">
+                            <label class="cr-inline">
+                                <input type="radio" value="1" name="enable">正常&nbsp;&nbsp;
+                            </label>
+                            <label class="cr-inline">
+                                <input type="radio" value="0" name="enable">禁用
+                            </label>
+                        </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>
+    $(document).ready(function(){
+        formSetValue("enable", {$info.enable|default=1});
+    });
+
+    $(document).ready(function(){
+        formSetValue("mode", {$info.mode|default=2});
+
+        clickMode({$info.mode|default=2});
+    });
+
+
+    function clickMode(e){
+        if(e === 2){
+            $('#bjType').css('display','block');
+            $('#ysType').css('display','none');
+        }else{
+            $('#ysType').css('display','block');
+            $('#bjType').css('display','none');
+        }
+    }
+
+
+</script>
+{/block}

+ 70 - 0
application/admin/view/mode_cate/cate_type.html

@@ -0,0 +1,70 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <!-- <div class="ibox-content">
+         <div class="row">
+             <div class="col-xs-12" style="text-align: right;">
+                 <div class="ibox-tools">
+                     <a class="toback" href="{:url('autoConveyCate')}">
+                         返回上一页
+                     </a>
+                 </div>
+             </div>
+         </div>
+     </div>-->
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('cateType')}?id={$id}&mode={$mode}",
+            datatype: "json",
+            colModel:[
+                {label:'名称',name:'title',index:'title',width:80,editable: false,sortable: false},
+                {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
+                        return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSortType')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
+                    }},
+                {label:'创建时间',name:'create_time',index:'create_time',width:80,editable: false,sortable: false},
+                {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
+                        var delurl = "{:url('delCateType',[],'')}/id/"+c.id;
+                        var btn = '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"{$m_name}列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+</script>
+{/block}

+ 116 - 0
application/admin/view/mode_cate/index.html

@@ -0,0 +1,116 @@
+{extend name="common/common2" /}
+{block name="main"}
+
+<div class="ibox">
+    <div class="ibox-content">
+        <div class="row">
+            <div class="col-xs-3">
+                <a href="javascript:;" url="{:url('add')}" data-title="新增时间代码" onclick="layer_open(this,1)" class="btn btn-sm btn-primary">新增</a>
+            </div>
+            <div class="col-xs-9" style="text-align: right;">
+                <form class="form-inline" id="form-search" action="{:url('index')}">
+                    <div class="input-group">
+                        <input type="text" class="form-control" name="title" placeholder="名称">
+                    </div>
+                    <div class="input-group">
+                        <select name="enable" class="form-control">
+                            <option value="">选择状态</option>
+                            <option value="0">禁用</option>
+                            <option value="1">正常</option>
+                        </select>
+                    </div>
+                    <div class="input-group">
+                    <span class="input-group-btn">
+                        <button class="btn-sm btn-primary" type="button" id ="search-btn" ><i class="fa fa-search"></i></button>
+                    </span> &nbsp;
+                        <span class="input-group-btn">
+                        <button class="btn-sm btn-warning" type="button" id="search-clear"><i class="fa fa-undo"></i></button>
+                    </span>
+                    </div>
+                </form>
+            </div>
+        </div>
+    </div>
+    <div class="ibox-content">
+        <div class="jqGrid_wrapper">
+            <table id="table" style="border-collapse: collapse"></table>
+            <div id="pager"></div>
+        </div>
+    </div>
+</div>
+{/block}
+{block name="script"}
+<script>
+    $(function () {
+
+        $(window).bind("resize",function(){
+            var width=$(".jqGrid_wrapper").width();
+            $("#table").setGridWidth(width);
+        });
+
+        $.jgrid.defaults.styleUI="Bootstrap";
+        $("#table").jqGrid({
+            url:"{:url('index')}",
+            datatype: "json",
+            colModel:[
+                {label:'ID',name:'id',index:'id', width:30,sortable: false},
+                {label:'名称',name:'title',index:'title',width:50,editable: false,sortable: false},
+
+                {label:'排序',name:'sort',index:'sort',width:40,sortable: true,formatter: function (a, b, c) {
+                        return '<input type="number" onchange="updateSort(this)" data-url="{:url('changeSort')}" class="form-control input-sm" data-id="'+c.id+'" data-old="'+a+'" value="'+a+'" />';
+                    }},
+                {label:'类型',name:'mode',index:'mode',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a == 2){
+                            return '<span style="color: #0d8ddb">保洁</span>';
+                        } else{
+                            return '<span style="color: #0d8ddb">运送</span>';
+                        }
+                    }},
+                {label:'保洁/运送类型',name:'cateTypes',index:'typeCates',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a){
+                            var url = "{:url('cateType',[],'')}/id/"+c.id+'/mode/'+c.mode;
+                            return '<a url="'+url+'" href="javascript:;" data-title="类型" onclick="layer_open(this,1)"><span class="label label-primary" title="查看">查看</span></a>&nbsp;';
+                        } else{
+                            return '<span>无</span>';
+                        }
+                    }},
+                {label:'状态',name:'enable',index:'enable',width:40,editable: false,sortable: false,formatter:function (a,b,c){
+                        if(a == 0){
+                            var url = "{:url('changeField',[],'')}/fn/enable/fv/1/id/"+c.id;
+                            return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-danger" title="禁用">禁用</span></a>';
+                        } else{
+                            var url = "{:url('changeField',[],'')}/fn/enable/fv/0/id/"+c.id;
+                            return '<a href="'+url+'" class="ajax-get" data-table="1"><span class="label label-primary" title="正常">正常</span></a>';
+                        }
+                    }},
+                {label:'操作',width:50,sortable: false,formatter: function (a, b, c) {
+                        var editurl = "{:url('add',[],'')}/id/"+c.id;
+                        var delurl = "{:url('del',[],'')}/id/"+c.id;
+                        var btn = '<a url="'+editurl+'" href="javascript:;" data-title="编辑" onclick="layer_open(this,1)"><span class="label label-primary" title="编辑">编辑</span></a>&nbsp;';
+                        btn += '<a href="'+delurl+'" class="confirm ajax-get" data-confirm="确定要删除此记录吗?" data-table="1"><span class="label label-danger" title="删除">删除</span></a>';
+                        return btn;
+                    }},
+            ],
+            rowNum:10,
+            rowList:[10,20,30,50,100],
+            pager: '#pager',
+            sortname: 'sort',
+            viewrecords: true,
+            autowidth:true,
+            mtype: 'post',
+            height: 'auto',
+            emptyrecords: "暂无数据",
+            sortorder: "asc",
+            caption:"分类列表",
+            loadComplete: function (xhr) {
+                if(xhr.code==0){
+                    layer.msg(xhr.msg);
+                    return false;
+                }
+            },
+        });
+    });
+
+
+</script>
+{/block}

+ 332 - 0
application/api/controller/v1/ModeCate.php

@@ -0,0 +1,332 @@
+<?php
+namespace app\api\controller\v1;
+use app\api\controller\Base;
+use app\common\util\AppMsg;
+use app\hander\HelpHander;
+use think\Controller;
+use think\Db;
+use think\Exception;
+
+class ModeCate extends Base
+{
+    public function list(){
+
+        $lists = Db::name('mode_cate')
+            ->where('del',0)
+            ->where('enable',1)
+            ->where('org_id',$this->orgId)
+            ->order('sort desc,id desc')
+            ->select();
+        foreach ($lists as $k=>$v){
+            if($v['mode'] == 2){
+                $atable = 'cleaning_type b';
+            }else{
+                $atable = 'convey_cate b';
+            }
+            $typeList =  Db::name('mode_cate_type')
+                ->alias('a')
+                ->field('b.id,b.title,b.color')
+                ->join($atable,'b.id=a.bus_id')
+                ->where('a.mode',$v['mode'])
+                ->where('a.cate_id',$v['id'])
+                ->order('a.sort desc,a.id desc')
+                ->select();
+            $lists[$k]['type_list'] = $typeList?$typeList:[];
+        }
+
+        HelpHander::success($lists);
+    }
+
+    public function addOrder(){
+
+        $mode = input('mode');
+        $typeId = input('typeId',0);
+
+        if(!in_array($mode,[2,3])){
+            HelpHander::error('参数错误');
+        }
+        if($typeId < 1){
+            HelpHander::error('参数错误');
+        }
+
+        $addrId = Db::name('user')->where('id',$this->userId)->value('addr_id');
+
+        if($addrId < 1){
+            HelpHander::error('始发空间不能为空');
+        }
+
+        $addrInfo = Db::name('address')->where('id',$addrId)->find();
+
+        $bjToUserId = $addrInfo['bj_user_id'] ?$addrInfo['bj_user_id']:0;
+
+        $ysToUserId = $addrInfo['ys_user_id'] ?$addrInfo['ys_user_id']:0;
+
+        $toUserId = 0;
+        $content = '';
+
+        if($mode == 2){
+            $content = Db::name('cleaning_type')->where('del',0)->where('id',$typeId)->value('title');
+            if(!$bjToUserId){
+                HelpHander::error('保洁责任人不能为空');
+            }
+            $toUserId = $bjToUserId;
+        }elseif($mode == 3){
+            $conveyCate = Db::name('convey_cate')->where('del',0)->where('is_sss',1)->where('id',$typeId)->find();
+            if(!$conveyCate){
+                HelpHander::error('类型不存在');
+            }
+            $content = $conveyCate['title'];
+            if(!$ysToUserId){
+                HelpHander::error('运送责任人不能为空');
+            }
+            $toUserId = $ysToUserId;
+
+            if($conveyCate['addr_id'] < 1){
+                HelpHander::error('地点不能为空');
+            }
+            if($addrId == $conveyCate['addr_id']){
+                HelpHander::error('开始地点和结束地点不能一致');
+            }
+        }
+
+
+//        $depId = Db::name('user_dep')
+//            ->alias('ud')
+//            ->join('dep d','d.id=ud.dep_id')
+//            ->where('d.del',0)
+//            ->where('ud.user_id',$this->userId)
+//            ->value('d.id');
+
+        $odata = [
+            'org_id'=>$this->orgId,
+            'user_id'=>$this->userId,
+            'create_time' => getTime(),
+            'create_yyyy' => date('Y'),
+            'create_yyyymm' => date('Ym'),
+            'create_yyyymmdd' => date('Ymd'),
+            'sn' => get_unique_sn(get_config('sn_prefix')),
+            'content' => $content,
+            'work_type_mode' => $mode,
+            'order_mode'=>4,
+            'source_type' => 2,
+            'dep_id' => 0,
+            'send_time' => getTime(),
+            'is_deal' => 1,
+            'from' => 0,
+        ];
+        Db::startTrans();
+        try {
+            $orderId = Db::name('orders')->insertGetId($odata);
+            if(!$orderId){
+                \exception('订单生成失败');
+            }
+            if($mode == 2){
+                $octData = [
+                    'order_id'=>$orderId,
+                    'type_id'=>$typeId,
+                    'create_time'=>getTime()
+                ];
+                $oct = Db::name('order_clean_type')->insert($octData);
+                if(!$oct){
+                    \exception('订单保洁类型扩展生成失败');
+                }
+            }
+            if($mode == 3){
+                $conveyCateInfo =  Db::name('convey_cate')->where('del',0)->where('id',$typeId)->find();
+
+                $time = Db::name('time')->where('del',0)->where('id',$conveyCateInfo['time_id'])->find();
+                $ywcTime = time() + $time['bz_time']*60;
+
+
+                if($conveyCateInfo['type'] == 0){
+                    $saddr = $addrId;
+                    $eaddr = $conveyCateInfo['addr_id'];
+                }else{
+                    $saddr = $conveyCateInfo['addr_id'];
+                    $eaddr = $addrId;
+                }
+
+                $ocData = [
+                  'order_id'=>$orderId,
+                  'type'=>$typeId,
+                  'start'=>$saddr,
+                  'end'=>$eaddr,
+                  'xq_time'=>getTime(),
+                  'ywc_time'=>date('Y-m-d H:i:s',$ywcTime),
+                  'score'=>$conveyCateInfo['score'],
+                  'priority'=>0,
+                ];
+                $ocAdd = Db::name('order_convey')->insert($ocData);
+                if(!$ocAdd){
+                    \exception('运送扩展生成失败');
+                }
+            }
+
+            $todoData = [
+                'order_id' => $orderId,
+                'todo_content' => $content,
+                'create_user_id' => $this->userId,
+                'org_id' => $this->orgId,
+                'create_time' => getTime(),
+                'confirm_time' => getTime(),
+                'todo_mode' => 2,
+                'work_type_mode' => $mode,
+                'create_yyyy' => date('Y'),
+                'create_yyyymm' => date('Ym'),
+                'create_yyyymmdd' => date('Ymd'),
+                'quality_type' => 0,
+                'to_user_id'=>$toUserId,
+                'sn'=> get_unique_sn(get_config('sn_prefix')),
+            ];
+
+            $todoId = Db::name('todo')->insertGetId($todoData);
+
+            if(!$todoId){
+                \exception('分派订单失败');
+            }
+
+            $taskData = [
+                'org_id' => $this->orgId,
+                'type' => 1,
+                'start_time' => getTime(),
+                'create_time' => getTime(),
+                'user_id' => $toUserId,
+                'bus_id' => $todoId,
+            ];
+            $res = Db::name('task')
+                ->insert($taskData);
+            if (!$res) {
+                \exception('任务保存失败');
+            }
+
+            send_jpush([$toUserId],AppMsg::PUSH_WORKER_ORDER_SEND,'',['id'=>$todoId]);
+
+            Db::commit();
+
+        }catch (\Exception $e){
+            Db::rollback();
+            HelpHander::error($e->getMessage());
+        }
+        HelpHander::success([],'操作成功');
+
+    }
+
+    public function getTodoList(){
+        $type = input('type',0);
+        $page = input('page',1);
+        $size = input('size',10);
+
+
+        if(!in_array($type,[0,1])){
+            HelpHander::error('参数错误');
+        }
+
+        $map[] = ['org_id','=',$this->orgId];
+        $map[] = ['del','=',0];
+        $map[] = ['create_user_id','=',$this->userId];
+
+        $map[] = ['work_type_mode','in',[2,3]];
+
+        if($type == 0){
+            $map[] = ['todo_mode','=',2];
+        }else{
+            $map[] = ['todo_mode','in',[3,6]];
+        }
+
+        $list = Db::name('todo')
+            ->where($map)
+            ->page($page,$size)
+            ->order('id','desc')
+            ->select();
+
+        $data = [];
+        foreach ($list as $k=>$v){
+            $data[$k]['id'] = $v['id'];
+            $data[$k]['work_type_mode'] = $v['work_type_mode'];
+            $data[$k]['create_time'] = $v['create_time'];
+            $data[$k]['todo_content'] = $v['todo_content'];
+            $data[$k]['order_id'] = $v['order_id'];
+            $data[$k]['todo_mode'] = $v['todo_mode'];
+            $data[$k]['done_time'] = $v['done_time'];
+
+            $touser = Db::name('user')->where('id',$v['to_user_id'])->find();
+            $data[$k]['to_user_name'] = $touser['real_name'];
+            $addrName = Db::name('address')->where('id',$touser['addr_id'])->value('title');
+            $data[$k]['s_addr'] = $addrName ?$addrName :'';
+            $data[$k]['todo_mode_text'] = Db::name('todo_mode')->where('id',$v['todo_mode'])->value('out_content');
+            $data[$k]['work_type_mode_text'] = Db::name('work_type_mode')->where('id',$v['work_type_mode'])->value('name');
+            $data[$k]['type_name'] = '';
+            $data[$k]['e_addr'] = '';
+            $data[$k]['last_addr'] = '';
+            $data[$k]['last_addr_time'] = '';
+            if($v['work_type_mode'] == 2){
+                $typeTitle = Db::name('cleaning_type')
+                    ->alias('ct')
+                    ->join('order_clean_type oct','oct.type_id=ct.id')
+                    ->where('oct.order_id',$v['order_id'])
+                    ->value('ct.title');
+                $data[$k]['type_name'] = $typeTitle ? $typeTitle :'';
+            }
+
+            if($v['work_type_mode'] == 3){
+                $typeInfo = Db::name('convey_cate')
+                    ->alias('cc')
+                    ->field('oc.*,cc.title')
+                    ->join('order_convey oc','oc.type=cc.id')
+                    ->where('oc.order_id',$v['order_id'])
+                    ->find();
+                if($typeInfo){
+                    $saddr = Db::name('address')->where('id',$typeInfo['start'])->value('title');
+                    $eaddr = Db::name('address')->where('id',$typeInfo['end'])->value('title');
+
+                    $data[$k]['type_name'] = $typeInfo ? $typeInfo['title'] :'';
+                    $data[$k]['s_addr'] = $saddr ? $saddr :'';
+                    $data[$k]['e_addr'] = $eaddr ? $eaddr :'';
+
+
+                    $addr = Db::name('order_convey')
+                        ->alias('cpr')
+                        ->join('todo os', 'cpr.order_id = os.order_id')
+                        ->join('orders ods', 'cpr.order_id = ods.id')
+                        ->join('address ca', 'ca.id = cpr.start')
+                        ->join('address cad', 'cad.id = cpr.end')
+                        ->field('os.todo_mode,ca.title as start_name,cad.title as end_name,os.create_time')
+                        ->where('os.to_user_id', $v['to_user_id'])
+                        ->where('os.del', 0)
+                        ->where('ods.del', 0)
+                        ->order('os.id desc')
+                        ->find();
+
+                    if(in_array($addr['todo_mode'],[1,2])){
+                        $data[$k]['last_addr'] = $addr['start_name'];
+                    }else{
+                        $data[$k]['last_addr'] = $addr['end_name'];
+                    }
+                    $data[$k]['last_addr_time'] = $addr['create_time'];
+                }
+
+            }
+        }
+        HelpHander::success($data,'操作成功');
+    }
+
+    public function updateState(){
+        $todoId = input('todoId/d',0);
+        if($todoId <= 0){
+            HelpHander::error('参数错误');
+        }
+        $todoMode =input('todoMode',0);
+        if(!in_array($todoMode,[2,4,6])){
+            HelpHander::error('参数错误');
+        }
+        $nodoReason = input('nodoReason','');
+
+        $rejectVoice = input('rejectVoice','');
+        $ret = model('Todo')->updateState($todoId,$todoMode,$nodoReason,$this->userId,$rejectVoice);
+        if(!$ret){
+            HelpHander::error(model('Todo')->getError());
+        }
+        HelpHander::success([],'操作成功');
+    }
+
+}

+ 34 - 0
application/common/model/CleaningType.php

@@ -0,0 +1,34 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use think\Exception;
+
+class CleaningType extends Base
+{
+
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+    protected $table = 'cleaning_type';
+    protected $validateName = 'CleaningType';
+
+    public function updates($orgId)
+    {
+        $data = request()->post();
+        $data['org_id'] = $orgId;
+        return $this->updateInfo($data, $this->validateName, '');
+    }
+
+    public function getList($orgId){
+
+        $map[] = ['org_id','=',$orgId];
+        $map[] = ['del','=',0];
+        $map[] = ['enable','=',1];
+
+        $lists = Db::name($this->table)
+            ->where($map)
+            ->select();
+
+        return $lists;
+    }
+}

+ 11 - 0
application/common/model/ConveyCate.php

@@ -216,4 +216,15 @@ class ConveyCate extends Base
         $v['priorityName']  = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:"";
         return $v;
     }
+
+    public function getList3($orgId){
+        $list = $this
+            ->where('org_id',$orgId)
+            ->where('enable',1)
+            ->where('del',0)
+            ->where('is_sss',1)
+            ->select();
+
+        return $list?$list->toArray():[];
+    }
 }

+ 183 - 0
application/common/model/ModeCate.php

@@ -0,0 +1,183 @@
+<?php
+namespace app\common\model;
+
+use think\Db;
+use think\Exception;
+
+class ModeCate extends Base
+{
+
+    protected $createTime = 'create_time';
+    protected $updateTime = 'update_time';
+    protected $table = 'mode_cate';
+    protected $validateName = 'ModeCate';
+
+    public function updates($orgId){
+        $data = request()->post();
+        $data['org_id'] = cur_org_id();
+        $result = validate($this->validateName)->check($data,[],'');
+        if(true !== $result){
+            $this->error = validate($this->validateName)->getError();
+            return false;
+        }
+
+        $busIds = $data['bus_ids'] ? explode(',',$data['bus_ids']) :[];
+        unset($data['bus_ids']);
+
+        $busIds1 = $data['bus_ids1'] ? explode(',',$data['bus_ids1']) :[];
+        unset($data['bus_ids1']);
+
+        if($data['mode'] == 2 && !$busIds){
+            $this->error = '保洁类型不能为空';
+            return false;
+        }
+
+        if($data['mode'] == 3 && !$busIds1){
+            $this->error = '运送类型不能为空';
+            return false;
+        }
+
+        $id = $data['id'];
+        unset($data['id']);
+        Db::startTrans();
+        try {
+
+            if($id > 0){
+                if($data['mode'] == 2){
+                    $atable = 'cleaning_type b';
+                }else{
+                    $atable = 'convey_cate b';
+                }
+
+                $busIdsAll =  Db::name('mode_cate_type')
+                    ->where('mode',$data['mode'])
+                    ->where('cate_id','<>',$id)
+                    ->column('bus_id');
+
+                if($data['mode'] == 2){
+                    $intersectIds = array_intersect($busIds,$busIdsAll);
+                }else{
+                    $intersectIds = array_intersect($busIds1,$busIdsAll);
+                }
+
+                $cleaningTypeTitle = Db::name('mode_cate_type')
+                    ->alias('mct')
+                    ->join($atable,'b.id=mct.bus_id')
+                    ->where('mct.mode',$data['mode'])
+                    ->where('mct.bus_id','in',$intersectIds)
+                    ->column('b.title');
+
+                if($cleaningTypeTitle){
+                    $cleaningTypeTitles = $cleaningTypeTitle ? implode(',',$cleaningTypeTitle):'';
+                    $this->error = $cleaningTypeTitles.'已存在';
+                    return false;
+                }
+
+                Db::name('mode_cate_type')->where('mode',$data['mode'])->where('cate_id',$id)->delete();
+
+                if($busIds){
+                    $tat = [
+                        'cate_id'=>$id,
+                        'mode'=>$data['mode'],
+                        'create_time'=>getTime(),
+                    ];
+                    foreach ($busIds as $k=>$v){
+                        $tat['bus_id'] = $v;
+                        $add = Db::name('mode_cate_type')->insert($tat);
+                        if(!$add){
+                            $this->error = '操作失败1';
+                            return false;
+                        }
+                    }
+                }
+
+                if($busIds1){
+                    $tat = [
+                        'cate_id'=>$id,
+                        'mode'=>$data['mode'],
+                        'create_time'=>getTime(),
+                    ];
+                    foreach ($busIds1 as $k=>$v){
+                        $tat['bus_id'] = $v;
+                        $add = Db::name('mode_cate_type')->insert($tat);
+                        if(!$add){
+                            $this->error = '操作失败2';
+                            return false;
+                        }
+                    }
+                }
+                $ret = $this->allowField(true)->save($data,['id'=>$id]);
+
+                if(!$ret){
+                    $this->error = '修改失败';
+                    return false;
+                }
+            }else{
+                if($data['mode'] == 2){
+                  $atable = 'cleaning_type b';
+                }else{
+                    $atable = 'convey_cate b';
+                }
+                $cleaningTypeTitle = Db::name('mode_cate_type')
+                    ->alias('mct')
+                    ->join($atable,'b.id=mct.bus_id')
+                    ->where('mct.mode',$data['mode'])
+                    ->where('mct.bus_id','in',$busIds)
+                    ->column('b.title');
+                if($cleaningTypeTitle){
+                    $cleaningTypeTitles = $cleaningTypeTitle ? implode(',',$cleaningTypeTitle):'';
+                    $this->error = $cleaningTypeTitles.'已存在';
+                    return false;
+                }
+
+
+                $id = Db::name($this->table)->insertGetId($data);
+
+                if(!$id){
+                    $this->error = '操作失败';
+                    return false;
+                }
+                if($data['mode'] == 2 && $busIds){
+                    $dt = [
+                        'cate_id'=>$id,
+                        'mode'=>$data['mode'],
+                        'create_time'=>getTime(),
+                    ];
+                    foreach ($busIds as $k=>$v){
+                        $dt['bus_id'] = $v;
+                        $add = Db::name('mode_cate_type')->insert($dt);
+                        if(!$add){
+                            $this->error = '操作失败1';
+                            return false;
+                        }
+                    }
+                }
+
+                if($data['mode'] == 3 && $busIds1){
+                    $dt = [
+                        'cate_id'=>$id,
+                        'mode'=>$data['mode'],
+                        'create_time'=>getTime(),
+                    ];
+                    foreach ($busIds1 as $k=>$v){
+                        $dt['bus_id'] = $v;
+                        $add = Db::name('mode_cate_type')->insert($dt);
+                        if(!$add){
+                            $this->error = '操作失败1';
+                            return false;
+                        }
+                    }
+                }
+            }
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+
+            Db::rollback();
+            $this->error = $e->getMessage();
+            return false;
+        }
+
+    }
+
+}

+ 17 - 0
application/common/model/User.php

@@ -959,4 +959,21 @@ class User extends Model
         }
         return $arr;
     }
+
+    public function getWorkTypeModeUser($id,$orgId,$work=0){
+        $list = (new WorkTypeMode())->getRolesUser($id,$orgId,$work);
+        $arr = [];
+        foreach ($list as $k=>$v){
+            if(!empty($v['user'])){
+                foreach ($v['user'] as $k1=>$v1){
+                    $arr[] = [
+                        'id'=>$v1['id'],
+                        'title'=>$v1['real_name'],
+                    ];
+                }
+            }
+        }
+        return $arr;
+    }
 }
+

+ 49 - 0
application/common/validate/CleaningType.php

@@ -0,0 +1,49 @@
+<?php
+namespace app\common\validate;
+
+use think\Db;
+use think\Validate;
+
+class CleaningType extends Validate{
+
+    /**
+     * 定义验证规则
+     * 格式:'字段名' =>  ['规则1','规则2'...]
+     *
+     * @var array
+     */
+    protected $rule = [
+        'title|名称'  =>  'require|length:1,10|checkTitle',
+    ];
+
+    /**
+     * 定义错误信息R
+     * 格式:'字段名.规则名' =>  '错误信息'
+     *
+     * @var array
+     */
+    protected $message = [
+        'title.length' => '名称必须10字以内',
+    ];
+
+
+    protected  function checkTitle($value, $rule, $data=[]){
+        if(isset($data['id']) && $data['id'] > 0){
+            $ret = Db::name('cleaning_type')
+                ->where('del',0)
+                ->where('title',$data['title'])
+                ->where('id','<>',$data['id'])
+                ->where('org_id',$data['org_id'])
+                ->find();
+        }else{
+            $ret = Db::name('cleaning_type')
+                ->where('del',0)
+                ->where('title',$data['title'])
+                ->where('org_id',$data['org_id'])
+                ->find();
+        }
+
+        return $ret?'名称已被使用':true;
+    }
+
+}

+ 14 - 0
application/common/validate/ModeCate.php

@@ -0,0 +1,14 @@
+<?php
+namespace app\common\validate;
+
+use think\Validate;
+
+class ModeCate extends Validate{
+
+    protected $rule = [
+        'title|名称'  =>  'require|length:1,10',
+        'mode|类型'  =>  'require',
+    ];
+
+}
+

+ 22 - 1
config/app.php

@@ -220,7 +220,7 @@ return [
         ],
     ],
     //------微信公众号配置---------
-    'wx_config' => [
+  /*  'wx_config' => [
         'app_id' => 'wx2f0195c58ad8c3ec',
         'secret' => '29452e7ad4db9fb53ddc1a8ab66eca2a',
 
@@ -239,6 +239,27 @@ return [
             'level' => 'error',
             'file' => env('runtime_path').'/log/wechat.log',
         ],
+    ],*/
+
+    'wx_config' => [
+        'app_id' => 'wx98c5fd5111be3125',
+        'secret' => '0f6b3f1eb5198b0e89cff977d67c3740',
+
+        'mch_id' => '', // 商户号
+        'key' => '',   // API 密钥
+
+        // 如需使用敏感接口(如退款、发送红包等)需要配置 API 证书路径(登录商户平台下载 API 证书)
+        'cert_path' => env('root_path').'public/certs/apiclient_cert.pem',
+        'key_path' => env('root_path').'public/certs/apiclient_key.pem',
+
+        // 下面为可选项
+        // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名
+        'response_type' => 'array',
+
+        'log' => [
+            'level' => 'error',
+            'file' => env('runtime_path').'/log/wechat.log',
+        ],
     ],
 
     'weather_key'=>'125cc579816bceb875b413794c2b13d4',//获取聚合天气接口的key

BIN
public/logo.png