98 lines
3.0 KiB
Vue

<template>
<div class="app-container">
<el-card v-loading="cardLoading">
<el-page-header @back="goBack">
<template #content>
<el-row :gutter="10">
<el-col :span="1.5">
<el-button type="default" plain icon="Refresh" @click="handleInit"> 初始化 </el-button>
</el-col>
</el-row>
</template>
</el-page-header>
<el-divider />
<el-row :gutter="10">
<el-col :span="10">
<el-card>
<template #header>
<b>模型</b>
</template>
<el-table :data="modelList" height="580" border highlight-current-row @current-change="handleCurrentChange">
<el-table-column prop="fullName" label="模型" />
</el-table>
</el-card>
</el-col>
<el-col :span="14">
<el-card>
<template #header>
<div class="flex justify-between items-center">
<b>数据字段</b>
<el-button type="primary" plain>{{ $t('btn.save') }}</el-button>
</div>
</template>
<el-table v-loading="fieldListLoading" :data="fieldList" height="580" border>
<el-table-column prop="fieldName" label="字段名称" />
<el-table-column prop="fieldType" label="字段类型" />
<el-table-column prop="isPermission" label="是否授权" align="center">
<template #default="scope">
<el-switch v-model="scope.row.isPermission" class="ml-2" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949" />
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script setup lang="ts">
import useTagsViewStore from '@/store/modules/tagsView.js'
import { getModelList, initFields, getFields } from '@/api/system/field'
const router = useRouter()
const route = useRoute()
const cardLoading = ref(false)
const goBack = () => {
useTagsViewStore().delView(router.currentRoute.value)
router.push('/system/role')
}
console.log(route.query.roleId)
const handleInit = async () => {
await initFields()
}
interface model {
fullName: string
// properties: field[]
}
interface field {
id: number
fieldName: string
fieldType: string
isPermission: boolean
}
const modelList = ref<model[]>([])
const fieldList = ref<field[]>([])
const getList = async () => {
cardLoading.value = true
const { data } = await getModelList()
modelList.value = data
cardLoading.value = false
}
const handleCurrentChange = async (val: any) => {
fieldListLoading.value = true
const { data } = await getFields({ fullName: val.fullName, roleId: route.query.roleId })
fieldList.value = data
fieldListLoading.value = false
}
const getProperties = (row) => {
console.log(row)
}
const fieldListLoading = ref(false)
const value2 = ref(true)
onMounted(() => {
getList()
})
</script>
<style scoped lang="scss"></style>