|
@@ -6,30 +6,45 @@
|
|
<el-divider style="background-color: #f4f4f4"/>
|
|
<el-divider style="background-color: #f4f4f4"/>
|
|
<div class="showTable">
|
|
<div class="showTable">
|
|
<div class="opr-btn">
|
|
<div class="opr-btn">
|
|
- <el-button type="primary" @click="exportData">导出数据</el-button>
|
|
|
|
- <el-button type="primary" @click="batchActivate">批量{{ active=='0'?'禁用':'激活' }}</el-button>
|
|
|
|
- <el-button type="primary" @click="batchDelete">批量删除</el-button>
|
|
|
|
|
|
+ <el-button type="primary" @click="batchUpdStatus">批量{{ active=='0'?'禁用':'激活' }}</el-button>
|
|
|
|
+ <el-button type="info" @click="batchDelete">批量删除</el-button>
|
|
|
|
+ <el-popconfirm
|
|
|
|
+ title="是否导出用户信息?"
|
|
|
|
+ style="margin-left: 12px"
|
|
|
|
+ @confirm="exportData"
|
|
|
|
+ >
|
|
|
|
+ <el-button slot="reference" type="default" >导出数据</el-button>
|
|
|
|
+ </el-popconfirm>
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ <div style="float: right">
|
|
|
|
+ <el-input class="opr-search" v-model="searchVal" style="width: 300px;" placeholder="用户名、手机号、单位名称" >
|
|
|
|
+ <el-button @click="searchEvent" slot="append" icon="el-icon-search"></el-button>
|
|
|
|
+ </el-input>
|
|
|
|
+ <el-button style="margin-left: 30px" type="primary" @click="addUser">添加人员</el-button>
|
|
|
|
+ </div>
|
|
</div>
|
|
</div>
|
|
<div class="table-data">
|
|
<div class="table-data">
|
|
- <userTableData :active="active" ref="userTableData" ></userTableData>
|
|
|
|
|
|
+ <userTableData :searchVal="searchVal" :active="active" ref="userTableData" @view="viewUser" @edit="editUser" @del="delUser" ></userTableData>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!--弹窗-->
|
|
<!--弹窗-->
|
|
- <userinfo ref="addUser" @confirmEvent="confirmEvent"></userinfo>
|
|
|
|
|
|
+ <userinfo :title="userDetail_title" ref="addUser" @confirmEvent="confirmEvent"></userinfo>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import userTableData from './tables/userTableData.vue'
|
|
import userTableData from './tables/userTableData.vue'
|
|
-import userinfo from './messageDialog/addUser'
|
|
|
|
|
|
+import userinfo from './messageDialog/userInfo.vue'
|
|
import Tags from "@/components/tags/index.vue";
|
|
import Tags from "@/components/tags/index.vue";
|
|
-import {addUser} from '@/api/user/user';
|
|
|
|
|
|
+import {addUser, alterUserStatusByBatched, deleteSingleUser, delUserByBatched, exportUserData, updateUserInfo} from '@/api/user/user';
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "personManagement",
|
|
name: "personManagement",
|
|
components: {userTableData, userinfo, Tags,},
|
|
components: {userTableData, userinfo, Tags,},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
|
|
+ userDetail_title: '添加用户',
|
|
tags: [
|
|
tags: [
|
|
{
|
|
{
|
|
label: '在用账户',
|
|
label: '在用账户',
|
|
@@ -42,7 +57,8 @@ export default {
|
|
show: false,
|
|
show: false,
|
|
}
|
|
}
|
|
],
|
|
],
|
|
- active: '0'
|
|
|
|
|
|
+ active: '0',
|
|
|
|
+ searchVal: '',
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -56,30 +72,43 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
addUser() {
|
|
addUser() {
|
|
- this.$refs.addUser.popTitle = '用户详情';
|
|
|
|
|
|
+ this.userDetail_title = '添加用户'
|
|
|
|
+ this.$refs.addUser.isView = false;
|
|
|
|
+ this.$refs.addUser.form = {
|
|
|
|
+ username: '',
|
|
|
|
+ password: '',
|
|
|
|
+ name: '',
|
|
|
|
+ phone: '',
|
|
|
|
+ email: '',
|
|
|
|
+ corporation: '',
|
|
|
|
+ department: '',
|
|
|
|
+ role: '',
|
|
|
|
+ permission: '',
|
|
|
|
+ working_status: '',
|
|
|
|
+ post: '',
|
|
|
|
+ account_status: '',
|
|
|
|
+ nationality: '中国',
|
|
|
|
+ photograph: '',
|
|
|
|
+ };
|
|
this.$refs.addUser.dialogVisible = true;
|
|
this.$refs.addUser.dialogVisible = true;
|
|
//重置form
|
|
//重置form
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
this.$refs.addUser.resetForm();
|
|
this.$refs.addUser.resetForm();
|
|
}, 100)
|
|
}, 100)
|
|
},
|
|
},
|
|
- confirmEvent(data) {
|
|
|
|
- if (this.$refs.addUser.popTitle === '用户详情') {
|
|
|
|
- let options = {
|
|
|
|
- username: data.username,
|
|
|
|
- password: data.password,
|
|
|
|
- photograph: data.photograph,
|
|
|
|
- name: data.name,
|
|
|
|
- phone: data.phone,
|
|
|
|
- email: data.email,
|
|
|
|
- company: data.corporation,
|
|
|
|
- department: data.department,
|
|
|
|
- role: data.role,
|
|
|
|
- permission: data.permission,
|
|
|
|
- on_job_status: data.working_status,
|
|
|
|
- duty: data.post,
|
|
|
|
- nationality: data.nationality,
|
|
|
|
- };
|
|
|
|
|
|
+ confirmEvent(data, isEdit) {
|
|
|
|
+ let options = JSON.parse(JSON.stringify(data));
|
|
|
|
+ options.photograph = data.photograph
|
|
|
|
+ if (isEdit) {
|
|
|
|
+ updateUserInfo(options).then((res) => {
|
|
|
|
+ if (res.data.code === 0) {
|
|
|
|
+ this.$message.success('用户修改成功');
|
|
|
|
+ this.$refs.addUser.dialogVisible = false;
|
|
|
|
+ this.$refs.addUser.isView = false;
|
|
|
|
+ this.$refs.userTableData.getTableData(1);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
addUser(options).then((res) => {
|
|
addUser(options).then((res) => {
|
|
if (res.data.code === -1) {
|
|
if (res.data.code === -1) {
|
|
this.$message.info('用户已存在,请修改重新添加!');
|
|
this.$message.info('用户已存在,请修改重新添加!');
|
|
@@ -87,6 +116,7 @@ export default {
|
|
if (res.data.code === 0) {
|
|
if (res.data.code === 0) {
|
|
this.$message.success('用户添加成功');
|
|
this.$message.success('用户添加成功');
|
|
this.$refs.addUser.dialogVisible = false;
|
|
this.$refs.addUser.dialogVisible = false;
|
|
|
|
+ this.$refs.addUser.isView = false;
|
|
this.$refs.userTableData.getTableData(1);
|
|
this.$refs.userTableData.getTableData(1);
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -94,6 +124,118 @@ export default {
|
|
},
|
|
},
|
|
searchEvent() {
|
|
searchEvent() {
|
|
this.$refs.userTableData.getTableData(this.$refs.userTableData.currentPage);
|
|
this.$refs.userTableData.getTableData(this.$refs.userTableData.currentPage);
|
|
|
|
+ },
|
|
|
|
+ viewUser(data) {
|
|
|
|
+ this.userDetail_title = '用户详情'
|
|
|
|
+ this.$refs.addUser.form = JSON.parse(JSON.stringify(data));
|
|
|
|
+ this.$refs.addUser.isView = true;
|
|
|
|
+ this.$refs.addUser.dialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+ editUser(data) {
|
|
|
|
+ this.userDetail_title = '用户更新'
|
|
|
|
+ this.$refs.addUser.form = JSON.parse(JSON.stringify(data));
|
|
|
|
+ this.$refs.addUser.isView = false;
|
|
|
|
+ this.$refs.addUser.dialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+ delUser(data) {
|
|
|
|
+ let id = data.id;
|
|
|
|
+ let params = {
|
|
|
|
+ id: id,
|
|
|
|
+ username: 'del',
|
|
|
|
+ password: 'del'
|
|
|
|
+ }
|
|
|
|
+ deleteSingleUser(params).then(res=>{
|
|
|
|
+ this.$message.success('删除成功');
|
|
|
|
+ this.$refs.userTableData.initData();
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ batchUpdStatus() {
|
|
|
|
+ let ids = [];
|
|
|
|
+ if (this.$refs.userTableData.multipleSelection) {
|
|
|
|
+ this.$refs.userTableData.multipleSelection.forEach(i=>{
|
|
|
|
+ ids.push(i.id);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ let params = {
|
|
|
|
+ users_id: '['+ids.join(',')+']',
|
|
|
|
+ status: this.active=='0'?'1':'0',
|
|
|
|
+ }
|
|
|
|
+ if (ids.length<1) {
|
|
|
|
+ this.$message.warning('请选择用户')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ let tips = this.active=='0'?'禁用':'激活';
|
|
|
|
+ let app = this;
|
|
|
|
+ this.$confirm('是否'+tips+ids.length+'名用户?', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ alterUserStatusByBatched(params).then(res=>{
|
|
|
|
+ if (res.data.code==0) {
|
|
|
|
+ app.$refs.userTableData.initData();
|
|
|
|
+ app.$message({
|
|
|
|
+ type: 'success',
|
|
|
|
+ message: '操作成功!'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ batchDelete() {
|
|
|
|
+ let ids = [];
|
|
|
|
+ if (this.$refs.userTableData.multipleSelection) {
|
|
|
|
+ this.$refs.userTableData.multipleSelection.forEach(i=>{
|
|
|
|
+ ids.push(i.id);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ let params = {
|
|
|
|
+ users_id: '['+ids.join(',')+']'
|
|
|
|
+ }
|
|
|
|
+ if (ids.length<1) {
|
|
|
|
+ this.$message.warning('请选择用户')
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ let app = this;
|
|
|
|
+ this.$confirm('是否删除'+ids.length+'名用户?', '提示', {
|
|
|
|
+ confirmButtonText: '确定',
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
+ type: 'warning'
|
|
|
|
+ }).then(() => {
|
|
|
|
+ delUserByBatched(params).then(res=>{
|
|
|
|
+ if (res.data.code==0) {
|
|
|
|
+ app.$refs.userTableData.initData();
|
|
|
|
+ app.$message({
|
|
|
|
+ type: 'success',
|
|
|
|
+ message: '操作成功!'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ exportData() {
|
|
|
|
+
|
|
|
|
+ exportUserData().then(res=>{
|
|
|
|
+ const data = res.data;
|
|
|
|
+ if (data.type === "application/octet-stream") {
|
|
|
|
+ let fileName
|
|
|
|
+ if (res.headers['content-disposition']) {
|
|
|
|
+ fileName = res.headers['content-disposition'].replace(/\w+;filename=(.*)/, '$1')
|
|
|
|
+ fileName = fileName.replace('attachment; filename=',Date.now()+'-');
|
|
|
|
+ } else {
|
|
|
|
+ fileName = data.fileName
|
|
|
|
+ }
|
|
|
|
+ const blob = new Blob([data], { type: data.type });
|
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
|
+ const link = document.createElement("a");
|
|
|
|
+ link.href = url;
|
|
|
|
+ link.download = fileName;
|
|
|
|
+ document.body.appendChild(link);
|
|
|
|
+ link.click();
|
|
|
|
+ link.parentNode.removeChild(link);
|
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
@@ -102,6 +244,30 @@ export default {
|
|
<style lang="less" scoped>
|
|
<style lang="less" scoped>
|
|
.container {
|
|
.container {
|
|
|
|
|
|
|
|
+ .opr-search {
|
|
|
|
+ /deep/ .el-input__inner {
|
|
|
|
+ height: 30px !important;
|
|
|
|
+ //border-right: none;
|
|
|
|
+ }
|
|
|
|
+ /deep/ .el-input-group__append {
|
|
|
|
+ border: none;
|
|
|
|
+ background-color: transparent;
|
|
|
|
+ padding: 0 20px;
|
|
|
|
+ }
|
|
|
|
+ /deep/ .el-button {
|
|
|
|
+ background-color: transparent;
|
|
|
|
+ border-radius: 0 4px 4px 0;
|
|
|
|
+ border-bottom: 1px solid #ebebeb;
|
|
|
|
+ border-right: 1px solid #ebebeb;
|
|
|
|
+ border-top: 1px solid #ebebeb;
|
|
|
|
+ height: 30px;
|
|
|
|
+ width: 30px;
|
|
|
|
+ text-align: center;
|
|
|
|
+ vertical-align: top;
|
|
|
|
+ margin-top: -5px;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
</style>
|
|
</style>
|