| | |
| | | <template> |
| | | <div> |
| | | <el-row> |
| | | <el-col v-for="item in homeData" :span="item.span"> |
| | | <component :is="item.currentComponent" :key="item.component"></component> |
| | | <el-col v-for="item in homeData" :span="item.num" :xs="24"> |
| | | <div class="basic-container"> |
| | | <el-card class="basic-container__card" :body-style="{height:+(height*item.ratio-(item.title?78:38))+'px'}"> |
| | | <div slot="header" class="clearfix" v-if="item.title || item.icon"> |
| | | <span>{{item.title}}</span> |
| | | <icon-show :name="item.icon" style="display: inline-block"></icon-show> |
| | | </div> |
| | | <component :height="height*item.ratio" :is="item.module" :key="item.module" :title="item.title" :icon="item.icon"></component> |
| | | </el-card> |
| | | </div> |
| | | </el-col> |
| | | </el-row> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import {getAllData} from "@/api/homeConfig"; |
| | | import UndoTaskPortlet from './components/UndoTaskPortlet.vue'; |
| | | import taskPortlet from './components/taskPortlet.vue'; |
| | | import test from './components/test.vue'; |
| | | export default { |
| | | name: "workIndex", |
| | | components:{}, |
| | | components:{UndoTaskPortlet,taskPortlet,test}, |
| | | data(){ |
| | | return { |
| | | homeData:[{ |
| | | component:'UndoTaskPortlet', |
| | | span:24 |
| | | }] |
| | | height:document.body.clientHeight-115, |
| | | homeData:[] |
| | | } |
| | | }, |
| | | created() { |
| | | this.initData(); |
| | | this.getList(); |
| | | }, |
| | | methods:{ |
| | | initData() { |
| | | this.homeData.map(item => { |
| | | this.loadCompoent(item); |
| | | return item; |
| | | }) |
| | | }, |
| | | loadCompoent(item){ |
| | | // 动态导入组件 |
| | | import(`@/views/wel/components/${item.component}.vue`).then((module) => { |
| | | // 成功导入后,将组件注册到Vue实例中 |
| | | item.currentComponent = module.default; |
| | | }).catch((error) => { |
| | | // 处理导入失败的情况 |
| | | console.log('组件加载失败:', error); |
| | | getList() { |
| | | getAllData().then(res => { |
| | | const data = res.data.data; |
| | | if(data.length>0){ |
| | | this.homeData = data; |
| | | }else { |
| | | this.homeData = [{ |
| | | orderNum:1, |
| | | module: "UndoTaskPortlet", |
| | | title: "待办流程任务", |
| | | num:24, |
| | | icon: "", |
| | | ratio:1.00 |
| | | }]; |
| | | } |
| | | }).catch(error=>{ |
| | | this.homeData = [{ |
| | | orderNum:1, |
| | | module: "UndoTaskPortlet", |
| | | title: "待办流程任务", |
| | | num:24, |
| | | icon: "", |
| | | ratio:1.00 |
| | | }]; |
| | | }); |
| | | }, |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | <style lang="scss" scoped> |
| | | ::v-deep { |
| | | .iconShow{ |
| | | margin-left: 5px; |
| | | position: relative; |
| | | top:4px; |
| | | } |
| | | .el-col { |
| | | margin-bottom: 0px; |
| | | } |
| | | } |
| | | </style> |