仿钉钉流程设计- 表单字段权限设置

pull/452/head
jason 2024-06-27 09:30:02 +08:00
parent 6ad29c6a39
commit fae712b9d4
2 changed files with 61 additions and 5 deletions

View File

@ -413,6 +413,11 @@ const saveConfig = async () => {
if (!showText) return false if (!showText) return false
currentNode.value.candidateStrategy = configForm.value.candidateStrategy currentNode.value.candidateStrategy = configForm.value.candidateStrategy
currentNode.value.candidateParam = configForm.value.candidateParamArray?.join(',') currentNode.value.candidateParam = configForm.value.candidateParamArray?.join(',')
//
currentNode.value.approveMethod = configForm.value.approveMethod
if (configForm.value.approveMethod === ApproveMethodType.APPROVE_BY_RATIO) {
currentNode.value.approveRatio = configForm.value.approveRatio
}
// //
currentNode.value.rejectHandler = { currentNode.value.rejectHandler = {
type: configForm.value.rejectHandlerType, type: configForm.value.rejectHandlerType,
@ -547,6 +552,11 @@ const setCurrentNode = (node: SimpleFlowNode) => {
} else { } else {
notAllowedMultiApprovers.value = false notAllowedMultiApprovers.value = false
} }
//
configForm.value.approveMethod = node.approveMethod
if (node.approveMethod == ApproveMethodType.APPROVE_BY_RATIO) {
configForm.value.approveRatio = node.approveRatio
}
configForm.value.rejectHandlerType = node.rejectHandler?.type configForm.value.rejectHandlerType = node.rejectHandler?.type
configForm.value.returnNodeId = node.rejectHandler?.returnNodeId configForm.value.returnNodeId = node.rejectHandler?.returnNodeId
configForm.value.timeoutHandlerEnable = node.timeoutHandler?.enable configForm.value.timeoutHandlerEnable = node.timeoutHandler?.enable

View File

@ -200,7 +200,11 @@ const handleAudit = async (task, pass) => {
// 1.2 // 1.2
const elForm = unref(auditFormRef) const elForm = unref(auditFormRef)
if (!elForm) return if (!elForm) return
const valid = await elForm.validate() let valid = await elForm.validate()
if (!valid) return
//
if (!fApi.value) return
valid = await fApi.value.validate()
if (!valid) return if (!valid) return
// 2.1 // 2.1
@ -216,6 +220,9 @@ const handleAudit = async (task, pass) => {
await formCreateApi.validate() await formCreateApi.validate()
data.variables = approveForms.value[index].value data.variables = approveForms.value[index].value
} }
//
data.variables = getWritableValueOfForm(task.fieldsPermission)
await TaskApi.approveTask(data) await TaskApi.approveTask(data)
message.success('审批通过成功') message.success('审批通过成功')
} else { } else {
@ -251,11 +258,11 @@ const handleSign = async (task: any) => {
} }
/** 获得详情 */ /** 获得详情 */
const getDetail = () => { const getDetail = async () => {
// 1. // 1.
await getTaskList()
// 2.
getProcessInstance() getProcessInstance()
// 2.
getTaskList()
} }
/** 加载流程实例 */ /** 加载流程实例 */
@ -283,6 +290,15 @@ const getProcessInstance = async () => {
fApi.value?.btn.show(false) fApi.value?.btn.show(false)
fApi.value?.resetBtn.show(false) fApi.value?.resetBtn.show(false)
fApi.value?.disabled(true) fApi.value?.disabled(true)
//
if (runningTasks.value.length > 0) {
const task = runningTasks.value.at(0)
if (task.fieldsPermission) {
Object.keys(task.fieldsPermission).forEach((item) => {
setFieldPermission(item, task.fieldsPermission[item])
})
}
}
}) })
} else { } else {
// data.processDefinition.formCustomViewPath /crm/contract/detail/index.vue // data.processDefinition.formCustomViewPath /crm/contract/detail/index.vue
@ -353,6 +369,7 @@ const loadRunningTask = (tasks) => {
if (!task.assigneeUser || task.assigneeUser.id !== userId) { if (!task.assigneeUser || task.assigneeUser.id !== userId) {
return return
} }
// 2.3 // 2.3
runningTasks.value.push({ ...task }) runningTasks.value.push({ ...task })
auditForms.value.push({ auditForms.value.push({
@ -371,6 +388,35 @@ const loadRunningTask = (tasks) => {
}) })
} }
/**
* 设置表单权限
*/
const setFieldPermission = (field: string, permission: string) => {
if (permission === '1') {
fApi.value?.disabled(true, field)
}
if (permission === '2') {
fApi.value?.disabled(false, field)
}
if (permission === '3') {
fApi.value?.hidden(true, field)
}
}
/**
* 获取可以编辑字段的值
*/
const getWritableValueOfForm = (fieldsPermission: Object) => {
const fieldsValue = {}
if (fieldsPermission && fApi.value) {
Object.keys(fieldsPermission).forEach((item) => {
if (fieldsPermission[item] === '2') {
fieldsValue[item] = fApi.value.getValue(item)
}
})
}
return fieldsValue
}
/** 初始化 */ /** 初始化 */
const userOptions = ref<UserApi.UserVO[]>([]) // const userOptions = ref<UserApi.UserVO[]>([]) //
onMounted(async () => { onMounted(async () => {