zhangsq 8 сар өмнө
parent
commit
c628d97258

+ 8 - 0
src/api/resourceAudit.js

@@ -46,5 +46,13 @@ export default {
 	//获取课程下拉
 	courseAllList(data = {}) {
 		return request('courseinfo/allList', data, 'get')
+	},
+	//查询资源表单最后一次提交信息
+	recentlyRecord(data = {}) {
+		return request('courseauditrecord/recentlyRecord', data, 'get')
+	},
+	//资源上传删除
+	deletefile(data = {}) {
+		return request('resourceFile/deletefile', data, 'post')
 	}
 }

+ 1 - 2
src/views/myResource/file/box/uploadFile/Box.vue

@@ -126,8 +126,7 @@
 	})
 
 	const options = ref({
-		// target: `${proxy.$RESOURCE_CONFIG.baseContext}/filetransfer/uploadfile`,
-		target: `${proxy.$RESOURCE_CONFIG.baseContext}/resourceFile/uploadfile`,
+		target: `${proxy.$RESOURCE_CONFIG.baseContext}/filetransfer/uploadfile`,
 		chunkSize: 1024 * 1024,
 		fileParameterName: 'file',
 		maxChunkRetries: 3,

+ 587 - 0
src/views/myResources/UploadModal.vue

@@ -0,0 +1,587 @@
+<template>
+	<div class="upload-area" @click="handleUpload">
+		<a-icon type="cloud-upload" style="font-size: 60px; color: #3ca9f5" />
+		<p>点击上传</p>
+		<p>按住Ctrl可同时多选,支持上传PPT/word/excel/pdf/mp4/zip/rar,单个文件不能超过2G</p>
+	</div>
+	<!-- 上传组件 -->
+	<uploader
+		class="uploader-app"
+		ref="uploaderRef"
+		:options="options"
+		:autoStart="false"
+		:fileStatusText="fileStatusText"
+		@files-added="handleFilesAdded"
+		@file-success="handleFileSuccess"
+		@file-error="handleFileError"
+		@dragleave="hideUploadMask"
+	>
+		<uploader-unsupport></uploader-unsupport>
+		<!-- 选择按钮 在这里隐藏 -->
+		<uploader-btn class="select-file-btn" :attrs="attrs" ref="uploadBtn"> 选择文件 </uploader-btn>
+		<uploader-btn class="select-file-btn" :attrs="attrs" :directory="true" ref="uploadDirBtn"> 选择目录 </uploader-btn>
+
+		<!-- 拖拽上传 -->
+		<uploader-drop class="drop-box" id="dropBox" @paste="handlePaste" v-show="dropBoxShow">
+			<div class="paste-img-wrapper" v-show="pasteImg.src">
+				<div class="paste-name">{{ pasteImg.name }}</div>
+				<img class="paste-img" :src="pasteImg.src" :alt="pasteImg.name" v-if="pasteImg.src" />
+			</div>
+			<span class="text" v-show="!pasteImg.src"> 截图粘贴或将文件拖拽至此区域上传 </span>
+			<UploadOutlined class="upload-icon" v-show="pasteImg.src" @click="handleUploadPasteImg" />
+			<DeleteOutlined class="delete-icon" v-show="pasteImg.src" @click="handleDeletePasteImg" />
+			<CloseCircleOutlined class="close-icon" @click="dropBoxShow = false" />
+		</uploader-drop>
+
+		<!-- 上传列表 -->
+		<uploader-list v-show="true">
+			<template #default="props">
+				<div class="file-panel">
+					<div class="file-title">
+						<span class="title-span">
+							上传列表 <span class="count">({{ props.fileList.length }})</span>
+						</span>
+					</div>
+
+					<transition name="collapse">
+						<ul class="file-list">
+							<li
+								v-for="file in props.fileList"
+								:key="file.id"
+								class="file-item"
+								:class="{ 'custom-status-item': file.statusStr !== '' }"
+							>
+								<uploader-file ref="fileItem" :file="file" :list="true" />
+								<span class="custom-status">{{ file.statusStr }}</span>
+							</li>
+							<div class="no-file" v-if="!props.fileList.length"><FileExclamationOutlined /> 暂无待上传文件</div>
+						</ul>
+					</transition>
+				</div>
+			</template>
+		</uploader-list>
+	</uploader>
+</template>
+
+<script setup>
+	import { ref, reactive, computed, nextTick, getCurrentInstance } from 'vue'
+	import { message } from 'ant-design-vue'
+	import { useMyResourceStore } from '@/store/myResource'
+	import SparkMD5 from 'spark-md5'
+	import tool from '@/utils/tool'
+	const props = defineProps({
+		visible: {
+			type: Boolean,
+			default: true
+		}
+	})
+
+	const emit = defineEmits(['update:visible', 'success'])
+
+	const { proxy } = getCurrentInstance()
+	const store = useMyResourceStore()
+
+	// refs
+	const formRef = ref(null)
+	const uploaderRef = ref(null)
+	const uploadBtn = ref(null)
+	const uploadDirBtn = ref(null)
+	const fileItem = ref(null)
+
+	// 表单数据
+	const formState = reactive({
+		title: '',
+		description: '',
+		category: undefined,
+		fileIds: []
+	})
+
+	const rules = {
+		title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
+		category: [{ required: true, message: '请选择分类', trigger: 'change' }]
+	}
+
+	// 上传相关数据
+	const options = ref({
+		target: `${proxy.$RESOURCE_CONFIG.baseContext}/resourceFile/uploadfile`,
+		chunkSize: 1024 * 1024,
+		fileParameterName: 'file',
+		maxChunkRetries: 3,
+		testChunks: true,
+		checkChunkUploadedByResponse: (chunk, message) => {
+			let objMessage = JSON.parse(message)
+			if (objMessage.success) {
+				let data = objMessage.data
+				if (data.skipUpload) {
+					return true
+				}
+				return (data.uploaded || []).indexOf(chunk.offset + 1) >= 0
+			} else {
+				return true
+			}
+		},
+		headers: {
+			token: tool.data.get('TOKEN')
+		},
+		query: () => {}
+	})
+
+	const fileStatusText = ref({
+		success: '上传成功',
+		error: 'error',
+		uploading: '上传中',
+		paused: '暂停中',
+		waiting: '等待中'
+	})
+
+	const attrs = ref({
+		accept: '*'
+	})
+
+	const dropBoxShow = ref(false)
+	const pasteImg = ref({
+		src: '',
+		name: ''
+	})
+	const pasteImgObj = ref(null)
+	const filesLength = ref(0)
+	const uploadStatus = ref({})
+	const submitting = ref(false)
+	const canClose = ref(true)
+
+	// 计算属性
+	const uploaderInstance = computed(() => {
+		return uploaderRef.value?.uploader
+	})
+
+	const remainderStorageValue = computed(() => {
+		return store.remainderStorageValue
+	})
+
+	// 方法
+	const hideUploadMask = (e) => {
+		e.stopPropagation()
+		e.preventDefault()
+		dropBoxShow.value = false
+	}
+
+	const handleUpload = () => {
+		if (uploadBtn.value?.$el) {
+			uploadBtn.value.$el.click()
+		}
+	}
+
+	const handleUploadDir = () => {
+		if (uploadDirBtn.value?.$el) {
+			uploadDirBtn.value.$el.click()
+		}
+	}
+
+	const handlePasteUpload = () => {
+		pasteImg.value.src = ''
+		pasteImg.value.name = ''
+		pasteImgObj.value = null
+		dropBoxShow.value = true
+	}
+	const handlePaste = (event) => {
+		let pasteItems = (event.clipboardData || window.clipboardData).items
+		if (pasteItems && pasteItems.length) {
+			let imgObj = pasteItems[0].getAsFile()
+			pasteImgObj.value =
+				imgObj !== null
+					? new File([imgObj], `qiwenshare_${new Date().valueOf()}.${imgObj.name.split('.')[1]}`, { type: imgObj.type })
+					: null
+		} else {
+			message.error('当前浏览器不支持')
+			return false
+		}
+
+		if (!pasteImgObj.value) {
+			message.error('粘贴内容非图片')
+			return false
+		}
+
+		pasteImg.value.name = pasteImgObj.value.name
+
+		let reader = new FileReader()
+		reader.onload = (event) => {
+			pasteImg.value.src = event.target.result
+		}
+		reader.readAsDataURL(pasteImgObj.value)
+	}
+
+	const handleUploadPasteImg = () => {
+		uploaderInstance.value.addFile(pasteImgObj.value)
+	}
+
+	const handleDeletePasteImg = () => {
+		pasteImg.value.src = ''
+		pasteImg.value.name = ''
+		pasteImgObj.value = null
+	}
+
+	const handleFilesAdded = (filesSource) => {
+		const filesTotalSize = filesSource
+			.map((item) => item.size)
+			.reduce((pre, next) => {
+				return pre + next
+			}, 0)
+
+		if (remainderStorageValue.value < filesTotalSize) {
+			// 批量选择的文件超出剩余存储空间
+			message.warning(`剩余存储空间不足,请重新选择${filesSource.length > 1 ? '批量' : ''}文件`)
+			filesSource.ignored = true // 本次选择的文件过滤掉
+		} else {
+			// 批量或单个选择的文件未超出剩余存储空间,正常上传
+			filesLength.value += filesSource.length
+			filesSource.forEach((file) => {
+				dropBoxShow.value = false
+				computeMD5(file)
+			})
+		}
+	}
+
+	const handleFileSuccess = (rootFile, file, response) => {
+		if (response === '') {
+			uploadStatus.value[file.id] = '上传失败'
+			return
+		}
+
+		const result = JSON.parse(response)
+		if (result.success) {
+			file.statusStr = ''
+			// 将上传成功的文件ID添加到表单数据中
+			formState.fileIds.push(result.data.userFileId)
+			emit('success', formState.fileIds)
+		} else {
+			message.error(result.msg)
+			uploadStatus.value[file.id] = '上传失败'
+		}
+		filesLength.value--
+		// 所有文件上传完成后,允许关闭弹窗
+		canClose.value = filesLength.value === 0
+		console.log(formState.fileIds, response, result, 'formState.fileIdsformState.fileIdsformState.fileIds')
+	}
+
+	const handleFileError = (rootFile, file, response) => {
+		message.error(response)
+		filesLength.value--
+		canClose.value = filesLength.value === 0
+	}
+
+	const computeMD5 = (file) => {
+		let fileReader = new FileReader()
+		let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice
+		let currentChunk = 0
+		const chunkSize = 1024 * 1024
+		let chunks = Math.ceil(file.size / chunkSize)
+		let spark = new SparkMD5.ArrayBuffer()
+
+		file.statusStr = '计算MD5'
+		file.pause()
+
+		const loadNext = () => {
+			let start = currentChunk * chunkSize
+			let end = start + chunkSize >= file.size ? file.size : start + chunkSize
+			fileReader.readAsArrayBuffer(blobSlice.call(file.file, start, end))
+		}
+
+		fileReader.onload = (e) => {
+			spark.append(e.target.result)
+			if (currentChunk < chunks) {
+				currentChunk++
+				loadNext()
+				file.statusStr = `校验MD5 ${((currentChunk / chunks) * 100).toFixed(0)}%`
+			} else {
+				let md5 = spark.end()
+				calculateFileMD5End(md5, file)
+			}
+		}
+
+		fileReader.onerror = () => {
+			message.error({
+				content: `文件${file.name}读取出错,请检查该文件`,
+				duration: 2
+			})
+			file.cancel()
+			filesLength.value--
+			canClose.value = filesLength.value === 0
+		}
+
+		loadNext()
+	}
+	const uploadFileParams = computed(() => {
+		return {
+			filePath: '/',
+			isDir: 0,
+			funcType: 0
+		}
+	})
+	const calculateFileMD5End = (md5, file) => {
+		Object.assign(uploaderInstance.value.opts, {
+			query: uploadFileParams.value
+		})
+		file.uniqueIdentifier = md5
+		file.resume()
+		file.statusStr = ''
+		// 文件开始上传时,禁止关闭弹窗
+		canClose.value = false
+	}
+
+	const handleCancel = () => {
+		if (!canClose.value) {
+			message.warning('文件正在上传中,请等待上传完成后再关闭')
+			return
+		}
+		// 重置表单和上传状态
+		formRef.value?.resetFields()
+		formState.fileIds = []
+		if (uploaderInstance.value) {
+			uploaderInstance.value.cancel()
+		}
+		emit('update:visible', false)
+	}
+
+	const handleSubmit = () => {
+		formRef.value
+			.validate()
+			.then(() => {
+				if (formState.fileIds.length === 0) {
+					message.warning('请上传文件')
+					return
+				}
+
+				if (filesLength.value > 0) {
+					message.warning('文件正在上传中,请等待上传完成后再提交')
+					return
+				}
+
+				submitting.value = true
+
+				// 模拟提交数据
+				setTimeout(() => {
+					message.success('提交成功')
+					submitting.value = false
+					emit('success', formState)
+					// 重置表单和上传状态
+					formRef.value?.resetFields()
+					formState.fileIds = []
+					emit('update:visible', false)
+				}, 1000)
+			})
+			.catch(() => {
+				// 表单验证失败
+			})
+	}
+
+	// 暴露方法给父组件
+	defineExpose({
+		handleUpload
+	})
+</script>
+
+<style lang="less" scoped>
+	.upload-btn-wrapper {
+		display: flex;
+		align-items: center;
+	}
+
+	.select-file-btn {
+		display: none;
+	}
+
+	.drop-box {
+		position: relative;
+		width: 100%;
+		height: 200px;
+		border: 2px dashed #e9e9e9;
+		border-radius: 6px;
+		background-color: #fafafa;
+		display: flex;
+		flex-direction: column;
+		justify-content: center;
+		align-items: center;
+		margin-top: 10px;
+
+		.text {
+			font-size: 16px;
+			color: #999;
+		}
+
+		.paste-img-wrapper {
+			width: 100%;
+			height: 100%;
+			display: flex;
+			flex-direction: column;
+			justify-content: center;
+			align-items: center;
+
+			.paste-name {
+				font-size: 14px;
+				margin-bottom: 10px;
+			}
+
+			.paste-img {
+				max-width: 80%;
+				max-height: 120px;
+			}
+		}
+
+		.upload-icon,
+		.delete-icon {
+			position: absolute;
+			bottom: 10px;
+			font-size: 20px;
+			cursor: pointer;
+		}
+
+		.upload-icon {
+			right: 40px;
+			color: #1890ff;
+		}
+
+		.delete-icon {
+			right: 10px;
+			color: #ff4d4f;
+		}
+
+		.close-icon {
+			position: absolute;
+			top: 10px;
+			right: 10px;
+			font-size: 16px;
+			cursor: pointer;
+			color: #999;
+		}
+	}
+
+	.file-panel {
+		width: 100%;
+		margin-top: 15px;
+		border: 1px solid #e9e9e9;
+		border-radius: 4px;
+		overflow: hidden;
+
+		.file-title {
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			padding: 8px 12px;
+			background-color: #f5f5f5;
+			border-bottom: 1px solid #e9e9e9;
+
+			.title-span {
+				font-size: 14px;
+				font-weight: 500;
+
+				.count {
+					color: #999;
+					font-weight: normal;
+				}
+			}
+		}
+
+		.file-list {
+			list-style: none;
+			margin: 0;
+			padding: 0;
+			max-height: 200px;
+			overflow-y: auto;
+
+			.file-item {
+				position: relative;
+				padding: 8px 12px;
+				border-bottom: 1px solid #f0f0f0;
+
+				&:last-child {
+					border-bottom: none;
+				}
+
+				&.custom-status-item {
+					padding-right: 100px;
+				}
+
+				.custom-status {
+					position: absolute;
+					right: 12px;
+					top: 50%;
+					transform: translateY(-50%);
+					color: #1890ff;
+				}
+			}
+
+			.no-file {
+				padding: 20px 0;
+				text-align: center;
+				color: #999;
+				font-size: 14px;
+			}
+		}
+	}
+
+	.collapse-enter-active,
+	.collapse-leave-active {
+		transition: all 0.3s;
+		max-height: 300px;
+		overflow: hidden;
+	}
+
+	.collapse-enter-from,
+	.collapse-leave-to {
+		max-height: 0;
+	}
+	.upload-area {
+		border: 2px dashed #3ca9f5;
+		padding: 40px;
+		text-align: center;
+	}
+
+	.upload-area p {
+		margin: 10px 0;
+	}
+
+	.file-item {
+		display: flex;
+		align-items: center;
+		margin: 10px 0;
+	}
+
+	.file-item .ant-progress {
+		flex: 1;
+		margin: 0 10px;
+	}
+
+	/* 新增表单样式 */
+	.ant-form-item {
+		margin-bottom: 16px;
+	}
+	.public-status-buttons {
+		display: flex;
+	}
+
+	.status-button {
+		padding: 5px 10px;
+		/* margin-right: 10px; */
+		border: 1px solid #ccc;
+		/* border-radius: 3px; */
+		cursor: pointer;
+		background-color: #fff;
+	}
+
+	.status-button.active {
+		background-color: #40a9ff;
+		color: #fff;
+		border-color: #40a9ff;
+	}
+	.upload-area {
+		border: 2px dashed #3ca9f5;
+		padding: 40px;
+		text-align: center;
+		transition: border-color 0.3s; /* 平滑过渡效果 */
+	}
+
+	.upload-area.drag-over {
+		border-color: #1890ff;
+		background-color: rgba(24, 144, 255, 0.05);
+	}
+</style>

+ 23 - 9
src/views/myResources/myResources.vue

@@ -121,7 +121,7 @@
 										<a href="javascript:;" @click="edit(record)">编辑</a>
 									</a-menu-item>
 									<a-menu-item>
-										<a-popconfirm title="确认删除吗?" @confirm="resourcesDelete(record)">
+										<a-popconfirm title="确认删除吗?" @confirm="resourcesDelete(record, 1)">
 											<a href="javascript:;">删除</a>
 										</a-popconfirm>
 									</a-menu-item>
@@ -574,14 +574,28 @@
 			ids: record.id,
 			verifyStatus: 4
 		}
-		resourceAuditApi
-			.updateStatus(params)
-			.then((res) => {
-				getListData()
-			})
-			.catch((err) => {
-				console.error(err)
-			})
+		if (formState.verifyStatus == 4) {
+			resourceAuditApi
+				.deletefile(params)
+				.then((res) => {
+					getListData()
+				})
+				.catch((err) => {
+					console.error(err)
+				})
+		} else {
+			resourceAuditApi
+				.updateStatus(params)
+				.then((res) => {
+					getListData()
+				})
+				.catch((err) => {
+					console.error(err)
+				})
+		}
+
+
+
 	}
 
 	// 上传资源模态框

+ 36 - 118
src/views/myResources/resourceUpload.vue

@@ -100,7 +100,7 @@
 				</a-radio-group>
 			</a-form-item>
 			<a-form-item v-if="isState == 1" label="资源描述" name="courseDesc">
-				<a-textarea v-model:value="formState.resourceDesc" placeholder="请输入课程介绍" :rows="4" />
+				<a-textarea v-model:value="formState.resourceDesc" placeholder="请输入资源描述" :rows="4" />
 			</a-form-item>
 			<a-form-item v-if="isState == 1" label="上传封面" name="coverImage">
 				<coverUpload
@@ -118,43 +118,8 @@
 			></userSelection>
 		</a-form>
 		<template v-if="isState == 0">
-			<!-- <a-upload
-				:multiple="true"
-				:before-upload="beforeUpload"
-				:headers="headers"
-				:action="action"
-				:file-list="fileList"
-				:remove="handleRemove"
-				accept=".ppt,.pptx,.doc,.docx,.xls,.xlsx,.pdf,.mp4,.zip,.rar"
-				:on-change="handleChange"
-			>
-				<div class="upload-area">
-					<a-icon type="cloud-upload" style="font-size: 60px; color: #3ca9f5"></a-icon>
-					<p>将文件拖到此处或点击上传</p>
-					<p>按住Ctrl可同时多选,支持上传PPT/word/excel/pdf/mp4/zip/rar,单个文件不能超过2G</p>
-				</div>
-			</a-upload>
-			<ul v-if="fileList.length">
-				<li v-for="(file, index) in fileList" :key="index" class="file-item">
-					<span>{{ file.name }}</span>
-					<a-progress :percent="file.percent || 0" />
-					<span v-if="file.response?.code == '200'">已完成</span>
-					<span v-if="file.response?.code == '500'">上传失败</span>
-					<span v-if="file.status === 'uploading'">上传中...</span>
-				</li>
-			</ul> -->
-			<div
-				class="upload-area"
-				@click="handleUploadFileBtnClick(1)"
-				@dragover.prevent="handleDragOver"
-				@dragleave.prevent="handleDragLeave"
-				@drop.prevent="handleDrop"
-			>
-				<a-icon type="cloud-upload" style="font-size: 60px; color: #3ca9f5" />
-				<p>点击上传</p>
-				<p>按住Ctrl可同时多选,支持上传PPT/word/excel/pdf/mp4/zip/rar,单个文件不能超过2G</p>
-			</div>
-			<uploadFile></uploadFile>
+			<!-- 资源上传 -->
+			<UploadModal @success="uploadSuccess"></UploadModal>
 		</template>
 	</a-modal>
 </template>
@@ -164,79 +129,11 @@
 	import { Modal, Upload, Form } from 'ant-design-vue'
 	import resourceAuditApi from '@/api/resourceAudit.js'
 	import userSelection from './userSelection.vue'
+	import UploadModal from './UploadModal.vue'
 	import coverUpload from './coverUpload/index.vue'
 	import { useMyResourceStore } from '@/store/myResource'
-	import uploadFile from '@/views/myResource/file/box/uploadFile/Box.vue'
 	const myResourceStore = useMyResourceStore()
 	const { proxy } = getCurrentInstance()
-	import {
-		getFileListByPath,
-		getFileListByType,
-		getRecoveryFile,
-		getMyShareFileList,
-		searchFile
-	} from '@/api/myResource/file'
-	// 分页数据
-	const pageData = ref({
-		currentPage: 1,
-		pageCount: 50,
-		total: 0
-	})
-	const fileType = ref(0)
-	// 当前所在路径
-	const filePath = computed(() => {
-		// return route.query.filePath ? route.query.filePath : '/'
-		return myResourceStore.getQuery.filePath ? myResourceStore.getQuery.filePath : '/'
-	})
-	// 上传文件组件参数
-	const uploadFileParams = computed(() => {
-		return {
-			filePath: myResourceStore.getQuery.filePath ? myResourceStore.getQuery.filePath : '/',
-			isDir: 0,
-			funcType: 0
-		}
-	})
-	// 拖拽相关方法
-	const handleDragOver = (e) => {
-		e.preventDefault()
-		e.currentTarget.style.borderColor = '#1890ff' // 拖拽进入时高亮边框
-	}
-
-	const handleDragLeave = (e) => {
-		e.preventDefault()
-		e.currentTarget.style.borderColor = '#3ca9f5' // 拖拽离开时恢复边框
-	}
-
-	const handleDrop = (e) => {
-		e.preventDefault()
-		e.currentTarget.style.borderColor = '#3ca9f5' // 恢复边框颜色
-		const files = e.dataTransfer.files
-		if (files.length > 0) {
-			// 触发上传逻辑(与点击事件相同)
-			handleUploadFileBtnClick(1)
-			// 如果需要直接处理文件,可以在这里添加逻辑
-			console.log('拖拽的文件列表:', files)
-		}
-	}
-	const handleUploadFileBtnClick = async (uploadWay) => {
-		proxy.$openDialog.authWeChat().then((res) => {
-			switch (res) {
-				case 'confirm': {
-					// window.$common.goAccount('/settings/account')
-					break
-				}
-				case 'go': {
-					proxy.$openBox.uploadFile({
-						params: uploadFileParams.value,
-						uploadWay,
-						serviceEl: proxy, // 使用proxy替代this
-						callType: 1 //  callType 调用此服务的方式:1 - 顶部栏,2 - 右键菜单
-					})
-					break
-				}
-			}
-		})
-	}
 	const props = defineProps({
 		isState: {
 			type: Number,
@@ -267,7 +164,7 @@
 		collegeTwoId: null, //院校二级id
 		collegeThreeId: null, //院校三级id
 		resourceDesc: null, //资源介绍
-		majorId: null, //专业id
+		majorId: '111111', //专业id
 		// courseTypeName: [], // 资源类型
 		keywordValue: [], // 添加关键词
 		keyword: [], // 热门关键词
@@ -294,6 +191,10 @@
 		emit('close')
 		fileList.value = []
 	}
+	//资源文件上传成功返回
+	const uploadSuccess = (idsArr) => {
+		formState.userfileIds = idsArr.join(',')
+	}
 	// 自定义校验函数示例
 	const validateKeywords = (rule, value, callback) => {
 		if (value.length < 2) {
@@ -447,16 +348,17 @@
 				coverImage: formState.coverImage,
 				publicStatus: formState.publicStatus
 			}
-			resourceAuditApi
-				.add(formData)
-				.then((res) => {
-					emit('getList')
-					Modal.success({ content: '资源上传成功' })
-				})
-				.catch((err) => {
-					Modal.error({ content: '资源上传失败' })
-					console.log(err)
-				})
+			console.log(formData, '上传数据')
+			// resourceAuditApi
+			// 	.add(formData)
+			// 	.then((res) => {
+			// 		emit('getList')
+			// 		Modal.success({ content: '资源上传成功' })
+			// 	})
+			// 	.catch((err) => {
+			// 		Modal.error({ content: '资源上传失败' })
+			// 		console.log(err)
+			// 	})
 		} catch (error) {
 			if (error.errorFields) {
 				// 表单验证错误
@@ -482,6 +384,20 @@
 			formState.majorId = res.data.majorId
 		})
 	}
+	// 获取资源详情
+	const getformState = () => {
+		resourceAuditApi.recentlyRecord().then((res) => {
+			console.log(res.data, '历史表单数据')
+			formState.courseType = res.data.courseType
+			formState.collegeId = res.data.collegeId
+			formState.collegeTwoId = res.data.collegeTwoId
+			formState.collegeThreeId = res.data.collegeThreeId
+			majorIdName.value = res.data.collegeAllId.split(',')
+			getCollegeMajor(majorIdName.value[majorIdName.value.length - 1])
+			formState.resourceDesc = res.data.resourceDesc
+			formState.majorId = res.data.majorId
+		})
+	}
 	// 上传前的钩子函数
 	const beforeUpload = (file) => {
 		const isLt2G = file.size / 1024 / 1024 / 1024 < 2
@@ -537,6 +453,8 @@
 		getHotKeywords()
 		if (props.isState == 1) {
 			getDetail()
+		} else {
+			getformState()
 		}
 	})
 </script>