|
|
@@ -285,6 +285,65 @@ const isRequiredExtProperty = (item: ExtPropertyItem) =>
|
|
|
|
|
|
const isDoubleExtProperty = (item: ExtPropertyItem) => item.dataType === 'double'
|
|
|
|
|
|
+const hasExtPropertyActualValue = (item: ExtPropertyItem) => {
|
|
|
+ const value = item.actualValue
|
|
|
+
|
|
|
+ return typeof value === 'string' ? value.trim() !== '' : value !== undefined && value !== null
|
|
|
+}
|
|
|
+
|
|
|
+const getExtPropertyScope = (item: ExtPropertyItem) =>
|
|
|
+ item.defaultValue === 'next' ? 'next' : 'current'
|
|
|
+
|
|
|
+const getExtPropertyAlternativeGroupKey = (item: ExtPropertyItem) => {
|
|
|
+ const value = String(item.maxValue ?? '').trim()
|
|
|
+
|
|
|
+ if (!value || parseNumberValue(value) !== undefined) return ''
|
|
|
+
|
|
|
+ return value
|
|
|
+}
|
|
|
+
|
|
|
+const getExtPropertyAlternativeGroups = (scope: string) => {
|
|
|
+ const groups = new Map<string, ExtPropertyItem[]>()
|
|
|
+
|
|
|
+ detailForm.value.extProperty.forEach((property) => {
|
|
|
+ if (!isRequiredExtProperty(property) || getExtPropertyScope(property) !== scope) return
|
|
|
+
|
|
|
+ const groupKey = getExtPropertyAlternativeGroupKey(property)
|
|
|
+ if (!groupKey) return
|
|
|
+
|
|
|
+ groups.set(groupKey, [...(groups.get(groupKey) || []), property])
|
|
|
+ })
|
|
|
+
|
|
|
+ return groups
|
|
|
+}
|
|
|
+
|
|
|
+const hasCompleteExtPropertyAlternativeGroup = (scope: string) =>
|
|
|
+ Array.from(getExtPropertyAlternativeGroups(scope).values()).some((items) =>
|
|
|
+ items.every(hasExtPropertyActualValue)
|
|
|
+ )
|
|
|
+
|
|
|
+const isAlternativeExtProperty = (item: ExtPropertyItem) => {
|
|
|
+ if (!getExtPropertyAlternativeGroupKey(item)) return false
|
|
|
+
|
|
|
+ return getExtPropertyAlternativeGroups(getExtPropertyScope(item)).size > 1
|
|
|
+}
|
|
|
+
|
|
|
+const getExtPropertyAlternativeProps = (item: ExtPropertyItem) =>
|
|
|
+ Array.from(getExtPropertyAlternativeGroups(getExtPropertyScope(item)).values())
|
|
|
+ .flat()
|
|
|
+ .map((property) => getExtPropertyProp(property))
|
|
|
+
|
|
|
+const handleExtPropertyValueChange = (item: ExtPropertyItem) => {
|
|
|
+ if (
|
|
|
+ !isAlternativeExtProperty(item) ||
|
|
|
+ !hasCompleteExtPropertyAlternativeGroup(getExtPropertyScope(item))
|
|
|
+ ) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ nextTick(() => detailFormRef.value?.clearValidate(getExtPropertyAlternativeProps(item)))
|
|
|
+}
|
|
|
+
|
|
|
const getExtPropertyLabel = (item: ExtPropertyItem) =>
|
|
|
item.unit ? `${item.name}(${item.unit})` : item.name
|
|
|
|
|
|
@@ -299,13 +358,27 @@ const getExtPropertyProp = (item: ExtPropertyItem) => {
|
|
|
const getExtPropertyRules = (item: ExtPropertyItem) => {
|
|
|
if (!isRequiredExtProperty(item)) return []
|
|
|
|
|
|
+ if (isAlternativeExtProperty(item)) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ validator: (_rule, _value, callback) => {
|
|
|
+ if (hasCompleteExtPropertyAlternativeGroup(getExtPropertyScope(item))) {
|
|
|
+ callback()
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ callback(new Error('请至少完整填写一种工作量'))
|
|
|
+ },
|
|
|
+ trigger: ['blur', 'change']
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+
|
|
|
return isDoubleExtProperty(item)
|
|
|
? requiredNumberRule(`请输入${item.name}`)
|
|
|
: requiredTextRule(`请输入${item.name}`)
|
|
|
}
|
|
|
|
|
|
-const getExtPropertyNumberBoundary = (value: unknown) => parseNumberValue(value)
|
|
|
-
|
|
|
const queryProjectNameSearch = (
|
|
|
queryString: string,
|
|
|
cb: (results: ProjectNameSuggestion[]) => void
|
|
|
@@ -525,14 +598,14 @@ onMounted(() => {
|
|
|
class="w-full!"
|
|
|
:controls="false"
|
|
|
:precision="2"
|
|
|
- :min="getExtPropertyNumberBoundary(item.minValue)"
|
|
|
- :max="getExtPropertyNumberBoundary(item.maxValue)" />
|
|
|
+ @change="handleExtPropertyValueChange(item)" />
|
|
|
<el-input
|
|
|
v-else
|
|
|
v-model="item.actualValue"
|
|
|
type="textarea"
|
|
|
:rows="3"
|
|
|
- :placeholder="`请输入${item.name}`" />
|
|
|
+ :placeholder="`请输入${item.name}`"
|
|
|
+ @input="handleExtPropertyValueChange(item)" />
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
<template v-else>
|
|
|
@@ -617,14 +690,14 @@ onMounted(() => {
|
|
|
class="w-full!"
|
|
|
:controls="false"
|
|
|
:precision="2"
|
|
|
- :min="getExtPropertyNumberBoundary(item.minValue)"
|
|
|
- :max="getExtPropertyNumberBoundary(item.maxValue)" />
|
|
|
+ @change="handleExtPropertyValueChange(item)" />
|
|
|
<el-input
|
|
|
v-else
|
|
|
v-model="item.actualValue"
|
|
|
type="textarea"
|
|
|
:rows="4"
|
|
|
- :placeholder="`请输入${item.name}`" />
|
|
|
+ :placeholder="`请输入${item.name}`"
|
|
|
+ @input="handleExtPropertyValueChange(item)" />
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
</section>
|