Compare commits

...

2 Commits

Author SHA1 Message Date
lyc fae380f9c6 Merge pull request 'edit' (#71) from lyc-dev into main 2024-11-27 11:21:39 +08:00
lyc a68fb21203 edit 2024-11-27 11:21:18 +08:00
2 changed files with 28 additions and 18 deletions

View File

@ -16,6 +16,7 @@
<script setup> <script setup>
import { ref, onMounted, nextTick } from 'vue' import { ref, onMounted, nextTick } from 'vue'
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'
@ -31,8 +32,8 @@ const onClick = () => {
const pdfUrl = ref('') const pdfUrl = ref('')
onMounted(async () => { onMounted(async () => {
await nextTick() await nextTick()
const { fileurl } = props.curNode let data = sessionStore.get('subject.curBook')
pdfUrl.value = import.meta.env.VITE_APP_RES_FILE_PATH + fileurl.replace('.txt', '.pdf') pdfUrl.value = import.meta.env.VITE_APP_RES_FILE_PATH + data.fileurl.replace('.txt', '.pdf')
}) })
</script> </script>

View File

@ -82,9 +82,10 @@
</template> </template>
<script setup> <script setup>
import { ref, reactive, onMounted, computed, onUnmounted } from 'vue' import { ref, reactive, onMounted, watch, onUnmounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import { tempSave, completion, modelList, removeChildTemp, tempResult } from '@/api/mode/index' import { tempSave, completion, modelList, removeChildTemp, tempResult } from '@/api/mode/index'
import { sessionStore } from '@/utils/store'
import keywordDialog from './keyword-dialog.vue'; import keywordDialog from './keyword-dialog.vue';
import AdjustDialog from './adjust-dialog.vue' import AdjustDialog from './adjust-dialog.vue'
import EditDialog from './edit-dialog.vue' import EditDialog from './edit-dialog.vue'
@ -187,7 +188,7 @@ const changeTemplate = (val) => {
const removeItem = async (item, isChild) => { const removeItem = async (item, isChild) => {
/** /**
* item: 当前操作的模板 * item: 当前操作的模板
* isChild: 子模板中的移除为 true 否则为false * isChild: 子模板中的移除为 true
*/ */
if (item.ex3 != '1') { if (item.ex3 != '1') {
ElMessageBox.confirm( ElMessageBox.confirm(
@ -213,15 +214,11 @@ const removeItem = async (item, isChild) => {
}) })
} }
else { else {
editKeyWord(item,!isChild) editKeyWord(item,!isChild)
} }
} }
// Ai // Ai
const curIndex = ref(-1) const curIndex = ref(-1)
const isAdjust = ref(false) const isAdjust = ref(false)
@ -240,11 +237,21 @@ const onEdit = (index, item) => {
} }
const modeType = computed(() => { const modeType = ref('课标')
if (props.type == 1) return '课标'; watch(() => props.type, (newVal) => {
if (props.type == 2) return '教材'; if (newVal == 1){
if (props.type == 3) return '考试'; modeType.value = '课标'
}) }
if (newVal == 2){
modeType.value = '教材'
}
if (newVal == 2){
modeType.value = '考试'
}
}, { immediate: false })
// //
const params = reactive( const params = reactive(
{ {
@ -256,7 +263,7 @@ const params = reactive(
const againResult = async (index, item) => { const againResult = async (index, item) => {
try { try {
childTempList.value[index].loading = true childTempList.value[index].loading = true
params.prompt = `按照${item.name}的要求,针对${props.curNode.edustage}${props.curNode.edusubject}${modeType}${props.curNode.itemtitle}进行教学分析` params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析`
const { data } = await completion(params) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
childTempList.value[index].oldAnswer = answer childTempList.value[index].oldAnswer = answer
@ -271,7 +278,7 @@ const getCompletion = async () => {
for (let item of childTempList.value) { for (let item of childTempList.value) {
try { try {
item.loading = true item.loading = true
params.prompt = `按照${item.name}的要求,针对${props.curNode.edustage}${props.curNode.edusubject}${modeType}${props.curNode.itemtitle}进行教学分析` params.prompt = `按照${item.name}的要求,针对${curNode.edustage}${curNode.edusubject}${modeType.value}${curNode.itemtitle}进行教学分析`
const { data } = await completion(params) const { data } = await completion(params)
let answer = data.answer let answer = data.answer
item.oldAnswer = answer item.oldAnswer = answer
@ -286,7 +293,7 @@ const getCompletion = async () => {
// //
const onSaveTemp = (item) => { const onSaveTemp = (item) => {
const data = { const data = {
mainModelId: props.tempId, mainModelId: curTemplate.id,
modelId: item.id, modelId: item.id,
examDocld: '', examDocld: '',
content: item.oldAnswer content: item.oldAnswer
@ -324,10 +331,12 @@ emitter.on('onGetMain', () => {
}) })
const curNode = reactive({})
onMounted(() => { onMounted(() => {
getTemplateList() getTemplateList()
let jsonKey = `${modeType}-${props.curNode.edustage}-${props.curNode.edusubject}` let data = sessionStore.get('subject.curNode')
Object.assign(curNode, data);
let jsonKey = `${modeType.value}-${data.edustage}-${data.edusubject}`
params.dataset_id = dataSetJson[jsonKey] params.dataset_id = dataSetJson[jsonKey]
}) })