This commit is contained in:
dengweisheng 2023-07-12 11:51:21 +08:00
parent f137561d6e
commit 583646d0a8
4 changed files with 137 additions and 171 deletions

View File

@ -6,6 +6,7 @@ import { createPinia } from "pinia";
import ElementPlus from "element-plus"; //引入element-plus库 import ElementPlus from "element-plus"; //引入element-plus库
import * as ElementPlusIconsVue from "@element-plus/icons-vue"; import * as ElementPlusIconsVue from "@element-plus/icons-vue";
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import VForm3 from "vform3-builds"; //引入VForm3库 import VForm3 from "vform3-builds"; //引入VForm3库
@ -89,4 +90,9 @@ for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
app.directive("permission", permission); app.directive("permission", permission);
app.use(ElementPlus).use(VForm3).use(createPinia()).use(router).mount("#app"); app
.use(ElementPlus, { locale: zhCn })
.use(VForm3)
.use(createPinia())
.use(router)
.mount("#app");

View File

@ -3,17 +3,6 @@
<TableBody v-bind="data" @handleTableHeader="handleTableHeader" @handleTablePagination="handleTablePagination" <TableBody v-bind="data" @handleTableHeader="handleTableHeader" @handleTablePagination="handleTablePagination"
ref="TableBodyRef"> ref="TableBodyRef">
<!-- 右侧顶部插槽 -->
<template #TableHeaderRight="{ selectData }">
<el-select v-model="reqParams.deptId" placeholder="请选择部门" @change="init" clearable class="status-select">
<el-option v-for="item in bmOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
<el-select v-model="reqParams.projectId" placeholder="请选择项目" @change="init" clearable class="status-select">
<el-option v-for="item in bmOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</template>
<!-- 表格插槽使用 --> <!-- 表格插槽使用 -->
<template #state="{ currentCol, currentData }"> <template #state="{ currentCol, currentData }">
<span>{{ currentData == '0' ? "未配置" : "已配置" }}</span> <span>{{ currentData == '0' ? "未配置" : "已配置" }}</span>
@ -27,11 +16,14 @@
<script setup> <script setup>
import { ref, reactive, onMounted } from "vue"; import { ref, reactive, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router"
import TableBody from "@/components/TableBody/TableBody.vue"; import TableBody from "@/components/TableBody/TableBody.vue";
import FormDialog from "@/components/FormDialog/FormDialog.vue"; import FormDialog from "@/components/FormDialog/FormDialog.vue";
import http from "@/utils/request.js"; import http from "@/utils/request.js";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
const route = useRoute()
const bmOptions = ref([]) const bmOptions = ref([])
const TableBodyRef = ref(); const TableBodyRef = ref();
const data = reactive({ const data = reactive({
@ -50,49 +42,7 @@ const data = reactive({
}, },
{ {
buttons: [ buttons: [
{ // "search"
type: "custom", // custom popconfirm ,
name: "ruleButton", // handleTableHeader
title: "配置规则", //
icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary '
// 3. 'custom '4.
isOpen: "custom",
// isOpen custom Boolean | | function
disabled: false,
// permission: false, //
}, {
type: "custom", // custom popconfirm ,
name: "dataButton", // handleTableHeader
title: "数据", //
icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary '
// 3. 'custom '4.
isOpen: "custom",
// isOpen custom Boolean | | function
disabled: false,
// permission: false, //
}, {
type: "custom", // custom popconfirm ,
name: "Button", // handleTableHeader
title: "字段管理", //
icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary '
// 3. 'custom '4.
isOpen: "custom",
// isOpen custom Boolean | | function
disabled: false,
// permission: false, //
},
{
name: "mixInput", //
options: [
{ label: '表中文名', value: 'name' },
{ label: '表英文名', value: 'ename' },
],
// permission: false, //
},
], ],
}, },
// permission // permission
@ -264,12 +214,10 @@ const handleDelete = (data) => {
// //
const handleDetail = (val) => { const handleDetail = (val) => {
console.log('val', val);
formDialogStatus.value = 'detail' formDialogStatus.value = 'detail'
const id = val[0].id const id = val[0].id
FormDialogData.title = '详情' FormDialogData.title = '详情'
http.get(`/api/system/metadata/${id}`).then(response => { http.get(`/api/metadataColumn`, { id }).then(response => {
console.log('response', response);
FormDialogData.formJsonData = response.data FormDialogData.formJsonData = response.data
formDialog.value = true formDialog.value = true
FormDialogData.formJosnDisabled = true FormDialogData.formJosnDisabled = true
@ -291,62 +239,45 @@ const FormDialogData = reactive({
formType: 'json', // 'slot' slot | 'json' json formType: 'json', // 'slot' slot | 'json' json
// json // json
formJosnRules: { formJosnRules: {
deptId: [
{ required: true, message: '请选择所属部门', trigger: 'blur' },
],
projectId: [
{ required: true, message: '请填写所属项目', trigger: 'blur' },
],
name: [ name: [
{ required: true, message: '请填写中文名', trigger: 'blur' }, { required: true, message: '请填写中文字段名', trigger: 'blur' },
], ],
ename: [ ename: [
{ required: true, message: '请填写英文名', trigger: 'blur' }, { required: true, message: '请填写英文字段名', trigger: 'blur' },
], ],
intro: [ intro: [
{ required: true, message: '请填写简介', trigger: 'blur' }, { required: true, message: '请填写简介', trigger: 'blur' },
], ],
state: [ type: [
{ required: true, message: '请选择配置状态', trigger: 'blur' }, { required: true, message: '请填写字段类型', trigger: 'blur' },
], ],
dataNum: [ isPk: [
{ required: true, message: '请填写数据量', trigger: 'blur' }, { required: true, message: '请选择是否主键', trigger: 'blur' },
],
isRequired: [
{ required: true, message: '请选择是否必填', trigger: 'blur' },
],
sortNo: [
{ required: true, message: '请填写数排序', trigger: 'blur' },
], ],
}, // {} }, // {}
formJosnLabelWidth: 'auto', // 120px label formJosnLabelWidth: 'auto', // 120px label
// form // form
formJosnElement: [ formJosnElement: [
{
type: 'tree-select', //
cloSpan: 12, // 24
disabled: false, // false
label: '所属部门', // label
placeholder: '请选择所属部门', // placeholder
model: 'deptId', // form key
options: bmOptions // type select []
},
{ {
type: 'input', // type: 'input', //
cloSpan: 12, // 24 cloSpan: 12, // 24
disabled: false, // false disabled: false, // false
label: '所属项目', // label label: '中文字段名', // label
placeholder: '请填写所属项目', // placeholder placeholder: '请填写中文字段名', // placeholder
model: 'projectId', // form key
},
{
type: 'input', //
cloSpan: 12, // 24
disabled: false, // false
label: '中文表名', // label
placeholder: '请填写中文表名', // placeholder
model: 'name', // form key model: 'name', // form key
}, },
{ {
type: 'input', // type: 'input', //
cloSpan: 12, // 24 cloSpan: 12, // 24
disabled: false, // false disabled: false, // false
label: '英文名', // label label: '英文字段名', // label
placeholder: '请填写英文名', // placeholder placeholder: '请填写英文字段名', // placeholder
model: 'ename', // form key model: 'ename', // form key
}, },
{ {
@ -357,32 +288,57 @@ const FormDialogData = reactive({
placeholder: '请填写简介', // placeholder placeholder: '请填写简介', // placeholder
model: 'intro', // form key model: 'intro', // form key
}, },
{
type: 'input', //
cloSpan: 12, // 24
disabled: false, // false
label: '字段类型', // label
placeholder: '请填写字段类型', // placeholder
model: 'type', // form key
},
{ {
type: 'select', // type: 'select', //
cloSpan: 12, // 24 cloSpan: 12, // 24
disabled: false, // false disabled: false, // false
label: '配置状态', // label label: '是否主键', // label
placeholder: '请选择配置状态', // placeholder placeholder: '请选择', // placeholder
model: 'state', // form key model: 'isPk', // form key
options: [ options: [
{ {
label: '启用', label: '',
value: "1", value: 1,
}, },
{ {
label: '未启用', label: '否',
value: "0", value: 0,
},
] // type select []
},
{
type: 'select', //
cloSpan: 12, // 24
disabled: false, // false
label: '是否必填', // label
placeholder: '请选择', // placeholder
model: 'isRequired', // form key
options: [
{
label: '是',
value: 1,
},
{
label: '否',
value: 0,
}, },
] // type select [] ] // type select []
}, },
{ {
type: 'number', // type: 'number', //
cloSpan: 12, // 24 cloSpan: 12, // 24
disabled: false, // false disabled: false, // false
label: '数据量', // label label: '排序', // label
placeholder: '请填写数据量', // placeholder placeholder: '请填写排序', // placeholder
model: 'dataNum', // form key model: 'sortNo', // form key
}, },
], ],
formJosnDisabled: false, // formJosnDisabled: false, //
@ -392,9 +348,10 @@ const FormDialogData = reactive({
const handleSubmit = (formJsonValue) => { const handleSubmit = (formJsonValue) => {
console.log(formJsonValue) console.log(formJsonValue)
const metadataId = route.query.id
switch (formDialogStatus.value) { switch (formDialogStatus.value) {
case 'create': case 'create':
http.post(`/api/system/metadata`, formJsonValue).then(response => { http.post(`/api/metadataColumn`, { ...formJsonValue, metadataId }).then(response => {
if (response.code == 200) { if (response.code == 200) {
ElMessage({ ElMessage({
message: '新增成功', message: '新增成功',
@ -406,18 +363,17 @@ const handleSubmit = (formJsonValue) => {
}) })
break; break;
case 'edit': case 'edit':
formJsonValue.id = formJsonValue.id // http.post(`/api/system/metadata`, formJsonValue).then(response => {
http.post(`/api/system/metadata`, formJsonValue).then(response => { // if (response.code == 200) {
if (response.code == 200) { // ElMessage({
ElMessage({ // message: '',
message: '编辑成功', // type: 'success',
type: 'success', // })
}) // fromId.value = ''
fromId.value = '' // init()
init() // formDialog.value = false
formDialog.value = false // }
} // })
})
break; break;
default: default:
break; break;
@ -429,27 +385,13 @@ const handleSubmit = (formJsonValue) => {
const reqParams = reactive({ const reqParams = reactive({
page: data.pagination.current, page: data.pagination.current,
size: data.pagination.pageSize, size: data.pagination.pageSize,
deptId: undefined, metadataId: route.query.id,
projectId: undefined,// id
name: undefined,//
ename: undefined, //
}) })
const handleMixInput = (val) => {
reqParams.name = undefined
reqParams.ename = undefined
if (val.seachMixSelect.value === '' || val.seachMixInput.value === '') {
init()
return
}
reqParams[val.seachMixSelect.value] = val.seachMixInput.value
init()
}
// //
const init = () => { const init = () => {
data.tableType.tableLoading = true data.tableType.tableLoading = true
http.get(`/api/system/metadata`, reqParams).then(res => { http.get(`/api/metadataColumn`, reqParams).then(res => {
if (res.code == 200) { if (res.code == 200) {
console.log(res.data) console.log(res.data)
data.tableData = res.data.rows data.tableData = res.data.rows

View File

@ -27,11 +27,14 @@
<script setup> <script setup>
import { ref, reactive, onMounted } from "vue"; import { ref, reactive, onMounted } from "vue";
import { useRouter } from "vue-router"
import TableBody from "@/components/TableBody/TableBody.vue"; import TableBody from "@/components/TableBody/TableBody.vue";
import FormDialog from "@/components/FormDialog/FormDialog.vue"; import FormDialog from "@/components/FormDialog/FormDialog.vue";
import http from "@/utils/request.js"; import http from "@/utils/request.js";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
const router = useRouter()
const bmOptions = ref([]) const bmOptions = ref([])
const TableBodyRef = ref(); const TableBodyRef = ref();
const data = reactive({ const data = reactive({
@ -57,7 +60,7 @@ const data = reactive({
icon: "Switch", // element icon icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary ' // 1. 'single'2. 'Arbitrary '
// 3. 'custom '4. // 3. 'custom '4.
isOpen: "custom", isOpen: "single",
// isOpen custom Boolean | | function // isOpen custom Boolean | | function
disabled: false, disabled: false,
// permission: false, // // permission: false, //
@ -68,18 +71,18 @@ const data = reactive({
icon: "Switch", // element icon icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary ' // 1. 'single'2. 'Arbitrary '
// 3. 'custom '4. // 3. 'custom '4.
isOpen: "custom", isOpen: "single",
// isOpen custom Boolean | | function // isOpen custom Boolean | | function
disabled: false, disabled: false,
// permission: false, // // permission: false, //
}, { }, {
type: "custom", // custom popconfirm , type: "custom", // custom popconfirm ,
name: "Button", // handleTableHeader name: "field", // handleTableHeader
title: "字段管理", // title: "字段管理", //
icon: "Switch", // element icon icon: "Switch", // element icon
// 1. 'single'2. 'Arbitrary ' // 1. 'single'2. 'Arbitrary '
// 3. 'custom '4. // 3. 'custom '4.
isOpen: "custom", isOpen: "single",
// isOpen custom Boolean | | function // isOpen custom Boolean | | function
disabled: false, disabled: false,
// permission: false, // // permission: false, //
@ -213,6 +216,9 @@ const handleTableHeader = ({ type, data }) => {
case "mixInput": case "mixInput":
handleMixInput(data); handleMixInput(data);
break; break;
case "field":
handleField(data);
break;
} }
}; };
// //
@ -276,6 +282,18 @@ const handleDetail = (val) => {
}) })
} }
//
const handleField = (val) => {
const id = val[0].id
router.push({
path: '/dc/field',
query: {
id: id,
}
})
}
// //
// TableBodyRef.value.clearMixInput() // TableBodyRef.value.clearMixInput()