mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-11 13:39:48 +08:00
feat: Add operators comparison to advanced search. (#287)
* feat: Add operators comparison to advanced search. * Set is null and not null operator. * Add multiple values to IN and NOT IN operators. * Add component render to set values to IN and NOT IN operators. * Add IN and NOT IN operators in date component. * Fix attribute comparison (isAdvancedQuery).
This commit is contained in:
parent
88c1f03494
commit
7870fdbfab
@ -76,7 +76,7 @@ export function getEntity({ tableName, recordId, recordUuid }) {
|
|||||||
* @param {string} tableName
|
* @param {string} tableName
|
||||||
* @param {string} query
|
* @param {string} query
|
||||||
* @param {string} whereClause
|
* @param {string} whereClause
|
||||||
* @param {array} conditions
|
* @param {array} conditionsList
|
||||||
* @param {string} orderByClause
|
* @param {string} orderByClause
|
||||||
* @param {string} nextPageToken
|
* @param {string} nextPageToken
|
||||||
*/
|
*/
|
||||||
@ -84,7 +84,7 @@ export function getEntitiesList({
|
|||||||
tableName,
|
tableName,
|
||||||
query,
|
query,
|
||||||
whereClause,
|
whereClause,
|
||||||
conditions: conditionsList = [],
|
conditionsList = [],
|
||||||
orderByClause,
|
orderByClause,
|
||||||
nextPageToken: pageToken,
|
nextPageToken: pageToken,
|
||||||
pageSize
|
pageSize
|
||||||
@ -100,6 +100,27 @@ export function getEntitiesList({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all operator or get key value type from value
|
||||||
|
* @param {number} keyToFind
|
||||||
|
EQUAL = 0;
|
||||||
|
NOT_EQUAL = 1;
|
||||||
|
LIKE = 2;
|
||||||
|
NOT_LIKE = 3;
|
||||||
|
GREATER = 4;
|
||||||
|
GREATER_EQUAL = 5;
|
||||||
|
LESS = 6;
|
||||||
|
LESS_EQUAL = 7;
|
||||||
|
BETWEEN = 8;
|
||||||
|
NOT_NULL = 9;
|
||||||
|
NULL = 10;
|
||||||
|
IN = 11;
|
||||||
|
NOT_IN = 12;
|
||||||
|
*/
|
||||||
|
export function getConditionOperators(keyToFind) {
|
||||||
|
return Instance.call(this).getConditionOperators(keyToFind)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rollback entity (Create, Update, Delete)
|
* Rollback entity (Create, Update, Delete)
|
||||||
* @param {string} tableName
|
* @param {string} tableName
|
||||||
|
@ -98,15 +98,18 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
typePicker() {
|
typePicker() {
|
||||||
let range = ''
|
let picker = 'date'
|
||||||
let time = ''
|
if (['IN', 'NOT_IN'].includes(this.metadata.operator) && this.metadata.isAdvancedQuery) {
|
||||||
if (String(this.metadata.displayType) === String(16)) {
|
picker += 's'
|
||||||
time = 'time'
|
return picker
|
||||||
|
}
|
||||||
|
if (this.metadata.displayType === 16) {
|
||||||
|
picker += 'time'
|
||||||
}
|
}
|
||||||
if (this.metadata.isRange && !this.metadata.inTable) {
|
if (this.metadata.isRange && !this.metadata.inTable) {
|
||||||
range = 'range'
|
picker += 'range'
|
||||||
}
|
}
|
||||||
return 'date' + time + range
|
return picker
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Parse the date format to be compatible with element-ui
|
* Parse the date format to be compatible with element-ui
|
||||||
@ -150,9 +153,30 @@ export default {
|
|||||||
parsedDateValue(value) {
|
parsedDateValue(value) {
|
||||||
// not return undefined to v-model
|
// not return undefined to v-model
|
||||||
if (this.isEmptyValue(value)) {
|
if (this.isEmptyValue(value)) {
|
||||||
|
if (['IN', 'NOT_IN'].includes(this.metadata.operator) && this.metadata.isAdvancedQuery) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (['IN', 'NOT_IN'].includes(this.metadata.operator) && this.metadata.isAdvancedQuery) {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value = value.map(itemValue => {
|
||||||
|
if (typeof itemValue === 'object') {
|
||||||
|
return itemValue.toUTCString()
|
||||||
|
}
|
||||||
|
return itemValue
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const tempValue = []
|
||||||
|
if (!this.isEmptyValue(value)) {
|
||||||
|
tempValue.push(value)
|
||||||
|
}
|
||||||
|
value = tempValue
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
// instance date from long value
|
// instance date from long value
|
||||||
if (typeof value === 'number') {
|
if (typeof value === 'number') {
|
||||||
value = new Date(value).toUTCString()
|
value = new Date(value).toUTCString()
|
||||||
@ -177,6 +201,14 @@ export default {
|
|||||||
let startValue, endValue
|
let startValue, endValue
|
||||||
startValue = value
|
startValue = value
|
||||||
|
|
||||||
|
if (this.typePicker === 'dates') {
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value = value.map(itemValue => new Date(itemValue))
|
||||||
|
}
|
||||||
|
this.handleChange(value)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (this.metadata.isRange && !this.metadata.inTable && Array.isArray(value)) {
|
if (this.metadata.isRange && !this.metadata.inTable && Array.isArray(value)) {
|
||||||
startValue = value[0]
|
startValue = value[0]
|
||||||
endValue = value[1]
|
endValue = value[1]
|
||||||
|
@ -6,8 +6,11 @@
|
|||||||
:placeholder="metadata.help"
|
:placeholder="metadata.help"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
value-key="key"
|
value-key="key"
|
||||||
class="select-base"
|
:class="classStyle"
|
||||||
clearable
|
clearable
|
||||||
|
:multiple="isSelectMultiple"
|
||||||
|
:allow-create="metadata.isSelectCreated"
|
||||||
|
:collapse-tags="!isSelectMultiple"
|
||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
@change="preHandleChange"
|
@change="preHandleChange"
|
||||||
@visible-change="getDataLookupList"
|
@visible-change="getDataLookupList"
|
||||||
@ -60,6 +63,16 @@ export default {
|
|||||||
isMobile() {
|
isMobile() {
|
||||||
return this.$store.state.app.device === 'mobile'
|
return this.$store.state.app.device === 'mobile'
|
||||||
},
|
},
|
||||||
|
isSelectMultiple() {
|
||||||
|
return ['IN', 'NOT_IN'].includes(this.metadata.operator) && this.metadata.isAdvancedQuery
|
||||||
|
},
|
||||||
|
classStyle() {
|
||||||
|
let styleClass = 'custom-field-select'
|
||||||
|
if (this.isSelectMultiple) {
|
||||||
|
styleClass += ' custom-field-select-multiple'
|
||||||
|
}
|
||||||
|
return styleClass
|
||||||
|
},
|
||||||
getterLookupItem() {
|
getterLookupItem() {
|
||||||
if (this.isEmptyValue(this.metadata.reference.directQuery)) {
|
if (this.isEmptyValue(this.metadata.reference.directQuery)) {
|
||||||
return this.blanckOption
|
return this.blanckOption
|
||||||
@ -99,6 +112,23 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
isSelectMultiple(isMultiple) {
|
||||||
|
if (isMultiple) {
|
||||||
|
const valueInArray = []
|
||||||
|
if (!this.isEmptyValue(this.value)) {
|
||||||
|
valueInArray.push(this.value)
|
||||||
|
}
|
||||||
|
this.value = valueInArray
|
||||||
|
} else {
|
||||||
|
if (Array.isArray(this.value)) {
|
||||||
|
if (this.value.length) {
|
||||||
|
this.value = this.value[0]
|
||||||
|
} else {
|
||||||
|
this.value = undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
valueModel(value) {
|
valueModel(value) {
|
||||||
if (this.metadata.inTable) {
|
if (this.metadata.inTable) {
|
||||||
this.value = value
|
this.value = value
|
||||||
@ -159,7 +189,8 @@ export default {
|
|||||||
return selected
|
return selected
|
||||||
},
|
},
|
||||||
async getDataLookupItem() {
|
async getDataLookupItem() {
|
||||||
if (this.isEmptyValue(this.metadata.reference.directQuery)) {
|
if (this.isEmptyValue(this.metadata.reference.directQuery) ||
|
||||||
|
(this.metadata.isAdvancedQuery && this.isSelectMultiple)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
@ -234,8 +265,16 @@ export default {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style lang="scss">
|
||||||
.select-base {
|
.custom-field-select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-field-select-multiple {
|
||||||
|
overflow: auto;
|
||||||
|
max-height: 100px;
|
||||||
|
.el-select__tags {
|
||||||
|
max-height: 100px;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
34
src/components/ADempiere/Field/FieldSelectMultiple.vue
Normal file
34
src/components/ADempiere/Field/FieldSelectMultiple.vue
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<template>
|
||||||
|
<el-select
|
||||||
|
v-model="value"
|
||||||
|
multiple
|
||||||
|
filterable
|
||||||
|
allow-create
|
||||||
|
:placeholder="metadata.help"
|
||||||
|
class="custom-field-select custom-field-select-multiple"
|
||||||
|
@change="preHandleChange"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(option, key) in value"
|
||||||
|
:key="key"
|
||||||
|
:value="option"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { fieldMixin } from '@/components/ADempiere/Field/FieldMixin'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This component is a list type field, for IN and NOT IN search with advanced query
|
||||||
|
*/
|
||||||
|
export default {
|
||||||
|
name: 'FieldSelectMultiple',
|
||||||
|
mixins: [fieldMixin],
|
||||||
|
methods: {
|
||||||
|
preHandleChange(value) {
|
||||||
|
this.handleChange(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
98
src/components/ADempiere/Field/fieldOperatorComparison.vue
Normal file
98
src/components/ADempiere/Field/fieldOperatorComparison.vue
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
<template>
|
||||||
|
<span>
|
||||||
|
<el-popover
|
||||||
|
ref="operatorComarison"
|
||||||
|
placement="top"
|
||||||
|
width="200"
|
||||||
|
trigger="click"
|
||||||
|
>
|
||||||
|
<span class="custom-tittle-popover">
|
||||||
|
{{ $t('operators.operator') }}:
|
||||||
|
</span>
|
||||||
|
<el-select
|
||||||
|
v-model="value"
|
||||||
|
@change="changeOperator"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="(item, key) in operatorsList"
|
||||||
|
:key="key"
|
||||||
|
:value="item"
|
||||||
|
:label="$t('operators.' + item)"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-popover>
|
||||||
|
<span v-popover:operatorComarison>
|
||||||
|
{{ fieldAttributes.name }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { FIELD_OPERATORS_LIST } from '@/utils/ADempiere/dataUtils'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'FieldOperatorComparison',
|
||||||
|
props: {
|
||||||
|
fieldAttributes: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
value: this.fieldAttributes.operator
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
operatorsList() {
|
||||||
|
const { conditionsList } = FIELD_OPERATORS_LIST.find(item => {
|
||||||
|
return item.type === this.fieldAttributes.componentPath
|
||||||
|
})
|
||||||
|
return conditionsList
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
'fieldAttributes.operator'(newValue) {
|
||||||
|
this.value = newValue
|
||||||
|
if (!this.isEmptyValue(this.fieldAttributes.value) ||
|
||||||
|
['NULL', 'NOT_NULL'].includes(this.fieldAttributes.operator)) {
|
||||||
|
this.handleChange(this.fieldAttributes.value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
changeOperator(value) {
|
||||||
|
this.$store.dispatch('changeFieldAttribure', {
|
||||||
|
containerUuid: this.fieldAttributes.containerUuid,
|
||||||
|
columnName: this.fieldAttributes.columnName,
|
||||||
|
isAdvancedQuery: true,
|
||||||
|
attributeName: 'operator',
|
||||||
|
attributeValue: value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* @param {mixed} value, main value in component
|
||||||
|
* @param {mixed} valueTo, used in end value in range
|
||||||
|
* @param {string} label, or displayColumn to show in select
|
||||||
|
*/
|
||||||
|
handleChange(value) {
|
||||||
|
const sendParameters = {
|
||||||
|
parentUuid: this.fieldAttributes.parentUuid,
|
||||||
|
containerUuid: this.fieldAttributes.containerUuid,
|
||||||
|
field: this.fieldAttributes,
|
||||||
|
panelType: this.fieldAttributes.panelType,
|
||||||
|
columnName: this.fieldAttributes.columnName,
|
||||||
|
newValue: value === 'NotSend' ? this.value : value,
|
||||||
|
isAdvancedQuery: this.fieldAttributes.isAdvancedQuery,
|
||||||
|
isSendToServer: !(value === 'NotSend' || this.fieldAttributes.isAdvancedQuery),
|
||||||
|
isSendCallout: !(value === 'NotSend' || this.fieldAttributes.isAdvancedQuery)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$store.dispatch('notifyFieldChange', {
|
||||||
|
...sendParameters,
|
||||||
|
isChangedOldValue: this.fieldAttributes.componentPath === 'FieldYesNo' && Boolean(value === 'NotSend')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -9,10 +9,10 @@
|
|||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
<span class="custom-tittle-popover">
|
<span class="custom-tittle-popover">
|
||||||
{{ name }}
|
{{ fieldAttributes.name }}
|
||||||
</span>
|
</span>
|
||||||
<template v-if="!isEmptyValue(help)">
|
<template v-if="!isEmptyValue(fieldAttributes.help)">
|
||||||
: {{ help }}
|
: {{ fieldAttributes.help }}
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item
|
<el-form-item
|
||||||
@ -66,29 +66,13 @@ import { getLanguage } from '@/lang/index'
|
|||||||
export default {
|
export default {
|
||||||
name: 'FieldTranslated',
|
name: 'FieldTranslated',
|
||||||
props: {
|
props: {
|
||||||
containerUuid: {
|
fieldAttributes: {
|
||||||
type: String,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
columnName: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
default: undefined
|
|
||||||
},
|
|
||||||
help: {
|
|
||||||
type: String,
|
|
||||||
default: undefined
|
|
||||||
},
|
|
||||||
recordUuid: {
|
recordUuid: {
|
||||||
type: String,
|
type: String,
|
||||||
default: undefined
|
default: undefined
|
||||||
},
|
|
||||||
tableName: {
|
|
||||||
type: String,
|
|
||||||
required: true
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@ -112,7 +96,7 @@ export default {
|
|||||||
},
|
},
|
||||||
getterTranslationValues() {
|
getterTranslationValues() {
|
||||||
const values = this.$store.getters.getTranslationByLanguage({
|
const values = this.$store.getters.getTranslationByLanguage({
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.fieldAttributes.containerUuid,
|
||||||
language: this.langValue,
|
language: this.langValue,
|
||||||
recordUuid: this.recordUuid
|
recordUuid: this.recordUuid
|
||||||
})
|
})
|
||||||
@ -126,7 +110,7 @@ export default {
|
|||||||
if (this.isEmptyValue(values)) {
|
if (this.isEmptyValue(values)) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
return values[this.columnName]
|
return values[this.fieldAttributes.columnName]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -154,9 +138,9 @@ export default {
|
|||||||
getTranslationsFromServer() {
|
getTranslationsFromServer() {
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
this.$store.dispatch('getTranslationsFromServer', {
|
this.$store.dispatch('getTranslationsFromServer', {
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.fieldAttributes.containerUuid,
|
||||||
recordUuid: this.recordUuid,
|
recordUuid: this.recordUuid,
|
||||||
tableName: this.tableName,
|
tableName: this.fieldAttributes.tableName,
|
||||||
language: this.langValue
|
language: this.langValue
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
@ -165,9 +149,9 @@ export default {
|
|||||||
},
|
},
|
||||||
changeTranslationValue(value) {
|
changeTranslationValue(value) {
|
||||||
this.$store.dispatch('changeTranslationValue', {
|
this.$store.dispatch('changeTranslationValue', {
|
||||||
containerUuid: this.containerUuid,
|
containerUuid: this.fieldAttributes.containerUuid,
|
||||||
language: this.langValue,
|
language: this.langValue,
|
||||||
columnName: this.columnName,
|
columnName: this.fieldAttributes.columnName,
|
||||||
value
|
value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<el-col
|
<el-col
|
||||||
v-if="!inTable"
|
v-if="!inTable"
|
||||||
v-show="isDisplayed()"
|
v-show="isDisplayed()"
|
||||||
key="panel-template"
|
key="is-panel-template"
|
||||||
:xs="sizeFieldResponsive.xs"
|
:xs="sizeFieldResponsive.xs"
|
||||||
:sm="sizeFieldResponsive.sm"
|
:sm="sizeFieldResponsive.sm"
|
||||||
:md="sizeFieldResponsive.md"
|
:md="sizeFieldResponsive.md"
|
||||||
@ -18,22 +18,26 @@
|
|||||||
:required="isMandatory()"
|
:required="isMandatory()"
|
||||||
>
|
>
|
||||||
<template slot="label">
|
<template slot="label">
|
||||||
<field-context-info
|
<field-operator-comparison
|
||||||
v-if="(field.contextInfo && field.contextInfo.isActive) || field.reference.zoomWindowList.length"
|
v-if="isAdvancedQuery && isDisplayed()"
|
||||||
|
key="is-field-operator-comparison"
|
||||||
:field-attributes="fieldAttributes"
|
:field-attributes="fieldAttributes"
|
||||||
:field-value="field.value"
|
:field-value="field.value"
|
||||||
/>
|
/>
|
||||||
<template v-else>
|
<field-context-info
|
||||||
|
v-else-if="(field.contextInfo && field.contextInfo.isActive) || field.reference.zoomWindowList.length"
|
||||||
|
key="is-field-context-info"
|
||||||
|
:field-attributes="fieldAttributes"
|
||||||
|
:field-value="field.value"
|
||||||
|
/>
|
||||||
|
<span v-else key="is-field-name">
|
||||||
{{ isFieldOnly() }}
|
{{ isFieldOnly() }}
|
||||||
</template>
|
</span>
|
||||||
|
|
||||||
<field-translated
|
<field-translated
|
||||||
v-if="field.isTranslated && !isAdvancedQuery"
|
v-if="field.isTranslated && !isAdvancedQuery"
|
||||||
:name="field.name"
|
:field-attributes="fieldAttributes"
|
||||||
:help="field.help"
|
|
||||||
:container-uuid="containerUuid"
|
|
||||||
:column-name="field.columnName"
|
|
||||||
:record-uuid="field.optionCRUD"
|
:record-uuid="field.optionCRUD"
|
||||||
:table-name="field.tableName"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<component
|
<component
|
||||||
@ -47,7 +51,7 @@
|
|||||||
<component
|
<component
|
||||||
:is="componentRender"
|
:is="componentRender"
|
||||||
v-else
|
v-else
|
||||||
key="table-template"
|
key="is-table-template"
|
||||||
:class="classField"
|
:class="classField"
|
||||||
:metadata="fieldAttributes"
|
:metadata="fieldAttributes"
|
||||||
:value-model="recordDataFields"
|
:value-model="recordDataFields"
|
||||||
@ -57,6 +61,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import FieldContextInfo from '@/components/ADempiere/Field/fieldContextInfo'
|
import FieldContextInfo from '@/components/ADempiere/Field/fieldContextInfo'
|
||||||
import FieldTranslated from '@/components/ADempiere/Field/fieldTranslated'
|
import FieldTranslated from '@/components/ADempiere/Field/fieldTranslated'
|
||||||
|
import FieldOperatorComparison from '@/components/ADempiere/Field/fieldOperatorComparison'
|
||||||
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'
|
||||||
@ -71,7 +76,8 @@ export default {
|
|||||||
name: 'Field',
|
name: 'Field',
|
||||||
components: {
|
components: {
|
||||||
FieldContextInfo,
|
FieldContextInfo,
|
||||||
FieldTranslated
|
FieldTranslated,
|
||||||
|
FieldOperatorComparison
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
parentUuid: {
|
parentUuid: {
|
||||||
@ -120,6 +126,9 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
// load the component that is indicated in the attributes of received property
|
// load the component that is indicated in the attributes of received property
|
||||||
componentRender() {
|
componentRender() {
|
||||||
|
if (this.isSelectCreated) {
|
||||||
|
return () => import(`@/components/ADempiere/Field/FieldSelectMultiple`)
|
||||||
|
}
|
||||||
return () => import(`@/components/ADempiere/Field/${this.field.componentPath}`)
|
return () => import(`@/components/ADempiere/Field/${this.field.componentPath}`)
|
||||||
},
|
},
|
||||||
fieldAttributes() {
|
fieldAttributes() {
|
||||||
@ -132,9 +141,15 @@ export default {
|
|||||||
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() {
|
||||||
|
return this.isAdvancedQuery &&
|
||||||
|
!['FieldBinary', 'FieldDate', 'FieldSelect', 'FieldYesNo'].includes(this.field.componentPath) &&
|
||||||
|
['IN', 'NOT_IN'].includes(this.field.operator)
|
||||||
|
},
|
||||||
getWidth() {
|
getWidth() {
|
||||||
return this.$store.getters.getWidthLayout
|
return this.$store.getters.getWidthLayout
|
||||||
},
|
},
|
||||||
|
@ -273,7 +273,7 @@ export default {
|
|||||||
notes: 'Notes',
|
notes: 'Notes',
|
||||||
changeLog: 'Change Log',
|
changeLog: 'Change Log',
|
||||||
workflowLog: 'Workflow Log',
|
workflowLog: 'Workflow Log',
|
||||||
changeDetail: 'Detalle del cambio',
|
changeDetail: 'Change detail',
|
||||||
logWorkflow: {
|
logWorkflow: {
|
||||||
message: 'Message',
|
message: 'Message',
|
||||||
responsible: 'Responsible',
|
responsible: 'Responsible',
|
||||||
@ -298,5 +298,21 @@ export default {
|
|||||||
sequence: {
|
sequence: {
|
||||||
available: 'Available',
|
available: 'Available',
|
||||||
sequence: 'Sequence'
|
sequence: 'Sequence'
|
||||||
|
},
|
||||||
|
operators: {
|
||||||
|
operator: 'Comparison operator',
|
||||||
|
EQUAL: 'Equal to "="',
|
||||||
|
NOT_EQUAL: 'Not equal to "<>"',
|
||||||
|
LIKE: 'Like "~"',
|
||||||
|
NOT_LIKE: 'Not like "!~"',
|
||||||
|
GREATER: 'Greater than ">"',
|
||||||
|
GREATER_EQUAL: 'Greater than equal to ">="',
|
||||||
|
LESS: 'Less than "<"',
|
||||||
|
LESS_EQUAL: 'Less than equal to "<="',
|
||||||
|
BETWEEN: 'Between ">-<"',
|
||||||
|
NOT_NULL: 'Is not null',
|
||||||
|
NULL: 'Is null',
|
||||||
|
IN: 'Include',
|
||||||
|
NOT_IN: 'Not include'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -273,5 +273,21 @@ export default {
|
|||||||
sequence: {
|
sequence: {
|
||||||
available: 'Disponibles',
|
available: 'Disponibles',
|
||||||
sequence: 'Secuencia'
|
sequence: 'Secuencia'
|
||||||
|
},
|
||||||
|
operators: {
|
||||||
|
operator: 'Operador de comparación',
|
||||||
|
EQUAL: 'Igual a "="',
|
||||||
|
NOT_EQUAL: 'Diferente a "<>"',
|
||||||
|
LIKE: 'Contiene "~"',
|
||||||
|
NOT_LIKE: 'No contiene "!~"',
|
||||||
|
GREATER: 'Mayor que ">"',
|
||||||
|
GREATER_EQUAL: 'Mayor o igual que ">="',
|
||||||
|
LESS: 'Menor que "<"',
|
||||||
|
LESS_EQUAL: 'Menor o igual que "<="',
|
||||||
|
BETWEEN: 'Entre ">-<"',
|
||||||
|
NULL: 'No tiene valor',
|
||||||
|
NOT_NULL: 'Tiene un valor',
|
||||||
|
IN: 'Incluye',
|
||||||
|
NOT_IN: 'No incluye'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -450,12 +450,12 @@ const data = {
|
|||||||
* @param {string} query, criteria to search record data
|
* @param {string} query, criteria to search record data
|
||||||
* @param {string} whereClause, criteria to search record data
|
* @param {string} whereClause, criteria to search record data
|
||||||
* @param {string} orderByClause, criteria to search record data
|
* @param {string} orderByClause, criteria to search record data
|
||||||
* @param {array} conditions, conditions to criteria
|
* @param {array} conditionsList, conditions list to criteria
|
||||||
*/
|
*/
|
||||||
getObjectListFromCriteria({ commit, dispatch, getters, rootGetters }, parameters) {
|
getObjectListFromCriteria({ commit, dispatch, getters, rootGetters }, parameters) {
|
||||||
const {
|
const {
|
||||||
parentUuid, containerUuid,
|
parentUuid, containerUuid,
|
||||||
tableName, query, whereClause, orderByClause, conditions = [],
|
tableName, query, whereClause, orderByClause, conditionsList = [],
|
||||||
isShowNotification = true, isParentTab = true, isAddRecord = false
|
isShowNotification = true, isParentTab = true, isAddRecord = false
|
||||||
} = parameters
|
} = parameters
|
||||||
if (isShowNotification) {
|
if (isShowNotification) {
|
||||||
@ -483,7 +483,7 @@ const data = {
|
|||||||
commit('addInGetting', {
|
commit('addInGetting', {
|
||||||
containerUuid,
|
containerUuid,
|
||||||
tableName,
|
tableName,
|
||||||
conditions
|
conditionsList
|
||||||
})
|
})
|
||||||
|
|
||||||
// gets the default value of the fields (including whether it is empty or undefined)
|
// gets the default value of the fields (including whether it is empty or undefined)
|
||||||
@ -496,7 +496,7 @@ const data = {
|
|||||||
tableName,
|
tableName,
|
||||||
query,
|
query,
|
||||||
whereClause,
|
whereClause,
|
||||||
conditions,
|
conditionsList,
|
||||||
orderByClause,
|
orderByClause,
|
||||||
nextPageToken
|
nextPageToken
|
||||||
})
|
})
|
||||||
|
@ -43,6 +43,9 @@ const panel = {
|
|||||||
changeFieldList(state, payload) {
|
changeFieldList(state, payload) {
|
||||||
payload.fieldList = payload.newFieldList
|
payload.fieldList = payload.newFieldList
|
||||||
},
|
},
|
||||||
|
changeField(state, payload) {
|
||||||
|
payload.field = payload.newField
|
||||||
|
},
|
||||||
changeFieldValue(state, payload) {
|
changeFieldValue(state, payload) {
|
||||||
payload.field.oldValue = payload.field.value
|
payload.field.oldValue = payload.field.value
|
||||||
payload.field.value = payload.newValue
|
payload.field.value = payload.newValue
|
||||||
@ -134,17 +137,18 @@ const panel = {
|
|||||||
groupField
|
groupField
|
||||||
}) {
|
}) {
|
||||||
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
||||||
var newPanel = panel
|
const newPanel = panel
|
||||||
var showsFieldsWithValue = false
|
let showsFieldsWithValue = false
|
||||||
var hiddenFieldsWithValue = false
|
let hiddenFieldsWithValue = false
|
||||||
var newFields = panel.fieldList.map(itemField => {
|
newPanel.fieldList = panel.fieldList.map(itemField => {
|
||||||
const isMandatory = itemField.isMandatory || itemField.isMandatoryFromLogic
|
const isMandatory = itemField.isMandatory || itemField.isMandatoryFromLogic
|
||||||
if (!isMandatory && fieldIsDisplayed(itemField)) {
|
if (!isMandatory && fieldIsDisplayed(itemField)) {
|
||||||
if (isAdvancedQuery || itemField.groupAssigned === groupField) {
|
if (isAdvancedQuery || itemField.groupAssigned === groupField) {
|
||||||
if (fieldsUser.length && fieldsUser.includes(itemField.columnName)) {
|
if (fieldsUser.length && fieldsUser.includes(itemField.columnName)) {
|
||||||
// if it isShowedFromUser it is false, and it has some value, it means
|
// if it isShowedFromUser it is false, and it has some value, it means
|
||||||
// that it is going to show, therefore the SmartBrowser must be searched
|
// that it is going to show, therefore the SmartBrowser must be searched
|
||||||
if (!isEmptyValue(itemField.value) && !itemField.isShowedFromUser) {
|
if ((!isEmptyValue(itemField.value) && !itemField.isShowedFromUser) ||
|
||||||
|
(isAdvancedQuery && ['NULL', 'NOT_NULL'].includes(itemField.operator))) {
|
||||||
showsFieldsWithValue = true
|
showsFieldsWithValue = true
|
||||||
}
|
}
|
||||||
if (isAdvancedQuery) {
|
if (isAdvancedQuery) {
|
||||||
@ -155,7 +159,8 @@ const panel = {
|
|||||||
}
|
}
|
||||||
// if it isShowedFromUser it is true, and it has some value, it means
|
// if it isShowedFromUser it is true, and it has some value, it means
|
||||||
// that it is going to hidden, therefore the SmartBrowser must be searched
|
// that it is going to hidden, therefore the SmartBrowser must be searched
|
||||||
if (!isEmptyValue(itemField.value) && itemField.isShowedFromUser) {
|
if ((!isEmptyValue(itemField.value) && itemField.isShowedFromUser) ||
|
||||||
|
(isAdvancedQuery && ['NULL', 'NOT_NULL'].includes(itemField.operator))) {
|
||||||
hiddenFieldsWithValue = true
|
hiddenFieldsWithValue = true
|
||||||
}
|
}
|
||||||
if (isAdvancedQuery) {
|
if (isAdvancedQuery) {
|
||||||
@ -168,7 +173,8 @@ const panel = {
|
|||||||
if (fieldsUser.length && fieldsUser.includes(itemField.columnName)) {
|
if (fieldsUser.length && fieldsUser.includes(itemField.columnName)) {
|
||||||
// if it isShowedFromUser it is false, and it has some value, it means
|
// if it isShowedFromUser it is false, and it has some value, it means
|
||||||
// that it is going to show, therefore the SmartBrowser must be searched
|
// that it is going to show, therefore the SmartBrowser must be searched
|
||||||
if (!isEmptyValue(itemField.value) && !itemField.isShowedFromUser) {
|
if ((!isEmptyValue(itemField.value) && !itemField.isShowedFromUser) ||
|
||||||
|
(isAdvancedQuery && ['NULL', 'NOT_NULL'].includes(itemField.operator))) {
|
||||||
showsFieldsWithValue = true
|
showsFieldsWithValue = true
|
||||||
}
|
}
|
||||||
if (isAdvancedQuery) {
|
if (isAdvancedQuery) {
|
||||||
@ -177,7 +183,8 @@ const panel = {
|
|||||||
itemField.isShowedFromUser = true
|
itemField.isShowedFromUser = true
|
||||||
return itemField
|
return itemField
|
||||||
}
|
}
|
||||||
if (!isEmptyValue(itemField.value) && itemField.isShowedFromUser) {
|
if ((!isEmptyValue(itemField.value) && itemField.isShowedFromUser) ||
|
||||||
|
(isAdvancedQuery && ['NULL', 'NOT_NULL'].includes(itemField.operator))) {
|
||||||
hiddenFieldsWithValue = true
|
hiddenFieldsWithValue = true
|
||||||
}
|
}
|
||||||
if (isAdvancedQuery) {
|
if (isAdvancedQuery) {
|
||||||
@ -188,34 +195,34 @@ const panel = {
|
|||||||
}
|
}
|
||||||
return itemField
|
return itemField
|
||||||
})
|
})
|
||||||
panel.fieldList = newFields
|
|
||||||
commit('changePanel', {
|
commit('changePanel', {
|
||||||
containerUuid,
|
containerUuid,
|
||||||
newPanel,
|
panel,
|
||||||
panel
|
newPanel
|
||||||
})
|
})
|
||||||
|
|
||||||
if (showsFieldsWithValue || hiddenFieldsWithValue) {
|
if (showsFieldsWithValue || hiddenFieldsWithValue) {
|
||||||
// Updated record result
|
// Updated record result
|
||||||
if (panel.panelType === 'browser') {
|
if (panel.panelType === 'browser') {
|
||||||
dispatch('getBrowserSearch', {
|
dispatch('getBrowserSearch', {
|
||||||
containerUuid: panel.uuid,
|
containerUuid,
|
||||||
isClearSelection: true
|
isClearSelection: true
|
||||||
})
|
})
|
||||||
} else if (panel.panelType === 'table' && panel.isAdvancedQuery) {
|
} else if (panel.panelType === 'table' && panel.isAdvancedQuery) {
|
||||||
dispatch('getObjectListFromCriteria', {
|
dispatch('getObjectListFromCriteria', {
|
||||||
parentUuid: panel.parentUuid,
|
parentUuid: panel.parentUuid,
|
||||||
containerUuid: panel.uuid,
|
containerUuid,
|
||||||
tableName: panel.tableName,
|
tableName: panel.tableName,
|
||||||
query: panel.query,
|
query: panel.query,
|
||||||
whereClause: panel.whereClause,
|
whereClause: panel.whereClause,
|
||||||
conditions: getters.getParametersToServer({
|
conditionsList: getters.getParametersToServer({
|
||||||
containerUuid,
|
containerUuid,
|
||||||
isAdvancedQuery: true,
|
isAdvancedQuery,
|
||||||
isEvaluateMandatory: false
|
isEvaluateMandatory: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn(`Error getting Advanced Query (changeFieldShowedFromUser): ${error.message}. Code: ${error.code}`)
|
console.warn(`Error getting Advanced Query (changeFieldShowedFromUser): ${error.message}. Code: ${error.code}.`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -466,16 +473,17 @@ const panel = {
|
|||||||
* @param {array} withOutColumnNames
|
* @param {array} withOutColumnNames
|
||||||
*/
|
*/
|
||||||
notifyFieldChange({ commit, dispatch, getters }, {
|
notifyFieldChange({ commit, dispatch, getters }, {
|
||||||
parentUuid, containerUuid, panelType = 'window', isAdvancedQuery = false, columnName,
|
parentUuid, containerUuid, panelType = 'window', isAdvancedQuery = false,
|
||||||
newValue, valueTo, displayColumn,
|
columnName, newValue, valueTo, displayColumn,
|
||||||
isSendToServer = true, isSendCallout = true,
|
isSendToServer = true, isSendCallout = true,
|
||||||
isChangedOldValue = false, withOutColumnNames = []
|
isChangedOldValue = false, withOutColumnNames = []
|
||||||
}) {
|
}) {
|
||||||
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
const panel = getters.getPanel(containerUuid, isAdvancedQuery)
|
||||||
var fieldList = panel.fieldList
|
const fieldList = panel.fieldList
|
||||||
// get field
|
// get field
|
||||||
var field = fieldList.find(fieldItem => fieldItem.columnName === columnName)
|
const field = fieldList.find(fieldItem => fieldItem.columnName === columnName)
|
||||||
|
|
||||||
|
if (!(isAdvancedQuery && ['IN', 'NOT_IN'].includes(field.operator))) {
|
||||||
newValue = parsedValueComponent({
|
newValue = parsedValueComponent({
|
||||||
fieldType: field.componentPath,
|
fieldType: field.componentPath,
|
||||||
referenceType: field.referenceType,
|
referenceType: field.referenceType,
|
||||||
@ -489,6 +497,7 @@ const panel = {
|
|||||||
value: valueTo
|
value: valueTo
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!(panelType === 'table' || isAdvancedQuery)) {
|
if (!(panelType === 'table' || isAdvancedQuery)) {
|
||||||
// Call context management
|
// Call context management
|
||||||
@ -584,7 +593,7 @@ const panel = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (field.panelType === 'window' && fieldIsDisplayed(field)) {
|
if (field.panelType === 'window' && fieldIsDisplayed(field)) {
|
||||||
var uuid = getters.getUuid(containerUuid)
|
const uuid = getters.getUuid(containerUuid)
|
||||||
if (isEmptyValue(uuid)) {
|
if (isEmptyValue(uuid)) {
|
||||||
dispatch('createNewEntity', {
|
dispatch('createNewEntity', {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
@ -605,7 +614,7 @@ const panel = {
|
|||||||
message: error.message,
|
message: error.message,
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
console.warn(`Create Entity Error ${error.code}: ${error.message}`)
|
console.warn(`Create Entity Error ${error.code}: ${error.message}.`)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
dispatch('updateCurrentEntity', {
|
dispatch('updateCurrentEntity', {
|
||||||
@ -647,7 +656,9 @@ const panel = {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (panelType === 'table' || isAdvancedQuery) {
|
if (panelType === 'table' || isAdvancedQuery) {
|
||||||
if (field.isShowedFromUser && field.oldValue !== field.value) {
|
if (field.isShowedFromUser && (field.oldValue !== field.value ||
|
||||||
|
['NULL', 'NOT_NULL'].includes(field.operator) ||
|
||||||
|
field.operator !== field.oldOperator)) {
|
||||||
// change action to advanced query on field value is changed in this panel
|
// change action to advanced query on field value is changed in this panel
|
||||||
if (router.currentRoute.query.action !== 'advancedQuery') {
|
if (router.currentRoute.query.action !== 'advancedQuery') {
|
||||||
router.push({
|
router.push({
|
||||||
@ -663,13 +674,20 @@ const panel = {
|
|||||||
tableName: panel.tableName,
|
tableName: panel.tableName,
|
||||||
query: panel.query,
|
query: panel.query,
|
||||||
whereClause: panel.whereClause,
|
whereClause: panel.whereClause,
|
||||||
conditions: getters.getParametersToServer({
|
conditionsList: getters.getParametersToServer({
|
||||||
containerUuid,
|
containerUuid,
|
||||||
isAdvancedQuery: true,
|
isAdvancedQuery: true,
|
||||||
isEvaluateMandatory: false
|
isEvaluateMandatory: false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
commit('changeField', {
|
||||||
|
field,
|
||||||
|
newField: {
|
||||||
|
...field,
|
||||||
|
oldOperator: field.operator
|
||||||
|
}
|
||||||
|
})
|
||||||
if (response && response.length) {
|
if (response && response.length) {
|
||||||
dispatch('notifyPanelChange', {
|
dispatch('notifyPanelChange', {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
@ -683,7 +701,7 @@ const panel = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn(`Error getting Advanced Query (notifyFieldChange): ${error.message}. Code: ${error.code}`)
|
console.warn(`Error getting Advanced Query (notifyFieldChange): ${error.message}. Code: ${error.code}.`)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -773,6 +791,9 @@ const panel = {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* @deprecated used changeFieldAttribure
|
||||||
|
*/
|
||||||
notifyFieldChangeDisplayColumn({ commit, getters }, {
|
notifyFieldChangeDisplayColumn({ commit, getters }, {
|
||||||
containerUuid,
|
containerUuid,
|
||||||
isAdvancedQuery,
|
isAdvancedQuery,
|
||||||
@ -843,6 +864,24 @@ const panel = {
|
|||||||
newPanel: newPanel
|
newPanel: newPanel
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
changeFieldAttribure({ commit, getters }, {
|
||||||
|
containerUuid,
|
||||||
|
isAdvancedQuery,
|
||||||
|
columnName,
|
||||||
|
field,
|
||||||
|
attributeName,
|
||||||
|
attributeValue
|
||||||
|
}) {
|
||||||
|
if (isEmptyValue(field)) {
|
||||||
|
field = getters.getFieldFromColumnName({ containerUuid, isAdvancedQuery, columnName })
|
||||||
|
}
|
||||||
|
const newField = field
|
||||||
|
newField[attributeName] = attributeValue
|
||||||
|
commit('changeField', {
|
||||||
|
field,
|
||||||
|
newField
|
||||||
|
})
|
||||||
|
},
|
||||||
dictionaryResetCache({ commit }) {
|
dictionaryResetCache({ commit }) {
|
||||||
commit('dictionaryResetCache')
|
commit('dictionaryResetCache')
|
||||||
commit('dictionaryResetCacheContext')
|
commit('dictionaryResetCacheContext')
|
||||||
@ -1216,7 +1255,7 @@ const panel = {
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Getter converter selection params with value format
|
* Getter converter selection params with value format
|
||||||
* [{ columname: name key, value: value to send }]
|
* [{ columname: name key, value: value to send, operator }]
|
||||||
*/
|
*/
|
||||||
getParametersToServer: (state, getters) => ({
|
getParametersToServer: (state, getters) => ({
|
||||||
containerUuid,
|
containerUuid,
|
||||||
@ -1225,16 +1264,15 @@ const panel = {
|
|||||||
withOutColumnNames = [],
|
withOutColumnNames = [],
|
||||||
isEvaluateDisplayed = true,
|
isEvaluateDisplayed = true,
|
||||||
isEvaluateMandatory = true,
|
isEvaluateMandatory = true,
|
||||||
isConvertedDateToTimestamp = false,
|
|
||||||
isAdvancedQuery = false
|
isAdvancedQuery = false
|
||||||
}) => {
|
}) => {
|
||||||
if (fieldList.length <= 0) {
|
if (fieldList.length <= 0) {
|
||||||
fieldList = getters.getFieldsListFromPanel(containerUuid, isAdvancedQuery)
|
fieldList = getters.getFieldsListFromPanel(containerUuid, isAdvancedQuery)
|
||||||
}
|
}
|
||||||
var parametersRange = []
|
const parametersRange = []
|
||||||
|
|
||||||
// filter fields
|
// filter fields
|
||||||
var parametersList = fieldList
|
let parametersList = fieldList
|
||||||
.filter(fieldItem => {
|
.filter(fieldItem => {
|
||||||
// columns to exclude
|
// columns to exclude
|
||||||
if (withOutColumnNames.includes(fieldItem.columnName)) {
|
if (withOutColumnNames.includes(fieldItem.columnName)) {
|
||||||
@ -1256,7 +1294,7 @@ const panel = {
|
|||||||
|
|
||||||
// evaluate displayed fields
|
// evaluate displayed fields
|
||||||
if (isEvaluateDisplayed) {
|
if (isEvaluateDisplayed) {
|
||||||
var isDisplayed = fieldIsDisplayed(fieldItem) && (fieldItem.isShowedFromUser || isMandatory)
|
let isDisplayed = fieldIsDisplayed(fieldItem) && (fieldItem.isShowedFromUser || isMandatory)
|
||||||
if (isAdvancedQuery) {
|
if (isAdvancedQuery) {
|
||||||
isDisplayed = fieldItem.isShowedFromUser
|
isDisplayed = fieldItem.isShowedFromUser
|
||||||
}
|
}
|
||||||
@ -1267,7 +1305,8 @@ const panel = {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!isEmptyValue(fieldItem.value)) {
|
if (!isEmptyValue(fieldItem.value) || (isAdvancedQuery &&
|
||||||
|
['NULL', 'NOT_NULL'].includes(fieldItem.operator))) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1280,23 +1319,27 @@ const panel = {
|
|||||||
// conever parameters
|
// conever parameters
|
||||||
parametersList = parametersList
|
parametersList = parametersList
|
||||||
.map(parameterItem => {
|
.map(parameterItem => {
|
||||||
var value = row ? row[parameterItem.columnName] : parameterItem.value
|
let value = row ? row[parameterItem.columnName] : parameterItem.value
|
||||||
var valueTo = row ? row[`${parameterItem.columnName}_To`] : parameterItem.valueTo
|
const valueTo = row ? row[`${parameterItem.columnName}_To`] : parameterItem.valueTo
|
||||||
let values = []
|
let values = []
|
||||||
|
|
||||||
|
if (isAdvancedQuery && ['IN', 'NOT_IN'].includes(parameterItem.operator)) {
|
||||||
if (Array.isArray(value)) {
|
if (Array.isArray(value)) {
|
||||||
values = value
|
values = value.map(itemValue => {
|
||||||
|
const isMandatory = !isAdvancedQuery && (parameterItem.isMandatory || parameterItem.isMandatoryFromLogic)
|
||||||
|
return parsedValueComponent({
|
||||||
|
fieldType: parameterItem.componentPath,
|
||||||
|
value: itemValue,
|
||||||
|
referenceType: parameterItem.referenceType,
|
||||||
|
isMandatory
|
||||||
|
})
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
values.push(value)
|
||||||
|
}
|
||||||
value = undefined
|
value = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isConvertedDateToTimestamp) {
|
|
||||||
if (['FieldDate', 'FieldTime'].includes(parameterItem.componentPath) &&
|
|
||||||
Object.prototype.toString.call(value) === '[object Date]') {
|
|
||||||
value = value.getTime()
|
|
||||||
if (valueTo) {
|
|
||||||
valueTo = valueTo.getTime()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// only to fields type Time, Datea and DateTime
|
// only to fields type Time, Datea and DateTime
|
||||||
if (parameterItem.isRange && parameterItem.componentPath !== 'FieldNumber') {
|
if (parameterItem.isRange && parameterItem.componentPath !== 'FieldNumber') {
|
||||||
parametersRange.push({
|
parametersRange.push({
|
||||||
@ -1307,9 +1350,10 @@ const panel = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
columnName: parameterItem.columnName,
|
columnName: parameterItem.columnName,
|
||||||
value: value,
|
value,
|
||||||
isRange: parameterItem.isRange,
|
isRange: parameterItem.isRange,
|
||||||
values: values
|
values,
|
||||||
|
operator: isAdvancedQuery ? parameterItem.operator : undefined
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -606,9 +606,10 @@ const windowControl = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const conditions = []
|
const conditionsList = []
|
||||||
if (tab.isParentTab && !isEmptyValue(tab.tableName) && !isEmptyValue(value)) {
|
// TODO: evaluate if overwrite values to conditions
|
||||||
conditions.push({
|
if (!isLoadAllRecords && tab.isParentTab && !isEmptyValue(tab.tableName) && !isEmptyValue(value)) {
|
||||||
|
conditionsList.push({
|
||||||
columnName: columnName,
|
columnName: columnName,
|
||||||
value: value
|
value: value
|
||||||
})
|
})
|
||||||
@ -620,8 +621,7 @@ const windowControl = {
|
|||||||
query: parsedQuery,
|
query: parsedQuery,
|
||||||
whereClause: parsedWhereClause,
|
whereClause: parsedWhereClause,
|
||||||
orderByClause: tab.orderByClause,
|
orderByClause: tab.orderByClause,
|
||||||
// TODO: evaluate if overwrite values to conditions
|
conditionsList,
|
||||||
conditions: isLoadAllRecords ? [] : conditions,
|
|
||||||
isParentTab: tab.isParentTab,
|
isParentTab: tab.isParentTab,
|
||||||
isAddRecord: isAddRecord,
|
isAddRecord: isAddRecord,
|
||||||
isShowNotification: isShowNotification
|
isShowNotification: isShowNotification
|
||||||
|
109
src/utils/ADempiere/dataUtils.js
Normal file
109
src/utils/ADempiere/dataUtils.js
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
|
||||||
|
export const OPERATORS = [
|
||||||
|
{
|
||||||
|
operator: 'EQUAL',
|
||||||
|
symbol: '='
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'NOT_EQUAL',
|
||||||
|
symbol: '<>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'LIKE',
|
||||||
|
symbol: '%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'NOT_LIKE',
|
||||||
|
symbol: '!%'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'GREATER',
|
||||||
|
symbol: '>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'GREATER_EQUAL',
|
||||||
|
symbol: '>='
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'LESS',
|
||||||
|
symbol: '<'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'LESS_EQUAL',
|
||||||
|
symbol: '<='
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'BETWEEN',
|
||||||
|
symbol: '>-<'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'NOT_NULL',
|
||||||
|
symbol: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'NULL',
|
||||||
|
symbol: ''
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'IN',
|
||||||
|
symbol: '()'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
operator: 'NOT_IN',
|
||||||
|
symbol: '!()'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
// Components associated with search type
|
||||||
|
export const FIELD_OPERATORS_LIST = [
|
||||||
|
{
|
||||||
|
type: 'FieldBinary',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldButton',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldDate',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'GREATER', 'GREATER_EQUAL', 'LESS', 'LESS_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldImage',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldNumber',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'GREATER', 'GREATER_EQUAL', 'LESS', 'LESS_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldSelect',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'IN', 'NOT_IN', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldText',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'LIKE', 'NOT_LIKE', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldTextLong',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'LIKE', 'NOT_LIKE', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldTime',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'GREATER', 'GREATER_EQUAL', 'LESS', 'LESS_EQUAL', 'IN', 'NOT_IN', 'NULL', 'NOT_NULL']
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'FieldYesNo',
|
||||||
|
isRange: false,
|
||||||
|
conditionsList: ['EQUAL', 'NOT_EQUAL', 'NULL', 'NOT_NULL']
|
||||||
|
}
|
||||||
|
]
|
@ -109,7 +109,11 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
|
|||||||
// app attributes
|
// app attributes
|
||||||
isShowedFromUser,
|
isShowedFromUser,
|
||||||
isShowedTableFromUser: fieldToGenerate.isDisplayed,
|
isShowedTableFromUser: fieldToGenerate.isDisplayed,
|
||||||
isFixedTableColumn: false
|
isFixedTableColumn: false,
|
||||||
|
// Advanced query
|
||||||
|
operator: 'EQUAL', // current operator
|
||||||
|
oldOperator: undefined, // old operator
|
||||||
|
defaultOperator: 'EQUAL'
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluate simple logics without context
|
// evaluate simple logics without context
|
||||||
|
@ -334,7 +334,7 @@ export function parsedValueComponent({ fieldType, value, referenceType, isMandat
|
|||||||
if (!isNaN(value)) {
|
if (!isNaN(value)) {
|
||||||
value = Number(value)
|
value = Number(value)
|
||||||
}
|
}
|
||||||
if (typeof value === 'number') {
|
if (typeof value === 'number' || typeof value === 'string') {
|
||||||
value = new Date(value)
|
value = new Date(value)
|
||||||
}
|
}
|
||||||
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
if (typeof value === 'object' && value.hasOwnProperty('query')) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user