二期:预约开发

This commit is contained in:
朱浩 2024-08-09 15:06:13 +08:00
parent e5845a6714
commit ae500c94ce
7 changed files with 237 additions and 56 deletions

View File

@ -24,8 +24,8 @@ export default defineConfig({
server: { server: {
proxy: { proxy: {
'/dev-api': { '/dev-api': {
target: 'http://27.128.240.72:7865', // target: 'http://27.128.240.72:7865',
// target: 'http://192.168.2.52:7863', target: 'http://192.168.2.52:7863',
changeOrigin: true, changeOrigin: true,
rewrite: (p) => p.replace(/^\/dev-api/, '') rewrite: (p) => p.replace(/^\/dev-api/, '')
} }

View File

@ -250,7 +250,9 @@ export default async function ({ app, shell, BrowserWindow, ipcMain }) {
onDownloadStarted: async ({ id, item, webContents }) => { onDownloadStarted: async ({ id, item, webContents }) => {
// Do something with the download id // Do something with the download id
}, },
onDownloadProgress: async ({ id, item, percentCompleted }) => {}, onDownloadProgress: async ({ id, item, percentCompleted }) => {
e.reply('download-file-default-prog' + fileName, percentCompleted)
},
onDownloadCompleted: async ({ id, item }) => { onDownloadCompleted: async ({ id, item }) => {
console.log('完成') console.log('完成')
e.reply('download-file-default' + fileName, true) e.reply('download-file-default' + fileName, true)

View File

@ -138,6 +138,14 @@ export function addSmartClassReserv(data) {
data: data data: data
}) })
} }
//修改课程预约
export function updateSmartClassReserv(data) {
return request({
url: '/smarttalk/classReserv/updateSmartClassReserv',
method: 'post',
data: data
})
}
//查询课程预约 //查询课程预约
export function getSelfReserv() { export function getSelfReserv() {
return request({ return request({
@ -145,4 +153,23 @@ export function getSelfReserv() {
method: 'get' method: 'get'
}) })
} }
export function deleteSmartReserv(id) {
return request({
url: '/smarttalk/classReserv/' + id,
method: 'delete'
})
}
export function startClass(id) {
return request({
url: '/smarttalk/classReserv/startClass',
method: 'get',
params: {id}
})
}
export function endClass(id) {
return request({
url: '/smarttalk/classReserv/endClass',
method: 'get',
params: {id}
})
}

View File

@ -1,12 +1,25 @@
<template> <template>
<el-container class="class-reserv-wrap"> <el-container class="class-reserv-wrap">
<div class="class-reserv-tabs"> <div class="class-reserv-tabs">
<el-segmented block v-model="tabActive" :options="tabOptions" size="large" /> <el-segmented v-model="tabActive" block :options="tabOptions" size="large" />
</div> </div>
<div class="class-reserv-body"> <div class="class-reserv-body">
<reserv-item v-for="(item, index) in activeDataList" :key="index" :item="item" v-show="tabActive === '进行中'"></reserv-item> <reserv-item
<reserv-item v-for="(item, index) in doneDataList" :key="index" :item="item" v-show="tabActive === '已结束'"></reserv-item> v-for="(item, index) in activeDataList"
v-show="tabActive === '进行中'"
:key="index"
:item="item"
@open-edit="reservDialog.openDialog(item)"
@delete-reserv="deleteReserv(item)"
></reserv-item>
<reserv-item
v-for="(item, index) in doneDataList"
v-show="tabActive === '已结束'"
:key="index"
:item="item"
></reserv-item>
</div> </div>
<reserv ref="reservDialog"></reserv>
</el-container> </el-container>
</template> </template>
@ -14,39 +27,45 @@
import { ref, onMounted, computed } from 'vue' import { ref, onMounted, computed } from 'vue'
import { getSelfReserv } from '@/api/classManage' import { getSelfReserv } from '@/api/classManage'
import ReservItem from '@/views/classManage/reserv-item.vue' import ReservItem from '@/views/classManage/reserv-item.vue'
import Reserv from '@/views/prepare/container/reserv.vue'
const tabOptions = ref(['进行中','已结束']) const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中') const tabActive = ref('进行中')
const dataList = ref([]) const dataList = ref([])
const activeDataList = computed(() => { const activeDataList = computed(() => {
return dataList.value.filter(item => { return dataList.value.filter((item) => {
return item.status !== "已结束" return item.status !== '已结束'
}) })
}) })
const deleteReserv = (item) => {
dataList.value = dataList.value.filter((is) => {
return is.id !== item.id
})
}
const doneDataList = computed(() => { const doneDataList = computed(() => {
return dataList.value.filter(item => { return dataList.value.filter((item) => {
return item.status === "已结束" return item.status === '已结束'
}) })
}) })
onMounted(() => { onMounted(() => {
getSelfReserv().then(res => { getSelfReserv().then((res) => {
dataList.value = res.data dataList.value = res.data
}) })
}) })
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.class-reserv-wrap{ .class-reserv-wrap {
height: 100%; height: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding: 15px 30px; padding: 15px 30px;
.class-reserv-tabs{ .class-reserv-tabs {
width: 30%; width: 30%;
text-align: left; text-align: left;
} }
.class-reserv-body{ .class-reserv-body {
height: 100%; height: 100%;
flex: 1; flex: 1;
overflow: auto; overflow: auto;

View File

@ -1,31 +1,40 @@
<template> <template>
<div class="class-reserv-item"> <div class="class-reserv-item">
<div class="class-reserv-item-img"> <div class="class-reserv-item-img">
<img :src="basePath + item.bookImg" alt="封面"/> <img :src="basePath + item.bookImg" alt="封面" />
</div> </div>
<div class="class-reserv-item-body"> <div class="class-reserv-item-body">
<div class="class-reserv-item-title1"> <div class="class-reserv-item-title1">
<label>{{item.className}}</label> <label>{{ item.className }}</label>
<el-tag style="margin-left: 5px;" type="primary"> {{ item.classType }}</el-tag> <el-tag style="margin-left: 5px" type="primary"> {{ item.classType }}</el-tag>
<el-tag style="margin-left: 5px;" type="primary"> {{ item.classSubject }}</el-tag> <el-tag style="margin-left: 5px" type="primary"> {{ item.classSubject }}</el-tag>
</div> </div>
<div class="class-reserv-item-title2"> <div class="class-reserv-item-title2">
{{item.classDay}}&nbsp;{{item.startTime}} ~ {{item.classDay}}&nbsp;{{item.endTime}} {{item.createUserName}}老师 {{ item.classDay }}&nbsp;{{ item.startTime }} ~ {{ item.classDay }}&nbsp;{{ item.endTime }}
{{ item.createUserName }}老师
</div> </div>
<div class="class-reserv-item-title3"> <div class="class-reserv-item-title3">
<span style="margin-left: 5px;" v-for="(tag, index) in item.classItemList" :key="index"> {{ index===0? tag.name:''+tag.name }}</span> <span v-for="(tag, index) in item.classItemList" :key="index" style="margin-left: 5px">
{{ index === 0 ? tag.name : '、' + tag.name }}</span
>
</div> </div>
</div> </div>
<div class="class-reserv-item-tool"> <div class="class-reserv-item-tool">
<el-button type="primary">上课</el-button> <el-button v-if="item.status !== '已结束'" type="primary" @click="startClassR(item)"
<el-button>编辑</el-button> >上课</el-button
<el-button type="info">下课</el-button> >
<el-button type="danger">删除</el-button> <el-button v-if="item.status === '未开始'" @click="openEdit">编辑</el-button>
<el-button v-if="item.status === '上课中'" type="info" @click="endClassR(item)"
>下课</el-button
>
<el-button type="danger" @click="deleteReserv">删除</el-button>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { ref } from 'vue' import { deleteSmartReserv, startClass, endClass } from '@/api/classManage'
import { ElMessage } from 'element-plus'
const emit = defineEmits(['openEdit', 'deleteReserv'])
const props = defineProps({ const props = defineProps({
item: { item: {
type: Object, type: Object,
@ -33,37 +42,74 @@ const props = defineProps({
} }
}) })
const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH const basePath = import.meta.env.VITE_APP_BUILD_BASE_PATH
const openEdit = () => {
emit('openEdit', props.item)
}
const deleteReserv = () => {
deleteSmartReserv([props.item.id]).then((res) => {
if (res.data === true) {
ElMessage({
message: '删除成功',
type: 'success'
})
emit('deleteReserv', props.item)
}
})
}
const startClassR = (item) => {
startClass(item.id).then((res) => {
if (res.data === true) {
ElMessage({
message: '上课成功',
type: 'success'
})
item.status = '上课中'
}
})
}
const endClassR = (item) => {
endClass(item.id).then((res) => {
if (res.data === true) {
ElMessage({
message: '下课成功',
type: 'success'
})
item.status = '已结束'
}
})
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.class-reserv-item{ .class-reserv-item {
display: flex; display: flex;
background-color: white; background-color: white;
border-radius: 10px; border-radius: 10px;
padding: 5px; padding: 5px;
margin-bottom: 10px; margin-bottom: 10px;
.class-reserv-item-img{ .class-reserv-item-img {
width: 80px; width: 80px;
padding-left: 20px; padding-left: 20px;
img{ img {
width: 100%; width: 100%;
} }
} }
.class-reserv-item-body{ .class-reserv-item-body {
flex: 1; flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
text-align: left; text-align: left;
padding-left: 30px; padding-left: 30px;
font-size: 14px; font-size: 14px;
.class-reserv-item-title1{ .class-reserv-item-title1 {
flex: 1; flex: 1;
label{ label {
font-size: 20px; font-size: 20px;
font-weight: bold; font-weight: bold;
} }
} }
} }
.class-reserv-item-tool{ .class-reserv-item-tool {
margin-left: 15px; margin-left: 15px;
display: flex; display: flex;
align-items: center; align-items: center;

View File

@ -77,21 +77,24 @@
</el-dialog> </el-dialog>
</template> </template>
<script setup> <script setup>
import { ref, defineExpose, onMounted, reactive, computed } from 'vue' import { ref, defineExpose, onMounted, reactive, computed, watch } from 'vue'
import { addSmartClassReserv, listClassmain } from '@/api/classManage' import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
import useUserStore from '@/store/modules/user' import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus' import { ElMessage } from 'element-plus'
const props = defineProps({ const props = defineProps({
subject: {
type: String,
default: ''
},
bookId: { bookId: {
type: Number, type: Number,
default: '' default: 0
},
currentNode: {
type: Object,
default: () => {
return {}
}
} }
}) })
const ruleFormDialog = ref(null) const ruleFormDialog = ref(null)
const nowType = ref('add')
const userStore = useUserStore().user const userStore = useUserStore().user
const centerDialogVisible = ref(false) const centerDialogVisible = ref(false)
const form = reactive({ const form = reactive({
@ -102,6 +105,13 @@ const form = reactive({
resource: [], resource: [],
classRoom: '' classRoom: ''
}) })
const updateForm = ref({})
watch(
() => props.currentNode,
(newValue, oldValue) => {
form.name = newValue.label
}
)
const ruleForm = reactive({ const ruleForm = reactive({
name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }], name: [{ required: true, message: '请输入课程名称', trigger: 'blur' }],
day: [{ required: true, message: '请选择上课日期', trigger: 'change' }], day: [{ required: true, message: '请选择上课日期', trigger: 'change' }],
@ -132,17 +142,29 @@ const locationOptions = [
const locationMessage = computed(() => { const locationMessage = computed(() => {
return locationOptions.find((item) => item.value === form.type).message return locationOptions.find((item) => item.value === form.type).message
}) })
const openDialog = () => { const openDialog = (data) => {
if (data) {
updateForm.value = data
nowType.value = 'update'
form.name = data.className
form.type = data.classType
form.day = data.classDay
form.time = [data.startTime, data.endTime]
form.resource = data.classList.split(',').map((item) => parseInt(item))
form.classRoom = data.classRoom
}
centerDialogVisible.value = true centerDialogVisible.value = true
} }
const closeDialog = () => { const closeDialog = () => {
ruleFormDialog.value.resetFields() ruleFormDialog.value.resetFields()
centerDialogVisible.value = false centerDialogVisible.value = false
form.name = props.currentNode.label
} }
const classList = ref([]) const classList = ref([])
onMounted(() => { onMounted(() => {
listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then( listClassmain({ classuserid: userStore.userId, pageSize: 100, status: 'open' }).then(
(response) => { (response) => {
console.log(response)
classList.value = [...response.rows] classList.value = [...response.rows]
} }
) )
@ -152,13 +174,17 @@ const submitForm = async () => {
if (!formEl) return if (!formEl) return
await formEl.validate((valid) => { await formEl.validate((valid) => {
if (valid) { if (valid) {
addClassReserv(form) if (nowType.value === 'update') {
updateClassReserv(form)
} else {
addClassReserv(form)
}
centerDialogVisible.value = false centerDialogVisible.value = false
} }
}) })
} }
const addClassReserv = (formData) => { const updateClassReserv = (formData) => {
let ids = formData.resource.join(",") let ids = formData.resource.join(',')
let param = { let param = {
className: formData.name, className: formData.name,
classType: formData.type, classType: formData.type,
@ -167,12 +193,41 @@ const addClassReserv = (formData) => {
endTime: formData.time[1], endTime: formData.time[1],
classList: ids, classList: ids,
classRoom: formData.classRoom, classRoom: formData.classRoom,
classSubject: props.subject, id: updateForm.value.id
ex1: props.bookId }
} updateSmartClassReserv(param).then((res) => {
if (res.data === true) {
closeDialog()
ElMessage({
type: 'success',
message: '修改预约成功!'
})
Object.assign(updateForm.value, param)
} else {
ElMessage({
type: 'error',
message: res.message
})
}
})
}
const addClassReserv = (formData) => {
let ids = formData.resource.join(',')
let param = {
className: formData.name,
classType: formData.type,
classDay: formData.day,
startTime: formData.time[0],
endTime: formData.time[1],
classList: ids,
classRoom: formData.classRoom,
classSubject: props.currentNode.edusubject,
ex1: props.bookId,
ex2: props.currentNode.id
}
addSmartClassReserv(param).then((res) => { addSmartClassReserv(param).then((res) => {
if (res.data === true) { if (res.data === true) {
closeDialog(); closeDialog()
ElMessage({ ElMessage({
type: 'success', type: 'success',
message: '预约成功!' message: '预约成功!'

View File

@ -13,8 +13,10 @@
<el-button class="btn" @click="handleOutLink('aiModel')">教学大模型</el-button> <el-button class="btn" @click="handleOutLink('aiModel')">教学大模型</el-button>
</div> </div>
<el-button type="primary" class="to-class-btn" @click="openLesson"> <el-button type="primary" class="to-class-btn" @click="openLesson">
<i class="iconfont icon-lingdang"></i>上课</el-button <label><i class="iconfont icon-lingdang"></i>上课</label>
> <label>{{ curClassReserv.classDay }} {{ getWeekday1(curClassReserv.classDay) }}</label>
<label>{{ curClassReserv.startTime }}-{{ curClassReserv.endTime }}</label>
</el-button>
<div class="top-zoom-style"></div> <div class="top-zoom-style"></div>
</div> </div>
<div class="prepare-body-header"> <div class="prepare-body-header">
@ -102,7 +104,7 @@
@on-close="closeHomework" @on-close="closeHomework"
/> />
</div> </div>
<reserv :subject="currentNode.edusubject" :book-id="uploadData.textbookId" ref="reservDialog"></reserv> <reserv ref="reservDialog" :current-node="currentNode" :book-id="uploadData.textbookId"></reserv>
</template> </template>
<script setup> <script setup>
import { Check } from '@element-plus/icons-vue' import { Check } from '@element-plus/icons-vue'
@ -129,6 +131,7 @@ import outLink from '@/utils/linkConfig'
import { createWindow } from '@/utils/tool' import { createWindow } from '@/utils/tool'
import { uniqBy, cloneDeep } from 'lodash' import { uniqBy, cloneDeep } from 'lodash'
import { delClasswork, addEntpcourse } from '@/api/teaching/classwork' import { delClasswork, addEntpcourse } from '@/api/teaching/classwork'
import { getSelfReserv } from '@/api/classManage'
const fs = require('fs') const fs = require('fs')
const { ipcRenderer } = window.electron || {} const { ipcRenderer } = window.electron || {}
@ -157,6 +160,7 @@ export default {
currentFileList: [], currentFileList: [],
currentWorkList: [], currentWorkList: [],
curBookPath: '', curBookPath: '',
curClassReserv: {},
lastAsyncAllTime: '', lastAsyncAllTime: '',
uploadData: { uploadData: {
textbookId: null, textbookId: null,
@ -199,7 +203,16 @@ export default {
}) })
this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime') this.lastAsyncAllTime = localStorage.getItem('lastAsyncAllTime')
}, },
mounted() {}, mounted() {
getSelfReserv().then((res) => {
let list = res.data.filter((item) => {
return item.status !== '已结束'
})
if (list.length > 0) {
this.curClassReserv = list[list.length - 1]
}
})
},
activated() { activated() {
if (this.uploadData.textbookId !== null) { if (this.uploadData.textbookId !== null) {
this.asyncAllFile() this.asyncAllFile()
@ -223,6 +236,8 @@ export default {
url: filePath, url: filePath,
fileName: fileName fileName: fileName
}) })
ipcRenderer.removeListener('download-file-default-prog' + fileName, this.progDownFile)
ipcRenderer.on('download-file-default-prog' + fileName, this.progDownFile)
ipcRenderer.once('download-file-default' + fileName, (e, isSuccess) => { ipcRenderer.once('download-file-default' + fileName, (e, isSuccess) => {
if (isSuccess === true) { if (isSuccess === true) {
resolve(fileName) resolve(fileName)
@ -239,6 +254,10 @@ export default {
}) })
}) })
}, },
progDownFile(e, num) {
console.log(num)
//TODO
},
createFile() { createFile() {
creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => { creatPPT(this.currentNode.label + '.pptx', this.uploadData).then((res) => {
this.currentFileList.unshift(res.resData) this.currentFileList.unshift(res.resData)
@ -510,6 +529,11 @@ export default {
this.currentWorkList = cloneDeep(ary) this.currentWorkList = cloneDeep(ary)
}) })
}, },
getWeekday1(date) {
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
const weekday = new Date(date).getDay()
return weekdays[weekday]
},
// //
openSet(row) { openSet(row) {
this.row = row this.row = row
@ -538,7 +562,9 @@ export default {
const toolStore = useToolState() const toolStore = useToolState()
if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作') if (toolStore.isPdfWin) return this.$message.error('您当前已打开课本,请勿重复操作')
let path = await this.getBookPathFromServer() let path = await this.getBookPathFromServer()
createWindow('open-PDF', { url: '/classBegins/index?textbookId='+this.uploadData.textbookId+'&path='+ path }) createWindow('open-PDF', {
url: '/classBegins/index?textbookId=' + this.uploadData.textbookId + '&path=' + path
})
}, },
// - // -
openLesson() { openLesson() {
@ -658,7 +684,13 @@ export default {
margin-left: 25px; margin-left: 25px;
font-size: 18px; font-size: 18px;
z-index: 1; z-index: 1;
& label:hover {
cursor: pointer !important;
}
& > :deep(span) {
flex-direction: column !important;
font-size: 12px;
}
.icon-lingdang { .icon-lingdang {
margin-right: 5px; margin-right: 5px;
color: #ffffff; color: #ffffff;