From 939afe16ec14bf83a5568b57487ba1236d2b18d6 Mon Sep 17 00:00:00 2001 From: Double-_-Z <2492419643@qq.com> Date: Wed, 15 Jan 2025 20:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=AE=A1=E7=90=86=E2=80=94?= =?UTF-8?q?=E2=80=94=E6=96=B0=E5=A2=9E=E6=96=87=E7=AB=A0=E5=8E=BB=E9=99=A4?= =?UTF-8?q?=E5=B0=81=E9=9D=A2=E5=BF=85=E4=B8=8A=E4=BC=A0=E9=99=90=E5=88=B6?= =?UTF-8?q?=EF=BC=8C=E5=AE=8C=E5=96=84=E6=8E=A8=E8=8D=90=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=92=8C=E5=BA=94=E7=94=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/article/component/upload.vue | 2 +- src/views/service/apply/index.vue | 2 +- src/views/service/recommend/index.vue | 107 ++++++++++++++++++++++++- 3 files changed, 105 insertions(+), 6 deletions(-) diff --git a/src/views/article/component/upload.vue b/src/views/article/component/upload.vue index ba634d8..6084d42 100644 --- a/src/views/article/component/upload.vue +++ b/src/views/article/component/upload.vue @@ -245,7 +245,7 @@ const articleFormRef = ref(); // 保存文章 const onSubmitForm = () => { articleFormRef.value.validate((valid: boolean) => { - if (valid && state.coverHide){ + if (valid){ const form = {...state.data,top:state.data.top ? 1 : 0}; if(state.coverFile.type === undefined){ realSubmit(form); diff --git a/src/views/service/apply/index.vue b/src/views/service/apply/index.vue index 1f089e0..d866e84 100644 --- a/src/views/service/apply/index.vue +++ b/src/views/service/apply/index.vue @@ -321,7 +321,7 @@ onMounted(() => { } .card-item-left{ - width: 80px; + width: 84px; height: 80px; img{ width: 100%; diff --git a/src/views/service/recommend/index.vue b/src/views/service/recommend/index.vue index acad4ed..e79d95f 100644 --- a/src/views/service/recommend/index.vue +++ b/src/views/service/recommend/index.vue @@ -5,7 +5,7 @@ 作品类型: + clearable class="ml10 mr10" style="max-width: 180px" filterable> @@ -21,7 +21,7 @@ 重置 - + @@ -82,6 +82,30 @@ + + + + + + + + + + + + + + + + + + 预览 + @@ -89,7 +113,7 @@ import { defineAsyncComponent, onMounted, reactive, ref } from 'vue'; import { recommendApi } from '/@/api/service/recommend'; import { applyApi } from '/@/api/service/apply'; -import { ElMessage, ElMessageBox, TableColumnCtx } from 'element-plus'; +import { ElMessage, ElMessageBox, TableColumnCtx, UploadFile } from 'element-plus'; // 表格数据 const state = reactive({ @@ -114,7 +138,19 @@ const state = reactive({ }, show: false, title: '作品审核', - message: '', + }, + recommend: { + loading: false, + form: {}, + rules: { + // photoSourceId: { required: true, message: '请输入应用名称', trigger: 'blur' }, + photoTargetId: { required: true, message: '请上传推荐作品', trigger: 'blur' }, + serviceName: { required: true, message: '请选择作品类型', trigger: 'blur' }, + }, + show: false, + title: '新增推荐作品', + coverFile: {}, + coverHide: false } }); @@ -122,6 +158,13 @@ const state = reactive({ const redApi = recommendApi(); const aplApi = applyApi(); +// 图标弹窗 +const dialogImageUrl = ref(''); +const dialogVisible = ref(false); + +// 定义变量内容 +const recommendFormRef = ref(); + // 获取专题列表 const getSpecialList = async() => { try { @@ -196,8 +239,61 @@ const reset = () =>{ getTableData(); } +// 关闭弹窗 +const closeDialog = () => { + setTimeout(() => { + state.recommend.show = false; + state.recommend.form = {}; + handleRemove(); + }, 300) +}; + +// 取消 +const onCancel = () => { + closeDialog(); +}; + +// 图标删除 +const handleRemove = (file?: UploadFile) => { + state.recommend.coverFile = {}; +// uploadRef.value.clearFiles(); + state.recommend.coverHide = false; +} + +// 图标预览 +const handlePictureCardPreview = (file: UploadFile) => { + dialogImageUrl.value = file.url! + dialogVisible.value = true +} + const replayFormRef = ref(); +// 提交 +const onSubmit = () => { + recommendFormRef.value.validate(async(valid: boolean) => { + if (valid && state.coverHide){ + try { + state.recommend.loading = true; + let res = await redApi.saveRecommend(state.recommend.form); + if(res?.success){ + ElMessage.success('推荐作品新增成功!'); + closeDialog(); // 关闭弹窗 + state.tableData.param.current = 1; + getTableData(); + }else{ + ElMessage.error('推荐作品新增失败!'); + } + } catch (error) { + ElMessage.error('处理失败!'); + } finally { + state.recommend.loading = false; + } + }else{ + ElMessage.error('请完善信息!'); + } + }); +}; + // 取消推荐 const toPublic = (row: any) => { ElMessageBox.confirm('确定要取消该作品推荐吗?', '提示', { @@ -265,6 +361,9 @@ onMounted(() => { } } } +.iconImg :deep(.hide .el-upload--picture-card) { + display: none; +} .dialog-content{ padding: 0; display: flex;