12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace app\bug\model;
- class Note extends Base
- {
- //设置字段信息
- protected $schema = [
- 'id' =>'int',//
- 'bugNo' =>'varchar',//编号
- 'noteNo' =>'varchar',//编号
- 'title' =>'varchar',//问题标题
- 'company_type' =>'varchar',//公司平台类别
- 'apply_name' =>'varchar',//创建人
- 'apply_id' =>'int',//创建人id
- 'model_id' =>'text',//模块分类id
- 'level' =>'int',//优先级
- 'type' =>'int',//问题类型
- 'weight' =>'int',//权重
- 'remark' =>'text',//描述
- 'submit' =>'int',//处理人提交0取消1提交
- 'status' =>'int',//处理状态
- 'is_del' =>'int',//是否删除
- 'addtime' =>'datetime',//添加时间
- 'updatetime' =>'datetime',//更新时间
- ];
- protected $createTime="addtime";
- protected $updateTime="updatetime";
- public static function onAfterWrite($model){
- $change= ["title","level","status","remark","noteNo","type","model_id"];
- $noteLog = new NoteLog();
- $origin = $model->getOrigin();
- $add=$model->getChangedData()??$model->toArray();
- $logAdd=[];
- foreach ($change as $key=>$value){
- $temp=[ 'bugNo' =>$model->bugNo,//编号
- 'type' =>isset($origin['id'])?2:1,//操作类型
- 'action_uid' =>$model->updaterid,//操作人id
- 'action_name' =>$model->updater,//操作人名称
- 'handle_name' =>$value,//操作字段
- 'action_item' =>$origin[$value]??"",//操作前值
- 'action_after' =>$add[$value],//操作后值
- ];
- if(isset($origin[$value])&&$origin[$value]!=$add[$value]){
- $logAdd[]=$temp;
- }
- if(!isset($origin['id'])){
- $logAdd[]=$temp;
- }
- }
- if(!empty($logAdd)){
- $noteLog->saveAll($logAdd);
- }
- }
- }
|