Commit 09fbb075 by hanxiao

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

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