49 changed files with 3539 additions and 37 deletions
@ -0,0 +1,291 @@ |
|||
//查看未参加考试人员 |
|||
public function looktakeexam(){ |
|||
$param_ary=$this->request->param(); |
|||
if(empty($param_ary['id'])) return '参数错误!不可访问'; |
|||
|
|||
$can_jia_people=examination::field('ex_id,ex_can_jia_people,ex_key,ex_range,ex_wsid,ex_wpid,ex_specified_range_us,ex_group')->where('ex_id',$param_ary['id'])->find(); |
|||
|
|||
$test_cj_peo=test_paper::distinct(true)->field('tp_u_key')->where(array('tp_exa_key'=>$can_jia_people['ex_key']))->select()->toArray(); |
|||
|
|||
if(!$can_jia_people) return '参数错误!不可访问'; |
|||
|
|||
|
|||
|
|||
// var_dump($can_jia_people); |
|||
|
|||
$canJiaPeopleAry= array(); |
|||
if(!empty($can_jia_people['ex_can_jia_people'])) $canJiaPeopleAry= json_decode($can_jia_people['ex_can_jia_people'],true); |
|||
|
|||
if(!empty($test_cj_peo)){ |
|||
$cj_ren=array(); |
|||
foreach($test_cj_peo as $key=>$val){ |
|||
$cj_ren[]=$val['tp_u_key']; |
|||
} |
|||
$canJiaPeopleAry=$cj_ren; |
|||
} |
|||
//划定考试人员 |
|||
$hua_ding_user=array(); |
|||
if(!empty($can_jia_people['ex_specified_range_us'])) $hua_ding_user= $this->get_user_key(explode(',',$can_jia_people['ex_specified_range_us'])); |
|||
|
|||
//划定人员分组 |
|||
$hua_ding_fenzu=array(); |
|||
if(!empty($hua_ding_user)){ |
|||
foreach($hua_ding_user as $hdu_key => $hdu_val){ |
|||
$hua_ding_fenzu[$this->get_workman_bf(array('wm_key'=>$hdu_val))][]=$hdu_val; |
|||
} |
|||
} |
|||
// $hebing_cjrs=array_merge($can_jia_people,$test_cj_peo); |
|||
// var_dump($canJiaPeopleAry); |
|||
|
|||
|
|||
$ret_data = array(); |
|||
$ret_wei_data=array(); |
|||
|
|||
if($this->session_val['bf_id'] == 0){ |
|||
// echo 1; |
|||
// echo "<hr>"; |
|||
$exam_bf_ary = explode(',',$can_jia_people['ex_range']); |
|||
|
|||
|
|||
if(count($exam_bf_ary) > 1){ |
|||
// echo 2; |
|||
// var_dump($exam_bf_ary); |
|||
// echo "<hr>"; |
|||
foreach($exam_bf_ary as $bf_key => $bf_val){ |
|||
$bf_name=branch_factory::field('bf_name')->where('bf_id',$bf_val)->find(); |
|||
$ret_data['date_val'][]=$bf_name['bf_name']; |
|||
$wei_can_jia=array(); |
|||
if(!empty($hua_ding_fenzu)){ |
|||
foreach($hua_ding_fenzu[$bf_val] as $hdf_key => $hdf_val){ |
|||
|
|||
if(!in_array($hdf_val,$canJiaPeopleAry)){ |
|||
$wei_can_jia[]=array( |
|||
'wm_number' => select_worker_man(array('wm_key'=>$hdf_val),'wm_number'), |
|||
'wmd_name' => select_worker_man_data(array('wmd_key'=>$hdf_val),'wmd_name'), |
|||
); |
|||
} |
|||
} |
|||
}else{ |
|||
$user_ary=$this->get_people_cont($bf_val,$can_jia_people['ex_wsid'],$can_jia_people['ex_wpid']); |
|||
// $ret_wei_data=$user_ary; |
|||
|
|||
if(!empty($user_ary)){ |
|||
foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
$wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
$ret_wei_data[]=array( |
|||
'title'=>$bf_name['bf_name'], |
|||
'datalist'=>$wei_can_jia |
|||
); |
|||
} |
|||
}else{ |
|||
// echo 3; |
|||
// echo "<hr>"; |
|||
if($can_jia_people['ex_range'] != -1 && $can_jia_people['ex_range'] != -2 && $this->session_val['u_private'] != 2){ |
|||
// echo 4; |
|||
// echo "<hr>"; |
|||
$bf_name=branch_factory::field('bf_name')->where('bf_id',$can_jia_people['ex_range'])->find(); |
|||
$ret_data['date_val'][]=$bf_name['bf_name']; |
|||
|
|||
$user_ary=$this->get_people_cont($can_jia_people['ex_range'],$can_jia_people['ex_wsid'],$can_jia_people['ex_wpid']); |
|||
// $ret_wei_data=$user_ary; |
|||
$wei_can_jia=array(); |
|||
if(!empty($user_ary)){ |
|||
foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
$wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
} |
|||
} |
|||
} |
|||
$ret_wei_data[]=array( |
|||
'title'=>$bf_name['bf_name'], |
|||
'datalist'=>$wei_can_jia |
|||
); |
|||
// echo $can_jia_people['ex_range'].'====>'.$can_jia_people['ex_wsid'].'====>'.$can_jia_people['ex_wpid'].'====>'.$param_ary['id']; |
|||
}else{ |
|||
|
|||
|
|||
|
|||
|
|||
// $list=test_paper::distinct(true)->field('tp_bf_id')->where(array('tp_exa_key'=>$can_jia_people['ex_key']))->where('tp_bf_id','<>',9)->select()->toArray(); |
|||
|
|||
// foreach($list as $key => $val){ |
|||
// $bf_name=branch_factory::field('bf_name')->where('bf_id',$val['tp_bf_id'])->find(); |
|||
// $ret_data['date_val'][]=$bf_name['bf_name']; |
|||
|
|||
// $user_ary=$this->get_people_cont($val['tp_bf_id']); |
|||
// // $ret_wei_data=$user_ary; |
|||
// $wei_can_jia=array(); |
|||
// if(!empty($user_ary)){ |
|||
// foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
// if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// // $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
// $wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
// } |
|||
// } |
|||
// } |
|||
// $ret_wei_data[$key]=array( |
|||
// 'title'=>$bf_name['bf_name'], |
|||
// 'datalist'=>$wei_can_jia |
|||
// ); |
|||
|
|||
|
|||
// } |
|||
|
|||
//改版 |
|||
// echo 5; |
|||
// echo "<hr>"; |
|||
$BF_wher=array( |
|||
['bf_set','=',1], |
|||
['bf_group','=',$can_jia_people['ex_group']] |
|||
); |
|||
$deparAry = branch_factory::field('bf_id,bf_name')->where($BF_wher)->select(); |
|||
foreach($deparAry as $dep_key => $dep_val){ |
|||
$ret_data['date_val'][]=$dep_val['bf_name']; |
|||
|
|||
$user_ary=$this->get_people_cont($dep_val['bf_id']); |
|||
|
|||
$wei_can_jia=array(); |
|||
if(!empty($user_ary)){ |
|||
foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
$wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
$ret_wei_data[$dep_key]=array( |
|||
'title'=>$dep_val['bf_name'], |
|||
'datalist'=>$wei_can_jia |
|||
); |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
|
|||
|
|||
$ceyan = 1; |
|||
}else{ |
|||
if($this->session_val['u_private'] == 2){ |
|||
echo 6; |
|||
echo "<hr>"; |
|||
$list=test_paper::distinct(true)->field('tp_bf_id')->where(array('tp_exa_key'=>$can_jia_people['ex_key']))->where('tp_bf_id','<>',9)->select()->toArray(); |
|||
|
|||
foreach($list as $key => $val){ |
|||
$bf_name=branch_factory::field('bf_name')->where('bf_id',$val['tp_bf_id'])->find(); |
|||
$ret_data['date_val'][]=$bf_name['bf_name']; |
|||
|
|||
// $user_ary=$this->get_people_cont($val['tp_bf_id']); |
|||
// // $ret_wei_data=$user_ary; |
|||
// $wei_can_jia=array(); |
|||
// if(!empty($user_ary)){ |
|||
// foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
// if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// // $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
// $wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
// } |
|||
// } |
|||
// } |
|||
// $ret_wei_data[$key]=array( |
|||
// 'title'=>$bf_name['bf_name'], |
|||
// 'datalist'=>$wei_can_jia |
|||
// ); |
|||
|
|||
|
|||
$wei_can_jia=array(); |
|||
if(!empty($hua_ding_fenzu)){ |
|||
foreach($hua_ding_fenzu[$val['tp_bf_id']] as $hdf_key => $hdf_val){ |
|||
|
|||
if(!in_array($hdf_val,$canJiaPeopleAry)){ |
|||
$wei_can_jia[]=array( |
|||
'wm_number' => select_worker_man(array('wm_key'=>$hdf_val),'wm_number'), |
|||
'wmd_name' => select_worker_man_data(array('wmd_key'=>$hdf_val),'wmd_name'), |
|||
); |
|||
} |
|||
} |
|||
}else{ |
|||
$user_ary=$this->get_people_cont($val['tp_bf_id'],$can_jia_people['ex_wsid'],$can_jia_people['ex_wpid']); |
|||
// $ret_wei_data=$user_ary; |
|||
|
|||
if(!empty($user_ary)){ |
|||
foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
$wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
$ret_wei_data[]=array( |
|||
'title'=>$bf_name['bf_name'], |
|||
'datalist'=>$wei_can_jia |
|||
); |
|||
|
|||
|
|||
} |
|||
$ceyan = 1; |
|||
}else{ |
|||
echo 7; |
|||
echo "<hr>"; |
|||
$ws_array=work_shopsection::field('ws_id,ws_name')->where(array('ws_bf_id'=>$this->session_val['bf_id'],'ws_set'=>1))->select(); |
|||
|
|||
$us_kkk =array(); |
|||
|
|||
foreach($ws_array as $ws_key => $ws_val){ |
|||
$ret_data['date_val'][]=$ws_val['ws_name']; |
|||
|
|||
$user_ary=$this->get_people_cont($this->session_val['bf_id'],$ws_val['ws_id']); |
|||
|
|||
$us_kkk[] = $user_ary; |
|||
$wei_can_jia=array(); |
|||
if(!empty($user_ary)){ |
|||
foreach($user_ary['us_key'] as $us_key => $us_val){ |
|||
if(!in_array($us_val,$canJiaPeopleAry)){ |
|||
// $ret_wei_data[$bf_name['bf_name']][]=$user_ary['us_list'][$us_val]; |
|||
$wei_can_jia[]=$user_ary['us_list'][$us_val]; |
|||
} |
|||
} |
|||
} |
|||
|
|||
$ret_wei_data[$ws_key]=array( |
|||
'title'=>$ws_val['ws_name'], |
|||
'datalist'=>$wei_can_jia |
|||
); |
|||
|
|||
// $sum_ping=$this->sum_fenshu_ws($ws_val['ws_id'],$param_ary['id']); |
|||
|
|||
// $sum_fenshu[$ws_key]=$sum_ping['sum_val']; |
|||
// $ping_junfen[$ws_key]=$sum_ping['ping']; |
|||
// $he_ge_lv[$ws_key]=$this->he_ge_lv_ws($ws_val['ws_id'],$param_ary['id']); |
|||
} |
|||
$ceyan = 2; |
|||
|
|||
// var_dump($us_kkk); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
// var_dump($ret_data); |
|||
// return $this->jsonecho(array($ret_data,$ret_wei_data),1,'数据读取成功!'); |
|||
// return $this->jsonecho($ret_wei_data,1,'数据读取成功!'); |
|||
View::assign('ex_id',$param_ary['id']); |
|||
View::assign('list',$ret_wei_data); |
|||
return View::fetch(); |
|||
|
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
package assessment |
|||
|
|||
import "github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
|
|||
//考核
|
|||
type Assessment struct{} |
|||
|
|||
//列表参数
|
|||
type getAssEssList struct { |
|||
commonus.PageSetLimt |
|||
BranchFactoryId int `json:"branchFactoryId"` |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package assessment |
|||
|
|||
type ApiGroup struct { |
|||
Assessment |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
package index |
|||
|
|||
import "github.com/flipped-aurora/gin-vue-admin/server/api/index/assessment" |
|||
|
|||
type ApiGroup struct { |
|||
AssessMentApi assessment.ApiGroup |
|||
} |
|||
|
|||
var ApiGroupApp = new(ApiGroup) |
|||
@ -0,0 +1,268 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//考核项目
|
|||
|
|||
func (d *DutyHandle) AssEssList(c *gin.Context) { |
|||
var requestData assessRequest |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(101, err, "参数错误!请重新提交!", c)
|
|||
// return
|
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
// var assessList assessmentmodel.AssessMentitems
|
|||
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.AssessMentitems{}) |
|||
if requestData.ParentId != 0 { |
|||
gormDb = gormDb.Where("`ai_parent` = ?", requestData.ParentId) |
|||
} |
|||
if requestData.Title != "" { |
|||
gormDb = gormDb.Where("ai_title LIKE ?", "%"+requestData.Title+"%") |
|||
} |
|||
|
|||
if requestData.State != 0 { |
|||
gormDb = gormDb.Where("`ai_state` = ?", requestData.State) |
|||
} else { |
|||
gormDb = gormDb.Where("`ai_state` IN ?", []int{1, 2}) |
|||
} |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
var assessList []assessmentmodel.AssessMentitems |
|||
assessListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Find(&assessList).Error |
|||
if assessListerr != nil { |
|||
response.Result(103, assessListerr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
var assessOutMap []assessOutput |
|||
for _, val := range assessList { |
|||
var assessOutInfo assessOutput |
|||
assessOutInfo.Id = val.Id |
|||
assessOutInfo.Title = val.Title |
|||
assessOutInfo.Weight = val.Weight |
|||
assessOutInfo.Fraction = val.Fraction |
|||
assessOutInfo.Content = val.Content |
|||
assessOutInfo.PartId = val.PartId |
|||
assessOutInfo.Time = val.Time |
|||
assessOutInfo.State = val.State |
|||
assessOutInfo.OutId = strconv.FormatInt(val.Id, 10) |
|||
assessOutInfo.ParentIdStr = strconv.FormatInt(val.PartId, 10) |
|||
|
|||
isTrue, parentCont := GetDutyClassCont(val.PartId) |
|||
if isTrue == true { |
|||
assessOutInfo.ParentTitle = parentCont.Title |
|||
} |
|||
|
|||
assessOutMap = append(assessOutMap, assessOutInfo) |
|||
} |
|||
countSum := len(assessOutMap) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, assessOutMap) |
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//添加考核项目
|
|||
func (d *DutyHandle) AddAssEssInfo(c *gin.Context) { |
|||
var requestData addAssEssInfo |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(102, err, "请输入考核项目名称", c) |
|||
return |
|||
} |
|||
if requestData.ParentId == "" { |
|||
response.Result(103, err, "请指定该考核项目归属于职责分类", c) |
|||
return |
|||
} |
|||
var assessInfo assessmentmodel.AssessMentitems |
|||
assessInfo.Id = commonus.GetFileNumberEs() |
|||
assessInfo.Title = requestData.Title |
|||
assessInfo.Weight = 0 |
|||
assessInfo.Fraction = 0 |
|||
assessInfo.Content = requestData.Content |
|||
partIdInt, partIdIntErr := strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
if partIdIntErr == nil { |
|||
assessInfo.PartId = partIdInt |
|||
} else { |
|||
assessInfo.PartId = 0 |
|||
} |
|||
assessInfo.Time = time.Now().Unix() |
|||
assessInfo.State = 1 |
|||
addassessInfoErr := global.GVA_DB_Performanceappraisal.Create(&assessInfo).Error |
|||
if addassessInfoErr != nil { |
|||
response.Result(104, assessInfo, "数据写入失败!", c) |
|||
} else { |
|||
response.Result(0, assessInfo, "数据写入成功!", c) |
|||
} |
|||
} |
|||
|
|||
//获取考核项目详细内容
|
|||
func (d *DutyHandle) GetAssEssInfo(c *gin.Context) { |
|||
var requestData commonus.SetId |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
var assessOutInfo assessOutput |
|||
inFoErr := global.GVA_DB_Performanceappraisal.Where("`ai_id` = ?", requestData.Id).First(&assessOutInfo).Error |
|||
assessOutInfo.OutId = strconv.FormatInt(assessOutInfo.Id, 10) |
|||
|
|||
assessOutInfo.ParentIdStr = strconv.FormatInt(assessOutInfo.PartId, 10) |
|||
isTrue, parentCont := GetDutyClassCont(assessOutInfo.PartId) |
|||
if isTrue == true { |
|||
assessOutInfo.ParentTitle = parentCont.Title |
|||
} |
|||
if inFoErr != nil { |
|||
response.Result(103, inFoErr, "数据查询失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, assessOutInfo, "数据查询成功!", c) |
|||
|
|||
} |
|||
|
|||
//修改考核项目内容
|
|||
func (d *DutyHandle) EiteAssEssInfo(c *gin.Context) { |
|||
var requestData eiteAssEssCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
saveData := commonus.MapOut() |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(103, err, "请输入考核项目名称", c) |
|||
return |
|||
} |
|||
if requestData.ParentId != "" { |
|||
parentIdInt, parentErr := strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
if parentErr == nil { |
|||
saveData["ai_parent"] = parentIdInt |
|||
} |
|||
|
|||
} |
|||
if requestData.Content != "" { |
|||
saveData["ai_content"] = requestData.Content |
|||
} |
|||
var assessInfo assessmentmodel.AssessMentitems |
|||
saveData["ai_title"] = requestData.Title |
|||
saveData["ai_time"] = time.Now().Unix() |
|||
isTrue, isErr := eiteAssEssInfoCont(requestData.Id, assessInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(104, isErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, saveData, "修改成功!", c) |
|||
} |
|||
|
|||
//考核项目编辑操作
|
|||
func eiteAssEssInfoCont(saveId int64, modelInfo assessmentmodel.AssessMentitems, saveData map[string]interface{}) (isTrue bool, dutyClassInfoErr error) { |
|||
isTrue = false |
|||
dutyClassInfoErr = global.GVA_DB_Performanceappraisal.Model(&modelInfo).Where("ai_id = ?", saveId).Updates(saveData).Error |
|||
if dutyClassInfoErr != nil { |
|||
return |
|||
} |
|||
isTrue = true |
|||
return |
|||
} |
|||
|
|||
//修改考核项目的状态
|
|||
func (d *DutyHandle) EiteAssEssState(c *gin.Context) { |
|||
var requestData dutyClassState |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
saveData := commonus.MapOut() |
|||
saveData["ai_state"] = requestData.State |
|||
saveData["ai_time"] = time.Now().Unix() |
|||
var eiteAssEssStateInfo assessmentmodel.AssessMentitems |
|||
if requestData.IsDel != 1 { |
|||
isTrue, dutyErr := eiteAssEssInfoCont(requestData.Id, eiteAssEssStateInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(103, dutyErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} else { |
|||
if requestData.State == 3 { |
|||
archiveInfoErr := global.GVA_DB_Performanceappraisal.Where("ai_id = ?", requestData.Id).Delete(&eiteAssEssStateInfo).Error |
|||
if archiveInfoErr != nil { |
|||
response.Result(104, requestData, "删除失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "删除成功!", c) |
|||
} else { |
|||
isTrue, saveErr := eiteAssEssInfoCont(requestData.Id, eiteAssEssStateInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(105, saveErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} |
|||
} |
|||
} |
|||
|
|||
//获取职责类别内容
|
|||
func GetAssEssCont(id int64) (isTrue bool, ContInfo assessmentmodel.AssessMentitems) { |
|||
isTrue = false |
|||
err := global.GVA_DB_Performanceappraisal.Where("ai_id = ?", id).First(&ContInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
@ -0,0 +1,243 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//入口
|
|||
func (d *DutyHandle) Index(c *gin.Context) { |
|||
outPut := commonus.MapOut() |
|||
response.Result(0, outPut, "获取成功", c) |
|||
} |
|||
|
|||
//职责类别列表
|
|||
func (d *DutyHandle) DutyClassList(c *gin.Context) { |
|||
var requestData dutyClassRequest |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(101, err, "参数错误!请重新提交!", c)
|
|||
// return
|
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
var total int64 //获取所有数据
|
|||
//条件
|
|||
whereMap := commonus.MapOut() |
|||
if requestData.State != 0 { |
|||
whereMap["state"] = requestData.State |
|||
} |
|||
var dutyClassAry []assessmentmodel.DutyClass |
|||
if requestData.Title != "" { |
|||
listTitleErr := global.GVA_DB_Performanceappraisal.Where(whereMap).Where("`title` LIKE '%"+requestData.Title+"%' AND `state` IN ?", []int{1, 2}).Order("id DESC").Limit(requestData.PageSize).Offset(offSetPage).Find(&dutyClassAry).Error |
|||
if listTitleErr != nil { |
|||
response.Result(103, listTitleErr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
counrErr := global.GVA_DB_Performanceappraisal.Model(&dutyClassAry).Where(whereMap).Where("`title` LIKE '%"+requestData.Title+"%' AND `state` IN ?", []int{1, 2}).Count(&total).Error |
|||
if counrErr != nil { |
|||
total = 0 |
|||
} |
|||
} else { |
|||
listTitleErr := global.GVA_DB_Performanceappraisal.Where(whereMap).Where("`state` IN ?", []int{1, 2}).Order("id DESC").Limit(requestData.PageSize).Offset(offSetPage).Find(&dutyClassAry).Error |
|||
if listTitleErr != nil { |
|||
response.Result(103, listTitleErr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
counrErr := global.GVA_DB_Performanceappraisal.Model(&dutyClassAry).Where(whereMap).Where("`state` IN ?", []int{1, 2}).Count(&total).Error |
|||
if counrErr != nil { |
|||
total = 0 |
|||
} |
|||
} |
|||
var dutyClassOutputAry []dutyClassOutput |
|||
for _, val := range dutyClassAry { |
|||
var dutyClassCont dutyClassOutput |
|||
dutyClassCont.Id = val.Id |
|||
dutyClassCont.Title = val.Title |
|||
dutyClassCont.Type = val.Type |
|||
dutyClassCont.Weight = val.Weight |
|||
dutyClassCont.Time = val.Time |
|||
dutyClassCont.State = val.State |
|||
dutyClassCont.OutId = strconv.FormatInt(val.Id, 10) |
|||
dutyClassOutputAry = append(dutyClassOutputAry, dutyClassCont) |
|||
} |
|||
countSum := len(dutyClassOutputAry) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, dutyClassOutputAry) |
|||
// fmt.Printf("%v\n", printData)
|
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//添加职责类别
|
|||
func (d *DutyHandle) AddDutyClass(c *gin.Context) { |
|||
var requestData dutyClassAdd |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(102, err, "请输入职责名称", c) |
|||
return |
|||
} |
|||
var dutyClassCont assessmentmodel.DutyClass |
|||
dutyClassCont.Id = commonus.GetFileNumberEs() |
|||
dutyClassCont.Title = requestData.Title |
|||
dutyClassCont.Type = 1 |
|||
dutyClassCont.Weight = 0 |
|||
dutyClassCont.State = 1 |
|||
dutyClassCont.Time = time.Now().Unix() |
|||
|
|||
addArchiveFileErr := global.GVA_DB_Performanceappraisal.Create(&dutyClassCont).Error |
|||
if addArchiveFileErr != nil { |
|||
response.Result(108, dutyClassCont, "数据写入失败!", c) |
|||
} else { |
|||
response.Result(0, dutyClassCont, "数据写入成功!", c) |
|||
} |
|||
} |
|||
|
|||
//查看职责类别详情
|
|||
func (d *DutyHandle) GetDutyClassInfo(c *gin.Context) { |
|||
var requestData commonus.SetId |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
var dutyClassCont assessmentmodel.DutyClass |
|||
inFoErr := global.GVA_DB_Performanceappraisal.Where("`id` = ?", requestData.Id).First(&dutyClassCont).Error |
|||
if inFoErr != nil { |
|||
response.Result(103, inFoErr, "数据查询失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, dutyClassCont, "数据查询成功!", c) |
|||
} |
|||
|
|||
//修改职责类别内容
|
|||
func (d *DutyHandle) EiteDutyClassInfo(c *gin.Context) { |
|||
var requestData dutyClassEite |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(103, err, "请输入职责名称", c) |
|||
return |
|||
} |
|||
//软处理
|
|||
saveData := commonus.MapOut() |
|||
saveData["title"] = requestData.Title |
|||
saveData["time"] = time.Now().Unix() |
|||
|
|||
var eiteDutyClass assessmentmodel.DutyClass |
|||
inFoErr := global.GVA_DB_Performanceappraisal.Model(&eiteDutyClass).Where("`id` = ?", requestData.Id).Updates(saveData).Error |
|||
if inFoErr != nil { |
|||
response.Result(104, inFoErr, "数据编辑失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, eiteDutyClass, "数据编辑成功!", c) |
|||
} |
|||
|
|||
//状态变更及删除
|
|||
func (d *DutyHandle) StateDutyClass(c *gin.Context) { |
|||
var requestData dutyClassState |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
var eiteDutyClass assessmentmodel.DutyClass |
|||
if requestData.IsDel != 1 { |
|||
isTrue, dutyErr := dutyInfoStateSet(eiteDutyClass, requestData) |
|||
if isTrue != true { |
|||
response.Result(103, dutyErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} else { |
|||
if requestData.State == 3 { |
|||
archiveInfoErr := global.GVA_DB_Performanceappraisal.Where("at_id = ?", requestData.Id).Delete(&eiteDutyClass).Error |
|||
if archiveInfoErr != nil { |
|||
response.Result(104, requestData, "删除失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "删除成功!", c) |
|||
} else { |
|||
isTrue, saveErr := dutyInfoStateSet(eiteDutyClass, requestData) |
|||
if isTrue != true { |
|||
response.Result(105, saveErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} |
|||
} |
|||
} |
|||
|
|||
//状态软操作
|
|||
func dutyInfoStateSet(dutyClassInfo assessmentmodel.DutyClass, arrData dutyClassState) (isTrue bool, dutyClassInfoErr error) { |
|||
isTrue = false |
|||
//软处理
|
|||
saveData := commonus.MapOut() |
|||
saveData["state"] = arrData.State |
|||
saveData["time"] = time.Now().Unix() |
|||
dutyClassInfoErr = global.GVA_DB_Performanceappraisal.Model(&dutyClassInfo).Where("id = ?", arrData.Id).Updates(saveData).Error |
|||
if dutyClassInfoErr != nil { |
|||
return |
|||
} |
|||
isTrue = true |
|||
return |
|||
} |
|||
|
|||
//获取职责类别内容
|
|||
func GetDutyClassCont(id int64) (isTrue bool, ContInfo assessmentmodel.DutyClass) { |
|||
isTrue = false |
|||
err := global.GVA_DB_Performanceappraisal.Where("id = ?", id).First(&ContInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
@ -0,0 +1,319 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//具体职责
|
|||
func (d *DutyHandle) DutyList(c *gin.Context) { |
|||
var requestData dutyRequest |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(101, err, "参数错误!请重新提交!", c)
|
|||
// return
|
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DutyContent{}) |
|||
if requestData.ParentId != 0 { |
|||
gormDb = gormDb.Where("`dc_parent` = ?", requestData.ParentId) |
|||
} |
|||
if requestData.Title != "" { |
|||
gormDb = gormDb.Where("dc_title LIKE ?", "%"+requestData.Title+"%") |
|||
} |
|||
|
|||
if requestData.State != 0 { |
|||
gormDb = gormDb.Where("`dc_state` = ?", requestData.State) |
|||
} else { |
|||
gormDb = gormDb.Where("`dc_state` IN ?", []int{1, 2}) |
|||
} |
|||
|
|||
if requestData.AssEssType != 0 { |
|||
gormDb = gormDb.Where("`dc_user_type` = ?", requestData.AssEssType) |
|||
if requestData.AssEssUserId != "" { |
|||
assessUserId, assessErr := strconv.ParseInt(requestData.AssEssUserId, 10, 64) |
|||
if assessErr == nil { |
|||
if requestData.AssEssType == 1 { |
|||
gormDb = gormDb.Where("`dc_user_dump` = ?", assessUserId) |
|||
} else { |
|||
gormDb = gormDb.Where("`dc_dump` = ?", assessUserId) |
|||
} |
|||
} |
|||
} |
|||
} else { |
|||
if requestData.AssEssUserId != "" { |
|||
assessUserId, assessErr := strconv.ParseInt(requestData.AssEssUserId, 10, 64) |
|||
if assessErr == nil { |
|||
if requestData.AssEssType == 1 { |
|||
gormDb = gormDb.Where("`dc_user_dump` = ?", assessUserId) |
|||
} else { |
|||
gormDb = gormDb.Where("`dc_dump` = ?", assessUserId) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
|
|||
var dutyList []assessmentmodel.DutyContent |
|||
dutyListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Find(&dutyList).Error |
|||
if dutyListerr != nil { |
|||
response.Result(103, dutyListerr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
var outDutyMap []dutyOutput |
|||
for _, val := range dutyList { |
|||
var outDutyInfo dutyOutput |
|||
outDutyInfo.Id = val.Id |
|||
outDutyInfo.Title = val.Title |
|||
outDutyInfo.Time = val.Time |
|||
outDutyInfo.State = val.State |
|||
outDutyInfo.PartId = val.PartId |
|||
outDutyInfo.UserType = val.UserType |
|||
outDutyInfo.UserDump = val.UserDump |
|||
outDutyInfo.Dump = val.Dump |
|||
outDutyInfo.OutId = strconv.FormatInt(outDutyInfo.Id, 10) |
|||
|
|||
outDutyInfo.ParentIdStr = strconv.FormatInt(val.PartId, 10) |
|||
isTrue, parentCont := GetAssEssCont(val.PartId) |
|||
if isTrue == true { |
|||
outDutyInfo.ParentTitle = parentCont.Title |
|||
} |
|||
|
|||
outDutyMap = append(outDutyMap, outDutyInfo) |
|||
} |
|||
countSum := len(outDutyMap) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, outDutyMap) |
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//添加具体职责
|
|||
func (d *DutyHandle) AddDutyInfo(c *gin.Context) { |
|||
var requestData addDutyContent |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(102, err, "请输入具体职责名称", c) |
|||
return |
|||
} |
|||
if requestData.ParentId == "" { |
|||
response.Result(103, err, "请指定该具体归属于职责项目", c) |
|||
return |
|||
} |
|||
if requestData.UserId == "" { |
|||
response.Result(103, err, "请指定该具体职责执行人或执行部门", c) |
|||
return |
|||
} |
|||
if requestData.Type == 0 { |
|||
requestData.Type = 1 |
|||
} |
|||
var dutyInfo assessmentmodel.DutyContent |
|||
dutyInfo.Id = commonus.GetFileNumberEs() |
|||
dutyInfo.Title = requestData.Title |
|||
dutyInfo.Time = time.Now().Unix() |
|||
dutyInfo.State = 1 |
|||
parentId, parentIdErr := strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
if parentIdErr == nil { |
|||
dutyInfo.PartId = parentId |
|||
} else { |
|||
dutyInfo.PartId = 0 |
|||
} |
|||
userID, userIDErr := strconv.ParseInt(requestData.UserId, 10, 64) |
|||
if userIDErr != nil { |
|||
userID = 0 |
|||
} |
|||
dutyInfo.UserType = requestData.Type |
|||
if requestData.Type == 1 { |
|||
dutyInfo.UserDump = userID |
|||
dutyInfo.Dump = 0 |
|||
} else { |
|||
dutyInfo.UserDump = 0 |
|||
dutyInfo.Dump = userID |
|||
} |
|||
dutyInfoErr := global.GVA_DB_Performanceappraisal.Create(&dutyInfo).Error |
|||
if dutyInfoErr != nil { |
|||
response.Result(104, dutyInfo, "数据写入失败!", c) |
|||
} else { |
|||
response.Result(0, dutyInfo, "数据写入成功!", c) |
|||
} |
|||
} |
|||
|
|||
//获取具体职责
|
|||
func (d *DutyHandle) GetDutyInfo(c *gin.Context) { |
|||
var requestData commonus.SetId |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
var dutyOutInfo dutyOutput |
|||
inFoErr := global.GVA_DB_Performanceappraisal.Where("`dc_id` = ?", requestData.Id).First(&dutyOutInfo).Error |
|||
dutyOutInfo.OutId = strconv.FormatInt(dutyOutInfo.Id, 10) |
|||
dutyOutInfo.ParentIdStr = strconv.FormatInt(dutyOutInfo.PartId, 10) |
|||
isTrue, parentCont := GetAssEssCont(dutyOutInfo.PartId) |
|||
if isTrue == true { |
|||
dutyOutInfo.ParentTitle = parentCont.Title |
|||
} |
|||
if inFoErr != nil { |
|||
response.Result(103, inFoErr, "数据查询失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, dutyOutInfo, "数据查询成功!", c) |
|||
} |
|||
|
|||
//编辑具体职责
|
|||
func (d *DutyHandle) EiteDutyInfor(c *gin.Context) { |
|||
var requestData eiteDutyCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
saveData := commonus.MapOut() |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.Title == "" { |
|||
response.Result(103, err, "请输入具体职责", c) |
|||
return |
|||
} |
|||
if requestData.ParentId != "" { |
|||
parentIdInt, parentErr := strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
if parentErr == nil { |
|||
saveData["dc_parent"] = parentIdInt |
|||
} |
|||
} |
|||
if requestData.Type != 0 { |
|||
saveData["dc_user_type"] = requestData.Type |
|||
if requestData.UserId != "" { |
|||
userID, userIDErr := strconv.ParseInt(requestData.UserId, 10, 64) |
|||
if userIDErr != nil { |
|||
userID = 0 |
|||
} |
|||
if requestData.Type == 1 { |
|||
saveData["dc_user_dump"] = userID |
|||
saveData["dc_dump"] = 0 |
|||
} else { |
|||
saveData["dc_user_dump"] = 0 |
|||
saveData["dc_dump"] = userID |
|||
} |
|||
} |
|||
} |
|||
var assessInfo assessmentmodel.DutyContent |
|||
saveData["dc_title"] = requestData.Title |
|||
saveData["dc_time"] = time.Now().Unix() |
|||
isTrue, isErr := eiteDutyInfoCont(requestData.Id, assessInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(104, isErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, saveData, "修改成功!", c) |
|||
} |
|||
|
|||
//编辑具体职责内容
|
|||
func eiteDutyInfoCont(saveId int64, modelInfo assessmentmodel.DutyContent, saveData map[string]interface{}) (isTrue bool, dutyClassInfoErr error) { |
|||
isTrue = false |
|||
dutyClassInfoErr = global.GVA_DB_Performanceappraisal.Model(&modelInfo).Where("dc_id = ?", saveId).Updates(saveData).Error |
|||
if dutyClassInfoErr != nil { |
|||
return |
|||
} |
|||
isTrue = true |
|||
return |
|||
} |
|||
|
|||
//修改考核项目的状态
|
|||
func (d *DutyHandle) EiteDutyState(c *gin.Context) { |
|||
var requestData dutyClassState |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
saveData := commonus.MapOut() |
|||
saveData["dc_state"] = requestData.State |
|||
saveData["dc_time"] = time.Now().Unix() |
|||
var eiteAssEssStateInfo assessmentmodel.DutyContent |
|||
if requestData.IsDel != 1 { |
|||
isTrue, dutyErr := eiteDutyInfoCont(requestData.Id, eiteAssEssStateInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(103, dutyErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} else { |
|||
if requestData.State == 3 { |
|||
archiveInfoErr := global.GVA_DB_Performanceappraisal.Where("ai_id = ?", requestData.Id).Delete(&eiteAssEssStateInfo).Error |
|||
if archiveInfoErr != nil { |
|||
response.Result(104, requestData, "删除失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "删除成功!", c) |
|||
} else { |
|||
isTrue, saveErr := eiteDutyInfoCont(requestData.Id, eiteAssEssStateInfo, saveData) |
|||
if isTrue != true { |
|||
response.Result(105, saveErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} |
|||
} |
|||
} |
|||
|
|||
//获取职责类别内容
|
|||
func GetDutyInfoCont(id int64) (isTrue bool, ContInfo assessmentmodel.DutyContent) { |
|||
isTrue = false |
|||
err := global.GVA_DB_Performanceappraisal.Where("dc_id = ?", id).First(&ContInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
@ -0,0 +1,159 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
|||
) |
|||
|
|||
//职责考核
|
|||
type DutyHandle struct{} |
|||
|
|||
//字符串ID
|
|||
type OutIdStruct struct { |
|||
OutId string `json:"outId"` |
|||
} |
|||
|
|||
//职责类别查询参数
|
|||
type dutyClassRequest struct { |
|||
commonus.PageSetLimt |
|||
OutIdStruct |
|||
Title string `json:"title"` |
|||
State int `json:"state"` |
|||
} |
|||
|
|||
//职责类别输出
|
|||
type dutyClassOutput struct { |
|||
assessmentmodel.DutyClass |
|||
OutIdStruct |
|||
} |
|||
|
|||
//职责类别添加
|
|||
type dutyClassAdd struct { |
|||
Title string `json:"title"` |
|||
} |
|||
|
|||
//职责类别修改
|
|||
type dutyClassEite struct { |
|||
commonus.SetId |
|||
dutyClassAdd |
|||
} |
|||
|
|||
//状态修改
|
|||
type dutyClassState struct { |
|||
commonus.SetId |
|||
State int `json:"state"` // 状态
|
|||
IsDel int `json:"isdel"` // 是否强制删除
|
|||
} |
|||
|
|||
//考核项目查询参数
|
|||
type assessRequest struct { |
|||
commonus.PageSetLimt |
|||
ParentId int64 `json:"parentId"` //父级
|
|||
Title string `json:"title"` |
|||
State int `json:"state"` |
|||
} |
|||
|
|||
//考核项目输出
|
|||
type assessOutput struct { |
|||
assessmentmodel.AssessMentitems |
|||
OutIdStruct |
|||
ParentIdStr string `json:"parentIdStr"` //部门ID
|
|||
ParentTitle string `json:"parentTitle"` |
|||
} |
|||
|
|||
//添加考核项目内容
|
|||
type addAssEssInfo struct { |
|||
dutyClassAdd |
|||
Content string `json:"content"` |
|||
ParentId string `json:"parentId"` //父级
|
|||
} |
|||
|
|||
//修改考核项目内容
|
|||
type eiteAssEssCont struct { |
|||
commonus.SetId |
|||
dutyClassAdd |
|||
Content string `json:"content"` |
|||
ParentId string `json:"parentId"` //父级
|
|||
} |
|||
|
|||
//具体职责查询
|
|||
type dutyRequest struct { |
|||
commonus.PageSetLimt |
|||
ParentId int64 `json:"parentId"` //父级
|
|||
Title string `json:"title"` |
|||
State int `json:"state"` |
|||
AssEssType int `json:"assesstype"` |
|||
AssEssUserId string `json:"assessuserid"` |
|||
} |
|||
|
|||
//具体职责输出
|
|||
type dutyOutput struct { |
|||
assessmentmodel.DutyContent |
|||
OutIdStruct |
|||
|
|||
ParentIdStr string `json:"parentIdStr"` //部门ID
|
|||
ParentTitle string `json:"parentTitle"` |
|||
} |
|||
|
|||
//添加具体职责
|
|||
type addDutyContent struct { |
|||
dutyClassAdd |
|||
Type int `json:"type"` |
|||
ParentId string `json:"parentId"` //父级
|
|||
UserId string `json:"userid"` |
|||
} |
|||
|
|||
//编辑具体项目
|
|||
type eiteDutyCont struct { |
|||
commonus.SetId |
|||
dutyClassAdd |
|||
Type int `json:"type"` |
|||
ParentId string `json:"parentId"` //父级
|
|||
UserId string `json:"userid"` |
|||
} |
|||
|
|||
//部门具体职责
|
|||
type specificDutyRequest struct { |
|||
commonus.PageSetLimt |
|||
DepartmentId string `json:"departmentId"` //部门ID
|
|||
} |
|||
|
|||
//部门具体职责输出
|
|||
type specificDutyOut struct { |
|||
assessmentmodel.DepartDuty |
|||
OutIdStruct |
|||
ParentId string `json:"parentId"` //部门
|
|||
ParentTitle string `json:"parentTitle"` |
|||
|
|||
ClassIdStr string `json:"classIdStr"` //考核类别
|
|||
ClassTitle string `json:"classTitle"` |
|||
|
|||
AssEssIdStr string `json:"assessIdStr"` //考核项目
|
|||
AssEssTitle string `json:"assessTitle"` |
|||
|
|||
DutyIdStr string `json:"duryIdStr"` //具体职责
|
|||
DutyTitle string `json:"duryTitle"` |
|||
|
|||
GroupTitle string `json:"groupTitle"` //集团
|
|||
} |
|||
|
|||
//添加部门具体职责
|
|||
type addSpecificDutyCont struct { |
|||
ParentId string `json:"parentId"` //部门ID
|
|||
ClassId string `json:"classId"` //考核类别
|
|||
AssEssId string `json:"assessId"` //考核项目
|
|||
DutyId string `json:"dutyId"` //具体职责
|
|||
Score int64 `json:"score"` //分数
|
|||
Group int64 `json:"group"` |
|||
} |
|||
|
|||
//编辑部门具体职责
|
|||
type eiteSpecificDutyCont struct { |
|||
commonus.SetId |
|||
ParentId string `json:"parentId"` //部门ID
|
|||
ClassId string `json:"classId"` //考核类别
|
|||
AssEssId string `json:"assessId"` //考核项目
|
|||
DutyId string `json:"dutyId"` //具体职责
|
|||
Score int64 `json:"score"` //分数
|
|||
Group int64 `json:"group"` |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package assessment |
|||
|
|||
type ApiGroup struct { |
|||
DutyHandle |
|||
} |
|||
@ -0,0 +1,381 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
"strconv" |
|||
"time" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/assessmentmodel" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/testpage" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/wechat" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//具体部门职责
|
|||
func (d *DutyHandle) SpecificDutyList(c *gin.Context) { |
|||
var requestData specificDutyRequest |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(101, err, "参数错误!请重新提交!", c)
|
|||
// return
|
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
|
|||
gormDb := global.GVA_DB_Performanceappraisal.Model(&assessmentmodel.DepartDuty{}) |
|||
if requestData.DepartmentId != "" { |
|||
departId, departErr := strconv.ParseInt(requestData.DepartmentId, 10, 64) |
|||
if departErr == nil { |
|||
gormDb = gormDb.Where("`de_partid` = ?", departId) |
|||
} |
|||
|
|||
} |
|||
|
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
|
|||
var dutyList []assessmentmodel.DepartDuty |
|||
dutyListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Find(&dutyList).Error |
|||
if dutyListerr != nil { |
|||
response.Result(103, dutyListerr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
var dutyListCont []specificDutyOut |
|||
for _, val := range dutyList { |
|||
var dutyCont specificDutyOut |
|||
|
|||
dutyCont.Id = val.Id |
|||
dutyCont.Title = val.Title |
|||
dutyCont.State = val.State |
|||
dutyCont.Time = val.Time |
|||
dutyCont.PartId = val.PartId |
|||
dutyCont.ClassId = val.ClassId |
|||
dutyCont.AssessId = val.AssessId |
|||
dutyCont.DutyId = val.DutyId |
|||
dutyCont.Rescore = val.Rescore |
|||
dutyCont.OutId = strconv.FormatInt(val.Id, 10) |
|||
|
|||
//职责分类
|
|||
dutyCont.ClassIdStr = strconv.FormatInt(val.ClassId, 10) |
|||
isTrue, classCont := GetDutyClassCont(val.ClassId) |
|||
if isTrue == true { |
|||
dutyCont.ClassTitle = classCont.Title |
|||
} |
|||
//职责项目
|
|||
dutyCont.AssEssIdStr = strconv.FormatInt(val.AssessId, 10) |
|||
isTrueAssEss, assessCont := GetAssEssCont(val.AssessId) |
|||
if isTrueAssEss == true { |
|||
dutyCont.AssEssTitle = assessCont.Title |
|||
} |
|||
//具体职责
|
|||
dutyCont.DutyIdStr = strconv.FormatInt(val.DutyId, 10) |
|||
isTrueDuty, dutyContInfo := GetDutyInfoCont(val.DutyId) |
|||
if isTrueDuty == true { |
|||
dutyCont.DutyTitle = dutyContInfo.Title |
|||
} |
|||
|
|||
isTrueGroup, groupCont := GetGroupCont(val.Group) |
|||
if isTrueGroup == true { |
|||
dutyCont.GroupTitle = groupCont.Name |
|||
} |
|||
|
|||
//具体职责
|
|||
dutyCont.ParentId = strconv.FormatInt(val.PartId, 10) |
|||
isTrueBranFact, branFactCont := GetBranchFactory(val.PartId) |
|||
if isTrueBranFact == true { |
|||
dutyCont.ParentTitle = branFactCont.Name |
|||
} |
|||
|
|||
dutyListCont = append(dutyListCont, dutyCont) |
|||
} |
|||
countSum := len(dutyListCont) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, dutyListCont) |
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//添加具体职责
|
|||
func (d *DutyHandle) AddSpecificDutyInfo(c *gin.Context) { |
|||
var requestData addSpecificDutyCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
var parentId, classId, assessId, dutyId int64 |
|||
if requestData.ParentId == "" { |
|||
response.Result(102, err, "请指定归属于被考核部门", c) |
|||
return |
|||
} else { |
|||
parentId, _ = strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
} |
|||
if requestData.ClassId == "" { |
|||
response.Result(103, err, "请指定考核类别", c) |
|||
return |
|||
} else { |
|||
classId, _ = strconv.ParseInt(requestData.ClassId, 10, 64) |
|||
} |
|||
if requestData.AssEssId == "" { |
|||
response.Result(104, err, "请指定考核项目", c) |
|||
return |
|||
} else { |
|||
assessId, _ = strconv.ParseInt(requestData.AssEssId, 10, 64) |
|||
} |
|||
if requestData.DutyId == "" { |
|||
response.Result(105, err, "请指定考核具体职责", c) |
|||
return |
|||
} else { |
|||
dutyId, _ = strconv.ParseInt(requestData.DutyId, 10, 64) |
|||
} |
|||
if requestData.Score < 1 { |
|||
response.Result(106, err, "请指定该具体职责参考分值", c) |
|||
return |
|||
} |
|||
var ScoreAll int64 |
|||
var specDutyInfo assessmentmodel.DepartDuty |
|||
|
|||
scoreErr := global.GVA_DB_Performanceappraisal.Model(&specDutyInfo).Where("`de_partid` = ?", parentId).Pluck("COALESCE(SUM(de_rescore), 0) as rescore", &ScoreAll).Error |
|||
if scoreErr != nil { |
|||
ScoreAll = 0 |
|||
} |
|||
if ScoreAll+requestData.Score > 100 { |
|||
response.Result(107, err, "该部门的总分值超过100。请重新写入该考核项目参考分值!", c) |
|||
return |
|||
} |
|||
if requestData.Group == 0 { |
|||
requestData.Group = 3 |
|||
} |
|||
specDutyInfo.Id = commonus.GetFileNumberEs() |
|||
specDutyInfo.Title = "" |
|||
specDutyInfo.State = 1 |
|||
specDutyInfo.Time = time.Now().Unix() |
|||
specDutyInfo.PartId = parentId |
|||
specDutyInfo.ClassId = classId |
|||
specDutyInfo.AssessId = assessId |
|||
specDutyInfo.DutyId = dutyId |
|||
specDutyInfo.Rescore = requestData.Score |
|||
specDutyInfo.Group = requestData.Group |
|||
dutyInfoErr := global.GVA_DB_Performanceappraisal.Create(&specDutyInfo).Error |
|||
if dutyInfoErr != nil { |
|||
response.Result(108, specDutyInfo, "数据写入失败!", c) |
|||
} else { |
|||
response.Result(0, specDutyInfo, "数据写入成功!", c) |
|||
} |
|||
} |
|||
|
|||
//获取部门具体考核项目
|
|||
func (d *DutyHandle) GetSpecDutyCont(c *gin.Context) { |
|||
var requestData commonus.SetId |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
var dutyOutInfo specificDutyOut |
|||
inFoErr := global.GVA_DB_Performanceappraisal.Where("`de_id` = ?", requestData.Id).First(&dutyOutInfo).Error |
|||
if inFoErr != nil { |
|||
response.Result(103, inFoErr, "数据查询失败!", c) |
|||
return |
|||
} |
|||
dutyOutInfo.OutId = strconv.FormatInt(dutyOutInfo.Id, 10) |
|||
//职责分类
|
|||
dutyOutInfo.ClassIdStr = strconv.FormatInt(dutyOutInfo.ClassId, 10) |
|||
isTrue, classCont := GetDutyClassCont(dutyOutInfo.ClassId) |
|||
if isTrue == true { |
|||
dutyOutInfo.ClassTitle = classCont.Title |
|||
} |
|||
//职责项目
|
|||
dutyOutInfo.AssEssIdStr = strconv.FormatInt(dutyOutInfo.AssessId, 10) |
|||
isTrueAssEss, assessCont := GetAssEssCont(dutyOutInfo.AssessId) |
|||
if isTrueAssEss == true { |
|||
dutyOutInfo.AssEssTitle = assessCont.Title |
|||
} |
|||
//具体职责
|
|||
dutyOutInfo.DutyIdStr = strconv.FormatInt(dutyOutInfo.DutyId, 10) |
|||
isTrueDuty, dutyCont := GetDutyInfoCont(dutyOutInfo.DutyId) |
|||
if isTrueDuty == true { |
|||
dutyOutInfo.DutyTitle = dutyCont.Title |
|||
} |
|||
|
|||
isTrueGroup, groupCont := GetGroupCont(dutyOutInfo.Group) |
|||
if isTrueGroup == true { |
|||
dutyOutInfo.GroupTitle = groupCont.Name |
|||
} |
|||
|
|||
//具体职责
|
|||
dutyOutInfo.ParentId = strconv.FormatInt(dutyOutInfo.PartId, 10) |
|||
isTrueBranFact, branFactCont := GetBranchFactory(dutyOutInfo.PartId) |
|||
if isTrueBranFact == true { |
|||
dutyOutInfo.ParentTitle = branFactCont.Name |
|||
} |
|||
|
|||
response.Result(0, dutyOutInfo, "数据查询成功!", c) |
|||
} |
|||
|
|||
//获取集团信息
|
|||
func GetGroupCont(id int64) (isTrue bool, ContInfo wechat.GroupForm) { |
|||
isTrue = false |
|||
err := global.GVA_DB_WatchDate.Where("g_id = ?", id).First(&ContInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
|
|||
//获得分厂名称
|
|||
func GetBranchFactory(id int64) (isTrue bool, ContInfo testpage.BranchFactory) { |
|||
isTrue = false |
|||
err := global.GVA_DB_Master.Where("bf_id = ?", id).First(&ContInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
|
|||
//编辑具体内容
|
|||
func (d *DutyHandle) EiteSpecFicDutyInfo(c *gin.Context) { |
|||
var requestData eiteSpecificDutyCont |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
saveData := commonus.MapOut() |
|||
|
|||
var parentId, classId, assessId, dutyId int64 |
|||
if requestData.ParentId != "" { |
|||
parentId, _ = strconv.ParseInt(requestData.ParentId, 10, 64) |
|||
saveData["de_partid"] = parentId |
|||
} |
|||
if requestData.ClassId != "" { |
|||
classId, _ = strconv.ParseInt(requestData.ClassId, 10, 64) |
|||
saveData["de_class"] = classId |
|||
} |
|||
if requestData.AssEssId != "" { |
|||
assessId, _ = strconv.ParseInt(requestData.AssEssId, 10, 64) |
|||
saveData["de_assess"] = assessId |
|||
} |
|||
if requestData.DutyId != "" { |
|||
dutyId, _ = strconv.ParseInt(requestData.DutyId, 10, 64) |
|||
saveData["de_duty"] = dutyId |
|||
} |
|||
if requestData.Score > 0 { |
|||
var ScoreAll int64 |
|||
var specDutyInfo assessmentmodel.DepartDuty |
|||
|
|||
scoreErr := global.GVA_DB_Performanceappraisal.Model(&specDutyInfo).Where("`de_partid` = ?", parentId).Pluck("COALESCE(SUM(de_rescore), 0) as rescore", &ScoreAll).Error |
|||
if scoreErr != nil { |
|||
ScoreAll = 0 |
|||
} |
|||
if ScoreAll+requestData.Score > 100 { |
|||
response.Result(107, err, "该部门的总分值超过100。请重新写入该考核项目参考分值!", c) |
|||
return |
|||
} |
|||
saveData["de_rescore"] = requestData.Score |
|||
} |
|||
|
|||
if requestData.Group != 0 { |
|||
saveData["de_group"] = requestData.Group |
|||
} |
|||
|
|||
saveData["de_time"] = time.Now().Unix() |
|||
isTrue, isErr := eiteSpecificDutyInfoCont(requestData.Id, saveData) |
|||
if isTrue != true { |
|||
response.Result(104, isErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, saveData, "修改成功!", c) |
|||
|
|||
} |
|||
|
|||
//编辑具体职责内容
|
|||
func eiteSpecificDutyInfoCont(saveId int64, saveData map[string]interface{}) (isTrue bool, dutyClassInfoErr error) { |
|||
var modelInfo assessmentmodel.DepartDuty |
|||
isTrue = false |
|||
dutyClassInfoErr = global.GVA_DB_Performanceappraisal.Model(&modelInfo).Where("de_id = ?", saveId).Updates(saveData).Error |
|||
if dutyClassInfoErr != nil { |
|||
return |
|||
} |
|||
isTrue = true |
|||
return |
|||
} |
|||
|
|||
//修改考核项目的状态
|
|||
func (d *DutyHandle) EiteSpecficDutyState(c *gin.Context) { |
|||
var requestData dutyClassState |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
response.Result(101, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.Id == 0 && requestData.OutId == "" { |
|||
response.Result(102, err, "参数错误!请重新提交!", c) |
|||
return |
|||
} |
|||
if requestData.OutId != "" { |
|||
idInt, inIntErr := strconv.ParseInt(requestData.OutId, 10, 64) |
|||
if inIntErr == nil { |
|||
requestData.Id = idInt |
|||
} |
|||
} |
|||
if requestData.State == 0 { |
|||
requestData.State = 1 |
|||
} |
|||
saveData := commonus.MapOut() |
|||
saveData["de_satte"] = requestData.State |
|||
saveData["de_time"] = time.Now().Unix() |
|||
var eiteAssEssStateInfo assessmentmodel.DepartDuty |
|||
if requestData.IsDel != 1 { |
|||
isTrue, dutyErr := eiteSpecificDutyInfoCont(requestData.Id, saveData) |
|||
if isTrue != true { |
|||
response.Result(103, dutyErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} else { |
|||
if requestData.State == 3 { |
|||
archiveInfoErr := global.GVA_DB_Performanceappraisal.Where("de_id = ?", requestData.Id).Delete(&eiteAssEssStateInfo).Error |
|||
if archiveInfoErr != nil { |
|||
response.Result(104, requestData, "删除失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "删除成功!", c) |
|||
} else { |
|||
isTrue, saveErr := eiteSpecificDutyInfoCont(requestData.Id, saveData) |
|||
if isTrue != true { |
|||
response.Result(105, saveErr, "修改失败!", c) |
|||
return |
|||
} |
|||
response.Result(0, requestData, "修改成功!", c) |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,208 @@ |
|||
package custom |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"strconv" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/api/v1/staff" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/api/v1/systemuser" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
systemReq "github.com/flipped-aurora/gin-vue-admin/server/model/system/request" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/utils" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel" |
|||
|
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//自定义登录
|
|||
func (cu *CustomHandle) CustomLogin(c *gin.Context) { |
|||
var l systemReq.Login |
|||
_ = c.ShouldBindJSON(&l) |
|||
if err := utils.Verify(l, utils.LoginVerify); err != nil { |
|||
response.FailWithMessage(err.Error(), c) |
|||
return |
|||
} |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
// store
|
|||
// if store.Verify(l.CaptchaId, l.Captcha, true) {
|
|||
userErr, user := staff.GetUserWork(l.Username, l.Password) |
|||
if userErr != true { |
|||
// // global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Any("err", err))
|
|||
response.Result(101, userErr, "登陆失败! 用户名不存在或者密码错误!!", c) |
|||
return |
|||
} else { |
|||
if user.State == 2 { |
|||
response.Result(102, userErr, "登陆失败! 该账号已经被禁用!", c) |
|||
return |
|||
} |
|||
if user.State == 3 { |
|||
response.Result(102, userErr, "登陆失败! 该账号不存在!", c) |
|||
return |
|||
} |
|||
if user.HireSet != 1 { |
|||
response.Result(102, userErr, "登陆失败! 该员工已经离职!", c) |
|||
return |
|||
} |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userAgent) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
|
|||
sha1Str := user.KeyStr + user.Number + user.Password + md5Token |
|||
sha1Token := commonus.Sha1Encryption(sha1Str) |
|||
|
|||
saveData := commonus.MapOut() |
|||
saveData["key"] = user.KeyStr |
|||
saveData["token"] = sha1Token |
|||
saveData["userinfo"] = user |
|||
|
|||
redisClient := redishandel.RunRedis() |
|||
redisClient.SetRedisTime(10800) |
|||
writeRedisData := map[string]interface{}{ |
|||
"userkey": user.KeyStr, |
|||
"usernumber": user.Number, |
|||
"userpwd": user.Password, |
|||
"usertoken": sha1Token, |
|||
} |
|||
|
|||
global.GVA_INDEX_USERKEY = user.Key |
|||
|
|||
redisClient.HashMsetAdd("system:Identification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, writeRedisData) |
|||
|
|||
userInfo := commonus.MapOut() |
|||
userInfo["id"] = user.Id |
|||
userInfo["number"] = user.Number |
|||
userInfo["departmentid"] = user.DepartmentId |
|||
userInfo["workshopid"] = user.WorkshopId |
|||
userInfo["postid"] = user.PostId |
|||
userInfo["key"] = user.Key |
|||
userInfo["group"] = user.Group |
|||
userInfo["tema"] = user.Tema |
|||
userInfo["workwechatid"] = user.WorkWechatId |
|||
userInfo["wechatid"] = user.WechatId |
|||
userInfo["name"] = user.Name |
|||
userInfo["nickname"] = user.NickName |
|||
|
|||
redisUserClient := redishandel.RunRedis() |
|||
redisUserClient.SetRedisTime(0) |
|||
redisUserClient.HashMsetAdd("system:userContent_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, userInfo) |
|||
// // b.tokenNext(c, *user)
|
|||
response.Result(0, saveData, "登录成功!", c) |
|||
} |
|||
// } else {
|
|||
// response.FailWithMessage("验证码错误", c)
|
|||
// }
|
|||
} |
|||
|
|||
//自定义登录
|
|||
func (cu *CustomHandle) SystemLogin(c *gin.Context) { |
|||
var l systemReq.Login |
|||
_ = c.ShouldBindJSON(&l) |
|||
if err := utils.Verify(l, utils.LoginVerify); err != nil { |
|||
response.FailWithMessage(err.Error(), c) |
|||
return |
|||
} |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
// store
|
|||
// if store.Verify(l.CaptchaId, l.Captcha, true) {
|
|||
userErr, user := systemuser.GetSysAdminLoginInfo(l.Username, l.Password) |
|||
if userErr != true { |
|||
// // global.GVA_LOG.Error("登陆失败! 用户名不存在或者密码错误!", zap.Any("err", err))
|
|||
response.Result(101, userErr, "登陆失败! 用户名不存在或者密码错误!!", c) |
|||
return |
|||
} else { |
|||
if user.State == 2 { |
|||
response.Result(102, userErr, "登陆失败! 该账号已经被禁用!", c) |
|||
return |
|||
} |
|||
if user.State == 3 { |
|||
response.Result(102, userErr, "登陆失败! 该账号不存在!", c) |
|||
return |
|||
} |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userAgent) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
|
|||
sha1Str := user.KeyStr + user.Name + user.PassWord + md5Token |
|||
sha1Token := commonus.Sha1Encryption(sha1Str) |
|||
|
|||
saveData := commonus.MapOut() |
|||
saveData["key"] = user.KeyStr |
|||
saveData["token"] = sha1Token |
|||
saveData["userinfo"] = user |
|||
|
|||
redisClient := redishandel.RunRedis() |
|||
redisClient.SetRedisTime(10800) |
|||
writeRedisData := map[string]interface{}{ |
|||
"userkey": user.KeyStr, |
|||
"usernumber": user.Name, |
|||
"userpwd": user.PassWord, |
|||
"usertoken": sha1Token, |
|||
"jurisdiction": user.Jurisdiction, |
|||
"menuOper": user.MenuOper, |
|||
"wand": user.Wand, |
|||
} |
|||
redisClient.HashMsetAdd("system:SystemIdentification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, writeRedisData) |
|||
|
|||
adminRedisData := map[string]interface{}{ |
|||
"userkey": user.KeyStr, |
|||
"usernumber": user.Name, |
|||
"userpwd": user.PassWord, |
|||
"usertoken": sha1Token, |
|||
"jurisdiction": user.Jurisdiction, |
|||
"menuOper": user.MenuOper, |
|||
"wand": user.Wand, |
|||
"name": user.NameAttr, |
|||
"groupname": user.GroupName, |
|||
"group": user.Group, |
|||
"attribute": user.Attribute, |
|||
"branchfactoryname": user.BranchFactoryName, |
|||
"role": user.Role, |
|||
"roleName": user.RoleName, |
|||
} |
|||
redisAdminClient := redishandel.RunRedis() |
|||
redisAdminClient.SetRedisTime(0) |
|||
redisAdminClient.HashMsetAdd("system:SystemAdminInfo_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+user.KeyStr, adminRedisData) |
|||
|
|||
global.GVA_ADMIN_USERKEY = user.Key |
|||
// // b.tokenNext(c, *user)
|
|||
var surisdictionStr []string |
|||
var surisdictionInt []int64 |
|||
jsonErr := json.Unmarshal([]byte(user.Jurisdiction), &surisdictionStr) |
|||
if jsonErr == nil { |
|||
for _, jurVal := range surisdictionStr { |
|||
jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64) |
|||
if jurValErr == nil { |
|||
surisdictionInt = append(surisdictionInt, jurValInt) |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
global.Gva_Authority_Authentication = surisdictionInt |
|||
var menuOperStr []string |
|||
var menuOperInts []int64 |
|||
jsonErrSun := json.Unmarshal([]byte(user.MenuOper), &menuOperStr) |
|||
if jsonErrSun == nil { |
|||
for _, menuOperVal := range menuOperStr { |
|||
menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64) |
|||
if menuOperErr == nil { |
|||
menuOperInts = append(menuOperInts, menuOperInt) |
|||
} |
|||
|
|||
} |
|||
} |
|||
global.Gva_Authority_Authentication_Subsidiary = menuOperInts |
|||
saveData["Jurisdiction"] = global.Gva_Authority_Authentication |
|||
saveData["MenuOper"] = global.Gva_Authority_Authentication_Subsidiary |
|||
|
|||
// saveData["jsonErr"] = jsonErr
|
|||
// saveData["jsonErrSun"] = jsonErrSun
|
|||
|
|||
response.Result(0, saveData, "登录成功!", c) |
|||
} |
|||
// } else {
|
|||
// response.FailWithMessage("验证码错误", c)
|
|||
// }
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package custom |
|||
|
|||
import "github.com/mojocn/base64Captcha" |
|||
|
|||
var store = base64Captcha.DefaultMemStore |
|||
|
|||
type CustomHandle struct{} |
|||
@ -0,0 +1,5 @@ |
|||
package custom |
|||
|
|||
type ApiGroup struct { |
|||
CustomHandle |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package staff |
|||
|
|||
type ApiGroup struct { |
|||
StaffPeople |
|||
} |
|||
@ -0,0 +1,210 @@ |
|||
package staff |
|||
|
|||
import ( |
|||
"strconv" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/api/v1/assessment" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/testpage" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//员工
|
|||
|
|||
type StaffPeople struct{} |
|||
|
|||
func (s *StaffPeople) Index(c *gin.Context) { |
|||
outPut := commonus.MapOut() |
|||
response.Result(0, outPut, "获取成功", c) |
|||
} |
|||
|
|||
//获得员工列表
|
|||
func (s *StaffPeople) StaffList(c *gin.Context) { |
|||
var requestData staffRequest |
|||
err := c.ShouldBindJSON(&requestData) |
|||
if err != nil { |
|||
// response.Result(101, err, "参数错误!请重新提交!", c)
|
|||
// return
|
|||
} |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
|
|||
gormDb := global.GVA_DB_Master.Model(&testpage.WorkMan{}).Select("worker_man.*,worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key") |
|||
|
|||
if requestData.GroupId != 0 { |
|||
gormDb = gormDb.Where("`wm_group` = ?", requestData.GroupId) |
|||
} |
|||
|
|||
if requestData.BranchFactoryId != 0 { |
|||
gormDb = gormDb.Where("`wm_bf_id` = ?", requestData.BranchFactoryId) |
|||
} |
|||
if requestData.PostId != 0 { |
|||
gormDb = gormDb.Where("`wm_ws_id` = ?", requestData.PostId) |
|||
} |
|||
if requestData.JobId != 0 { |
|||
gormDb = gormDb.Where("`wm_pt_id` = ?", requestData.JobId) |
|||
} |
|||
|
|||
if requestData.UserName != "" { |
|||
gormDb = gormDb.Where("wmd_name LIKE ?", "%"+requestData.UserName+"%") |
|||
} |
|||
|
|||
if requestData.State != 0 { |
|||
gormDb = gormDb.Where("`wm_set` = ?", requestData.State) |
|||
} else { |
|||
gormDb = gormDb.Where("`wm_set` IN ?", []int{1, 2}) |
|||
} |
|||
|
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
var staffList []testpage.PersonalDetails |
|||
staffListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Order("wm_id desc").Find(&staffList).Error |
|||
if staffListerr != nil { |
|||
response.Result(103, staffListerr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
var staffMap []staffOutInfo |
|||
for _, val := range staffList { |
|||
var staffInfo staffOutInfo |
|||
|
|||
staffInfo.Id = val.Id |
|||
|
|||
staffInfo.Number = val.Number |
|||
staffInfo.Password = val.Password |
|||
staffInfo.DepartmentId = val.DepartmentId |
|||
staffInfo.WorkshopId = val.WorkshopId |
|||
staffInfo.PostId = val.PostId |
|||
staffInfo.Key = val.Key |
|||
staffInfo.State = val.State |
|||
staffInfo.HireSet = val.HireSet |
|||
staffInfo.Time = val.Time |
|||
staffInfo.EiteTime = val.EiteTime |
|||
staffInfo.UserId = val.UserId |
|||
staffInfo.QuitTime = val.QuitTime |
|||
staffInfo.Group = val.Group |
|||
staffInfo.Soptcheck = val.Soptcheck |
|||
staffInfo.Tema = val.Tema |
|||
staffInfo.IsOne = val.IsOne |
|||
staffInfo.WorkWechatId = val.WorkWechatId |
|||
staffInfo.WechatId = val.WechatId |
|||
|
|||
staffInfo.KeyAttr = val.KeyAttr |
|||
staffInfo.Name = val.Name |
|||
staffInfo.Gender = val.Gender |
|||
staffInfo.Age = val.Age |
|||
staffInfo.Tel = val.Tel |
|||
staffInfo.Category = val.Category |
|||
staffInfo.CertificatesType = val.CertificatesType |
|||
staffInfo.CertificatesNum = val.CertificatesNum |
|||
staffInfo.Birthday = val.Birthday |
|||
staffInfo.EntryTime = val.EntryTime |
|||
staffInfo.QuitTimeAttr = val.QuitTimeAttr |
|||
staffInfo.EiteTimeAttr = val.EiteTimeAttr |
|||
staffInfo.Addrest = val.Addrest |
|||
staffInfo.Icon = val.Icon |
|||
staffInfo.NickName = val.NickName |
|||
|
|||
staffInfo.KeyStr = strconv.FormatInt(val.Key, 10) |
|||
|
|||
isTrueBranFact, branFactCont := assessment.GetBranchFactory(val.DepartmentId) |
|||
if isTrueBranFact == true { |
|||
staffInfo.BranchFactory = branFactCont.Name |
|||
} |
|||
isTrueGroup, groupCont := assessment.GetGroupCont(val.Group) |
|||
if isTrueGroup == true { |
|||
staffInfo.GroupTitle = groupCont.Name |
|||
} |
|||
|
|||
isTrueWork, workCont := commonus.GetWorkShopSection(val.WorkshopId) |
|||
if isTrueWork == true { |
|||
staffInfo.PostTitle = workCont.Name |
|||
} |
|||
|
|||
staffMap = append(staffMap, staffInfo) |
|||
} |
|||
countSum := len(staffMap) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, staffMap) |
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//通过账号密码获取用户信息
|
|||
func GetUserWork(userName, userPwd string) (isTrue bool, staffInfo staffOutInfo) { |
|||
isTrue = false |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userPwd) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
var userInfo testpage.PersonalDetails |
|||
userErr := global.GVA_DB_Master.Model(&testpage.WorkMan{}).Select("worker_man.*,worker_man_data.*").Joins("left join worker_man_data on worker_man_data.wmd_key = worker_man.wm_key").Where("`wm_number` = ? AND `wm_pwd` = ?", userName, md5Token).First(&userInfo).Error |
|||
|
|||
if userErr != nil { |
|||
return |
|||
} |
|||
// var staffInfo staffOutInfo
|
|||
// fmt.Printf("------->%v\n", userInfo.Id)
|
|||
staffInfo.Id = userInfo.Id |
|||
|
|||
staffInfo.Number = userInfo.Number |
|||
staffInfo.Password = userInfo.Password |
|||
staffInfo.DepartmentId = userInfo.DepartmentId |
|||
staffInfo.WorkshopId = userInfo.WorkshopId |
|||
staffInfo.PostId = userInfo.PostId |
|||
staffInfo.Key = userInfo.Key |
|||
staffInfo.State = userInfo.State |
|||
staffInfo.HireSet = userInfo.HireSet |
|||
staffInfo.Time = userInfo.Time |
|||
staffInfo.EiteTime = userInfo.EiteTime |
|||
staffInfo.UserId = userInfo.UserId |
|||
staffInfo.QuitTime = userInfo.QuitTime |
|||
staffInfo.Group = userInfo.Group |
|||
staffInfo.Soptcheck = userInfo.Soptcheck |
|||
staffInfo.Tema = userInfo.Tema |
|||
staffInfo.IsOne = userInfo.IsOne |
|||
staffInfo.WorkWechatId = userInfo.WorkWechatId |
|||
staffInfo.WechatId = userInfo.WechatId |
|||
|
|||
staffInfo.KeyAttr = userInfo.KeyAttr |
|||
staffInfo.Name = userInfo.Name |
|||
staffInfo.Gender = userInfo.Gender |
|||
staffInfo.Age = userInfo.Age |
|||
staffInfo.Tel = userInfo.Tel |
|||
staffInfo.Category = userInfo.Category |
|||
staffInfo.CertificatesType = userInfo.CertificatesType |
|||
staffInfo.CertificatesNum = userInfo.CertificatesNum |
|||
staffInfo.Birthday = userInfo.Birthday |
|||
staffInfo.EntryTime = userInfo.EntryTime |
|||
staffInfo.QuitTimeAttr = userInfo.QuitTimeAttr |
|||
staffInfo.EiteTimeAttr = userInfo.EiteTimeAttr |
|||
staffInfo.Addrest = userInfo.Addrest |
|||
staffInfo.Icon = userInfo.Icon |
|||
staffInfo.NickName = userInfo.NickName |
|||
|
|||
staffInfo.KeyStr = strconv.FormatInt(userInfo.Key, 10) |
|||
|
|||
isTrueBranFact, branFactCont := assessment.GetBranchFactory(userInfo.DepartmentId) |
|||
if isTrueBranFact == true { |
|||
staffInfo.BranchFactory = branFactCont.Name |
|||
} |
|||
isTrueGroup, groupCont := assessment.GetGroupCont(userInfo.Group) |
|||
if isTrueGroup == true { |
|||
staffInfo.GroupTitle = groupCont.Name |
|||
} |
|||
|
|||
isTrueWork, workCont := commonus.GetWorkShopSection(userInfo.WorkshopId) |
|||
if isTrueWork == true { |
|||
staffInfo.PostTitle = workCont.Name |
|||
} |
|||
isTrue = true |
|||
|
|||
// fmt.Printf("&&&&&&&&&&&>%v\n", staffInfo)
|
|||
return |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package staff |
|||
|
|||
import ( |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/testpage" |
|||
) |
|||
|
|||
type staffRequest struct { |
|||
commonus.PageSetLimt |
|||
GroupId int `json:"groupId"` |
|||
BranchFactoryId int `json:"branchFactoryId"` |
|||
PostId int `json:"postId"` |
|||
JobId int `json:"jobId"` |
|||
State int `json:"state"` |
|||
UserName string `json:"username"` |
|||
} |
|||
|
|||
//输出员工信息
|
|||
type staffOutInfo struct { |
|||
testpage.PersonalDetails |
|||
KeyStr string `json:"keystr"` |
|||
GroupTitle string `json:"grouptitle"` |
|||
BranchFactory string `json:"branchFactory"` |
|||
PostTitle string `json:"postTitle"` |
|||
JobTitle string `json:"jobTitle"` |
|||
TemaTitle string `json:"temaTitle"` |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
package systemuser |
|||
|
|||
import ( |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/systemuser" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//角色相关
|
|||
|
|||
/* |
|||
角色列表 |
|||
*/ |
|||
func (s *SystemRoleApi) SystemRoleList(c *gin.Context) {} |
|||
|
|||
//获取角色详细内容
|
|||
func GetAdminRoleInfo(id int64) (isTrue bool, adminRoleInfo systemuser.SystemRole) { |
|||
isTrue = false |
|||
err := global.GVA_DB_Master.Where("r_id = ?", id).First(&adminRoleInfo).Error |
|||
if err == nil { |
|||
isTrue = true |
|||
} |
|||
return |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
package systemuser |
|||
|
|||
type ApiGroup struct { |
|||
SystemUserApi |
|||
SystemRoleApi |
|||
SysTemMenuApi |
|||
} |
|||
@ -0,0 +1,78 @@ |
|||
package systemuser |
|||
|
|||
import ( |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/systemuser" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//菜单相关
|
|||
func (s *SysTemMenuApi) SystemMenuList(c *gin.Context) { |
|||
// response.Result(101, global.Gva_Authority_Authentication, "数据获取失败!", c)
|
|||
var systemMenuList []systemuser.SystemMenu |
|||
menuOperErr := global.GVA_DB_Master.Where("`m_steat` IN ?", []int{1, 2}).Order("m_id desc").Find(&systemMenuList).Error |
|||
if menuOperErr != nil { |
|||
response.Result(101, menuOperErr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
systemListMenu := GetMenuThree(1, 0, systemMenuList) |
|||
response.Result(0, systemListMenu, "数据获取成功!", c) |
|||
} |
|||
|
|||
//递归无限树
|
|||
func GetMenuThree(jurisd int, parentId int64, threeData []systemuser.SystemMenu) []SystemMenuThree { |
|||
treeList := []SystemMenuThree{} |
|||
for _, v := range threeData { |
|||
if v.ParentId == parentId { |
|||
child := GetMenuThree(jurisd, v.Id, threeData) |
|||
node := SystemMenuThree{ |
|||
Id: v.Id, |
|||
Title: v.Title, |
|||
State: v.State, |
|||
ParentId: v.ParentId, |
|||
ApiUrl: v.ApiUrl, |
|||
Time: v.Time, |
|||
EiteTime: v.EiteTime, |
|||
UserId: v.UserId, |
|||
Sort: v.Sort, |
|||
} |
|||
isTrue, menuOper := MenuOperation(jurisd, v.Id) |
|||
if isTrue == true { |
|||
node.MenuOperation = menuOper |
|||
} |
|||
node.Child = child |
|||
treeList = append(treeList, node) |
|||
} |
|||
} |
|||
return treeList |
|||
} |
|||
|
|||
//获取菜单操作项目
|
|||
func MenuOperation(jurisd int, menuId int64) (isTrue bool, operation []systemuser.MenuOperation) { |
|||
isTrue = false |
|||
if jurisd != 1 { |
|||
operErr := global.GVA_DB_Master.Where("`menu_id` = ? AND oper_id IN ?", menuId, global.Gva_Authority_Authentication).Order("oper_id desc").Find(&operation).Error |
|||
if operErr == nil { |
|||
isTrue = true |
|||
} |
|||
} else { |
|||
operErr := global.GVA_DB_Master.Where("`menu_id` = ?", menuId).Order("oper_id desc").Find(&operation).Error |
|||
if operErr == nil { |
|||
isTrue = true |
|||
} |
|||
} |
|||
return |
|||
} |
|||
|
|||
//获取左侧菜单栏
|
|||
func (s *SysTemMenuApi) GetMenu(c *gin.Context) { |
|||
var systemMenuList []systemuser.SystemMenu |
|||
menuOperErr := global.GVA_DB_Master.Where("`m_steat` IN ? AND m_id IN ?", []int{1, 2}, global.Gva_Authority_Authentication_Subsidiary).Order("m_id desc").Find(&systemMenuList).Error |
|||
if menuOperErr != nil { |
|||
response.Result(101, menuOperErr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
systemListMenu := GetMenuThree(2, 0, systemMenuList) |
|||
response.Result(0, systemListMenu, "数据获取成功!", c) |
|||
} |
|||
@ -0,0 +1,155 @@ |
|||
package systemuser |
|||
|
|||
import ( |
|||
"strconv" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/api/v1/assessment" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/systemuser" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
//系统相关
|
|||
func (s *SystemUserApi) Index(c *gin.Context) { |
|||
outPut := commonus.MapOut() |
|||
response.Result(0, outPut, "获取成功", c) |
|||
} |
|||
|
|||
//管理员列表
|
|||
func (s *SystemUserApi) AdminList(c *gin.Context) { |
|||
var requestData adminRequest |
|||
c.ShouldBindJSON(&requestData) |
|||
if requestData.PageSize == 0 { |
|||
requestData.PageSize = 20 |
|||
} |
|||
if requestData.Page <= 0 { |
|||
requestData.Page = 1 |
|||
} |
|||
offSetPage := commonus.CalculatePages(requestData.Page, requestData.PageSize) |
|||
gormDb := global.GVA_DB_Master.Model(&systemuser.SystemUser{}).Select("system_user.*,system_user_attribute.*").Joins("left join system_user_attribute on system_user.u_key = system_user_attribute.ua_id") |
|||
|
|||
if requestData.GroupId != 0 { |
|||
gormDb = gormDb.Where("`u_group` = ?", requestData.GroupId) |
|||
} |
|||
|
|||
if requestData.BranchFactoryId != 0 { |
|||
gormDb = gormDb.Where("`u_attribute` = ?", requestData.BranchFactoryId) |
|||
} |
|||
|
|||
if requestData.RoleId != 0 { |
|||
gormDb = gormDb.Where("`u_role` = ?", requestData.RoleId) |
|||
} |
|||
|
|||
if requestData.State != 0 { |
|||
gormDb = gormDb.Where("`u_set` = ?", requestData.State) |
|||
} else { |
|||
gormDb = gormDb.Where("`u_set` IN ?", []int{1, 2}) |
|||
} |
|||
|
|||
if requestData.UserName != "" { |
|||
gormDb = gormDb.Where("(`u_name` LIKE ? OR `ua_name` LIKE ?)", "%"+requestData.UserName+"%", "%"+requestData.UserName+"%") |
|||
} |
|||
var total int64 |
|||
totalErr := gormDb.Count(&total).Error |
|||
if totalErr != nil { |
|||
total = 0 |
|||
} |
|||
var systemAdminList []systemuser.SystemAdminDetails |
|||
systemAdminListerr := gormDb.Limit(requestData.PageSize).Offset(offSetPage).Order("u_id desc").Find(&systemAdminList).Error |
|||
if systemAdminListerr != nil { |
|||
response.Result(101, systemAdminListerr, "数据获取失败!", c) |
|||
return |
|||
} |
|||
var sysAdminList []adminOutInfo |
|||
for _, val := range systemAdminList { |
|||
var sysAdminInfo adminOutInfo |
|||
sysAdminInfo.Id = val.Id |
|||
sysAdminInfo.Name = val.Name |
|||
sysAdminInfo.PassWord = val.PassWord |
|||
sysAdminInfo.Role = val.Role |
|||
sysAdminInfo.State = val.State |
|||
sysAdminInfo.Attribute = val.Attribute |
|||
sysAdminInfo.Time = val.Time |
|||
sysAdminInfo.EiteTime = val.EiteTime |
|||
sysAdminInfo.Key = val.Key |
|||
sysAdminInfo.Group = val.Group |
|||
sysAdminInfo.Wand = val.Wand |
|||
sysAdminInfo.IdAttr = val.IdAttr |
|||
sysAdminInfo.NameAttr = val.NameAttr |
|||
sysAdminInfo.Tel = val.Tel |
|||
sysAdminInfo.TimeAttr = val.TimeAttr |
|||
|
|||
isTrueGroup, groupCont := assessment.GetGroupCont(val.Group) |
|||
if isTrueGroup == true { |
|||
sysAdminInfo.GroupName = groupCont.Name |
|||
} |
|||
isTrueBranFact, branFactCont := assessment.GetBranchFactory(val.Attribute) |
|||
if isTrueBranFact == true { |
|||
sysAdminInfo.BranchFactoryName = branFactCont.Name |
|||
} |
|||
|
|||
isTrueRole, adminRoleCont := GetAdminRoleInfo(val.Role) |
|||
if isTrueRole == true { |
|||
sysAdminInfo.RoleName = adminRoleCont.Title |
|||
sysAdminInfo.Jurisdiction = adminRoleCont.Jurisdiction |
|||
sysAdminInfo.MenuOper = adminRoleCont.MenuOper |
|||
sysAdminInfo.Wand = adminRoleCont.Wand |
|||
} |
|||
sysAdminInfo.KeyStr = strconv.FormatInt(val.Key, 10) |
|||
|
|||
sysAdminList = append(sysAdminList, sysAdminInfo) |
|||
} |
|||
countSum := len(sysAdminList) |
|||
printData := commonus.OutPutList(total, int64(countSum), requestData.Page, requestData.PageSize, sysAdminList) |
|||
response.Result(0, printData, "查询成功!", c) |
|||
} |
|||
|
|||
//获取管理员详细内容登录
|
|||
func GetSysAdminLoginInfo(userName, userPwd string) (isTrue bool, sysAdminInfo adminOutInfo) { |
|||
isTrue = false |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userPwd) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
var userInfo systemuser.SystemAdminDetails |
|||
userErr := global.GVA_DB_Master.Model(&systemuser.SystemUser{}).Select("system_user.*,system_user_attribute.*").Joins("left join system_user_attribute on system_user.u_key = system_user_attribute.ua_id").Where("`u_name` = ? AND `u_password` = ?", userName, md5Token).First(&userInfo).Error |
|||
if userErr != nil { |
|||
return |
|||
} |
|||
sysAdminInfo.Id = userInfo.Id |
|||
sysAdminInfo.Name = userInfo.Name |
|||
sysAdminInfo.PassWord = userInfo.PassWord |
|||
sysAdminInfo.Role = userInfo.Role |
|||
sysAdminInfo.State = userInfo.State |
|||
sysAdminInfo.Attribute = userInfo.Attribute |
|||
sysAdminInfo.Time = userInfo.Time |
|||
sysAdminInfo.EiteTime = userInfo.EiteTime |
|||
sysAdminInfo.Key = userInfo.Key |
|||
sysAdminInfo.Group = userInfo.Group |
|||
sysAdminInfo.Wand = userInfo.Wand |
|||
sysAdminInfo.IdAttr = userInfo.IdAttr |
|||
sysAdminInfo.NameAttr = userInfo.NameAttr |
|||
sysAdminInfo.Tel = userInfo.Tel |
|||
sysAdminInfo.TimeAttr = userInfo.TimeAttr |
|||
|
|||
isTrueGroup, groupCont := assessment.GetGroupCont(userInfo.Group) |
|||
if isTrueGroup == true { |
|||
sysAdminInfo.GroupName = groupCont.Name |
|||
} |
|||
isTrueBranFact, branFactCont := assessment.GetBranchFactory(userInfo.Attribute) |
|||
if isTrueBranFact == true { |
|||
sysAdminInfo.BranchFactoryName = branFactCont.Name |
|||
} |
|||
|
|||
isTrueRole, adminRoleCont := GetAdminRoleInfo(userInfo.Role) |
|||
if isTrueRole == true { |
|||
sysAdminInfo.RoleName = adminRoleCont.Title |
|||
sysAdminInfo.Jurisdiction = adminRoleCont.Jurisdiction |
|||
sysAdminInfo.MenuOper = adminRoleCont.MenuOper |
|||
sysAdminInfo.Wand = adminRoleCont.Wand |
|||
} |
|||
sysAdminInfo.KeyStr = strconv.FormatInt(userInfo.Key, 10) |
|||
isTrue = true |
|||
return |
|||
} |
|||
@ -0,0 +1,51 @@ |
|||
package systemuser |
|||
|
|||
import ( |
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/systemuser" |
|||
) |
|||
|
|||
type SystemUserApi struct{} |
|||
|
|||
//管理员列表查询
|
|||
type adminRequest struct { |
|||
commonus.PageSetLimt |
|||
GroupId int `json:"groupId"` |
|||
BranchFactoryId int `json:"branchFactoryId"` |
|||
RoleId int `json:"roleId"` |
|||
State int `json:"state"` |
|||
UserName string `json:"username"` |
|||
} |
|||
|
|||
//管理员输出
|
|||
type adminOutInfo struct { |
|||
systemuser.SystemAdminDetails |
|||
RoleName string `json:"roleName"` |
|||
GroupName string `json:"groupName"` |
|||
BranchFactoryName string `json:"branchFactoryName"` |
|||
KeyStr string `json:"keyStr"` |
|||
Jurisdiction string `json:"jurisdiction"` |
|||
MenuOper string `json:"menuoper"` |
|||
Wand int `json:"wand"` |
|||
} |
|||
|
|||
//角色相关
|
|||
type SystemRoleApi struct{} |
|||
|
|||
//菜单相关
|
|||
type SysTemMenuApi struct{} |
|||
|
|||
//菜单递给
|
|||
type SystemMenuThree struct { |
|||
Id int64 `json:"id"` |
|||
Title string `json:"title"` |
|||
State int `json:"state"` |
|||
ParentId int64 `json:"parentId"` |
|||
ApiUrl string `json:"apiUrl"` |
|||
Time int64 `json:"time"` |
|||
EiteTime int64 `json:"eiteTime"` |
|||
UserId int64 `json:"userId"` |
|||
Sort int `json:"sort"` |
|||
Child []SystemMenuThree `json:"child"` |
|||
MenuOperation []systemuser.MenuOperation `json:"menuOperation"` |
|||
} |
|||
@ -0,0 +1,179 @@ |
|||
package middleware |
|||
|
|||
import ( |
|||
"encoding/json" |
|||
"strconv" |
|||
|
|||
"github.com/flipped-aurora/gin-vue-admin/server/commonus" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/global" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/service" |
|||
"github.com/flipped-aurora/gin-vue-admin/server/utils/redishandel" |
|||
"github.com/gin-gonic/gin" |
|||
"github.com/mitchellh/mapstructure" |
|||
) |
|||
|
|||
//鉴权
|
|||
func MyAuthentication() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
userToken := c.Request.Header.Get("user-token") |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
|
|||
if userKey == "" || userToken == "" || userAgent == "" { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 1}, "未登录或非法访问", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
|
|||
redisClient := redishandel.RunRedis() |
|||
tokenInfo, isTrues := redisClient.HashGetAll("system:Identification_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKey) |
|||
var myCustomIdentify commonus.MyCustomLogonIdentify |
|||
if isTrues != true { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 2}, "您的帐户异地登陆或令牌失效", c) |
|||
c.Abort() |
|||
return |
|||
} else { |
|||
tokenErr := mapstructure.Decode(tokenInfo, &myCustomIdentify) |
|||
if tokenErr != nil { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 2}, "您的帐户异地登陆或令牌失效", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userAgent) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
sha1Str := myCustomIdentify.UserKey + myCustomIdentify.UserNumber + myCustomIdentify.UserPwd + md5Token |
|||
sha1Token := commonus.Sha1Encryption(sha1Str) |
|||
// fmt.Printf("token=========>%v---->%v---->%v\n", md5Token, sha1Token, userAgent)
|
|||
if sha1Token != userToken { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 3}, "授权已过期", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
} |
|||
redisClient.SetRedisTime(10800) |
|||
writeRedisData := map[string]interface{}{ |
|||
"userkey": myCustomIdentify.UserKey, |
|||
"usernumber": myCustomIdentify.UserNumber, |
|||
"userpwd": myCustomIdentify.UserPwd, |
|||
"usertoken": myCustomIdentify.UserToken, |
|||
} |
|||
redisClient.HashMsetAdd("system:Identification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+userKey, writeRedisData) |
|||
c.Next() |
|||
} |
|||
} |
|||
|
|||
var mycasbinService = service.ServiceGroupApp.SystemServiceGroup.CasbinService |
|||
|
|||
// 拦截器
|
|||
func MyCasbinHandler() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
// waitUse, _ := utils.GetClaims(c)
|
|||
// 获取请求的URI
|
|||
// obj := c.Request.URL.RequestURI()
|
|||
// 获取请求方法
|
|||
// act := c.Request.Method
|
|||
// 获取用户的角色
|
|||
// sub := waitUse.AuthorityId
|
|||
// e := mycasbinService.Casbin()
|
|||
// 判断策略中是否存在
|
|||
// success, _ := e.Enforce(sub, obj, act)
|
|||
|
|||
// fmt.Printf("=====>%v===========>%v===========>%v===========>%v\n", e, obj, act, e)
|
|||
|
|||
// if global.GVA_CONFIG.System.Env == "develop" || success {
|
|||
// c.Next()
|
|||
// } else {
|
|||
// response.FailWithDetailed(gin.H{}, "权限不足", c)
|
|||
// c.Abort()
|
|||
// return
|
|||
// }
|
|||
} |
|||
} |
|||
|
|||
func SystemAuthentication() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
userKey := c.Request.Header.Get("user-key") |
|||
userToken := c.Request.Header.Get("user-token") |
|||
userAgent := c.Request.Header.Get("User-Agent") |
|||
|
|||
if userKey == "" || userToken == "" || userAgent == "" { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 101}, "未登录或非法访问", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
redisClient := redishandel.RunRedis() |
|||
tokenInfo, isTrues := redisClient.HashGetAll("system:SystemIdentification_" + global.GVA_CONFIG.RedisPrefix.Alias + "_" + userKey) |
|||
var myCustomIdentify commonus.MyCustomAdminLogonIdentify |
|||
if isTrues != true { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 102}, "您的帐户异地登陆或令牌失效", c) |
|||
c.Abort() |
|||
return |
|||
} else { |
|||
tokenErr := mapstructure.Decode(tokenInfo, &myCustomIdentify) |
|||
if tokenErr != nil { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 103, "tokenErr": tokenErr}, "您的帐户异地登陆或令牌失效", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
var md5JiaMi commonus.Md5Encryption |
|||
md5JiaMi.Md5EncryptionInit(userAgent) |
|||
md5Token := md5JiaMi.Md5EncryptionAlgorithm() |
|||
sha1Str := myCustomIdentify.UserKey + myCustomIdentify.UserNumber + myCustomIdentify.UserPwd + md5Token |
|||
sha1Token := commonus.Sha1Encryption(sha1Str) |
|||
// fmt.Printf("token=========>%v---->%v---->%v\n", md5Token, sha1Token, userAgent)
|
|||
if sha1Token != userToken { |
|||
response.FailWithDetailed(gin.H{"reload": true, "code": 104}, "授权已过期", c) |
|||
c.Abort() |
|||
return |
|||
} |
|||
} |
|||
redisClient.SetRedisTime(10800) |
|||
writeRedisData := map[string]interface{}{ |
|||
"userkey": myCustomIdentify.UserKey, |
|||
"usernumber": myCustomIdentify.UserNumber, |
|||
"userpwd": myCustomIdentify.UserPwd, |
|||
"usertoken": myCustomIdentify.UserToken, |
|||
"jurisdiction": myCustomIdentify.Jurisdiction, |
|||
"menuOper": myCustomIdentify.MenuOper, |
|||
"wand": myCustomIdentify.Wand, |
|||
} |
|||
var surisdictionStr []string |
|||
var surisdictionInt []int64 |
|||
jsonErr := json.Unmarshal([]byte(myCustomIdentify.Jurisdiction), &surisdictionStr) |
|||
if jsonErr == nil { |
|||
for _, jurVal := range surisdictionStr { |
|||
jurValInt, jurValErr := strconv.ParseInt(jurVal, 10, 64) |
|||
if jurValErr == nil { |
|||
surisdictionInt = append(surisdictionInt, jurValInt) |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
global.Gva_Authority_Authentication = surisdictionInt |
|||
var menuOperStr []string |
|||
var menuOperInts []int64 |
|||
jsonErrSun := json.Unmarshal([]byte(myCustomIdentify.MenuOper), &menuOperStr) |
|||
if jsonErrSun == nil { |
|||
for _, menuOperVal := range menuOperStr { |
|||
menuOperInt, menuOperErr := strconv.ParseInt(menuOperVal, 10, 64) |
|||
if menuOperErr == nil { |
|||
menuOperInts = append(menuOperInts, menuOperInt) |
|||
} |
|||
|
|||
} |
|||
} |
|||
global.Gva_Authority_Authentication_Subsidiary = menuOperInts |
|||
redisClient.HashMsetAdd("system:SystemIdentification_"+global.GVA_CONFIG.RedisPrefix.Alias+"_"+userKey, writeRedisData) |
|||
c.Next() |
|||
} |
|||
} |
|||
|
|||
// 拦截器
|
|||
func SystemCasbinHandler() gin.HandlerFunc { |
|||
return func(c *gin.Context) { |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
package assessmentmodel |
|||
|
|||
//职责类别
|
|||
type DutyClass struct { |
|||
Id int64 `json:"id" gorm:"column:id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:title;type:varchar(255);comment:职责类别名称"` |
|||
Type int `json:"type" gorm:"column:type;type:tinyint(1) unsigned;default:1;not null;comment:类型(1:职能部门;2:生产部门)"` |
|||
Weight int `json:"weight" gorm:"column:weight;type:int(3) unsigned;default:0;not null;comment:权重比例"` |
|||
Time int64 `json:"time" gorm:"column:time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:state;type:tinyint(1) unsigned;default:1;not null;comment:状态"` |
|||
} |
|||
|
|||
func (DutyClass *DutyClass) TableName() string { |
|||
return "dutyclass" |
|||
} |
|||
|
|||
//履职考核表
|
|||
type DepartDuty struct { |
|||
Id int64 `json:"id" gorm:"column:de_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:de_title;type:varchar(255);comment:考核名称"` |
|||
State int `json:"state" gorm:"column:de_satte;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
Time int64 `json:"time" gorm:"column:de_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
PartId int64 `json:"partId" gorm:"column:de_partid;type:bigint(20) unsigned;default:0;not null;comment:部门ID"` |
|||
ClassId int64 `json:"classId" gorm:"column:de_class;type:bigint(20) unsigned;default:0;not null;comment:考核类别"` |
|||
AssessId int64 `json:"assessId" gorm:"column:de_assess;type:bigint(20) unsigned;default:0;not null;comment:考核项目"` |
|||
DutyId int64 `json:"dutyId" gorm:"column:de_duty;type:bigint(20) unsigned;default:0;not null;comment:具体职责"` |
|||
Rescore int64 `json:"rescore" gorm:"column:de_rescore;type:int(3) unsigned;default:0;not null;comment:参考分值"` |
|||
Group int64 `json:"group" gorm:"column:de_group;type:int(3) unsigned;default:0;not null;comment:集团"` |
|||
} |
|||
|
|||
func (DepartDuty *DepartDuty) TableName() string { |
|||
return "departduty" |
|||
} |
|||
|
|||
//职责详情
|
|||
type DutyContent struct { |
|||
Id int64 `json:"id" gorm:"column:dc_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:dc_title;type:text;comment:具体职责"` |
|||
Time int64 `json:"time" gorm:"column:dc_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:dc_state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
PartId int64 `json:"partId" gorm:"column:dc_parent;type:bigint(20) unsigned;default:0;not null;comment:父级"` |
|||
UserType int `json:"userType" gorm:"column:dc_user_type;type:tinyint(1) unsigned;default:1;not null;comment:考核部门类型(1:指定人;2:指定部门)"` |
|||
UserDump int64 `json:"userDump" gorm:"column:dc_user_dump;type:bigint(20) unsigned;default:0;not null;comment:考核人执行人"` |
|||
Dump int64 `json:"dump" gorm:"column:dc_dump;type:bigint(20) unsigned;default:0;not null;comment:考核执行部门"` |
|||
} |
|||
|
|||
func (DutyContent *DutyContent) TableName() string { |
|||
return "dutycontent" |
|||
} |
|||
|
|||
//考核项目
|
|||
type AssessMentitems struct { |
|||
Id int64 `json:"id" gorm:"column:ai_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:ai_title;type:varchar(255);comment:考核类别"` |
|||
Weight int `json:"weight" gorm:"column:ai_weight;type:int(3) unsigned;default:0;not null;comment:权重比例"` |
|||
Fraction int `json:"fraction" gorm:"column:ai_fraction;type:int(3) unsigned;default:0;not null;comment:分数"` |
|||
Content string `json:"content" gorm:"column:ai_content;type:text;comment:说明"` |
|||
PartId int64 `json:"partId" gorm:"column:ai_parent;type:bigint(20) unsigned;default:0;not null;comment:父级"` |
|||
Time int64 `json:"time" gorm:"column:ai_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
State int `json:"state" gorm:"column:ai_state;type:tinyint(1) unsigned;default:1;not null;comment:状态(1:启用;2:禁用;3:删除)"` |
|||
} |
|||
|
|||
func (AssessMentitems *AssessMentitems) TableName() string { |
|||
return "assessmentitems" |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package systemuser |
|||
|
|||
//菜单
|
|||
type SystemMenu struct { |
|||
Id int64 `json:"id" gorm:"column:m_id;type:bigint(20) unsigned;not null;comment:ID"` |
|||
Title string `json:"title" gorm:"column:m_title;type:varchar(255);not null;comment:菜单名称"` |
|||
State int `json:"state" gorm:"column:m_steat;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` |
|||
ParentId int64 `json:"parentId" gorm:"column:m_parent;type:bigint(30) unsigned;default:0;not null;comment:'父级(顶级:0)"` |
|||
ApiUrl string `json:"apiUrl" gorm:"column:m_url;type:varchar(255);not null;comment:地址"` |
|||
Time int64 `json:"time" gorm:"column:m_time;type:bigint(30) unsigned;default:0;not null;comment:创建时间"` |
|||
EiteTime int64 `json:"eiteTime" gorm:"column:m_eite_time;type:bigint(30) unsigned;default:0;not null;comment:修改时间"` |
|||
UserId int64 `json:"userId" gorm:"column:m_user_id;type:bigint(20) unsigned;not null;default:0;comment:写入人"` |
|||
Sort int `json:"sort" gorm:"column:m_sort;type:tinyint(3) unsigned;default:0;not null;comment:排序"` |
|||
} |
|||
|
|||
func (SystemMenu *SystemMenu) TableName() string { |
|||
return "system_menu" |
|||
} |
|||
|
|||
//菜单功能
|
|||
type MenuOperation struct { |
|||
OperId int64 `json:"operId" gorm:"column:oper_id;type:bigint(20) unsigned;not null;comment:功能ID"` |
|||
MenuId int64 `json:"menuId" gorm:"column:menu_id;type:bigint(20) unsigned;not null;default:0;comment:菜单id"` |
|||
OperTitle string `json:"operTitle" gorm:"column:oper_title;type:varchar(255);not null;comment:操作名称"` |
|||
} |
|||
|
|||
func (MenuOperation *MenuOperation) TableName() string { |
|||
return "menu_operation" |
|||
} |
|||
|
|||
//菜单管理
|
|||
type SystemMenuOperation struct { |
|||
SystemMenu |
|||
MenuOperation |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
package systemuser |
|||
|
|||
type SystemRole struct { |
|||
Id int64 `json:"id" gorm:"column:r_id;type:bigint(20) unsigned;not null;comment:Id"` |
|||
Title string `json:"title" gorm:"column:r_title;type:varchar(36);not null;comment:角色名称"` |
|||
State int `json:"state" gorm:"column:r_set;type:tinyint(1) unsigned;default:1;not null;comment:是否启用(1:启用;2:禁用;3:删除)"` |
|||
Attribute int64 `json:"attribute" gorm:"column:r_attribute;type:bigint(20) unsigned;default:0;not null;comment:属性"` |
|||
Gode int `json:"gode" gorm:"column:r_gode;type:tinyint(1) unsigned;default:1;not null;comment:继承属性(1:系统管理员;2:分厂管理员)"` |
|||
Time int64 `json:"time" gorm:"column:r_time;type:bigint(20) unsigned;default:0;not null;comment:创建时间"` |
|||
UserId int64 `json:"userId" gorm:"column:r_user_id;type:bigint(50) unsigned;default:0;not null;comment:写入人"` |
|||
Jurisdiction string `json:"jurisdiction" gorm:"column:r_jurisdiction;type:text;not null;comment:权限"` |
|||
MenuOper string `json:"menuoper" gorm:"column:r_menu_oper;type:text;not null;comment:权限"` |
|||
Wand int `json:"wand" gorm:"column:r_wand;type:tinyint(2) unsigned;default:0;not null;comment:权杖"` |
|||
Group int64 `json:"group" gorm:"column:r_group;type:bigint(20) unsigned;not null;default:3;comment:归属集团"` |
|||
} |
|||
|
|||
func (SystemRole *SystemRole) TableName() string { |
|||
return "system_role" |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
package assessment |
|||
|
|||
import ( |
|||
v2 "github.com/flipped-aurora/gin-vue-admin/server/api/index" |
|||
v1 "github.com/flipped-aurora/gin-vue-admin/server/api/v1" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type AssessmentRouter struct{} |
|||
|
|||
func (s *AssessmentRouter) InitAssessmentRouter(Router *gin.RouterGroup) { |
|||
dutyCodeRouter := Router.Group("duty") |
|||
var authorityApi = v1.ApiGroupApp.DutyHandleApi.DutyHandle |
|||
{ |
|||
dutyCodeRouter.POST("/", authorityApi.Index) // 入口
|
|||
dutyCodeRouter.POST("", authorityApi.Index) // 入口
|
|||
dutyCodeRouter.GET("/", authorityApi.Index) // 入口
|
|||
dutyCodeRouter.GET("", authorityApi.Index) // 入口
|
|||
dutyCodeRouter.POST("dutyclasslist", authorityApi.DutyClassList) // 考核类别
|
|||
dutyCodeRouter.POST("adddutyclass", authorityApi.AddDutyClass) // 添加考核类别
|
|||
dutyCodeRouter.POST("getdutyclassinfo", authorityApi.GetDutyClassInfo) // 查询考核类别详情
|
|||
dutyCodeRouter.POST("eitedutyclassinfo", authorityApi.EiteDutyClassInfo) // 编辑考核类别
|
|||
dutyCodeRouter.POST("statedutyclass", authorityApi.StateDutyClass) // 编辑考核类别状态或删除
|
|||
|
|||
dutyCodeRouter.POST("assessList", authorityApi.AssEssList) // 考核项目列表
|
|||
dutyCodeRouter.POST("addassessinfo", authorityApi.AddAssEssInfo) // 添加考核项目
|
|||
dutyCodeRouter.POST("getassessinfo", authorityApi.GetAssEssInfo) // 获取考核项目详情
|
|||
dutyCodeRouter.POST("eiteassessinfo", authorityApi.EiteAssEssInfo) // 修改考核项目详情
|
|||
dutyCodeRouter.POST("eiteassessstate", authorityApi.EiteAssEssState) // 修改状态或删除考核项目
|
|||
|
|||
dutyCodeRouter.POST("dutylist", authorityApi.DutyList) // 具体职责列表
|
|||
dutyCodeRouter.POST("adddutyinfo", authorityApi.AddDutyInfo) // 添加具体职责
|
|||
dutyCodeRouter.POST("getdutyinfo", authorityApi.GetDutyInfo) // 获取具体职责详情
|
|||
dutyCodeRouter.POST("eitedutyinfo", authorityApi.EiteDutyInfor) // 修改具体职责详情
|
|||
dutyCodeRouter.POST("eitedutystate", authorityApi.EiteDutyState) // 修改状态或删除具体职责
|
|||
|
|||
dutyCodeRouter.POST("specdutylist", authorityApi.SpecificDutyList) // 具体部门考核项目列表
|
|||
dutyCodeRouter.POST("addspecdutyinfo", authorityApi.AddSpecificDutyInfo) // 添加具体部门考核项目
|
|||
dutyCodeRouter.POST("getspecdutyinfo", authorityApi.GetSpecDutyCont) // 获取具体部门考核项目详情
|
|||
dutyCodeRouter.POST("eitespecdutyinfo", authorityApi.EiteSpecFicDutyInfo) // 修改具体部门考核项目详情
|
|||
dutyCodeRouter.POST("eitespecdutystate", authorityApi.EiteSpecficDutyState) // 修改状态或删除具体部门考核项目
|
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
func (s *AssessmentRouter) InitDutyHandelRouter(Router *gin.RouterGroup) { |
|||
dutyIndexCodeRouter := Router.Group("dutys") |
|||
var authorityIndexApi = v2.ApiGroupApp.AssessMentApi.Assessment |
|||
{ |
|||
dutyIndexCodeRouter.POST("/", authorityIndexApi.Index) // 入口
|
|||
dutyIndexCodeRouter.POST("", authorityIndexApi.Index) // 入口
|
|||
dutyIndexCodeRouter.GET("/", authorityIndexApi.Index) // 入口
|
|||
dutyIndexCodeRouter.GET("", authorityIndexApi.Index) // 入口
|
|||
} |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package assessment |
|||
|
|||
type RouterGroup struct { |
|||
AssessmentRouter |
|||
} |
|||
@ -0,0 +1,5 @@ |
|||
package staffrouter |
|||
|
|||
type RouterGroup struct { |
|||
StaffRouter |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
package staffrouter |
|||
|
|||
import ( |
|||
v1 "github.com/flipped-aurora/gin-vue-admin/server/api/v1" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type StaffRouter struct{} |
|||
|
|||
func (s *StaffRouter) InitStaffRouter(Router *gin.RouterGroup) { |
|||
staffRouter := Router.Group("staff") |
|||
var authorityApi = v1.ApiGroupApp.StaffApi.StaffPeople |
|||
{ |
|||
staffRouter.POST("", authorityApi.Index) //员工档案入口
|
|||
staffRouter.POST("/", authorityApi.Index) //员工档案入口
|
|||
staffRouter.GET("", authorityApi.Index) //员工档案入口
|
|||
staffRouter.GET("/", authorityApi.Index) //员工档案入口
|
|||
|
|||
staffRouter.POST("/stafflist", authorityApi.StaffList) //员工列表
|
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package system |
|||
|
|||
import ( |
|||
v1 "github.com/flipped-aurora/gin-vue-admin/server/api/v1" |
|||
"github.com/gin-gonic/gin" |
|||
) |
|||
|
|||
type AdminUserApi struct{} |
|||
|
|||
func (a *AdminUserApi) InitSystemAdminRouter(Router *gin.RouterGroup) { |
|||
adminRouter := Router.Group("systemadmin") |
|||
var authorityApi = v1.ApiGroupApp.SystemApi.SystemUserApi |
|||
{ |
|||
adminRouter.POST("", authorityApi.Index) //系统管理员档案入口
|
|||
adminRouter.POST("/", authorityApi.Index) //系统管理员档案入口
|
|||
adminRouter.GET("", authorityApi.Index) //系统管理员档案入口
|
|||
adminRouter.GET("/", authorityApi.Index) //系统管理员档案入口
|
|||
|
|||
adminRouter.POST("/adminlist", authorityApi.AdminList) //系统管理员列表
|
|||
} |
|||
//角色相关
|
|||
roleRouter := Router.Group("systemrole") |
|||
var roleApi = v1.ApiGroupApp.SystemApi.SystemRoleApi |
|||
{ |
|||
roleRouter.POST("/systemrolelist", roleApi.SystemRoleList) //系统管理员角色列表
|
|||
} |
|||
//菜单相关
|
|||
muneRouter := Router.Group("systemmenu") |
|||
var systemMuneApi = v1.ApiGroupApp.SystemApi.SysTemMenuApi |
|||
{ |
|||
muneRouter.POST("/systemmenulist", systemMuneApi.SystemMenuList) //系统菜单列表
|
|||
|
|||
muneRouter.POST("/getmenu", systemMuneApi.GetMenu) //获取系统做出菜单
|
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
import translate from './translate'; |
|||
|
|||
|
|||
export default function customTranslate(template, replacements) { |
|||
replacements = replacements || {}; |
|||
|
|||
// Translate
|
|||
template = translate[template] || template; |
|||
|
|||
// Replace
|
|||
return template.replace(/{([^}]+)}/g, function(_, key) { |
|||
|
|||
var str=replacements[key]; |
|||
if(translate[replacements[key]]!=null&&translate[replacements[key]]!='undefined'){ |
|||
str=translate[replacements[key]]; |
|||
} |
|||
return str || '{' + key + '}'; |
|||
|
|||
}); |
|||
} |
|||
@ -0,0 +1,256 @@ |
|||
export default { |
|||
'Activate the global connect tool': '激活全局连接工具', |
|||
'Append {type}': '添加 {type}', |
|||
'Add Lane above': '在上面添加道', |
|||
'Divide into two Lanes': '分割成两个道', |
|||
'Divide into three Lanes': '分割成三个道', |
|||
'Add Lane below': '在下面添加道', |
|||
'Append compensation activity': '追加补偿活动', |
|||
'Change type': '修改类型', |
|||
'Connect using Association': '使用关联连接', |
|||
'Connect using Sequence/MessageFlow or Association': '使用顺序/消息流或者关联连接', |
|||
'Connect using DataInputAssociation': '使用数据输入关联连接', |
|||
'Remove': '移除', |
|||
'Activate the hand tool': '激活抓手工具', |
|||
'Activate the lasso tool': '激活套索工具', |
|||
'Activate the create/remove space tool': '激活创建/删除空间工具', |
|||
'Create expanded SubProcess': '创建扩展子过程', |
|||
'Create IntermediateThrowEvent/BoundaryEvent': '创建中间抛出事件/边界事件', |
|||
'Create Pool/Participant': '创建池/参与者', |
|||
'Create Group':'创建组', |
|||
'Parallel Multi Instance': '并行多重事件', |
|||
'Sequential Multi Instance': '时序多重事件', |
|||
'DataObjectReference': '数据对象参考', |
|||
'DataStoreReference': '数据存储参考', |
|||
'Loop': '循环', |
|||
'Ad-hoc': '即席', |
|||
'Create {type}': '创建 {type}', |
|||
'Task': '任务', |
|||
'Send Task': '发送任务', |
|||
'Receive Task': '接收任务', |
|||
'User Task': '用户任务', |
|||
'Manual Task': '手工任务', |
|||
'Business Rule Task': '业务规则任务', |
|||
'Service Task': '服务任务', |
|||
'Script Task': '脚本任务', |
|||
'Call Activity': '调用活动', |
|||
'Sub Process (collapsed)': '子流程(折叠的)', |
|||
'Sub Process (expanded)': '子流程(展开的)', |
|||
'Start Event': '开始事件', |
|||
'StartEvent': '开始事件', |
|||
'Intermediate Throw Event': '中间事件', |
|||
'End Event': '结束事件', |
|||
'EndEvent': '结束事件', |
|||
'Create Gateway': '创建网关', |
|||
'Create ExclusiveGateway': '创建互斥网关', |
|||
'Create ParallelGateway': '创建并行网关', |
|||
'Create InclusiveGateway': '创建相容网关', |
|||
'Create ComplexGateway': '创建复杂网关', |
|||
'Create EventbasedGateway': '创建事件网关', |
|||
'Create Intermediate/Boundary Event': '创建中间/边界事件', |
|||
'Message Start Event': '消息开始事件', |
|||
'Timer Start Event': '定时开始事件', |
|||
'Conditional Start Event': '条件开始事件', |
|||
'Signal Start Event': '信号开始事件', |
|||
'Error Start Event': '错误开始事件', |
|||
'Escalation Start Event': '升级开始事件', |
|||
'Compensation Start Event': '补偿开始事件', |
|||
'Message Start Event (non-interrupting)': '消息开始事件(非中断)', |
|||
'Timer Start Event (non-interrupting)': '定时开始事件(非中断)', |
|||
'Conditional Start Event (non-interrupting)': '条件开始事件(非中断)', |
|||
'Signal Start Event (non-interrupting)': '信号开始事件(非中断)', |
|||
'Escalation Start Event (non-interrupting)': '升级开始事件(非中断)', |
|||
'Message Intermediate Catch Event': '消息中间捕获事件', |
|||
'Message Intermediate Throw Event': '消息中间抛出事件', |
|||
'Timer Intermediate Catch Event': '定时中间捕获事件', |
|||
'Escalation Intermediate Throw Event': '升级中间抛出事件', |
|||
'Conditional Intermediate Catch Event': '条件中间捕获事件', |
|||
'Link Intermediate Catch Event': '链接中间捕获事件', |
|||
'Link Intermediate Throw Event': '链接中间抛出事件', |
|||
'Compensation Intermediate Throw Event': '补偿中间抛出事件', |
|||
'Signal Intermediate Catch Event': '信号中间捕获事件', |
|||
'Signal Intermediate Throw Event': '信号中间抛出事件', |
|||
'Message End Event': '消息结束事件', |
|||
'Escalation End Event': '定时结束事件', |
|||
'Error End Event': '错误结束事件', |
|||
'Cancel End Event': '取消结束事件', |
|||
'Compensation End Event': '补偿结束事件', |
|||
'Signal End Event': '信号结束事件', |
|||
'Terminate End Event': '终止结束事件', |
|||
'Message Boundary Event': '消息边界事件', |
|||
'Message Boundary Event (non-interrupting)': '消息边界事件(非中断)', |
|||
'Timer Boundary Event': '定时边界事件', |
|||
'Timer Boundary Event (non-interrupting)': '定时边界事件(非中断)', |
|||
'Escalation Boundary Event': '升级边界事件', |
|||
'Escalation Boundary Event (non-interrupting)': '升级边界事件(非中断)', |
|||
'Conditional Boundary Event': '条件边界事件', |
|||
'Conditional Boundary Event (non-interrupting)': '条件边界事件(非中断)', |
|||
'Error Boundary Event': '错误边界事件', |
|||
'Cancel Boundary Event': '取消边界事件', |
|||
'Signal Boundary Event': '信号边界事件', |
|||
'Signal Boundary Event (non-interrupting)': '信号边界事件(非中断)', |
|||
'Compensation Boundary Event': '补偿边界事件', |
|||
'Exclusive Gateway': '互斥网关', |
|||
'Parallel Gateway': '并行网关', |
|||
'Inclusive Gateway': '相容网关', |
|||
'Complex Gateway': '复杂网关', |
|||
'Event based Gateway': '事件网关', |
|||
'Transaction': '转运', |
|||
'Sub Process': '子流程', |
|||
'Event Sub Process': '事件子流程', |
|||
'Collapsed Pool': '折叠池', |
|||
'Expanded Pool': '展开池', |
|||
|
|||
// Errors
|
|||
'no parent for {element} in {parent}': '在{parent}里,{element}没有父类', |
|||
'no shape type specified': '没有指定的形状类型', |
|||
'flow elements must be children of pools/participants': '流元素必须是池/参与者的子类', |
|||
'out of bounds release': 'out of bounds release', |
|||
'more than {count} child lanes': '子道大于{count} ', |
|||
'element required': '元素不能为空', |
|||
'diagram not part of bpmn:Definitions': '流程图不符合bpmn规范', |
|||
'no diagram to display': '没有可展示的流程图', |
|||
'no process or collaboration to display': '没有可展示的流程/协作', |
|||
'element {element} referenced by {referenced}#{property} not yet drawn': '由{referenced}#{property}引用的{element}元素仍未绘制', |
|||
'already rendered {element}': '{element} 已被渲染', |
|||
'failed to import {element}': '导入{element}失败', |
|||
'Id must be a valid QName.':'编号必须以字母或下划线开头', |
|||
'Element must have an unique id.':'元素必须具有唯一的id', |
|||
|
|||
//属性面板的参数
|
|||
'Id': '编号', |
|||
'Name': '名称', |
|||
'General': '常规', |
|||
'Details': '详情', |
|||
'Message Name': '消息名称', |
|||
'Message': '消息', |
|||
'Initiator': '创建者', |
|||
'Asynchronous Continuations': '持续异步', |
|||
'Asynchronous Before': '异步前', |
|||
'Asynchronous After': '异步后', |
|||
'Job Configuration': '工作配置', |
|||
'Exclusive': '排除', |
|||
'Job Priority': '工作优先级', |
|||
'Retry Time Cycle': '重试时间周期', |
|||
'Documentation': '文档', |
|||
'Element Documentation': '元素文档', |
|||
'History Configuration': '历史配置', |
|||
'History Time To Live': '历史的生存时间', |
|||
'Forms': '表单', |
|||
'Form Key': '表单key', |
|||
'Form Fields': '表单字段', |
|||
'Business Key': '业务key', |
|||
'Form Field': '表单字段', |
|||
'ID': '编号', |
|||
'Type': '类型', |
|||
'Label': '名称', |
|||
'Default Value': '默认值', |
|||
'Validation': '校验', |
|||
'Add Constraint': '添加约束', |
|||
'Config': '配置', |
|||
'Properties': '属性', |
|||
'Add Property': '添加属性', |
|||
'Value': '值', |
|||
'Listeners': '监听器', |
|||
'Execution Listener': '执行监听', |
|||
'Event Type': '事件类型', |
|||
'Listener Type': '监听器类型', |
|||
'Java Class': 'Java类', |
|||
'Expression': '表达式', |
|||
'Must provide a value': '必须提供一个值', |
|||
'Delegate Expression': '代理表达式', |
|||
'Script': '脚本', |
|||
'Script Format': '脚本格式', |
|||
'Script Type': '脚本类型', |
|||
'Inline Script': '内联脚本', |
|||
'External Script': '外部脚本', |
|||
'Resource': '资源', |
|||
'Field Injection': '字段注入', |
|||
'Extensions': '扩展', |
|||
'Input/Output': '输入/输出', |
|||
'Input Parameters': '输入参数', |
|||
'Output Parameters': '输出参数', |
|||
'Parameters': '参数', |
|||
'Output Parameter': '输出参数', |
|||
'Timer Definition Type': '定时器定义类型', |
|||
'Timer Definition': '定时器定义', |
|||
'Date': '日期', |
|||
'Duration': '持续', |
|||
'Cycle': '循环', |
|||
'Signal': '信号', |
|||
'Signal Name': '信号名称', |
|||
'Escalation': '升级', |
|||
'Error': '错误', |
|||
'Link Name': '链接名称', |
|||
'Condition': '条件名称', |
|||
'Variable Name': '变量名称', |
|||
'Variable Event': '变量事件', |
|||
'Specify more than one variable change event as a comma separated list.': '多个变量事件以逗号隔开', |
|||
'Wait for Completion': '等待完成', |
|||
'Activity Ref': '活动参考', |
|||
'Version Tag': '版本标签', |
|||
'Executable': '可执行文件', |
|||
'External Task Configuration': '扩展任务配置', |
|||
'Task Priority': '任务优先级', |
|||
'External': '外部', |
|||
'Connector': '连接器', |
|||
'Must configure Connector': '必须配置连接器', |
|||
'Connector Id': '连接器编号', |
|||
'Implementation': '实现方式', |
|||
'Field Injections': '字段注入', |
|||
'Fields': '字段', |
|||
'Result Variable': '结果变量', |
|||
'Topic': '主题', |
|||
'Configure Connector': '配置连接器', |
|||
'Input Parameter': '输入参数', |
|||
'Assignee': '代理人', |
|||
'Candidate Users': '候选用户', |
|||
'Candidate Groups': '候选组', |
|||
'Due Date': '到期时间', |
|||
'Follow Up Date': '跟踪日期', |
|||
'Priority': '优先级', |
|||
'The follow up date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00', |
|||
'The due date as an EL expression (e.g. ${someDate} or an ISO date (e.g. 2015-06-26T09:54:00)': '跟踪日期必须符合EL表达式,如: ${someDate} ,或者一个ISO标准日期,如:2015-06-26T09:54:00', |
|||
'Variables': '变量', |
|||
'Create DataObjectReference': '创建数据对象', |
|||
'Create Task': '创建任务', |
|||
'Create SendTask': '创建发送任务', |
|||
'Create ReceiveTask': '创建接收任务', |
|||
'Create UserTask': '创建用户任务', |
|||
'Create ManualTask': '创建手工任务', |
|||
'Create BusinessRuleTask': '创建业务规则任务', |
|||
'Create ServiceTask': '创建服务任务', |
|||
'Create ScriptTask': '创建脚本任务', |
|||
'Create CallActivityTask': '创建调用活动', |
|||
'Create SubProcessCollapsed': '创建子流程(折叠的)', |
|||
'Create SubProcessExpanded': '创建子流程(展开的)', |
|||
'Create StartEvent': '创建开始事件', |
|||
'Create EndEvent': '创建结束事件', |
|||
'Create DataStoreReference': '创建数据存储引用', |
|||
'Tasklist Configuration': '任务列表配置', |
|||
'Candidate Starter Configuration': '候选启动程序配置', |
|||
'Candidate Starter Groups': '候选启动组', |
|||
'Candidate Starter Users': '候选启动器用户', |
|||
'Specify more than one group as a comma separated list.':'将多个组指定为逗号分隔的列表。', |
|||
'Specify more than one user as a comma separated list.':'将多个用户指定为逗号分隔的列表。', |
|||
'This maps to the process definition key.':'映射到流程定义键。', |
|||
'Startable':'可启动', |
|||
'TextAnnotation':'文本批注', |
|||
'Append Intermediate/Boundary Event':'追加中间/边界事件', |
|||
'Append EndEvent':'附加事件', |
|||
'Append Gateway':'附加网关', |
|||
'Append Task':'追加任务', |
|||
'Parameter must have a name':'参数必须有名称', |
|||
'CallActivity Type':'调用活动类型', |
|||
'In Mapping':'在映射中', |
|||
'Out Mapping':'输出映射', |
|||
'Case Ref':'参考案例', |
|||
'Binding':'捆绑', |
|||
'Tenant Id':'机构ID', |
|||
'deployment':'调度。', |
|||
'Source':'来源', |
|||
'Target':'目标', |
|||
'Mapping must have a source':'映射必须有一个源', |
|||
'Mapping must have a target':'映射必须有一个目标', |
|||
'Task Listener':'任务侦听器', |
|||
}; |
|||
@ -1,15 +1,209 @@ |
|||
<template> |
|||
<div> |
|||
人事管理 |
|||
<div class="processDrawBody"> |
|||
<el-button-group> |
|||
<el-button size="mini" @click="showProcessInfo">xml数据</el-button> |
|||
<el-button type="primary" size="mini" @click="handleUndo">撤销</el-button> |
|||
<el-button type="success" size="mini" @click="handleRedo">恢复</el-button> |
|||
<el-button type="warning" size="mini" @click="handleDownload">下载</el-button> |
|||
<el-upload |
|||
style="display: inline-block;" |
|||
:file-list="fileList" |
|||
class="upload-demo" |
|||
action="" |
|||
:auto-upload="false" |
|||
:show-file-list="false" |
|||
:http-request="httpRequest" |
|||
:on-change="handleOnchangeFile" |
|||
:on-remove="handleRemove" |
|||
:before-remove="beforeRemove" |
|||
> |
|||
<el-button type="danger" size="mini">导入</el-button> |
|||
</el-upload> |
|||
</el-button-group> |
|||
<div class="containerBox" style="position: relative;"> |
|||
<div id="container"> |
|||
</div> |
|||
<div id="js-properties-panel" class="panel"></div> |
|||
</div> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
import { markRaw } from 'vue'; |
|||
// bpmn-js相关 |
|||
import 'bpmn-js/dist/assets/diagram-js.css'; |
|||
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'; |
|||
import BpmnModeler from 'bpmn-js/lib/Modeler'; |
|||
// bpmn-js-properties-panel相关 |
|||
import 'bpmn-js-properties-panel/dist/assets/bpmn-js-properties-panel.css' |
|||
import propertiesPanelModule from 'bpmn-js-properties-panel' |
|||
import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda' |
|||
import camundaModdleDescriptor from 'camunda-bpmn-moddle/resources/camunda' |
|||
|
|||
import CustomTranslate from '../language/CustomTranslate.js'; |
|||
|
|||
export default { |
|||
props: ['deploymentId'], |
|||
data() { |
|||
return { |
|||
containerEl: null, |
|||
bpmnModeler: null, |
|||
fileList: [] |
|||
}; |
|||
}, |
|||
mounted() { |
|||
// 初始化流程图 |
|||
this.init(); |
|||
}, |
|||
methods: { |
|||
/** |
|||
* 初始化流程图 |
|||
*/ |
|||
init() { |
|||
var customTranslate = { |
|||
translate: ['value', CustomTranslate] |
|||
}; |
|||
this.containerEl = document.getElementById('container'); |
|||
// 加markRaw去除双向绑定作用域 |
|||
this.bpmnModeler = markRaw(new BpmnModeler({ |
|||
container: this.containerEl, |
|||
// 添加控制板 |
|||
propertiesPanel: { |
|||
parent: '#js-properties-panel' |
|||
}, |
|||
// 右侧属性面板 |
|||
additionalModules: [ |
|||
propertiesPanelModule, |
|||
propertiesProviderModule, |
|||
customTranslate |
|||
], |
|||
moddleExtensions: { |
|||
camunda: camundaModdleDescriptor |
|||
} |
|||
})); |
|||
this.bpmnModeler.createDiagram(() => { |
|||
this.bpmnModeler.get('canvas').zoom('fit-viewport'); |
|||
}); |
|||
let _this = this; |
|||
// 如果deploymentId存在,则为编辑,导入xml信息 |
|||
if (_this.deploymentId) { |
|||
getProcessXml({"deploymentId":_this.deploymentId}) |
|||
.then((res) => { |
|||
_this.bpmnModeler.importXML(res.data, (err) => { |
|||
this.$message.success('加载成功!'); |
|||
}); |
|||
}) |
|||
.catch((error) => { |
|||
this.$message.error('获取流程信息失败'); |
|||
}); |
|||
} |
|||
}, |
|||
handleRemove(file) { |
|||
for (let i = 0; i < this.fileList.length; i++) { |
|||
if (file.name === this.fileList[i].name) { |
|||
this.fileList.splice(i, 1); |
|||
} |
|||
} |
|||
}, |
|||
beforeRemove(file) { |
|||
return this.$confirm(`确定移除 ${file.name}?`); |
|||
}, |
|||
// 后退 |
|||
handleUndo() { |
|||
this.bpmnModeler.get('commandStack').undo(); |
|||
}, |
|||
// 前进 |
|||
handleRedo() { |
|||
this.bpmnModeler.get('commandStack').redo(); |
|||
}, |
|||
// 下载 |
|||
handleDownload() { |
|||
this.bpmnModeler.saveXML({format: true}, (err, data) => { |
|||
const dataTrack = 'bpmn'; |
|||
const a = document.createElement('a'); |
|||
const name = `diagram.${dataTrack}`; |
|||
a.setAttribute( |
|||
'href', |
|||
`data:application/bpmn20-xml;charset=UTF-8,${encodeURIComponent(data)}` |
|||
); |
|||
a.setAttribute('target', '_blank'); |
|||
a.setAttribute('dataTrack', `diagram:download-${dataTrack}`); |
|||
a.setAttribute('download', name); |
|||
document.body.appendChild(a); |
|||
a.click(); |
|||
document.body.removeChild(a); |
|||
}); |
|||
}, |
|||
// 导入成功回调 |
|||
handleOnchangeFile(file) { |
|||
const reader = new FileReader(); |
|||
let data = ''; |
|||
reader.readAsText(file.raw); |
|||
reader.onload = (event) => { |
|||
data = event.target.result; |
|||
this.bpmnModeler.importXML(data, (err) => { |
|||
debugger |
|||
if (err) { |
|||
this.$message.info('导入失败'); |
|||
} else { |
|||
this.$message.success('导入成功'); |
|||
} |
|||
}); |
|||
}; |
|||
}, |
|||
// 取xml信息 |
|||
showProcessInfo() { |
|||
this.bpmnModeler.saveXML({format: true}, (err, data) => { |
|||
alert(data); |
|||
console.log(data) |
|||
}); |
|||
}, |
|||
/** |
|||
* 保存 |
|||
*/ |
|||
save() { |
|||
this.bpmnModeler.saveXML({format: true}, (err, data) => { |
|||
let processInfo = {}; |
|||
processInfo.xml = data.replace(/camunda/ig,"activiti"); |
|||
processInfo.processId = document.getElementById("camunda-id").value; |
|||
processInfo.processName = document.getElementById("camunda-name").innerHTML; |
|||
processDeployment(processInfo) |
|||
.then((res) => { |
|||
console.log(res); |
|||
}) |
|||
.catch((error) => { |
|||
console.log(error); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
|
|||
<style> |
|||
.processDrawBody { |
|||
height: 100%; |
|||
text-align: left; |
|||
} |
|||
.containerBox { |
|||
height: 100%; |
|||
} |
|||
.containerBox #container { |
|||
height: 100%; |
|||
border: 1px solid rgb(121, 121, 121); |
|||
} |
|||
.bpp-properties-panel [type=text] { |
|||
box-sizing: border-box; |
|||
} |
|||
.panel { |
|||
width: 400px; |
|||
position: absolute; |
|||
top: 1px; |
|||
right: 1px; |
|||
height:100%; |
|||
overflow: auto; |
|||
} |
|||
/* 右下角logo */ |
|||
.bjs-powered-by { |
|||
display: none; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue