Note.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace app\bug\model;
  3. class Note extends Base
  4. {
  5. //设置字段信息
  6. protected $schema = [
  7. 'id' =>'int',//
  8. 'bugNo' =>'varchar',//编号
  9. 'noteNo' =>'varchar',//编号
  10. 'title' =>'varchar',//问题标题
  11. 'company_type' =>'varchar',//公司平台类别
  12. 'apply_name' =>'varchar',//创建人
  13. 'apply_id' =>'int',//创建人id
  14. 'model_id' =>'text',//模块分类id
  15. 'level' =>'int',//优先级
  16. 'type' =>'int',//问题类型
  17. 'weight' =>'int',//权重
  18. 'remark' =>'text',//描述
  19. 'submit' =>'int',//处理人提交0取消1提交
  20. 'status' =>'int',//处理状态
  21. 'is_del' =>'int',//是否删除
  22. 'addtime' =>'datetime',//添加时间
  23. 'updatetime' =>'datetime',//更新时间
  24. ];
  25. protected $createTime="addtime";
  26. protected $updateTime="updatetime";
  27. public static function onAfterWrite($model){
  28. $change= ["title","level","status","remark","noteNo","type","model_id"];
  29. $noteLog = new NoteLog();
  30. $origin = $model->getOrigin();
  31. $add=$model->getChangedData()??$model->toArray();
  32. $logAdd=[];
  33. foreach ($change as $key=>$value){
  34. $temp=[ 'bugNo' =>$model->bugNo,//编号
  35. 'type' =>isset($origin['id'])?2:1,//操作类型
  36. 'action_uid' =>$model->updaterid,//操作人id
  37. 'action_name' =>$model->updater,//操作人名称
  38. 'handle_name' =>$value,//操作字段
  39. 'action_item' =>$origin[$value]??"",//操作前值
  40. 'action_after' =>$add[$value],//操作后值
  41. ];
  42. if(isset($origin[$value])&&$origin[$value]!=$add[$value]){
  43. $logAdd[]=$temp;
  44. }
  45. if(!isset($origin['id'])){
  46. $logAdd[]=$temp;
  47. }
  48. }
  49. if(!empty($logAdd)){
  50. $noteLog->saveAll($logAdd);
  51. }
  52. }
  53. }