|
|
@@ -3,18 +3,17 @@ meta:
|
|
|
enabled: false
|
|
|
</route>
|
|
|
|
|
|
-<script lang="ts" setup>
|
|
|
+<script lang="ts" setup name="daasObjectEdit">
|
|
|
import Sortable from 'sortablejs'
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { createObject, getObjectById, updateObject } from '@/api/model/objectApi'
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
|
|
|
-const emit = defineEmits(['success'])
|
|
|
-
|
|
|
const settingsStore = useSettingsStore()
|
|
|
-
|
|
|
const route = useRoute()
|
|
|
+const modelId = parseInt(route.params.modelId.toString())
|
|
|
+const objectId = parseInt(route.params.objectId.toString())
|
|
|
const router = useRouter()
|
|
|
const tabbar = useTabbar()
|
|
|
|
|
|
@@ -27,7 +26,7 @@ interface ObjectAttr {
|
|
|
attrDecimals: number
|
|
|
isNotNull: number
|
|
|
isFixed: number
|
|
|
- attrComment: string
|
|
|
+ comment: string
|
|
|
isPKey: number
|
|
|
sortNo: number
|
|
|
}
|
|
|
@@ -37,6 +36,7 @@ const dataType = [
|
|
|
{ dataType: 2, dataName: '字符串' },
|
|
|
{ dataType: 3, dataName: '小数' }]
|
|
|
|
|
|
+// 数据
|
|
|
const state = reactive({
|
|
|
title: '',
|
|
|
dialogVisible: false,
|
|
|
@@ -45,8 +45,9 @@ const state = reactive({
|
|
|
keywords: '',
|
|
|
},
|
|
|
formData: {
|
|
|
- modelId: 0,
|
|
|
- objectId: 0,
|
|
|
+ modelId,
|
|
|
+ objectId,
|
|
|
+ objectType: 1,
|
|
|
objectCode: '',
|
|
|
objectTitle: '',
|
|
|
comment: '',
|
|
|
@@ -58,18 +59,21 @@ const state = reactive({
|
|
|
const formRef = ref<FormInstance>()
|
|
|
const formRules = ref<FormRules>({
|
|
|
objectTitle: [
|
|
|
- { required: true, message: '请输入标题', trigger: 'blur' },
|
|
|
+ { required: true, message: '请输入对象标题', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ objectType: [
|
|
|
+ { required: true, message: '请输入对象类型', trigger: 'blur' },
|
|
|
],
|
|
|
objectCode: [
|
|
|
- { required: true, message: '请输入标题', trigger: 'blur' },
|
|
|
+ { required: true, message: '请输入对像代码', trigger: 'blur' },
|
|
|
],
|
|
|
comment: [
|
|
|
- { required: false, message: '请输入描述', trigger: 'blur' },
|
|
|
+ { required: false, message: '请输入简要描述', trigger: 'blur' },
|
|
|
],
|
|
|
})
|
|
|
|
|
|
// 查询数据
|
|
|
-const getData = async (modelId: number, objectId: number) => {
|
|
|
+const getData = async () => {
|
|
|
state.loading = true
|
|
|
const { data } = await getObjectById(modelId, objectId)
|
|
|
state.loading = false
|
|
|
@@ -89,7 +93,7 @@ function onAttrAdd() {
|
|
|
isNotNull: 0, // 是否为空
|
|
|
isFixed: 0, // 是否锁定
|
|
|
isPKey: 0, // 主键
|
|
|
- attrComment: '', // 注释
|
|
|
+ comment: '', // 注释
|
|
|
sortNo: 0,
|
|
|
})
|
|
|
nextTick(() => {
|
|
|
@@ -121,6 +125,16 @@ function onAttrDrag() {
|
|
|
}
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ if (objectId <= 0) {
|
|
|
+ state.title = '新增对象'
|
|
|
+ state.actionType = 1
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ state.title = '编辑对象'
|
|
|
+ state.actionType = 2
|
|
|
+ getData()
|
|
|
+ }
|
|
|
+
|
|
|
nextTick(() => {
|
|
|
onAttrDrag()
|
|
|
})
|
|
|
@@ -135,47 +149,17 @@ function onSubmit() {
|
|
|
await createObject(state.formData)
|
|
|
state.dialogVisible = false
|
|
|
ElMessage.success('新增成功')
|
|
|
- emit('success')
|
|
|
}
|
|
|
else {
|
|
|
await updateObject(state.formData)
|
|
|
state.dialogVisible = false
|
|
|
ElMessage.success('修改成功')
|
|
|
- emit('success')
|
|
|
}
|
|
|
+ goBack()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function resetFormData() {
|
|
|
- state.formData = {
|
|
|
- modelId: 0,
|
|
|
- objectId: 0,
|
|
|
- objectCode: '',
|
|
|
- objectTitle: '',
|
|
|
- comment: '',
|
|
|
- attrs: [],
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-defineExpose({
|
|
|
- showAddModel(modelId: number) {
|
|
|
- resetFormData()
|
|
|
- state.title = '新增对象'
|
|
|
- state.actionType = 1
|
|
|
- state.dialogVisible = true
|
|
|
- state.formData.modelId = modelId
|
|
|
- },
|
|
|
- showEditModel(modelId: number, objectId: number) {
|
|
|
- resetFormData()
|
|
|
- state.title = '编辑对象'
|
|
|
- state.actionType = 2
|
|
|
- state.dialogVisible = true
|
|
|
- getData(modelId, objectId)
|
|
|
- },
|
|
|
-
|
|
|
-})
|
|
|
-
|
|
|
function onCancel() {
|
|
|
goBack()
|
|
|
}
|
|
|
@@ -189,14 +173,11 @@ function goBack() {
|
|
|
router.push({ name: 'daasModel' })
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-const getPermitData = () => {}
|
|
|
-const onPermitAdd = () => {}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="absolute-container">
|
|
|
- <page-header title="应用权限管理" content="为每个应用配置基于角色的权限。">
|
|
|
+ <page-header title="对象" content="为每个应用配置基于角色的权限。">
|
|
|
<el-button size="default" round @click="goBack">
|
|
|
<template #icon>
|
|
|
<el-icon>
|
|
|
@@ -217,9 +198,22 @@ const onPermitAdd = () => {}
|
|
|
<el-form-item label="对象名称" prop="objectTitle">
|
|
|
<el-input v-model="state.formData.objectTitle" placeholder="请输入标题" />
|
|
|
</el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="类型" prop="objectType">
|
|
|
+ <el-radio-group v-model="state.formData.objectType">
|
|
|
+ <el-radio :label="1">
|
|
|
+ 实体对象
|
|
|
+ </el-radio>
|
|
|
+ <el-radio :label="2">
|
|
|
+ 视图对象
|
|
|
+ </el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
<el-form-item label="对象代码" prop="objectCode">
|
|
|
<el-input v-model="state.formData.objectCode" placeholder="请输入代码" />
|
|
|
</el-form-item>
|
|
|
+
|
|
|
<el-form-item label="简要说明" prop="comment">
|
|
|
<el-input v-model="state.formData.comment" type="textarea" rows="10" placeholder="请输入标题" />
|
|
|
</el-form-item>
|
|
|
@@ -230,9 +224,12 @@ const onPermitAdd = () => {}
|
|
|
|
|
|
<div class="container">
|
|
|
<tool-bar>
|
|
|
+ <template #left>
|
|
|
+ <h2>属性</h2>
|
|
|
+ </template>
|
|
|
<template #right>
|
|
|
<el-input v-model="state.search.keywords" placeholder="请输入关键词筛选字典项" clearable style="width: 200px;" />
|
|
|
- <el-button @click="getPermitData">
|
|
|
+ <el-button @click="getData">
|
|
|
<template #icon>
|
|
|
<el-icon>
|
|
|
<svg-icon name="i-ep:search" />
|
|
|
@@ -240,7 +237,7 @@ const onPermitAdd = () => {}
|
|
|
</template>
|
|
|
</el-button>
|
|
|
|
|
|
- <el-button type="primary" @click="onPermitAdd">
|
|
|
+ <el-button type="primary" @click="onAttrAdd">
|
|
|
<template #icon>
|
|
|
<el-icon>
|
|
|
<svg-icon name="i-ep:plus" />
|
|
|
@@ -250,7 +247,6 @@ const onPermitAdd = () => {}
|
|
|
</template>
|
|
|
</tool-bar>
|
|
|
|
|
|
- <h2>属性</h2>
|
|
|
<el-table ref="attrsTableRef" :key="attrsTableKey" :data="state.formData.attrs" class="list-table" border stripe highlight-current-row>
|
|
|
<el-table-column width="60" align="center" fixed>
|
|
|
<template #header>
|
|
|
@@ -338,7 +334,7 @@ const onPermitAdd = () => {}
|
|
|
|
|
|
<el-table-column label="注释" width="120">
|
|
|
<template #default="scope">
|
|
|
- <el-input v-model="scope.row.attrComment" />
|
|
|
+ <el-input v-model="scope.row.comment" />
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
@@ -356,59 +352,16 @@ const onPermitAdd = () => {}
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</div>
|
|
|
- <template #footer>
|
|
|
- <div style="flex: auto">
|
|
|
- <el-button type="primary" size="large" @click="onSubmit">
|
|
|
- 提交
|
|
|
- </el-button>
|
|
|
- <el-button size="large" @click="onCancel">
|
|
|
- 取消
|
|
|
- </el-button>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
</LayoutContainer>
|
|
|
</div>
|
|
|
+
|
|
|
+ <fixed-action-bar>
|
|
|
+ <el-button type="primary" size="large" @click="onSubmit">
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
+ <el-button size="large" @click="onCancel">
|
|
|
+ 取消
|
|
|
+ </el-button>
|
|
|
+ </fixed-action-bar>
|
|
|
</div>
|
|
|
</template>
|
|
|
-
|
|
|
-<style lang="scss" scoped>
|
|
|
-.form-right-side {
|
|
|
- // display: flex;
|
|
|
- // flex-direction: column;
|
|
|
- // width: 500px;
|
|
|
- padding: var(--container-padding);
|
|
|
- border-left: 1px dashed var(--el-disabled-border-color);
|
|
|
- background-color: var(--g-app-bg);
|
|
|
- transition: background-color 0.3s;
|
|
|
-
|
|
|
- :deep(.el-table) {
|
|
|
- height: 100%;
|
|
|
- margin-top: 15px;
|
|
|
-
|
|
|
- .el-table__row {
|
|
|
- .index {
|
|
|
- display: inline-block;
|
|
|
- }
|
|
|
-
|
|
|
- .delete {
|
|
|
- display: none;
|
|
|
- }
|
|
|
-
|
|
|
- &:hover {
|
|
|
- .index {
|
|
|
- display: none;
|
|
|
- }
|
|
|
-
|
|
|
- .delete {
|
|
|
- display: inline-block;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- .el-tag.sortable,
|
|
|
- .el-tag.sortable .el-icon {
|
|
|
- cursor: s-resize;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
-</style>
|