Browse Source

Home System Final

caiaa 1 năm trước cách đây
mục cha
commit
c3a7d6e7ef

+ 1 - 1
src/styles/index.scss

@@ -198,7 +198,7 @@ aside {
 
 .home-more-dialog,
 .home-edit-dialog {
-  margin-top: 5vh !important;
+  margin-top: 10vh !important;
 
   .el-dialog__header {
     border-bottom: 1px solid rgba(0, 0, 0, 0.15);

+ 73 - 40
src/views/home/System.vue

@@ -5,23 +5,27 @@
         <span>{{ title }}</span>
         <el-button style="float: right; padding: 3px 0" type="text" size="medium" @click="showEdit">编辑</el-button>
       </div>
-      <el-carousel class="system-content" :autoplay="false" arrow="never" trigger="click">
-        <el-carousel-item v-for="(page,index) in carouselData" :key="index">
+      <el-carousel v-loading="loading" class="system-content" :autoplay="false" arrow="never" trigger="click">
+        <el-carousel-item v-for="(page, index) in carouselData" :key="'carousel_' + index">
           <div class="system-box">
-            <div v-for="item in page" :key="item.id" class="system-item-box" @click="jumpTo(item.link)">
-              <el-avatar :size="56" fit="fill" />
-              <div class="system-title">{{ item.name }}</div>
+            <div v-for="item in page" :key="item.id" class="system-item-box" @click="jumpTo(item.url)">
+              <el-avatar :size="56" fit="fill" :src="item.icon" />
+              <div class="system-title">{{ item.systemName }}</div>
             </div>
           </div>
         </el-carousel-item>
       </el-carousel>
     </el-card>
-    <system-edit ref="systemEdit" />
+    <system-edit ref="systemEdit" :title="title.startsWith('我的') ? title.substr(2) : title" />
   </div>
 </template>
 
 <script>
 import SystemEdit from './components/SystemEdit'
+
+import { fetchMySystemList } from '@/api/system'
+import { isNull, hasValidRecords } from '@/utils/convert'
+
 export default {
   components: { SystemEdit },
   props: {
@@ -36,28 +40,15 @@ export default {
   },
   data() {
     return {
-      rawData: [
-        { id: '1', code: '1', name: 'System1', link: 'https://www.baidu.com', icon: 'icon-1' },
-        { id: '2', code: '2', name: 'System2', link: 'https://www.baidu.com', icon: 'icon-2' },
-        { id: '3', code: '3', name: 'System3', link: 'https://www.baidu.com', icon: 'icon-3' },
-        { id: '4', code: '4', name: 'System4', link: 'https://www.baidu.com', icon: 'icon-4' },
-        { id: '5', code: '5', name: 'System5', link: 'https://www.baidu.com', icon: 'icon-5' },
-        { id: '6', code: '6', name: 'System6', link: 'https://www.baidu.com', icon: 'icon-6' },
-        { id: '7', code: '7', name: 'System7', link: 'https://www.baidu.com', icon: 'icon-7' },
-        { id: '8', code: '8', name: 'System8', link: 'https://www.baidu.com', icon: 'icon-8' },
-        { id: '9', code: '9', name: 'System9', link: 'https://www.baidu.com', icon: 'icon-9' },
-        { id: '10', code: '10', name: 'System10', link: 'https://www.baidu.com', icon: 'icon-10' },
-        { id: '11', code: '11', name: 'System11', link: 'https://www.baidu.com', icon: 'icon-11' },
-        { id: '12', code: '12', name: 'System12', link: 'https://www.baidu.com', icon: 'icon-12' },
-        { id: '13', code: '13', name: 'System13', link: 'https://www.baidu.com', icon: 'icon-13' }
-      ],
-      carouselData2: []
+      rawData: [],
+      carouselData2: [],
+      loading: false
     }
   },
   computed: {
     carouselData() {
       const result = []
-      if (this.rawData && this.rawData.length > 0) {
+      if (!isNull(this.rawData)) {
         const len = this.rawData.length
         const page = Math.ceil(len / this.pageSize)
         for (var i = 0; i < page; i++) {
@@ -68,24 +59,41 @@ export default {
     }
   },
   created() {
-    // this.formatData()
+    this.getMySystemData()
   },
   methods: {
-    formatData() {
-      this.carouselData2 = []
-      if (this.rawData && this.rawData.length > 0) {
-        const len = this.rawData.length
-        const page = Math.ceil(len / this.pageSize)
-        for (var i = 0; i < page; i++) {
-          this.carouselData2.push(this.rawData.slice(i * this.pageSize, (i + 1) * this.pageSize))
-        }
-      }
-    },
     jumpTo(link) {
       window.open(link, '_blank')
     },
     showEdit() {
       this.$refs.systemEdit.open()
+    },
+    getMySystemData() {
+      this.loading = true
+      const params = {
+        page: 1,
+        size: 100,
+        params: {
+          delFlag: 0
+        }
+      }
+      fetchMySystemList(params).then(response => {
+        this.loading = false
+        if (hasValidRecords(response)) {
+          this.rawData = response.data.records
+        } else {
+          this.rawData = []
+        }
+      }).catch(error => {
+        console.log(error)
+        this.loading = false
+        this.$message.error({
+          type: 'error',
+          duration: 0,
+          showClose: true,
+          message: '获取我的应用出错:' + error.message
+        })
+      })
     }
   }
 }
@@ -113,20 +121,24 @@ export default {
   .system-box {
     display: flex;
     flex-wrap: wrap;
-    justify-content: space-between;
-    width: 790px !important;
-    margin: 0 auto;
+    // justify-content: space-around;
+    align-content: space-around;
+    // width: 790px !important;
+    // margin: 0 auto;
+    height: 100%;
+    padding: 10px 0;
 
     .system-item-box {
-      width: 150px;
-      height: 110px;
+      width: 170px;
+      height: 130px;
       border: 1px solid rgba(0,0,0,0.09);
       border-radius:  10px;
       display: flex;
       flex-direction: column;
       justify-content: center;
       align-items: center;
-      margin: 5px 0;
+      margin: 5px calc(10% - 85px);
+      cursor: pointer;
 
       .system-title {
         font-size: 16px;
@@ -138,5 +150,26 @@ export default {
       }
     }
   }
+
+  @media only screen and (min-width: 1680px) {
+    .system-item-box {
+      width: 170px !important;
+      margin: 5px calc(10% - 85px) !important;
+    }
+  }
+
+  @media only screen and (min-width: 1440px) and (max-width: 1679px) {
+    .system-item-box {
+      width: 140px !important;
+      margin: 5px calc(10% - 70px) !important;
+    }
+  }
+
+  @media only screen and (max-width: 1439px) {
+    .system-item-box {
+      width: 100px !important;
+      margin: 5px calc(10% - 50px) !important;
+    }
+  }
 }
 </style>

+ 36 - 16
src/views/home/components/SystemEdit.vue

@@ -3,17 +3,17 @@
     <el-dialog
       v-loading="loading"
       :visible.sync="visible"
-      :close-on-press-escape="false"
+      :close-on-press-escape="true"
       :close-on-click-modal="false"
       :show-close="false"
       append-to-body
       custom-class="home-edit-dialog"
-      title="Setting"
+      :title="title + '设置'"
     >
       <div class="drag-container">
         <div v-loading="allLoading" class="drag-left">
           <div class="list-filter">
-            <span class="filter-title">list</span>
+            <span class="filter-title">{{ title }}</span>
             <el-input v-model="formData.systemName" clearable>
               <el-button slot="append" icon="el-icon-search" @click="searchTable" />
             </el-input>
@@ -26,6 +26,7 @@
             :move="checkMove"
             :set-data="setData"
             filter=".filtered"
+            handle=".handle-icon"
             class="drag-item-box"
           >
             <div
@@ -33,6 +34,7 @@
               :key="element.id"
               class="drag-item"
               :class="{'filtered': element.isFavorite}"
+              @click="jumpTo(element.url)"
             >
               <i class="el-icon-plus handle-icon" @click="clickAddItem(index)" />
               <el-avatar :size="56" :src="element.icon" />
@@ -52,8 +54,8 @@
         </div>
         <div v-loading="myLoading" class="drag-right">
           <div class="list-filter">
-            <span class="filter-title">My</span>
-            <span class="filter-tip">tip</span>
+            <span class="filter-title">{{ '我的' + title }}</span>
+            <span class="filter-tip">提示:可以通过鼠标拖拽进行排序</span>
           </div>
           <el-scrollbar class="my-scroll-box">
             <draggable
@@ -65,7 +67,7 @@
             >
               <div v-for="(element, index) in myListData" :key="element.id" class="drag-item">
                 <i class="el-icon-minus handle-icon" @click="clickRemoveItem(index)" />
-                <el-avatar :size="56" src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png" />
+                <el-avatar :size="56" :src="element.icon" />
                 <div class="item-system">{{ element.systemName }}</div>
               </div>
             </draggable>
@@ -73,8 +75,8 @@
         </div>
       </div>
       <div slot="footer">
-        <el-button @click="close">Cancel</el-button>
-        <el-button type="primary" @click="saveFavorite">Confirm</el-button>
+        <el-button @click="close">取消</el-button>
+        <el-button type="primary" @click="saveFavorite">确定</el-button>
       </div>
     </el-dialog>
   </div>
@@ -89,7 +91,12 @@ export default {
   components: {
     draggable
   },
-  props: {},
+  props: {
+    title: {
+      type: String,
+      default: '应用'
+    }
+  },
   data() {
     return {
       // dialog
@@ -183,7 +190,7 @@ export default {
       this.allLoading = true
       const params = {
         page: 1,
-        size: 50,
+        size: 100,
         params: {
           delFlag: 0
         }
@@ -240,6 +247,9 @@ export default {
     close() {
       this.visible = false
     },
+    jumpTo(link) {
+      window.open(link, '_blank')
+    },
     clone(item) {
       return { ...item }
     },
@@ -278,12 +288,12 @@ export default {
   .drag-left, .drag-right {
     width: 50%;
     padding: 0 0 20px 20px;
-    max-height: 560px;
   }
 
   .drag-left {
     background-color: #F8F9F9;
     position: relative;
+    max-height: 642px;
 
     .page {
       position: absolute;
@@ -304,8 +314,10 @@ export default {
   }
 
   .drag-right {
+    max-height: 770px;
+
     .my-scroll-box {
-      // 48 = filter-title + filter-tip - drag-right.margin-bottom
+      // 36 = list-filter - drag-right.margin-bottom
       height: calc(100% - 36px);
       margin-top: -2px;
     }
@@ -334,13 +346,21 @@ export default {
   }
 
   .filter-title {
-    font-size: 14px;
+    font-size: 15px;
     color: rgba(0,0,0,0.85);
+    font-weight: 550;
   }
 
   .filter-tip {
     font-size: 12px;
     color: rgba(0,0,0,0.65);
+    padding-top: 15px;
+
+    &::before{
+      content: "*";
+      color: #ff4949;
+      margin-right: 2px;
+    }
   }
 
   .drag-item-box {
@@ -349,8 +369,8 @@ export default {
   }
 
   .drag-item {
-    width: 150px;
-    height: 110px;
+    width: 140px;
+    height: 130px;
     border: 1px solid rgba(0,0,0,0.09);
     margin-bottom: 10px;
     margin-right: 20px;
@@ -385,7 +405,7 @@ export default {
 
     .item-system {
       text-align: center;
-      width: 130px;
+      width: 120px;
       text-overflow: ellipsis;
       overflow: hidden;
       white-space: nowrap;

+ 0 - 2
src/views/home/index.vue

@@ -133,8 +133,6 @@ export default {
 $msgCardHeaderHeight: 43px;
 
 .home-container {
-  // 1830=1920- sidebar - 5 padding - 21 browser scrollbar
-  width: 1830px;
 
   .card-box {
     height: 100%;

+ 1 - 1
src/views/system/components/SystemDetail.vue

@@ -3,7 +3,7 @@
     <el-dialog
       v-loading="loading"
       :visible.sync="visible"
-      :close-on-press-escape="false"
+      :close-on-press-escape="true"
       :close-on-click-modal="false"
       :show-close="false"
       custom-class="main-edit-dialog"

+ 1 - 1
src/views/system/index.vue

@@ -52,7 +52,7 @@
           </div>
           <div class="item-content">
             <div class="item-content-left">
-              <el-avatar :size="43" :src="item.icon" />
+              <el-avatar :size="56" :src="item.icon" />
               <span class="item-name">{{ item.systemName }}</span>
             </div>
             <el-button class="item-link" @click="jumpTo(item.url)">Open</el-button>