feat(oa): add owner person/dept fields with initiator defaults

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-07-30 17:54:48 +08:00
1 parent 3b46b10604
commit 4ebc2dbe82
18 files changed
+791 -15

No files matched your search

@@ -0,0 +1,45 @@
<!-- FormCreate:归属部门(默认当前登录人主部门;allowModify 控制可否改选) -->
<template>
<OaDeptSelect
:model-value="modelValue"
:disabled="effectiveDisabled"
:multiple="false"
:form-create-inject="formCreateInject"
@update:model-value="onUpdate"
@change="onChange"
/>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import OaDeptSelect from '@/components/oa-approval/OaDeptSelect.vue'
import type { OaDeptValueItem } from '@/utils/oa-dept-value'
defineOptions({ name: 'ownerDept' })
const props = withDefaults(
defineProps<{
modelValue?: unknown
disabled?: boolean
/** 是否允许改选;默认 false(只读展示默认值) */
allowModify?: boolean
formCreateInject?: Record<string, unknown>
}>(),
{ allowModify: false }
)
const emit = defineEmits<{
(e: 'update:modelValue', v: OaDeptValueItem | OaDeptValueItem[] | null): void
(e: 'change', v: OaDeptValueItem | OaDeptValueItem[] | null): void
}>()
const effectiveDisabled = computed(() => !!props.disabled || !props.allowModify)
function onUpdate(v: OaDeptValueItem | OaDeptValueItem[] | null) {
emit('update:modelValue', v)
}
function onChange(v: OaDeptValueItem | OaDeptValueItem[] | null) {
emit('change', v)
}
</script>
@@ -0,0 +1,45 @@
<!-- FormCreate:归属人(默认当前登录人;allowModify 控制可否改选) -->
<template>
<OaPersonSelect
:model-value="modelValue"
:disabled="effectiveDisabled"
:multiple="false"
:form-create-inject="formCreateInject"
@update:model-value="onUpdate"
@change="onChange"
/>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import OaPersonSelect from '@/components/oa-approval/OaPersonSelect.vue'
import type { OaPersonValueItem } from '@/utils/oa-person-value'
defineOptions({ name: 'ownerPerson' })
const props = withDefaults(
defineProps<{
modelValue?: unknown
disabled?: boolean
/** 是否允许改选;默认 false(只读展示默认值) */
allowModify?: boolean
formCreateInject?: Record<string, unknown>
}>(),
{ allowModify: false }
)
const emit = defineEmits<{
(e: 'update:modelValue', v: OaPersonValueItem | OaPersonValueItem[] | null): void
(e: 'change', v: OaPersonValueItem | OaPersonValueItem[] | null): void
}>()
const effectiveDisabled = computed(() => !!props.disabled || !props.allowModify)
function onUpdate(v: OaPersonValueItem | OaPersonValueItem[] | null) {
emit('update:modelValue', v)
}
function onChange(v: OaPersonValueItem | OaPersonValueItem[] | null) {
emit('change', v)
}
</script>
@@ -172,7 +172,7 @@
function isPersonLikeField(field: string) {
const t = meta(field)?.type
return t === 'person' || t === 'initiator'
return t === 'person' || t === 'ownerPerson' || t === 'initiator'
}
function isPostField(field: string) {
@@ -186,7 +186,9 @@
}
function defaultValueForType(type: string, opts?: ConditionCandidate['options']) {
if (type === 'person' || type === 'post' || type === 'initiator') return [] as string[]
if (type === 'person' || type === 'ownerPerson' || type === 'post' || type === 'initiator') {
return [] as string[]
}
return opts?.[0]?.value ?? ''
}
@@ -335,7 +337,7 @@
}
onMounted(() => {
if (props.candidates.some((c) => c.type === 'person' || c.type === 'initiator')) {
if (props.candidates.some((c) => c.type === 'person' || c.type === 'ownerPerson' || c.type === 'initiator')) {
loadUsers()
}
if (props.candidates.some((c) => c.type === 'post')) {
@@ -344,7 +346,10 @@
})
watch(
() => props.candidates.some((c) => c.type === 'person' || c.type === 'initiator'),
() =>
props.candidates.some(
(c) => c.type === 'person' || c.type === 'ownerPerson' || c.type === 'initiator'
),
(need) => {
if (need && !userOptions.value.length) loadUsers()
}
@@ -5,6 +5,7 @@ export const CONDITION_ELIGIBLE_TYPES = new Set([
'number',
'money',
'person',
'ownerPerson',
'post',
'radio',
'select',
@@ -32,7 +33,7 @@ export interface ConditionCandidate {
}
export function opsForFieldType(type: string): Array<{ value: ConditionOp; label: string }> {
if (type === 'person' || type === 'post' || type === 'initiator') {
if (type === 'person' || type === 'ownerPerson' || type === 'post' || type === 'initiator') {
return [{ value: 'contains', label: '包含' }]
}
// 单选/下拉为离散选项,仅等于/不等于;输入框常填数字参与区间比较,与数字/金额/日期同套运算符