提交拖动代码

This commit is contained in:
jiangzhe 2024-07-12 14:42:22 +08:00
parent cb790f86d0
commit 985ec3d51a
8 changed files with 249 additions and 189 deletions

View File

@ -69,3 +69,12 @@ export const delCatalogTextbook = (catalogId: string | number | Array<string | n
method: 'delete' method: 'delete'
}); });
}; };
export const dragTextbook = (data: any) => {
return request({
url: '/catalog/textbook/drag',
method: 'post',
data: data
});
};

View File

@ -122,6 +122,10 @@ export interface TeacherForm extends BaseEntity {
*/ */
birthday?: string; birthday?: string;
postCode?: string;
postIds?: []
} }
export interface TeacherQuery extends PageQuery { export interface TeacherQuery extends PageQuery {

View File

@ -97,7 +97,7 @@
<el-form-item label="年级/班级" prop="deptId"> <el-form-item label="年级/班级" prop="deptId">
<el-tree-select v-model="form.deptId" :data="deptOptions" clearable <el-tree-select v-model="form.deptId" :data="deptOptions" clearable
:props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="请选择年级/班级" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="请选择年级/班级"
check-strictly /> check-strictly @change="handleDeptChange" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -172,6 +172,15 @@
<el-input v-model="form.email" placeholder="请输入电子邮箱" /> <el-input v-model="form.email" placeholder="请输入电子邮箱" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12">
<el-form-item label="岗位">
<el-select v-model="form.postIds" multiple placeholder="请选择">
<el-option v-for="item in postOptions" :key="item.postId" :label="item.postName" :value="item.postId"
:disabled="item.status == '1'"></el-option>
</el-select>
</el-form-item>
</el-col>
</el-row> </el-row>
</el-form> </el-form>
<template #footer> <template #footer>
@ -217,7 +226,9 @@ import { pageTeacher, getTeacher, delTeacher, addTeacher, updateTeacher } from '
import { TeacherVO, TeacherQuery, TeacherForm } from '@/api/teacher/types'; import { TeacherVO, TeacherQuery, TeacherForm } from '@/api/teacher/types';
import { deptTreeSelect } from '@/api/system/user'; import { deptTreeSelect } from '@/api/system/user';
import { optionselect } from '@/api/system/post';
import { DeptVO } from '@/api/system/dept/types'; import { DeptVO } from '@/api/system/dept/types';
import { PostVO } from '@/api/system/post/types';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@ -310,6 +321,13 @@ const data = reactive<PageData<TeacherForm, TeacherQuery>>({
const { queryParams, form, rules } = toRefs(data); const { queryParams, form, rules } = toRefs(data);
const postOptions = ref<PostVO[]>([]);
async function handleDeptChange(value: number | string) {
const response = await optionselect(value);
postOptions.value = response.data;
form.value.postIds = [];
}
/** 查询部门下拉树结构 */ /** 查询部门下拉树结构 */
const getTreeSelect = async () => { const getTreeSelect = async () => {
const res = await deptTreeSelect(); const res = await deptTreeSelect();

View File

@ -17,41 +17,29 @@
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button> <el-button type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :search="false"></right-toolbar>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
</template> </template>
<div class="tree-container-scroll"> <div class="tree-container-scroll">
<el-scrollbar> <el-scrollbar>
<el-table ref="catalogPersonTableRef" @row-click="handleRowClick" v-loading="loading"
:data="catalogPersonList" row-key="catalogId" :default-expand-all="isExpandAll" <el-tree ref="treeRef" draggable v-loading="loading" :data="catalogPersonList" :props="defaultProps"
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> default-expand-all :expand-on-click-node="false" node-key="catalogId" @node-click="handleNodeClick"
<el-table-column label="分类名称" align="left" prop="catalogName"> @node-drop="handleDrop">
<template #default="scope"> <template #default="{ node, data }">
<el-popover placement="top-start" title="分类名称" :width="200" trigger="hover" <div class="custom-tree-node">
:content="scope.row.catalogName"> <div class="text-ellipsis">{{ node.label }} </div>
<template #reference>
<span class="text-ellipsis">{{ scope.row.catalogName }}</span> <div>
<el-button link type="primary" icon="Edit" @click="handleUpdate(data)" />
<el-button link type="primary" icon="Plus" @click="handleAdd(data)" />
<el-button link type="primary" icon="Delete" @click="handleDelete(data)" />
</div>
</div>
</template> </template>
</el-popover> </el-tree>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" />
</el-tooltip>
<el-tooltip content="新增" placement="top">
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" />
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" />
</el-tooltip>
</template>
</el-table-column>
</el-table>
</el-scrollbar> </el-scrollbar>
</div> </div>
</el-card> </el-card>
@ -103,6 +91,11 @@ type CatalogPersonOption = {
children?: CatalogPersonOption[]; children?: CatalogPersonOption[];
} }
const defaultProps = {
children: 'children',
label: 'catalogName',
}
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { volume } = useVolume(2); const { volume } = useVolume(2);
@ -290,10 +283,18 @@ onMounted(() => {
}); });
const fileListRef = ref() const fileListRef = ref()
const handleRowClick = (row: any) => { const handleNodeClick = (row: any) => {
fileListRef.value.handleNode(row) fileListRef.value.handleNode(row)
} }
const handleDrop = (draggingNode, dropNode, dropType) => {
//
console.log('draggingNode:', draggingNode, 'dropNode:', dropNode, 'dropType:', dropType)
const oldData = draggingNode.data
const newData = dropNode.data
}
const handleChange = () => { const handleChange = () => {
fileListRef.value.handleTypeChange(queryParams.value.type) fileListRef.value.handleTypeChange(queryParams.value.type)
} }
@ -338,6 +339,15 @@ const handleChange = () => {
.active { .active {
background-color: #F5F7FA; background-color: #F5F7FA;
} }
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
} }
:deep(.docx-wrapper) { :deep(.docx-wrapper) {

View File

@ -1,22 +1,5 @@
<template> <template>
<div class="p-2"> <div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter"
:leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="专题名称" prop="catalogName">
<el-input v-model="queryParams.catalogName" placeholder="请输入专题名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col :span="12">
<el-card shadow="never"> <el-card shadow="never">
@ -26,42 +9,32 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd()" <el-button type="primary" plain icon="Plus" @click="handleAdd()"
v-hasPermi="['catalog:resource:add']">新增</el-button> v-hasPermi="['catalog:resource:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :search="false"></right-toolbar>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
</template> </template>
<el-table ref="catalogResourceTableRef" @row-click="handleNodeClick" v-loading="loading"
:data="catalogResourceList" row-key="catalogId" :default-expand-all="isExpandAll" <el-scrollbar>
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> <el-tree ref="treeRef" draggable v-loading="loading" :data="catalogResourceList" :props="defaultProps"
<el-table-column label="专题名称" align="left" prop="catalogName"> default-expand-all :expand-on-click-node="false" node-key="catalogId" @node-click="handleNodeClick"
<template #default="scope"> @node-drop="handleDrop">
<el-popover placement="top-start" title="专题名称" :width="200" trigger="hover" <template #default="{ node, data }">
:content="scope.row.catalogName"> <div class="custom-tree-node">
<template #reference> <div class="text-ellipsis">{{ node.label }} </div>
<span class="text-ellipsis">{{ scope.row.catalogName }}</span>
</template> <div>
</el-popover> <el-button link type="primary" icon="Edit" @click="handleUpdate(data)"
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['catalog:resource:edit']" /> v-hasPermi="['catalog:resource:edit']" />
</el-tooltip> <el-button link type="primary" icon="Plus" @click="handleAdd(data)"
<el-tooltip content="新增" placement="top">
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)"
v-hasPermi="['catalog:resource:add']" /> v-hasPermi="['catalog:resource:add']" />
</el-tooltip> <el-button link type="primary" icon="Delete" @click="handleDelete(data)"
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['catalog:resource:remove']" /> v-hasPermi="['catalog:resource:remove']" />
</el-tooltip> </div>
</div>
</template> </template>
</el-table-column> </el-tree>
</el-table> </el-scrollbar>
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
@ -125,6 +98,11 @@ type CatalogResourceOption = {
children?: CatalogResourceOption[]; children?: CatalogResourceOption[];
} }
const defaultProps = {
children: 'children',
label: 'catalogName',
}
const { proxy } = getCurrentInstance() as ComponentInternalInstance;; const { proxy } = getCurrentInstance() as ComponentInternalInstance;;
@ -316,12 +294,31 @@ const getTable = async () => {
loadingTable.value = false; loadingTable.value = false;
} }
const handleNodeClick = (row: any) => { const handleNodeClick = (data: any) => {
queryTableParams.value.catalogId = row.catalogId queryTableParams.value.catalogId = data.catalogId
getTable() getTable()
} }
const handleDrop = (draggingNode, dropNode, dropType) => {
//
console.log('draggingNode:', draggingNode, 'dropNode:', dropNode, 'dropType:', dropType)
const oldData = draggingNode.data
const newData = dropNode.data
}
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
</script> </script>
<style scoped lang="scss">
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
</style>

View File

@ -1,22 +1,5 @@
<template> <template>
<div class="p-2"> <div class="p-2">
<transition :enter-active-class="proxy?.animate.searchAnimate.enter"
:leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
<el-form-item label="教材名称" prop="catalogName">
<el-input v-model="queryParams.catalogName" placeholder="请输入教材名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item>
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</transition>
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="14"> <el-col :span="14">
<el-card shadow="never"> <el-card shadow="never">
@ -26,53 +9,40 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd()" <el-button type="primary" plain icon="Plus" @click="handleAdd()"
v-hasPermi="['catalog:textbook:add']">新增</el-button> v-hasPermi="['catalog:textbook:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :search="false"></right-toolbar>
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
</el-col>
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
</template> </template>
<el-table ref="catalogTextbookTableRef" @row-click="handleNodeClick" v-loading="loading"
:data="catalogTextbookList" row-key="catalogId" :default-expand-all="isExpandAll" <el-scrollbar>
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"> <el-tree ref="treeRef" draggable v-loading="loading" :data="catalogTextbookList" :props="defaultProps"
<el-table-column label="教材名称" align="left" prop="catalogName"> default-expand-all :expand-on-click-node="false" node-key="catalogId" @node-click="handleNodeClick"
<template #default="scope"> @node-drop="handleDrop">
<el-popover placement="top-start" title="教材名称" :width="200" trigger="hover" <template #default="{ node, data }">
:content="scope.row.catalogName"> <div class="custom-tree-node">
<template #reference> <div class="text-ellipsis">{{ node.label }} </div>
<span class="text-ellipsis">{{ scope.row.catalogName }}</span>
</template> <div>
</el-popover> <span style="margin-right:20px;">
</template> <el-tag v-if="data.type === 1" type="success">主目录</el-tag>
</el-table-column> <el-tag v-if="data.type === 2" type="success">学段</el-tag>
<el-table-column label="目录类型" align="center" prop="type" width="100"> <el-tag v-if="data.type === 3" type="success">年级</el-tag>
<template #default="scope"> <el-tag v-if="data.type === 4" type="success">学科</el-tag>
<el-tag v-if="scope.row.type === 1" type="success">主目录</el-tag> <el-tag v-if="data.type === 5" type="success">版本</el-tag>
<el-tag v-if="scope.row.type === 2" type="success">学段</el-tag> <el-tag v-if="data.type === 6" type="success">教材</el-tag>
<el-tag v-if="scope.row.type === 3" type="success">年级</el-tag> <el-tag v-if="data.type === 7" type="success">目录</el-tag>
<el-tag v-if="scope.row.type === 4" type="success">学科</el-tag> </span>
<el-tag v-if="scope.row.type === 5" type="success">版本</el-tag> <el-button link type="primary" icon="Edit" @click="handleUpdate(data)"
<el-tag v-if="scope.row.type === 6" type="success">教材</el-tag>
<el-tag v-if="scope.row.type === 7" type="success">目录</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120">
<template #default="scope">
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
v-hasPermi="['catalog:textbook:edit']" /> v-hasPermi="['catalog:textbook:edit']" />
</el-tooltip> <el-button link type="primary" icon="Plus" @click="handleAdd(data)"
<el-tooltip content="新增" placement="top">
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)"
v-hasPermi="['catalog:textbook:add']" /> v-hasPermi="['catalog:textbook:add']" />
</el-tooltip> <el-button link type="primary" icon="Delete" @click="handleDelete(data)"
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
v-hasPermi="['catalog:textbook:remove']" /> v-hasPermi="['catalog:textbook:remove']" />
</el-tooltip> </div>
</div>
</template> </template>
</el-table-column> </el-tree>
</el-table> </el-scrollbar>
</el-card> </el-card>
</el-col> </el-col>
<el-col :span="10"> <el-col :span="10">
@ -140,7 +110,7 @@
</template> </template>
<script setup name="CatalogTextbook" lang="ts"> <script setup name="CatalogTextbook" lang="ts">
import { listCatalogTextbook, pageCatalogTextbook, getCatalogTextbook, delCatalogTextbook, addCatalogTextbook, updateCatalogTextbook } from "@/api/resource/catalogTextbook"; import { listCatalogTextbook, pageCatalogTextbook, getCatalogTextbook, delCatalogTextbook, addCatalogTextbook, updateCatalogTextbook, dragTextbook } from "@/api/resource/catalogTextbook";
import { CatalogTextbookVO, CatalogTextbookQuery, CatalogTextbookForm } from '@/api/resource/catalogTextbook/types'; import { CatalogTextbookVO, CatalogTextbookQuery, CatalogTextbookForm } from '@/api/resource/catalogTextbook/types';
type CatalogTextbookOption = { type CatalogTextbookOption = {
@ -162,6 +132,11 @@ const queryFormRef = ref<ElFormInstance>();
const catalogTextbookFormRef = ref<ElFormInstance>(); const catalogTextbookFormRef = ref<ElFormInstance>();
const catalogTextbookTableRef = ref<ElTableInstance>() const catalogTextbookTableRef = ref<ElTableInstance>()
const defaultProps = {
children: 'children',
label: 'catalogName',
}
const typeOptions = [ const typeOptions = [
{ {
value: 2, value: 2,
@ -290,20 +265,6 @@ const handleAdd = (row?: CatalogTextbookVO) => {
dialog.title = "添加目录-同步教材"; dialog.title = "添加目录-同步教材";
} }
/** 展开/折叠操作 */
const handleToggleExpandAll = () => {
isExpandAll.value = !isExpandAll.value;
toggleExpandAll(catalogTextbookList.value, isExpandAll.value)
}
/** 展开/折叠操作 */
const toggleExpandAll = (data: CatalogTextbookVO[], status: boolean) => {
data.forEach((item) => {
catalogTextbookTableRef.value?.toggleRowExpansion(item, status)
if (item.children && item.children.length > 0) toggleExpandAll(item.children, status)
})
}
/** 修改按钮操作 */ /** 修改按钮操作 */
const handleUpdate = async (row: CatalogTextbookVO) => { const handleUpdate = async (row: CatalogTextbookVO) => {
reset(); reset();
@ -369,12 +330,43 @@ const getTable = async () => {
loadingTable.value = false; loadingTable.value = false;
} }
const handleNodeClick = (row: any) => { const handleNodeClick = (node: any) => {
queryTableParams.value.catalogId = row.catalogId console.log(node);
queryTableParams.value.catalogId = node.catalogId
getTable() getTable()
} }
const handleDrop = async (draggingNode, dropNode, dropType) => {
loading.value= true
//
const oldData = draggingNode.data
const newData = dropNode.data
try {
const res = await dragTextbook({
oldCatalog: oldData.catalogId,
newCatalog: newData.catalogId,
position: dropType
})
proxy?.$modal.msgSuccess(res.msg);
} finally {
getList()
loading.value = false
}
}
onMounted(() => { onMounted(() => {
getList(); getList();
}); });
</script> </script>
<style scoped lang="scss">
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
</style>

View File

@ -183,11 +183,11 @@
<script setup name="Oss" lang="ts"> <script setup name="Oss" lang="ts">
import { pageResource, awaitResourceList, awaitResourceCount, previewResource, delResource, addResource, reviewResource, copyResource, moveResource } from '@/api/system/oss'; import { pageResource, awaitResourceList, awaitResourceCount, previewResource, delResource, addResource, reviewResource, copyResource, moveResource } from '@/api/system/oss';
import FileMd5Upload from '@/components/FileMd5Upload/index.vue'; import FileMd5Upload from '@/components/FileMd5Upload/index.vue';
import { OssForm, OssQuery, OssVO } from '@/api/system/oss/types';
import { listCatalogResource } from "@/api/resource/catalogResource"; import { listCatalogResource } from "@/api/resource/catalogResource";
import { CatalogTextbookVO } from '@/api/resource/catalogTextbook/types'; import { CatalogTextbookVO } from '@/api/resource/catalogTextbook/types';
import { Base64 } from 'js-base64' import { Base64 } from 'js-base64'
import { useVolume } from "@/composables/useVolume"; import { useVolume } from "@/composables/useVolume";
import auth from '@/plugins/auth';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { volume } = useVolume(1); const { volume } = useVolume(1);
@ -236,7 +236,7 @@ const isUpload = ref(false)
const currentNode = ref<any>({}) const currentNode = ref<any>({})
const treeData = ref<CatalogTextbookVO[]>([]) const treeData = ref<CatalogTextbookVO[]>([])
const ossList = ref<OssVO[]>([]); const ossList = ref<any[]>([]);
const showTable = ref(true); const showTable = ref(true);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
@ -283,7 +283,7 @@ const queryFormRef = ref<ElFormInstance>();
const initFormData = { const initFormData = {
file: undefined file: undefined
}; };
const data = reactive<PageData<OssForm, OssQuery>>({ const data = reactive<PageData<any, any>>({
form: { ...initFormData }, form: { ...initFormData },
// //
queryParams: { queryParams: {
@ -333,8 +333,10 @@ function reset() {
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
} }
}
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
showTable.value = false; showTable.value = false;
@ -342,7 +344,7 @@ function resetQuery() {
handleQuery(); handleQuery();
} }
/** 选择条数 */ /** 选择条数 */
function handleSelectionChange(selection: OssVO[]) { function handleSelectionChange(selection: any[]) {
ids.value = selection.map((item) => item.ossId); ids.value = selection.map((item) => item.ossId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
@ -374,7 +376,9 @@ const handleOrderChange = (prop: string, order: string) => {
queryParams.value.orderByColumn = orderByArr.join(','); queryParams.value.orderByColumn = orderByArr.join(',');
queryParams.value.isAsc = isAscArr.join(','); queryParams.value.isAsc = isAscArr.join(',');
getList(); getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
}
}; };
/** 文件按钮操作 */ /** 文件按钮操作 */
@ -397,7 +401,9 @@ const submitForm = async () => {
await addResource({ ossId, catalogId, fileName: fileName.value }) await addResource({ ossId, catalogId, fileName: fileName.value })
dialog.visible = false; dialog.visible = false;
getList(); getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
}
}; };
const submitMoveForm = () => { const submitMoveForm = () => {
@ -479,8 +485,10 @@ const handleAudit = () => {
isTree.value = false isTree.value = false
getList() getList()
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
} }
}
const handleNode = (node: any) => { const handleNode = (node: any) => {
console.log(node) console.log(node)
@ -491,8 +499,10 @@ const handleNode = (node: any) => {
queryParams.value.catalogId = node.catalogId queryParams.value.catalogId = node.catalogId
getList() getList()
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
} }
}
const preViewUrl = import.meta.env.VITE_APP_PREVIEW const preViewUrl = import.meta.env.VITE_APP_PREVIEW
const handlePreview = async (row: any) => { const handlePreview = async (row: any) => {
@ -512,16 +522,23 @@ const getlistCatalogResource = async () => {
} }
} }
const auditNum = ref(0) const auditNum = ref(0)
const awaitResourceCountData = async () => { const awaitResourceCountData = async () => {
const res = await awaitResourceCount(queryParams.value) const res = await awaitResourceCount(queryParams.value)
auditNum.value = res.data auditNum.value = res.data
} }
onMounted(() => { onMounted(() => {
getlistCatalogResource() getlistCatalogResource()
getList(); getList();
if (auth.hasPermi('file:resource:review')) {
awaitResourceCountData() awaitResourceCountData()
}
}); });
</script> </script>

View File

@ -13,7 +13,6 @@
<el-button type="" text="plain">全部文件</el-button> <el-button type="" text="plain">全部文件</el-button>
<br> <br>
<el-badge v-if="auditNum > 0" :value="auditNum" style="margin-left:10px;margin-top: 10px;"> <el-badge v-if="auditNum > 0" :value="auditNum" style="margin-left:10px;margin-top: 10px;">
<el-button v-hasPermi="['file:textbook: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> text="plain" @click="handleAudit">待审核</el-button>
@ -24,7 +23,7 @@
<div class="tree-container-scroll"> <div class="tree-container-scroll">
<el-scrollbar> <el-scrollbar>
<el-tree ref="treeRef" v-loading="treeLoading" :data="treeData" :props="defaultProps" default-expand-all <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> </el-scrollbar>
</div> </div>
</div> </div>
@ -191,11 +190,11 @@
<script setup name="Oss" lang="ts"> <script setup name="Oss" lang="ts">
import { pageTextbook, awaitTexbookList, previewTextbook, awaitTextbookCount, delTextbook, addTextbook, reviewTextbook, copyTextbook, moveTextbook } 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 FileMd5Upload from '@/components/FileMd5Upload/index.vue';
import { OssForm, OssQuery, OssVO } from '@/api/system/oss/types';
import { listCatalogTextbook } from "@/api/resource/catalogTextbook"; import { listCatalogTextbook } from "@/api/resource/catalogTextbook";
import { CatalogTextbookVO } from '@/api/resource/catalogTextbook/types'; import { CatalogTextbookVO } from '@/api/resource/catalogTextbook/types';
import { Base64 } from 'js-base64' import { Base64 } from 'js-base64'
import { useVolume } from "@/composables/useVolume"; import { useVolume } from "@/composables/useVolume";
import auth from '@/plugins/auth';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { volume } = useVolume(1); const { volume } = useVolume(1);
@ -244,7 +243,7 @@ const isUpload = ref(false)
const currentNode = ref<any>({}) const currentNode = ref<any>({})
const treeData = ref<CatalogTextbookVO[]>([]) const treeData = ref<CatalogTextbookVO[]>([])
const ossList = ref<OssVO[]>([]); const ossList = ref<any[]>([]);
const showTable = ref(true); const showTable = ref(true);
const buttonLoading = ref(false); const buttonLoading = ref(false);
const loading = ref(true); const loading = ref(true);
@ -291,7 +290,7 @@ const queryFormRef = ref<ElFormInstance>();
const initFormData = { const initFormData = {
file: undefined file: undefined
}; };
const data = reactive<PageData<OssForm, OssQuery>>({ const data = reactive<PageData<any, any>>({
form: { ...initFormData }, form: { ...initFormData },
// //
queryParams: { queryParams: {
@ -315,8 +314,10 @@ const { queryParams, form, rules } = toRefs(data);
const handleTypeChange = () => { const handleTypeChange = () => {
getList() getList()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
} }
}
/** 查询OSS对象存储列表 */ /** 查询OSS对象存储列表 */
const getList = async () => { const getList = async () => {
@ -347,8 +348,10 @@ function reset() {
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
getList(); getList();
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
} }
}
/** 重置按钮操作 */ /** 重置按钮操作 */
function resetQuery() { function resetQuery() {
showTable.value = false; showTable.value = false;
@ -356,7 +359,7 @@ function resetQuery() {
handleQuery(); handleQuery();
} }
/** 选择条数 */ /** 选择条数 */
function handleSelectionChange(selection: OssVO[]) { function handleSelectionChange(selection: any[]) {
ids.value = selection.map((item) => item.ossId); ids.value = selection.map((item) => item.ossId);
single.value = selection.length != 1; single.value = selection.length != 1;
multiple.value = !selection.length; multiple.value = !selection.length;
@ -393,7 +396,9 @@ const submitForm = async () => {
await addTextbook({ ossId, catalogId, fileName: fileName.value, type: queryParams.value.type }) await addTextbook({ ossId, catalogId, fileName: fileName.value, type: queryParams.value.type })
dialog.visible = false; dialog.visible = false;
getList(); getList();
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
}
}; };
const submitMoveForm = () => { const submitMoveForm = () => {
@ -475,8 +480,10 @@ const handleAudit = () => {
isTree.value = false isTree.value = false
getList() getList()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
} }
}
const handleNode = (node: any) => { const handleNode = (node: any) => {
console.log(node) console.log(node)
@ -487,8 +494,10 @@ const handleNode = (node: any) => {
queryParams.value.catalogId = node.catalogId queryParams.value.catalogId = node.catalogId
getList() getList()
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
} }
}
const preViewUrl = import.meta.env.VITE_APP_PREVIEW const preViewUrl = import.meta.env.VITE_APP_PREVIEW
const handlePreview = async (row: any) => { const handlePreview = async (row: any) => {
@ -517,7 +526,11 @@ const awaitTextbookCountData = async () => {
onMounted(() => { onMounted(() => {
getListCatalogTextbook() getListCatalogTextbook()
getList(); getList();
if (auth.hasPermi('file:textbook:review')) {
awaitTextbookCountData() awaitTextbookCountData()
}
}); });
</script> </script>