Compare commits

..

6 Commits

9 changed files with 361 additions and 79 deletions

View File

@ -151,9 +151,9 @@ export const useSlidesStore = defineStore('slides', {
for (const slide of slides) {
if (slide.sectionTag) delete slide.sectionTag
}
// const addIndex = this.slideIndex + 1
this.slides.splice(this.slideIndex, 0, ...slides)
// this.slideIndex = addIndex
const addIndex = this.slideIndex + 1
this.slides.splice(addIndex, 0, ...slides)
this.slideIndex = addIndex
},
updateSlide(props: Partial<Slide>, slideId?: string) {
const slideIndex = slideId ? this.slides.findIndex(item => item.id === slideId) : this.slideIndex

View File

@ -45,9 +45,9 @@
</template>
</div>
<!-- // -->
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="90%" height="500">
<el-scrollbar height="550">
<div style="height: 550px;">
<el-dialog v-model="dialogVisible" append-to-body :show-close="false" width="85%" height="500">
<el-scrollbar>
<div style="height: 75vh;">
<NewClassTsakAssign :currentCourse='currentCourse' @getData="getData" />
</div>
</el-scrollbar>
@ -335,9 +335,10 @@ onMounted(() => {
objItem.value = workItem.value[slideIndex.value]
getCurrentPPtData()
})
watch(() => [workItem.value.length,slideIndex.value], (newVal,oldVal) => {
watch(() => [workItem.value.length,workItem.value[slideIndex.value]?.id], (newVal,oldVal) => {
if(!objectsAreEqual(newVal,oldVal))
getCurrentPPtData()
if(workItem.value[slideIndex.value])
getCurrentPPtData()
})
// watch(() => workItem.value.length, () => {
// getCurrentPPtData()

View File

@ -40,7 +40,7 @@ const props = defineProps({
type: Number,
default: 1
},
item: { //
item: { //
type: Object,
default: () => {
return { ex3: '' }
@ -73,23 +73,25 @@ const loading = ref(false)
const saveAdd = async () => {
loading.value = true
if (props.item.ex3 == '1') {
let id; // id id
if (props.item.isAdd) {
try {
// copy
const { msg } = await addKeyWords({ name: form.name, id: props.item.id })
emitter.emit('onGetMain')
ElMessage.success(msg)
mode.value = false
} finally {
loading.value = false
}
id = props.item.id
}
else{
onAddChildTemp(props.item.parentId)
// item item.parentId
id = props.item.parentId
}
try {
// copy
const { msg } = await addKeyWords({ name: form.name, id })
emitter.emit('onGetMain')
ElMessage.success(msg)
mode.value = false
} finally {
loading.value = false
}
} else {
if (props.item.isAdd) {
onAddChildTemp(props.item.id)
}

View File

@ -16,12 +16,12 @@
</template>
<script setup>
import { ref, onMounted, nextTick } from 'vue'
import { ref, onMounted, nextTick, reactive } from 'vue'
import { sessionStore } from '@/utils/store'
import PDF from '@/components/PdfJs/index.vue'
import LeftDialog from './left-dialog.vue'
const props = defineProps(['curNode', 'type'])
const props = defineProps(['type'])
const showDialog = ref(false)
const onClick = () => {
@ -31,8 +31,13 @@ const onClick = () => {
// PDF
const pdfUrl = ref('')
const curNode = reactive({})
onMounted(async () => {
await nextTick()
//
let nodeData = sessionStore.get('subject.curNode')
Object.assign(curNode, nodeData);
let data = sessionStore.get('subject.curBook')
let fileurl = data.fileurl
if(props.type == 1){

View File

@ -83,7 +83,7 @@
</template>
<script setup>
import { ref, reactive, onMounted, watch, onUnmounted, nextTick } from 'vue'
import { ref, reactive, onMounted, onUnmounted, nextTick } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { tempSave, completion, modelList, removeChildTemp, tempResult, editTempResult } from '@/api/mode/index'
import { sessionStore } from '@/utils/store'
@ -95,7 +95,7 @@ import useUserStore from '@/store/modules/user'
import emitter from '@/utils/mitt';
import { dataSetJson } from '@/utils/comm.js'
const props = defineProps(['curNode', 'type'])
const props = defineProps(['type'])
const { user } = useUserStore()
/*****************提示词相关****************/
@ -270,21 +270,6 @@ const onEdit = (index, item) => {
isEdit.value = true
}
const modeType = ref('课标')
watch(() => props.type, (newVal) => {
if (newVal == 1) {
modeType.value = '课标'
}
if (newVal == 2) {
modeType.value = '教材'
}
if (newVal == 3) {
modeType.value = '考试'
}
}, { immediate: false })
//
const params = reactive(
{
@ -402,11 +387,14 @@ emitter.on('onGetMain', () => {
const curNode = reactive({})
const modeType = ref('')
onMounted(() => {
let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data);
modeType.value = props.type == 1 ? '课标' : props.type == 2 ? '教材' : '考试'
getTemplateList()
let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey]
})

View File

@ -2,18 +2,16 @@
<div class="page-template flex">
<el-row>
<el-col :span="12">
<Left :curNode="curNode" :type="type" />
<Left :type="type" />
</el-col>
<el-col :span="12">
<Right :curNode="curNode" :type="type" />
<Right :type="type" />
</el-col>
</el-row>
</div>
</template>
<script setup>
import { reactive, onMounted } from 'vue'
import { sessionStore } from '@/utils/store'
import Left from './container/left.vue'
import Right from './container/right.vue'
@ -23,13 +21,6 @@ const props = defineProps({
default: 1
},
})
const curNode = reactive({})
onMounted(() =>{
let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data);
})
</script>
<style lang="scss" scoped>

View File

@ -0,0 +1,159 @@
<template>
<el-dialog v-model="mode" :show-close="false" width="600" append-to-body destroy-on-close>
<template #header>
<div class="custom-header flex">
<span>{{ item.ex3 == '1' ? '请输入新的模板名称' : item.isAdd ? '添加提示词' : '编辑提示词' }}</span>
<i class="iconfont icon-guanbi" @click="mode = false"></i>
</div>
</template>
<div class="dialog-content" v-loading="loading">
<p class="small-tip" v-if="item && item.ex3 == '1'">*当前模板为系统预设不支持直接操作需要复制一份为自己的然后再操作</p>
<el-form :model="form" label-width="auto">
<el-form-item label="名称">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item label="提示词" v-if="item.ex3 == '1' ? false : true">
<el-input v-model="form.prompt" type="textarea" />
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="mode = false">取消</el-button>
<el-button type="primary" @click="saveAdd">
确定
</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import { ref, reactive, watch } from 'vue'
import { ElMessage } from 'element-plus'
import emitter from '@/utils/mitt';
import { addKeyWords, addChildTemp, editChildTemp } from '@/api/mode/index'
const mode = defineModel()
const props = defineProps({
modeType: {
type: Number,
default: 1
},
item: { //
type: Object,
default: () => {
return { ex3: '' }
}
},
})
const form = reactive({
name: '',
prompt: '',
})
watch(() => mode.value, (newVal) => {
if(newVal){
if (props.item.isAdd) {
form.name = ''
form.prompt = ''
}
else{
form.name = props.item?.name
form.prompt = props.item?.prompt
}
}
},{ deep: true})
const loading = ref(false)
const saveAdd = async () => {
loading.value = true
if (props.item.ex3 == '1') {
let id; // id id
if (props.item.isAdd) {
id = props.item.id
}
else{
// item item.parentId
id = props.item.parentId
}
try {
// copy
const { msg } = await addKeyWords({ name: form.name, id })
emitter.emit('onGetMain')
ElMessage.success(msg)
mode.value = false
} finally {
loading.value = false
}
} else {
if (props.item.isAdd) {
onAddChildTemp(props.item.id)
}
else {
try {
let data = JSON.parse(JSON.stringify(props.item))
data.name = form.name;
data.prompt = form.prompt
const { msg } = await editChildTemp(data)
emitter.emit('onGetChild', data )
ElMessage.success(msg)
mode.value = false
} finally {
loading.value = false
}
}
}
}
//
const onAddChildTemp = async (parentId) => {
//
let obj = {
name: form.name,
type: 2, // 2
sortNum: 1,
parentId,
lmType: 1,
model: props.modeType,
prompt: form.prompt,
ex1: props.item.ex1, //
ex2: props.item.ex2, //
ex3: '', //
}
try {
var { msg } = await addChildTemp(obj)
emitter.emit('onGetChild')
ElMessage.success(msg)
mode.value = false
} finally {
loading.value = false
}
}
</script>
<style lang="scss" scoped>
.custom-header {
justify-content: space-between;
align-items: center;
.icon-guanbi {
cursor: pointer;
font-weight: bold;
}
}
.small-tip {
text-align: left;
font-size: 12px;
margin-bottom: 15px;
color: #F56C6C;
}
</style>

View File

@ -2,6 +2,7 @@
<div class="container-left flex">
<div class="left-header flex">教学模式</div>
<div class="left-con" v-loading="loading">
<el-empty v-if="!(tempList.length)" description="暂无数据" />
<div class="con-item" v-for="item in tempList" :key="item.id">
<div class="item-header flex">
<span>{{ item.name }}</span>
@ -29,27 +30,33 @@
</template>
<script setup>
import { ref, onMounted } from 'vue';
import { ref, reactive, onMounted, onUnmounted } from 'vue';
import emitter from '@/utils/mitt';
import { modelList } from '@/api/mode/index'
import useUserStore from '@/store/modules/user'
import { sessionStore } from '@/utils/store'
const { user } = useUserStore()
//
let list = []
const getTemplate = () => {
modelList({ model: 1, type: 1, ex3: 1 }).then(res => {
list = res.rows
getChildTemp()
})
let list = ref([])
const getTemplate = async (id) => {
const { rows } = await modelList({ createUser: user.userId, model: 4, type: 1, pageNum: 1, pageSize: 10000})
list.value = rows
if(list.value.length){
getChildTemp(id)
}
}
//
const loading = ref(false)
const tempList = ref([])
const getChildTemp = async () => {
const getChildTemp = async (parentId) => {
tempList.value.length = 0
loading.value = true
for (let item of list) {
for (let item of list.value) {
try {
const { rows } = await modelList({ model: 1, type: 2, parentId: item.id })
const { rows } = await modelList({ model: 4, type: 2, parentId: item.id })
tempList.value.push({
id: item.id,
name: item.name,
@ -57,20 +64,52 @@ const getChildTemp = async () => {
})
} finally {
loading.value = false
emitter.emit('changeMode', tempList.value[0])
}
}
if(parentId){
const item = tempList.value.find(item => item.id == parentId)
emitter.emit('changeMode', item)
}
else{
emitter.emit('changeMode', tempList.value[0])
}
}
//
emitter.on('onGetChild', async (data) => {
await getTemplate(data.parentId)
})
//
emitter.on('onGetMain', (item) => {
getTemplate(item.parentId)
})
//
const emit = defineEmits([''])
const onSelect = (item) =>{
emitter.emit('changeMode', item)
}
const curNode = reactive({})
onMounted(() => {
let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data);
getTemplate()
})
//
onUnmounted(() => {
emitter.off('onGetMain');
emitter.off('onGetChild');
})
</script>
<style lang="scss" scoped>
@ -96,7 +135,7 @@ onMounted(() => {
padding: 15px;
box-sizing: border-box;
font-size: 14px;
overflow: auto;
.item-header {
justify-content: space-between;
margin-bottom: 5px;

View File

@ -10,17 +10,29 @@
</el-button>
</div>
<div class="header-right">
<el-button type="primary" :disabled="!(resultList.length)" @click="getCompletion">一键研读</el-button>
<el-button type="primary">生成大纲</el-button>
<el-button type="danger" @click="pptDialog = true">生成PPT</el-button>
</div>
</div>
<div class="right-con flex">
<el-empty v-if="!(resultList.length)" description="暂无数据" />
<div class="con-item flex" v-for="(item, index) in resultList" :key="item.id" v-loading="item.loading">
<div class="item-top flex">
<span>{{ item.name }}</span>
<el-button type="info" link>
<el-popover placement="bottom-end" trigger="hover" popper-class="template-custom-popover">
<template #reference>
<el-button link type="primary">
<i class="iconfont icon-shenglvehao"></i></el-button>
</template>
<template #default>
<el-button type="primary" link @click="editKeyWord(item, false)">编辑</el-button>
<el-button type="primary" link @click="removeItem(item, true)">移除</el-button>
</template>
</el-popover>
<!-- <el-button type="info" link>
<i class="iconfont icon-xiazai9"></i>
</el-button>
</el-button> -->
</div>
<div class="item-bom">
<div class="item-prompt">{{ item.prompt }}</div>
@ -51,19 +63,23 @@
<AdjustDialog v-model="isAdjust" :item="curItem" />
<PptDialog @add-success="addAiPPT" :dataList="resultList" v-model="pptDialog"/>
<progress-dialog v-model:visible="pgDialog.visible" v-bind="pgDialog" />
<!--添加编辑提示词-->
<keywordDialog v-model="isWordDialog" :item="curItem" />
</template>
<script setup>
import { ref, onMounted, onUnmounted, reactive } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { sessionStore } from '@/utils/store'
import emitter from '@/utils/mitt'
import EditDialog from './edit-dialog.vue'
import AdjustDialog from './adjust-dialog.vue'
import progressDialog from './progress-dialog.vue'
import { completion, tempResult } from '@/api/mode/index.js'
import { completion, tempResult, tempSave, removeChildTemp } from '@/api/mode/index.js'
// import { dataSetJson } from '@/utils/comm.js'
import * as commUtils from '@/utils/comm.js'
import PptDialog from '@/views/prepare/container/pptist-dialog.vue'
import keywordDialog from './keyword-dialog.vue'
import useUserStore from '@/store/modules/user'
import {PPTXFileToJson} from '@/AixPPTist/src/hooks/useImport' // pptjson
@ -97,11 +113,87 @@ const pgDialog = reactive({ // 弹窗-进度条
})
emitter.on('changeMode', (item) => {
resultList.value = item.child
// conversation()
getTempResult(item.id)
})
//
const getCompletion = async () => {
for (let item of resultList.value) {
console.log(item)
try {
item.loading = true
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}${curNode.itemtitle}进行教学分析`
const { data } = await completion(params)
item.answer = getResult(data.answer)
onSaveTemp(item)
} finally {
item.loading = false
}
}
}
//
const onSaveTemp = (item) => {
if (item.answer == '') return
const data = {
mainModelId: item.parentId,
modelId: item.id,
examDocld: '',
content: item.answer,
ex1: curNode.id
}
tempSave(data).then(res => { })
}
const isWordDialog = ref(false)
const editKeyWord = (item, val) => {
/**
* isAdd: 子模板中的移除 为编辑false 头部删除 添加提示词为新增 true
*/
Object.assign(curItem, item)
curItem.isAdd = val
isWordDialog.value = true
}
//
const removeItem = async (item, isChild) => {
/**
* item: 当前操作的模板
* isChild: 子模板中的移除为 true
*/
if (item.ex3 != '1') {
ElMessageBox.confirm(
'确认是否移除?',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
removeChildTemp(item.id).then(res => {
ElMessage.success('操作成功')
if (isChild) {
//
emitter.emit('onGetChild', item)
}
else {
//
// getTemplateList()
}
})
})
}
else {
// editKeyWord(item, !isChild)
}
}
//
const getTempResult = (id) => {
tempResult({ mainModelId: id }).then(res => {
@ -119,6 +211,11 @@ const getTempResult = (id) => {
})
}
// ### **
let getResult = (str) => {
let newStr = str.replace(/#+|(\*\*)/g, '');
return newStr
}
const params = reactive(
{
@ -176,18 +273,7 @@ const addAiPPT = async(res) => {
}
})
}
const conversation = async () => {
for (let item of resultList.value) {
item.loading = true
try {
params.prompt = `按照${item.prompt}的要求,针对${curNode.edustage}${curNode.edusubject}课标对${curNode.itemtitle}进行教学分析`
const { data } = await completion(params)
item.answer = data.answer
} finally {
item.loading = false
}
}
}
const isEdit = ref(false)
//
@ -368,8 +454,10 @@ onUnmounted(() => {
emitter.off('changeMode')
emitter.off('changeResult')
emitter.off('changeAdjust')
})
</script>
<style lang="scss" scoped>
@ -402,6 +490,9 @@ onUnmounted(() => {
justify-content: space-between;
align-items: center;
margin-bottom: 5px;
.icon-shenglvehao{
font-weight: bold
}
}
.item-bom {
@ -446,3 +537,9 @@ onUnmounted(() => {
}
}
</style>
<style>
.template-custom-popover {
width: 110px !important;
min-width: 110px !important;
}
</style>