fix: 修复场景联动数据格式错误问题
This commit is contained in:
parent
a42c108b08
commit
0154fb7d7c
|
@ -29,8 +29,6 @@ const assignmentKey = (data: any[]): any[] => {
|
||||||
export const defaultBranches = [
|
export const defaultBranches = [
|
||||||
{
|
{
|
||||||
when: [
|
when: [
|
||||||
{
|
|
||||||
terms: [
|
|
||||||
{
|
{
|
||||||
terms: [
|
terms: [
|
||||||
{
|
{
|
||||||
|
@ -45,10 +43,6 @@ export const defaultBranches = [
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
type: 'and',
|
type: 'and',
|
||||||
key: 'terms_1_terms_1',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
type: 'and',
|
|
||||||
key: 'terms_1',
|
key: 'terms_1',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
@ -106,6 +106,7 @@ const showWhen = computed(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const whenData = computed(() => {
|
const whenData = computed(() => {
|
||||||
|
console.log(props.data.when)
|
||||||
return props.data.when
|
return props.data.when
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -139,8 +140,6 @@ const mouseout = () => {
|
||||||
const addWhen = () => {
|
const addWhen = () => {
|
||||||
const terms = {
|
const terms = {
|
||||||
type: 'and',
|
type: 'and',
|
||||||
terms: [
|
|
||||||
{
|
|
||||||
terms: [
|
terms: [
|
||||||
{
|
{
|
||||||
column: undefined,
|
column: undefined,
|
||||||
|
@ -153,10 +152,6 @@ const addWhen = () => {
|
||||||
type: 'and',
|
type: 'and',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
key: `terms_2_${randomString()}`,
|
|
||||||
type: 'and',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
key: `terms_${randomString()}`
|
key: `terms_${randomString()}`
|
||||||
}
|
}
|
||||||
FormModel.value.branches?.[props.name].when?.push(terms)
|
FormModel.value.branches?.[props.name].when?.push(terms)
|
||||||
|
|
|
@ -284,8 +284,8 @@ const columnSelect = (option: any) => {
|
||||||
handOptionByColumn(option)
|
handOptionByColumn(option)
|
||||||
emit('update:value', { ...paramsValue })
|
emit('update:value', { ...paramsValue })
|
||||||
formItemContext.onFieldChange()
|
formItemContext.onFieldChange()
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][0] = option.name
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][0] = option.name
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][1] = paramsValue.termType
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][1] = paramsValue.termType
|
||||||
}
|
}
|
||||||
|
|
||||||
const termsTypeSelect = (e: { key: string, name: string }) => {
|
const termsTypeSelect = (e: { key: string, name: string }) => {
|
||||||
|
@ -310,11 +310,12 @@ const termsTypeSelect = (e: { key: string, name: string }) => {
|
||||||
}
|
}
|
||||||
emit('update:value', { ...paramsValue })
|
emit('update:value', { ...paramsValue })
|
||||||
formItemContext.onFieldChange()
|
formItemContext.onFieldChange()
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][1] = e.name
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][1] = e.name
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, option: any) => {
|
const valueSelect = (v: any, label: string, labelObj: Record<number, any>, option: any) => {
|
||||||
|
console.log(paramsValue.value?.source)
|
||||||
if (paramsValue.value?.source === 'metric') {
|
if (paramsValue.value?.source === 'metric') {
|
||||||
paramsValue.metric = option?.id
|
paramsValue.metric = option?.id
|
||||||
}
|
}
|
||||||
|
@ -325,14 +326,15 @@ const valueSelect = (v: any, label: string, labelObj: Record<number, any>, optio
|
||||||
delete newValues.metric
|
delete newValues.metric
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(newValues)
|
||||||
emit('update:value', { ...newValues })
|
emit('update:value', { ...newValues })
|
||||||
formItemContext.onFieldChange()
|
formItemContext.onFieldChange()
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][2] = labelObj
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][2] = labelObj
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeSelect = (e: any) => {
|
const typeSelect = (e: any) => {
|
||||||
emit('update:value', { ...paramsValue })
|
emit('update:value', { ...paramsValue })
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.name][3] = e.label
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName][3] = e.label
|
||||||
}
|
}
|
||||||
|
|
||||||
const termAdd = () => {
|
const termAdd = () => {
|
||||||
|
@ -346,17 +348,17 @@ const termAdd = () => {
|
||||||
type: 'and',
|
type: 'and',
|
||||||
key: `params_${new Date().getTime()}`
|
key: `params_${new Date().getTime()}`
|
||||||
}
|
}
|
||||||
formModel.value.branches?.[props.branchName]?.when?.[props.whenName]?.terms?.[props.termsName]?.terms?.push(terms)
|
formModel.value.branches?.[props.branchName]?.when?.[props.whenName]?.terms?.push(terms)
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName].push(['', '', '', '并且'])
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms[props.termsName].push(['', '', '', '并且'])
|
||||||
}
|
}
|
||||||
|
|
||||||
const onDelete = () => {
|
const onDelete = () => {
|
||||||
formModel.value.branches?.[props.branchName]?.when?.[props.whenName]?.terms?.[props.termsName]?.terms?.splice(props.name, 1)
|
formModel.value.branches?.[props.branchName]?.when?.[props.whenName]?.terms?.splice(props.termsName, 1)
|
||||||
formModel.value.options!.when[props.branchName].terms[props.whenName].terms.splice(props.name, 1)
|
formModel.value.options!.when[props.branchName].terms[props.whenName].terms.splice(props.termsName, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
Object.assign(paramsValue, pick(props.value, ['column', 'options', 'termType', 'terms', 'type', 'value']))
|
Object.assign(paramsValue, pick(props.value, ['column', 'options', 'termType', 'terms', 'type', 'value', 'metric']))
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -15,17 +15,14 @@
|
||||||
</j-popconfirm>
|
</j-popconfirm>
|
||||||
|
|
||||||
<j-form-item
|
<j-form-item
|
||||||
v-for='(item, index) in termsData'
|
:name='["branches", branchName, "when", whenName, "terms", props.name]'
|
||||||
:key='item.key'
|
|
||||||
:name='["branches", branchName, "when", whenName, "terms", props.name, "terms", index]'
|
|
||||||
:rules='rules'
|
:rules='rules'
|
||||||
>
|
>
|
||||||
<ParamsItem
|
<ParamsItem
|
||||||
v-model:value='formModel.branches[branchName].when[whenName].terms[props.name].terms[index]'
|
v-model:value='formModel.branches[branchName].when[whenName].terms[props.name]'
|
||||||
:isFirst='index === 0'
|
:isFirst='isFirst'
|
||||||
:isLast='index === termsData.length - 1'
|
:isLast='isLast'
|
||||||
:showDeleteBtn='termsData.length !== 1'
|
:showDeleteBtn='showDeleteBtn'
|
||||||
:name='index'
|
|
||||||
:termsName='name'
|
:termsName='name'
|
||||||
:whenName='whenName'
|
:whenName='whenName'
|
||||||
:branchName='branchName'
|
:branchName='branchName'
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
:branchName='branchName'
|
:branchName='branchName'
|
||||||
:whenName='props.name'
|
:whenName='props.name'
|
||||||
:name='index'
|
:name='index'
|
||||||
:showDeleteBtn='showDeleteBtn'
|
:showDeleteBtn='termsData.length > 1'
|
||||||
:isFirst='index === 0'
|
:isFirst='index === 0'
|
||||||
:isLast='index === termsData.length -1'
|
:isLast='index === termsData.length -1'
|
||||||
:data='item'
|
:data='item'
|
||||||
|
@ -91,8 +91,6 @@ const typeChange = (e: any) => {
|
||||||
const addWhen = () => {
|
const addWhen = () => {
|
||||||
const terms = {
|
const terms = {
|
||||||
type: 'and',
|
type: 'and',
|
||||||
terms: [
|
|
||||||
{
|
|
||||||
terms: [
|
terms: [
|
||||||
{
|
{
|
||||||
column: undefined,
|
column: undefined,
|
||||||
|
@ -105,10 +103,6 @@ const addWhen = () => {
|
||||||
type: 'and',
|
type: 'and',
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
key: `terms_2_${randomString()}`,
|
|
||||||
type: 'and',
|
|
||||||
}
|
|
||||||
],
|
|
||||||
key: `terms_${randomString()}`
|
key: `terms_${randomString()}`
|
||||||
}
|
}
|
||||||
formModel.value.branches?.[props.branchName]?.when?.push(terms)
|
formModel.value.branches?.[props.branchName]?.when?.push(terms)
|
||||||
|
|
Loading…
Reference in New Issue