mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
* fix: Value preference with session context. * fix set value in field isParentLink or isKey * remove unused attribute. * Add additional attributes fieldTemplate.
This commit is contained in:
parent
f57a3bd11e
commit
876b51cce3
@ -93,16 +93,17 @@ const browser = {
|
|||||||
|
|
||||||
// Get dependent fields
|
// Get dependent fields
|
||||||
fieldsList
|
fieldsList
|
||||||
.filter(field => field.parentFieldsList && field.isActive)
|
|
||||||
.forEach((field, index, list) => {
|
.forEach((field, index, list) => {
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
if (field.isActive && field.parentFieldsList.length) {
|
||||||
const parentField = list.find(parentField => {
|
field.parentFieldsList.forEach(parentColumnName => {
|
||||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
const parentField = list.find(parentField => {
|
||||||
|
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
||||||
|
})
|
||||||
|
if (parentField) {
|
||||||
|
parentField.dependentFieldsList.push(field.columnName)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (parentField) {
|
}
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Convert from gRPC process list
|
// Convert from gRPC process list
|
||||||
|
@ -97,7 +97,7 @@ const panel = {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let orderBy = 'sequence'
|
let orderBy = 'sequence'
|
||||||
if ((params.panelType === 'window' && !params.isParent) || params.panelType === 'browser') {
|
if ((params.panelType === 'window' && !params.isParentTab) || params.panelType === 'browser') {
|
||||||
orderBy = 'seqNoGrid'
|
orderBy = 'seqNoGrid'
|
||||||
}
|
}
|
||||||
params.fieldList = assignedGroup({
|
params.fieldList = assignedGroup({
|
||||||
|
@ -252,7 +252,7 @@ const window = {
|
|||||||
isAdvancedQuery
|
isAdvancedQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
let fieldUuidsequence = 0
|
let isWithUuidField = false // indicates it contains the uuid field
|
||||||
let fieldLinkColumnName
|
let fieldLinkColumnName
|
||||||
// Convert from gRPC
|
// Convert from gRPC
|
||||||
const fieldsList = tabResponse.fieldsList.map((fieldItem, index) => {
|
const fieldsList = tabResponse.fieldsList.map((fieldItem, index) => {
|
||||||
@ -263,8 +263,9 @@ const window = {
|
|||||||
fieldListIndex: index
|
fieldListIndex: index
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (fieldItem.sequence > fieldUuidsequence) {
|
|
||||||
fieldUuidsequence = fieldItem.sequence
|
if (!isWithUuidField && fieldItem.columnName === 'UUID') {
|
||||||
|
isWithUuidField = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldItem.isParent) {
|
if (fieldItem.isParent) {
|
||||||
@ -277,30 +278,29 @@ const window = {
|
|||||||
if (!isAdvancedQuery) {
|
if (!isAdvancedQuery) {
|
||||||
// Get dependent fields
|
// Get dependent fields
|
||||||
fieldsList
|
fieldsList
|
||||||
.filter(field => field.parentFieldsList && field.isActive)
|
|
||||||
.forEach((field, index, list) => {
|
.forEach((field, index, list) => {
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
if (field.parentFieldsList.length && field.isActive) {
|
||||||
const parentField = list.find(parentField => {
|
field.parentFieldsList.forEach(parentColumnName => {
|
||||||
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
const parentField = list.find(parentField => {
|
||||||
|
return parentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
||||||
|
})
|
||||||
|
if (parentField) {
|
||||||
|
parentField.dependentFieldsList.push(field.columnName)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (parentField) {
|
}
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fieldsList.find(field => field.columnName === 'UUID')) {
|
if (!isWithUuidField) {
|
||||||
const attributesOverwrite = {
|
const fieldUuid = getFieldTemplate({
|
||||||
panelType: panelType,
|
...additionalAttributes,
|
||||||
sequence: (fieldUuidsequence + 10),
|
isShowedFromUser: false,
|
||||||
name: 'UUID',
|
name: 'UUID',
|
||||||
columnName: 'UUID',
|
columnName: 'UUID',
|
||||||
isAdvancedQuery,
|
|
||||||
componentPath: 'FieldText'
|
componentPath: 'FieldText'
|
||||||
}
|
})
|
||||||
const field = getFieldTemplate(attributesOverwrite)
|
fieldsList.push(fieldUuid)
|
||||||
fieldsList.push(field)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const window = getters.getWindow(parentUuid)
|
const window = getters.getWindow(parentUuid)
|
||||||
|
@ -23,38 +23,19 @@ export const getContext = ({
|
|||||||
* @param {string} mandatoryLogic
|
* @param {string} mandatoryLogic
|
||||||
* @param {string} readOnlyLogic
|
* @param {string} readOnlyLogic
|
||||||
* @param {string} defaultValue
|
* @param {string} defaultValue
|
||||||
|
* @returns {array} List column name of parent fields
|
||||||
*/
|
*/
|
||||||
export function getParentFields({ displayLogic, mandatoryLogic, readOnlyLogic, defaultValue }) {
|
export function getParentFields({ displayLogic, mandatoryLogic, readOnlyLogic, defaultValue }) {
|
||||||
let parentFields = []
|
return Array.from(new Set([
|
||||||
// For Display logic
|
// For Display logic
|
||||||
if (displayLogic) {
|
...evaluator.parseDepends(displayLogic),
|
||||||
parentFields = Array.from(new Set([
|
// For Mandatory Logic
|
||||||
...parentFields,
|
...evaluator.parseDepends(mandatoryLogic),
|
||||||
...evaluator.parseDepends(displayLogic)
|
// For Read Only Logic
|
||||||
]))
|
...evaluator.parseDepends(readOnlyLogic),
|
||||||
}
|
// For Default Value
|
||||||
// For Mandatory Logic
|
...evaluator.parseDepends(defaultValue)
|
||||||
if (mandatoryLogic) {
|
]))
|
||||||
parentFields = Array.from(new Set([
|
|
||||||
...parentFields,
|
|
||||||
...evaluator.parseDepends(mandatoryLogic)
|
|
||||||
]))
|
|
||||||
}
|
|
||||||
// For Read Only Logic
|
|
||||||
if (readOnlyLogic) {
|
|
||||||
parentFields = Array.from(new Set([
|
|
||||||
...parentFields,
|
|
||||||
...evaluator.parseDepends(readOnlyLogic)
|
|
||||||
]))
|
|
||||||
}
|
|
||||||
// For Default Value
|
|
||||||
if (defaultValue) {
|
|
||||||
parentFields = Array.from(new Set([
|
|
||||||
...parentFields,
|
|
||||||
...evaluator.parseDepends(defaultValue)
|
|
||||||
]))
|
|
||||||
}
|
|
||||||
return parentFields
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,14 +69,14 @@ export function parseContext({
|
|||||||
if (value.includes('@SQL=')) {
|
if (value.includes('@SQL=')) {
|
||||||
value = value.replace('@SQL=', '')
|
value = value.replace('@SQL=', '')
|
||||||
}
|
}
|
||||||
// var instances = value.length - value.replace('@', '').length
|
// const instances = value.length - value.replace('@', '').length
|
||||||
// if ((instances > 0) && (instances % 2) !== 0) { // could be an email address
|
// if ((instances > 0) && (instances % 2) !== 0) { // could be an email address
|
||||||
// return value
|
// return value
|
||||||
// }
|
// }
|
||||||
|
|
||||||
var token
|
let token, contextInfo
|
||||||
var inString = value
|
let inString = value
|
||||||
var outString = ''
|
let outString = ''
|
||||||
|
|
||||||
let firstIndexTag = inString.indexOf('@')
|
let firstIndexTag = inString.indexOf('@')
|
||||||
|
|
||||||
@ -117,7 +98,7 @@ export function parseContext({
|
|||||||
token = inString.substring(0, secondIndexTag)
|
token = inString.substring(0, secondIndexTag)
|
||||||
columnName = token
|
columnName = token
|
||||||
|
|
||||||
var contextInfo = getContext({
|
contextInfo = getContext({
|
||||||
parentUuid,
|
parentUuid,
|
||||||
containerUuid,
|
containerUuid,
|
||||||
columnName
|
columnName
|
||||||
|
@ -37,7 +37,8 @@ export function generateField({
|
|||||||
operator = 'LIKE'
|
operator = 'LIKE'
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (String(parsedDefaultValue).includes('@')) {
|
if (String(parsedDefaultValue).includes('@') &&
|
||||||
|
String(parsedDefaultValue).trim() !== '-1') {
|
||||||
parsedDefaultValue = parseContext({
|
parsedDefaultValue = parseContext({
|
||||||
...moreAttributes,
|
...moreAttributes,
|
||||||
columnName: fieldToGenerate.columnName,
|
columnName: fieldToGenerate.columnName,
|
||||||
@ -46,8 +47,8 @@ export function generateField({
|
|||||||
}).value
|
}).value
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isEmptyValue(parsedDefaultValue) ||
|
if (isEmptyValue(parsedDefaultValue) &&
|
||||||
String(parsedDefaultValue).includes('@')) &&
|
!(fieldToGenerate.isKey || fieldToGenerate.isParent) &&
|
||||||
String(parsedDefaultValue).trim() !== '-1') {
|
String(parsedDefaultValue).trim() !== '-1') {
|
||||||
parsedDefaultValue = getPreference({
|
parsedDefaultValue = getPreference({
|
||||||
parentUuid: fieldToGenerate.parentUuid,
|
parentUuid: fieldToGenerate.parentUuid,
|
||||||
@ -57,9 +58,7 @@ export function generateField({
|
|||||||
|
|
||||||
// search value preference with elementName
|
// search value preference with elementName
|
||||||
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
||||||
(isEmptyValue(parsedDefaultValue) ||
|
isEmptyValue(parsedDefaultValue)) {
|
||||||
String(parsedDefaultValue).includes('@')) &&
|
|
||||||
String(parsedDefaultValue).trim() !== '-1') {
|
|
||||||
parsedDefaultValue = getPreference({
|
parsedDefaultValue = getPreference({
|
||||||
parentUuid: fieldToGenerate.parentUuid,
|
parentUuid: fieldToGenerate.parentUuid,
|
||||||
containerUuid: fieldToGenerate.containerUuid,
|
containerUuid: fieldToGenerate.containerUuid,
|
||||||
@ -76,9 +75,8 @@ export function generateField({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// VALUE TO
|
// VALUE TO
|
||||||
// if (String(parsedDefaultValueTo).includes('@SQL=')) {
|
if (String(parsedDefaultValueTo).includes('@') &&
|
||||||
// parsedDefaultValueTo.replace('@SQL=', '')
|
String(parsedDefaultValueTo).trim() !== '-1') {
|
||||||
if (String(parsedDefaultValueTo).includes('@')) {
|
|
||||||
parsedDefaultValueTo = parseContext({
|
parsedDefaultValueTo = parseContext({
|
||||||
...moreAttributes,
|
...moreAttributes,
|
||||||
columnName: `${fieldToGenerate.columnName}_To`,
|
columnName: `${fieldToGenerate.columnName}_To`,
|
||||||
@ -86,8 +84,8 @@ export function generateField({
|
|||||||
}).value
|
}).value
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((isEmptyValue(parsedDefaultValueTo) ||
|
if (isEmptyValue(parsedDefaultValueTo) &&
|
||||||
String(parsedDefaultValueTo).includes('@')) &&
|
!(fieldToGenerate.isKey || fieldToGenerate.isParent) &&
|
||||||
String(parsedDefaultValueTo).trim() !== '-1') {
|
String(parsedDefaultValueTo).trim() !== '-1') {
|
||||||
parsedDefaultValueTo = getPreference({
|
parsedDefaultValueTo = getPreference({
|
||||||
parentUuid: fieldToGenerate.parentUuid,
|
parentUuid: fieldToGenerate.parentUuid,
|
||||||
@ -97,9 +95,7 @@ export function generateField({
|
|||||||
|
|
||||||
// search value preference with elementName
|
// search value preference with elementName
|
||||||
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
if (!isEmptyValue(fieldToGenerate.elementName) &&
|
||||||
(isEmptyValue(parsedDefaultValueTo) ||
|
isEmptyValue(parsedDefaultValueTo)) {
|
||||||
String(parsedDefaultValueTo).includes('@')) &&
|
|
||||||
String(parsedDefaultValueTo).trim() !== '-1') {
|
|
||||||
parsedDefaultValueTo = getPreference({
|
parsedDefaultValueTo = getPreference({
|
||||||
parentUuid: fieldToGenerate.parentUuid,
|
parentUuid: fieldToGenerate.parentUuid,
|
||||||
containerUuid: fieldToGenerate.containerUuid,
|
containerUuid: fieldToGenerate.containerUuid,
|
||||||
@ -260,16 +256,17 @@ export function generateProcess({ processToGenerate, containerUuidAssociated = u
|
|||||||
|
|
||||||
// Get dependent fields
|
// Get dependent fields
|
||||||
fieldDefinitionList
|
fieldDefinitionList
|
||||||
.filter(field => field.parentFieldsList && field.isActive)
|
|
||||||
.forEach((field, index, list) => {
|
.forEach((field, index, list) => {
|
||||||
field.parentFieldsList.forEach(parentColumnName => {
|
if (field.isActive && field.parentFieldsList.length) {
|
||||||
const parentField = list.find(itemParentField => {
|
field.parentFieldsList.forEach(parentColumnName => {
|
||||||
return itemParentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
const parentField = list.find(itemParentField => {
|
||||||
|
return itemParentField.columnName === parentColumnName && parentColumnName !== field.columnName
|
||||||
|
})
|
||||||
|
if (parentField) {
|
||||||
|
parentField.dependentFieldsList.push(field.columnName)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (parentField) {
|
}
|
||||||
parentField.dependentFieldsList.push(field.columnName)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,18 +389,7 @@ export function evalutateTypeField(displayTypeId, isAllInfo = false) {
|
|||||||
|
|
||||||
// Default template for injected fields
|
// Default template for injected fields
|
||||||
export function getFieldTemplate(attributesOverwrite) {
|
export function getFieldTemplate(attributesOverwrite) {
|
||||||
const referenceValue = {
|
return {
|
||||||
tableName: '',
|
|
||||||
keyColumnName: '',
|
|
||||||
displayColumnName: '',
|
|
||||||
query: '',
|
|
||||||
parsedQuery: '',
|
|
||||||
directQuery: '',
|
|
||||||
parsedDirectQuery: '',
|
|
||||||
validationCode: '',
|
|
||||||
windowsList: []
|
|
||||||
}
|
|
||||||
const newField = {
|
|
||||||
id: 0,
|
id: 0,
|
||||||
uuid: '',
|
uuid: '',
|
||||||
name: '',
|
name: '',
|
||||||
@ -452,16 +438,26 @@ export function getFieldTemplate(attributesOverwrite) {
|
|||||||
readOnlyLogic: undefined,
|
readOnlyLogic: undefined,
|
||||||
parentFieldsList: undefined,
|
parentFieldsList: undefined,
|
||||||
dependentFieldsList: [],
|
dependentFieldsList: [],
|
||||||
reference: referenceValue,
|
reference: {
|
||||||
|
tableName: '',
|
||||||
|
keyColumnName: '',
|
||||||
|
displayColumnName: '',
|
||||||
|
query: '',
|
||||||
|
parsedQuery: '',
|
||||||
|
directQuery: '',
|
||||||
|
parsedDirectQuery: '',
|
||||||
|
validationCode: '',
|
||||||
|
windowsList: []
|
||||||
|
},
|
||||||
contextInfo: undefined,
|
contextInfo: undefined,
|
||||||
isShowedFromUser: false,
|
isShowedFromUser: false,
|
||||||
isFixedTableColumn: false,
|
isFixedTableColumn: false,
|
||||||
sizeFieldFromType: {
|
sizeFieldFromType: {
|
||||||
type: 'Button',
|
type: 'Button',
|
||||||
size: DEFAULT_SIZE
|
size: DEFAULT_SIZE
|
||||||
}
|
},
|
||||||
|
...attributesOverwrite
|
||||||
}
|
}
|
||||||
return Object.assign(newField, attributesOverwrite)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user