【新增】租户创建修改的时候新增专业的点位数据创建和新增
This commit is contained in:
@@ -13,6 +13,7 @@ export interface TenantVO {
|
||||
expireTime: Date
|
||||
accountCount: number
|
||||
createTime: Date
|
||||
tenantSpecialtyPointsVOList: any
|
||||
}
|
||||
|
||||
export interface TenantPageReqVO extends PageParam {
|
||||
@@ -36,6 +37,11 @@ export const getTenantPage = (params: TenantPageReqVO) => {
|
||||
return request.get({ url: '/system/tenant/page', params })
|
||||
}
|
||||
|
||||
// 查询租户对应专业授权列表
|
||||
export const getTenantSpecialty = (id: number) => {
|
||||
return request.get({ url: '/system/tenant/get-id-by-specialty?id=' + id })
|
||||
}
|
||||
|
||||
// 查询租户详情
|
||||
export const getTenant = (id: number) => {
|
||||
return request.get({ url: '/system/tenant/get?id=' + id })
|
||||
|
@@ -10,12 +10,12 @@
|
||||
<el-form-item label="上级专业" prop="parentId">
|
||||
<el-tree-select
|
||||
v-model="formData.parentId"
|
||||
:data="deptTree"
|
||||
:data="specialtyTree"
|
||||
:props="defaultProps"
|
||||
check-strictly
|
||||
default-expand-all
|
||||
placeholder="请选择上级专业"
|
||||
value-key="deptId"
|
||||
value-key="spId"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="专业名称" prop="spName">
|
||||
@@ -73,7 +73,7 @@ const formRules = reactive<FormRules>({
|
||||
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const deptTree = ref() // 树形结构
|
||||
const specialtyTree = ref() // 树形结构
|
||||
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||
|
||||
/** 打开弹窗 */
|
||||
@@ -142,10 +142,10 @@ const resetForm = () => {
|
||||
|
||||
/** 获得专业-课程-题型树 */
|
||||
const getTree = async () => {
|
||||
deptTree.value = []
|
||||
specialtyTree.value = []
|
||||
const data = await SpecialtyApi.getSpecialtyPage()
|
||||
let dept: Tree = { id: 0, name: '专业-课程-题型', children: [] }
|
||||
dept.children = handleTree(data)
|
||||
deptTree.value.push(dept)
|
||||
specialtyTree.value.push(dept)
|
||||
}
|
||||
</script>
|
||||
|
120
src/views/system/tenant/Demo03CourseForm.vue
Normal file
120
src/views/system/tenant/Demo03CourseForm.vue
Normal file
@@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
>
|
||||
<el-table :data="formData" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" width="100" />
|
||||
<el-table-column label="课程名称" min-width="150">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.name`" class="mb-0px!">
|
||||
<el-tree-select
|
||||
v-model="row.specialtyId"
|
||||
:data="specialtyTree"
|
||||
:props="defaultProps"
|
||||
check-strictly
|
||||
default-expand-all
|
||||
value-key="spId"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="授权数量" min-width="150">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.score`" class="mb-0px!">
|
||||
<el-input v-model="row.points" placeholder="请输入授权数量" type="number"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="60">
|
||||
<template #default="{ $index }">
|
||||
<el-button @click="handleDelete($index)" link>—</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<el-row justify="center" class="mt-3">
|
||||
<el-button @click="handleAdd" round>+ 添加课程</el-button>
|
||||
</el-row>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import * as TenantSpecialtyApi from '@/api/system/tenant'
|
||||
import * as SpecialtyApi from '@/api/exam/specialty'
|
||||
import * as TenantPackageApi from "@/api/system/tenantPackage";
|
||||
import {defaultProps, handleTree} from '@/utils/tree'
|
||||
|
||||
const packageList = ref([] as TenantPackageApi.TenantPackageVO[]) // 租户套餐
|
||||
const specialtyTree = ref() // 树形结构
|
||||
const props = defineProps<{
|
||||
tenantId: undefined // 租户ID(主表的关联字段)
|
||||
}>()
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const formData = ref([])
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 监听主表的关联字段的变化,加载对应的子表数据 */
|
||||
watch(
|
||||
() => props.tenantId,
|
||||
async (val) => {
|
||||
// 1. 重置表单
|
||||
formData.value = []
|
||||
// 2. val 非空,则加载数据
|
||||
if (!val) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
formLoading.value = true
|
||||
// 获得专业树
|
||||
await getTree();
|
||||
formData.value = await TenantSpecialtyApi.getTenantSpecialty(val)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
// 获得专业树
|
||||
getTree();
|
||||
const row = {
|
||||
id: undefined,
|
||||
specialtyId: undefined,
|
||||
tenantId: undefined,
|
||||
points: undefined
|
||||
}
|
||||
row.tenantId = props.tenantId
|
||||
formData.value.push(row)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = (index) => {
|
||||
formData.value.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 表单校验 */
|
||||
const validate = () => {
|
||||
return formRef.value.validate()
|
||||
}
|
||||
|
||||
/** 表单值 */
|
||||
const getData = () => {
|
||||
return formData.value
|
||||
}
|
||||
|
||||
defineExpose({ validate, getData })
|
||||
|
||||
/** 获得专业-课程-题型树 */
|
||||
const getTree = async () => {
|
||||
specialtyTree.value = []
|
||||
const data = await SpecialtyApi.getSpecialtyPage()
|
||||
let dept: Tree = { id: 0, name: '专业-课程-题型', children: [] }
|
||||
dept.children = handleTree(data)
|
||||
specialtyTree.value.push(dept)
|
||||
}
|
||||
</script>
|
@@ -69,6 +69,12 @@
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<!-- 子表的表单 -->
|
||||
<el-tabs v-model="subTabsName">
|
||||
<el-tab-pane label="课程授权" name="demo03Course">
|
||||
<Demo03CourseForm ref="demo03CourseFormRef" :tenant-id="formData.id" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
@@ -80,6 +86,7 @@ import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import * as TenantApi from '@/api/system/tenant'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
import * as TenantPackageApi from '@/api/system/tenantPackage'
|
||||
import Demo03CourseForm from "@/views/system/tenant/Demo03CourseForm.vue";
|
||||
|
||||
defineOptions({ name: 'SystemTenantForm' })
|
||||
|
||||
@@ -117,6 +124,10 @@ const formRules = reactive({
|
||||
const formRef = ref() // 表单 Ref
|
||||
const packageList = ref([] as TenantPackageApi.TenantPackageVO[]) // 租户套餐
|
||||
|
||||
/** 子表的表单 */
|
||||
const subTabsName = ref('demo03Course')
|
||||
const demo03CourseFormRef = ref()
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
@@ -144,10 +155,20 @@ const submitForm = async () => {
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
// 校验子表单
|
||||
// 校验子表单
|
||||
try {
|
||||
await demo03CourseFormRef.value.validate()
|
||||
} catch (e) {
|
||||
subTabsName.value = 'demo03Course'
|
||||
return
|
||||
}
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as TenantApi.TenantVO
|
||||
// 拼接子表的数据
|
||||
data.tenantSpecialtyPointsVOList = demo03CourseFormRef.value.getData()
|
||||
if (formType.value === 'create') {
|
||||
await TenantApi.createTenant(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
|
Reference in New Issue
Block a user