vue element插件this.$confirm修改默认样式

App.vue全局样式定制:修改El-message-box组件
文章介绍了如何在Vue应用的全局样式中,对ElementUI的`.el-message-box`组件进行定制,包括边框、内边距、头部样式和按钮颜色等。

1.在App.vue全局添加样式

  .el-message-box{
    border: none !important;
  }
  .el-message-box__content{
    padding: 20px 15px !important;
  }
  .el-message-box__header {
  background: #b2afb3 !important;
  padding: 10px 15px 10px !important;
}
.el-message-box__title{
  color: #fff !important;
}
.el-message-box__header .el-message-box__headerbtn{
  top: 10px !important;
}
.el-message-box__header .el-message-box__headerbtn .el-message-box__close{
  color: #fff !important;
}

.el-button--primary{
  background: #b2afb3 !important;
  border-color:#b2afb3 !important;
}

<template> <nav class="site-navbar" :class="'site-navbar--' + navbarLayoutType" id="navbar" style="height:38px;" > <div class="site-navbar__body clearfix" style="height:38px;margin-left:0px;"> <el-menu class="site-navbar__menu" mode="horizontal" style="height:38px;"> <el-menu-item v-if="sidebarIsShow" class="site-navbar__switch" id="myzhedie" index="0" @click="sidebarFold = !sidebarFold" style="width:64px;"> <icon-svg name="zhedie"></icon-svg> </el-menu-item> <el-menu-item v-else class="site-navbar__switch" index="0" id="myhome1" style="width:64px;"> <icon-svg name="home"></icon-svg> </el-menu-item> <el-menu-item class="site-navbar__switch" index="0" style="padding:0 0px;background-color:transparent;color:inherit;margin-left:-10px"> <img src="~@/assets/img/logoNew6.png" style="width:160px;height:28px;"> </el-menu-item> </el-menu> <el-menu id="myNavbar" :default-active="activeMenu || 'home'" @select="handleSelect" class="site-navbar__menu" mode="horizontal" style="margin-left:21px;" > <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:monitornavbar')" style="margin-left:-1%;font-size: 14px;" index="home" @click="openHomeHandle"> <icon-svg name="chezidingyi" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">实时查询</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:traditionnavbar')" style="margin-left:-1%;font-size: 14px;" index="tradition" @click="openSideMenusHandle('330,384,515,516')"> <icon-svg name="system" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">数据中心</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:reportnavbar')" style="margin-left:-1%;font-size: 14px;" index="report" @click="openSideMenusHandle('445,459,462,453,429')"> <icon-svg name="tubiao" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">统计分析</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:statisticsnavbar')" style="margin-left:-1%;font-size: 14px;" index="statistics" @click="openSideMenusHandle('465,471')"> <icon-svg name="shouye" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">安全中心</span> </el-menu-item> <el-menu-item v-if="isAuth('battery:bmsbatteryinfo:managenavbar')" style="margin-left:-1%;font-size: 14px;" index="manage" @click="openSideMenusHandle('405,1,506,507')"> <icon-svg name="config" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">管理中心</span> </el-menu-item> <el-submenu id="myWindow" v-if="isAuth('battery:bmsbatteryinfo:largescreennavbar')" style="margin-left:-1%;font-size: 14px;" index="largescreen"> <template slot="title" > <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title" style="margin-left:-1%;font-size: 14px;">驾驶舱</span> </template> <el-menu-item index="2-1" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largedep')"> <icon-svg name="dashujukeshihua" class="site-sidebar__menu-icon"></icon-svg> <span slot="title">欣动电池大屏</span> </el-menu-item> </el-submenu> </el-menu> <el-menu class="site-navbar__menu site-navbar__menu--right" mode="horizontal"> <el-menu-item index="1" id="mydaping" @click="openEchartInNewWindow" v-if="isAuth('mqtt:mtbatteryinfolastest:largeDatalist')"> <template slot="title"> <el-badge value="大屏"> <icon-svg name="dashujukeshihua" class="el-icon-rank"></icon-svg> </el-badge> </template> </el-menu-item> <el-menu-item index="2" id="myshezhi" @click="$router.push({ name: 'theme' })"> <template slot="title"> <el-badge value="设置"> <icon-svg name="shezhi" class="el-icon-setting"></icon-svg> </el-badge> </template> </el-menu-item> <el-menu-item class="site-navbar__avatar" index="3" id="myhuichu"> <el-dropdown :show-timeout="0" placement="bottom"> <span class="el-dropdown-link"> <img src="~@/assets/img/avatar1.png" style="width:30px;height:30px;margin-bottom:2px;" :alt="userName">{{ userName }} </span> <el-dropdown-menu slot="dropdown"> <el-dropdown-item @click.native="updatePasswordHandle()">修改密码</el-dropdown-item> <el-dropdown-item @click.native="logoutHandle()">退出</el-dropdown-item> </el-dropdown-menu> </el-dropdown> </el-menu-item> </el-menu> </div> <!-- 弹窗, 修改密码 --> <update-password v-if="updatePassowrdVisible" ref="updatePassowrd"></update-password> </nav> </template> <script> import UpdatePassword from './main-navbar-update-password' import { clearLoginInfo,EventBus } from '@/utils' import Router from 'vue-router' import http from '@/utils/httpRequest' import { isURL } from '@/utils/validate' export default { data () { return { firstLogin: true, updatePassowrdVisible: false, activeMenu: 'home' // 默认激活的菜单项ID } }, components: { UpdatePassword }, computed: { navbarLayoutType: { get () { return this.$store.state.common.navbarLayoutType } }, sidebarFold: { get () { return this.$store.state.common.sidebarFold }, set (val) { this.$store.commit('common/updateSidebarFold', val) } }, mainTabs: { get () { return this.$store.state.common.mainTabs }, set (val) { this.$store.commit('common/updateMainTabs', val) } }, menuActiveName: { get () { return this.$store.state.common.menuActiveName }, set (val) { this.$store.commit('common/updateMenuActiveName', val) } }, userName: { get () { return this.$store.state.user.name } }, isHomePage(){ return this.$route.path === '/home' }, // 左侧菜单显示 sidebarIsShow: { get () { return this.$store.state.common.sidebarIsShow }, set (val) { this.$store.commit('common/updateSidebarIsShow', val) } }, // 顶部菜单的点击 // activeMenuIndex() { // return this.activeMenu.toString(); // 转换为字符串,以匹配模板中的index // } }, created() { // 刚登录进来,多点击监控中心,防止左侧缓存的菜单出现---20241217 this.firstLogin && ---------------------------------- if(localStorage.getItem('firstLogin')===null){ localStorage.clear(); console.log('本地存储已清除'); localStorage.setItem('firstLogin', '1'); this.firstLogin = false; // alert('第一次进来,firstLogin='+localStorage.getItem('firstLogin')) // 显示左侧菜单隐藏 this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 1); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); }else{ // 显示左侧菜单显示 // alert('firstLogin='+localStorage.getItem('firstLogin')) // this.$store.state.common.sidebarIsShow = true } //------------------------------------------------------------------------------------------------------------ this.openHomeHandle () setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 10); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 100); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 120); setTimeout(() => { // alert('延时加载') this.openHomeHandle (); }, 180); // 页面加载时尝试恢复之前的选中状态。刷新时一直保持点击颜色 this.activeMenu = sessionStorage.getItem('activeMenu') || 'home'; }, methods: { handleSelect(key, keyPath) { // 菜单项被点击时保存选中状态 this.activeMenu = key sessionStorage.setItem('activeMenu', key); // vue刷新页面数据不丢失-localStorage或sessionStorage保存数据 }, openEchartInNewWindow() { const routeData = this.$router.resolve({ name: 'echart' }); window.open(routeData.href, '_blank'); }, // 修改密码 updatePasswordHandle () { this.updatePassowrdVisible = true this.$nextTick(() => { this.$refs.updatePassowrd.init() }) }, // 退出 logoutHandle () { this.$confirm(`确定进行[退出]操作?`, '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { this.$http({ url: this.$http.adornUrl('/sys/logout'), method: 'post', data: this.$http.adornData() }).then(({data}) => { if (data && data.code === 0) { clearLoginInfo() this.$router.push({ name: 'login' }) } }) }).catch(() => {}) }, openSideMenusHandle (parentMenuIds) { // alert(parentMenuIds) this.mainTabs = [] //清除打开的tab菜单 this.menuActiveName = '' // 左侧菜单显示 this.$store.state.common.sidebarIsShow = true // 折叠打开 this.$store.state.common.sidebarFold = false // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); // 再次调用,防止点击监控中心--然后跳转到其他菜单时无反应 setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 150); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 100); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 220); setTimeout(() => { // alert('延时加载') EventBus.$emit('callMethod',parentMenuIds); }, 120); // this.$router.push({ name: 'center' }) // center home }, openHomeHandle () { this.$store.state.common.sidebarFold = true this.$store.state.common.sidebarIsShow = false this.activeMenu = 'home' sessionStorage.setItem('activeMenu', 'home') // 确保刷新后读取到正确的值 this.$router.push({ name: 'home' }) }, //--------------------------------------------------------------------------------------------------- // tabs, 关闭全部tab tabsCloseAllHandle () { this.mainTabs = [] this.menuActiveName = '' this.$router.push({ name: 'home' }) }, reloadMenus(parentMenuIds){ this.$http({ url: this.$http.adornUrl('/sys/menu/navappoint'), method: 'get', // params: this.$http.adornParams() params: this.$http.adornParams({ 'parentMenuIds': parentMenuIds }) }).then(({data}) => { if (data && data.code === 0) { // alert("获取导航菜单成功") this.fnAddDynamicMenuRoutes(data.menuList) this.$router.options.isAddDynamicMenuRoutes = true sessionStorage.setItem('menuList', JSON.stringify(data.menuList || '[]')) sessionStorage.setItem('permissions', JSON.stringify(data.permissions || '[]')) // sessionStorage.setItem('menuList', '[]') // sessionStorage.setItem('permissions', '[]') // alert("添加菜单") // 这里调用左侧菜单的方法 EventBus.$emit('callMethod',parentMenuIds); this.tabsCloseAllHandle (); // 折叠打开 this.$store.state.common.sidebarFold = false this.$router.push({ name: 'home' }) // next({ ...to, replace: true }) // 刷新 // location.reload() // alert("前往首页") } else { sessionStorage.setItem('menuList', '[]') sessionStorage.setItem('permissions', '[]') // 折叠缩进 this.$store.state.common.sidebarFold = true next() } }).catch((e) => { // alert("请求菜单列表和权限失败-to.path="+to.path) console.log(`%c${e} 请求菜单列表和权限失败,跳转至登录页!!`, 'color:blue') // alert("权限失败login") // this.$router.push({ name: 'login' }) }) }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes (menuList = [], routes = []) { var temp = [] for (var i = 0; i < menuList.length; i++) { if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } }, /** * 添加动态(菜单)路由 * @param {*} menuList 菜单列表 * @param {*} routes 递归创建的动态(菜单)路由 */ fnAddDynamicMenuRoutes2 (menuList) { var routes = [] var temp = [] // alert("添加动态(菜单)路由--"+menuList.length) for (var i = 0; i < menuList.length; i++) { // alert("添加动态URL----"+menuList[i].url) if (menuList[i].list && menuList[i].list.length >= 1) { temp = temp.concat(menuList[i].list) } else if (menuList[i].url && /\S/.test(menuList[i].url)) { menuList[i].url = menuList[i].url.replace(/^\//, '') var route = { path: menuList[i].url.replace('/', '-'), component: null, name: menuList[i].url.replace('/', '-'), meta: { menuId: menuList[i].menuId, title: menuList[i].name, isDynamic: true, isTab: true, iframeUrl: '' } } // alert("添加动态=isTab==="+route['meta']['isTab']) // url以http[s]://开头, 通过iframe展示 if (isURL(menuList[i].url)) { route['path'] = `i-${menuList[i].menuId}` route['name'] = `i-${menuList[i].menuId}` route['meta']['iframeUrl'] = menuList[i].url // alert("添加动态=isTab==="+route['meta']['isTab']) } else { try { route['component'] = _import(`modules/${menuList[i].url}`) || null } catch (e) {} } routes.push(route) } } if (temp.length >= 1) { this.fnAddDynamicMenuRoutes(temp, routes) } else { var mainRoutes = { name: 'main-dynamic', children: routes, path: '/' } // mainRoutes.name = 'main-dynamic' // mainRoutes.children = routes this.$router.addRoutes([ mainRoutes, { path: '*', redirect: { name: '404' } } ]) sessionStorage.setItem('dynamicMenuRoutes', JSON.stringify(mainRoutes.children || '[]')) console.log('\n') console.log('%c!<-------------------- 动态(菜单)路由 s -------------------->', 'color:blue') console.log(mainRoutes.children) console.log('%c!<-------------------- 动态(菜单)路由 e -------------------->', 'color:blue') } } //---------------------------------------------------------------------------------------------------------------------- } } </script> <style> #myNavbar .el-menu-item:hover { background-color: transparent !important; color: inherit !important; } /* 顶部菜单点击后的背景颜色 */ #myNavbar .el-menu-item.is-active { background-color: #409EFF !important; color: #fff; /*选中颜色*/ } /* 驾驶舱鼠标悬浮时 样式文件或组件内样式 */ #myNavbar .el-submenu__title:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ } .site-navbar__menu .el-menu-item, .site-navbar__menu .el-submenu > .el-submenu__title { height: 38px; line-height: 38px; } /* 左侧菜单选中与悬停样式 */ #myzhedie:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myzhedie.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhome1:hover { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhome1.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myshezhi:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myshezhi.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #mydaping:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #mydaping.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } #myhuichu:hover { background-color: #409EFF !important; /* 使用!important确保覆盖默认样式 */ color: inherit !important; } #myhuichu.is-active { background-color: rgba(126, 203, 252, 1) !important; /* 使用!important确保覆盖默认样式 */ } /* 加载表头颜色设置 */ /* rgba(126, 203, 252, 1) rgba(211, 236, 255, 255) #cdccd9 #87CEEB; rgba(211, 236, 255, 255); rgba(137, 207, 240); */ /* .el-table thead th { color: #909399; background-color: rgba(211, 236, 255, 255); font-weight: 800; color: #1D3124; } */ </style>帮我分析一下顶部导航栏为什么是鲜红色
最新发布
12-04
为什么使用vue使用screenfull插件全屏后element中的分页不能用了,以下是我的代码<template> <div class="app-container"> <!-- 添加全屏容器 --> <div :class="['table-container', { 'fullscreen-mode': isFullscreen }]" ref="tableContainer" > <!-- 添加全屏按钮 --> <el-row :gutter="10" class="mb8"> <el-col :span="22"> <div class="rightTop" style="display: flex; justify-content: center"> {{ queryParam.data.sheetName }} </div> </el-col> <el-col :span="2" style="text-align: right"> <!-- 添加全屏按钮 --> <el-button type="info" plain :icon="isFullscreen ? 'el-icon-close' : 'el-icon-full-screen'" size="mini" @click="toggleFullscreen" v-hasPermi="['im:frDatasourceImportDataView:list']" > {{ isFullscreen ? "退出全屏" : "全屏" }} </el-button> </el-col> </el-row> <el-form :model="queryParam.data" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px" > <el-form-item v-for="(x, index) in colName" :key="x.columnName" :label="x.columnComment" :prop="'queryForm.data.' + x.columnName" v-if="index <= 1 || isExpand" > <el-input v-model="queryParam.data[x.columnName]" :placeholder="'请输入' + x.columnComment" clearable @keyup.enter.native="handleQuery" /> </el-form-item> <el-form-item> <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" >搜索</el-button > <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" >重置</el-button > <el-button type="primary" icon="el-icon-d-arrow-right" size="mini" @click="isExpandClick" >展开</el-button > </el-form-item> </el-form> <el-row :gutter="10" class="mb8"> <el-col :span="1.5"> <el-button v-if="isTableOrView === 1" type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['im:frDatasourceImportDataView:list']" >新增</el-button > </el-col> <el-col :span="1.5"> <el-button v-if="isTableOrView === 1" type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['im:frDatasourceImportDataView:list']" >修改</el-button > </el-col> <el-col :span="1.5"> <el-button v-if="isTableOrView === 1" type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['im:frDatasourceImportDataView:list']" >删除</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['im:frDatasourceImportDataView:list']" >导出</el-button > </el-col> <el-col :span="1.5"> <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExportLimit" v-hasPermi="['im:frDatasourceImportDataView:list']" >导出模版</el-button > </el-col> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" ></right-toolbar> </el-row> <el-table v-loading="loading" :data="ImportDataViewList" @selection-change="handleSelectionChange" > <el-table-column v-if="isTableOrView === 1" type="selection" width="55" align="center" /> <el-table-column v-for="x in colName" :key="x.columnName" :label="x.columnComment" :prop="x.columnName" align="center" v-if="x.columnName != 'guid'" /> <el-table-column v-if="isTableOrView === 1" label="操作" align="center" class-name="small-padding fixed-width" > <template slot-scope="scope"> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['im:frDatasourceImportDataView:list']" >修改</el-button > <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['im:frDatasourceImportDataView:list']" >删除</el-button > </template> </el-table-column> </el-table> <pagination v-show="queryParam.pageInfo.total > 0" :total="queryParam.pageInfo.total" :page.sync="queryParam.pageInfo.pageNum" :limit.sync="queryParam.pageInfo.pageSize" popper-class="pageClass" @pagination="getList" /> <!-- 添加或修改数据库配置对话框 --> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body > <el-form ref="form" :model="form" :rules="rules" label-width="80px"> <el-form-item v-for="x in colName" :key="x.columnName" :label="x.columnComment" :prop="x.columnName" v-show="x.columnName != 'guid'" > <el-input v-model="form[x.columnName]" placeholder="请输入" /> </el-form-item> <!-- <el-form-item label="用户密码" prop="password"> <el-input v-model="form.password" placeholder="请输入用户密码" /> </el-form-item> --> </el-form> <div slot="footer" class="dialog-footer"> <el-button type="primary" @click="submitForm">确 定</el-button> <el-button @click="cancel">取 消</el-button> </div> </el-dialog> </div> </div> </template> <script> import { listImportDataView, // getImportDataView, delImportDataView, addImportDataView, updateImportDataView, getIsTableOrView, } from "@/api/im/importData/importDataView"; import screenfull from "screenfull"; // 引入screenfull库 const baseURL = process.env.VUE_APP_BASE_API; export default { name: "DataTableDataBase", props: { sheetName: "", }, data() { return { isFullscreen: false, // 全屏状态标志 isExpand: false, // 控制是否展开 //判断是视图还是表 isTableOrView: 0, //1表 2视图 downloadUrl: baseURL + "/im/importDataView/export", //存储字段与标签的映射关系 colName: {}, // 遮罩层 loading: true, // 选中数组 guids: [], dataRowS: [], // 非单个禁用 single: true, // 非多个禁用 multiple: true, // 显示搜索条件 showSearch: true, // 总条数 total: 0, // 数据库配置表格数据 ImportDataViewList: [], // 弹出层标题 title: "", // 是否显示弹出层 open: false, // 查询参数 queryParams: { pageNum: 1, pageSize: 10, dataName: null, driverClassName: null, url: null, username: null, password: null, }, // 表单参数 form: {}, // 表单校验 rules: {}, queryParam: { data: { sheetName: "", }, pageInfo: { pageNum: 1, pageSize: 10, size: 0, startRow: 0, endRow: 0, pages: 0, prePage: 0, nextPage: 0, isFirstPage: true, isLastPage: true, hasPreviousPage: false, navigatePages: 0, navigatepageNums: [], navigateFirstPage: 1, navigateLastPage: 1, total: 0, }, }, }; }, created() { var sheetNameRoute = this.$route.query.sheetName; console.log("this.$route.query.sheetName", sheetNameRoute); //this.queryParam.data.sheetName= this.$route.query.sheetName; if ( sheetNameRoute != null && sheetNameRoute != "" && sheetNameRoute != undefined ) { this.queryParam.data.sheetName = this.$route.query.sheetName; this.getIsTableOrView(); this.getList(); } }, watch: { //我想监控sheetName值是否发生变化 sheetName(newVal) { this.queryParam.data.sheetName = newVal; console.log("监控sheetName值", this.queryParam.data.sheetName); this.getIsTableOrView(); this.getList(); }, // visible(newVal) { // this.localVisible = newVal; // if (newVal) { // this.findContent(this.contentParam); // } // }, }, // 组件销毁时移除监听 beforeDestroy() { if (screenfull.isEnabled) { screenfull.off("change"); } }, methods: { // 添加全屏切换方法 toggleFullscreen() { if (screenfull.isEnabled) { const container = this.$refs.tableContainer; screenfull.toggle(container); // 监听全屏变化 screenfull.on("change", () => { this.isFullscreen = screenfull.isFullscreen; }); } else { this.$message.warning("您的浏览器不支持全屏功能"); } }, getIsTableOrView() { getIsTableOrView(this.queryParam.data.sheetName).then((response) => { this.isTableOrView = response.data; }); }, /** 查询数据库配置列表 */ getList() { this.loading = true; listImportDataView(this.queryParam).then((response) => { console.log("sss", response); this.colName = response.data.colName; this.ImportDataViewList = response.data.data.list; this.queryParam.pageInfo.total = response.data.data.total; this.loading = false; }); }, // 取消按钮 cancel() { this.open = false; this.reset(); }, // 表单重置 reset() { this.form = { // id: null, // dataName: null, // driverClassName: null, // url: null, // username: null, // password: null, // updateTime: null, // createTime: null, }; this.resetForm("form"); }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; this.getList(); }, isExpandClick() { this.isExpand = !this.isExpand; }, /** 重置按钮操作 */ resetQuery() { this.resetForm("queryForm"); this.handleQuery(); }, // 多选框选中数据 handleSelectionChange(selection) { this.guids = selection.map((item) => item.guid); this.dataRowS = selection; this.single = selection.length !== 1; this.multiple = !selection.length; }, /** 新增按钮操作 */ handleAdd() { this.reset(); this.open = true; this.title = "添加数据"; }, /** 修改按钮操作 */ handleUpdate(row) { this.reset(); console.log("row", row); console.log("this.dataRowS[0]", this.dataRowS[0]); const rowTwo = row.guid == null || row.guid == undefined ? this.dataRowS[0] : row; this.form = JSON.parse(JSON.stringify(rowTwo)); //this.form = this.dataRowS[0]; this.open = true; this.title = "修改数据"; }, /** 提交按钮 */ submitForm() { this.$refs["form"].validate((valid) => { if (valid) { var dataFrom = {}; dataFrom.data = this.form; dataFrom.sheetName = this.queryParam.data.sheetName; if (this.form.guid != null) { updateImportDataView(dataFrom).then((response) => { this.$modal.msgSuccess("修改成功"); this.open = false; this.getList(); }); } else { addImportDataView(dataFrom).then((response) => { this.$modal.msgSuccess("新增成功"); this.open = false; this.getList(); }); } } }); }, /** 删除按钮操作 */ handleDelete(row) { var dataFrom = {}; dataFrom.sheetName = this.queryParam.data.sheetName; const guids = row.guid != null && row.guid != undefined ? [row.guid] : this.guids; dataFrom.data = guids; this.$modal .confirm("是否确认删除数据?") .then(function () { return delImportDataView(dataFrom); }) .then(() => { this.getList(); this.$modal.msgSuccess("删除成功"); }) .catch(() => {}); }, /** 导出按钮操作 */ // handleExport() { // this.download( // "/im/importDataView/export", // { // ...this.queryParam, // }, // `ImportDataView_${new Date().getTime()}.xlsx` // ); // }, handleExport() { var param = { sheetName: this.queryParam.data.sheetName, }; this.download( "im/importDataView/export", { ...param, }, `导出报表_${new Date().getTime()}.xlsx` ); //window.location.href = this.downloadUrl+'?sheetName='+this.queryParam.data.sheetName; }, handleExportLimit() { var param = { sheetName: this.queryParam.data.sheetName, }; this.download( "im/importDataView/exportLimit", { ...param, }, `导出报表_${new Date().getTime()}.xlsx` ); //window.location.href = this.downloadUrl+'?sheetName='+this.queryParam.data.sheetName; }, }, }; </script> <style scoped> /* 添加全屏模式样式 */ .table-container { transition: all 0.3s; } .table-container.fullscreen-mode { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 9999; background: #fff; padding: 20px; overflow: auto; } </style>
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嫣嫣细语

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值