1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 23:20:12 +08:00

fix: Display logic field when set empty value in parent field. (#357)

This commit is contained in:
Edwin Betancourt 2020-02-25 09:18:35 -04:00 committed by GitHub
parent c4456850e2
commit 8f9c7f390d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 32 deletions

View File

@ -5,7 +5,7 @@
<el-col></el-col> container--> <el-col></el-col> container-->
<el-col <el-col
v-if="!inTable" v-if="!inTable"
v-show="isDisplayed()" v-show="isDisplayed"
key="is-panel-template" key="is-panel-template"
:xs="sizeFieldResponsive.xs" :xs="sizeFieldResponsive.xs"
:sm="sizeFieldResponsive.sm" :sm="sizeFieldResponsive.sm"
@ -19,7 +19,7 @@
> >
<template slot="label"> <template slot="label">
<field-operator-comparison <field-operator-comparison
v-if="isAdvancedQuery && isDisplayed()" v-if="isAdvancedQuery && isDisplayed"
key="is-field-operator-comparison" key="is-field-operator-comparison"
:field-attributes="fieldAttributes" :field-attributes="fieldAttributes"
:field-value="field.value" :field-value="field.value"
@ -70,7 +70,8 @@ import FieldOperatorComparison from '@/components/ADempiere/Field/fieldPopovers/
import FieldTranslated from '@/components/ADempiere/Field/fieldPopovers/fieldTranslated' import FieldTranslated from '@/components/ADempiere/Field/fieldPopovers/fieldTranslated'
import { FIELD_ONLY } from '@/components/ADempiere/Field/references' import { FIELD_ONLY } from '@/components/ADempiere/Field/references'
import { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize' import { DEFAULT_SIZE } from '@/components/ADempiere/Field/fieldSize'
import { fieldIsDisplayed } from '@/utils/ADempiere' import { fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
import { showMessage } from '@/utils/ADempiere/notification'
/** /**
* This is the base component for linking the components according to the * This is the base component for linking the components according to the
@ -141,11 +142,17 @@ export default {
// DOM properties // DOM properties
required: this.isMandatory(), required: this.isMandatory(),
readonly: this.isReadOnly(), readonly: this.isReadOnly(),
displayed: this.isDisplayed(), displayed: this.isDisplayed,
disabled: !this.field.isActive, disabled: !this.field.isActive,
isSelectCreated: this.isSelectCreated isSelectCreated: this.isSelectCreated
} }
}, },
isDisplayed() {
if (this.isAdvancedQuery) {
return this.field.isShowedFromUser
}
return fieldIsDisplayed(this.field) && (this.isMandatory() || this.field.isShowedFromUser || this.inTable)
},
isSelectCreated() { isSelectCreated() {
return this.isAdvancedQuery && return this.isAdvancedQuery &&
!['FieldBinary', 'FieldDate', 'FieldSelect', 'FieldYesNo'].includes(this.field.componentPath) && !['FieldBinary', 'FieldDate', 'FieldSelect', 'FieldYesNo'].includes(this.field.componentPath) &&
@ -167,7 +174,7 @@ export default {
return false return false
}, },
sizeFieldResponsive() { sizeFieldResponsive() {
if (!this.isDisplayed()) { if (!this.isDisplayed) {
return DEFAULT_SIZE return DEFAULT_SIZE
} }
@ -267,12 +274,7 @@ export default {
this.field = this.metadataField this.field = this.metadataField
}, },
methods: { methods: {
isDisplayed() { showMessage,
if (this.isAdvancedQuery) {
return this.field.isShowedFromUser
}
return fieldIsDisplayed(this.field) && (this.isMandatory() || this.field.isShowedFromUser || this.inTable)
},
isReadOnly() { isReadOnly() {
if (this.isAdvancedQuery) { if (this.isAdvancedQuery) {
if (['NULL', 'NOT_NULL'].includes(this.field.operator)) { if (['NULL', 'NOT_NULL'].includes(this.field.operator)) {
@ -343,7 +345,7 @@ export default {
return Boolean(field) return Boolean(field)
}, },
focusField() { focusField() {
if (this.isDisplayed() && this.isMandatory() && !this.isReadOnly()) { if (this.isDisplayed && this.isMandatory() && !this.isReadOnly()) {
this.$refs[this.field.columnName].activeFocus() this.$refs[this.field.columnName].activeFocus()
} }
} }

View File

@ -16,7 +16,7 @@ const context = {
*/ */
setContext(state, payload) { setContext(state, payload) {
let key = '' let key = ''
if (payload.parentUuid && !isEmptyValue(payload.value)) { if (payload.parentUuid) {
key += payload.parentUuid + '|' key += payload.parentUuid + '|'
// set context for window // set context for window

View File

@ -496,23 +496,22 @@ const panel = {
// get field // get field
const field = fieldList.find(fieldItem => fieldItem.columnName === columnName) const field = fieldList.find(fieldItem => fieldItem.columnName === columnName)
if (!(isAdvancedQuery && ['IN', 'NOT_IN'].includes(field.operator))) { if (!(panelType === 'table' || isAdvancedQuery)) {
newValue = parsedValueComponent({ if (!['IN', 'NOT_IN'].includes(field.operator)) {
fieldType: field.componentPath, newValue = parsedValueComponent({
referenceType: field.referenceType,
value: newValue
})
if (field.isRange) {
valueTo = parsedValueComponent({
fieldType: field.componentPath, fieldType: field.componentPath,
referenceType: field.referenceType, referenceType: field.referenceType,
value: valueTo value: newValue
}) })
if (field.isRange) {
valueTo = parsedValueComponent({
fieldType: field.componentPath,
referenceType: field.referenceType,
value: valueTo
})
}
} }
}
if (!(panelType === 'table' || isAdvancedQuery)) {
// Call context management // Call context management
dispatch('setContext', { dispatch('setContext', {
parentUuid, parentUuid,
@ -555,9 +554,7 @@ const panel = {
} }
}) })
} }
}
if (!isAdvancedQuery) {
// Change Dependents // Change Dependents
dispatch('changeDependentFieldsList', { dispatch('changeDependentFieldsList', {
parentUuid, parentUuid,

View File

@ -120,7 +120,7 @@ class evaluator {
}) })
// in context exists this column name // in context exists this column name
if (value === null || value === undefined) { if (value === null || value === undefined) {
console.info(`.The column ${first} not exists in context.`) // console.info(`.The column ${first} not exists in context.`)
return _defaultUndefined return _defaultUndefined
} }
firstEval = value // replace with it's value firstEval = value // replace with it's value
@ -186,10 +186,6 @@ class evaluator {
value2 = false value2 = false
} }
if ([value1, operand, value2].includes(null)) {
return false
}
let isValueLogic let isValueLogic
// TODO: Add '^' operand comparison // TODO: Add '^' operand comparison
switch (operand) { switch (operand) {