Commit d6ca78da authored by “yiyousong”'s avatar “yiyousong”

perf: 优化后台添加文件夹

parent 6f98cffe
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
border border
tooltip-effect="dark" tooltip-effect="dark"
style="width: 100%" style="width: 100%"
max-height="676px"
highlight-current-row highlight-current-row
reserve-selection reserve-selection
:row-key="(row) => row.id" :row-key="(row) => row.id"
...@@ -127,7 +126,11 @@ ...@@ -127,7 +126,11 @@
<el-button size="small" type="danger" @click="handleDelAll" <el-button size="small" type="danger" @click="handleDelAll"
>批量删除</el-button >批量删除</el-button
> >
<el-button size="small" type="primary" @click="addMaterialsToFolder" <el-button
size="small"
v-if="activeDep.id"
type="primary"
@click="addMaterialsToFolder"
>移动至</el-button >移动至</el-button
> >
</div> </div>
...@@ -178,7 +181,6 @@ ...@@ -178,7 +181,6 @@
border border
tooltip-effect="dark" tooltip-effect="dark"
style="width: 100%" style="width: 100%"
max-height="676px"
:row-key="(row) => row.id" :row-key="(row) => row.id"
@selection-change="handleSelectionChangeRight" @selection-change="handleSelectionChangeRight"
> >
...@@ -207,6 +209,14 @@ ...@@ -207,6 +209,14 @@
</p> </p>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column
prop="categoryName"
show-overflow-tooltip
label="所属文件夹"
align="center"
width="100"
>
</el-table-column>
<el-table-column <el-table-column
prop="total" prop="total"
label="查看次数" label="查看次数"
...@@ -565,7 +575,7 @@ export default { ...@@ -565,7 +575,7 @@ export default {
this.$message.warning("请先勾选材料"); this.$message.warning("请先勾选材料");
return; return;
} }
this.$refs.FolderList.onAdd(this.rightSelectedRowKeys); this.$refs.FolderList.onAdd(this.rightSelectedRowKeys, this.activeDep.id);
this.folderListVisible = true; this.folderListVisible = true;
}, },
materialsToFolderOk() { materialsToFolderOk() {
......
...@@ -7,24 +7,45 @@ ...@@ -7,24 +7,45 @@
@close="handleClose" @close="handleClose"
:close-on-click-modal="false" :close-on-click-modal="false"
> >
<div class="folder-list"> <div class="folder-list" v-if="folderList.length">
<el-radio <div class="folder-item-box" v-for="v in folderList" :key="v.id">
v-model="form.categoryId" <div class="control">
name="type" <div class="flex flexc">
v-for="v in folderList" <i
:key="v.id" class="el-icon-edit-outline pointer green mb10"
:label="v.id" @click="handleEdit(v)"
></i>
<i
class="el-icon-delete pointer delete"
@click="handleDel(v.id)"
></i>
</div>
</div>
<el-card shadow="hover" :body-style="{ padding: '0px' }">
<div
:class="[
'folder-item',
'flex',
'flexc',
'aic',
'jca',
{ active: v.id === categoryId },
]"
@click="categoryId = v.id"
> >
<div class="folder-item flex flexc aic jca">
<div class="folder-img-box flex aic jcc"> <div class="folder-img-box flex aic jcc">
<i class="iconfont icon-folder"></i> <i class="iconfont icon-folder"></i>
</div> </div>
<el-tooltip :content="v.categoryName" placement="top">
<p class="folder-name tac">{{ v.categoryName }}</p> <p class="folder-name tac">{{ v.categoryName }}</p>
</el-tooltip>
</div>
</el-card>
</div> </div>
</el-radio>
</div> </div>
<el-empty v-else description="暂无文件夹"></el-empty>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button size="small" @click="handleRest">重 置</el-button> <el-button size="small" @click="handleClose">关 闭</el-button>
<el-button <el-button
:loading="loading" :loading="loading"
size="small" size="small"
...@@ -34,13 +55,23 @@ ...@@ -34,13 +55,23 @@
> >
</span> </span>
</el-dialog> </el-dialog>
<!-- 新增文件夹 -->
<AddFolders
ref="AddFolders"
:addFolderVisible.sync="addFolderVisible"
@addSuccess="getMatterFolderList"
></AddFolders>
</div> </div>
</template> </template>
<script> <script>
import { getMatterFolderList } from "@/api/matter"; import { getMatterFolderList, delMatterFolder } from "@/api/matter";
import { batchSaveDatumToCategory } from "@/api/materials"; import { batchSaveDatumToCategory } from "@/api/materials";
import AddFolders from "./AddFolders.vue";
export default { export default {
components: {
AddFolders,
},
props: { props: {
folderListVisible: { folderListVisible: {
type: Boolean, type: Boolean,
...@@ -50,17 +81,12 @@ export default { ...@@ -50,17 +81,12 @@ export default {
}, },
data() { data() {
return { return {
categoryId: "", categoryId: "", // 选中文件夹
matterId: "", // 事项id
folderList: [], // 分类列表 folderList: [], // 分类列表
materialList: [], // 材料列表 materialList: [], // 材料列表
form: {
categoryId: "",
categoryName: "",
materialId: "",
materialName: "",
sort: 79,
},
loading: false, loading: false,
addFolderVisible: false,
}; };
}, },
computed: { computed: {
...@@ -77,14 +103,18 @@ export default { ...@@ -77,14 +103,18 @@ export default {
methods: { methods: {
// 获取事项文件夹列表 // 获取事项文件夹列表
async getMatterFolderList() { async getMatterFolderList() {
let res = await getMatterFolderList({ page: 1, size: -1 }); let res = await getMatterFolderList({
page: 1,
size: -1,
matterId: this.matterId,
});
if (res.data.code == 1) { if (res.data.code == 1) {
this.folderList = res.data.data.data; this.folderList = res.data.data.data;
} }
}, },
// 确定 // 确定
async handleOk() { async handleOk() {
if (!this.form.categoryId) { if (!this.categoryId) {
this.$message.warning("请勾选文件夹"); this.$message.warning("请勾选文件夹");
return; return;
} }
...@@ -106,21 +136,15 @@ export default { ...@@ -106,21 +136,15 @@ export default {
} }
}, },
// 新增 // 新增
onAdd(row) { onAdd(materialList, matterId) {
Object.assign(this.form, this.$options.data().form); this.materialList = materialList;
this.form.id && this.$delete(this.form, "id"); this.matterId = matterId;
// this.form.materialId = row.id;
// this.form.materialName = row.materialName;
this.materialList = row;
this.getMatterFolderList(); this.getMatterFolderList();
}, },
// 编辑
onEdit(row) {
this.form = { ...row };
},
// 重置 // 重置
handleRest() { handleRest() {
this.checked = ""; this.categoryId = "";
}, },
// 关闭 // 关闭
handleClose() { handleClose() {
...@@ -128,6 +152,32 @@ export default { ...@@ -128,6 +152,32 @@ export default {
this.loading = false; this.loading = false;
this.Visible = false; this.Visible = false;
}, },
// 删除文件夹
handleDel(id) {
this.$confirm("此操作将删除该文件夹,是否继续?", "系统提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
cancelButtonClass: "btn-custom-cancel",
type: "warning",
})
.then(async () => {
let res = await delMatterFolder({ id });
let { code, msg } = res.data;
if (code === 1) {
this.$message.success(msg);
this.getMatterFolderList();
}
})
.catch(() => {
console.log("取消成功!");
});
},
// 编辑文件夹
handleEdit(row) {
this.$refs.AddFolders.onEdit(row);
this.addFolderVisible = true;
console.log(row);
},
}, },
}; };
</script> </script>
...@@ -138,22 +188,40 @@ export default { ...@@ -138,22 +188,40 @@ export default {
max-height: 600px; max-height: 600px;
overflow-y: auto; overflow-y: auto;
display: grid; display: grid;
grid-template-columns: 182px 182px 182px 182px; grid-template-columns: repeat(4, 1fr);
justify-content: center; gap: 10px;
grid-row-gap: 10px; .folder-item-box {
width: 100%;
height: 140px;
position: relative;
.control {
top: 10px;
right: 10px;
position: absolute;
display: none;
}
i {
font-size: 18px;
}
&:hover {
.control {
display: block;
}
}
}
.folder-item { .folder-item {
width: 120px; width: 100%;
height: 140px; height: 140px;
// border: 1px solid red; cursor: pointer;
.icon-folder { .icon-folder {
font-size: 50px; font-size: 50px;
color: #188fff; color: #fca134;
} }
.folder-img-box { .folder-img-box {
width: 80px; width: 80px;
height: 80px; height: 80px;
background-color: rgba(24, 143, 255, 0.1); background-color: rgba(250, 147, 45, 0.1);
border-radius: 4px; border-radius: 4px;
} }
.folder-name { .folder-name {
...@@ -164,6 +232,17 @@ export default { ...@@ -164,6 +232,17 @@ export default {
white-space: nowrap; white-space: nowrap;
} }
} }
.active {
.folder-img-box {
background-color: rgba(24, 143, 255, 0.1);
}
.icon-folder {
color: #188fff;
}
.folder-name {
color: #1890ff;
}
}
} }
/deep/.el-checkbox__input { /deep/.el-checkbox__input {
position: absolute !important; position: absolute !important;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment