| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | 
							- <?php
 
- namespace app\common\model;
 
- use think\Db;
 
- class QualityGroup extends Base
 
- {
 
-     protected $createTime = 'create_time';
 
-     protected $updateTime = 'update_time';
 
-     public $table = 'quality_group';
 
-     protected $validateName = 'QualityGroup';
 
-     public function updates(){
 
-         $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;
 
-         }
 
-         $id = $data['id'];
 
-         unset($data['id']);
 
-         if($id > 0){
 
-             $data['update_time'] = date('Y-m-d H:i:s');
 
-             $ret = $this->allowField(true)->save($data,['id'=>$id]);
 
-         }else{
 
-             $data['create_time'] = date('Y-m-d H:i:s');
 
-             $ret = $this->allowField(true)->save($data);
 
-         }
 
-         if(!$ret){
 
-             $this->error = '操作失败';
 
-             return false;
 
-         }
 
-         return true;
 
-     }
 
-     /**
 
-      * 获取指定mode检查项
 
-      *
 
-      * @author wst
 
-      * @date   2021/9/7 15:15
 
-      * @return array
 
-      */
 
-     public function getByModeList(){
 
-         $list =$this
 
-             ->where('org_id',cur_org_id())
 
-             ->where('del',0)
 
-             ->where('enable',1)
 
-             ->select()
 
-             ->toArray();
 
-         return $list?$list:[];
 
-     }
 
-     public function getListByType($type,$orgId){
 
-         $ll = [];
 
-         if(in_array($type,[1,2,3,4,5])){
 
-             $ctype = $type;
 
-             if(in_array($type,[1,2,3,4])){
 
-                 $ctype = $type+2;
 
-             }
 
-             if($type == 5){
 
-                 $ctype = 10;
 
-             }
 
-             $lists = (new \app\common\model\Address())->getListByType($ctype,$orgId);
 
-             foreach ($lists as $k=>$v){
 
-                 $ll[] = [
 
-                     'id' => $v['id'],
 
-                     'title' => $v['title'],
 
-                     'sn' => $v['sn'],
 
-                     'qrcode' => get_qrcode_str('address',$v['id'])
 
-                 ];
 
-             }
 
-         }
 
- //        else if($type == 5){ // 日常工作
 
- //            $lists =  Db::name('daily')
 
- //                ->where('del',0)
 
- //                ->where('enable',1)
 
- //                ->where('org_id',$orgId)
 
- //                ->field('id,title')
 
- //                ->select();
 
- //            $lists = $lists?$lists:[];
 
- //            foreach ($lists as $k=>$v){
 
- //                $ll[] = [
 
- //                    'id' => $v['id'],
 
- //                    'title' => $v['title'],
 
- //                    'sn' => '',
 
- //                    'qrcode' => get_qrcode_str('daily',$v['id'])
 
- //                ];
 
- //            }
 
- //        }
 
-         else if($type == 6){ // 设备台账
 
-             $lists =  Db::name('device')
 
-                 ->where('del',0)
 
-                 ->where('enable',1)
 
-                 ->where('org_id',$orgId)
 
-                 ->field('id,title')
 
-                 ->select();
 
-             $lists = $lists?$lists:[];
 
-             foreach ($lists as $k=>$v){
 
-                 $ll[] = [
 
-                     'id' => $v['id'],
 
-                     'title' => $v['title'],
 
-                     'sn' => '',
 
-                     'qrcode' => get_qrcode_str('device',$v['id'])
 
-                 ];
 
-             }
 
-         }
 
-         return $ll?$ll:[];
 
-     }
 
- }
 
 
  |