lyc-dev #223

Merged
lyc merged 2 commits from lyc-dev into main 2025-01-14 11:26:59 +08:00
5 changed files with 144 additions and 178 deletions

View File

@ -118,6 +118,14 @@ export function docList(params) {
}) })
} }
// 删除 doc ai文档
export function removeDoc(id) {
return request({
url: '/education/doc/' + id,
method: 'delete',
})
}
// 保存教学大纲 // 保存教学大纲
export function addSyllabus(data) { export function addSyllabus(data) {
return request({ return request({

View File

@ -2,34 +2,44 @@
<el-dialog v-model="isDialog" :show-close="false" width="900" append-to-body destroy-on-close> <el-dialog v-model="isDialog" :show-close="false" width="900" append-to-body destroy-on-close>
<template #header> <template #header>
<div class="custom-header flex"> <div class="custom-header flex">
<span>选择{{ title }}</span> <span>选择</span>
<i class="iconfont icon-guanbi" @click="isDialog = false"></i> <i class="iconfont icon-guanbi" @click="isDialog = false"></i>
</div> </div>
</template> </template>
<div class="dialog-content"> <div class="dialog-content" v-loading="loading">
<div class="content-list"> <div class="content-list">
<ul> <el-radio-group v-model="curFileId">
<li v-for="(item, index) in fileList" :class="activeIndex == index ? 'li-active' : ''" <el-row>
@click="clickItem(index, item)"> <el-col :span="12" v-for="item in fileList" :key="item.id">
<el-image class="img" :src="url" /> <el-radio :value="item.id">
<el-button type="primary" class="prev-btn" @click.stop="onPrevItem(item)">预览</el-button> <el-text class="w-50" truncated>{{ item.fileName }}</el-text>
<el-text truncated>{{ item.fileName }}</el-text> <div class="flex items-center">
</li> <el-button type="primary" link v-if="isPrev(item).value" @click="onPrevItem(item)"
</ul> >预览</el-button
>
<el-button type="danger" link @click="removeItem(item)">删除</el-button>
</div>
</el-radio>
</el-col>
</el-row>
</el-radio-group>
</div> </div>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-upload class="upload-demo" :action="uploadFileUrl" :limit="1" :show-file-list="false" :headers="headers" <el-upload
:on-success="onSuccess"> class="upload-demo"
:action="uploadFileUrl"
:limit="1"
:show-file-list="false"
:headers="headers"
:on-success="onSuccess"
>
<el-button type="primary">上传</el-button> <el-button type="primary">上传</el-button>
</el-upload> </el-upload>
<div> <div>
<el-button @click="isDialog = false">取消</el-button> <el-button @click="isDialog = false">取消</el-button>
<el-button type="primary" @click="isDialog = false"> <el-button type="primary" @click="handleDialog"> 确定 </el-button>
确定
</el-button>
</div> </div>
</div> </div>
</template> </template>
@ -41,21 +51,18 @@
<i class="iconfont icon-guanbi" @click="prevVisible = false"></i> <i class="iconfont icon-guanbi" @click="prevVisible = false"></i>
</div> </div>
</template> </template>
<div style="height: calc(100vh - 120px);"> <div style="height: calc(100vh - 120px)">
<template v-if="getFileSuffix(prevItem.fileUrl) == 'pdf'"> <template v-if="getFileSuffix(prevItem.fileUrl) == 'pdf'">
<iframe :src="prevItem.fileUrl" <iframe :src="prevItem.fileUrl" frameborder="0" width="100%" height="100%"></iframe>
frameborder="0" width="100%" height="100%"></iframe>
</template> </template>
<template v-else> <template v-else>
<el-image :src="prevItem.fileUrl" style="height:100%"/> <el-image :src="prevItem.fileUrl" style="height: 100%" />
</template> </template>
</div> </div>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<div></div> <div></div>
<el-button type="primary" @click="prevVisible = false"> <el-button type="primary" @click="prevVisible = false"> 关闭 </el-button>
关闭
</el-button>
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
@ -63,20 +70,19 @@
<script setup> <script setup>
import { ref, computed, onMounted, reactive } from 'vue' import { ref, computed, onMounted, reactive } from 'vue'
import { completion, addDoc, docList } from '@/api/mode/index.js' import { completion, addDoc, docList, removeDoc } from '@/api/mode/index.js'
import { getToken } from "@/utils/auth"; import { getToken } from '@/utils/auth'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import { dataSetJson } from '@/utils/comm.js' import { dataSetJson } from '@/utils/comm.js'
import { ElMessage } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { getFileSuffix } from '@/utils/ruoyi.js' import { getFileSuffix } from '@/utils/ruoyi.js'
import emitter from '@/utils/mitt'; import emitter from '@/utils/mitt'
import { cloneDeep } from 'lodash'
const userInfo = useUserStore().user const userInfo = useUserStore().user
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + '/common/upload')
const headers = ref({ Authorization: "Bearer " + getToken() }); const headers = ref({ Authorization: 'Bearer ' + getToken() })
const url = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2F11044b08-04c1-41a0-a453-1fd20b58a614%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1732953359&t=7ab1d1b3a903db85b1149914407aea35'
const isDialog = defineModel() const isDialog = defineModel()
const prevVisible = ref(false) const prevVisible = ref(false)
@ -88,36 +94,14 @@ const props = defineProps({
} }
}) })
const title = computed(() => {
if (props.modeType == 1) return '课标';
if (props.modeType == 2) return '教材';
if (props.modeType == 3) return '考试';
})
const radio = ref(1) const isPrev = (item) => {
const radioList = ref([ return computed(() => {
{ label: '浏览研读', value: 1 }, return ['pdf', 'png', 'jpg', 'jpeg', 'gif'].includes(getFileSuffix(item.fileUrl))
{ label: '跨学科研读', value: 2 }, })
{ label: '跨学段研读', value: 3 },
{ label: '课标修订研读', value: 4 },
{ label: '自由研读', value: 5 },
])
const list = ref([
{
name: '高中语文课程标准',
url
}
])
const changeRadio = () => {
list.value = []
for (let i = 0; i < Math.floor(Math.random() * 5) + 1; i++) {
list.value.push({
name: '高中语文课程标准',
url
})
}
} }
const activeIndex = ref(0)
const curFileId = ref(0)
const dataset_id = ref('') const dataset_id = ref('')
@ -143,43 +127,77 @@ const onSuccess = async (response) => {
const { msg } = await addDoc(docData) const { msg } = await addDoc(docData)
ElMessage.success(msg) ElMessage.success(msg)
getList() getList()
} }
const curNode = reactive({}) const curNode = reactive({})
// doc ai
const fileList = ref([]) const fileList = ref([])
const curFile = reactive({}) const curFile = reactive({})
const getList = () => { const getList = () => {
docList({ docList({
userId: userInfo.userId, userId: userInfo.userId,
dataset_id: dataset_id.value dataset_id: dataset_id.value
}).then(res => { }).then((res) => {
fileList.value = [...res.rows] fileList.value = [...res.rows]
Object.assign(curFile, fileList.value[0]) Object.assign(curFile, fileList.value[0])
curFileId.value = fileList.value[0].id
}) })
} }
const clickItem = (index, item) => {
activeIndex.value = index //
Object.assign(curFile, item) const loading = ref(false)
emitter.emit('changeCurFile', item) const removeItem = (item) => {
ElMessageBox.confirm('确定要删除?', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
loading.value = true
removeDoc(item.id)
.then(() => {
ElMessage.success('操作成功')
getList()
})
.finally(() => {
loading.value = false
})
})
.catch(() => {})
} }
//
const prevItem = reactive({}) const prevItem = reactive({})
const onPrevItem = (item) => { const onPrevItem = (item) => {
Object.assign(prevItem, item) Object.assign(prevItem, item)
prevVisible.value = true prevVisible.value = true
} }
//
const handleDialog = () => {
isDialog.value = false
const item = fileList.value.find((item) => item.id == curFileId.value)
Object.assign(curFile, item)
emitter.emit('changeCurFile', item)
// pdf
if (getFileSuffix(curFile.fileUrl) == 'pdf') {
let data = cloneDeep(curFile)
emitter.emit('changePdfUrl', data)
}
}
onMounted(() => { onMounted(() => {
let data = sessionStore.get('subject.curNode') let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data); Object.assign(curNode, data)
// "-" // "-"
let jsonKey = `考试-${curNode.edustage}-${curNode.edusubject}` let jsonKey = `考试-${curNode.edustage}-${curNode.edusubject}`
dataset_id.value = dataSetJson[jsonKey] dataset_id.value = dataSetJson[jsonKey]
getList() getList()
}) })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.custom-header { .custom-header {
@ -198,45 +216,6 @@ onMounted(() => {
.content-list { .content-list {
padding-top: 10px; padding-top: 10px;
ul {
display: flex;
flex-wrap: wrap;
li {
width: 130px;
display: flex;
flex-direction: column;
font-size: 13px;
padding: 10px;
cursor: pointer;
border-radius: 5px;
overflow: hidden;
margin-right: 20px;
margin-bottom: 10px;
position: relative;
overflow: hidden;
.img {
width: 100%;
height: 130px;
border: solid #ccc 1px;
margin-bottom: 10px;
}
&:hover {
background: #E0EAFF;
}
&:hover .prev-btn {
transform: translate(-50%, -40px)
}
}
.li-active {
background: #E0EAFF;
}
}
} }
} }
@ -246,13 +225,7 @@ onMounted(() => {
justify-content: space-between; justify-content: space-between;
} }
.prev-btn { :deep(.el-radio__label) {
position: absolute; display: flex;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) translateY(-110px);
/* 按钮初始位置在容器外 */
transition: transform 0.3s ease-in-out;
/* 设置过渡效果 */
} }
</style> </style>

View File

@ -2,8 +2,9 @@
<div class="container-left-page flex"> <div class="container-left-page flex">
<div class="container-left-header flex"> <div class="container-left-header flex">
<el-button link @click="onClick"> <el-button link @click="onClick">
{{ curNode.edustage }}{{ curNode.edusubject }}{{ type == 1 ? '课标研读' : type == 2 ? '教材分析' : '考试分析' }}<i {{ curNode.edustage }}{{ curNode.edusubject
class="iconfont icon-xiangxia"></i> }}{{ type == 1 ? '课标研读' : type == 2 ? '教材分析' : '考试分析'
}}<i v-if="type == 3" class="iconfont icon-xiangxia"></i>
</el-button> </el-button>
</div> </div>
<div class="container-left-pdf"> <div class="container-left-pdf">
@ -20,6 +21,7 @@ import { ref, onMounted, nextTick, reactive } from 'vue'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import PDF from '@/components/PdfJs/index.vue' import PDF from '@/components/PdfJs/index.vue'
import LeftDialog from './left-dialog.vue' import LeftDialog from './left-dialog.vue'
import emitter from '@/utils/mitt'
const props = defineProps(['type']) const props = defineProps(['type'])
@ -29,6 +31,12 @@ const onClick = () => {
showDialog.value = true showDialog.value = true
} }
emitter.on('changePdfUrl', async (data) => {
pdfUrl.value = ''
await nextTick()
pdfUrl.value = data.fileUrl
})
// PDF // PDF
const pdfUrl = ref('') const pdfUrl = ref('')
const curNode = reactive({}) const curNode = reactive({})
@ -36,16 +44,15 @@ onMounted(async () => {
await nextTick() await nextTick()
// //
let nodeData = sessionStore.get('subject.curNode') let nodeData = sessionStore.get('subject.curNode')
Object.assign(curNode, nodeData); Object.assign(curNode, nodeData)
let data = sessionStore.get('subject.curBook') let data = sessionStore.get('subject.curBook')
let fileurl = data.fileurl let fileurl = data.fileurl
if(props.type == 1){ if (props.type == 1) {
fileurl = `${data.edustage}-${data.edusubject}-课标.txt` fileurl = `${data.edustage}-${data.edusubject}-课标.txt`
} }
if(fileurl == '') return if (fileurl == '') return
pdfUrl.value = import.meta.env.VITE_APP_RES_FILE_PATH + fileurl.replace('.txt', '.pdf') pdfUrl.value = import.meta.env.VITE_APP_RES_FILE_PATH + fileurl.replace('.txt', '.pdf')
}) })
</script> </script>
@ -53,6 +60,7 @@ onMounted(async () => {
.container-left-page { .container-left-page {
height: 100%; height: 100%;
flex-direction: column; flex-direction: column;
.container-left-header { .container-left-header {
height: 45px; height: 45px;
background: #fff; background: #fff;

View File

@ -16,7 +16,7 @@
</el-dropdown> </el-dropdown>
<div class="flex"> <div class="flex">
<el-select v-model="curMode" placeholder="Select" class="mr-4 w-30"> <el-select v-model="curMode" placeholder="Select" class="mr-4 w-30">
<el-option v-for="item in modeOptions" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in modeOptions" :key="item.value" :disabled="item.disabled" :label="item.label" :value="item.value" />
</el-select> </el-select>
<el-button type="danger" link :disabled="!(templateList.length)" @click="removeItem(curTemplate, false)"> <el-button type="danger" link :disabled="!(templateList.length)" @click="removeItem(curTemplate, false)">
删除 删除
@ -104,6 +104,12 @@ import { cloneDeep } from 'lodash'
const props = defineProps(['type']) const props = defineProps(['type'])
const { user } = useUserStore() const { user } = useUserStore()
const params = reactive(
{
prompt: '',
dataset_id: ''
}
)
const curMode = ref(2) const curMode = ref(2)
const modeOptions = ref([ const modeOptions = ref([
{ {
@ -112,7 +118,8 @@ const modeOptions = ref([
}, },
{ {
label: '知识库模型', label: '知识库模型',
value: 2 value: 2,
disabled: false
} }
]) ])
@ -288,12 +295,7 @@ const onEdit = (index, item) => {
} }
// //
const params = reactive(
{
prompt: '',
dataset_id: ''
}
)
const prompt = ref('') const prompt = ref('')
// //
@ -483,7 +485,18 @@ onMounted(() => {
getTemplateList() getTemplateList()
let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}` let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey] params.dataset_id = dataSetJson[jsonKey]
if(!params.dataset_id){
curMode.value = 1
modeOptions.value.forEach(item => {
if(item.value == 2){
item.disabled = true
}
})
}
// ID // ID
conversation_id.value = localStorage.getItem('conversation_id') conversation_id.value = localStorage.getItem('conversation_id')
if (!conversation_id.value) { if (!conversation_id.value) {

View File

@ -22,24 +22,22 @@
<el-empty v-else description="请选择符合您需要的教学模式,生成教学大纲" /> <el-empty v-else description="请选择符合您需要的教学模式,生成教学大纲" />
</div> </div>
</div> </div>
<!-- <EditDialog v-model="isEdit" :item="editItem" :index="editIndex" /> -->
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, onUnmounted } from 'vue' import { ref, reactive, onMounted, onUnmounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { sessionStore } from '@/utils/store' import { sessionStore } from '@/utils/store'
import EditDialog from './edit-dialog.vue'
import emitter from '@/utils/mitt' 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, removeSyllabus, editSyllabus, modelList } from '@/api/mode/index.js' import { completion, addSyllabus, removeSyllabus, modelList } from '@/api/mode/index.js'
import { createOutlineV2 } from '@/utils/ppt-request.js' import { createOutlineV2 } from '@/utils/ppt-request.js'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { cloneDeep } from 'lodash' import { cloneDeep } from 'lodash'
const curMode = ref(2) const curMode = ref(2)
const isEdit = ref(false)
const { user } = useUserStore() const { user } = useUserStore()
@ -50,7 +48,8 @@ const modeOptions = ref([
}, },
{ {
label: '知识库模型', label: '知识库模型',
value: 2 value: 2,
disabled: false
} }
]) ])
@ -134,47 +133,6 @@ const createAi = async () => {
} }
} }
//
// const editItem = reactive({})
// const editIndex = ref(0)
// const onEdit = (item, index)=>{
// let obj = null
// if(index == -1){
// obj = {
// title: answer.title,
// subTitle: answer.subTitle
// }
// }
// else{
// obj = cloneDeep(item)
// }
// editIndex.value = index
// isEdit.value = true
// Object.assign(editItem, obj)
// }
// emitter.on('editItem', (item) =>{
// if(editIndex.value == -1){
// answer.title = item.title
// answer.subTitle = item.subTitle
// }else{
// answer.chapters[editIndex.value] = item
// }
// let data = cloneDeep(curItem)
// data.outline = JSON.stringify(cloneDeep(answer))
// loading.value = true
// editSyllabus(data).then( res =>{
// curItem.outline = answer
// emitter.emit('onResult', curItem)
// ElMessage.success('')
// }).finally( ()=>{
// loading.value = false
// })
// })
// //
const onSaveTemp = async (outline) => { const onSaveTemp = async (outline) => {
let modelIds = selectedData.value.map(item => item.id).join(',') let modelIds = selectedData.value.map(item => item.id).join(',')
@ -209,8 +167,6 @@ const delAnswer = () => {
markeDownAnswer.value = '' markeDownAnswer.value = ''
emitter.emit('resetSelect') emitter.emit('resetSelect')
// window.location.reload();
}) })
.catch(() => {}) .catch(() => {})
@ -252,6 +208,14 @@ onMounted(() => {
// dataset_id // dataset_id
let jsonKey = `课标-${data.edustage}-${data.edusubject}` let jsonKey = `课标-${data.edustage}-${data.edusubject}`
params.dataset_id = commUtils.dataSetJson[jsonKey] params.dataset_id = commUtils.dataSetJson[jsonKey]
if(!params.dataset_id){
curMode.value = 1
modeOptions.value.forEach(item => {
if(item.value == 2){
item.disabled = true
}
})
}
// ID // ID
conversation_id.value = localStorage.getItem('conversation_id') conversation_id.value = localStorage.getItem('conversation_id')