mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-10 20:39:48 +08:00
Support to Field Preference (#662)
* add field preference * minimal changes * remove input * fix error * raname service * add information * rename descrition the preference Co-authored-by: Elsio Sanchez <elsiosanche@gmail.com>
This commit is contained in:
parent
44077e45f8
commit
7617bdbdf1
35
src/api/ADempiere/field/preference.js
Normal file
35
src/api/ADempiere/field/preference.js
Normal file
@ -0,0 +1,35 @@
|
||||
export function getPreference({
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level
|
||||
}) {
|
||||
return getPreference({
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level
|
||||
})
|
||||
}
|
||||
|
||||
export function updatePreference({
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level
|
||||
}) {
|
||||
return updatePreference({
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level
|
||||
})
|
||||
}
|
@ -50,8 +50,12 @@
|
||||
:field-attributes="fieldAttributes"
|
||||
:field-value="recordDataFields"
|
||||
/>
|
||||
<preference
|
||||
:field-attributes="fieldAttributes"
|
||||
:field-value="recordDataFields"
|
||||
:panel-type="field.panelType"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<component
|
||||
:is="componentRender"
|
||||
:ref="field.columnName"
|
||||
@ -75,12 +79,12 @@
|
||||
<script>
|
||||
import contextInfo from '@/components/ADempiere/Field/popover/contextInfo'
|
||||
import documentStatus from '@/components/ADempiere/Field/popover/documentStatus'
|
||||
import preference from '@/components/ADempiere/Field/popover/preference/index'
|
||||
import operatorComparison from '@/components/ADempiere/Field/popover/operatorComparison'
|
||||
import translated from '@/components/ADempiere/Field/popover/translated'
|
||||
import calculator from '@/components/ADempiere/Field/popover/calculator'
|
||||
import { DEFAULT_SIZE } from '@/utils/ADempiere/references'
|
||||
import { evalutateTypeField, fieldIsDisplayed } from '@/utils/ADempiere/dictionaryUtils'
|
||||
import { LOG_COLUMNS_NAME_LIST } from '@/utils/ADempiere/dataUtils.js'
|
||||
|
||||
/**
|
||||
* This is the base component for linking the components according to the
|
||||
@ -93,7 +97,8 @@ export default {
|
||||
documentStatus,
|
||||
operatorComparison,
|
||||
translated,
|
||||
calculator
|
||||
calculator,
|
||||
preference
|
||||
},
|
||||
props: {
|
||||
// receives the property that is an object with all the attributes
|
||||
@ -232,9 +237,6 @@ export default {
|
||||
return true
|
||||
}
|
||||
|
||||
// records in columns manage by backend
|
||||
const isLogColumns = LOG_COLUMNS_NAME_LIST.includes(this.field.columnName)
|
||||
|
||||
const isUpdateableAllFields = this.field.isReadOnly || this.field.isReadOnlyFromLogic
|
||||
|
||||
if (this.isPanelWindow) {
|
||||
@ -246,10 +248,6 @@ export default {
|
||||
return true
|
||||
}
|
||||
|
||||
if (isLogColumns) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (this.field.isAlwaysUpdateable) {
|
||||
return false
|
||||
}
|
||||
@ -266,7 +264,7 @@ export default {
|
||||
} else if (this.field.panelType === 'browser') {
|
||||
if (this.inTable) {
|
||||
// browser result
|
||||
return this.field.isReadOnly || isLogColumns
|
||||
return this.field.isReadOnly
|
||||
}
|
||||
// query criteria
|
||||
return this.field.isReadOnlyFromLogic
|
||||
@ -446,12 +444,7 @@ export default {
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
}
|
||||
.el-textarea {
|
||||
position: relative;
|
||||
display: contents;
|
||||
width: 100%;
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
/* Global Styles */
|
||||
.el-textarea__inner:not(.in-table) {
|
||||
min-height: 36px !important;
|
||||
|
@ -0,0 +1,61 @@
|
||||
export default [
|
||||
{
|
||||
elementColumnName: 'AD_Client_ID',
|
||||
columnName: 'AD_Client_ID',
|
||||
isFromDictionary: true,
|
||||
overwriteDefinition: {
|
||||
size: 24,
|
||||
sequence: 0,
|
||||
isReadOnly: true,
|
||||
handleActionPerformed: true,
|
||||
handleContentSelection: true,
|
||||
handleActionKeyPerformed: true,
|
||||
componentPath: 'FieldYesNo',
|
||||
value: true
|
||||
}
|
||||
},
|
||||
{
|
||||
elementColumnName: 'AD_Org_ID',
|
||||
columnName: 'AD_Org_ID',
|
||||
isFromDictionary: true,
|
||||
overwriteDefinition: {
|
||||
size: 24,
|
||||
sequence: 1,
|
||||
handleActionPerformed: true,
|
||||
handleContentSelection: true,
|
||||
handleActionKeyPerformed: true,
|
||||
componentPath: 'FieldYesNo',
|
||||
value: false
|
||||
}
|
||||
},
|
||||
{
|
||||
elementColumnName: 'AD_User_ID',
|
||||
columnName: 'AD_User_ID',
|
||||
isFromDictionary: true,
|
||||
overwriteDefinition: {
|
||||
size: 24,
|
||||
sequence: 2,
|
||||
isReadOnly: true,
|
||||
handleActionPerformed: true,
|
||||
handleContentSelection: true,
|
||||
handleActionKeyPerformed: true,
|
||||
componentPath: 'FieldYesNo',
|
||||
value: true
|
||||
}
|
||||
},
|
||||
{
|
||||
elementColumnName: 'AD_Window_ID',
|
||||
columnName: 'AD_Window_ID',
|
||||
isFromDictionary: true,
|
||||
overwriteDefinition: {
|
||||
size: 24,
|
||||
sequence: 3,
|
||||
isReadOnly: true,
|
||||
handleActionPerformed: true,
|
||||
handleContentSelection: true,
|
||||
handleActionKeyPerformed: true,
|
||||
componentPath: 'FieldYesNo',
|
||||
value: true
|
||||
}
|
||||
}
|
||||
]
|
301
src/components/ADempiere/Field/popover/preference/index.vue
Normal file
301
src/components/ADempiere/Field/popover/preference/index.vue
Normal file
@ -0,0 +1,301 @@
|
||||
<template>
|
||||
<el-dropdown trigger="click">
|
||||
<el-button type="text" :disabled="fieldAttributes.readonly">
|
||||
<i class="el-icon-notebook-2 el-icon--right" @click="isActive = !isActive" />
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown" class="dropdown-calc">
|
||||
<el-card
|
||||
v-if="!isEmptyValue(metadataList)"
|
||||
class="box-card"
|
||||
>
|
||||
<div slot="header" class="clearfix">
|
||||
<span>
|
||||
{{ $t('components.preference.title') }}
|
||||
<b>
|
||||
{{ fieldAttributes.name }}
|
||||
</b>
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="!isEmptyValue(descriptionOfPreference)" class="text item">
|
||||
{{
|
||||
descriptionOfPreference
|
||||
}}
|
||||
<template
|
||||
v-for="(index) in fieldsListPreference"
|
||||
>
|
||||
<span
|
||||
v-if="index.value"
|
||||
:key="index.sequence"
|
||||
>
|
||||
{{
|
||||
index.label
|
||||
}}
|
||||
</span>
|
||||
</template>
|
||||
</div>
|
||||
<br>
|
||||
<div class="text item">
|
||||
<el-form
|
||||
:inline="true"
|
||||
>
|
||||
<el-form-item>
|
||||
<p slot="label">
|
||||
{{ fieldAttributes.name }}
|
||||
</p>
|
||||
<el-switch
|
||||
v-if="fieldAttributes.componentPath === 'FieldYesNo'"
|
||||
v-model="code"
|
||||
:active-text="$t('components.preference.yes')"
|
||||
:inactive-text="$t('components.preference.no')"
|
||||
:disabled="true"
|
||||
style="padding-top: 30%"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
>
|
||||
<p>
|
||||
{{
|
||||
code
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form
|
||||
label-position="top"
|
||||
:inline="true"
|
||||
class="demo-form-inline"
|
||||
size="medium"
|
||||
>
|
||||
<el-form-item
|
||||
v-for="(field) in metadataList"
|
||||
:key="field.sequence"
|
||||
>
|
||||
<p slot="label">
|
||||
{{ field.name }}
|
||||
</p>
|
||||
<el-switch
|
||||
v-model="field.value"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<br>
|
||||
<el-row>
|
||||
<el-col :span="24">
|
||||
<samp style="float: right; padding-right: 10px;">
|
||||
<el-button
|
||||
type="danger"
|
||||
class="custom-button-address-location"
|
||||
icon="el-icon-close"
|
||||
@click="close()"
|
||||
/>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="custom-button-address-location"
|
||||
icon="el-icon-check"
|
||||
@click="close()"
|
||||
/>
|
||||
</samp>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
<div
|
||||
v-else
|
||||
v-loading="isEmptyValue(metadataList)"
|
||||
:element-loading-text="$t('notifications.loading')"
|
||||
element-loading-background="rgba(255, 255, 255, 0.8)"
|
||||
class="loading-window"
|
||||
/>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// import { ID, INTEGER } from '@/utils/ADempiere/references'
|
||||
import filelistPreference from './filelistPreference.js'
|
||||
import { getPreference } from '@/api/ADempiere/field/preference.js'
|
||||
import { createFieldFromDictionary } from '@/utils/ADempiere/lookupFactory'
|
||||
import { attributePreference } from '@/utils/ADempiere/valueUtils'
|
||||
|
||||
export default {
|
||||
name: 'Preference',
|
||||
props: {
|
||||
fieldAttributes: {
|
||||
type: [Object],
|
||||
required: true,
|
||||
default: null
|
||||
},
|
||||
fieldValue: {
|
||||
type: [String, Number, Boolean, Date, Array, Object],
|
||||
required: true,
|
||||
default: ''
|
||||
},
|
||||
containerUuid: {
|
||||
type: String,
|
||||
default: 'fiel-reference'
|
||||
},
|
||||
panelType: {
|
||||
type: String,
|
||||
default: undefined
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
filelistPreference,
|
||||
metadataList: [],
|
||||
code: '',
|
||||
description: [],
|
||||
isActive: false,
|
||||
unsubscribe: () => {}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
fieldsListPreference() {
|
||||
return this.metadataList.map(item => {
|
||||
return {
|
||||
label: item.name,
|
||||
value: item.value,
|
||||
columnName: item.columnName,
|
||||
sequence: item.sequence
|
||||
}
|
||||
})
|
||||
},
|
||||
descriptionOfPreference() {
|
||||
const label = this.fieldsListPreference.filter(element => {
|
||||
return element.value
|
||||
})
|
||||
if (!this.isEmptyValue(label)) {
|
||||
if (label[0].columnName === 'AD_User_ID') {
|
||||
return this.$t('components.preference.defaulMessageUser')
|
||||
}
|
||||
return this.$t('components.preference.defaulMessage')
|
||||
}
|
||||
return []
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
isActive(value) {
|
||||
const preferenceValue = this.fieldValue
|
||||
if (value && this.isEmptyValue(this.metadataList)) {
|
||||
this.setFieldsList()
|
||||
}
|
||||
if (!this.isEmptyValue(preferenceValue)) {
|
||||
if ((typeof preferenceValue !== 'string') && (this.fieldAttributes.componentPath !== 'FieldYesNo')) {
|
||||
this.code = preferenceValue
|
||||
} else {
|
||||
this.code = preferenceValue
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.unsubscribe = this.subscribeChanges()
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.unsubscribe()
|
||||
},
|
||||
methods: {
|
||||
createFieldFromDictionary,
|
||||
attributePreference,
|
||||
close() {
|
||||
this.$children[0].visible = false
|
||||
},
|
||||
notSubmitForm(event) {
|
||||
event.preventDefault()
|
||||
return false
|
||||
},
|
||||
setFieldsList() {
|
||||
const fieldsList = []
|
||||
// Product Code
|
||||
this.filelistPreference.forEach(element => {
|
||||
this.createFieldFromDictionary(element)
|
||||
.then(metadata => {
|
||||
const data = metadata
|
||||
fieldsList.push({
|
||||
...data,
|
||||
containerUuid: 'fiel-reference'
|
||||
})
|
||||
if (data.value) {
|
||||
this.description.push(data.name)
|
||||
}
|
||||
}).catch(error => {
|
||||
console.warn(`LookupFactory: Get Field From Server (State) - Error ${error.code}: ${error.message}.`)
|
||||
})
|
||||
})
|
||||
this.metadataList = fieldsList
|
||||
},
|
||||
sendValue(list) {
|
||||
const preference = this.attributePreference({
|
||||
containerUuid: this.containerUuid,
|
||||
panelType: this.panelType,
|
||||
attribute: this.fieldAttributes.columnName,
|
||||
value: this.code,
|
||||
level: list
|
||||
})
|
||||
getPreference(preference)
|
||||
},
|
||||
changeValue(value) {
|
||||
switch (value.columName) {
|
||||
// case 'options':
|
||||
case 'AD_Client_ID':
|
||||
this.$store.commit('updateValueOfField', {
|
||||
containerUuid: 'fiel-reference',
|
||||
columnName: value.columName,
|
||||
value: value.value
|
||||
})
|
||||
break
|
||||
case 'AD_Org_ID':
|
||||
this.$store.commit('updateValueOfField', {
|
||||
containerUuid: 'fiel-reference',
|
||||
columnName: value.columName,
|
||||
value: value.value
|
||||
})
|
||||
break
|
||||
case 'AD_User_ID':
|
||||
this.$store.commit('updateValueOfField', {
|
||||
containerUuid: 'fiel-reference',
|
||||
columnName: value.columName,
|
||||
value: value.value
|
||||
})
|
||||
break
|
||||
case 'AD_Window_ID':
|
||||
this.$store.commit('updateValueOfField', {
|
||||
containerUuid: 'fiel-reference',
|
||||
columnName: value.columName,
|
||||
value: value.value
|
||||
})
|
||||
break
|
||||
}
|
||||
},
|
||||
subscribeChanges() {
|
||||
return this.$store.subscribe((mutation, state) => {
|
||||
if (mutation.type === 'updateValueOfField') {
|
||||
// const values = this.$store.getters.getValuesView({
|
||||
// containerUuid: mutation.payload.containerUuid,
|
||||
// format: 'object'
|
||||
// })
|
||||
// this.changeValue(values)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.title {
|
||||
color: #000000;
|
||||
text-size-adjust: 20px;
|
||||
font-size: 120%;
|
||||
/* font-weight: 605!important;
|
||||
left: 50%; */
|
||||
}
|
||||
.value {
|
||||
color: #606266;
|
||||
text-size-adjust: 20px;
|
||||
font-size: 120%;
|
||||
/* font-weight: 605!important;
|
||||
left: 50%; */
|
||||
}
|
||||
</style>
|
@ -148,7 +148,16 @@ export default {
|
||||
resetAllFilters: 'Reset all filters',
|
||||
switchActiveText: 'Yes',
|
||||
switchInactiveText: 'Not',
|
||||
contextFieldTitle: 'Context Information'
|
||||
contextFieldTitle: 'Context Information',
|
||||
preference: {
|
||||
title: 'Preference Value',
|
||||
attribute: 'Attribute',
|
||||
code: 'Code',
|
||||
yes: 'Yes',
|
||||
no: 'No',
|
||||
defaulMessage: 'Applies for this ',
|
||||
defaulMessageUser: 'Applies for this '
|
||||
}
|
||||
},
|
||||
views: {
|
||||
browser: 'Smart Browser',
|
||||
|
@ -148,7 +148,16 @@ export default {
|
||||
resetAllFilters: 'Reiniciar todos los filtros',
|
||||
switchActiveText: 'Si',
|
||||
switchInactiveText: 'No',
|
||||
contextFieldTitle: 'Información de Contexto'
|
||||
contextFieldTitle: 'Información de Contexto',
|
||||
preference: {
|
||||
title: 'Valor de Preferencia',
|
||||
attribute: 'Atributo',
|
||||
code: 'Codigo',
|
||||
yes: 'Si',
|
||||
no: 'No',
|
||||
defaulMessage: 'Aplica para Esta ',
|
||||
defaulMessageUser: 'Aplica para Este '
|
||||
}
|
||||
},
|
||||
views: {
|
||||
browser: 'Consulta Inteligente',
|
||||
|
@ -250,7 +250,7 @@ export const recursiveTreeSearch = ({
|
||||
}
|
||||
|
||||
/**
|
||||
* Parsed value to component type
|
||||
* Preference Value
|
||||
* @author Elsio Sanchez <elsiosanches@gmail.com>
|
||||
* @param {mixed} value, value to parsed
|
||||
* @param {string} componentPath
|
||||
@ -530,3 +530,39 @@ export function tenderTypeFind({
|
||||
export function clearVariables() {
|
||||
partialValue = ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the Payment List for the Current Payment
|
||||
* @param {string} parentUuid Uuid the Parent
|
||||
* @param {string} containerUuid Uuid the Container
|
||||
* @param {string} panelType Panel Type
|
||||
* @param {string} attribute ColumName Field
|
||||
* @param {boolean| string | number} value Value
|
||||
* @param {array} level list value the preference
|
||||
*/
|
||||
export function attributePreference({
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level
|
||||
}) {
|
||||
let levelPanel
|
||||
if (level) {
|
||||
levelPanel = level.map(parameter => {
|
||||
return {
|
||||
key: parameter.columnName,
|
||||
value: parameter.value
|
||||
}
|
||||
})
|
||||
}
|
||||
return {
|
||||
parentUuid,
|
||||
containerUuid,
|
||||
panelType,
|
||||
attribute,
|
||||
value,
|
||||
level: levelPanel
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +132,8 @@ export default {
|
||||
loading: false,
|
||||
showDialog: false,
|
||||
redirect: undefined,
|
||||
otherQuery: {}
|
||||
otherQuery: {},
|
||||
default: 'dashboard'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -212,6 +213,9 @@ export default {
|
||||
},
|
||||
clientIdRedirect(query, expr) {
|
||||
const redirect = query.split(expr)
|
||||
if (redirect[1] === this.default) {
|
||||
return
|
||||
}
|
||||
return redirect[1]
|
||||
},
|
||||
organizationIdRedirect(query, expr) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user