Merge branch 'feature/new-sys' into 'release'
fix: 字段管理新增一个字段 See merge request workbench/y-code!8
This commit is contained in:
commit
5999b3ec9c
@ -71,15 +71,6 @@ const currentChart = computed(() => {
|
||||
return props.chartCfg[chartType.value];
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.filterConfig,
|
||||
(newVal) => {
|
||||
// newVal.forEach((item) => {
|
||||
// filterData.value[item.name] = undefined;
|
||||
// });
|
||||
},
|
||||
);
|
||||
|
||||
const toFilt = () => {
|
||||
const cloneFilter = _.cloneDeep(props.filterConfig);
|
||||
const filter = cloneFilter
|
||||
|
@ -87,16 +87,6 @@ const pageState = reactive({
|
||||
perPage: 20,
|
||||
});
|
||||
|
||||
watch(
|
||||
() => props.filterConfig,
|
||||
(newVal) => {
|
||||
|
||||
// newVal.forEach((item) => {
|
||||
// filterData.value[item.name] = undefined;
|
||||
// });
|
||||
}
|
||||
);
|
||||
|
||||
const getData = () => {
|
||||
const cloneFilter = _.cloneDeep(props.filterConfig);
|
||||
const filter = cloneFilter
|
||||
|
@ -126,10 +126,6 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// onMounted(() => {
|
||||
// toGetDbTable();
|
||||
// });
|
||||
|
||||
const toGetDbTable = () => {
|
||||
getDbTableSelect({ projectId: formData.value.project_id }).then((res) => {
|
||||
tableTypes.value = res.data;
|
||||
|
@ -34,6 +34,7 @@
|
||||
<a-input
|
||||
v-if="editableData[record.field_id]"
|
||||
v-model:value="record[column.dataIndex]"
|
||||
allow-clear
|
||||
placeholder="请输入"
|
||||
/>
|
||||
<template v-else>
|
||||
@ -46,6 +47,7 @@
|
||||
v-model:value="record.field_numerical_type_id"
|
||||
:options="fieldNumTypeSel"
|
||||
placeholder="请选择"
|
||||
allow-clear
|
||||
style="width: 160px">
|
||||
</a-select>
|
||||
<template v-else>
|
||||
@ -58,6 +60,7 @@
|
||||
v-model:value="record.field_type_id"
|
||||
:options="fieldTypeSel"
|
||||
placeholder="请选择"
|
||||
allow-clear
|
||||
style="width: 160px"
|
||||
>
|
||||
</a-select>
|
||||
@ -76,6 +79,19 @@
|
||||
{{ record.is_search ? "是" : "否" }}
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'original_type'">
|
||||
<a-select
|
||||
v-if="editableData[record.field_id]"
|
||||
placeholder="请选择"
|
||||
v-model:value="record.original_type"
|
||||
:options="originalTypes"
|
||||
allow-clear
|
||||
>
|
||||
</a-select>
|
||||
<template v-else>
|
||||
{{ record.original_type_name }}
|
||||
</template>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'action'">
|
||||
<a-space v-if="editableData[record.field_id]">
|
||||
<a-button type="primary" size="small" @click="handleSave(record)"
|
||||
@ -105,7 +121,7 @@
|
||||
|
||||
<script setup>
|
||||
import { onMounted, reactive, ref, watch } from "vue";
|
||||
import { viewCfgCols } from "@/views/config-manage/module-cfg/config";
|
||||
import { viewCfgCols, originalTypes } from "@/views/config-manage/module-cfg/config";
|
||||
import {
|
||||
getFieldTypeSelect,
|
||||
getFieldNumSelect,
|
||||
@ -198,6 +214,7 @@ const addField = () => {
|
||||
is_search: 0,
|
||||
field_type_id: undefined,
|
||||
belong_to_table: undefined,
|
||||
original_type: undefined,
|
||||
original_sql: undefined,
|
||||
sort: 0,
|
||||
};
|
||||
@ -223,22 +240,38 @@ const handleCancel = (record) => {
|
||||
|
||||
const handleSave = (record) => {
|
||||
const params = {
|
||||
field_id: record.field_id,
|
||||
field_title: record.field_title,
|
||||
field_name: record.field_name,
|
||||
field_numerical_type_id: record.field_numerical_type_id,
|
||||
is_search: record.is_search,
|
||||
field_type_id: record.field_type_id,
|
||||
belong_to_table: record.belong_to_table,
|
||||
original_sql: record.original_sql,
|
||||
modular_id: props.modularId,
|
||||
};
|
||||
if (typeof params.field_id === "string") {
|
||||
// 新建
|
||||
delete params.field_id;
|
||||
} else {
|
||||
// 检验必填参数
|
||||
const validateFields = [
|
||||
{ field: 'field_title', msg: "请填写字段标题" },
|
||||
{ field: 'field_name', msg: "请填写字段名称" },
|
||||
{ field: 'field_numerical_type_id', msg: "请选择字段类型" },
|
||||
{ field: 'belong_to_table', msg: "请填写关联表" },
|
||||
{ field: 'original_type', msg: '请选择数据源类型' },
|
||||
{ field: 'original_sql', msg: "请填写sql数据源" },
|
||||
]
|
||||
for(let i = 0; i < validateFields.length; i++) {
|
||||
const curr = validateFields[i];
|
||||
if (!record[curr.field]) {
|
||||
message.error(curr.msg);
|
||||
return;
|
||||
} else {
|
||||
params[curr.field] = record[curr.field];
|
||||
}
|
||||
}
|
||||
if (record.is_search && !record.field_type_id) {
|
||||
message.error("请选择搜索类型");
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是编辑操作
|
||||
if (typeof record.field_id === "number") {
|
||||
params.field_id = record.field_id;
|
||||
}
|
||||
|
||||
saveField(params).then(() => {
|
||||
delete editableData[record.field_id];
|
||||
message.success("保存成功");
|
||||
|
@ -16,6 +16,12 @@ export const viewCfgCols = [
|
||||
{ dataIndex: 'is_search', title: '是否可搜索', align: 'center'},
|
||||
{ dataIndex: 'sort', title: '排序', align: 'center'},
|
||||
{ dataIndex: 'belong_to_table', title: '所属表名称', align: 'center'},
|
||||
{ dataIndex: 'original_sql', title: 'sql数据源', align: 'center'},
|
||||
{ dataIndex: 'original_type', title: '数据源类型', align: 'center'},
|
||||
{ dataIndex: 'original_sql', title: '数据源', align: 'center', width: 400},
|
||||
{ dataIndex: 'action', title: '操作', align: 'center'},
|
||||
];
|
||||
|
||||
export const originalTypes = [
|
||||
{ label: 'sql', value: 1 },
|
||||
{ label: 'json', value: 2 },
|
||||
]
|
||||
|
@ -3,7 +3,7 @@
|
||||
<div class="project">
|
||||
<span>项目: </span>
|
||||
<a-select
|
||||
style="min-width: 120px"
|
||||
style="min-width: 160px"
|
||||
placeholder="请选择项目"
|
||||
v-model:value="projectVal"
|
||||
:options="projectOptions"
|
||||
|
@ -141,6 +141,7 @@ import {
|
||||
import { message } from "ant-design-vue";
|
||||
import { BarChartOutlined } from "@ant-design/icons-vue";
|
||||
import yChart from "@/components/common/y-chart.vue";
|
||||
import _ from 'lodash'
|
||||
|
||||
const projectSel = ref([]); // 项目下拉
|
||||
const modularSel = ref([]) // 数据来源下拉
|
||||
@ -264,7 +265,8 @@ const toPreview = ({filter}) => {
|
||||
previewLoading.value = true;
|
||||
let filterData
|
||||
if (!filter) {
|
||||
filterData = previewData.filterConfig
|
||||
const cloneFilter = _.cloneDeep(previewData.filterConfig)
|
||||
filterData = cloneFilter
|
||||
.filter((item) => {
|
||||
return previewData.filterData[item.name] !== undefined && previewData.filterData[item.name] !== null;
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user