mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 15:15:53 +08:00
fix: Field isActive not edit with false value. (#693)
* fix: Field isActive not edit with false value. * fix changed record is active. Co-authored-by: EdwinBetanc0urt <EdwinBetanco0urt@outlook.com>
This commit is contained in:
parent
2f1f6bf6c9
commit
31e6b7b3c8
@ -8,7 +8,7 @@ import IconElement from '@/components/ADempiere/IconElement'
|
|||||||
import { formatField } from '@/utils/ADempiere/valueFormat'
|
import { formatField } from '@/utils/ADempiere/valueFormat'
|
||||||
import MainPanel from '@/components/ADempiere/Panel'
|
import MainPanel from '@/components/ADempiere/Panel'
|
||||||
import { sortFields } from '@/utils/ADempiere/dictionaryUtils'
|
import { sortFields } from '@/utils/ADempiere/dictionaryUtils'
|
||||||
import { FIELDS_DECIMALS, FIELDS_QUANTITY, FIELDS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
import { FIELDS_DECIMALS, FIELDS_QUANTITY, COLUMNS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
||||||
import { LOG_COLUMNS_NAME_LIST } from '@/utils/ADempiere/dataUtils.js'
|
import { LOG_COLUMNS_NAME_LIST } from '@/utils/ADempiere/dataUtils.js'
|
||||||
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
||||||
import evaluator from '@/utils/ADempiere/evaluator'
|
import evaluator from '@/utils/ADempiere/evaluator'
|
||||||
@ -407,7 +407,7 @@ export default {
|
|||||||
}
|
}
|
||||||
if (fieldIsDisplayed(field)) {
|
if (fieldIsDisplayed(field)) {
|
||||||
// columnName: IsActive
|
// columnName: IsActive
|
||||||
const fieldReadOnlyForm = FIELDS_READ_ONLY_FORM.find(item => {
|
const fieldReadOnlyForm = COLUMNS_READ_ONLY_FORM.find(item => {
|
||||||
return !item.isChangedAllForm &&
|
return !item.isChangedAllForm &&
|
||||||
// columnName: IsActive, Processed, Processing
|
// columnName: IsActive, Processed, Processing
|
||||||
Object.prototype.hasOwnProperty.call(row, item.columnName)
|
Object.prototype.hasOwnProperty.call(row, item.columnName)
|
||||||
|
@ -16,23 +16,15 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
import { fieldIsDisplayed } from '@/utils/ADempiere'
|
||||||
import { FIELDS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
import { COLUMNS_READ_ONLY_FORM } from '@/utils/ADempiere/references'
|
||||||
import fieldMixin from '@/components/ADempiere/Field/mixin/mixinField.js'
|
import fieldMixin from '@/components/ADempiere/Field/mixin/mixinField.js'
|
||||||
import { convertStringToBoolean } from '@/utils/ADempiere/valueFormat.js'
|
import { convertStringToBoolean } from '@/utils/ADempiere/valueFormat.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FieldYesNo',
|
name: 'FieldYesNo',
|
||||||
mixins: [fieldMixin],
|
mixins: [
|
||||||
data() {
|
fieldMixin
|
||||||
return {
|
],
|
||||||
valuesReadOnly: [
|
|
||||||
{
|
|
||||||
columnName: 'IsActive',
|
|
||||||
isReadOnlyValue: false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
cssClassStyle() {
|
cssClassStyle() {
|
||||||
let styleClass = ' custom-field-yes-no '
|
let styleClass = ' custom-field-yes-no '
|
||||||
@ -40,6 +32,16 @@ export default {
|
|||||||
styleClass += this.metadata.cssClassName
|
styleClass += this.metadata.cssClassName
|
||||||
}
|
}
|
||||||
return styleClass
|
return styleClass
|
||||||
|
},
|
||||||
|
columnReadOnlyForm() {
|
||||||
|
return COLUMNS_READ_ONLY_FORM.find(item => {
|
||||||
|
return item.columnName === this.metadata.columnName
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
if (!this.isEmptyValue(this.columnReadOnlyForm)) {
|
||||||
|
this.isReadOnlyForm(this.value)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -53,12 +55,13 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
isReadOnlyForm(value) {
|
isReadOnlyForm(value) {
|
||||||
const fieldReadOnlyForm = FIELDS_READ_ONLY_FORM.find(item => item.columnName === this.metadata.columnName)
|
const fieldReadOnlyForm = this.columnReadOnlyForm
|
||||||
|
|
||||||
// columnName: IsActive, Processed, Processing
|
// columnName: IsActive, Processed, Processing
|
||||||
if (fieldReadOnlyForm && fieldIsDisplayed(this.metadata)) {
|
if (!this.isEmptyValue(fieldReadOnlyForm) && fieldIsDisplayed(this.metadata)) {
|
||||||
const fieldsExcludes = []
|
const fieldsExcludes = []
|
||||||
// if isChangedAllForm it does not exclude anything, otherwise it excludes this columnName
|
// if isChangedAllForm it does not exclude anything, otherwise it excludes this columnName
|
||||||
if (fieldReadOnlyForm.isChangedAllForm) {
|
if (!fieldReadOnlyForm.isChangedAllForm) {
|
||||||
fieldsExcludes.push(this.metadata.columnName)
|
fieldsExcludes.push(this.metadata.columnName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +274,7 @@ const actions = {
|
|||||||
valueAttribute: true
|
valueAttribute: true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set default values to panel
|
* Set default values to panel
|
||||||
* @param {string} parentUuid
|
* @param {string} parentUuid
|
||||||
@ -356,10 +357,26 @@ const actions = {
|
|||||||
attributes: defaultAttributes
|
attributes: defaultAttributes
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (['browser', 'form', 'process', 'report'].includes(panelType)) {
|
const windowPanel = (itemField) => {
|
||||||
// const fieldsUser = []
|
|
||||||
panel.fieldsList.forEach(itemField => {
|
|
||||||
if (!itemField.isAdvancedQuery || itemField.isActiveLogics) {
|
if (!itemField.isAdvancedQuery || itemField.isActiveLogics) {
|
||||||
|
// enable edit fields in panel
|
||||||
|
commit('changeFieldAttribure', {
|
||||||
|
attributeName: 'isReadOnlyFromForm',
|
||||||
|
field: itemField,
|
||||||
|
attributeValue: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const othersPanel = (itemField) => {
|
||||||
|
if (!itemField.isAdvancedQuery || itemField.isActiveLogics) {
|
||||||
|
// enable edit fields in panel
|
||||||
|
commit('changeFieldAttribure', {
|
||||||
|
attributeName: 'isReadOnlyFromForm',
|
||||||
|
field: itemField,
|
||||||
|
attributeValue: false
|
||||||
|
})
|
||||||
|
|
||||||
// Change Dependents
|
// Change Dependents
|
||||||
dispatch('changeDependentFieldsList', {
|
dispatch('changeDependentFieldsList', {
|
||||||
field: itemField
|
field: itemField
|
||||||
@ -368,7 +385,12 @@ const actions = {
|
|||||||
// if (itemField.isShowedFromUserDefault || !isEmptyValue(itemField.value)) {
|
// if (itemField.isShowedFromUserDefault || !isEmptyValue(itemField.value)) {
|
||||||
// fieldsUser.push(itemField.columnName)
|
// fieldsUser.push(itemField.columnName)
|
||||||
// }
|
// }
|
||||||
})
|
}
|
||||||
|
|
||||||
|
let execute = windowPanel
|
||||||
|
if (['browser', 'form', 'process', 'report'].includes(panelType)) {
|
||||||
|
// const fieldsUser = []
|
||||||
|
execute = othersPanel
|
||||||
|
|
||||||
// dispatch('changeFieldShowedFromUser', {
|
// dispatch('changeFieldShowedFromUser', {
|
||||||
// containerUuid,
|
// containerUuid,
|
||||||
@ -376,11 +398,13 @@ const actions = {
|
|||||||
// groupField: ''
|
// groupField: ''
|
||||||
// })
|
// })
|
||||||
}
|
}
|
||||||
|
panel.fieldsList.forEach(execute)
|
||||||
})
|
})
|
||||||
|
|
||||||
resolve(defaultAttributes)
|
resolve(defaultAttributes)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
seekRecord({ dispatch, getters }, {
|
seekRecord({ dispatch, getters }, {
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
|
@ -583,28 +583,40 @@ export const FIELDS_HIDDEN = [
|
|||||||
BUTTON
|
BUTTON
|
||||||
]
|
]
|
||||||
|
|
||||||
/**
|
export const COLUMN_IS_ACTIVE = {
|
||||||
* Fields with this column name, changed all fields is read only
|
|
||||||
*/
|
|
||||||
export const FIELDS_READ_ONLY_FORM = [
|
|
||||||
{
|
|
||||||
columnName: 'IsActive', // column name of field
|
columnName: 'IsActive', // column name of field
|
||||||
defaultValue: true, // default value when loading
|
defaultValue: true, // default value when loading
|
||||||
valueIsReadOnlyForm: false, // value that activates read-only form
|
valueIsReadOnlyForm: false, // value that activates read-only form
|
||||||
isChangedAllForm: false // change the entire form to read only including this field
|
isChangedAllForm: false // change the entire form to read only including this field
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const COLUMN_PROCESSED = {
|
||||||
columnName: 'Processed',
|
columnName: 'Processed',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
valueIsReadOnlyForm: true,
|
valueIsReadOnlyForm: true,
|
||||||
isChangedAllForm: true
|
isChangedAllForm: true
|
||||||
},
|
}
|
||||||
{
|
|
||||||
|
export const COLUMN_PROCESSING = {
|
||||||
columnName: 'Processing',
|
columnName: 'Processing',
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
valueIsReadOnlyForm: false,
|
valueIsReadOnlyForm: false,
|
||||||
isChangedAllForm: true
|
isChangedAllForm: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const COLUMNS_NAME_READ_ONLY = [
|
||||||
|
COLUMN_IS_ACTIVE.columnName,
|
||||||
|
COLUMN_PROCESSED.columnName,
|
||||||
|
COLUMN_PROCESSING.columnName
|
||||||
|
]
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fields with this column name, changed all fields is read only
|
||||||
|
*/
|
||||||
|
export const COLUMNS_READ_ONLY_FORM = [
|
||||||
|
COLUMN_IS_ACTIVE,
|
||||||
|
COLUMN_PROCESSED,
|
||||||
|
COLUMN_PROCESSING
|
||||||
]
|
]
|
||||||
|
|
||||||
export const FIELDS_DECIMALS = [
|
export const FIELDS_DECIMALS = [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user