This commit is contained in:
lyc 2024-12-30 17:25:56 +08:00
parent c1c18582d8
commit a2639c097f
3 changed files with 153 additions and 35 deletions

View File

@ -119,3 +119,12 @@ export function docList(params) {
}
// 保存教学大纲
export function addSyllabus(data) {
return request({
url: '/education/generate',
method: 'post',
data
})
}

View File

@ -25,10 +25,14 @@ import { sessionStore } from '@/utils/store'
import emitter from '@/utils/mitt'
import * as commUtils from '@/utils/comm.js'
import { createChart, sendChart } from '@/api/ai/index'
import { completion, tempResult, tempSave, removeChildTemp, editTempResult, modelList } from '@/api/mode/index.js'
import { completion, addSyllabus } from '@/api/mode/index.js'
import TypingEffect from '@/components/typing-effect/index.vue'
import useUserStore from '@/store/modules/user'
const curMode = ref(2)
const { user } = useUserStore()
const modeOptions = ref([
{
label: '教学大模型',
@ -59,10 +63,13 @@ const params = reactive(
const loading = ref(false)
const answer = ref('')
const createAi = async ()=>{
console.log(selectedData.value)
if(selectedData.value.length == 0){
ElMessage.warning('请先选择教学环节后再生成教学大纲')
return
}
onSaveTemp()
return
let str = selectedData.value.map( item => item.name).join('、')
let bookV = curNode.roottitle.split('-')[1] + '版'
loading.value = true
@ -97,6 +104,30 @@ const createAi = async ()=>{
}
//
const onSaveTemp = async (data) => {
if (data == '') return
console.log(selectedData)
let modelIds = selectedData.value.map( item => item.id).join(',')
console.log(modelIds)
console.log(user)
const data1 = {
eduId: curNode.id,
outline: data,
outlineType: curMode.value == 1 ? 0 : 1,
modelIds,
sourceType: 1,
createUserId: 1
}
// const res = await addSyllabus(data)
if(!item.resultId){
item.resultId = res.data
}
}
// ### **
let getResult = (str) => {
let newStr = str.replace(/#+|(\*\*)/g, '');

View File

@ -1,30 +1,39 @@
<template>
<div class="container-left flex">
<div class="container-left flex" v-loading="loading">
<div class="left-header flex">
<span>教学模式</span>
<el-button type="primary" link @click="addVisible = true; addChild = false"><i class="iconfont icon-jiahao"
<div>
<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"
></i>新增</el-button>
</div>
</div>
<div class="left-list">
<div class="item" v-for="item in templateList" :key="item.id">
<div class="item-name flex" @mouseenter="item.isAdd = true" @mouseleave="item.isAdd = false"
@click="handleItem(item)">
<span>{{ item.name }}</span>
<i v-show="item.isAdd && !item.isSelect && !item.newMode" class="iconfont icon-jiahao"></i>
<div class="flex">
<span>{{ item.name }}</span>
<!--个人教学模式才会有添加编辑-->
<div v-if="!item.ex3" class="ml-3">
<el-button type="primary" link @click.stop="addModeChild(item)">添加</el-button>
<el-button type="primary" link @click.stop="editMode(item)">编辑</el-button>
</div>
</div>
<!--加号 数鼠标悬浮 显示-->
<i v-show="item.isAdd && !item.isSelect" class="iconfont icon-jiahao"></i>
<!--减号 选中之后显示-->
<i v-show="item.isSelect" class="iconfont icon-zuixiaohua"></i>
<!--新增的教学模式才会有添加编辑-->
<template v-if="item.newMode">
<div>
<el-button type="primary" link @click="addModeChild">添加</el-button>
<el-button type="primary" link @click="editMode(item)">编辑</el-button>
</div>
</template>
</div>
<div class="item-child flex" :class="el.isSelect ? 'act-child' : ''" v-for="el in item.child" :key="el.id"
@mouseenter="el.isAdd = true" @mouseleave="el.isAdd = false" @click="handleItemChild(el)">
<span>{{ el.name }}</span>
<i v-show="el.isAdd && !el.isSelect" class="iconfont icon-jiahao"></i>
<i v-show="el.isSelect" class="iconfont icon-zuixiaohua"></i>
<div>
<span>{{ el.name }}</span>
<!--个人教学模式才会有编辑-->
<el-button v-if="!el.ex3" class="ml-3" type="primary" link @click.stop="editMode(el)">编辑</el-button>
</div>
<i v-show="el.isAdd && !el.isSelect" class="iconfont icon-jiahao"></i>
<i v-show="el.isSelect" class="iconfont icon-zuixiaohua "></i>
</div>
</div>
</div>
@ -40,10 +49,13 @@
<el-form ref="ruleFormRef" style="max-width: 600px" :model="ruleForm" :rules="rules" label-width="auto"
class="demo-ruleForm">
<el-form-item :label="`教学${ addChild ? '环节' : '模式'}名称`" prop="name">
<el-input v-model="ruleForm.name" />
<div class="flex" style="width: 100%;">
<el-input v-model="ruleForm.name" />
<el-button v-if="isEdit" link type="danger" class="ml-5 mr-3" @click="onDel">删除</el-button>
</div>
</el-form-item>
<el-form-item label="说明" v-if="addChild">
<el-input v-model="ruleForm.desc" type="textarea" />
<el-form-item label="说明" v-if="addChild" prop="prompt">
<el-input v-model="ruleForm.prompt" type="textarea" />
</el-form-item>
</el-form>
<div class="mt-10 form-btn">
@ -60,7 +72,11 @@ import { ref, reactive, onMounted } from 'vue'
import { modelList } from '@/api/mode/index'
import useUserStore from '@/store/modules/user'
import { sessionStore } from '@/utils/store'
import emitter from '@/utils/mitt';
import emitter from '@/utils/mitt'
import { ElMessage, ElMessageBox } from 'element-plus'
import { addChildTemp, editChildTemp, removeChildTemp } from '@/api/mode'
import { cloneDeep } from 'lodash'
const { user } = useUserStore()
@ -80,15 +96,14 @@ const getTemplate = async (id) => {
//
const templateList = ref([])
const getChildTemp = async () => {
templateList.length = 0
templateList.value = []
loading.value = true
for (let item of list.value) {
try {
let { rows } = await modelList({ model: 4, type: 2, parentId: item.id })
templateList.value.push({
name: item.name,
id: item.id,
...item,
child: rows
})
} finally {
@ -97,6 +112,16 @@ const getChildTemp = async () => {
}
}
//
const resetSelect = () =>{
templateList.value.forEach(item =>{
item.isSelect = false
item.child.forEach( el=>{
el.isSelect = false
})
})
}
const handleItem = (item) => {
if(item.newMode) return
item.isSelect = !item.isSelect
@ -110,7 +135,6 @@ const handleItem = (item) => {
const handleItemChild = (el) =>{
el.isSelect = !el.isSelect
console.log(templateList.value)
let data = collectSelectedItems(templateList.value)
emitter.emit('selected', data)
@ -152,40 +176,94 @@ const rules = reactive({
})
const ruleForm = reactive({
name: '',
desc: ''
prompt: ''
})
//
const onSubmit = async (formEl) =>{
if (!formEl) return
await formEl.validate((valid, fields) => {
await formEl.validate(async (valid, fields) => {
if (valid) {
templateList.value.push({
id: + new Date(),
name: ruleForm.name,
newMode: true
})
//
if(isEdit.value){
let data = cloneDeep(curEditItem)
data.name = ruleForm.name
await editChildTemp(data)
}
//
else{
let obj = {
ex1: curNode.edustage,
ex2: curNode.edusubject,
model: 4,
name: ruleForm.name,
sortNum: 1,
type: 1
}
//
if(addChild.value){
obj.parentId = curEditItem.id
obj.prompt = ruleForm.prompt
obj.type = 2
}
await addChildTemp(obj)
}
ElMessage.success('操作成功')
resetForm()
addVisible.value = false
getTemplate()
} else {
console.log('error submit!', fields)
}
})
}
//
const isEdit = ref(false)
// false true
const addChild = ref(false)
const addModeChild = () =>{
const curEditItem = reactive({})
const addModeChild = (item) =>{
isEdit.value = false
Object.assign(curEditItem, item)
addChild.value = true
addVisible.value = true
}
//
const editMode = (item)=>{
isEdit.value = true
addChild.value = false
Object.assign(curEditItem, item)
ruleForm.name = item.name
addVisible.value = true
}
//
const onDel = () =>{
ElMessageBox.confirm(
'确定要删除模板吗?',
'温馨提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
)
.then(async () => {
await removeChildTemp(curEditItem.id)
ElMessage.success('操作成功')
resetForm()
addVisible.value = false
getTemplate()
})
.catch(() => {})
}
const closeDialog = () =>{
handleBeforeClose(() => addVisible.value = false);
}
@ -245,7 +323,7 @@ onMounted(() => {
}
.item-child {
text-indent: 3em;
padding-left: 3em;
justify-content: space-between;
cursor: pointer;
align-items: center;