From 5f00696dfb25bc90034448ceb634ed1ef256681a Mon Sep 17 00:00:00 2001 From: qiyunfeng-create <1940665526@qq.com> Date: 星期四, 21 八月 2025 21:13:35 +0800 Subject: [PATCH] Merge branch 'master' of http://182.92.203.7:2001/r/xiehe_website --- src/views/classManage/talkingPoint.vue | 375 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 375 insertions(+), 0 deletions(-) diff --git a/src/views/classManage/talkingPoint.vue b/src/views/classManage/talkingPoint.vue new file mode 100644 index 0000000..8f10051 --- /dev/null +++ b/src/views/classManage/talkingPoint.vue @@ -0,0 +1,375 @@ +<template> + <div class="classManagePage-box"> + <div class="classManagePage-nav"> + <el-breadcrumb :separator-icon="ArrowRight"> + <el-breadcrumb-item>鎴戠殑鐝骇</el-breadcrumb-item> + <el-breadcrumb-item>{{ classInfo?.name }}</el-breadcrumb-item> + <el-breadcrumb-item>璇濋</el-breadcrumb-item> + </el-breadcrumb> + </div> + <div class="classManagePage-content"> + <div class="headerBox"> + <div class="searchBox"> + <el-input + v-model="searchKey" + @clear="searchData()" + @keydown.enter="searchData()" + clearable + placeholder="鎼滅储璇濋鍚嶇О" + > + <template #append> + <el-button type="primary" class="searchBtn" @click="searchData()" :icon="Search" /> + </template> + </el-input> + </div> + <el-button @click="openTalk()" v-if="userInfo?.role == 'Teacher'" type="primary" round> + 鏂板缓 <el-icon><Plus /></el-icon> + </el-button> + </div> + <div class="listBox"> + <el-table + :header-cell-style="{ background: '#eee' }" + :data="dataList" + border + v-loading="isLoading" + style="width: 100%" + > + <el-table-column prop="index" label="搴忓彿" width="70" /> + <el-table-column label="璇濋鍚嶇О" width="500"> + <template #default="scope"> + <span style="color: #ff6c00" v-if="scope.row.name">{{ scope.row.name }}</span> + </template> + </el-table-column> + <el-table-column prop="createDate" label="鍙戣捣鏃ユ湡" /> + <el-table-column label="鍙戣捣浜�"> + <template #default="scope"> + <span v-if="scope.row.publicText">{{ scope.row.publicText.publisher }}</span> + </template> + </el-table-column> + <el-table-column label="鍙戣捣浜鸿鑹�"> + <template #default="scope"> + <span v-if="scope.row.publicText?.publishRole == 'Teacher'">鍔╂暀</span> + <span v-else>瀛︾敓</span> + </template> + </el-table-column> + <el-table-column prop="updateDate" label="鍙戣捣浜烘渶鍚庡洖澶嶆棩鏈�" /> + <el-table-column label="鎿嶄綔" width="180px"> + <template #default="scope"> + <el-button + link + type="primary" + v-if="scope.row.state == 'Normal'" + @click="toDetail(scope.row)" + >璇︽儏</el-button + > + <el-button + link + type="success" + v-if="scope.row.state != 'Normal'" + @click="pubTalk(scope.row)" + >鍙戝竷</el-button + > + <el-button + link + type="danger" + v-if="userInfo.role == 'Teacher'" + @click="delMessageItem(scope.row)" + >鍒犻櫎</el-button + > + </template> + </el-table-column> + </el-table> + <el-pagination + style="float: right" + v-model:current-page="pages.page" + :page-size="pages.pageSize" + layout="total, prev, pager, next" + :total="pages.count" + @size-change="handleSizeChange" + @current-change="handleCurrentChange" + /> + </div> + <el-dialog v-model="dialogVisible" title="鏂板缓璇濋" width="800"> + <div class="talkWall"> + <div class="talKBox"> + <span>璇濋鏍囬锛�</span> + <el-input v-model="talkTitle" style="width: 440px" placeholder="璇疯緭鍏ユ爣棰�" /> + </div> + <div class="talKBox"> + <span>璇濋鍐呭锛�</span> + <el-input + style="flex: 1" + v-model="talkContent" + :autosize="{ minRows: 10, maxRows: 15 }" + type="textarea" + placeholder="璇疯緭鍏ュ唴瀹�" + /> + </div> + </div> + <template #footer> + <div class="dialog-footer"> + <el-button @click="dialogVisible = false"> 鍙栨秷 </el-button> + <el-button type="primary" @click="createMessage()"> 纭 </el-button> + </div> + </template> + </el-dialog> + </div> + </div> +</template> + +<script setup lang="ts"> +import { reactive, ref, onMounted, inject, watch } from 'vue' +import { useRoute, useRouter } from 'vue-router' +import { Search, ArrowRight } from '@element-plus/icons-vue' +import { ElMessage } from 'element-plus' +import moment from 'moment' +const route: any = useRoute() +const router = useRouter() +const MG: any = inject('MG') +const config: any = inject('config') +const classInfo = JSON.parse(route.query.classInfo) +const userInfo = ref() + +const searchKey = ref('') +const talkTitle = ref('') +const talkContent = ref('') +const dialogVisible = ref(false) +const talkTopicInfo = ref() +const dataList = ref([]) +const isLoading = ref(false) +let pages = reactive({ + page: 1, + pageSize: 10, + count: 0, + loading: false +}) + +onMounted(() => { + const userCache: any = localStorage.getItem(config.userInfoKey) + if (userCache) { + userInfo.value = JSON.parse(userCache) + } + getTopicInfo() +}) + +const handleSizeChange = (val: number) => { + pages.pageSize = val + getMessage() +} + +const handleCurrentChange = (val: number) => { + pages.page = val + getMessage() +} + +const searchData = () => { + pages.page = 1 + pages.pageSize = 10 + getMessage() +} + +// 鑾峰彇璇濋topic +const getTopicInfo = () => { + const pramas = { + classId: classInfo.id, + refCodes: [config.refCodes.talk] + } + MG.edu.getClassTopic(pramas).then((res: any) => { + const list = res + talkTopicInfo.value = list.find((item: any) => item.refCode == config.refCodes.talk) + if (talkTopicInfo.value.id) { + getMessage() + } + }) +} + +// 鏂板缓璇濋 +const createMessage = () => { + if (talkTitle.value == '') { + ElMessage({ + message: '璇峰~鍐欐爣棰�', + type: 'warning' + }) + return false + } + if (talkContent.value == '') { + ElMessage({ + message: '璇峰~鍐欏唴瀹�', + type: 'warning' + }) + return false + } + newTalkMessage() +} + +// 璇濋璇︽儏 +const toDetail = (item: any) => { + const obj = classInfo + obj.MessageName = item.name + router.push({ + path: '/talkDetail', + query: { + classInfo: JSON.stringify(obj) + } + }) +} + +const newTalkMessage = () => { + const userCache: any = localStorage.getItem(config.userInfoKey) + const userInfo = JSON.parse(userCache) + const textObj = { + content: talkContent.value, + publisher: userInfo?.name ?? '', + publishRole: userInfo?.role ?? '', + icon: userInfo.icon ?? '' + } + const data = { + description: '', + icon: '', + state: 'Normal', + topicIdOrRefCode: String(talkTopicInfo.value.id), + name: talkTitle.value, + content: JSON.stringify(textObj), + type: 'Normal', + cmsTypeRefCode: '', + newDataListRequest: [] + } + MG.ugc.newTopicMessage(data).then((res: any) => { + if (res) { + dialogVisible.value = false + getMessage() + } + }) +} + +// 鑾峰彇鐝骇璇濋 +const getMessage = () => { + isLoading.value = true + const data = { + start: (pages.page - 1) * pages.pageSize, + size: pages.pageSize, + appRefCode: config.appRefCode, + topicIdOrRefCode: String(talkTopicInfo.value.id), + searchList: searchKey.value + ? [ + { + keywords: searchKey.value, + field: 'Name', + compareType: 'Contains' + } + ] + : [] + } + MG.ugc.getTopicMessageList(data).then((res: any) => { + const list = res.datas + pages.count = res.totalSize + isLoading.value = false + dataList.value = list.map((item: any, i: number) => { + const str = item.content.indexOf('publisher') + if (str > -1) { + item.publicText = JSON.parse(item.content) + } + return { + ...item, + index: i + 1, + createDate: moment(item.createDate).format('YYYY-MM-DD HH:mm:ss'), + updateDate: moment(item.updateDate).format('YYYY-MM-DD HH:mm:ss') + } + }) + }) +} + +// 鍒犻櫎璇濋 +const delMessageItem = (item: any) => { + const data = { + messageIds: [item.id] + } + MG.ugc + .delTopicMessage(data) + .then((res: any) => { + if (res) { + ElMessage.success('宸插垹闄�') + getTopicInfo() + } + }) + .catch((err: any) => { + ElMessage.error('鍒犻櫎澶辫触锛岃绋嶅悗鍐嶈瘯') + console.log(err) + }) +} + +// 瀹℃牳璇濋 +const pubTalk = (item: any) => { + const data = { + id: item.id, + name: item.name, + description: item.description, + icon: item.icon, + type: item.type, + state: 'Normal', + content: JSON.stringify(item.publicText), + newDataRequests: [], + updateDataRequests: [] + } + MG.ugc + .updateTopicMessage(data) + .then((res: any) => { + if (res) { + ElMessage({ + type: 'success', + message: '宸插彂甯�' + }) + getMessage() + } + }) + .catch((err: any) => { + console.log(err, '瀹℃牳璇濋') + }) +} + +const openTalk = () => { + dialogVisible.value = true +} +</script> + +<style lang="less" scoped> +.classManagePage-box { + padding: 20px; + .classManagePage-nav { + padding-bottom: 20px; + border-bottom: 1px solid #e6e8ed; + } + .classManagePage-content { + .headerBox { + padding: 20px 0; + overflow: hidden; + display: flex; + align-items: center; + justify-content: space-between; + .searchBox { + width: 300px; + float: left; + .searchBtn { + background-color: var(--el-color-primary); + color: #fff; + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + } + } + } +} +.headerCellClass { + background-color: red !important; +} + +.talkWall { + width: 100%; + height: auto; + .talKBox { + display: flex; + align-items: baseline; + margin-bottom: 20px; + } +} +</style> -- Gitblit v1.9.1