Ver código fonte

file manager view

wxb 5 anos atrás
pai
commit
049b87377c

+ 137 - 0
src/components/DragColumn/index.vue

@@ -0,0 +1,137 @@
+<template>
+  <div>
+    <div class="layout">
+      <div class="layout-left" :style="{ width: leftWidth }">
+        <slot name="left" />
+      </div>
+      <div ref="drag" class="layout-drag" :style="{ left: leftWidth }" @mousedown="handleDown">
+        <span class="line" />
+        <span class="line" />
+        <span class="line" />
+        <span class="line" />
+        <span class="line" />
+        <span class="line" />
+      </div>
+      <div class="layout-right" :style="{ width: rightWidth }">
+        <slot name="right" />
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'DragColumn',
+  data() {
+    return {
+      disX: 0,
+      layoutWidth: 0,
+      dragWidth: 0,
+      leftWidth: 0,
+      rightWidth: 0
+    }
+  },
+  mounted() {
+    this.layoutWidth = document.querySelector('.layout').clientWidth
+    this.dragWidth = document.querySelector('.layout-drag').clientWidth
+    this.leftWidth = (0.255 * this.layoutWidth) + 'px'
+    this.rightWidth = (0.735 * this.layoutWidth) + 'px'
+    window.onresize = () => {
+      this.layoutWidth = document.querySelector('.layout').clientWidth
+      this.dragWidth = document.querySelector('.layout-drag').clientWidth
+      this.leftWidth = (0.255 * this.layoutWidth) + 'px'
+      this.rightWidth = (0.735 * this.layoutWidth) + 'px'
+    }
+  },
+  methods: {
+    handleDown(e) {
+      const ev = e || event
+      const pos = this.getPos(ev)
+      const drag = this.$refs.drag
+      this.disX = pos.x - drag.offsetLeft
+      document.onmousemove = moveEvent => {
+        const oEvent = moveEvent || event
+        const movePos = this.getPos(oEvent)
+        const t = movePos.x - this.disX
+        const surplusWidth = this.layoutWidth - this.dragWidth - t
+        const leftWidth = this.layoutWidth - this.dragWidth - surplusWidth
+        if (leftWidth < 260) {
+          return false
+        } else if (surplusWidth < 260) {
+          return false
+        }
+        this.leftWidth = leftWidth + 'px'
+        this.rightWidth = surplusWidth + 'px'
+      }
+      document.onmouseup = () => {
+        document.onmousemove = null
+        document.onmouseup = null
+      }
+      return false
+    },
+    getPos(ev) {
+      const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
+      const scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft
+      return { x: ev.clientX + scrollLeft, y: ev.clientY + scrollTop }
+    }
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.layout {
+  height: calc(100vh - 113px);
+  position: relative;
+  .layout-left {
+    width: 25.5%;
+    height: 100%;
+    position: absolute;
+    top: 0;
+    left: 0;
+    bottom: 0;
+  }
+  .layout-drag {
+    width: 1%;
+    position: absolute;
+    height: 100%;
+    top: 0;
+    bottom: 0;
+    left: 25.5%;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column;
+    cursor: col-resize;
+    &:active{
+      .line{
+        transition: all 0.3s ease-in-out;
+        background: #0f82ff;
+        width: 3.5px;
+        height: 3.5px;
+        border-radius: 50%;
+      }
+    }
+    .line {
+      display: inline-block;
+      width: 2px;
+      height: 2px;
+      background: #898989;
+      margin-bottom: 5px;
+      border-radius: 50%;
+    }
+  }
+  .layout-right {
+    width: 73.5%;
+    height: 100%;
+    position: absolute;
+    top: 0;
+    right: 0;
+    bottom: 0;
+  }
+}
+.focus{
+  .line{
+    color: red;
+  }
+}
+</style>

+ 4 - 4
src/views/dashboard/admin/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="dashboard-editor-container">
     <el-row :gutter="12">
-      <el-col :sm="24" :xs="6" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
+      <el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
         <chart-card title="总销售额" total="¥126,560">
           <el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
             <i class="el-icon-warning-outline" />
@@ -17,7 +17,7 @@
           <template slot="footer">日均销售额<span>¥ 234.56</span></template>
         </chart-card>
       </el-col>
-      <el-col :sm="24" :xs="6" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
+      <el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
         <chart-card title="访问量" :total="8846">
           <el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
             <i class="el-icon-warning-outline" />
@@ -28,7 +28,7 @@
           <template slot="footer">日访问量<span> {{ '1234' }}</span></template>
         </chart-card>
       </el-col>
-      <el-col :sm="24" :xs="6" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
+      <el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
         <chart-card title="支付笔数" :total="6560">
           <el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
             <i class="el-icon-warning-outline" />
@@ -39,7 +39,7 @@
           <template slot="footer">转化率 <span>60%</span></template>
         </chart-card>
       </el-col>
-      <el-col :sm="24" :xs="6" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
+      <el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
         <chart-card title="运营活动效果" total="78%">
           <el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
             <i class="el-icon-warning-outline" />

+ 101 - 0
src/views/fileManage/index.vue

@@ -0,0 +1,101 @@
+<template>
+  <div>
+    <BasicLayout>
+      <template #wrapper>
+        <DragColumn>
+          <div slot="left" class="left">
+            <el-card>
+              <el-tree :data="data" :props="defaultProps" icon-class="el-icon-folder" draggable />
+            </el-card>
+          </div>
+          <div slot="right" class="right">
+            <el-card>2</el-card>
+          </div>
+        </DragColumn>
+      </template>
+    </BasicLayout>
+  </div>
+</template>
+
+<script>
+import DragColumn from '@/components/DragColumn/index'
+export default {
+  name: 'FileManage',
+  components: {
+    DragColumn
+  },
+  data() {
+    return {
+      data: [{
+        label: '一级 1',
+        children: [{
+          label: '二级 1-1',
+          children: [{
+            label: '三级 1-1-1'
+          }]
+        }]
+      }, {
+        label: '一级 2',
+        children: [{
+          label: '二级 2-1',
+          children: [{
+            label: '三级 2-1-1'
+          }]
+        }, {
+          label: '二级 2-2',
+          children: [{
+            label: '三级 2-2-1'
+          }]
+        }]
+      }, {
+        label: '一级 3',
+        children: [{
+          label: '二级 3-1',
+          children: [{
+            label: '三级 3-1-1'
+          }]
+        }, {
+          label: '二级 3-2',
+          children: [{
+            label: '三级 3-2-1'
+          }]
+        }]
+      }],
+      defaultProps: {
+        children: 'children',
+        label: 'label'
+      }
+    }
+  },
+  mounted() {
+
+  },
+  methods: {
+
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+  .left /deep/{
+    height: 100%;
+    .el-card{
+        height: 100%;
+    }
+    .el-tree-node__content{
+      height: 40px;
+    }
+    .el-icon-caret-right:before{
+        content: "\e78a";
+    }
+    .el-tree-node__expand-icon.expanded:before{
+        content: "\e784";
+    }
+  }
+  .right{
+    height: 100%;
+    .el-card{
+        height: 100%;
+    }
+  }
+</style>