feat(数据集): 数据集字段支持公式运算等操作(UI和CRUD)

This commit is contained in:
junjie 2021-07-29 16:31:49 +08:00
parent e0c23d5211
commit 243dacc959
2 changed files with 30 additions and 7 deletions

View File

@ -217,12 +217,11 @@ export default {
'param': function() { 'param': function() {
this.initFunctions() this.initFunctions()
}, },
'field': function() { 'field': {
if (this.field.id) { handler: function() {
this.fieldForm = JSON.parse(JSON.stringify(this.field)) this.initField()
} else { },
this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm)) deep: true
}
} }
}, },
mounted() { mounted() {
@ -230,6 +229,7 @@ export default {
this.$refs.myCm.codemirror.showHint() this.$refs.myCm.codemirror.showHint()
}) })
this.initFunctions() this.initFunctions()
this.initField()
}, },
methods: { methods: {
onCmReady(cm) { onCmReady(cm) {
@ -256,7 +256,16 @@ export default {
}) })
}, },
initField() {
if (this.field.id) {
this.fieldForm = JSON.parse(JSON.stringify(this.field))
} else {
this.fieldForm = JSON.parse(JSON.stringify(this.fieldForm))
}
},
closeCalcField() { closeCalcField() {
this.resetField()
this.$emit('onEditClose', {}) this.$emit('onEditClose', {})
}, },
@ -268,6 +277,21 @@ export default {
post('/dataset/field/save', this.fieldForm).then(response => { post('/dataset/field/save', this.fieldForm).then(response => {
this.closeCalcField() this.closeCalcField()
}) })
},
resetField() {
this.fieldForm = {
id: null,
name: '',
groupType: 'd',
deType: 0,
originName: '',
tableId: this.param.id,
checked: 1,
columnIndex: this.tableFields.dimensionList.length + this.tableFields.quotaList.length,
size: 0,
extField: 2
}
} }
} }
} }

View File

@ -247,7 +247,6 @@
:visible="editCalcField" :visible="editCalcField"
:show-close="false" :show-close="false"
class="dialog-css" class="dialog-css"
:destroy-on-close="true"
:title="currEditField.id?$t('dataset.edit_calc_field'):$t('dataset.add_calc_field')" :title="currEditField.id?$t('dataset.edit_calc_field'):$t('dataset.add_calc_field')"
append-to-body append-to-body
> >