mirror of
https://github.com/dataease/dataease.git
synced 2026-05-15 21:42:32 +08:00
feat(数据集): 计算字段编辑页面支持校验计算字段语法 #14332
This commit is contained in:
@@ -114,6 +114,7 @@ export default {
|
||||
client: 'Client'
|
||||
},
|
||||
data_set: {
|
||||
validation_succeeded: 'Field expression validation succeeded',
|
||||
to_nth_digits: 'Retain the Mth to Nth digits',
|
||||
the_column_permissions: 'Are you sure you want to delete column permissions?',
|
||||
last_n_digits: 'Retain the first M digits and the last N digits',
|
||||
|
||||
@@ -114,6 +114,7 @@ export default {
|
||||
client: '客戶端'
|
||||
},
|
||||
data_set: {
|
||||
validation_succeeded: '欄位表達式校驗成功',
|
||||
to_nth_digits: '保留第M至N位元',
|
||||
the_column_permissions: '確定刪除列權限嗎?',
|
||||
last_n_digits: '保留前M位元,後N位元',
|
||||
|
||||
@@ -115,6 +115,7 @@ export default {
|
||||
client: '客户端'
|
||||
},
|
||||
data_set: {
|
||||
validation_succeeded: '字段表达式校验成功',
|
||||
to_nth_digits: '保留第M至N位',
|
||||
the_column_permissions: '确定删除列权限吗?',
|
||||
last_n_digits: '保留前M位,后N位',
|
||||
|
||||
@@ -980,6 +980,41 @@ const setActiveName = (data: Table) => {
|
||||
activeName.value = data.tableName
|
||||
}
|
||||
|
||||
const verify = () => {
|
||||
if (datasetPreviewLoading.value) return
|
||||
calcEdit.value.formField.validate(val => {
|
||||
if (val) {
|
||||
calcEdit.value.setFieldForm()
|
||||
if (!calcEdit.value.fieldForm.originName.trim()) {
|
||||
ElMessage.error(t('data_set.cannot_be_empty_de_'))
|
||||
return
|
||||
}
|
||||
const obj = cloneDeep(calcEdit.value.fieldForm)
|
||||
const { deType, dateFormat, deExtractType } = obj
|
||||
obj.dateFormat = deType === 1 ? dateFormat : ''
|
||||
obj.dateFormatType = deType === 1 ? dateFormat : ''
|
||||
obj.deTypeArr = deType === 1 && deExtractType === 0 ? [deType, dateFormat] : [deType]
|
||||
const result = allfields.value.findIndex(ele => obj.id === ele.id)
|
||||
const allfieldsCopy = cloneDeep(unref(allfields))
|
||||
if (result !== -1) {
|
||||
allfieldsCopy.splice(result, 1, obj)
|
||||
} else {
|
||||
allfieldsCopy.push(obj)
|
||||
}
|
||||
const arr = []
|
||||
dfsNodeList(arr, datasetDrag.value.getNodeList())
|
||||
datasetPreviewLoading.value = true
|
||||
getPreviewData({ union: arr, allFields: allfieldsCopy })
|
||||
.then(() => {
|
||||
ElMessage.success(t('data_set.validation_succeeded'))
|
||||
})
|
||||
.finally(() => {
|
||||
datasetPreviewLoading.value = false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const isDragging = ref(false)
|
||||
|
||||
const mousedownDrag = () => {
|
||||
@@ -2217,6 +2252,7 @@ const getDsIconName = data => {
|
||||
<calc-field-edit ref="calcEdit" :crossDs="crossDatasources" />
|
||||
<template #footer>
|
||||
<el-button secondary @click="closeEditCalc()">{{ t('dataset.cancel') }} </el-button>
|
||||
<el-button secondary @click="verify">{{ t('datasource.validate') }} </el-button>
|
||||
<el-button type="primary" @click="confirmEditCalc()">{{ t('dataset.confirm') }} </el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
Reference in New Issue
Block a user