记录:前端-外部关闭confirm

部署运行你感兴趣的模型镜像

背景:页面使用了element-ui   confirm组件,有且只有一个消息框,要在某些条件下关闭这个消息框,而且是不点击confirm上的任何按钮(右上角关闭,下方按钮,ESC,modal等等)

解决:

打开:

this.$confirm('当前会话已接入,是否进入视频理赔界面进行会话?', '提示', {
    confirmButtonText: '是',
    showCancelButton: false,
    closeOnClickModal: false,
    closeOnPressEscape: false,
    showClose: false,
    type: 'warning'
  }).then(() => {
    console.log('xxxxx') //业务部分。。。省略
})

关闭:

this.$msgbox.close()

以上已经解决了我的问题。

问题:

多级confirm是否有效?多个呢?能否指定哪个关闭呢? 待验证。。。

 

不积跬步,无以至千里。

您可能感兴趣的与本文相关的镜像

Stable-Diffusion-3.5

Stable-Diffusion-3.5

图片生成
Stable-Diffusion

Stable Diffusion 3.5 (SD 3.5) 是由 Stability AI 推出的新一代文本到图像生成模型,相比 3.0 版本,它提升了图像质量、运行速度和硬件效率

<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>🎨 AI 图片生成器 - 智能图像创作平台</title> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet"> <style> :root { --primary: #6a11cb; --secondary: #2575fc; --accent: #ff6f61; --light: rgba(255, 255, 255, 0.9); --dark-bg: #1a1a2e; --card-bg: rgba(255, 255, 255, 0.12); --shadow: 0 8px 32px rgba(0, 0, 0, 0.15); --transition: all 0.3s ease; } * { box-sizing: border-box; } body { font-family: 'Noto Sans SC', 'Segoe UI', sans-serif; margin: 0; padding: 0; background: linear-gradient(135deg, var(--primary), var(--secondary)); color: white; min-height: 100vh; position: relative; } /* 渐变背景粒子效果 */ body::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url('https://particles.js.org/images/background.png'); opacity: 0.05; pointer-events: none; z-index: -1; } header { background: rgba(0, 0, 0, 0.4); padding: 1.2rem; text-align: center; box-shadow: 0 4px 12px rgba(0,0,0,0.2); backdrop-filter: blur(10px); } h1 { margin: 0; font-size: 2.2rem; font-weight: 700; text-shadow: 0 2px 8px rgba(0,0,0,0.3); } nav a { color: white; margin: 0 18px; text-decoration: none; font-weight: 500; font-size: 1.1rem; transition: var(--transition); } nav a:hover { text-decoration: underline; text-shadow: 0 1px 6px rgba(255,255,255,0.5); } main { display: flex; flex-wrap: wrap; gap: 2rem; padding: 0 1rem; justify-content: center; } .input-section { flex: 1 1 400px; max-width: 500px; } .gallery-section { flex: 2 1 600px; max-width: 800px; } .container { background: var(--card-bg); border-radius: 16px; padding: 2rem; box-shadow: var(--shadow); backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.2); } h2 { font-size: 1.5rem; margin-top: 0; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.3); } p.example { font-size: 0.95rem; opacity: 0.8; margin-bottom: 1.2rem; } label { display: block; margin-top: 1rem; font-size: 1.1rem; font-weight: 500; } input[type="text"], select { width: 100%; padding: 14px; margin: 0.5rem 0; border: none; border-radius: 8px; font-size: 1rem; background: rgba(255, 255, 255, 0.2); color: white; outline: none; transition: var(--transition); } input[type="text"]::placeholder { color: rgba(255,255,255,0.6); } input[type="text"]:focus { background: rgba(255, 255, 255, 0.3); transform: translateY(-2px); } button { margin-top: 1.5rem; padding: 14px 28px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: 1.1rem; cursor: pointer; transition: var(--transition); font-weight: 600; width: 100%; } button:hover { background: #e05a4f; transform: translateY(-2px); box-shadow: 0 6px 14px rgba(255,111,97,0.4); } button:active { transform: translateY(0); } #result { margin-top: 1.5rem; text-align: center; min-height: 200px; } #result.loading { color: rgba(255,255,255,0.8); font-style: italic; } #result img { max-width: 100%; max-height: 400px; border-radius: 12px; box-shadow: 0 8px 20px rgba(0,0,0,0.3); border: 4px solid rgba(255,255,255,0.2); margin: 1rem auto; display: block; cursor: zoom-in; } .img-caption { margin-top: 0.5rem; font-size: 0.9rem; opacity: 0.9; } .thumbnail-wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 1.5rem; } .thumb-item { position: relative; height: 100px; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.2); transition: var(--transition); cursor: zoom-in; } .thumb-item:hover { transform: scale(1.08); box-shadow: 0 6px 16px rgba(0,0,0,0.3); } .thumb-item img { width: 100%; height: 100%; object-fit: cover; } .clear-btn { background: #aaa !important; margin-top: 1rem !important; font-size: 0.9rem !important; } .clear-btn:hover { background: #888 !important; } footer { text-align: center; padding: 1.5rem; margin-top: 3rem; color: rgba(255,255,255,0.6); font-size: 0.9rem; } /* === 全屏图片预览模态框样式 === */ .modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.9); z-index: 1000; justify-content: center; align-items: center; flex-direction: column; animation: fadeIn 0.3s ease; } .modal.active { display: flex; } .modal-content { max-width: 90vw; max-height: 80vh; border-radius: 10px; box-shadow: 0 0 30px rgba(255, 255, 255, 0.2); overflow: hidden; position: relative; } .modal-content img { max-width: 100%; max-height: 80vh; display: block; } .modal-caption { margin-top: 1rem; font-size: 1rem; color: white; text-align: center; max-width: 90vw; } .close-modal { position: absolute; top: 15px; right: 20px; font-size: 2rem; color: white; background: none; border: none; cursor: pointer; opacity: 0.8; } .close-modal:hover { opacity: 1; } @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @media (max-width: 768px) { main { flex-direction: column; padding: 0.5rem; } .container { padding: 1.5rem; } h1 { font-size: 1.8rem; } } </style> </head> <body> <!-- 头部导航 --> <header> <h1>🎨 AI 图片生成器</h1> <nav> <a href="index.html">首页</a> <a href="guide.html">使用说明</a> </nav> </header> <main> <!-- 左侧输入区 --> <section class="input-section"> <div class="container"> <h2>描述你的创意</h2> <p class="example">例如:一只穿宇航服的猫在火星上钓鱼,赛博朋克风格</p> <label for="prompt">文字提示 (Prompt)</label> <input type="text" id="prompt" placeholder="输入你想要的画面描述..." /> <label for="style">艺术风格</label> <select id="style"> <option value="">无特定风格</option> <option value="anime">动漫风格</option> <option value="realistic">写实风格</option> <option value="oil painting">油画风格</option> <option value="cyberpunk">赛博朋克</option> <option value="watercolor">水彩画</option> <option value="surrealism">超现实主义</option> </select> <button onclick="generateImage()">✨ 生成图片</button> <div id="result"> <!-- 生成结果将显示在这里 --> </div> </div> </section> <!-- 右侧图库区 --> <section class="gallery-section"> <div class="container"> <h2>🖼️ 生成历史</h2> <p class="example">点击缩略图可查看大图</p> <div class="thumbnail-wall" id="history"></div> <button class="clear-btn" onclick="clearHistory()">🗑️ 清除历史</button> </div> </section> </main> <footer> © 2025 AI Image Generator Tool | 使用 Unsplash 模拟数据 | 学习演示用途 </footer> <!-- === 全屏图片预览模态框 === --> <div id="imageModal" class="modal"> <button class="close-modal" onclick="closeModal()">×</button> <div class="modal-content"> <img id="modalImage" src="" alt="Preview"> </div> <div class="modal-caption" id="modalCaption"></div> </div> <script> // 历史记录存储 let history = JSON.parse(localStorage.getItem('aiImageHistory')) || []; // 获取模态框元素 const modal = document.getElementById("imageModal"); const modalImg = document.getElementById("modalImage"); const modalCaption = document.getElementById("modalCaption"); // 打开模态框函数 function viewImage(src, caption) { modalImg.src = src; modalCaption.textContent = caption || ""; modal.classList.add("active"); document.body.style.overflow = "hidden"; // 防止滚动 } // 关闭模态框 function closeModal() { modal.classList.remove("active"); document.body.style.overflow = ""; // 恢复滚动 } // 点击遮罩外部关闭 modal.onclick = function(e) { if (e.target === modal) { closeModal(); } }; // 支持 ESC 键关闭(可选) document.onkeydown = function(e) { if (e.key === "Escape" && modal.classList.contains("active")) { closeModal(); } }; // 更新历史记录页面 function updateHistory() { const historyContainer = document.getElementById('history'); historyContainer.innerHTML = ''; if (history.length === 0) { historyContainer.innerHTML = '<p style="opacity:0.6; font-size:0.9rem;">暂无历史记录</p>'; return; } // 显示最新的6条 const recent = history.slice(-6).reverse(); recent.forEach(item => { const div = document.createElement('div'); div.className = 'thumb-item'; div.onclick = () => viewImage(item.imageUrl, `Prompt: ${item.prompt} | 风格: ${item.style}`); div.innerHTML = ` <img src="${item.imageUrl}" alt="history" onerror="this.onerror=null;this.src='https://via.placeholder.com/120x100?text=Error';"> `; historyContainer.appendChild(div); }); } // 从历史中点击查看详情(也支持大图) function showFromHistory(item) { document.getElementById('result').innerHTML = ` <h3>历史记录</h3> <img src="${item.imageUrl}" alt="Historical Image" onclick="viewImage('${item.imageUrl}', 'Prompt: ${item.prompt} | 风格: ${item.style}')"> <p class="img-caption"><strong>Prompt:</strong> ${item.prompt}</p> ${item.style ? `<p class="img-caption"><strong>风格:</strong> ${item.style}</p>` : ''} `; window.scrollTo({ top: 0, behavior: 'smooth' }); } // 清除所有历史 function clearHistory() { if (confirm("确定要清除所有生成的历史记录吗?")) { localStorage.removeItem('aiImageHistory'); history = []; updateHistory(); alert("历史记录已清除!"); } } // 图片模拟池(可按风格分类) const imagePool = { default: ['abstract', 'art', 'creative'], anime: ['anime', 'manga', 'cartoon'], realistic: ['realistic', 'photo', 'highly detailed'], 'oil painting': ['oil painting', 'brush strokes', 'classic art'], cyberpunk: ['cyberpunk', 'neon', 'futuristic'], watercolor: ['watercolor', 'painting', 'soft colors'], surrealism: ['surreal', 'dreamlike', 'melting'] }; function getRandomImageUrl(prompt, style) { const tags = imagePool[style] || imagePool.default; const tag = tags[Math.floor(Math.random() * tags.length)]; return `https://source.unsplash.com/random/800x600/?${encodeURIComponent(tag)}`; } // 生成图片主函数 function generateImage() { const promptInput = document.getElementById("prompt").value.trim(); const styleSelect = document.getElementById("style").value; const resultDiv = document.getElementById("result"); if (!promptInput) { alert("请输入你的创意描述!"); return; } resultDiv.className = "loading"; resultDiv.innerHTML = "<p>🧠 正在通过 AI 创作中,请稍候...</p>"; // 模拟网络请求延迟 setTimeout(() => { const imageUrl = getRandomImageUrl(promptInput, styleSelect); const displayStyle = document.getElementById("style").options[document.getElementById("style").selectedIndex].text; resultDiv.className = ""; resultDiv.innerHTML = ` <h3>✅ 生成成功!</h3> <img src="${imageUrl}" alt="AI Generated" onclick="viewImage('${imageUrl}', 'Prompt: ${promptInput} | 风格: ${displayStyle}')" onerror="this.src='https://via.placeholder.com/800x600?text=生成失败';"> <p class="img-caption"><strong>Prompt:</strong> ${promptInput}</p> ${styleSelect ? `<p class="img-caption"><strong>风格:</strong> ${displayStyle}</p>` : ''} `; // 添加到历史 const record = { prompt: promptInput, style: displayStyle, imageUrl, timestamp: new Date().toLocaleString() }; history.push(record); localStorage.setItem('aiImageHistory', JSON.stringify(history)); updateHistory(); // 刷新缩略图墙 }, 1800); } // 页面加载时初始化历史记录 window.onload = function () { updateHistory(); }; </script> </body> </html> 添加更多功能,我需要完整代码
最新发布
11-07
<template> <div class="add-announcement"> <el-dialog v-model:visible="outerVisible" width="1000px" :title="isEdit ? $t('HDP.WEB.ONLINE_NOTICE.MODIFYING_A_BULLETIN') : $t('HDP.WEB.ONLINE_NOTICE.ADDING_A_BULLETIN')" :before-close="closeDialog" :close-on-click-modal="false" :close-on-press-escape="false" > <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="100px" class="add-notice-ruleForm"> <el-form-item :label="$t('HDP.WEB.ONLINE_NOTICE.BULLETIN_TYPE')" prop="type"> <el-tooltip class="item" max-width="300" placement="right"> <template #content> <p>{{ $t('HDP.WEB.ONLINE_NOTICE.THE_ONLINE_BULLETIN') }}</p> <p>{{ $t('HDP.WEB.ONLINE_NOTICE.THE_CHANGE_NOTIFICATION') }}</p> <p>{{ $t('HDP.WEB.ONLINE_NOTICE.THE_HISTORICAL_RECORDS') }}</p> </template> <i class="ipd-font-icon icon-help announcement-help-tip"></i> </el-tooltip> <el-radio-group v-model="ruleForm.type" :disabled="isEdit"> <el-radio v-for="item in typeList" :key="item.value" :label="item.value"> {{ item.label }} </el-radio> </el-radio-group> </el-form-item> <el-form-item :label="$t('HDP.WEB.ONLINE_NOTICE.BULLETIN_TITLE')" prop="announcementTitle"> <el-input v-model.trim="ruleForm.announcementTitle" /> </el-form-item> <div v-if="isOld === 0" class="test"> <el-form-item :label="$t('HDP.WEB.ONLINE_NOTICE.BULLETIN_DESCRIPTION')" prop="announcementDesc"> <el-input v-model.trim="ruleForm.announcementDesc" /> </el-form-item> </div> <el-form-item :label="$t('HDP.WEB.ONLINE_NOTICE.RELEASE_TIME')" prop="releaseDate"> <el-date-picker v-model="ruleForm.releaseDate" :disabled="isEdit && Number(ruleForm.isDraft) !== 0" type="daterange" range-single range-separate :range-separator="$t('HDPPub.common.timeTo')" style="width: 100%" :start-placeholder="$t('HDP.PUB.StartDate')" :end-placeholder="$t('HDP.PUB.EndTime')" /> </el-form-item> <div v-if="isOld === 0" class="notice-editor"> <RichTextEditor ref="noticeEditor" v-model="richText" :img-count="3" :file-size="2" :min-height="24" :set-height="150" @get-content="callbackEqitorData" /> </div> <div v-if="isOld === 1" class="board-line"></div> <el-button v-if="isOld === 1" id="add-announ-des" @click="addDes">{{ `${$t('HDP.Common.Add')}(${ruleForm.picList.length}/30)` }}</el-button> <div v-if="isOld === 1"> <div v-for="(item, index) in ruleForm.picList" :key="index" class="announ-des"> <div class="img-upload"> <div v-if="!item.picUrl" class="img-upload-concent"> <input id="file" class="upload-button" type="file" :value="item.picUrl" accept="image/*" @change="onUpload(item, $event)" /> <i class="el-icon-plus"></i> </div> <div v-if="item.picUrl" class="no-img-concent"> <img :src="$xss.getSafeValue(item.picUrl)" class="img-hover" /> <span class="mulch"></span> <span class="option-img"> <input id="file" class="upload-button" type="file" value="" accept="image/*" @change="onUpload(item, $event)" /> <i class="ipd-font-icon icon-upload"></i> <i class="el-icon-zoom-in" @click="() => previewImg(item)"></i> <i class="el-icon-delete" @click="() => deleteImg(item)"></i> </span> </div> </div> <div class="option-right"> <div class="input-url"> <el-form-item :label="$t('HDP.WEB.ONLINE_NOTICE.REDIRECTION_URL')" :prop="`picList.${index}.url`" :rules="{ required: true, validator: validateUrl, trigger: 'blur' }" > <el-input v-model.trim="item.url" maxlength="500" /> </el-form-item> </div> <div class="option-sorting"> <i class="ipd-font-icon icon-chevron-up" @click="() => chevronUp(item, index)"></i> <br /> <span></span> <i class="ipd-font-icon icon-chevron-down" @click="() => chevrondown(item, index)"></i> </div> <div class="delete-des"> <i class="el-icon-delete" @click="() => deleteImgGrou(item, index)"></i> </div> </div> </div> </div> </el-form> <template #footer> <div class="dialog-footer"> <el-button id="announ-ok" type="primary" @click="addNotice('ruleForm')">{{ $t('HDP.BCM.Determined') }}</el-button> <!--新的公告或者是草稿才展示保存按钮--> <el-button v-if="isOld === 1 && Number(ruleForm.isDraft) === 0" id="announ-save" @click="saveNotice('ruleForm')"> {{ $t('HDP.CMS.GV.Dll.Save') }} </el-button> <el-button v-if="isOld === 1" id="announ-preview" style="margin-left: 20px" @click="previewNotice('ruleForm')"> {{ $t('HDP.COMMON.ONE_PREVIEW') }} </el-button> <el-button v-if="isOld === 0" id="announ-cancel" @click="closeDialog()">{{ $t('HDP.BCM.ToCancel') }}</el-button> </div> </template> </el-dialog> <ElImageViewer v-if="previewImgItem.showViewer" :z-index="previewImgItem.zIndex" :initial-index="previewImgItem.imageIndex" :on-close="closeViewer" :url-list="previewImgItem.srcList" /> <PreviewNotice ref="previewNotice" @add-callback-ann="addCallbackAnn" @is-hide-ti-yan-fun="isHideTiYanFun" /> </div> </template> <script> import { ImageViewer } from '@plmcsdk/common-ui'; import { mapState } from 'vuex'; import RichTextEditor from '@/components/common/component/RichTextEditor'; import PreviewNotice from '@/components/system-configuration/online-notice/PreviewNotice'; export default { emits: ['refsAnnouncement', 'isHideTiYanFun'], components: { PreviewNotice, ElImageViewer: ImageViewer, RichTextEditor, }, props: {}, data() { const validateUrl = (rule, value, callback) => { const match = /^((http|https):\/\/)/; if (!value.length) { callback(new Error('请输入跳转URL')); } else if (!match.test(value)) { callback(new Error('请输入正确的URL')); } else { callback(); } }; return { validateUrl, richText: '', // 富文本内容 isEdit: false, isOld: 1, // 是否是历史报告和变更通知 0表示 是老的1表示新的 outerVisible: false, announContrastItem: {}, // 记录主页传过来的修改数据 previewImgItem: { showViewer: false, imageIndex: 0, zIndex: 5000, srcList: [], }, typeList: [ { value: 0, label: '上线公告', title: '上线公告将会以弹框的方式提示用户', }, { value: 1, label: '变更通知', title: '变更通知将会以弹出页面的方式提示用户', }, ], ruleForm: { announcementTitle: '', announcementDesc: '', releaseDate: [], announcementContent: '', type: 0, isDraft: 0, picList: [ { picUrl: '', url: '', }, ], }, rules: { announcementTitle: [ { required: true, message: '请输入标题', trigger: 'blur', }, { min: 0, max: 60, message: '最多只能输入60个字符', trigger: 'blur', }, ], announcementDesc: [ { required: true, message: '请输入公告描述', trigger: 'blur', }, { min: 0, max: 50, message: '最多只能输入50个字符', trigger: 'blur', }, ], releaseDate: [ { required: true, message: '发布时间不能为空', validator: this.validateReleaseDate, trigger: 'blur', }, ], type: [ { required: true, message: '公告类型不能为空', trigger: 'change', }, ], }, }; }, watch: { 'ruleForm.type': { handler(val, oldVla) { // val等于1是变更通知 if (val == 1) { this.isOld = 0; } else { this.isOld = 1; } }, immediate: true, // 可以深度检测到 person 对象的属性值的变化 }, }, computed: { ...mapState({ userInfo: state => state.aside.userData, }), }, created() {}, methods: { validateReleaseDate(rule, value, callback) { if (!value.length || !value[0] || !value[1]) { callback('发布时间不能为空'); return false; } callback(); }, // 上传附件 onUpload(item, e) { const me = this; const file = e.target.files[0]; const formData = new FormData(); formData.append('file', e.target.files[0]); me.util.post('service/common/services/announcement/updateFileToS3', formData).then(result => { if (result.code == '200') { item.picUrl = result.response; } }); }, previewImg(item) { this.previewImgItem.srcList = [item.picUrl]; this.previewImgItem.showViewer = true; }, closeViewer() { this.previewImgItem.showViewer = false; }, deleteImg(item) { item.picUrl = ''; }, openDialog(data) { // 新增公告 if (data === 'add') { this.isEdit = false; } else { // 修改公告 this.ruleForm = data; this.ruleForm.releaseDate = [data.releaseDate, data.releaseEndDate]; this.announContrastItem = JSON.parse(JSON.stringify(data)); this.isEdit = true; this.isOld = Number(data.isOld); // 如果是修改的旧数据 if (data.isOld == 0) { setTimeout(() => { this.$refs.noticeEditor.setContent(data.announcementContent); }, 500); this.ruleForm.picList = []; } } this.outerVisible = true; }, // 关闭预览打开编辑 addCallbackAnn() { this.outerVisible = true; }, // 新增公告 addNotice(formName) { const me = this; me.$refs[formName].validate(valid => { if (valid) { if (me.isOld == 0) { me.saveOldData(); } else { me.saveNewData(); } } else { return false; } }); }, // 保存新的数据 saveNewData() { this.saveData('add'); }, // 保存草稿 saveNotice(formName) { const validList = ['announcementTitle', 'releaseDate']; this.$refs[formName].validateField(validList); // 保存草稿描述和发布日期必填 const announcementTitle = this.ruleForm.announcementTitle; // 标题60字符以内 if ( announcementTitle.length > 0 && announcementTitle.length < 61 && this.ruleForm.releaseDate.length && this.ruleForm.releaseDate[0] && this.ruleForm.releaseDate[1] ) { this.saveData('draft'); } }, // 调用接口保存新的数据 saveData(type, paramsx) { const me = this; let isImg = true; for (let i = 0; i < me.ruleForm.picList.length; i++) { me.ruleForm.picList[i].order = i; if (isImg && !me.ruleForm.picList[i].picUrl) { isImg = false; } } if (!isImg && type === 'add') { me.commonFun.setNotice('发布上线公告请不要忘了上传公告图片哦', 'warning'); return; } const params = { announcementTitle: me.ruleForm.announcementTitle, releaseDate: me.comments.formatDate(me.ruleForm.releaseDate[0], 'YMD'), releaseEndDate: me.comments.formatDate(me.ruleForm.releaseDate[1], 'YMD'), type: '0', isDraft: type === 'add' ? 1 : 0, picList: me.ruleForm.picList, }; if (me.announContrastItem.id) { params.id = me.announContrastItem.id; } me.util .post('service/common/services/announcement/saveAnnouncement', params) .then(result => { if (result.code == 200) { // 刷新主页面数据 me.$emit('refsAnnouncement', result.response.id); me.closeDialog(); me.commonFun.setNotice(type === 'add' ? '发布成功' : '保存成功', 'success'); } else { me.commonFun.setNotice(result.message, 'error'); } }) .catch(err => this.hdpCommon.errorHandling(err)); }, // 预览 previewNotice() { this.outerVisible = false; this.isHideTiYanFun(false); this.$refs.previewNotice.openDialog(this.ruleForm); }, // 获取富文本的数据 callbackEqitorData(data) { this.ruleForm.announcementContent = data; }, // 上移 chevronUp(item, index) { const picList = JSON.parse(JSON.stringify(this.ruleForm.picList)); if (index != 0) { picList[index] = picList.splice(index - 1, 1, picList[index])[0]; } else { picList.push(picList.shift()); } this.ruleForm.picList = picList; }, // 下移 chevrondown(item, index) { const picList = JSON.parse(JSON.stringify(this.ruleForm.picList)); if (index != picList.length - 1) { picList[index] = picList.splice(index + 1, 1, picList[index])[0]; } else { picList.unshift(picList.splice(index, 1)[0]); } this.ruleForm.picList = picList; }, // 删除组 deleteImgGrou(item, index) { if (this.ruleForm.picList.length > 1) { this.ruleForm.picList.splice(index, 1); } else { this.commonFun.setNotice('最少要有一组数据', 'warning'); } }, // 新增描述 addDes() { const addItem = { picUrl: '', url: '', rule: 'url', }; if (this.ruleForm.picList.length < 30) { this.ruleForm.picList.unshift(addItem); } else { this.commonFun.setNotice('最多只能新增30个', 'error'); } }, // 保存历史数据及变更通知 saveOldData() { this.$refs.noticeEditor.submit(); const me = this; const editValue = me.ruleForm.announcementContent; const params = { announcementContent: editValue, announcementDesc: me.ruleForm.announcementDesc, announcementTitle: me.ruleForm.announcementTitle, releaseDate: me.comments.formatDate(me.ruleForm.releaseDate[0], 'YMD'), releaseEndDate: me.comments.formatDate(me.ruleForm.releaseDate[1], 'YMD'), type: me.ruleForm.type, isDraft: '1', }; if (me.isEdit) { params.id = me.ruleForm.id; } me.util .post('service/common/services/announcement/saveAnnouncement', params) .then(result => { if (result.code == 200) { // 刷新主页面数据 me.$emit('refsAnnouncement', result.response.id); me.outerVisible = false; me.closeDialog(); } else { me.commonFun.setNotice(result.message, 'error'); } }) .catch(err => this.hdpCommon.errorHandling(err)); }, isHideTiYanFun(type) { this.$emit('isHideTiYanFun', type); }, // 关闭弹框 closeDialog(type) { this.$refs.ruleForm.clearValidate(); this.ruleForm = { announcementTitle: '', announcementDesc: '', releaseDate: [], announcementContent: '', type: 0, isDraft: 0, picList: [ { picUrl: '', url: '', }, ], }; this.announContrastItem = {}; this.outerVisible = false; this.isOld = 1; }, }, }; </script> <style scoped> .add-announcement :deep(.el-dialog__body) { padding-bottom: 0; } .add-announcement :deep(.el-dialog__footer) { padding: 20px 0; } .announcement-help-tip { position: absolute; left: -87px; color: #1890ff; } .board-line { position: absolute; left: 0; border-bottom: 1px dashed #d5d5d5; width: 100%; } #add-announ-des { margin-top: 10px; margin-bottom: 10px; } .announ-des { border-top: 1px solid #d5d5d5; border-left: 1px solid #d5d5d5; border-right: 1px solid #d5d5d5; height: 159px; } .announ-des:last-child { border-bottom: 1px solid #d5d5d5; } .img-upload { width: 279px; float: left; border-right: 1px solid #d5d5d5; height: 100%; padding: 10px 20px 10px 20px; } .el-icon-plus { margin-left: -35px; } .upload-button { width: 29px; text-align: center; opacity: 0; } .img-upload-concent { background-color: #fbfdff; border: 1px dashed #d9d9d9; border-radius: 2px; box-sizing: border-box; width: 242px; height: 134px; cursor: pointer; line-height: 134px; text-align: center; } .img-upload-concent i { font-size: 20px; color: #9097a1; } .option-img { display: none; text-align: center; position: absolute; top: 76%; left: 53%; margin: -50px 0 0 -50px; } .option-img i { font-size: 16px; color: #fff; } .option-img i:hover, .option-sorting i:hover, .delete-des i:hover { color: #1890ff; } .img-hover { width: 240px; height: 137px; } .no-img-concent { position: relative; } .no-img-concent:hover .option-img { display: block; } .no-img-concent:hover .mulch { width: 240px; height: 137px; position: absolute; left: 0; top: 0; opacity: 0.3; background: #000; } i.ipd-font-icon.icon-upload { margin-left: -19px; } .option-right { float: left; width: 70%; height: 100%; text-align: center; } .option-sorting { float: left; width: 5%; border-left: 1px solid #d5d5d5; border-right: 1px solid #d5d5d5; height: 100%; line-height: 76px; } .option-sorting i, .delete-des i { color: #9097a1; cursor: pointer; } .option-sorting span { border-bottom: 1px solid #d5d5d5; width: 100%; float: left; } .input-url { margin-top: 62px; margin-left: -10px; width: 91%; float: left; margin-right: 10px; } .delete-des { line-height: 156px; margin-left: 9px; float: left; } .notice-editor { margin-left: 36px; } </style> 结合上边的代码和下边这段代码 <template> <div class="online-notice"> <div class="notice-date"> <div class="operation"> <!-- 上线公告 --> <span class="title" style="margin-left: 20px">{{ $t('HDP.COMMON.GO_LIVE_BULLETIN') }}</span> <!-- 新增公告 --> <a v-if="systemAdmin" :title="$t('HDP.WEB.ONLINE_NOTICE.ADDING_A_BULLETIN')" class="ipd-font-icon icon-new fontSize no true" @click="addNotice"></a> </div> <div class="release-date" :style="{ height: releaseHeight }"> <el-menu :default-active="activeIndex" class="el-menu-vertical-demo" :unique-opened="true" :collapse="false"> <el-submenu v-for="(item, index) in quarterly" :key="index" :index="item.parentQuarterly"> <template #title> <span :title="item.parentQuarterly">{{ item.parentQuarterly }}</span> </template> <el-menu-item-group> <el-menu-item v-for="(item2, index2) in item.children" :key="index2" :index="item2.id" :title="item2.announcementTitle" @click="() => getAnnouncementItem(item2.id, 'detail')" > <!-- 草稿 --> <span v-if="item2.isDraft === '0'" class="draft">{{ $t('HDP.WEB.ONLINE_NOTICE.DRAFT') }}</span> <i v-if="systemAdmin && item2.isDraft === '0'" class="ifont ifont-del" @click="() => deleteDraft(item2)"></i> <i v-if="systemAdmin" class="ifont ifont-shenbaoshizhixuqiu" @click="() => updateNotice(item2)"></i> {{ item2.announcementTitle }} </el-menu-item> </el-menu-item-group> </el-submenu> </el-menu> </div> </div> <div class="notice-cntent" :style="{ height: noticeCntentHeight }"> <div class="desc"> <span class="announcementDesc">{{ announItem.announcementTitle }}</span> <!-- 发布时间 --> <span class="releaseDate">{{ $t('HDP.WEB.ONLINE_NOTICE.RELEASE_TIME') }} : {{ announItem.releaseDate }}</span> </div> <div v-if="announItem.isOld === '0' || announItem.type === 1" v-xss-html="replaceCommonAppId(announItem.announcementContent)"></div> <div v-else class="preview-notice"> <ElCarousel :interval="5000" arrow="always" :loop="false" :autoplay="false" @change="changeCarousel"> <ElCarouselItem v-for="(item, index) in announItem.picList" :key="index"> <img v-if="item.picUrl" :src="$xss.getSafeValue(item.picUrl)" /> </ElCarouselItem> </ElCarousel> <!-- 马上体验 --> <el-button v-show="isHideTiYan" id="preview-notice-home-experience" type="primary" style="margin-top: 20px" @click="experience"> {{ $t('HDP.WEB.ONLINE_NOTICE.EXPERIENCE_IT_RIGHT') }} </el-button> </div> </div> <AddAnnouncement ref="addAnnouncement" @refs-announcement="getAnnouncementList" @is-hide-ti-yan-fun="isHideTiYanFun" /> </div> </template> <script> import { Carousel, CarouselItem } from '@plmcsdk/common-ui'; import { mapState } from 'vuex'; import commonApi from '../../api/common-api'; import AddAnnouncement from './AddAnnouncement'; export default { components: { AddAnnouncement, ElCarousel: Carousel, ElCarouselItem: CarouselItem, }, data() { return { isHideTiYan: true, outerVisible: false, previewItem: {}, // 切换当前图片 activeIndex: '', noticeData: {}, quarterly: [], announItem: {}, releaseHeight: `${window.innerHeight - 167}px`, noticeCntentHeight: `${window.innerHeight - 130}px`, editorOp: { id: 'notice', // 富文本id,必传 uploadUrl: 'service/common/services/announcement/updateFileToS3', // 图片上传url,必传 imgSize: 5, // 图片大小,必传 limit: 50, // 最大图片个数。如不传则不限制 editorContent: '', // 富文本内容 disabled: false, }, systemAdmin: false, }; }, computed: mapState({ userData: state => state.aside.userData, }), mounted() { const me = this; commonApi.getSystemAdmin().then(result => { if (result.success) { me.systemAdmin = result.response; } }); this.getAnnouncementList(); this.hdpCommon.changeIhelpApp('plm-hdd'); this.hdpCommon.trackPysicalPageView('GoliveBulletin'); // 该埋码用于验证common埋码接入 this.hdpCommon.trackPysicalPageView('notice'); }, methods: { // 兼容历史appid replaceCommonAppId(content) { if (window.vue.comments.getJumpUrl('replaceCommonAppId') ?? true) { content = content.replace(/com.huawei.ipd.innovation.hdd:hdp_service_common/g, 'com.huawei.ipd.hdp.common:hdp_service_common'); } return content; }, // 查询公告 getAnnouncementList(id) { const me = this; me.commonReadAjax .get('service/common/services/announcement/getAnnouncementList') .then(result => { if (result.code == 200) { me.quarterly = result.response; const itemNotice = result.response.length > 0 ? result.response[0].children[0] : ''; let noticeId = itemNotice.id; if (id) { noticeId = id; } me.getAnnouncementItem(noticeId, 'detail'); } else { me.commonFun.setNotice(result.message, 'error'); } }) .catch(err => this.hdpCommon.errorHandling(err)); }, // 获取单个公告详情 getAnnouncementItem(id, type) { const me = this; const params = { id, }; if (!id) { return; } me.activeIndex = id; me.commonReadAjax .get('service/common/services/announcement/getAnnouncement', params) .then(result => { if (result.code == 200) { const announcementTitle = this.comments.reverseXss(result.response.announcementTitle); const announcementDesc = this.comments.reverseXss(result.response.announcementDesc); const releaseDate = result.response.releaseDate; const releaseEndDate = result.response.releaseEndDate; const announcementContent = this.comments.reverseXss(result.response.announcementContent); const item = { announcementTitle, announcementDesc, releaseDate, releaseEndDate, announcementContent, type: parseInt(result.response.type), id: result.response.id, isOld: result.response.isOld, picList: result.response.picList, isDraft: result.response.isDraft, }; if (type == 'update') { if (item.type == 1) { item.isOld = 0; } me.$refs.addAnnouncement.openDialog(item); } if (type == 'detail') { me.announItem = JSON.parse(JSON.stringify(item)); } } else { me.commonFun.setNotice(result.message, 'error'); } }) .catch(err => this.hdpCommon.errorHandling(err)); }, // 新增/修改公告 addNotice() { this.$refs.addAnnouncement.openDialog('add'); }, // 修改公告 updateNotice(item) { const me = this; me.outerVisible = true; me.noticeData = item; event.stopPropagation(); me.getAnnouncementItem(item.id, 'update'); }, // 删除公告 deleteDraft(item) { this.hdpCommon.messageBox('提示', '确认删除选中的数据 ?', status => { if (status === 'confirm') { const params = { id: item.id, type: '0', isDraft: 0, }; this.util .post('service/common/services/announcement/deleteAnnouncement', params) .then(result => { if (result.code === 200) { this.getAnnouncementList(); this.hdpCommon.setNotice('删除成功', 'success'); } else { this.hdpCommon.setNotice(result.message, 'error'); } }) .catch(err => this.hdpCommon.errorHandling(err)); } }); }, changeCarousel(index) { this.previewItem = this.announItem.picList[index]; }, experience() { let url = this.previewItem.url; if (!url) { url = this.announItem.picList.length > 0 ? this.announItem.picList[0].url : ''; } window.open(url); }, // 预览的时候隐藏主页面的体验按钮 isHideTiYanFun(type) { this.isHideTiYan = type; }, }, }; </script> <style scoped lang="less"> .online-notice { width: 100%; float: left; .operation { height: 30px; line-height: 30px; .title { margin-left: 22px; font-weight: bold; } a { float: right; margin-right: 12px; margin-top: -1px; cursor: pointer; } } .el-dialog__body .el-form-item:nth-child(2) { margin-bottom: 18px; } .notice-editor { margin-left: 36px; } .notice-date { width: 14%; float: left; border-right: 1px solid #d9d9d9; .release-date { overflow: auto; } } .notice-cntent { width: 84%; float: left; overflow: auto; margin-left: 1%; margin: 12px 1% 0 1%; :deep(table) { border: none; border-collapse: collapse; table-layout: fixed; empty-cells: show; max-width: 100%; box-sizing: border-box; tr td, tr th { border: 1px solid #ddd; text-align: left; vertical-align: middle; -webkit-user-select: text; -moz-user-select: text; -ms-user-select: text; user-select: text; } } } .el-menu-item-group, .el-menu-item { text-overflow: ellipsis !important; overflow: hidden !important; white-space: nowrap !important; } li.el-menu-item:hover i.ifont { display: block; } i.ifont { float: right; margin-right: -4%; color: #1890ff; cursor: pointer; display: none; margin-right: 10px; } .desc { margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid #ccc; .announcementDesc { font-size: 18px; color: #333333; font-weight: bold; margin-right: 15px; } } } </style> <style scoped> .online-notice .release-date :deep(.el-menu) { border-right: 0 !important; } .online-notice .release-date :deep(.el-submenu__icon-arrow) { margin-top: -4px; } .online-notice .preview-notice { width: 1200px; height: 675px; text-align: center; margin: 0 auto; background: #99a9bf; border: 1px solid #979797; background-color: rgba(153, 169, 191, 0.3); } .preview-notice :deep(.el-carousel--horizontal), .preview-notice :deep(.el-carousel__container) { height: 100%; } .preview-notice :deep(.el-carousel__button) { width: 8px; height: 8px; border-radius: 50%; } .preview-notice :deep(.el-carousel__container button) { background-color: #1890ff; } .preview-notice :deep(.el-carousel__container button:hover) { background: #66b1ff; border-color: #66b1ff; color: #fff; } .preview-notice :deep(.el-carousel__container button:active) { background-color: #3a8ee6; border-color: #3a8ee6; color: #fff; } .online-notice :deep(.draft) { float: right; background: #e6f7ff; border: 1px solid #91d5ff; border-radius: 2px; border-radius: 2px; height: 20px; width: 34px; line-height: 18px; text-align: center; color: #1890ff; margin-top: 10px; } #preview-notice-home-experience { width: 120px; height: 40px; } </style> 帮我分析一下点击新增上线公告点击确定后的公告通知弹窗的代码在哪个位置,并告诉我为什么没有弹窗的原因,如何解决这个问题
09-30
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值