修改同步教材教务学校

This commit is contained in:
jiangzhe 2024-07-17 11:25:53 +08:00
parent d8c7a20228
commit ceddefc6f2
3 changed files with 69 additions and 70 deletions

View File

@ -3,20 +3,27 @@
<el-col :span="5">
<div class="tree-container">
<div class="top">
<!-- <el-button type="" text="plain">全部专题资源</el-button>
<el-radio-group v-model="queryParams.type" @change="handleTypeChange">
<el-radio-button label="课件" :value="1" />
<el-radio-button label="精品课堂" :value="2" />
<el-radio-button label="作业" :value="3" />
<el-radio-button label="试卷" :value="4" />
</el-radio-group>
<div class="line"></div>
<!-- <el-button type="" text="plain">全部文件</el-button>
<br>
<el-badge v-if="auditNum > 0" :value="auditNum" style="margin-left:10px;margin-top: 10px;">
<el-button v-hasPermi="['file:resource:awaitList']" :class="['btn-audit', isAudit && 'active']" type=""
<el-button v-hasPermi="['file:textbook:awaitList']" :class="['btn-audit', isAudit && 'active']" type=""
text="plain" @click="handleAudit">待审核</el-button>
</el-badge>
<el-button v-else v-hasPermi="['file:resource:awaitList']" :class="['btn-audit', isAudit && 'active']" type=""
<el-button v-else v-hasPermi="['file:textbook:awaitList']" :class="['btn-audit', isAudit && 'active']" type=""
text="plain" @click="handleAudit">待审核</el-button> -->
<div class="tree-container-scroll">
<el-scrollbar>
<el-tree ref="treeRef" v-loading="treeLoading" :data="treeData" :props="defaultProps" default-expand-all
@node-click="handleNode" />
:expand-on-click-node="false" node-key="catalogId" @node-click="handleNode" />
</el-scrollbar>
</div>
</div>
@ -57,11 +64,11 @@
<template #header>
<el-row :gutter="10" class="mb8">
<el-col v-if="isUpload" :span="1.5">
<el-button v-hasPermi="['file:resource:add']" type="primary" plain icon="Upload"
<el-button v-hasPermi="['file:textbook:add']" type="primary" plain icon="Upload"
@click="handleFile">上传文件</el-button>
</el-col>
<el-col :span="1.5">
<el-button v-hasPermi="['file:resource:remove']" type="danger" plain icon="Delete" :disabled="multiple"
<el-button v-hasPermi="['file:textbook:remove']" type="danger" plain icon="Delete" :disabled="multiple"
@click="handleDelete()">
删除
</el-button>
@ -92,7 +99,7 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="400">
<template #default="scope">
<span v-hasPermi="['file:resource:review']">
<span v-hasPermi="['file:textbook:review']">
<el-tooltip v-if="isAudit" content="审核通过" placement="top">
<el-button link type="primary" icon="CopyDocument"
@click="handleAuditBtn(scope.row, 1)">审核通过</el-button>
@ -103,21 +110,21 @@
</el-tooltip>
</span>
<el-tooltip v-hasPermi="['file:resource:preview']" content="预览" placement="top">
<el-tooltip v-hasPermi="['file:textbook:preview']" content="预览" placement="top">
<el-button link type="primary" icon="View" @click="handlePreview(scope.row)">预览</el-button>
</el-tooltip>
<el-tooltip v-hasPermi="['file:resource:download']" content="下载" placement="top">
<el-tooltip v-hasPermi="['file:textbook:download']" content="下载" placement="top">
<el-button link type="primary" icon="Download" @click="handleDownload(scope.row)">下载</el-button>
</el-tooltip>
<el-tooltip v-hasPermi="['file:resource:move']" v-if="isTree" content="移动" placement="top">
<el-tooltip v-hasPermi="['file:textbook:move']" v-if="isTree" content="移动" placement="top">
<el-button link type="primary" icon="CopyDocument" @click="handleMove(scope.row)">移动</el-button>
</el-tooltip>
<el-tooltip v-hasPermi="['file:resource:copy']" v-if="isTree" content="复制" placement="top">
<el-tooltip v-hasPermi="['file:textbook:copy']" v-if="isTree" content="复制" placement="top">
<el-button link type="primary" icon="DocumentCopy" @click="handleCopy(scope.row)">复制</el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button v-hasPermi="['file:resource:remove']" link type="primary" icon="Delete"
<el-button v-hasPermi="['file:textbook:remove']" link type="primary" icon="Delete"
@click="handleDelete(scope.row)">删除</el-button>
</el-tooltip>
</template>
@ -181,9 +188,9 @@
</template>
<script setup name="Oss" lang="ts">
import { pageResource, awaitResourceList, awaitResourceCount, previewResource, delResource, addResource, reviewResource, copyResource, moveResource } from '@/api/system/oss';
import { pageTextbook, awaitTexbookList, previewTextbook, awaitTextbookCount, delTextbook, addTextbook, reviewTextbook, copyTextbook, moveTextbook } from '@/api/system/oss';
import FileMd5Upload from '@/components/FileMd5Upload/index.vue';
import { listCatalogResource } from "@/api/resource/catalogResource";
import { listCatalogTextbook } from "@/api/resource/catalogTextbook";
import { CatalogTextbookVO } from '@/api/resource/catalogTextbook/types';
import { Base64 } from 'js-base64'
import { useVolume } from "@/composables/useVolume";
@ -289,6 +296,7 @@ const data = reactive<PageData<any, any>>({
queryParams: {
pageNum: 1,
pageSize: 10,
type: 1,
ossId: '',
fileName: '',
originalName: '',
@ -296,6 +304,7 @@ const data = reactive<PageData<any, any>>({
createTime: '',
service: '',
catalogId: '',
ossType: 2
},
rules: {
file: [{ required: true, message: '文件不能为空', trigger: 'blur' }]
@ -304,14 +313,21 @@ const data = reactive<PageData<any, any>>({
const { queryParams, form, rules } = toRefs(data);
const handleTypeChange = () => {
getList()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
}
/** 查询OSS对象存储列表 */
const getList = async () => {
loading.value = true;
let response
if (isAudit.value) {
response = await awaitResourceList(queryParams.value);
response = await awaitTexbookList(queryParams.value);
} else {
response = await pageResource(queryParams.value);
response = await pageTextbook(queryParams.value);
}
ossList.value = response.rows;
total.value = response.total;
@ -333,8 +349,8 @@ function reset() {
function handleQuery() {
queryParams.value.pageNum = 1;
getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
}
/** 重置按钮操作 */
@ -354,33 +370,6 @@ const handleHeaderClass = ({ column }: any): any => {
column.order = column.multiOrder;
};
const handleOrderChange = (prop: string, order: string) => {
let orderByArr = queryParams.value.orderByColumn ? queryParams.value.orderByColumn.split(',') : [];
let isAscArr = queryParams.value.isAsc ? queryParams.value.isAsc.split(',') : [];
let propIndex = orderByArr.indexOf(prop);
if (propIndex !== -1) {
if (order) {
//
isAscArr[propIndex] = order;
} else {
//ordernull
isAscArr.splice(propIndex, 1); //
orderByArr.splice(propIndex, 1); //
}
} else {
//
orderByArr.push(prop);
isAscArr.push(order);
}
//
queryParams.value.orderByColumn = orderByArr.join(',');
queryParams.value.isAsc = isAscArr.join(',');
getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
}
};
/** 文件按钮操作 */
const handleFile = () => {
reset();
@ -388,6 +377,13 @@ const handleFile = () => {
dialog.visible = true;
dialog.title = '上传文件';
};
/** 图片按钮操作 */
const handleImage = () => {
reset();
type.value = 1;
dialog.visible = true;
dialog.title = '上传图片';
};
const fileName = ref('')
const handleFileName = (val) => {
@ -398,11 +394,11 @@ const handleFileName = (val) => {
const submitForm = async () => {
const ossId = form.value.file
const catalogId = currentNode.value.catalogId
await addResource({ ossId, catalogId, fileName: fileName.value })
await addTextbook({ ossId, catalogId, fileName: fileName.value, type: queryParams.value.type, ossType: 2 })
dialog.visible = false;
getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
};
@ -410,7 +406,7 @@ const submitMoveForm = () => {
treeMoveFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
treeMoveDialog.visible = false;
const res = await moveResource(treeMoveForm.value)
const res = await moveTextbook(treeMoveForm.value)
if (res.code === 200) {
proxy?.$modal.msgSuccess("移动成功")
await getList()
@ -427,7 +423,7 @@ const submitCopyForm = () => {
treeCopyFormRef.value?.validate(async (valid: boolean) => {
if (valid) {
treeCopyDialog.visible = false
const res = await copyResource(treeCopyForm.value)
const res = await copyTextbook(treeCopyForm.value)
if (res.code === 200) {
proxy?.$modal.msgSuccess("复制成功")
await getList()
@ -446,14 +442,14 @@ const handleAuditBtn = async (row: any, status: number) => {
const fileName = row?.fileName
const title = status === 1 ? `是否审核通过${fileName}?` : `是否审核不通过${fileName}?`
await proxy?.$modal.confirm(title).finally(() => loading.value = false)
await reviewResource({ id, status })
await reviewTextbook({ id, status })
proxy?.$modal.msgSuccess(status === 1 ? "审核通过" : '审核不通过');
await getList();
}
/** 下载按钮操作 */
const handleDownload = (row: any) => {
proxy?.download(`/file/resource/download/${row.id}`, {}, `${row.fileName}`);
proxy?.download(`/file/textbook/download/${row.id}`, {}, `${row.fileName}`);
};
const handleMove = async (row: any) => {
@ -473,7 +469,7 @@ const handleDelete = async (row?: any) => {
const delIds = row?.id || ids.value;
await proxy?.$modal.confirm('是否确认删除OSS对象存储编号为"' + delIds + '"的数据项?');
loading.value = true;
await delResource(delIds).finally(() => (loading.value = false));
await delTextbook(delIds).finally(() => (loading.value = false));
await getList();
proxy?.$modal.msgSuccess('删除成功');
};
@ -485,8 +481,8 @@ const handleAudit = () => {
isTree.value = false
getList()
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
}
@ -499,22 +495,22 @@ const handleNode = (node: any) => {
queryParams.value.catalogId = node.catalogId
getList()
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
}
const preViewUrl = import.meta.env.VITE_APP_PREVIEW
const handlePreview = async (row: any) => {
const fileRes = await previewResource(row.id)
const fileRes = await previewTextbook(row.id)
window.open(`${preViewUrl}?url=${encodeURIComponent(Base64.encode(fileRes.data))}`, '__blank')
}
const treeLoading = ref(false)
/** 查询目录-同步教材列表 */
const getlistCatalogResource = async () => {
const getListCatalogTextbook = async () => {
treeLoading.value = true;
const res = await listCatalogResource();
const res = await listCatalogTextbook();
const data = proxy?.handleTree<CatalogTextbookVO>(res.data, "catalogId", "parentId");
if (data) {
treeData.value = data;
@ -522,21 +518,18 @@ const getlistCatalogResource = async () => {
}
}
const auditNum = ref(0)
const awaitResourceCountData = async () => {
const res = await awaitResourceCount(queryParams.value)
const awaitTextbookCountData = async () => {
const res = await awaitTextbookCount(queryParams.value)
auditNum.value = res.data
}
onMounted(() => {
getlistCatalogResource()
getListCatalogTextbook()
getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData()
}
});
@ -568,6 +561,11 @@ onMounted(() => {
font-size: 18px;
}
.line {
border: 1px solid #ccc;
margin: 10px 0;
}
.btn-audit {
text-indent: 1em;
}

View File

@ -304,6 +304,7 @@ const data = reactive<PageData<any, any>>({
createTime: '',
service: '',
catalogId: '',
ossType: 1
},
rules: {
file: [{ required: true, message: '文件不能为空', trigger: 'blur' }]
@ -393,7 +394,7 @@ const handleFileName = (val) => {
const submitForm = async () => {
const ossId = form.value.file
const catalogId = currentNode.value.catalogId
await addTextbook({ ossId, catalogId, fileName: fileName.value, type: queryParams.value.type })
await addTextbook({ ossId, catalogId, fileName: fileName.value, type: queryParams.value.type, ossType: 1 })
dialog.visible = false;
getList();
if (auth.hasPermi('file:textbook:review')) {

View File

@ -127,7 +127,7 @@
<el-row>
<el-col :span="12">
<el-form-item label="管理员姓名" prop="nickName">
<el-select v-model="form.teacherId" @change="handleTeacherChange" placeholder="请选择管理员姓名"
<el-select v-model="form.teacherId" :disabled="form.userId ? true : false" @change="handleTeacherChange" placeholder="请选择管理员姓名"
style="width: 100%">
<el-option v-for="item in teacherOption" :key="item.teacherId" :label="item.teacherName"
:value="item.teacherId" />