Merge branch 'develoop' of http://182.92.169.222:3000/dlsx/Teaching_integration_platform_admin_template into develoop
commit
a570de2a2f
11 changed files with 5695 additions and 4021 deletions
@ -1,5 +1,5 @@ |
||||
# 变量必须以 VITE_ 为前缀才能暴露给外部读取 |
||||
NODE_ENV = 'development' |
||||
VITE_APP_TITLE = '无糖运营平台' |
||||
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://127.0.0.1:8008' |
||||
VITE_APP_BASE_API = 'http://39.106.16.162:8080' |
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,174 @@ |
||||
import request from '@/utils/request' |
||||
/** |
||||
* 章节顺序linkedlist |
||||
* @param {string} courseid courseid |
||||
* @returns |
||||
* 2fa0fd63262230639d2c45a3acd9045c |
||||
*/ |
||||
export function getChapterApi(courseid: string) { |
||||
return request.get(`/chapter/aaa/${courseid}`); |
||||
} |
||||
|
||||
|
||||
// 响应接口
|
||||
export interface DeleteRes { |
||||
code: number; |
||||
data: boolean; |
||||
message: string; |
||||
} |
||||
|
||||
/** |
||||
* 删除章节信息 |
||||
* @param {string} id id |
||||
* @returns |
||||
*/ |
||||
export function deleteSectionApi(id: string): Promise<DeleteRes> { |
||||
return request.delete(`/chapter/${id}`); |
||||
} |
||||
|
||||
// 响应接口
|
||||
export interface GetByIdCourseVoRes { |
||||
code: number; |
||||
data: { |
||||
classhours: number; |
||||
credit: number; |
||||
description: string; |
||||
id: string; |
||||
img: string; |
||||
name: string; |
||||
objectContent: string; |
||||
teacher: string; |
||||
totalAssignHours: number; |
||||
totalHours: number; |
||||
totalKnow: number; |
||||
totalNotAssignHours: number; |
||||
totalchapter: number; |
||||
}; |
||||
message: string; |
||||
} |
||||
|
||||
/** |
||||
* 根据id查询课程Vo版 |
||||
* @param {string} id id |
||||
* @returns |
||||
*/ |
||||
export function getByIdCourseVoApi(id: string): Promise<GetByIdCourseVoRes> { |
||||
return request.get(`/api/coursesteacher/getById/${id}`); |
||||
} |
||||
|
||||
|
||||
// 参数接口
|
||||
export interface AddChapterParams { |
||||
content?: string; |
||||
courseid?: string; |
||||
courseobjectivesid?: string; |
||||
createBy?: string; |
||||
createTime?: Record<string, unknown>; |
||||
id?: string; |
||||
name?: string; |
||||
num?: number; |
||||
numshow?: string; |
||||
onlinclasshours?: string; |
||||
pid?: string; |
||||
requirement?: string; |
||||
sysOrgCode?: string; |
||||
totalclasshours?: string; |
||||
updateBy?: string; |
||||
updateTime?: Record<string, unknown>; |
||||
zc?: string; |
||||
ziyuan?: string; |
||||
zywj?: string; |
||||
} |
||||
|
||||
// 响应接口
|
||||
export interface AddChapterRes { |
||||
code: number; |
||||
data: boolean; |
||||
message: string; |
||||
} |
||||
|
||||
/** |
||||
* 添加章节 |
||||
* @param {object} params chapter |
||||
* @param {string} params.content 简介 |
||||
* @param {string} params.courseid 课程 |
||||
* @param {string} params.courseobjectivesid 课程目标 |
||||
* @param {string} params.createBy 创建人 |
||||
* @param {object} params.createTime 创建日期 |
||||
* @param {string} params.id 主键 |
||||
* @param {string} params.name 名称 |
||||
* @param {number} params.num 序号 |
||||
* @param {string} params.numshow 内部序号显示 |
||||
* @param {string} params.onlinclasshours 线上学时 |
||||
* @param {string} params.pid 父级节点 |
||||
* @param {string} params.requirement 要求 |
||||
* @param {string} params.sysOrgCode 所属部门 |
||||
* @param {string} params.totalclasshours 总学时 |
||||
* @param {string} params.updateBy 更新人 |
||||
* @param {object} params.updateTime 更新日期 |
||||
* @param {string} params.zc 周次 |
||||
* @param {string} params.ziyuan 资源 |
||||
* @param {string} params.zywj 资源文件 |
||||
* @returns |
||||
*/ |
||||
export function addChapterApi(params: AddChapterParams): Promise<AddChapterRes> { |
||||
return request.post(`/chapter/add`, params); |
||||
} |
||||
|
||||
// 参数接口
|
||||
export interface UpdateChapterParams { |
||||
content?: string; |
||||
courseid?: string; |
||||
courseobjectivesid?: string; |
||||
createBy?: string; |
||||
createTime?: Record<string, unknown>; |
||||
id?: string; |
||||
name?: string; |
||||
num?: number; |
||||
numshow?: string; |
||||
onlinclasshours?: string; |
||||
pid?: string; |
||||
requirement?: string; |
||||
sysOrgCode?: string; |
||||
totalclasshours?: string; |
||||
updateBy?: string; |
||||
updateTime?: Record<string, unknown>; |
||||
zc?: string; |
||||
ziyuan?: string; |
||||
zywj?: string; |
||||
} |
||||
|
||||
// 响应接口
|
||||
export interface UpdateChapterRes { |
||||
code: number; |
||||
data: boolean; |
||||
message: string; |
||||
} |
||||
|
||||
/** |
||||
* 更新章节 |
||||
* @param {object} params chapter |
||||
* @param {string} params.content 简介 |
||||
* @param {string} params.courseid 课程 |
||||
* @param {string} params.courseobjectivesid 课程目标 |
||||
* @param {string} params.createBy 创建人 |
||||
* @param {object} params.createTime 创建日期 |
||||
* @param {string} params.id 主键 |
||||
* @param {string} params.name 名称 |
||||
* @param {number} params.num 序号 |
||||
* @param {string} params.numshow 内部序号显示 |
||||
* @param {string} params.onlinclasshours 线上学时 |
||||
* @param {string} params.pid 父级节点 |
||||
* @param {string} params.requirement 要求 |
||||
* @param {string} params.sysOrgCode 所属部门 |
||||
* @param {string} params.totalclasshours 总学时 |
||||
* @param {string} params.updateBy 更新人 |
||||
* @param {object} params.updateTime 更新日期 |
||||
* @param {string} params.zc 周次 |
||||
* @param {string} params.ziyuan 资源 |
||||
* @param {string} params.zywj 资源文件 |
||||
* @returns |
||||
*/ |
||||
export function updateChapterApi(params: UpdateChapterParams): Promise<UpdateChapterRes> { |
||||
return request.put(`/chapter`, params); |
||||
} |
@ -0,0 +1,213 @@ |
||||
<template> |
||||
<div class="add-or-edit"> |
||||
<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" |
||||
class="demo-ruleForm" :size="formSize" status-icon> |
||||
<el-form-item label="章节" prop="pid"> |
||||
<el-cascader v-model="activePidArr" :options="options" :props="CascaderProps" |
||||
:show-all-levels="false" clearable /> |
||||
</el-form-item> |
||||
<el-form-item label="章节名" prop="name"> |
||||
<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> |
||||
<script lang="ts" setup> |
||||
function comNum(n: number | undefined) { |
||||
if (n === undefined) return 1 |
||||
return n + 1 |
||||
} |
||||
import { ref, reactive, watch, computed, nextTick } from 'vue' |
||||
const props = defineProps(['isD', 'data', 'loading']) |
||||
const emits = defineEmits(['update:isD', 'submit']) |
||||
|
||||
|
||||
const isDrawer = ref(props.isD) |
||||
watch(() => props.isD, newVal => isDrawer.value = newVal) |
||||
watch(() => isDrawer.value, newVal => emits('update:isD', newVal)) |
||||
|
||||
const type = false |
||||
const options = computed(() => { |
||||
if (type) { |
||||
const arr = props.data.map((item: any, i: number) => { |
||||
const obj = { ...item } |
||||
if (item.chapterSection) obj.chapterSection = item.chapterSection.map((chap: any) => ({ ...chap, disabled: true })) |
||||
else obj.chapterSection = [] |
||||
obj.chapterSection.push({ name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, pid: item.id }) |
||||
return obj |
||||
}) |
||||
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
||||
return arr |
||||
} |
||||
return props.data |
||||
}) |
||||
const CascaderProps = { |
||||
checkStrictly: !type, |
||||
label: 'name', |
||||
value: type ? 'pid' : 'id', |
||||
children: 'chapterSection' |
||||
} |
||||
|
||||
|
||||
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
||||
|
||||
interface RuleForm { |
||||
content: string |
||||
courseid: string |
||||
courseobjectivesid: string |
||||
createBy: string |
||||
createTime: string |
||||
id: string |
||||
name: string |
||||
num: number |
||||
numshow: string |
||||
onlinclasshours: string |
||||
pid: string | undefined |
||||
requirement: string |
||||
sysOrgCode: string |
||||
totalclasshours: string |
||||
updateBy: string |
||||
updateTime: string |
||||
zc: string |
||||
ziyuan: string |
||||
zywj: string |
||||
} |
||||
|
||||
const formSize = ref<ComponentSize>('default') |
||||
const ruleFormRef = ref<FormInstance>() |
||||
let o |
||||
if (type) { |
||||
o = { |
||||
"content": "", |
||||
"courseid": "", |
||||
"courseobjectivesid": "", |
||||
"createBy": "", |
||||
"createTime": "", |
||||
"id": "", |
||||
"name": "", |
||||
"num": 0, |
||||
"numshow": "", |
||||
"onlinclasshours": "", |
||||
"pid": undefined, |
||||
"requirement": "", |
||||
"sysOrgCode": "", |
||||
"totalclasshours": "", |
||||
"updateBy": "", |
||||
"updateTime": "", |
||||
"zc": "", |
||||
"ziyuan": "", |
||||
"zywj": "" |
||||
} |
||||
}else{ |
||||
o = { |
||||
"content": "", |
||||
"courseid": "", |
||||
"courseobjectivesid": "", |
||||
"createBy": "", |
||||
"createTime": "", |
||||
"id": undefined, |
||||
"name": "111", |
||||
"num": 0, |
||||
"numshow": "", |
||||
"onlinclasshours": "", |
||||
"pid": "", |
||||
"requirement": "", |
||||
"sysOrgCode": "", |
||||
"totalclasshours": "", |
||||
"updateBy": "", |
||||
"updateTime": "", |
||||
"zc": "", |
||||
"ziyuan": "", |
||||
"zywj": "" |
||||
} |
||||
} |
||||
let pxObj |
||||
if (type) pxObj = o |
||||
else { |
||||
pxObj = new Proxy(o, { |
||||
get(target, key) { |
||||
if (key === 'pid') return target.id |
||||
// @ts-ignore |
||||
return target[key]; |
||||
}, |
||||
set: function (obj, prop, value) { |
||||
if (prop === 'pid') { |
||||
obj.id = value |
||||
return true |
||||
} |
||||
|
||||
// @ts-ignore |
||||
obj[prop] = value |
||||
return true; |
||||
} |
||||
}) |
||||
} |
||||
// @ts-ignore |
||||
const ruleForm = reactive<RuleForm>(pxObj) |
||||
|
||||
// @ts-ignore |
||||
const validateChapterOrSection = (rule, value, callback) => { |
||||
nextTick(() => { |
||||
const value = ruleForm.pid |
||||
if (!value && value !== '') { |
||||
if (type) callback(new Error('请选择新增的章或节')) |
||||
else callback(new Error('请选择编辑的章或节')) |
||||
} |
||||
else callback() |
||||
}) |
||||
}; |
||||
// 表单验证 |
||||
const rules = reactive<FormRules<RuleForm>>({ |
||||
pid: [ |
||||
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
||||
] |
||||
}) |
||||
|
||||
const submitForm = async (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
await formEl.validate((valid, fields) => { |
||||
if (valid) { |
||||
console.log(options.value, '1') |
||||
console.log(ruleForm); |
||||
|
||||
// emits('submit', ruleForm) |
||||
} else { |
||||
console.log('error submit!', fields) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
formEl.resetFields() |
||||
activePidArr.value = undefined |
||||
} |
||||
const placeholder = ref('请输入章节名') |
||||
watch(() => ruleForm.pid, newVal => { |
||||
if (newVal === undefined) placeholder.value = '请输入章节名' |
||||
else if (newVal === '') placeholder.value = '请输入章名' |
||||
else placeholder.value = '请输入节名' |
||||
}) |
||||
const activePidArr = ref<string[] | undefined>([]) |
||||
watch(() => activePidArr.value, newVal => {// 设置pid |
||||
if (newVal === undefined) { |
||||
ruleForm.pid = undefined |
||||
return |
||||
} |
||||
ruleForm.pid = newVal.slice(-1)[0] |
||||
}) |
||||
|
||||
|
||||
</script> |
||||
<style lang="scss"></style> |
@ -0,0 +1,155 @@ |
||||
<template> |
||||
<div class="add-or-edit"> |
||||
<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" |
||||
class="demo-ruleForm" :size="formSize" status-icon> |
||||
<el-form-item label="章节" prop="pid"> |
||||
<el-cascader v-model="activePidArr" :options="options1" :props="CascaderProps" |
||||
:show-all-levels="false" clearable /> |
||||
</el-form-item> |
||||
<el-form-item label="章节名" prop="name"> |
||||
<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> |
||||
<script lang="ts" setup> |
||||
function comNum(n: number | undefined) { |
||||
if (n === undefined) return 1 |
||||
return n + 1 |
||||
} |
||||
import { ref, reactive, watch, computed, nextTick } from 'vue' |
||||
const props = defineProps(['isD', 'data']) |
||||
const emits = defineEmits(['update:isD','submit']) |
||||
const loading = ref(false) |
||||
const updLoading = (boo:boolean) => loading.value = boo |
||||
|
||||
const isDrawer = ref(props.isD) |
||||
watch(() => props.isD, newVal => isDrawer.value = newVal) |
||||
watch(()=>isDrawer.value,newVal=>emits('update:isD',newVal)) |
||||
|
||||
|
||||
const options1 = computed(() => { |
||||
const arr = props.data.map((item: any, i: number) => { |
||||
const obj = { ...item } |
||||
if (item.chapterSection) obj.chapterSection = item.chapterSection.map((chap: any) => ({ ...chap, disabled: true })) |
||||
else obj.chapterSection = [] |
||||
obj.chapterSection.push({ name: `第${i + 1}章第${comNum(item.chapterSection?.length)}节`, pid: item.id }) |
||||
return obj |
||||
}) |
||||
arr.push({ name: `第${arr.length + 1}章`, pid: '' }) |
||||
return arr |
||||
}) |
||||
const CascaderProps = { |
||||
label: 'name', |
||||
value: 'pid', |
||||
children: 'chapterSection' |
||||
} |
||||
|
||||
|
||||
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
||||
|
||||
interface RuleForm { |
||||
content: string |
||||
courseid: string |
||||
courseobjectivesid: string |
||||
createBy: string |
||||
createTime: string |
||||
id: string |
||||
name: string |
||||
num: number |
||||
numshow: string |
||||
onlinclasshours: string |
||||
pid: string | undefined |
||||
requirement: string |
||||
sysOrgCode: string |
||||
totalclasshours: string |
||||
updateBy: string |
||||
updateTime: string |
||||
zc: string |
||||
ziyuan: string |
||||
zywj: string |
||||
} |
||||
|
||||
const formSize = ref<ComponentSize>('default') |
||||
const ruleFormRef = ref<FormInstance>() |
||||
const ruleForm = reactive<RuleForm>({ |
||||
"content": "", |
||||
"courseid": "2fa0fd63262230639d2c45a3acd9045c", |
||||
"courseobjectivesid": "", |
||||
"createBy": "", |
||||
"createTime": "", |
||||
"id": "", |
||||
"name": "", |
||||
"num": 0, |
||||
"numshow": "", |
||||
"onlinclasshours": "", |
||||
"pid": undefined, |
||||
"requirement": "", |
||||
"sysOrgCode": "", |
||||
"totalclasshours": "", |
||||
"updateBy": "", |
||||
"updateTime": "", |
||||
"zc": "", |
||||
"ziyuan": "", |
||||
"zywj": "" |
||||
}) |
||||
// @ts-ignore |
||||
const validateChapterOrSection = (rule, value, callback) => { |
||||
nextTick(()=>{ |
||||
const value =ruleForm.pid |
||||
if (!value && value !== '') callback(new Error('请选择新增的章或节')) |
||||
else callback() |
||||
}) |
||||
}; |
||||
// 表单验证 |
||||
const rules = reactive<FormRules<RuleForm>>({ |
||||
pid: [ |
||||
{ required: true, validator: validateChapterOrSection, trigger: 'change' }, |
||||
] |
||||
}) |
||||
|
||||
const submitForm = async (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
await formEl.validate((valid, fields) => { |
||||
if (valid) { |
||||
emits('submit',ruleForm,updLoading) |
||||
} else { |
||||
console.log('error submit!', fields) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
formEl.resetFields() |
||||
activePidArr.value = undefined |
||||
} |
||||
const placeholder = ref('请输入章节名') |
||||
watch(() => ruleForm.pid, newVal => { |
||||
if (newVal === undefined) placeholder.value = '请输入章节名' |
||||
else if (newVal === '') placeholder.value = '请输入章名' |
||||
else placeholder.value = '请输入节名' |
||||
}) |
||||
const activePidArr = ref<string[] | undefined>([]) |
||||
watch(() => activePidArr.value, newVal => {// 设置pid |
||||
if (newVal === undefined) { |
||||
ruleForm.pid = undefined |
||||
return |
||||
} |
||||
ruleForm.pid = newVal.slice(-1)[0] |
||||
}) |
||||
|
||||
|
||||
</script> |
||||
<style lang="scss"></style> |
@ -0,0 +1,155 @@ |
||||
<template> |
||||
<div class="add-or-edit"> |
||||
<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" |
||||
class="demo-ruleForm" :size="formSize" status-icon> |
||||
<el-form-item label="章节" prop="id"> |
||||
<el-cascader v-model="activeIdArr" :options="options1" :props="CascaderProps" |
||||
:show-all-levels="false" clearable /> |
||||
</el-form-item> |
||||
<el-form-item label="章节名" prop="name"> |
||||
<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> |
||||
<script lang="ts" setup> |
||||
import { ref, reactive, watch, computed } from 'vue' |
||||
const props = defineProps(['isD', 'data', 'editData']) |
||||
const emits = defineEmits(['update:isD', 'submit']) |
||||
const loading = ref(false) |
||||
const updLoading = (boo:boolean) => loading.value = boo |
||||
|
||||
const isDrawer = ref(props.isD) |
||||
watch(() => props.isD, newVal => isDrawer.value = newVal) |
||||
watch(() => isDrawer.value, newVal => emits('update:isD', newVal)) |
||||
|
||||
|
||||
const options1 = computed(() => props.data) |
||||
const CascaderProps = { |
||||
checkStrictly: true, |
||||
label: 'name', |
||||
value: 'id', |
||||
children: 'chapterSection' |
||||
} |
||||
|
||||
|
||||
import type { ComponentSize, FormInstance, FormRules } from 'element-plus' |
||||
import { isArray } from 'element-plus/es/utils/types.mjs'; |
||||
|
||||
interface RuleForm { |
||||
content: string |
||||
courseid: string |
||||
courseobjectivesid: string |
||||
createBy: string |
||||
createTime: string |
||||
id: string | undefined |
||||
name: string |
||||
num: number |
||||
numshow: string |
||||
onlinclasshours: string |
||||
pid: string |
||||
requirement: string |
||||
sysOrgCode: string |
||||
totalclasshours: string |
||||
updateBy: string |
||||
updateTime: string |
||||
zc: string |
||||
ziyuan: string |
||||
zywj: string |
||||
} |
||||
|
||||
const formSize = ref<ComponentSize>('default') |
||||
const ruleFormRef = ref<FormInstance>() |
||||
const ruleForm = reactive<RuleForm>({ ...props.editData }) |
||||
|
||||
// 表单验证 |
||||
const rules = reactive<FormRules<RuleForm>>({ |
||||
id: [ |
||||
{ required: true, message: '请选择要更新的章节', trigger: 'change' }, |
||||
] |
||||
}) |
||||
|
||||
const submitForm = async (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
await formEl.validate((valid, fields) => { |
||||
if (valid) { |
||||
emits('submit', ruleForm,updLoading) |
||||
} else { |
||||
console.log('error submit!', fields) |
||||
} |
||||
}) |
||||
} |
||||
|
||||
const resetForm = (formEl: FormInstance | undefined) => { |
||||
if (!formEl) return |
||||
formEl.resetFields() |
||||
activeIdArr.value = getCheckedChapter(options1.value) |
||||
} |
||||
|
||||
watch(() => ruleForm.id, newVal => { |
||||
const obj =getCheckedChapterObj(options1.value,newVal) |
||||
// const arr = getCheckedChapter(options1.value) |
||||
// let obj |
||||
// if (arr.length === 1) obj = options1.value.find((item: any) => item.id === arr[0]) |
||||
// else if (arr.length === 2) obj = options1.value.find((item: any) => item.id === arr[0]).value.find((item: any) => item.id === arr[1]) |
||||
if (obj) Object.assign(ruleForm, obj) |
||||
}) |
||||
const placeholder = ref('请输入章节名') |
||||
watch(() => ruleForm.pid, newVal => { |
||||
if (newVal === '') placeholder.value = '请输入章名' |
||||
else placeholder.value = '请输入节名' |
||||
},{immediate:true}) |
||||
// 得到选中的章节id数组 |
||||
function getCheckedChapter(array: any) { |
||||
let i = 0, arr: any[] = [], f: any |
||||
(function fn(array: any) { |
||||
if (!isArray(array)) return |
||||
const ch = array.find((item: any) => item.id === ruleForm.id) |
||||
if (ch === undefined && i < array.length) { |
||||
f = array[i].id |
||||
fn(array[i++].chapterSection) |
||||
} |
||||
if (ch === undefined) return |
||||
if (f) arr.push(f) |
||||
arr.push(ch.id) |
||||
}(array)) |
||||
return arr |
||||
} |
||||
// 得到选中的章节 |
||||
function getCheckedChapterObj(array: any,id:any) { |
||||
let i = 0, arr: any[] = []; |
||||
(function fn(array: any) { |
||||
if (!isArray(array)) return |
||||
const ch = array.find((item: any) => item.id === id) |
||||
if (ch === undefined && i < array.length) { |
||||
fn(array[i++].chapterSection) |
||||
} |
||||
if (ch === undefined) return |
||||
arr.push(ch) |
||||
}(array)) |
||||
return arr[0] |
||||
} |
||||
|
||||
const activeIdArr = ref<string[] | undefined>(getCheckedChapter(options1.value)) |
||||
watch(() => activeIdArr.value, newVal => {// 设置id |
||||
if (newVal === undefined) { |
||||
ruleForm.id = undefined |
||||
return |
||||
} |
||||
ruleForm.id = newVal.slice(-1)[0] |
||||
}) |
||||
|
||||
|
||||
</script> |
||||
<style lang="scss"></style> |
Loading…
Reference in new issue