|
@@ -6,37 +6,50 @@
|
|
|
下载列表
|
|
|
</h2>
|
|
|
<div class="m-core">
|
|
|
- <save-form :inline="true" class="searchForm" :model="searchForm" @submit="search" @reset='onReSet'>
|
|
|
+ <save-form
|
|
|
+ :inline="true"
|
|
|
+ class="searchForm"
|
|
|
+ :model="searchForm"
|
|
|
+ @submit="search"
|
|
|
+ @reset="onReSet"
|
|
|
+ >
|
|
|
<el-form-item prop="type">
|
|
|
<!-- downTypeList -->
|
|
|
- <el-form-item>
|
|
|
- <el-select
|
|
|
- v-model.trim="searchForm.type"
|
|
|
- clearable
|
|
|
- filterable
|
|
|
- placeholder="文件搜索类型"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="(item, index) in downTypeList"
|
|
|
- :key="index"
|
|
|
- :value="item.value"
|
|
|
- :label="item.label"
|
|
|
- ></el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-select
|
|
|
+ v-model.trim="searchForm.type"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ placeholder="文件搜索类型"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in downTypeList"
|
|
|
+ :key="index"
|
|
|
+ :value="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ ></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item>
|
|
|
<el-button native-type="submit" type="primary">搜索</el-button>
|
|
|
<el-button native-type="reset" type="danger">重置</el-button>
|
|
|
+ <auth auths="managerDownload/batchDel" style="margin-left:10px;">
|
|
|
+ <el-button type="primary" @click="clearRecord">清除记录</el-button>
|
|
|
+ </auth>
|
|
|
</el-form-item>
|
|
|
</save-form>
|
|
|
<div class="tableWrap">
|
|
|
<el-table
|
|
|
style="width: 100%"
|
|
|
+ ref="tableList"
|
|
|
:header-cell-style="{ background: '#EDEEF0', color: '#444' }"
|
|
|
:data="tableList"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ @select="onTableSelect"
|
|
|
>
|
|
|
+ <el-table-column type="selection" width="55"></el-table-column>
|
|
|
<el-table-column
|
|
|
width="120"
|
|
|
align="center"
|
|
@@ -51,7 +64,7 @@
|
|
|
<el-table-column align="center" prop="type" label="文件类型">
|
|
|
<template slot-scope="scope">
|
|
|
<div>
|
|
|
- {{ scope.row.type |downListType }}
|
|
|
+ {{ scope.row.type | downListType }}
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
@@ -103,8 +116,8 @@ import axios from "axios";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
import pagination from "@/components/Pagination/index";
|
|
|
import load from "@/utils/loading";
|
|
|
-import {downTypeList} from "@/utils/searchArray"
|
|
|
-import { managerDownloadList } from "./api";
|
|
|
+import { downTypeList } from "@/utils/searchArray";
|
|
|
+import { managerDownloadList, managerDownloadRecord } from "./api";
|
|
|
export default {
|
|
|
components: { pagination },
|
|
|
data() {
|
|
@@ -122,6 +135,7 @@ export default {
|
|
|
total: 0, // 总条数
|
|
|
page_size: [10, 20, 40, 50], // 选择限制显示条数
|
|
|
},
|
|
|
+ deleteList: [],
|
|
|
};
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
@@ -145,6 +159,19 @@ export default {
|
|
|
});
|
|
|
this.tableList = res.data.rows;
|
|
|
this.rules.total = res.data.total;
|
|
|
+
|
|
|
+ let idList = this.deleteList.map((course) => {
|
|
|
+ return course.id;
|
|
|
+ });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.tableList.forEach((course) => {
|
|
|
+ if (idList.indexOf(course.id) != -1) {
|
|
|
+ console.log(course.id);
|
|
|
+ this.$refs.tableList.toggleRowSelection(course, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.isDetele = false;
|
|
|
+ });
|
|
|
} catch (e) {
|
|
|
console.log(e);
|
|
|
}
|
|
@@ -155,7 +182,79 @@ export default {
|
|
|
},
|
|
|
onReSet() {
|
|
|
this.searchForm.type = null;
|
|
|
- this.search()
|
|
|
+ this.clearCom();
|
|
|
+ this.search();
|
|
|
+ },
|
|
|
+ handleSelectionChange(arr) {
|
|
|
+ // this.deleteList = arr;
|
|
|
+ if (arr.length > 0) {
|
|
|
+ // 有可能加 有可能减
|
|
|
+ this.deleteList = this.deleteList.concat(arr);
|
|
|
+ // 去重
|
|
|
+ this.deleteList = this.$helpers.lodash.uniqBy(this.deleteList, "id");
|
|
|
+ }
|
|
|
+ // else if(){}
|
|
|
+ else {
|
|
|
+ if (this.isDetele) return;
|
|
|
+ // 有2种 1是新页
|
|
|
+ // 2是点击反选
|
|
|
+ let idList = this.deleteList.map((course) => {
|
|
|
+ return course.id;
|
|
|
+ });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ let tableIdList = [];
|
|
|
+ this.tableList.forEach((course) => {
|
|
|
+ tableIdList.push(course.id);
|
|
|
+ if (idList.indexOf(course.id) != -1) {
|
|
|
+ this.$refs.tableList.toggleRowSelection(course, false);
|
|
|
+ // 删除这个元素
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.deleteList = this.$helpers.lodash.remove(
|
|
|
+ this.deleteList,
|
|
|
+ function (item) {
|
|
|
+ return tableIdList.indexOf(item.id) == -1;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ if (this.deleteList.length <= 0) {
|
|
|
+ this.clearCom();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onTableSelect(rows, row) {
|
|
|
+ let idList = this.deleteList.map((course) => {
|
|
|
+ return course.id;
|
|
|
+ });
|
|
|
+ if (idList.indexOf(row.id) != -1) {
|
|
|
+ this.deleteList.splice(idList.indexOf(row.id), 1);
|
|
|
+ if (this.deleteList.length <= 0) {
|
|
|
+ this.clearCom();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clearCom() {
|
|
|
+ // this.deleteList = [];
|
|
|
+ this.$set(this, "deleteList", []);
|
|
|
+ this.$refs.tableList.clearSelection();
|
|
|
+ // this.$refs.addCompound.isLook = false;
|
|
|
+ },
|
|
|
+ async clearRecord() {
|
|
|
+ if (this.deleteList.length <= 0) {
|
|
|
+ this.$message.error("请至少勾选一条记录");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ let idList = this.deleteList.map((course) => {
|
|
|
+ return course.id;
|
|
|
+ });
|
|
|
+ const res = await managerDownloadRecord({ ids: idList.join(",") });
|
|
|
+ this.$message.success("清除成功");
|
|
|
+ this.clearCom();
|
|
|
+ this.getList();
|
|
|
+ } catch (e) {
|
|
|
+ console.log(e);
|
|
|
+ }
|
|
|
},
|
|
|
},
|
|
|
};
|