Merge pull request #5813 from dataease/pr@dev@refactor_calc

refactor: 字段管理修改名称、维度指标时不进行语法校验
This commit is contained in:
Junjun 2023-08-01 14:42:00 +08:00 committed by GitHub
commit aa87a2fbdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 48 additions and 15 deletions

View File

@ -53,6 +53,13 @@ public class ChartViewFieldController {
return chartViewFieldService.save(chartViewField); return chartViewFieldService.save(chartViewField);
} }
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANEL_LEVEL_MANAGE)
@ApiOperation("保存不校验表达式")
@PostMapping("/saveNotCheck/{panelId}")
public ChartViewField saveNotCheck(@PathVariable String panelId, @RequestBody ChartViewField chartViewField) {
return chartViewFieldService.save(chartViewField);
}
@DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANEL_LEVEL_MANAGE, paramIndex = 1) @DePermission(type = DePermissionType.PANEL, level = ResourceAuthLevel.PANEL_LEVEL_MANAGE, paramIndex = 1)
@ApiOperation("删除") @ApiOperation("删除")
@PostMapping("/delete/{id}/{panelId}") @PostMapping("/delete/{id}/{panelId}")

View File

@ -172,6 +172,21 @@ public class DataSetTableFieldController {
return dataSetTableFieldsService.save(datasetTableField); return dataSetTableFieldsService.save(datasetTableField);
} }
@DePermission(type = DePermissionType.DATASET, value = "tableId", level = ResourceAuthLevel.DATASET_LEVEL_MANAGE)
@ApiOperation("保存不校验表达式")
@PostMapping("saveNotCheck")
public DatasetTableField saveNotCheck(@RequestBody DatasetTableField datasetTableField) throws Exception {
dataSetTableFieldsService.checkFieldName(datasetTableField);
// 非直连数据集需先完成数据同步
DatasetTable datasetTable = dataSetTableService.get(datasetTableField.getTableId());
if (datasetTable.getMode() == 1) {
if (!dataSetTableService.checkEngineTableIsExists(datasetTableField.getTableId())) {
throw new RuntimeException(Translator.get("i18n_data_not_sync"));
}
}
return dataSetTableFieldsService.save(datasetTableField);
}
@DePermissions(value = { @DePermissions(value = {
@DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE, paramIndex = 1) @DePermission(type = DePermissionType.DATASET, level = ResourceAuthLevel.DATASET_LEVEL_MANAGE, paramIndex = 1)
}) })

View File

@ -48,8 +48,8 @@
<el-input <el-input
v-model="scope.row.name" v-model="scope.row.name"
size="mini" size="mini"
@blur="saveEdit(scope.row)" @blur="saveEdit(scope.row,false)"
@keyup.enter.native="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row,false)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -284,8 +284,8 @@
<el-input <el-input
v-model="scope.row.name" v-model="scope.row.name"
size="mini" size="mini"
@blur="saveEdit(scope.row)" @blur="saveEdit(scope.row,false)"
@keyup.enter.native="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row,false)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -604,13 +604,18 @@ export default {
this.filterField(this.searchField) this.filterField(this.searchField)
}) })
}, },
saveEdit(item) { saveEdit(item, checkExp = true) {
if (item.name && item.name.length > 50) { if (item.name && item.name.length > 50) {
this.$message.error(this.$t('dataset.field_name_less_50')) this.$message.error(this.$t('dataset.field_name_less_50'))
return return
} }
let url
post('/chart/field/save/' + this.panelInfo.id, item).then(response => { if (checkExp) {
url = '/chart/field/save/'
} else {
url = '/chart/field/saveNotCheck/'
}
post(url + this.panelInfo.id, item).then(response => {
this.initField() this.initField()
}).catch(res => { }).catch(res => {
this.initField() this.initField()
@ -623,7 +628,7 @@ export default {
} else if (val === 'q') { } else if (val === 'q') {
item.groupType = 'd' item.groupType = 'd'
} }
this.saveEdit(item) this.saveEdit(item, false)
}, },
addCalcField() { addCalcField() {

View File

@ -88,8 +88,8 @@
v-model="scope.row.name" v-model="scope.row.name"
size="mini" size="mini"
:disabled="!hasDataPermission('manage', param.privileges)" :disabled="!hasDataPermission('manage', param.privileges)"
@blur="saveEdit(scope.row)" @blur="saveEdit(scope.row,false)"
@keyup.enter.native="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row,false)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -427,8 +427,8 @@
v-model="scope.row.name" v-model="scope.row.name"
size="mini" size="mini"
:disabled="!hasDataPermission('manage', param.privileges)" :disabled="!hasDataPermission('manage', param.privileges)"
@blur="saveEdit(scope.row)" @blur="saveEdit(scope.row,false)"
@keyup.enter.native="saveEdit(scope.row)" @keyup.enter.native="saveEdit(scope.row,false)"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -850,7 +850,7 @@ export default {
] ]
} }
}, },
saveEdit(item) { saveEdit(item, checkExp = true) {
if (item.name && item.name.length > 50) { if (item.name && item.name.length > 50) {
this.$message.error(this.$t('dataset.field_name_less_50')) this.$message.error(this.$t('dataset.field_name_less_50'))
return return
@ -868,7 +868,13 @@ export default {
if (item.dateFormatType === 'custom' && !item.dateFormat) { if (item.dateFormatType === 'custom' && !item.dateFormat) {
return return
} }
post('/dataset/field/save', item) let url
if (checkExp) {
url = '/dataset/field/save'
} else {
url = '/dataset/field/saveNotCheck'
}
post(url, item)
.then((response) => { .then((response) => {
this.initField() this.initField()
localStorage.setItem('reloadDsData', 'true') localStorage.setItem('reloadDsData', 'true')
@ -885,7 +891,7 @@ export default {
} else if (val === 'q') { } else if (val === 'q') {
item.groupType = 'd' item.groupType = 'd'
} }
this.saveEdit(item) this.saveEdit(item, false)
}, },
addCalcField() { addCalcField() {