123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451 |
- <template>
- <div class="container">
- <!-- 标签 -->
- <div class="tags">
- <!-- TODO 标签可以拖动位置 -->
- <el-tabs
- v-model="clickCollect"
- class="demo-tabs"
- @tab-click="changeSearchFor"
- >
- <el-tab-pane label="常用" name="first"></el-tab-pane>
- <el-tab-pane label="默认" name="second"></el-tab-pane>
- <el-tab-pane
- v-for="item in tabList"
- :key="item.labelId"
- :label="item.labelName"
- :name="item.labelId"
- @contextmenu.prevent="checkRight($event, item)"
- ></el-tab-pane>
- </el-tabs>
- <!-- 添加标签 -->
- <div class="addCollect">
- <div v-if="!isAddCollect">
- <el-icon color="#2E6BC8">
- <Plus />
- </el-icon>
- <span @click="toAddCollectFn">添加标签</span>
- </div>
- <div v-else>
- <el-input
- v-model="tabName"
- size="mini"
- @blur="addCollectFn"
- maxlength="32"
- :autofocus="true"
- ></el-input>
- </div>
- </div>
- </div>
- <el-collapse v-model="activeNames" @change="handleChange">
- <div v-if="isList">
- <el-collapse-item name="folder">
- <template #title>
- <span class="collapseItem_title">文件夹</span>
- </template>
- <!-- 表格 -->
- <el-table
- :data="tableData"
- style="width: 100%"
- height="250"
- :scrollbar-always-on="true"
- >
- <el-table-column fixed prop="date" label="名称" width="500">
- <template #default="scope">
- <div>
- <img
- class="table_icon"
- src="@/assets/images/fileBox.png"
- alt=""
- style=""
- />
- {{ scope.row.date }}
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" label="时间" width="200" />
- <el-table-column prop="state" label="类型" width="180" />
- <el-table-column prop="city" label="大小" width="160" />
- </el-table>
- </el-collapse-item>
- <el-collapse-item name="file">
- <template #title>
- <span class="collapseItem_title">文件</span>
- </template>
- <!-- 表格 -->
- <el-table
- :data="tableData"
- style="width: 100%"
- height="250"
- :scrollbar-always-on="true"
- >
- <el-table-column fixed prop="date" label="名称" width="500">
- <template #default="scope">
- <div>
- <img
- class="table_icon"
- src="@/assets/images/fileBox.png"
- alt=""
- style=""
- />
- {{ scope.row.date }}
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="name" label="时间" width="200" />
- <el-table-column prop="state" label="类型" width="180" />
- <el-table-column prop="city" label="大小" width="160" />
- </el-table>
- </el-collapse-item>
- </div>
- <div v-else>
- <el-collapse-item name="folder">
- <template #title>
- <span class="collapseItem_title">文件夹</span>
- </template>
- <!-- 平铺 -->
- <el-scrollbar height="360px">
- <div class="tile_box">
- <div class="file_box" v-for="item in 20" :key="item">
- <img
- class="big_file_img"
- src="@/assets/images/fileBox.png"
- alt=""
- />
- <span>Inceptos</span>
- </div>
- </div>
- </el-scrollbar>
- </el-collapse-item>
- <el-collapse-item name="file">
- <template #title>
- <span class="collapseItem_title">文件</span>
- </template>
- <!-- 平铺 -->
- <el-scrollbar height="360px">
- <div class="tile_box">
- <div class="file_box" v-for="item in 20" :key="item">
- <img
- class="big_file_img"
- src="@/assets/images/fileType//file/DOC.png"
- alt=""
- />
- <span>Inceptos</span>
- </div>
- </div>
- </el-scrollbar>
- </el-collapse-item>
- </div>
- </el-collapse>
- </div>
- <!-- 右键唤出的菜单 -->
- <div
- class="right_menu"
- v-show="visible"
- :style="{ left: left + 'px', top: top + 'px' }"
- >
- <div class="menu_item">
- <img src="@/assets/images/textbox.png" alt="" />
- <span>重命名</span>
- </div>
- <div class="menu_item">
- <img src="@/assets/images/trash.png" alt="" />
- <span>删除</span>
- </div>
- </div>
- </template>
- <script setup>
- import { onMounted, ref, watch } from "vue";
- import { listLabel, addLabel, delLabel } from "@/api/biz/label.js";
- import { listFavorite } from "@/api/biz/favorite.js";
- const activeNames = ref(["folder", "file"]);
- const clickCollect = ref("first"); //当前标签
- const isAddCollect = ref(false); //是否在添加标签
- const tabName = ref(""); //新增的标签名
- const tabList = ref([]);
- const tableData = [
- {
- date: "2016-05-03",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-02",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-04",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-01",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-08",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-06",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- {
- date: "2016-05-07",
- name: "Tom",
- state: "California",
- city: "Los Angeles",
- address: "No. 189, Grove St, Los Angeles",
- zip: "CA 90036",
- },
- ];
- const visible = ref(false); //显示右键菜单
- const top = ref(0);
- const left = ref(0);
- onMounted(async () => {
- await getList();
- await getCollectList();
- });
- // tab右键事件
- const checkRight = (e, item) => {
- console.log('11');
- // TODO 唤出右键菜单,思路:获取鼠标位置来定位菜单
- this.visible = true;
- top.value = e.pageY;
- left.value = e.pageX;
- };
- // 关闭右键菜单
- const closeMenu = () => {
- visible.value = false;
- };
- //添加标签
- const toAddCollectFn = async () => {
- isAddCollect.value = true;
- // const res = await addLabel({
- // labelName: "tab1",
- // params: {},
- // });
- // if (res.code == 200) {
- // getList();
- // }
- };
- const addCollectFn = async () => {
- if (!tabName.value) {
- isAddCollect.value = false;
- return;
- }
- const res = await addLabel({
- labelName: tabName.value,
- });
- if (res.code == 200) {
- isAddCollect.value = false;
- tabName.value = "";
- getList();
- }
- };
- //获取标签数据
- const getList = async () => {
- const res = await listLabel();
- console.log("tabList =", res);
- if (res.rows.length > 0) {
- tabList.value = res.rows;
- }
- };
- // 删除标签
- const delTabs = async () => {
- const res = await delLabel("7"); //直接传id
- console.log("delres = ", res);
- getList();
- };
- //获取收藏数据
- const getCollectList = async () => {
- const res = await listFavorite();
- // console.log("collectres = ", res);
- if (res.code === 200 && res.rows.length > 0) {
- tableData.value = res.rows;
- }
- };
- watch(
- () => visible.value,
- (nv, ov) => {
- if (nv) {
- console.log('r',nv);
- document.body.addEventListener("click", closeMenu());
- } else {
- document.body.removeEventListener("click",closeMenu());
- }
- }
- );
- </script>
- <style lang="scss" scoped>
- .container {
- height: 100%;
- background-color: #fff;
- border-radius: 4px;
- .tags {
- display: flex;
- width: 100%;
- height: 40px;
- box-sizing: border-box;
- border-top: 1px solid #c1cce3;
- border-bottom: 1px solid #c1cce3;
- background-color: #f5f7f9;
- }
- .addCollect {
- margin-left: 16px;
- cursor: pointer;
- height: 100%;
- line-height: 40px;
- font-size: 14px;
- color: #2e6bc8;
- font-weight: 400;
- vertical-align: middle;
- }
- }
- .right_menu {
- width: 100px;
- padding: 8px;
- box-shadow: 0px 2px 10px 1px rgba(199, 203, 216, 0.4);
- border-radius: 4px 4px 4px 4px;
- border: 1px solid #c1cce3;
- .menu_item {
- width: 100%;
- height: 40px;
- border-radius: 4px 4px 4px 4px;
- display: flex;
- align-items: center;
- &:hover {
- background-color: #f5f7f9;
- }
- span {
- margin-left: 4px;
- }
- }
- }
- // tag间距
- ::v-deep .el-tabs__item {
- padding: 0 16px !important;
- color: #505870 !important;
- font-weight: 400 !important;
- }
- ::v-deep .el-tabs--top .el-tabs__item.is-top:last-child {
- padding-right: 0 !important;
- }
- // tag选中颜色
- ::v-deep .el-tabs__item.is-active {
- color: #2e6bc8 !important;
- font-weight: normal;
- font-family: Inter-SemiBold;
- }
- ::v-deep .el-tabs__active-bar {
- background-color: #2e6bc8;
- }
- .table_icon {
- height: 27px;
- width: 27px;
- vertical-align: middle;
- }
- ::v-deep .el-collapse-item__content {
- padding-bottom: 0;
- }
- ::v-deep .el-collapse-item__header {
- background-color: #ebeff6 !important;
- width: 100% !important;
- height: 24px !important;
- }
- ::v-deep .el-collapse-item__arrow {
- position: relative;
- color: #2e6bc8;
- right: 97%;
- }
- ::v-deep .el-table td.el-table__cell {
- border: none;
- font-size: 14px !important;
- font-weight: 400 !important;
- color: #000 !important;
- }
- ::v-deep .el-table__row {
- height: 35px !important;
- }
- ::v-deep .el-table .el-table__header-wrapper th {
- border-bottom: none;
- border-right: 1px solid #c1cce3;
- background-color: #fff !important;
- color: #505870;
- font-size: 14px;
- }
- .collapseItem_title {
- position: relative;
- left: 40px;
- color: #2e6bc8;
- font-family: Inter-Medium;
- font-size: 12px;
- }
- // 表格右边3个靠右对齐
- ::v-deep .el-table__header thead tr th {
- font-family: Inter-Medium;
- font-size: 14px;
- color: #505870;
- text-align: right;
- &:nth-child(1) {
- text-align: left;
- }
- }
- ::v-deep .el-table__body tbody [class*="column_"] {
- text-align: right;
- &:nth-child(4n + 1) {
- text-align: left;
- }
- }
- //平铺
- .tile_box {
- width: 100%;
- height: 300px;
- display: flex;
- flex-wrap: wrap;
- .file_box {
- width: 116px;
- min-height: 138px;
- // border: 1px solid #000;
- display: flex;
- flex-direction: column;
- align-items: center;
- .big_file_img {
- width: 100px;
- height: 100px;
- }
- span {
- font-size: 14px;
- font-weight: 400;
- line-height: 22px;
- }
- }
- }
- </style>
|