Browse Source

后台 工时页面 爆红处理

master
zhanyunjiu 3 years ago
parent
commit
509bc328da
  1. 66
      src/views/farm/workHour/index.vue

66
src/views/farm/workHour/index.vue

@ -43,7 +43,7 @@
<el-table-column label="id" align="center" prop="id" />
<el-table-column label="员工名" align="center" prop="userId" >
<template slot-scope="scope">
<span>{{cpUserList.find(t=>t.id == scope.row.userId).name}}</span>
<span>{{userConvert(scope.row.userId)}}</span>
</template>
</el-table-column>
<el-table-column label="项目名" align="center" prop="projectId" >
@ -53,7 +53,7 @@
</el-table-column>
<el-table-column label="任务名" align="center" prop="taskId" >
<template slot-scope="scope">
<span>{{taskList.find(t=>t.id == scope.row.taskId).name}}</span>
<span>{{taskConvert(scope.row.taskId)}}</span>
</template>
</el-table-column>
<el-table-column label="工时" align="center" prop="hour" />
@ -94,10 +94,10 @@
<el-option
v-for="item in selectTaskList"
:key="item.id"
:label="item.name"
:label="item.taskName +'/'+ item.taskMsg"
:value="item.id"
@change="chooseTask">
{{item.name}}
{{item.taskName +"/"+ item.taskMsg}}
</el-option>
</el-select>
</el-form-item>
@ -129,6 +129,7 @@ import { createWorkHour, updateWorkHour, deleteWorkHour, getWorkHour, getWorkHou
import { getProjectPage} from "@/api/farm/project";
import { getTaskPage} from "@/api/farm/task";
import { getCpUserPage} from "@/api/system/cpUser"
import { getTaskCatePage} from "@/api/farm/taskCate"
export default {
@ -172,24 +173,31 @@ export default {
taskList:[],
selectTaskList:[],
cpUserList:[],
selectCpUserList:[]
selectCpUserList:[],
taskCateList:[]
};
},
created() {
this.getProjectPageList();
this.getTaskPageList();
this.getCpUserPageList();
this.getList();
this.getTaskCateList();
},
methods: {
getTaskCateList(){
getTaskCatePage({
pageNo : 1,
pageSize : 100
}).then(res =>{
this.taskCateList = res.data.list;
this.getProjectPageList();
})
},
getProjectPageList(){
getProjectPage({
pageNo:1,
pageSize:100
}).then(res => {
this.projectList = res.data.list;
this.getTaskPageList();
})
},
getTaskPageList(){
@ -198,6 +206,7 @@ export default {
pageSize:100
}).then(res => {
this.taskList = res.data.list;
this.getCpUserPageList();
})
},
getCpUserPageList(){
@ -206,6 +215,7 @@ export default {
pageSize:400
}).then(res => {
this.cpUserList = res.data.list;
this.getList()
})
},
/** 查询列表 */
@ -356,24 +366,36 @@ export default {
chooseTask(row){
this.form.userId = undefined;
this.selectCpUserList = [];
let arr = this.selectTaskList.filter(t => t.id == row)
let userIdArr = [];
arr.forEach(item =>{
userIdArr = JSON.parse(item.executorPerson);
userIdArr.push(item.mainPerson);
let arr = this.selectTaskList.filter(t => t.id == row)[0];
let userIdList = [];
userIdList.push(arr.mainPerson);
arr.executorPerson.forEach(exe =>{
userIdList.push(exe);
})
let userArr = [];
userIdArr.forEach(item =>{
this.cpUserList.forEach(u =>{
if(u.id == item){
userArr.push(u);
let userList = [];
this.cpUserList.forEach(user =>{
userIdList.forEach(id =>{
if(user.id == id){
userList.push(user);
}
})
})
let mapp = new Set(userArr);
let mapp = new Set(userList);
let quchong = Array.from(mapp);
this.selectCpUserList = quchong;
}
},
userConvert(userId){
return this.cpUserList.filter(user => user.id == userId)[0].name;
},
taskConvert(taskId){
let task = this.taskList.filter(item => item.id == taskId)[0];
let cate = this.taskCateList.filter(cate => cate.id == task.taskCateId)[0].name;
let cateName = this.taskCateList.filter(cate => cate.id == task.taskCateName)[0].name;
return cate +"/"+ cateName;
},
}
};
</script>

Loading…
Cancel
Save