| | |
| | | <div class="helpContainer"> |
| | | <el-table |
| | | class="custom-table" |
| | | :data="tableData" |
| | | :data="helpData" |
| | | style="width: 100%" |
| | | :row-class-name="tableRowClassName" |
| | | > |
| | |
| | | {{ $index + 1 }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="jibie1" label="一级类别" /> |
| | | <el-table-column prop="jibie2" label="二级类别" /> |
| | | <el-table-column prop="name" label="上传者" /> |
| | | <el-table-column prop="date" label="上传时间" /> |
| | | <el-table-column prop="levelOneType" label="一级类别" /> |
| | | <el-table-column prop="levelTwoType" label="二级类别" /> |
| | | <el-table-column prop="uploadUser" label="上传者" /> |
| | | <el-table-column prop="createTime" label="上传时间" /> |
| | | <el-table-column label="操作" width="150" align="center"> |
| | | <template #default="scope"> |
| | | <span class="look">查看</span> |
| | | <span class="look" @click="clickDetail(scope.row)">查看</span> |
| | | <el-upload |
| | | style="display: inline-block" |
| | | :show-file-list="false" |
| | | :before-upload="onUploadFileBefore" |
| | | :before-upload="(file) => onUploadFileBefore(file, scope.row)" |
| | | :limit="1" |
| | | > |
| | | <span class="uploads">上传</span> |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { uploadFileAPI } from '@/api/helpCenter/helpCenter'; |
| | | import { uploadFileAPI, listDataAPI, updataDataAPI } from '@/api/helpCenter/helpCenter'; |
| | | import { ElMessage } from 'element-plus'; |
| | | const helpData = ref([{}]); |
| | | const tableData = [ |
| | | { |
| | | jibie1: '入门指南', |
| | | jibie2: '指挥调度平台', |
| | | name: 'cdsfsdf', |
| | | date: '2025/05/03 14:10', |
| | | }, |
| | | { |
| | | jibie1: '入门指南', |
| | | jibie2: '综合管理平台', |
| | | name: 'cdsfsdf', |
| | | date: '2025/05/03 14:10', |
| | | }, |
| | | { |
| | | jibie1: '入门指南', |
| | | jibie2: 'AISKY算法平台', |
| | | name: 'cdsfsdf', |
| | | date: '2025/05/03 14:10', |
| | | }, |
| | | { |
| | | jibie1: '一级类别', |
| | | jibie2: '7.6.35版本更新', |
| | | name: 'cdsfsdf', |
| | | date: '2025/05/03 14:10', |
| | | }, |
| | | ]; |
| | | import { onMounted } from 'vue'; |
| | | const helpData = ref([]); |
| | | |
| | | // 表格隔行变色 |
| | | const tableRowClassName = ({ row, rowIndex }) => { |
| | | if (rowIndex % 2 === 1) { |
| | |
| | | return 'success-row'; |
| | | } |
| | | }; |
| | | const onUploadFileBefore = file => { |
| | | const fileFormat = file.name.split('.')[1] |
| | | if (fileFormat !== 'pdf') return ElMessage.error('请上传pdf格式的文件') |
| | | const getlistDataAPI = () => { |
| | | listDataAPI().then(res => { |
| | | helpData.value = res.data.data; |
| | | |
| | | }); |
| | | }; |
| | | // 查看 |
| | | const clickDetail = (val) => { |
| | | const filePath = val.filePath |
| | | if (!val.filePath) { |
| | | ElMessage.warning('没有可预览的文件'); |
| | | return; |
| | | } |
| | | window.open(filePath, '_blank'); |
| | | }; |
| | | // 文件上传 |
| | | const onUploadFileBefore = (file,row) => { |
| | | const params={ |
| | | id:row.id, |
| | | filePath:row.filePath |
| | | } |
| | | const fileFormat = file.name?.split('.')[1]; |
| | | if (fileFormat !== 'pdf') return ElMessage.error('请上传pdf格式的文件'); |
| | | const formData = new FormData(); |
| | | formData.append('file',file, file.name); |
| | | uploadFileAPI(formData) |
| | | .then(res => { |
| | | if (res.data.code !== 200) return ElMessage.error('上传失败') |
| | | ElMessage.success('上传成功') |
| | | |
| | | }) |
| | | uploadFileAPI(formData).then(res => { |
| | | if (res.data.code === 200) { |
| | | ElMessage.success('上传成功'); |
| | | updataDataAPI(params) |
| | | } else { |
| | | ElMessage.error('上传失败'); |
| | | } |
| | | }); |
| | | }; |
| | | onMounted(() => { |
| | | getlistDataAPI(); |
| | | }); |
| | | </script> |
| | | <style lang="scss"> |
| | | .helpContainer { |