提交 13f0158a authored 作者: lihuihui's avatar lihuihui
...@@ -42,14 +42,12 @@ const submitForm = async (formEl: FormInstance | undefined) => { ...@@ -42,14 +42,12 @@ const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
await formEl.validate(valid => { await formEl.validate(valid => {
if (valid) { if (valid) {
console.log(store.getMapValuesByKey('teacher_level'), ruleForm.education, 'add')
if (ruleForm.education !== '') { if (ruleForm.education !== '') {
ruleForm.education = store ruleForm.education = store
.getMapValuesByKey('teacher_level') .getMapValuesByKey('teacher_level')
.filter(item => item.value === ruleForm.education)[0].label .filter(item => item.value === ruleForm.education)[0].label
} }
// if (ruleForm.avatar === '') {
// ruleForm.avatar = 'https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png'
// }
const params = Object.assign({}, ruleForm) const params = Object.assign({}, ruleForm)
createTeacher(params).then(() => { createTeacher(params).then(() => {
ElMessage.success('创建讲师成功') ElMessage.success('创建讲师成功')
......
...@@ -10,7 +10,9 @@ const store = useMapStore() ...@@ -10,7 +10,9 @@ const store = useMapStore()
const router = useRouter() const router = useRouter()
const route = useRoute() const route = useRoute()
const appList = ref() const appList = ref()
const levelList = store.getMapValuesByKey('teacher_level') const levelList = $computed(() => {
return store.getMapValuesByKey('teacher_level')
})
const imgDefault = $ref('https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png') const imgDefault = $ref('https://cube.elemecdn.com/9/c2/f0ee8a3c7c9638a54940382568c9dpng.png')
const id = route.query.id as string const id = route.query.id as string
...@@ -69,10 +71,21 @@ const handleUpdate = async (formEl: FormInstance | undefined) => { ...@@ -69,10 +71,21 @@ const handleUpdate = async (formEl: FormInstance | undefined) => {
if (!formEl) return if (!formEl) return
await formEl.validate(valid => { await formEl.validate(valid => {
if (valid) { if (valid) {
console.log(store.getMapValuesByKey('teacher_level'), ruleForm.education, ruleForm.education, 'edit')
if (ruleForm.education !== '') {
ruleForm.education = store
.getMapValuesByKey('teacher_level')
.filter(item => item.label === ruleForm.education)[0].label
} else {
ruleForm.education = ''
}
if (ruleForm.avatar === '') {
ruleForm.avatar = imgDefault
}
const params = Object.assign({}, ruleForm) const params = Object.assign({}, ruleForm)
params.education = store console.log(params, 'params.education')
.getMapValuesByKey('teacher_level')
.filter(item => item.label === ruleForm.education)[0].label console.log(params, 'params')
updateTeacher(params).then(() => { updateTeacher(params).then(() => {
ElMessage.success('更新讲师成功') ElMessage.success('更新讲师成功')
router.push('/admin/teacher') router.push('/admin/teacher')
...@@ -80,6 +93,9 @@ const handleUpdate = async (formEl: FormInstance | undefined) => { ...@@ -80,6 +93,9 @@ const handleUpdate = async (formEl: FormInstance | undefined) => {
} }
}) })
} }
const changeEdu = (val: any) => {
console.log(val, val)
}
onMounted(() => { onMounted(() => {
// 更新获取讲师信息 // 更新获取讲师信息
...@@ -111,6 +127,7 @@ onMounted(() => { ...@@ -111,6 +127,7 @@ onMounted(() => {
style="width: 250px" style="width: 250px"
placeholder="请选择讲师学历" placeholder="请选择讲师学历"
:disabled="isEdit === '1'" :disabled="isEdit === '1'"
@change="changeEdu"
> >
<el-option v-for="(item, index) in levelList" :key="index" :label="item.label" :value="item.value" /> <el-option v-for="(item, index) in levelList" :key="index" :label="item.label" :value="item.value" />
</el-select> </el-select>
......
...@@ -34,6 +34,9 @@ const listOptions = $computed(() => { ...@@ -34,6 +34,9 @@ const listOptions = $computed(() => {
label: '讲师学历', label: '讲师学历',
prop: 'education', prop: 'education',
align: 'center' align: 'center'
// computed(row: any) {
// return row.row.education
// }
}, },
{ label: '创建时间', prop: 'created_time', align: 'center' }, { label: '创建时间', prop: 'created_time', align: 'center' },
{ label: '操作', slots: 'table-operate', width: 230, align: 'center' } { label: '操作', slots: 'table-operate', width: 230, align: 'center' }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论