Commit 09fbb075 by hanxiao

添加批量添加账号、上传文件功能

parent 53f163c0
......@@ -13,6 +13,11 @@ export const users = p => get('/api/backup/users?page=' + p.page + '&size=' + p.
export const changeStatus = p => put('/api/backup/users/' + p.id, { status: p.status });
export const addusers = p => post('/api/backup/users', p);
export const deleusers = p => Delete('/api/backup/users', p);
//下载模板
export const downloads = p => get('/api/backup/downloads/批量添加账号.xlsx');
//上传文件
export const batchAdd = p => post('/api/backup/users/batchAdd', p);
......
......@@ -22,3 +22,4 @@ export const sendEmail = p => post('/api/common/sendEmail', p);
......@@ -67,11 +67,12 @@ export default {
<style lang="less" scoped>
.user {
width: calc(100%);
// height: 100%;
min-height: 900px;
height: 100%;
// min-height: 900px;
.user_main {
min-height: 800px;
// height: calc(100% - 65px);
height: 100%;
min-height: 900px;
// height: 100%;
width: 100%;
background-color: #ebebeb;
display: flex;
......
......@@ -13,12 +13,28 @@
<a-button type="primary" size="large" danger @click="opendeleteModal">
<img src="../../static/login/icon-delete.png" alt="" class="img" />
删除</a-button
>&nbsp;
<a-button type="primary" size="large" @click="downLoad">
<!-- <img src="../../static/login/icon-add.png" alt="" class="img" /> -->
批量添加账号模板 </a-button
>&nbsp;
<a-upload
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
v-model:file-list="fileList"
name="file"
:show-upload-list="false"
:customRequest="imageUpload"
>
<a-button type="primary" size="large"> 上传账号文件 </a-button>
</a-upload>
<br /><br />
<a-table
:row-selection="rowSelection"
:columns="columns"
:data-source="data"
:pagination="false"
:rowKey="
(row) => {
return row.id;
......@@ -46,6 +62,13 @@
</template>
</template>
</a-table>
<br />
<a-pagination
@change="changePage"
:total="total"
v-model:current="currentPage"
:showSizeChanger="false"
/>
</div>
</div>
<a-modal
......@@ -75,18 +98,25 @@
<script>
// import { AES_Encrypt, AES_Decrypt } from "@/utils/aes_util.js";
import { message } from "ant-design-vue";
import { users, changeStatus, addusers, deleusers } from "@/utils/loginAPI";
import {
users,
changeStatus,
addusers,
deleusers,
batchAdd,
} from "@/utils/loginAPI";
export default {
name: "userInfo",
data() {
return {
visible: false,
username: "",
fileList: [],
visibleDelete: false,
columns: [
{
title: "序号",
dataIndex: "id",
dataIndex: "index",
align: "center",
},
{
......@@ -123,6 +153,7 @@ export default {
selectedRowKeys: [],
data: [],
checked: true,
currentPage: 1,
};
},
created() {
......@@ -146,10 +177,30 @@ export default {
mounted() {},
methods: {
imageUpload(file) {
let data = new FormData();
data.append("file", file.file);
batchAdd(data).then((res) => {
if (res.code == 0) {
message.success(res.msg);
// console.log( this.img)
} else {
message.error(res.msg);
}
});
},
//调用删除用户接口
deleteUser() {
this.visibleDelete = false;
},
//下载模板
downLoad() {
window.location.href =
"https://zlcgzyzhzntjxt.industrychain.online/templates/批量添加账号.xlsx";
},
//上传文件
uploadFile() {},
//打开删除用户弹窗
opendeleteModal() {
this.visibleDelete = true;
......@@ -178,30 +229,35 @@ export default {
this.getList();
},
//获取用户列表
getList(page) {
getList() {
users({
page: page || 1,
page: this.currentPage,
size: 10,
}).then((res) => {
if (res.code == 0) {
this.data = res.data;
this.data.forEach((item, index) => {
item.index = (this.currentPage - 1) * 10 + index + 1;
});
this.total = res.total
} else {
message.error(res.msg);
}
});
},
changePage(){
this.getList();
},
// 勾选表格复选框
selectedTableRows(selectedRowKeys, selectedRows) {
// 批量选中的key
this.selectedRowKeys = selectedRowKeys;
console.log(selectedRowKeys);
},
//删除用户
deleteUser() {
let parma = {
user_ids: [...this.selectedRowKeys],
};
console.log(parma);
deleusers(parma).then((res) => {
// console.log(res)
if (res.code == 0) {
......@@ -238,6 +294,11 @@ export default {
width: calc(100% - 80px);
// text-align: center;
flex: 1;
.table{
height: 90%;
background-color: #fff;
padding: 15px 25px;
}
.img {
width: 15px;
height: 15px;
......
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