0.5.4 非管理员可创建属于自己的任务

This commit is contained in:
磷叶 2025-02-28 10:35:35 +08:00
parent 0e57e9916a
commit e68b6444b1
7 changed files with 69 additions and 21 deletions

View File

@ -69,7 +69,6 @@ export default {
getOptions() {
listDept().then(response => {
this.options = this.handleTree(response.data, "deptId", "parentId", "children");
console.log(this.options);
});
},
}

View File

@ -54,7 +54,7 @@ export default {
},
mainValue: {
type: Number,
required: true
default: null,
},
mainLabel: {
type: String,

View File

@ -137,3 +137,8 @@ export const BriefKeys = {
CUSTOMER_SOON_FOLLOW: "customerSoonFollow", // 即将需要跟进的客户
}
// 角色
export const Role = {
SYS_ADMIN: "sys_admin", // 系统管理员
ADMIN: "admin", // 管理员
}

View File

@ -92,7 +92,7 @@
<script>
import { getCustomer, addCustomer, updateCustomer } from "@/api/bst/customer";
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 UserSelect from '@/components/Business/User/UserSelect.vue';
import CustomerFollowForm from '@/views/bst/customerFollow/components/CustomerFollowForm.vue';
@ -149,7 +149,7 @@ export default {
...mapGetters(['userId']),
//
disabledFollowUser() {
return !checkRole(['sys_admin', 'admin']);
return !checkRole([Role.SYS_ADMIN, Role.ADMIN]);
},
title() {
return this.id ? '修改客户' : '新增客户';

View File

@ -8,7 +8,7 @@
@close="handleClose"
@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>
<form-col :span="24" label="项目" prop="projectId">
<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 FormCol from "@/components/FormCol/index.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 { FileType } from '@/utils/constants';
import { checkRole } from '@/utils/permission';
import { mapGetters } from 'vuex';
export default {
name: "TaskEditDialog",
@ -107,6 +109,7 @@ export default {
};
},
computed: {
...mapGetters(['userId']),
title() {
return this.id ? '修改任务' : '新增任务';
},
@ -120,19 +123,38 @@ export default {
}
},
methods: {
/**
* 过滤可选择的负责人列表
* @param {Array} data 用户列表数据
* @returns {Array} 过滤后的用户列表
*/
filterOwnerMethod(data) {
console.log("filterOwnerMethod", data, this.form);
if (this.form.projectId == null) {
return data;
// ,
if (this.form.projectId) {
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 item.userId === this.form.projectOwnerId || item.userId === this.form.projectFollowId || this.form.projectMemberIds.includes(item.userId);
});
return userList;
return data;
},
onChangeProject(project) {
this.form.projectOwnerId = project.ownerId;

View File

@ -164,14 +164,14 @@
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-has-permi="['bst:task:edit']"
v-if="canEdit(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-has-permi="['bst:task:remove']"
v-if="canDel(scope.row)"
>删除</el-button>
</template>
</el-table-column>

View File

@ -1,5 +1,5 @@
import { TaskStatus } from '@/utils/enums';
import { checkPermi } from '@/utils/permission';
import { Role, TaskStatus } from '@/utils/enums';
import { checkPermi, checkRole } from '@/utils/permission';
import { mapGetters } from 'vuex';
export const $task = {
computed: {
@ -17,7 +17,8 @@ export const $task = {
canCancel() {
return (row) => {
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'])
&& 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;
}
}
}
}