DisinfectionDevice.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class DisinfectionDevice extends Base {
  5. protected $createTime = 'create_time';
  6. protected $updateTime = 'update_time';
  7. public $table = 'disinfection_device';
  8. protected $validateName = 'DisinfectionDevice';
  9. public function updates(){
  10. $data = request()->post();
  11. $data['org_id'] =cur_org_id();
  12. $result = validate($this->validateName)->check($data,[],'');
  13. if(true !== $result){
  14. $this->error = validate($this->validateName)->getError();
  15. return false;
  16. }
  17. // $data['img'] = isset($data['img'])?$data['img']:'';
  18. $id = $data['id'];
  19. unset($data['id']);
  20. if($id > 0){
  21. $data['update_time'] = date('Y-m-d H:i:s');
  22. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  23. }else{
  24. $data['create_time'] = date('Y-m-d H:i:s');
  25. $ret = $this->allowField(true)->save($data);
  26. }
  27. if(!$ret){
  28. $this->error = '操作失败';
  29. return false;
  30. }
  31. // $name = '任务工作项';
  32. // $content = $name.':新增';
  33. // if($id > 0){
  34. // $content = $name.':编辑';
  35. // $data['id'] = $id;
  36. // }else{
  37. // $data['id'] = $this->id;
  38. // }
  39. // model('ActionLog')->addlog(is_login(),27,$content,$data,cur_org_id());
  40. return true;
  41. }
  42. /**
  43. * 获取检查项列表
  44. *
  45. * @author wst
  46. * @date 2021/9/6 15:00
  47. * @return array
  48. */
  49. public function list(){
  50. $where['del']=0;
  51. $where['enable']=1;
  52. $where['org_id']=cur_org_id();
  53. $dailyForm=$this->field('id,content as title')->where($where)->select()->toArray();
  54. return $dailyForm;
  55. }
  56. /**
  57. * 根据id获取检查项列表
  58. *
  59. * @author wst
  60. * @date 2021/9/6 15:00
  61. * @return array
  62. */
  63. public function getByIdList($id){
  64. $dailyForm = Db::name('daily_form')
  65. ->where('enable',1)
  66. ->where('del',0)
  67. ->whereIn('id',explode(',',$id))
  68. ->select();
  69. $ids = [];
  70. foreach ($dailyForm as $k=>$v){
  71. $ids[$k]=(string)$v['id'];
  72. }
  73. return $ids;
  74. }
  75. }