mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-11 05:11:59 +08:00
fix: Fields that are not displayed by default and have a default value. (#345)
This commit is contained in:
parent
557937349a
commit
02c634e56d
@ -136,6 +136,9 @@ export default {
|
||||
},
|
||||
'metadata.value'(value) {
|
||||
if (!this.metadata.inTable) {
|
||||
if (typeof value === 'boolean') {
|
||||
value = value ? 'Y' : 'N'
|
||||
}
|
||||
if (this.metadata.displayed) {
|
||||
if (!this.options.some(option => option.key === value)) {
|
||||
this.options.push({
|
||||
|
@ -59,10 +59,10 @@ export function loadMainMenu() {
|
||||
return new Promise(resolve => {
|
||||
getMenu(getToken()).then(menuResponse => {
|
||||
const asyncRoutesMap = []
|
||||
menuResponse.childsList.forEach(menu => {
|
||||
const optionMenu = getRouteFromMenuItem(menu)
|
||||
if (menu.isSummary) {
|
||||
menu.childsList.forEach(menu => {
|
||||
menuResponse.childsList.forEach(menuElement => {
|
||||
const optionMenu = getRouteFromMenuItem(menuElement)
|
||||
if (menuElement.isSummary) {
|
||||
menuElement.childsList.forEach(menu => {
|
||||
const childsSumaryConverted = getChildFromAction(menu, 0)
|
||||
|
||||
optionMenu.children.push(childsSumaryConverted)
|
||||
@ -70,7 +70,7 @@ export function loadMainMenu() {
|
||||
optionMenu.meta.childs.push(childsSumaryConverted)
|
||||
})
|
||||
} else {
|
||||
const childsConverted = getChildFromAction(menu)
|
||||
const childsConverted = getChildFromAction(menuElement)
|
||||
|
||||
optionMenu.children.push(childsConverted)
|
||||
optionMenu.meta.childs.push(childsConverted)
|
||||
@ -99,16 +99,20 @@ function getChildFromAction(menu, index) {
|
||||
name: menu.uuid,
|
||||
hidden: index > 0,
|
||||
meta: {
|
||||
isIndex: actionAttributes.isIndex,
|
||||
title: menu.name,
|
||||
description: menu.description,
|
||||
uuid: menu.referenceUuid,
|
||||
tabUuid: '',
|
||||
type: actionAttributes.name,
|
||||
parentUuid: menu.parentUuid,
|
||||
icon: actionAttributes.icon,
|
||||
alwaysShow: true,
|
||||
description: menu.description,
|
||||
icon: actionAttributes.icon,
|
||||
isIndex: actionAttributes.isIndex,
|
||||
isReadOnly: menu.isReadOnly,
|
||||
isSummary: menu.isSummary,
|
||||
isSOTrx: menu.isSOTrx,
|
||||
parentUuid: menu.parentUuid,
|
||||
noCache: false,
|
||||
referenceUuid: menu.referenceUuid,
|
||||
tabUuid: '',
|
||||
title: menu.name,
|
||||
type: actionAttributes.name,
|
||||
uuid: menu.referenceUuid,
|
||||
childs: []
|
||||
}
|
||||
}
|
||||
@ -134,11 +138,15 @@ function getRouteFromMenuItem(menu) {
|
||||
component: Layout,
|
||||
name: menu.uuid,
|
||||
meta: {
|
||||
title: menu.name,
|
||||
description: menu.description,
|
||||
type: actionAttributes.name,
|
||||
icon: actionAttributes.icon,
|
||||
isReadOnly: menu.isReadOnly,
|
||||
isSummary: menu.isSummary,
|
||||
isSOTrx: menu.isSOTrx,
|
||||
noCache: true,
|
||||
referenceUuid: menu.referenceUuid,
|
||||
title: menu.name,
|
||||
type: actionAttributes.name,
|
||||
childs: []
|
||||
},
|
||||
children: [{
|
||||
@ -147,14 +155,17 @@ function getRouteFromMenuItem(menu) {
|
||||
name: menu.uuid + '-index',
|
||||
hidden: true,
|
||||
meta: {
|
||||
isIndex: actionAttributes.isIndex,
|
||||
parentUuid: menu.uuid,
|
||||
title: menu.name,
|
||||
description: menu.description,
|
||||
type: actionAttributes.name,
|
||||
icon: actionAttributes.icon,
|
||||
noCache: true,
|
||||
breadcrumb: false,
|
||||
description: menu.description,
|
||||
icon: actionAttributes.icon,
|
||||
isIndex: actionAttributes.isIndex,
|
||||
isReadOnly: menu.isReadOnly,
|
||||
isSOTrx: menu.isSOTrx,
|
||||
noCache: true,
|
||||
parentUuid: menu.uuid,
|
||||
referenceUuid: menu.referenceUuid,
|
||||
title: menu.name,
|
||||
type: actionAttributes.name,
|
||||
childs: []
|
||||
}
|
||||
}]
|
||||
|
@ -47,10 +47,18 @@ const browser = {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
}
|
||||
const field = generateField(fieldItem, someAttributes)
|
||||
const field = generateField({
|
||||
fieldToGenerate: fieldItem,
|
||||
moreAttributes: someAttributes,
|
||||
isSOTrxMenu: routeToDelete.meta.isSOTrx
|
||||
})
|
||||
// Add new field if is range number
|
||||
if (field.isRange && field.componentPath === 'FieldNumber') {
|
||||
const fieldRange = generateField(fieldItem, someAttributes, true)
|
||||
const fieldRange = generateField({
|
||||
fieldToGenerate: fieldItem,
|
||||
moreAttributes: someAttributes,
|
||||
typeRange: true
|
||||
})
|
||||
if (!isEmptyValue(fieldRange.value)) {
|
||||
fieldRange.isShowedFromUser = true
|
||||
}
|
||||
|
@ -256,9 +256,12 @@ const window = {
|
||||
let fieldLinkColumnName
|
||||
// Convert from gRPC
|
||||
const fieldsList = tabResponse.fieldsList.map((fieldItem, index) => {
|
||||
fieldItem = generateField(fieldItem, {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
fieldItem = generateField({
|
||||
fieldToGenerate: fieldItem,
|
||||
moreAttributes: {
|
||||
...additionalAttributes,
|
||||
fieldListIndex: index
|
||||
}
|
||||
})
|
||||
if (fieldItem.sequence > fieldUuidsequence) {
|
||||
fieldUuidsequence = fieldItem.sequence
|
||||
|
@ -71,7 +71,8 @@ export function parseContext({
|
||||
columnName,
|
||||
value,
|
||||
isSQL = false,
|
||||
isBooleanToString = false
|
||||
isBooleanToString = false,
|
||||
isSOTrxMenu
|
||||
}) {
|
||||
let isError = false
|
||||
const errorsList = []
|
||||
@ -129,18 +130,22 @@ export function parseContext({
|
||||
}
|
||||
}
|
||||
|
||||
if ((contextInfo === undefined || contextInfo.length === 0) &&
|
||||
if (isEmptyValue(contextInfo) &&
|
||||
(token.startsWith('#') || token.startsWith('$'))) {
|
||||
contextInfo = getContext({
|
||||
columnName
|
||||
}) // get global context
|
||||
}
|
||||
// menu attribute isEmptyValue isSOTrx
|
||||
if (!isEmptyValue(isSOTrxMenu) && token === 'IsSOTrx' && isEmptyValue(contextInfo)) {
|
||||
contextInfo = isSOTrxMenu
|
||||
}
|
||||
if (contextInfo === undefined || contextInfo.length === 0) {
|
||||
console.info(`No Context for: ${token}`)
|
||||
isError = true
|
||||
errorsList.push(token)
|
||||
} else {
|
||||
if (typeof contextInfo === 'object') {
|
||||
if (['object', 'boolean'].includes(typeof contextInfo)) {
|
||||
outString = contextInfo
|
||||
} else {
|
||||
outString = outString + contextInfo // replace context with Context
|
||||
@ -150,7 +155,7 @@ export function parseContext({
|
||||
inString = inString.substring(secondIndexTag + 1, inString.length) // from second @
|
||||
firstIndexTag = inString.indexOf('@')
|
||||
}
|
||||
if (typeof contextInfo !== 'object') {
|
||||
if (!['object', 'boolean'].includes(typeof contextInfo)) {
|
||||
outString = outString + inString // add the rest of the string
|
||||
}
|
||||
if (isSQL) {
|
||||
|
@ -11,7 +11,12 @@ import language from '@/lang'
|
||||
* @param {object} moreAttributes, additional attributes
|
||||
* @param {boolean} typeRange, indicate if this field is a range used as _To
|
||||
*/
|
||||
export function generateField(fieldToGenerate, moreAttributes, typeRange = false) {
|
||||
export function generateField({
|
||||
fieldToGenerate,
|
||||
moreAttributes,
|
||||
typeRange = false,
|
||||
isSOTrxMenu
|
||||
}) {
|
||||
let isShowedFromUser = false
|
||||
// verify if it no overwrite value with ...moreAttributes
|
||||
if (moreAttributes.isShowedFromUser) {
|
||||
@ -27,10 +32,14 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
|
||||
parsedDefaultValue = parseContext({
|
||||
...moreAttributes,
|
||||
columnName: fieldToGenerate.columnName,
|
||||
value: parsedDefaultValue
|
||||
value: parsedDefaultValue,
|
||||
isSOTrxMenu: isSOTrxMenu
|
||||
}).value
|
||||
}
|
||||
if (isEmptyValue(parsedDefaultValue) && String(parsedDefaultValue).trim() !== '-1') {
|
||||
|
||||
if ((isEmptyValue(parsedDefaultValue) ||
|
||||
String(parsedDefaultValue).includes('@')) &&
|
||||
String(parsedDefaultValue).trim() !== '-1') {
|
||||
parsedDefaultValue = getPreference({
|
||||
parentUuid: fieldToGenerate.parentUuid,
|
||||
containerUuid: fieldToGenerate.containerUuid,
|
||||
@ -38,7 +47,10 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
|
||||
})
|
||||
|
||||
// search value preference with elementName
|
||||
if (isEmptyValue(parsedDefaultValue) && !isEmptyValue(fieldToGenerate.elementName)) {
|
||||
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
||||
(isEmptyValue(parsedDefaultValue) ||
|
||||
String(parsedDefaultValue).includes('@')) &&
|
||||
String(parsedDefaultValue).trim() !== '-1') {
|
||||
parsedDefaultValue = getPreference({
|
||||
parentUuid: fieldToGenerate.parentUuid,
|
||||
containerUuid: fieldToGenerate.containerUuid,
|
||||
@ -65,7 +77,10 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
|
||||
value: parsedDefaultValueTo
|
||||
}).value
|
||||
}
|
||||
if (isEmptyValue(parsedDefaultValueTo) && String(parsedDefaultValueTo).trim() !== '-1') {
|
||||
|
||||
if ((isEmptyValue(parsedDefaultValueTo) ||
|
||||
String(parsedDefaultValueTo).includes('@')) &&
|
||||
String(parsedDefaultValueTo).trim() !== '-1') {
|
||||
parsedDefaultValueTo = getPreference({
|
||||
parentUuid: fieldToGenerate.parentUuid,
|
||||
containerUuid: fieldToGenerate.containerUuid,
|
||||
@ -73,7 +88,10 @@ export function generateField(fieldToGenerate, moreAttributes, typeRange = false
|
||||
})
|
||||
|
||||
// search value preference with elementName
|
||||
if (isEmptyValue(parsedDefaultValueTo) && !isEmptyValue(fieldToGenerate.elementName)) {
|
||||
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
||||
(isEmptyValue(parsedDefaultValueTo) ||
|
||||
String(parsedDefaultValueTo).includes('@')) &&
|
||||
String(parsedDefaultValueTo).trim() !== '-1') {
|
||||
parsedDefaultValueTo = getPreference({
|
||||
parentUuid: fieldToGenerate.parentUuid,
|
||||
containerUuid: fieldToGenerate.containerUuid,
|
||||
@ -211,10 +229,17 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u
|
||||
|
||||
fieldDefinitionList = processToGenerate.parametersList
|
||||
.map(fieldItem => {
|
||||
const field = generateField(fieldItem, additionalAttributes)
|
||||
const field = generateField({
|
||||
fieldToGenerate: fieldItem,
|
||||
moreAttributes: additionalAttributes
|
||||
})
|
||||
// Add new field if is range number
|
||||
if (field.isRange && field.componentPath === 'FieldNumber') {
|
||||
const fieldRange = generateField(fieldItem, additionalAttributes, true)
|
||||
const fieldRange = generateField({
|
||||
fieldToGenerate: fieldItem,
|
||||
moreAttributes: additionalAttributes,
|
||||
typeRange: true
|
||||
})
|
||||
if (!isEmptyValue(fieldRange.value)) {
|
||||
fieldRange.isShowedFromUser = true
|
||||
}
|
||||
|
@ -350,6 +350,9 @@ export function parsedValueComponent({ fieldType, value, referenceType, isMandat
|
||||
if (String(value).trim() === '') {
|
||||
value = undefined
|
||||
}
|
||||
if (typeof value === 'boolean') {
|
||||
value = value ? 'Y' : 'N'
|
||||
}
|
||||
if (referenceType === 'TableDirect') {
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
value = Number(value)
|
||||
|
Loading…
x
Reference in New Issue
Block a user