develoop
parent
a570de2a2f
commit
db33196725
25 changed files with 1623 additions and 1065 deletions
@ -1,5 +1,5 @@ |
|||||||
# 变量必须以 VITE_ 为前缀才能暴露给外部读取 |
# 变量必须以 VITE_ 为前缀才能暴露给外部读取 |
||||||
NODE_ENV = 'development' |
NODE_ENV = 'development' |
||||||
VITE_APP_TITLE = '无糖运营平台' |
VITE_APP_TITLE = '无糖运营平台' |
||||||
# VITE_APP_BASE_API = 'http://127.0.0.1:8008' |
VITE_APP_BASE_API = 'http://127.0.0.1:8080' |
||||||
VITE_APP_BASE_API = 'http://39.106.16.162:8080' |
# VITE_APP_BASE_API = 'http://39.106.16.162:8080' |
||||||
|
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 189 KiB |
@ -1,9 +1,9 @@ |
|||||||
// 引入仓库
|
// 引入仓库
|
||||||
import { createPinia } from 'pinia' |
import { createPinia } from 'pinia' |
||||||
import persist from 'pinia-plugin-persistedstate' |
// import persist from 'pinia-plugin-persistedstate'
|
||||||
// 创建仓库
|
// 创建仓库
|
||||||
const pinia = createPinia() |
const pinia = createPinia() |
||||||
// 暴露仓库
|
// 暴露仓库
|
||||||
pinia.use(persist) |
// pinia.use(persist)
|
||||||
export default pinia |
export default pinia |
||||||
export * from './modules/user' |
// export * from './modules/user'
|
||||||
|
@ -1,213 +1,253 @@ |
|||||||
<template> |
<template> |
||||||
<div class="add-or-edit"> |
<div class="add-or-edit"> |
||||||
<el-drawer v-model="isDrawer" title="新增章节" direction="rtl" size="50%"> |
<el-drawer v-model="isDrawer" title="新增章节" direction="rtl" size="50%"> |
||||||
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto" |
<el-form |
||||||
class="demo-ruleForm" :size="formSize" status-icon> |
ref="ruleFormRef" |
||||||
<el-form-item label="章节" prop="pid"> |
style="max-width: 600px" |
||||||
<el-cascader v-model="activePidArr" :options="options" :props="CascaderProps" |
:model="ruleForm" |
||||||
:show-all-levels="false" clearable /> |
:rules="rules" |
||||||
</el-form-item> |
label-width="auto" |
||||||
<el-form-item label="章节名" prop="name"> |
class="demo-ruleForm" |
||||||
<el-input v-model="ruleForm.name" style="width: 240px" :placeholder="placeholder" /> |
:size="formSize" |
||||||
</el-form-item> |
status-icon |
||||||
<el-form-item label="总学时" prop="totalclasshours"> |
> |
||||||
<el-input v-model="ruleForm.totalclasshours" style="width: 240px" placeholder="请输入总学时" /> |
<el-form-item label="章节" prop="pid"> |
||||||
</el-form-item> |
<el-cascader |
||||||
<el-form-item> |
v-model="activePidArr" |
||||||
<el-button type="primary" :loading="loading" @click="submitForm(ruleFormRef)"> |
:options="options" |
||||||
Create |
:props="CascaderProps" |
||||||
</el-button> |
:show-all-levels="false" |
||||||
<el-button @click="resetForm(ruleFormRef)">Reset</el-button> |
clearable |
||||||
</el-form-item> |
/> |
||||||
</el-form> |
</el-form-item> |
||||||
</el-drawer> |
<el-form-item label="章节名" prop="name"> |
||||||
</div> |
<el-input |
||||||
|
v-model="ruleForm.name" |
||||||
|
style="width: 240px" |
||||||
|
:placeholder="placeholder" |
||||||
|
/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="总学时" prop="totalclasshours"> |
||||||
|
<el-input |
||||||
|
v-model="ruleForm.totalclasshours" |
||||||
|
style="width: 240px" |
||||||
|
placeholder="请输入总学时" |
||||||
|
/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item> |
||||||
|
<el-button |
||||||
|
type="primary" |
||||||
|
:loading="loading" |
||||||
|
@click="submitForm(ruleFormRef)" |
||||||
|
> |
||||||
|
Create |
||||||
|
</el-button> |
||||||
|
<el-button @click="resetForm(ruleFormRef)">Reset</el-button> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
</el-drawer> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
function comNum(n: number | undefined) { |
function comNum(n: number | undefined) { |
||||||
if (n === undefined) return 1 |
if (n === undefined) return 1 |
||||||
return n + 1 |
return n + 1 |
||||||
} |
} |
||||||
import { ref, reactive, watch, computed, nextTick } from 'vue' |
import { ref, reactive, watch, computed, nextTick } from 'vue' |
||||||
const props = defineProps(['isD', 'data', 'loading']) |
const props = defineProps(['isD', 'data', 'loading']) |
||||||
const emits = defineEmits(['update:isD', 'submit']) |
const emits = defineEmits(['update:isD', 'submit']) |
||||||
|
|
||||||
|
|
||||||
const isDrawer = ref(props.isD) |
const isDrawer = ref(props.isD) |
||||||
watch(() => props.isD, newVal => isDrawer.value = newVal) |
watch( |
||||||
watch(() => isDrawer.value, newVal => emits('update:isD', newVal)) |
() => props.isD, |
||||||
|
(newVal) => (isDrawer.value = newVal), |
||||||
|
) |
||||||
|
watch( |
||||||
|
() => isDrawer.value, |
||||||
|
(newVal) => emits('update:isD', newVal), |
||||||
|
) |
||||||
|
|
||||||
const type = false |
const type = false |
||||||
const options = computed(() => { |
const options = computed(() => { |
||||||
if (type) { |
if (type) { |
||||||
const arr = props.data.map((item: any, i: number) => { |
const arr = props.data.map((item: any, i: number) => { |
||||||
const obj = { ...item } |
const obj = { ...item } |
||||||
if (item.chapterSection) obj.chapterSection = item.chapterSection.map((chap: any) => ({ ...chap, disabled: true })) |
if (item.chapterSection) |
||||||
else obj.chapterSection = [] |
obj.chapterSection = item.chapterSection.map((chap: any) => ({ |
||||||
obj.chapterSection.push({ name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, pid: item.id }) |
...chap, |
||||||
return obj |
disabled: true, |
||||||
}) |
})) |
||||||
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
else obj.chapterSection = [] |
||||||
return arr |
obj.chapterSection.push({ |
||||||
} |
name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, |
||||||
return props.data |
pid: item.id, |
||||||
|
}) |
||||||
|
return obj |
||||||
|
}) |
||||||
|
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
||||||
|
return arr |
||||||
|
} |
||||||
|
return props.data |
||||||
}) |
}) |
||||||
const CascaderProps = { |
const CascaderProps = { |
||||||
checkStrictly: !type, |
checkStrictly: !type, |
||||||
label: 'name', |
label: 'name', |
||||||
value: type ? 'pid' : 'id', |
value: type ? 'pid' : 'id', |
||||||
children: 'chapterSection' |
children: 'chapterSection', |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
||||||
|
|
||||||
interface RuleForm { |
interface RuleForm { |
||||||
content: string |
content: string |
||||||
courseid: string |
courseid: string |
||||||
courseobjectivesid: string |
courseobjectivesid: string |
||||||
createBy: string |
createBy: string |
||||||
createTime: string |
createTime: string |
||||||
id: string |
id: string |
||||||
name: string |
name: string |
||||||
num: number |
num: number |
||||||
numshow: string |
numshow: string |
||||||
onlinclasshours: string |
onlinclasshours: string |
||||||
pid: string | undefined |
pid: string | undefined |
||||||
requirement: string |
requirement: string |
||||||
sysOrgCode: string |
sysOrgCode: string |
||||||
totalclasshours: string |
totalclasshours: string |
||||||
updateBy: string |
updateBy: string |
||||||
updateTime: string |
updateTime: string |
||||||
zc: string |
zc: string |
||||||
ziyuan: string |
ziyuan: string |
||||||
zywj: string |
zywj: string |
||||||
} |
} |
||||||
|
|
||||||
const formSize = ref<ComponentSize>('default') |
const formSize = ref<ComponentSize>('default') |
||||||
const ruleFormRef = ref<FormInstance>() |
const ruleFormRef = ref<FormInstance>() |
||||||
let o |
let o |
||||||
if (type) { |
if (type) { |
||||||
o = { |
o = { |
||||||
"content": "", |
content: '', |
||||||
"courseid": "", |
courseid: '', |
||||||
"courseobjectivesid": "", |
courseobjectivesid: '', |
||||||
"createBy": "", |
createBy: '', |
||||||
"createTime": "", |
createTime: '', |
||||||
"id": "", |
id: '', |
||||||
"name": "", |
name: '', |
||||||
"num": 0, |
num: 0, |
||||||
"numshow": "", |
numshow: '', |
||||||
"onlinclasshours": "", |
onlinclasshours: '', |
||||||
"pid": undefined, |
pid: undefined, |
||||||
"requirement": "", |
requirement: '', |
||||||
"sysOrgCode": "", |
sysOrgCode: '', |
||||||
"totalclasshours": "", |
totalclasshours: '', |
||||||
"updateBy": "", |
updateBy: '', |
||||||
"updateTime": "", |
updateTime: '', |
||||||
"zc": "", |
zc: '', |
||||||
"ziyuan": "", |
ziyuan: '', |
||||||
"zywj": "" |
zywj: '', |
||||||
} |
} |
||||||
}else{ |
} else { |
||||||
o = { |
o = { |
||||||
"content": "", |
content: '', |
||||||
"courseid": "", |
courseid: '', |
||||||
"courseobjectivesid": "", |
courseobjectivesid: '', |
||||||
"createBy": "", |
createBy: '', |
||||||
"createTime": "", |
createTime: '', |
||||||
"id": undefined, |
id: undefined, |
||||||
"name": "111", |
name: '111', |
||||||
"num": 0, |
num: 0, |
||||||
"numshow": "", |
numshow: '', |
||||||
"onlinclasshours": "", |
onlinclasshours: '', |
||||||
"pid": "", |
pid: '', |
||||||
"requirement": "", |
requirement: '', |
||||||
"sysOrgCode": "", |
sysOrgCode: '', |
||||||
"totalclasshours": "", |
totalclasshours: '', |
||||||
"updateBy": "", |
updateBy: '', |
||||||
"updateTime": "", |
updateTime: '', |
||||||
"zc": "", |
zc: '', |
||||||
"ziyuan": "", |
ziyuan: '', |
||||||
"zywj": "" |
zywj: '', |
||||||
} |
} |
||||||
} |
} |
||||||
let pxObj |
let pxObj |
||||||
if (type) pxObj = o |
if (type) pxObj = o |
||||||
else { |
else { |
||||||
pxObj = new Proxy(o, { |
pxObj = new Proxy(o, { |
||||||
get(target, key) { |
get(target, key) { |
||||||
if (key === 'pid') return target.id |
if (key === 'pid') return target.id |
||||||
// @ts-ignore |
// @ts-ignore |
||||||
return target[key]; |
return target[key] |
||||||
}, |
}, |
||||||
set: function (obj, prop, value) { |
set: function (obj, prop, value) { |
||||||
if (prop === 'pid') { |
if (prop === 'pid') { |
||||||
obj.id = value |
obj.id = value |
||||||
return true |
return true |
||||||
} |
} |
||||||
|
|
||||||
// @ts-ignore |
// @ts-ignore |
||||||
obj[prop] = value |
obj[prop] = value |
||||||
return true; |
return true |
||||||
} |
}, |
||||||
}) |
}) |
||||||
} |
} |
||||||
// @ts-ignore |
// @ts-ignore |
||||||
const ruleForm = reactive<RuleForm>(pxObj) |
const ruleForm = reactive<RuleForm>(pxObj) |
||||||
|
|
||||||
// @ts-ignore |
// @ts-ignore |
||||||
const validateChapterOrSection = (rule, value, callback) => { |
const validateChapterOrSection = (rule, value, callback) => { |
||||||
nextTick(() => { |
nextTick(() => { |
||||||
const value = ruleForm.pid |
const value = ruleForm.pid |
||||||
if (!value && value !== '') { |
if (!value && value !== '') { |
||||||
if (type) callback(new Error('请选择新增的章或节')) |
if (type) callback(new Error('请选择新增的章或节')) |
||||||
else callback(new Error('请选择编辑的章或节')) |
else callback(new Error('请选择编辑的章或节')) |
||||||
} |
} else callback() |
||||||
else callback() |
}) |
||||||
}) |
} |
||||||
}; |
|
||||||
// 表单验证 |
// 表单验证 |
||||||
const rules = reactive<FormRules<RuleForm>>({ |
const rules = reactive<FormRules<RuleForm>>({ |
||||||
pid: [ |
pid: [ |
||||||
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
||||||
] |
], |
||||||
}) |
}) |
||||||
|
|
||||||
const submitForm = async (formEl: FormInstance | undefined) => { |
const submitForm = async (formEl: FormInstance | undefined) => { |
||||||
if (!formEl) return |
if (!formEl) return |
||||||
await formEl.validate((valid, fields) => { |
await formEl.validate((valid, fields) => { |
||||||
if (valid) { |
if (valid) { |
||||||
console.log(options.value, '1') |
console.log(options.value, '1') |
||||||
console.log(ruleForm); |
console.log(ruleForm) |
||||||
|
|
||||||
// emits('submit', ruleForm) |
// emits('submit', ruleForm) |
||||||
} else { |
} else { |
||||||
console.log('error submit!', fields) |
console.log('error submit!', fields) |
||||||
} |
} |
||||||
}) |
}) |
||||||
} |
} |
||||||
|
|
||||||
const resetForm = (formEl: FormInstance | undefined) => { |
const resetForm = (formEl: FormInstance | undefined) => { |
||||||
if (!formEl) return |
if (!formEl) return |
||||||
formEl.resetFields() |
formEl.resetFields() |
||||||
activePidArr.value = undefined |
activePidArr.value = undefined |
||||||
} |
} |
||||||
const placeholder = ref('请输入章节名') |
const placeholder = ref('请输入章节名') |
||||||
watch(() => ruleForm.pid, newVal => { |
watch( |
||||||
|
() => ruleForm.pid, |
||||||
|
(newVal) => { |
||||||
if (newVal === undefined) placeholder.value = '请输入章节名' |
if (newVal === undefined) placeholder.value = '请输入章节名' |
||||||
else if (newVal === '') placeholder.value = '请输入章名' |
else if (newVal === '') placeholder.value = '请输入章名' |
||||||
else placeholder.value = '请输入节名' |
else placeholder.value = '请输入节名' |
||||||
}) |
}, |
||||||
|
) |
||||||
const activePidArr = ref<string[] | undefined>([]) |
const activePidArr = ref<string[] | undefined>([]) |
||||||
watch(() => activePidArr.value, newVal => {// 设置pid |
watch( |
||||||
|
() => activePidArr.value, |
||||||
|
(newVal) => { |
||||||
|
// 设置pid |
||||||
if (newVal === undefined) { |
if (newVal === undefined) { |
||||||
ruleForm.pid = undefined |
ruleForm.pid = undefined |
||||||
return |
return |
||||||
} |
} |
||||||
ruleForm.pid = newVal.slice(-1)[0] |
ruleForm.pid = newVal.slice(-1)[0] |
||||||
}) |
}, |
||||||
|
) |
||||||
|
|
||||||
</script> |
</script> |
||||||
<style lang="scss"></style> |
<style lang="scss"></style> |
||||||
|
@ -1,155 +1,196 @@ |
|||||||
<template> |
<template> |
||||||
<div class="add-or-edit"> |
<div class="add-or-edit"> |
||||||
<el-drawer v-model="isDrawer" title="新增章节" direction="rtl" size="50%"> |
<el-drawer v-model="isDrawer" title="新增章节" direction="rtl" size="50%"> |
||||||
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto" |
<el-form |
||||||
class="demo-ruleForm" :size="formSize" status-icon> |
ref="ruleFormRef" |
||||||
<el-form-item label="章节" prop="pid"> |
style="max-width: 600px" |
||||||
<el-cascader v-model="activePidArr" :options="options1" :props="CascaderProps" |
:model="ruleForm" |
||||||
:show-all-levels="false" clearable /> |
:rules="rules" |
||||||
</el-form-item> |
label-width="auto" |
||||||
<el-form-item label="章节名" prop="name"> |
class="demo-ruleForm" |
||||||
<el-input v-model="ruleForm.name" style="width: 240px" :placeholder="placeholder" /> |
:size="formSize" |
||||||
</el-form-item> |
status-icon |
||||||
<el-form-item label="总学时" prop="totalclasshours"> |
> |
||||||
<el-input v-model="ruleForm.totalclasshours" style="width: 240px" placeholder="请输入总学时" /> |
<el-form-item label="章节" prop="pid"> |
||||||
</el-form-item> |
<el-cascader |
||||||
<el-form-item> |
v-model="activePidArr" |
||||||
<el-button type="primary" :loading="loading" @click="submitForm(ruleFormRef)"> |
:options="options1" |
||||||
提交 |
:props="CascaderProps" |
||||||
</el-button> |
:show-all-levels="false" |
||||||
<el-button @click="resetForm(ruleFormRef)">重置</el-button> |
clearable |
||||||
</el-form-item> |
/> |
||||||
</el-form> |
</el-form-item> |
||||||
</el-drawer> |
<el-form-item label="章节名" prop="name"> |
||||||
</div> |
<el-input |
||||||
|
v-model="ruleForm.name" |
||||||
|
style="width: 240px" |
||||||
|
:placeholder="placeholder" |
||||||
|
/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item label="总学时" prop="totalclasshours"> |
||||||
|
<el-input |
||||||
|
v-model="ruleForm.totalclasshours" |
||||||
|
style="width: 240px" |
||||||
|
placeholder="请输入总学时" |
||||||
|
/> |
||||||
|
</el-form-item> |
||||||
|
<el-form-item> |
||||||
|
<el-button |
||||||
|
type="primary" |
||||||
|
:loading="loading" |
||||||
|
@click="submitForm(ruleFormRef)" |
||||||
|
> |
||||||
|
提交 |
||||||
|
</el-button> |
||||||
|
<el-button @click="resetForm(ruleFormRef)">重置</el-button> |
||||||
|
</el-form-item> |
||||||
|
</el-form> |
||||||
|
</el-drawer> |
||||||
|
</div> |
||||||
</template> |
</template> |
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
function comNum(n: number | undefined) { |
function comNum(n: number | undefined) { |
||||||
if (n === undefined) return 1 |
if (n === undefined) return 1 |
||||||
return n + 1 |
return n + 1 |
||||||
} |
} |
||||||
import { ref, reactive, watch, computed, nextTick } from 'vue' |
import { ref, reactive, watch, computed, nextTick } from 'vue' |
||||||
const props = defineProps(['isD', 'data']) |
const props = defineProps(['isD', 'data']) |
||||||
const emits = defineEmits(['update:isD','submit']) |
const emits = defineEmits(['update:isD', 'submit']) |
||||||
const loading = ref(false) |
const loading = ref(false) |
||||||
const updLoading = (boo:boolean) => loading.value = boo |
const updLoading = (boo: boolean) => (loading.value = boo) |
||||||
|
|
||||||
const isDrawer = ref(props.isD) |
const isDrawer = ref(props.isD) |
||||||
watch(() => props.isD, newVal => isDrawer.value = newVal) |
watch( |
||||||
watch(()=>isDrawer.value,newVal=>emits('update:isD',newVal)) |
() => props.isD, |
||||||
|
(newVal) => (isDrawer.value = newVal), |
||||||
|
) |
||||||
|
watch( |
||||||
|
() => isDrawer.value, |
||||||
|
(newVal) => emits('update:isD', newVal), |
||||||
|
) |
||||||
|
|
||||||
const options1 = computed(() => { |
const options1 = computed(() => { |
||||||
const arr = props.data.map((item: any, i: number) => { |
const arr = props.data.map((item: any, i: number) => { |
||||||
const obj = { ...item } |
const obj = { ...item } |
||||||
if (item.chapterSection) obj.chapterSection = item.chapterSection.map((chap: any) => ({ ...chap, disabled: true })) |
if (item.chapterSection) |
||||||
else obj.chapterSection = [] |
obj.chapterSection = item.chapterSection.map((chap: any) => ({ |
||||||
obj.chapterSection.push({ name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, pid: item.id }) |
...chap, |
||||||
return obj |
disabled: true, |
||||||
|
})) |
||||||
|
else obj.chapterSection = [] |
||||||
|
obj.chapterSection.push({ |
||||||
|
name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, |
||||||
|
pid: item.id, |
||||||
}) |
}) |
||||||
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
return obj |
||||||
return arr |
}) |
||||||
|
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
||||||
|
return arr |
||||||
}) |
}) |
||||||
const CascaderProps = { |
const CascaderProps = { |
||||||
label: 'name', |
label: 'name', |
||||||
value: 'pid', |
value: 'pid', |
||||||
children: 'chapterSection' |
children: 'chapterSection', |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
||||||
|
|
||||||
interface RuleForm { |
interface RuleForm { |
||||||
content: string |
content: string |
||||||
courseid: string |
courseid: string |
||||||
courseobjectivesid: string |
courseobjectivesid: string |
||||||
createBy: string |
createBy: string |
||||||
createTime: string |
createTime: string |
||||||
id: string |
id: string |
||||||
name: string |
name: string |
||||||
num: number |
num: number |
||||||
numshow: string |
numshow: string |
||||||
onlinclasshours: string |
onlinclasshours: string |
||||||
pid: string | undefined |
pid: string | undefined |
||||||
requirement: string |
requirement: string |
||||||
sysOrgCode: string |
sysOrgCode: string |
||||||
totalclasshours: string |
totalclasshours: string |
||||||
updateBy: string |
updateBy: string |
||||||
updateTime: string |
updateTime: string |
||||||
zc: string |
zc: string |
||||||
ziyuan: string |
ziyuan: string |
||||||
zywj: string |
zywj: string |
||||||
} |
} |
||||||
|
|
||||||
const formSize = ref<ComponentSize>('default') |
const formSize = ref<ComponentSize>('default') |
||||||
const ruleFormRef = ref<FormInstance>() |
const ruleFormRef = ref<FormInstance>() |
||||||
const ruleForm = reactive<RuleForm>({ |
const ruleForm = reactive<RuleForm>({ |
||||||
"content": "", |
content: '', |
||||||
"courseid": "2fa0fd63262230639d2c45a3acd9045c", |
courseid: '2fa0fd63262230639d2c45a3acd9045c', |
||||||
"courseobjectivesid": "", |
courseobjectivesid: '', |
||||||
"createBy": "", |
createBy: '', |
||||||
"createTime": "", |
createTime: '', |
||||||
"id": "", |
id: '', |
||||||
"name": "", |
name: '', |
||||||
"num": 0, |
num: 0, |
||||||
"numshow": "", |
numshow: '', |
||||||
"onlinclasshours": "", |
onlinclasshours: '', |
||||||
"pid": undefined, |
pid: undefined, |
||||||
"requirement": "", |
requirement: '', |
||||||
"sysOrgCode": "", |
sysOrgCode: '', |
||||||
"totalclasshours": "", |
totalclasshours: '', |
||||||
"updateBy": "", |
updateBy: '', |
||||||
"updateTime": "", |
updateTime: '', |
||||||
"zc": "", |
zc: '', |
||||||
"ziyuan": "", |
ziyuan: '', |
||||||
"zywj": "" |
zywj: '', |
||||||
}) |
}) |
||||||
// @ts-ignore |
// @ts-ignore |
||||||
const validateChapterOrSection = (rule, value, callback) => { |
const validateChapterOrSection = (rule, value, callback) => { |
||||||
nextTick(()=>{ |
nextTick(() => { |
||||||
const value =ruleForm.pid |
const value = ruleForm.pid |
||||||
if (!value && value !== '') callback(new Error('请选择新增的章或节')) |
if (!value && value !== '') callback(new Error('请选择新增的章或节')) |
||||||
else callback() |
else callback() |
||||||
}) |
}) |
||||||
}; |
} |
||||||
// 表单验证 |
// 表单验证 |
||||||
const rules = reactive<FormRules<RuleForm>>({ |
const rules = reactive<FormRules<RuleForm>>({ |
||||||
pid: [ |
pid: [ |
||||||
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
||||||
] |
], |
||||||
}) |
}) |
||||||
|
|
||||||
const submitForm = async (formEl: FormInstance | undefined) => { |
const submitForm = async (formEl: FormInstance | undefined) => { |
||||||
if (!formEl) return |
if (!formEl) return |
||||||
await formEl.validate((valid, fields) => { |
await formEl.validate((valid, fields) => { |
||||||
if (valid) { |
if (valid) { |
||||||
emits('submit',ruleForm,updLoading) |
emits('submit', ruleForm, updLoading) |
||||||
} else { |
} else { |
||||||
console.log('error submit!', fields) |
console.log('error submit!', fields) |
||||||
} |
} |
||||||
}) |
}) |
||||||
} |
} |
||||||
|
|
||||||
const resetForm = (formEl: FormInstance | undefined) => { |
const resetForm = (formEl: FormInstance | undefined) => { |
||||||
if (!formEl) return |
if (!formEl) return |
||||||
formEl.resetFields() |
formEl.resetFields() |
||||||
activePidArr.value = undefined |
activePidArr.value = undefined |
||||||
} |
} |
||||||
const placeholder = ref('请输入章节名') |
const placeholder = ref('请输入章节名') |
||||||
watch(() => ruleForm.pid, newVal => { |
watch( |
||||||
|
() => ruleForm.pid, |
||||||
|
(newVal) => { |
||||||
if (newVal === undefined) placeholder.value = '请输入章节名' |
if (newVal === undefined) placeholder.value = '请输入章节名' |
||||||
else if (newVal === '') placeholder.value = '请输入章名' |
else if (newVal === '') placeholder.value = '请输入章名' |
||||||
else placeholder.value = '请输入节名' |
else placeholder.value = '请输入节名' |
||||||
}) |
}, |
||||||
|
) |
||||||
const activePidArr = ref<string[] | undefined>([]) |
const activePidArr = ref<string[] | undefined>([]) |
||||||
watch(() => activePidArr.value, newVal => {// 设置pid |
watch( |
||||||
|
() => activePidArr.value, |
||||||
|
(newVal) => { |
||||||
|
// 设置pid |
||||||
if (newVal === undefined) { |
if (newVal === undefined) { |
||||||
ruleForm.pid = undefined |
ruleForm.pid = undefined |
||||||
return |
return |
||||||
} |
} |
||||||
ruleForm.pid = newVal.slice(-1)[0] |
ruleForm.pid = newVal.slice(-1)[0] |
||||||
}) |
}, |
||||||
|
) |
||||||
|
|
||||||
</script> |
</script> |
||||||
<style lang="scss"></style> |
<style lang="scss"></style> |
||||||
|
@ -0,0 +1,84 @@ |
|||||||
|
<script setup> |
||||||
|
import conheader from '@/views/home/components/ConHeader.vue' |
||||||
|
import fe from '@/assets/images/fe.jpg' |
||||||
|
</script> |
||||||
|
<template> |
||||||
|
<div class="lesson_container" style="width: 95%"> |
||||||
|
<conheader :title="`课程列表`"></conheader> |
||||||
|
<div class="lessonlist-content"> |
||||||
|
<div class="lessonlist-item" v-for="item in 3" :key="item"> |
||||||
|
<div class="lessonlist-item-img"> |
||||||
|
<img :src="fe" alt="" style="width: 100%; height: 140px" /> |
||||||
|
</div> |
||||||
|
<div class="lessonlist-item-info"> |
||||||
|
<h3>课程名称</h3> |
||||||
|
<div class="p"><p>编辑</p></div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
<style scoped> |
||||||
|
.lesson_container { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
justify-content: space-between; |
||||||
|
margin: 0 auto; |
||||||
|
padding: 20px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.lessonlist-content { |
||||||
|
display: flex; |
||||||
|
flex-wrap: wrap; |
||||||
|
justify-content: space-between; |
||||||
|
margin: 10px 0; |
||||||
|
} |
||||||
|
|
||||||
|
.lesson_container { |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
justify-content: space-between; |
||||||
|
margin: 0 auto; |
||||||
|
padding: 5px 0; |
||||||
|
} |
||||||
|
.lessonlist-item { |
||||||
|
width: 270px; |
||||||
|
height: 200px; |
||||||
|
border-radius: 10px; |
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); |
||||||
|
} |
||||||
|
.lessonlist-item-img { |
||||||
|
width: 100%; |
||||||
|
height: 140px; |
||||||
|
} |
||||||
|
.lessonlist-item-info { |
||||||
|
padding: 10px; |
||||||
|
display: flex; |
||||||
|
flex-direction: column; |
||||||
|
justify-content: space-between; |
||||||
|
} |
||||||
|
.lessonlist-item-info h3 { |
||||||
|
font-size: 16px; |
||||||
|
font-weight: bold; |
||||||
|
margin-bottom: 5px; |
||||||
|
} |
||||||
|
.lessonlist-item-info .p { |
||||||
|
width: 100%; |
||||||
|
display: flex; |
||||||
|
justify-content: end; |
||||||
|
} |
||||||
|
.lessonlist-item-info p { |
||||||
|
font-size: 12px; |
||||||
|
color: #a7c4f7; |
||||||
|
line-height: 1.5; |
||||||
|
box-sizing: border-box; |
||||||
|
border: 2px solid #a7c4f7; |
||||||
|
border-radius: 10px; |
||||||
|
margin-bottom: 5px; |
||||||
|
width: 50px; |
||||||
|
margin: 5px; |
||||||
|
text-align: center; |
||||||
|
cursor: pointer; |
||||||
|
} |
||||||
|
</style> |
@ -1,30 +1,5 @@ |
|||||||
<template> |
<template> |
||||||
<div> |
<div>学生</div> |
||||||
<!-- Dialog组件 --> |
|
||||||
<Dialog |
|
||||||
v-model="dialogVisible" |
|
||||||
@confirm="collectData" |
|
||||||
:name="readonlyName" |
|
||||||
:age="readonlyAge" |
|
||||||
/> |
|
||||||
</div> |
|
||||||
</template> |
</template> |
||||||
|
|
||||||
<script setup> |
<style lang="scss"></style> |
||||||
import { ref, readonly } from 'vue' |
|
||||||
|
|
||||||
const dialogVisible = ref(false) // 控制Dialog的显示与隐藏 |
|
||||||
const name = ref('John') // 可修改字段 |
|
||||||
const age = ref(25) // 可修改字段 |
|
||||||
|
|
||||||
const readonlyName = readonly(name) // 将name字段设置为只读 |
|
||||||
const readonlyAge = readonly(age) // 将age字段设置为只读 |
|
||||||
|
|
||||||
const collectData = () => { |
|
||||||
// 在这里可以收集Dialog中的其他可修改字段的数据 |
|
||||||
// ... |
|
||||||
|
|
||||||
console.log(readonlyName.value) // 可以访问只读字段的值 |
|
||||||
console.log(readonlyAge.value) // 可以访问只读字段的值 |
|
||||||
} |
|
||||||
</script> |
|
||||||
|
@ -1,68 +0,0 @@ |
|||||||
<template> |
|
||||||
<div> |
|
||||||
<el-button type="primary" @click="openDrawer">Open Drawer</el-button> |
|
||||||
<el-drawer |
|
||||||
title="Drawer Title" |
|
||||||
v-model:visible="drawerVisible" |
|
||||||
:direction="drawerDirection" |
|
||||||
> |
|
||||||
<el-table :data="formModel" style="width: 100%"> |
|
||||||
<el-table-column prop="name" label="Name"></el-table-column> |
|
||||||
<el-table-column prop="content" label="Content"> |
|
||||||
<template v-slot="scope"> |
|
||||||
<el-input |
|
||||||
v-model="scope.row.content" |
|
||||||
@input="handleInput(scope.row)" |
|
||||||
></el-input> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
|
|
||||||
<template v-slot:footer> |
|
||||||
<div> |
|
||||||
<el-button @click="cancelEdit">Cancel</el-button> |
|
||||||
<el-button type="primary" @click="saveEdit">Save</el-button> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
</el-drawer> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
|
|
||||||
<script> |
|
||||||
export default { |
|
||||||
data() { |
|
||||||
return { |
|
||||||
formModel: [ |
|
||||||
{ name: 'Macbook', content: 9.9 }, |
|
||||||
{ name: 'iPhone', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
{ name: '小米电脑', content: 9.9 }, |
|
||||||
], |
|
||||||
drawerVisible: false, |
|
||||||
drawerDirection: 'ltr', |
|
||||||
} |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
openDrawer() { |
|
||||||
this.drawerVisible = true |
|
||||||
}, |
|
||||||
cancelEdit() { |
|
||||||
this.drawerVisible = false |
|
||||||
}, |
|
||||||
saveEdit() { |
|
||||||
// 执行保存修改的逻辑,可以将数据发送给后端进行保存 |
|
||||||
console.log('Save Edit:', this.formModel) |
|
||||||
this.drawerVisible = false |
|
||||||
}, |
|
||||||
handleInput(row) { |
|
||||||
// 处理输入框的输入事件,可以在此处更新数据 |
|
||||||
console.log('Handle Input:', row) |
|
||||||
}, |
|
||||||
}, |
|
||||||
} |
|
||||||
</script> |
|
Loading…
Reference in new issue