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