二期:预约开发

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: {
proxy: {
'/dev-api': {
target: 'http://27.128.240.72:7865',
// target: 'http://192.168.2.52:7863',
// target: 'http://27.128.240.72:7865',
target: 'http://192.168.2.52:7863',
changeOrigin: true,
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 }) => {
// 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 }) => {
console.log('完成')
e.reply('download-file-default' + fileName, true)

View File

@ -138,6 +138,14 @@ export function addSmartClassReserv(data) {
data: data
})
}
//修改课程预约
export function updateSmartClassReserv(data) {
return request({
url: '/smarttalk/classReserv/updateSmartClassReserv',
method: 'post',
data: data
})
}
//查询课程预约
export function getSelfReserv() {
return request({
@ -145,4 +153,23 @@ export function getSelfReserv() {
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>
<el-container class="class-reserv-wrap">
<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 class="class-reserv-body">
<reserv-item v-for="(item, index) in activeDataList" :key="index" :item="item" v-show="tabActive === '进行中'"></reserv-item>
<reserv-item v-for="(item, index) in doneDataList" :key="index" :item="item" v-show="tabActive === '已结束'"></reserv-item>
<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>
<reserv ref="reservDialog"></reserv>
</el-container>
</template>
@ -14,39 +27,45 @@
import { ref, onMounted, computed } from 'vue'
import { getSelfReserv } from '@/api/classManage'
import ReservItem from '@/views/classManage/reserv-item.vue'
const tabOptions = ref(['进行中','已结束'])
import Reserv from '@/views/prepare/container/reserv.vue'
const reservDialog = ref(null)
const tabOptions = ref(['进行中', '已结束'])
const tabActive = ref('进行中')
const dataList = ref([])
const activeDataList = computed(() => {
return dataList.value.filter(item => {
return item.status !== "已结束"
return dataList.value.filter((item) => {
return item.status !== '已结束'
})
})
const deleteReserv = (item) => {
dataList.value = dataList.value.filter((is) => {
return is.id !== item.id
})
}
const doneDataList = computed(() => {
return dataList.value.filter(item => {
return item.status === "已结束"
return dataList.value.filter((item) => {
return item.status === '已结束'
})
})
onMounted(() => {
getSelfReserv().then(res => {
getSelfReserv().then((res) => {
dataList.value = res.data
})
})
</script>
<style scoped lang="scss">
.class-reserv-wrap{
.class-reserv-wrap {
height: 100%;
display: flex;
flex-direction: column;
padding: 15px 30px;
.class-reserv-tabs{
.class-reserv-tabs {
width: 30%;
text-align: left;
}
.class-reserv-body{
.class-reserv-body {
height: 100%;
flex: 1;
overflow: auto;

View File

@ -1,31 +1,40 @@
<template>
<div class="class-reserv-item">
<div class="class-reserv-item-img">
<img :src="basePath + item.bookImg" alt="封面"/>
<img :src="basePath + item.bookImg" alt="封面" />
</div>
<div class="class-reserv-item-body">
<div class="class-reserv-item-title1">
<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.classSubject }}</el-tag>
<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.classSubject }}</el-tag>
</div>
<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 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 class="class-reserv-item-tool">
<el-button type="primary">上课</el-button>
<el-button>编辑</el-button>
<el-button type="info">下课</el-button>
<el-button type="danger">删除</el-button>
<el-button v-if="item.status !== '已结束'" type="primary" @click="startClassR(item)"
>上课</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>
</template>
<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({
item: {
type: Object,
@ -33,37 +42,74 @@ const props = defineProps({
}
})
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>
<style scoped lang="scss">
.class-reserv-item{
.class-reserv-item {
display: flex;
background-color: white;
border-radius: 10px;
padding: 5px;
margin-bottom: 10px;
.class-reserv-item-img{
.class-reserv-item-img {
width: 80px;
padding-left: 20px;
img{
img {
width: 100%;
}
}
.class-reserv-item-body{
.class-reserv-item-body {
flex: 1;
display: flex;
flex-direction: column;
text-align: left;
padding-left: 30px;
font-size: 14px;
.class-reserv-item-title1{
.class-reserv-item-title1 {
flex: 1;
label{
label {
font-size: 20px;
font-weight: bold;
}
}
}
.class-reserv-item-tool{
.class-reserv-item-tool {
margin-left: 15px;
display: flex;
align-items: center;

View File

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

View File

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