0.5.4 非管理员可创建属于自己的任务
This commit is contained in:
parent
0e57e9916a
commit
e68b6444b1
|
@ -69,7 +69,6 @@ export default {
|
||||||
getOptions() {
|
getOptions() {
|
||||||
listDept().then(response => {
|
listDept().then(response => {
|
||||||
this.options = this.handleTree(response.data, "deptId", "parentId", "children");
|
this.options = this.handleTree(response.data, "deptId", "parentId", "children");
|
||||||
console.log(this.options);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ export default {
|
||||||
},
|
},
|
||||||
mainValue: {
|
mainValue: {
|
||||||
type: Number,
|
type: Number,
|
||||||
required: true
|
default: null,
|
||||||
},
|
},
|
||||||
mainLabel: {
|
mainLabel: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -137,3 +137,8 @@ export const BriefKeys = {
|
||||||
CUSTOMER_SOON_FOLLOW: "customerSoonFollow", // 即将需要跟进的客户
|
CUSTOMER_SOON_FOLLOW: "customerSoonFollow", // 即将需要跟进的客户
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 角色
|
||||||
|
export const Role = {
|
||||||
|
SYS_ADMIN: "sys_admin", // 系统管理员
|
||||||
|
ADMIN: "admin", // 管理员
|
||||||
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { getCustomer, addCustomer, updateCustomer } from "@/api/bst/customer";
|
import { getCustomer, addCustomer, updateCustomer } from "@/api/bst/customer";
|
||||||
import FormCol from "@/components/FormCol/index.vue";
|
import FormCol from "@/components/FormCol/index.vue";
|
||||||
import { CustomerStatus, CustomerIntentLevel } from '@/utils/enums';
|
import { CustomerStatus, CustomerIntentLevel, Role } from '@/utils/enums';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
import UserSelect from '@/components/Business/User/UserSelect.vue';
|
import UserSelect from '@/components/Business/User/UserSelect.vue';
|
||||||
import CustomerFollowForm from '@/views/bst/customerFollow/components/CustomerFollowForm.vue';
|
import CustomerFollowForm from '@/views/bst/customerFollow/components/CustomerFollowForm.vue';
|
||||||
|
@ -149,7 +149,7 @@ export default {
|
||||||
...mapGetters(['userId']),
|
...mapGetters(['userId']),
|
||||||
// 禁用选择跟进人的情况
|
// 禁用选择跟进人的情况
|
||||||
disabledFollowUser() {
|
disabledFollowUser() {
|
||||||
return !checkRole(['sys_admin', 'admin']);
|
return !checkRole([Role.SYS_ADMIN, Role.ADMIN]);
|
||||||
},
|
},
|
||||||
title() {
|
title() {
|
||||||
return this.id ? '修改客户' : '新增客户';
|
return this.id ? '修改客户' : '新增客户';
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
@close="handleClose"
|
@close="handleClose"
|
||||||
@open="handleOpen"
|
@open="handleOpen"
|
||||||
>
|
>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px" v-loading="loading">
|
<el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px" v-loading="loading">
|
||||||
<el-row>
|
<el-row>
|
||||||
<form-col :span="24" label="项目" prop="projectId">
|
<form-col :span="24" label="项目" prop="projectId">
|
||||||
<project-select v-model="form.projectId" :disabled="initData.projectId != null" @change="onChangeProject"/>
|
<project-select v-model="form.projectId" :disabled="initData.projectId != null" @change="onChangeProject"/>
|
||||||
|
@ -54,9 +54,11 @@
|
||||||
import { getTask, addTask, updateTask } from "@/api/bst/task";
|
import { getTask, addTask, updateTask } from "@/api/bst/task";
|
||||||
import FormCol from "@/components/FormCol/index.vue";
|
import FormCol from "@/components/FormCol/index.vue";
|
||||||
import ProjectSelect from '@/components/Business/Project/ProjectSelect.vue';
|
import ProjectSelect from '@/components/Business/Project/ProjectSelect.vue';
|
||||||
import { TaskType, TaskLevel } from '@/utils/enums';
|
import { TaskType, TaskLevel, Role } from '@/utils/enums';
|
||||||
import UserSelect from '@/components/Business/User/UserSelect.vue';
|
import UserSelect from '@/components/Business/User/UserSelect.vue';
|
||||||
import { FileType } from '@/utils/constants';
|
import { FileType } from '@/utils/constants';
|
||||||
|
import { checkRole } from '@/utils/permission';
|
||||||
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TaskEditDialog",
|
name: "TaskEditDialog",
|
||||||
|
@ -107,6 +109,7 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters(['userId']),
|
||||||
title() {
|
title() {
|
||||||
return this.id ? '修改任务' : '新增任务';
|
return this.id ? '修改任务' : '新增任务';
|
||||||
},
|
},
|
||||||
|
@ -120,19 +123,38 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
/**
|
||||||
|
* 过滤可选择的负责人列表
|
||||||
|
* @param {Array} data 用户列表数据
|
||||||
|
* @returns {Array} 过滤后的用户列表
|
||||||
|
*/
|
||||||
filterOwnerMethod(data) {
|
filterOwnerMethod(data) {
|
||||||
console.log("filterOwnerMethod", data, this.form);
|
// 如果选择了项目,需要判断项目相关人员是否存在
|
||||||
if (this.form.projectId == null) {
|
if (this.form.projectId) {
|
||||||
return data;
|
const { projectOwnerId, projectFollowId, projectMemberIds } = this.form;
|
||||||
|
|
||||||
|
// 项目相关人员信息不完整时返回空数组
|
||||||
|
if (!projectOwnerId || !projectFollowId || !projectMemberIds) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取项目相关人员ID列表(负责人、跟进人、成员)
|
||||||
|
const projectUserIds = [
|
||||||
|
projectOwnerId,
|
||||||
|
projectFollowId,
|
||||||
|
...projectMemberIds
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
// 过滤出项目相关人员
|
||||||
|
data = data.filter(item => projectUserIds.includes(item.userId));
|
||||||
}
|
}
|
||||||
if (this.form.projectOwnerId == null || this.form.projectFollowId == null || this.form.projectMemberIds == null) {
|
|
||||||
return [];
|
// 非管理员只能选择自己
|
||||||
|
if (!checkRole([Role.SYS_ADMIN, Role.ADMIN])) {
|
||||||
|
data = data.filter(item => item.userId === this.userId);
|
||||||
}
|
}
|
||||||
// 过滤,项目负责人、项目跟进人、项目成员
|
|
||||||
let userList = data.filter(item => {
|
return data;
|
||||||
return item.userId === this.form.projectOwnerId || item.userId === this.form.projectFollowId || this.form.projectMemberIds.includes(item.userId);
|
|
||||||
});
|
|
||||||
return userList;
|
|
||||||
},
|
},
|
||||||
onChangeProject(project) {
|
onChangeProject(project) {
|
||||||
this.form.projectOwnerId = project.ownerId;
|
this.form.projectOwnerId = project.ownerId;
|
||||||
|
|
|
@ -164,14 +164,14 @@
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-edit"
|
icon="el-icon-edit"
|
||||||
@click="handleUpdate(scope.row)"
|
@click="handleUpdate(scope.row)"
|
||||||
v-has-permi="['bst:task:edit']"
|
v-if="canEdit(scope.row)"
|
||||||
>修改</el-button>
|
>修改</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-delete"
|
icon="el-icon-delete"
|
||||||
@click="handleDelete(scope.row)"
|
@click="handleDelete(scope.row)"
|
||||||
v-has-permi="['bst:task:remove']"
|
v-if="canDel(scope.row)"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { TaskStatus } from '@/utils/enums';
|
import { Role, TaskStatus } from '@/utils/enums';
|
||||||
import { checkPermi } from '@/utils/permission';
|
import { checkPermi, checkRole } from '@/utils/permission';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
export const $task = {
|
export const $task = {
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -17,7 +17,8 @@ export const $task = {
|
||||||
canCancel() {
|
canCancel() {
|
||||||
return (row) => {
|
return (row) => {
|
||||||
return checkPermi(['bst:task:cancel'])
|
return checkPermi(['bst:task:cancel'])
|
||||||
&& TaskStatus.canCancel().includes(row.status);
|
&& TaskStatus.canCancel().includes(row.status)
|
||||||
|
&& (checkRole([Role.SYS_ADMIN, Role.ADMIN]) || this.isCreator(row));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 是否可以完成
|
// 是否可以完成
|
||||||
|
@ -26,6 +27,27 @@ export const $task = {
|
||||||
return checkPermi(['bst:task:pass'])
|
return checkPermi(['bst:task:pass'])
|
||||||
&& TaskStatus.canPass().includes(row.status);
|
&& TaskStatus.canPass().includes(row.status);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 是否可以修改
|
||||||
|
canEdit() {
|
||||||
|
return (row) => {
|
||||||
|
return checkPermi(['bst:task:edit'])
|
||||||
|
&& (checkRole([Role.SYS_ADMIN, Role.ADMIN]) || this.isCreator(row));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 是否可以删除
|
||||||
|
canDel() {
|
||||||
|
return (row) => {
|
||||||
|
return checkPermi(['bst:task:remove'])
|
||||||
|
&& (checkRole([Role.SYS_ADMIN, Role.ADMIN]) || this.isCreator(row));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 是否是创建者
|
||||||
|
isCreator() {
|
||||||
|
return (row) => {
|
||||||
|
console.log("isCreator", row, this.userId);
|
||||||
|
return row.createId === this.userId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user