<script lang="ts" setup>
import useVuelidate from '@vuelidate/core'
import { required } from '@/utils/vuelidate/vuelidate-rules'
import { em } from '@/utils/vuelidate/vuelidate-helper'
import { getCurrentInstance } from 'vue'
import { getCourseGroupItemList, bindCourseGroupItemList } from '@/api/course-setup'
import useDialogPluginComponent from '@/components/global-render/use-dialog-plugin-component'
const route = useRoute()
const props = defineProps<{
row: TeacherListItem | undefined
CertCourseOptions
SchoolCourseOptions
attributeList
}>()
const multipleTableRef = ref()
const { visible, onDialogHide, onDialogOK } = useDialogPluginComponent()
const tableData = ref([])
const attribute = ref()
const certCourseTypeId = ref()
/* const schoolCourseTypeId = ref() */
const certPlanId = ref(route.query.id)
const name = ref()
const id = ref(props.row.id)
async function execute() {
try {
const params = {
id: id.value,
certCourseTypeId: certCourseTypeId.value,
certPlanId: certPlanId.value,
attribute: attribute.value,
name: name.value,
}
const { data } = await getCourseGroupItemList(params)
tableData.value = data.data
tableData.value.forEach((item) => {
if (item.checkStatus === true && item.otherCourseCheckStatus === false) {
multipleTableRef.value?.toggleRowSelection(item, true)
}
})
} catch (error) {
errorHandler(error)
}
}
async function onOkClick() {
try {
const params = {
certPlanCourseId: id.value,
certPlanCourseVOList: selectable.value,
}
await bindCourseGroupItemList(params)
ElMessage.success('保存成功')
onDialogOK()
} catch (error) {
errorHandler(error, '保存失败')
}
}
const selectable = ref<[]>([])
async function reset() {
name.value = ''
attribute.value = ''
certCourseTypeId.value = ''
execute()
}
const handleSelectionChange = (selection: []) => {
selectable.value = selection
}
async function select(row, index) {
if (row.checkStatus === true && row.otherCourseCheckStatus === true) {
return false // 禁用
} else {
return true //不禁用
}
}
execute()
</script>
<template>
<ElDialog v-model="visible" width="800px" title="管理课程" center @closed="onDialogHide">
<TableLayout>
<template #filter>
<ElForm class="flex" style="background-color: #f2f2f2; padding: 10px 0 0 10px; margin-bottom: 20px; height: 130px; display: flex; flex-wrap: wrap">
<ElFormItem>
<ElInput v-model="name" placeholder="请输入课程名称" />
</ElFormItem>
<ElFormItem>
<el-select v-model="attribute" placeholder="课程属性" style="width: 240px">
<el-option v-for="item in props.attributeList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</ElFormItem>
<ElFormItem>
<el-select v-model="certCourseTypeId" placeholder="专业课程类别" style="width: 240px">
<el-option v-for="item in props.CertCourseOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</ElFormItem>
<!-- <ElFormItem>
<el-select v-model="schoolCourseTypeId" placeholder="学校课程类别" style="width: 240px">
<el-option v-for="item in props.SchoolCourseOptions" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</ElFormItem> -->
<ElFormItem class="ml-4">
<ElButton type="primary" @click="execute()"> 搜索 </ElButton>
<ElButton type="primary" @click="reset()"> 重置 </ElButton>
</ElFormItem>
</ElForm>
</template>
<template #table>
<el-Table @select-all="handleSelectionChange" @selection-change="handleSelectionChange" :row-key="(row) => row.id" ref="multipleTableRef" v-loading="isLoading" :data="tableData" border>
<el-table-column type="selection" width="55" :reserve-selection="true" :selectable="select" />
<ElTableColumn label="课程名称" prop="name" />
<ElTableColumn label="课程代码" prop="code" />
<ElTableColumn label="适用学年" prop="path" />
<ElTableColumn label="专业认证类别" prop="certCourseTypeName" />
<ElTableColumn label="属性" prop="attributeName" />
</el-Table>
</template>
</TableLayout>
<div style="text-align: center; margin: 30px 0">
<ElButton type="primary" @click="onOkClick()" style="border-radius: 20px; width: 200px; height: 40px"> 保存 </ElButton>
</div>
</ElDialog>
</template>
<style lang="scss" scoped>
.text-center {
margin-top: 50px;
}
::v-deep .el-card {
border: none !important;
}
</style>
eltable是在eldialog里面的,我设置了eltable的默认选中和type=selection的禁用,但是禁用不生效,也不是不生效,只是接口请求已发送,禁用状态就会消失,怎么禁用呢