edit
This commit is contained in:
parent
1814f811d4
commit
7be60a3d72
|
@ -107,9 +107,13 @@ const getBackGroundV2 = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const createOutlineV2 = async (data) => {
|
const createOutlineV2 = async (params) => {
|
||||||
try {
|
try {
|
||||||
const response = await req("/api/aipptV2/createOutlineV2", "POST", data);
|
const response = await request({
|
||||||
|
url:"/api/aipptV2/createOutlineV2",
|
||||||
|
method: "POST",
|
||||||
|
params
|
||||||
|
});
|
||||||
console.log("createOutline response:", response);
|
console.log("createOutline response:", response);
|
||||||
|
|
||||||
return response.data;
|
return response.data;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import emitter from '@/utils/mitt'
|
||||||
import * as commUtils from '@/utils/comm.js'
|
import * as commUtils from '@/utils/comm.js'
|
||||||
import { createChart, sendChart } from '@/api/ai/index'
|
import { createChart, sendChart } from '@/api/ai/index'
|
||||||
import { completion, addSyllabus, syllabuss, removeSyllabus } from '@/api/mode/index.js'
|
import { completion, addSyllabus, syllabuss, removeSyllabus } from '@/api/mode/index.js'
|
||||||
|
import { createOutlineV2 } from '@/utils/ppt-request.js'
|
||||||
import TypingEffect from '@/components/typing-effect/index.vue'
|
import TypingEffect from '@/components/typing-effect/index.vue'
|
||||||
import useUserStore from '@/store/modules/user'
|
import useUserStore from '@/store/modules/user'
|
||||||
|
|
||||||
|
@ -59,6 +60,7 @@ const modeOptions = ref([
|
||||||
// 选中的环节
|
// 选中的环节
|
||||||
const selectedData = ref([])
|
const selectedData = ref([])
|
||||||
emitter.on('selected', (data)=>{
|
emitter.on('selected', (data)=>{
|
||||||
|
console.log(data,3000)
|
||||||
selectedData.value = data
|
selectedData.value = data
|
||||||
})
|
})
|
||||||
// 回显大纲
|
// 回显大纲
|
||||||
|
@ -119,9 +121,11 @@ const createAi = async ()=>{
|
||||||
// 知识库模型
|
// 知识库模型
|
||||||
else {
|
else {
|
||||||
const res = await completion(params)
|
const res = await completion(params)
|
||||||
|
|
||||||
data = res.data
|
data = res.data
|
||||||
}
|
}
|
||||||
console.log(data)
|
const res = await createOutlineV2({query: data.answer})
|
||||||
|
console.log(res)
|
||||||
emitter.emit('onResult', data.answer)
|
emitter.emit('onResult', data.answer)
|
||||||
answer.value = getResult(data.answer)
|
answer.value = getResult(data.answer)
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,11 @@
|
||||||
<span>教学模式</span>
|
<span>教学模式</span>
|
||||||
<div>
|
<div>
|
||||||
<el-button type="primary" link @click="resetSelect">重置</el-button>
|
<el-button type="primary" link @click="resetSelect">重置</el-button>
|
||||||
<el-button type="primary" link @click="addVisible = true; addChild = false; isEdit = false"><i class="iconfont icon-jiahao"
|
<el-button type="primary" link @click="
|
||||||
></i>新增</el-button>
|
addVisible = true
|
||||||
|
addChild = false
|
||||||
|
isEdit = false
|
||||||
|
"><i class="iconfont icon-jiahao"></i>新增</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="left-list">
|
<div class="left-list">
|
||||||
|
@ -25,21 +28,22 @@
|
||||||
<!--减号 选中之后显示-->
|
<!--减号 选中之后显示-->
|
||||||
<i v-show="item.selected" class="iconfont icon-zuixiaohua"></i>
|
<i v-show="item.selected" class="iconfont icon-zuixiaohua"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-child flex" :class="child.selected ? 'act-child' : ''" v-for="child in item.children" :key="child.id"
|
<div class="item-child flex" :class="child.selected ? 'act-child' : ''" v-for="child in item.children"
|
||||||
@mouseenter="child.isAdd = true" @mouseleave="child.isAdd = false" @click="toggleChild(item,child)">
|
:key="child.id" @mouseenter="child.isAdd = true" @mouseleave="child.isAdd = false"
|
||||||
|
@click="toggleChild(item, child)">
|
||||||
<div>
|
<div>
|
||||||
<span>{{ child.name }}</span>
|
<span>{{ child.name }}</span>
|
||||||
<!--个人教学模式才会有编辑-->
|
<!--个人教学模式才会有编辑-->
|
||||||
<el-button v-if="!child.ex3" class="ml-3" type="primary" link @click.stop="editMode(child)">编辑</el-button>
|
<el-button v-if="!child.ex3" class="ml-3" type="primary" link @click.stop="editMode(child)">编辑</el-button>
|
||||||
</div>
|
</div>
|
||||||
<i v-show="child.isAdd && !child.selected" class="iconfont icon-jiahao"></i>
|
<i v-show="child.isAdd && !child.selected" class="iconfont icon-jiahao"></i>
|
||||||
<i v-show="child.selected" class="iconfont icon-zuixiaohua "></i>
|
<i v-show="child.selected" class="iconfont icon-zuixiaohua"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--弹窗-->
|
<!--弹窗-->
|
||||||
<el-dialog v-model="addVisible" append-to-body :show-close="false" width="550" :before-close="handleBeforeClose"
|
<el-dialog v-model="addVisible" append-to-body :show-close="false" width="550" :before-close="handleBeforeClose"
|
||||||
style="border-radius: 10px; padding: 10px 15px;">
|
style="border-radius: 10px; padding: 10px 15px">
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="mode-dialog-header flex">
|
<div class="mode-dialog-header flex">
|
||||||
<span>{{ addChild ? '教学环节' : '教学模式' }}</span>
|
<span>{{ addChild ? '教学环节' : '教学模式' }}</span>
|
||||||
|
@ -48,8 +52,8 @@
|
||||||
</template>
|
</template>
|
||||||
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto"
|
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto"
|
||||||
class="demo-ruleForm">
|
class="demo-ruleForm">
|
||||||
<el-form-item :label="`教学${ addChild ? '环节' : '模式'}名称`" prop="name">
|
<el-form-item :label="`教学${addChild ? '环节' : '模式'}名称`" prop="name">
|
||||||
<div class="flex" style="width: 100%;">
|
<div class="flex" style="width: 100%">
|
||||||
<el-input v-model="ruleForm.name" />
|
<el-input v-model="ruleForm.name" />
|
||||||
<el-button v-if="isEdit" link type="danger" class="ml-5 mr-3" @click="onDel">删除</el-button>
|
<el-button v-if="isEdit" link type="danger" class="ml-5 mr-3" @click="onDel">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -64,7 +68,6 @@
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
@ -77,127 +80,130 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { addChildTemp, editChildTemp, removeChildTemp, syllabusList } from '@/api/mode'
|
import { addChildTemp, editChildTemp, removeChildTemp, syllabusList } from '@/api/mode'
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
|
|
||||||
|
|
||||||
const { user } = useUserStore()
|
const { user } = useUserStore()
|
||||||
|
|
||||||
// 获取主模板
|
// 获取模板
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
let list = ref([])
|
|
||||||
const getTemplate = async (id) => {
|
|
||||||
loading.value = true
|
|
||||||
const { rows } = await modelList({ createUser: user.userId, model: 4, type: 1, pageNum: 1, pageSize: 10000 })
|
|
||||||
loading.value = false
|
|
||||||
list.value = rows
|
|
||||||
if (list.value.length) {
|
|
||||||
getChildTemp(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取子模板
|
|
||||||
const templateList = ref([])
|
const templateList = ref([])
|
||||||
const getChildTemp = async () => {
|
const getTemplate = async () => {
|
||||||
templateList.value = []
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
const { rows } = await modelList({
|
||||||
for (let item of list.value) {
|
createUser: user.userId,
|
||||||
try {
|
model: 4,
|
||||||
let { rows } = await modelList({ model: 4, type: 2, parentId: item.id })
|
pageNum: 1,
|
||||||
templateList.value.push({
|
pageSize: 10000
|
||||||
...item,
|
|
||||||
children: rows
|
|
||||||
})
|
})
|
||||||
} finally {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
|
||||||
}
|
// 过滤出 type 为 1 的项
|
||||||
|
let ary1 = rows.filter((item) => item.type === 1)
|
||||||
|
templateList.value = ary1.map((parent) => {
|
||||||
|
parent.children = rows.filter((child) => child.type === 2 && child.parentId === parent.id)
|
||||||
|
return parent
|
||||||
|
})
|
||||||
getSyllabus()
|
getSyllabus()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询生成大纲记录
|
// 查询生成大纲记录
|
||||||
const getSyllabus = async () =>{
|
const getSyllabus = async () => {
|
||||||
const { rows } = await syllabusList()
|
const { rows } = await syllabusList({
|
||||||
if(rows && rows.length){
|
createUserId: user.userId,
|
||||||
const idsAry = rows.at(-1).modelIds.split(',').map(item => Number(item));
|
eduId: curNode.id,
|
||||||
|
sourceType: 1,
|
||||||
|
pageSize: 1,
|
||||||
|
orderByColumn: 'createTime',
|
||||||
|
isAsc: 'desc'
|
||||||
|
})
|
||||||
|
if (rows && rows.length) {
|
||||||
|
const idsAry = rows
|
||||||
|
.at(-1)
|
||||||
|
.modelIds.split(',')
|
||||||
|
.map((item) => Number(item))
|
||||||
// 设置选中
|
// 设置选中
|
||||||
|
let ary = []
|
||||||
templateList.value.forEach((parent) => {
|
templateList.value.forEach((parent) => {
|
||||||
parent.children.forEach((child) => {
|
parent.children.forEach((child) => {
|
||||||
child.selected = idsAry.includes(child.id);
|
child.selected = idsAry.includes(child.id)
|
||||||
});
|
if (child.selected) {
|
||||||
|
ary.push(child)
|
||||||
|
}
|
||||||
|
})
|
||||||
// 更新父项的 selected 状态
|
// 更新父项的 selected 状态
|
||||||
parent.selected = parent.children.every((child) => child.selected);
|
parent.selected = parent.children.every((child) => child.selected)
|
||||||
});
|
})
|
||||||
// 回显大纲数据
|
// 回显大纲数据
|
||||||
emitter.emit('onShow', rows.at(-1))
|
emitter.emit('onShow', rows.at(-1))
|
||||||
|
emitter.emit('selected', ary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重置选中
|
// 重置选中
|
||||||
const resetSelect = () =>{
|
const resetSelect = () => {
|
||||||
templateList.value.forEach(item =>{
|
templateList.value.forEach((item) => {
|
||||||
item.selected = false
|
item.selected = false
|
||||||
item.children.forEach( el=>{
|
item.children.forEach((el) => {
|
||||||
el.selected = false
|
el.selected = false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
emitter.emit('selected', [])
|
emitter.emit('selected', [])
|
||||||
}
|
}
|
||||||
|
|
||||||
emitter.on('resetSelect', () =>{
|
emitter.on('resetSelect', () => {
|
||||||
resetSelect()
|
resetSelect()
|
||||||
})
|
})
|
||||||
|
|
||||||
// 点击教学模式
|
// 点击教学模式
|
||||||
const toggleParent = (parent) => {
|
const toggleParent = (parent) => {
|
||||||
parent.selected = !parent.selected;
|
parent.selected = !parent.selected
|
||||||
parent.children.forEach(child => {
|
parent.children.forEach((child) => {
|
||||||
child.selected = parent.selected;
|
child.selected = parent.selected
|
||||||
});
|
})
|
||||||
const selectedData = templateList.value.map((item) => item.children.filter((child) => child.selected)).flat()
|
const selectedData = templateList.value
|
||||||
|
.map((item) => item.children.filter((child) => child.selected))
|
||||||
|
.flat()
|
||||||
// .flat()将二维数组扁平化为一维数组
|
// .flat()将二维数组扁平化为一维数组
|
||||||
emitter.emit('selected', selectedData)
|
emitter.emit('selected', selectedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击教学环节
|
// 点击教学环节
|
||||||
const toggleChild = (parent,child) =>{
|
const toggleChild = (parent, child) => {
|
||||||
child.selected = !child.selected;
|
child.selected = !child.selected
|
||||||
updateParentSelection(parent)
|
updateParentSelection(parent)
|
||||||
const selectedData = templateList.value.map((item) => item.children.filter((child) => child.selected)).flat()
|
const selectedData = templateList.value
|
||||||
|
.map((item) => item.children.filter((child) => child.selected))
|
||||||
|
.flat()
|
||||||
emitter.emit('selected', selectedData)
|
emitter.emit('selected', selectedData)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查父项(教学模式)的所有子项(教学环节)是否都被选中,如果是,则设置父项为选中状态,否则取消选中
|
// 检查父项(教学模式)的所有子项(教学环节)是否都被选中,如果是,则设置父项为选中状态,否则取消选中
|
||||||
const updateParentSelection = (parent) => {
|
const updateParentSelection = (parent) => {
|
||||||
parent.selected = parent.children.every((child) => child.selected);
|
parent.selected = parent.children.every((child) => child.selected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 弹窗
|
// 弹窗
|
||||||
const addVisible = ref(false)
|
const addVisible = ref(false)
|
||||||
|
|
||||||
const ruleFormRef = ref()
|
const ruleFormRef = ref()
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
name: [
|
name: [{ required: true, message: '不能为空', trigger: 'blur' }]
|
||||||
{ required: true, message: '不能为空', trigger: 'blur' },
|
|
||||||
]
|
|
||||||
})
|
})
|
||||||
const ruleForm = reactive({
|
const ruleForm = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
prompt: ''
|
prompt: ''
|
||||||
})
|
})
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async (formEl) =>{
|
const onSubmit = async (formEl) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate(async (valid, fields) => {
|
await formEl.validate(async (valid, fields) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
|
||||||
// 修改
|
// 修改
|
||||||
if(isEdit.value){
|
if (isEdit.value) {
|
||||||
let data = cloneDeep(curEditItem)
|
let data = cloneDeep(curEditItem)
|
||||||
data.name = ruleForm.name
|
data.name = ruleForm.name
|
||||||
await editChildTemp(data)
|
await editChildTemp(data)
|
||||||
}
|
}
|
||||||
// 新增
|
// 新增
|
||||||
else{
|
else {
|
||||||
let obj = {
|
let obj = {
|
||||||
ex1: curNode.edustage,
|
ex1: curNode.edustage,
|
||||||
ex2: curNode.edusubject,
|
ex2: curNode.edusubject,
|
||||||
|
@ -207,13 +213,12 @@ const onSubmit = async (formEl) =>{
|
||||||
type: 1
|
type: 1
|
||||||
}
|
}
|
||||||
// 新增教学环节
|
// 新增教学环节
|
||||||
if(addChild.value){
|
if (addChild.value) {
|
||||||
obj.parentId = curEditItem.id
|
obj.parentId = curEditItem.id
|
||||||
obj.prompt = ruleForm.prompt
|
obj.prompt = ruleForm.prompt
|
||||||
obj.type = 2
|
obj.type = 2
|
||||||
}
|
}
|
||||||
await addChildTemp(obj)
|
await addChildTemp(obj)
|
||||||
|
|
||||||
}
|
}
|
||||||
ElMessage.success('操作成功')
|
ElMessage.success('操作成功')
|
||||||
resetForm()
|
resetForm()
|
||||||
|
@ -231,7 +236,7 @@ const isEdit = ref(false)
|
||||||
const addChild = ref(false)
|
const addChild = ref(false)
|
||||||
|
|
||||||
const curEditItem = reactive({})
|
const curEditItem = reactive({})
|
||||||
const addModeChild = (item) =>{
|
const addModeChild = (item) => {
|
||||||
isEdit.value = false
|
isEdit.value = false
|
||||||
Object.assign(curEditItem, item)
|
Object.assign(curEditItem, item)
|
||||||
addChild.value = true
|
addChild.value = true
|
||||||
|
@ -240,7 +245,7 @@ const addModeChild = (item) =>{
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
const editMode = (item)=>{
|
const editMode = (item) => {
|
||||||
isEdit.value = true
|
isEdit.value = true
|
||||||
addChild.value = false
|
addChild.value = false
|
||||||
Object.assign(curEditItem, item)
|
Object.assign(curEditItem, item)
|
||||||
|
@ -249,16 +254,12 @@ const editMode = (item)=>{
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除 教学模式 教学环节
|
// 删除 教学模式 教学环节
|
||||||
const onDel = () =>{
|
const onDel = () => {
|
||||||
ElMessageBox.confirm(
|
ElMessageBox.confirm('确定要删除模板吗?', '温馨提示', {
|
||||||
'确定要删除模板吗?',
|
|
||||||
'温馨提示',
|
|
||||||
{
|
|
||||||
confirmButtonText: '确定',
|
confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
cancelButtonText: '取消',
|
||||||
type: 'warning',
|
type: 'warning'
|
||||||
}
|
})
|
||||||
)
|
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
await removeChildTemp(curEditItem.id)
|
await removeChildTemp(curEditItem.id)
|
||||||
ElMessage.success('操作成功')
|
ElMessage.success('操作成功')
|
||||||
|
@ -266,36 +267,33 @@ const onDel = () =>{
|
||||||
addVisible.value = false
|
addVisible.value = false
|
||||||
getTemplate()
|
getTemplate()
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => { })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
const closeDialog = () =>{
|
handleBeforeClose(() => (addVisible.value = false))
|
||||||
handleBeforeClose(() => addVisible.value = false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleBeforeClose = (done) =>{
|
const handleBeforeClose = (done) => {
|
||||||
resetForm()
|
resetForm()
|
||||||
done()
|
done()
|
||||||
}
|
}
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
if (ruleFormRef.value) {
|
if (ruleFormRef.value) {
|
||||||
ruleFormRef.value.resetFields();
|
ruleFormRef.value.resetFields()
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
const curNode = reactive({})
|
const curNode = reactive({})
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
let data = sessionStore.get('subject.curNode')
|
let data = sessionStore.get('subject.curNode')
|
||||||
Object.assign(curNode, data);
|
Object.assign(curNode, data)
|
||||||
getTemplate()
|
getTemplate()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
onUnmounted(() => {
|
||||||
onUnmounted(()=>{
|
|
||||||
emitter.off('resetSelect')
|
emitter.off('resetSelect')
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
@ -342,7 +340,7 @@ onUnmounted(()=>{
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: "";
|
content: '';
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
|
@ -352,7 +350,6 @@ onUnmounted(()=>{
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(0, -50%);
|
transform: translate(0, -50%);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.iconfont {
|
.iconfont {
|
||||||
|
@ -389,7 +386,8 @@ onUnmounted(()=>{
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.form-btn{
|
|
||||||
|
.form-btn {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue