|
|
@@ -4,68 +4,170 @@
|
|
|
|
|
|
<div class="head">
|
|
|
<div class="head-img">
|
|
|
- <img src="../../../public/images/img-1.png" />
|
|
|
+ <img src="../../../public/images/img-1.png">
|
|
|
</div>
|
|
|
<div class="head-info">用户与组绑定</div>
|
|
|
</div>
|
|
|
|
|
|
<!-- 搜索区域 -->
|
|
|
<div class="form-head">
|
|
|
- <span>姓名:</span>
|
|
|
- <span class="input">
|
|
|
+ <span>
|
|
|
<el-input
|
|
|
- v-model="listQuery.name"
|
|
|
- placeholder="请输入姓名"
|
|
|
+ v-model="listQuery.key"
|
|
|
+ size="mini"
|
|
|
+ placeholder="请输入姓名,手机号或卡号"
|
|
|
clearable
|
|
|
- @clear="handleChangeFilter"
|
|
|
- @keyup.enter.native="handleFilter"
|
|
|
- >
|
|
|
- </el-input>
|
|
|
+ />
|
|
|
</span>
|
|
|
|
|
|
- <span>卡号:</span>
|
|
|
- <span class="input">
|
|
|
- <el-input
|
|
|
- v-model="listQuery.cardNumber"
|
|
|
- placeholder="请输入卡号"
|
|
|
- clearable
|
|
|
- @clear="handleChangeFilter"
|
|
|
- @keyup.enter.native="handleFilter"
|
|
|
- >
|
|
|
- </el-input>
|
|
|
- </span>
|
|
|
+ <span style="margin-left: 15px">学院:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="listQuery.college"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="请选择学院"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in collegeList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.name"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <span style="margin-left: 15px">专业:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="listQuery.professor"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="请选择专业"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in professorList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.name"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <span style="margin-left: 15px">年级:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="listQuery.nj"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="请选择年级"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in njList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.name"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
|
|
|
- <el-button type="primary" size="mini" class="button" @click="handleFilter"
|
|
|
- >查询</el-button
|
|
|
+ <span style="margin-left: 15px">班级:</span>
|
|
|
+ <el-select
|
|
|
+ v-model="listQuery.className"
|
|
|
+ clearable
|
|
|
+ size="mini"
|
|
|
+ placeholder="请选择班级"
|
|
|
>
|
|
|
+ <el-option
|
|
|
+ v-for="(item, index) in classNameList"
|
|
|
+ :key="index"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.name"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ style="margin-left: 20px"
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ class="button"
|
|
|
+ @click="handleFilter"
|
|
|
+ >
|
|
|
+ 查询
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ <!-- <el-button
|
|
|
+ style="margin-left: 20px"
|
|
|
+ type="primary"
|
|
|
+ size="mini"
|
|
|
+ class="button"
|
|
|
+ >
|
|
|
+ 导出
|
|
|
+ </el-button> -->
|
|
|
</div>
|
|
|
|
|
|
<!-- 表格区域 -->
|
|
|
<div class="form">
|
|
|
<el-table :data="list">
|
|
|
- <el-table-column label="姓名" align="center" width="440px">
|
|
|
+ <el-table-column label="姓名" align="center">
|
|
|
<template slot-scope="{ row }">
|
|
|
<span>{{ row.name }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column label="卡号" align="center" width="440px">
|
|
|
+ <el-table-column label="手机号" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span>{{ row.mobile }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="卡号" align="center" show-overflow-tooltip>
|
|
|
<template slot-scope="{ row }">
|
|
|
<span>{{ row.cardNumber }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column label="操作" width="440px" align="center">
|
|
|
+ <el-table-column label="学院" align="center">
|
|
|
<template slot-scope="{ row }">
|
|
|
- <el-button type="text" size="small" @click="checkGroup(row)"
|
|
|
- >查看当前分组</el-button
|
|
|
- >
|
|
|
- <el-button type="text" size="small" @click="bindGroup(row)"
|
|
|
- >绑定分组</el-button
|
|
|
- >
|
|
|
- <el-button type="text" size="small" @click="unbindGroup(row)"
|
|
|
- >解绑分组</el-button
|
|
|
- >
|
|
|
+ <span>{{ row.college }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="专业" align="center" show-overflow-tooltip>
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span>{{ row.professor }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="年级" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span>{{ row.nj }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="班级" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span>{{ row.classname }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="当前分组" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <span style="color: #1890ff">{{ row.group }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <el-table-column label="操作" width="300px" align="center">
|
|
|
+ <template slot-scope="{ row }">
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ @click="checkGroup(row)"
|
|
|
+ >查看当前分组</el-button>
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ @click="bindGroup(row)"
|
|
|
+ >绑定分组</el-button>
|
|
|
+ <el-button
|
|
|
+ type="text"
|
|
|
+ size="small"
|
|
|
+ @click="unbindGroup(row)"
|
|
|
+ >解绑分组</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -95,9 +197,9 @@
|
|
|
<el-form-item label="已绑定分组:" class="switch-button-item">
|
|
|
<span>
|
|
|
<el-tag
|
|
|
- class="groupclass"
|
|
|
v-for="item in groupWithDeviceList"
|
|
|
:key="item.idGroup"
|
|
|
+ class="groupclass"
|
|
|
>
|
|
|
{{ item.groupName }}
|
|
|
</el-tag>
|
|
|
@@ -134,8 +236,7 @@
|
|
|
:key="item.id"
|
|
|
:label="item.name"
|
|
|
:value="item.id"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-col>
|
|
|
</el-form-item>
|
|
|
@@ -167,8 +268,7 @@
|
|
|
type="text"
|
|
|
size="small"
|
|
|
@click="deleteGroup(row, $index)"
|
|
|
- >解绑</el-button
|
|
|
- >
|
|
|
+ >解绑</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
@@ -177,37 +277,43 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import Pagination from "@/components/Pagination";
|
|
|
+import Pagination from '@/components/Pagination'
|
|
|
import {
|
|
|
- fetchUserList,
|
|
|
fetchGroupList,
|
|
|
- editGroup,
|
|
|
searchList,
|
|
|
- fetchList,
|
|
|
bindGroups,
|
|
|
deleteGroups,
|
|
|
checkGroups,
|
|
|
-} from "@/api/userWithGroup";
|
|
|
+ getList
|
|
|
+} from '@/api/userWithGroup'
|
|
|
+import { getChooseList } from '@/api/usermanagement'
|
|
|
export default {
|
|
|
components: {
|
|
|
- Pagination,
|
|
|
+ Pagination
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ collegeList: [],
|
|
|
+ njList: [],
|
|
|
+ professorList: [],
|
|
|
+ classNameList: [],
|
|
|
list: [],
|
|
|
groupList: [],
|
|
|
groupWithDeviceList: [],
|
|
|
temp: {
|
|
|
- userName: "",
|
|
|
- cardNumber: "",
|
|
|
- groupsId: [],
|
|
|
+ userName: '',
|
|
|
+ cardNumber: '',
|
|
|
+ groupsId: []
|
|
|
},
|
|
|
- total: 0, //数据的总数//
|
|
|
+ total: 0, // 数据的总数//
|
|
|
listQuery: {
|
|
|
- page: 1, //当前在第几页//
|
|
|
- limit: 8, //一页几条//
|
|
|
- name: "",
|
|
|
- cardNumber: "",
|
|
|
+ page: 1, // 当前在第几页//
|
|
|
+ limit: 8, // 一页几条//
|
|
|
+ key: '', // 关键字 姓名 手机号 卡号
|
|
|
+ college: '', // 学院
|
|
|
+ nj: '', // 年级
|
|
|
+ professor: '', // 专业
|
|
|
+ className: '' // 班级
|
|
|
},
|
|
|
dialogCheckGroups: false,
|
|
|
dialogBindGroup: false,
|
|
|
@@ -216,121 +322,138 @@ export default {
|
|
|
groupsId: [
|
|
|
{
|
|
|
required: true,
|
|
|
- message: "请选择分组",
|
|
|
- trigger: "change",
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- };
|
|
|
+ message: '请选择分组',
|
|
|
+ trigger: 'change'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
- this.getUserList();
|
|
|
- this.getgroupList();
|
|
|
+ this.getUserList()
|
|
|
+ this.getgroupList()
|
|
|
+ // 获取学院
|
|
|
+ this.getCollege(1)
|
|
|
+ // 获取专业
|
|
|
+ this.getProfessor(3)
|
|
|
+ // 获取年级
|
|
|
+ this.getNj(2)
|
|
|
+ // 获取班级
|
|
|
+ this.getClassName(4)
|
|
|
},
|
|
|
methods: {
|
|
|
getUserList() {
|
|
|
- if (this.listQuery.name || this.listQuery.cardNumber) {
|
|
|
- searchList(this.listQuery).then((response) => {
|
|
|
- this.list = response.data;
|
|
|
- this.total = response.total;
|
|
|
- });
|
|
|
- } else {
|
|
|
- fetchUserList({
|
|
|
- page: this.listQuery.page,
|
|
|
- limit: this.listQuery.limit,
|
|
|
- }).then((response) => {
|
|
|
- this.list = response.data;
|
|
|
- this.total = response.total;
|
|
|
- });
|
|
|
- }
|
|
|
+ getList(this.listQuery).then((response) => {
|
|
|
+ console.log(response)
|
|
|
+
|
|
|
+ this.list = response.data
|
|
|
+ this.total = response.total
|
|
|
+ })
|
|
|
},
|
|
|
getgroupList() {
|
|
|
- fetchGroupList({ page: this.listQuery.page, limit: "999" }).then(
|
|
|
+ fetchGroupList({ page: this.listQuery.page, limit: '999' }).then(
|
|
|
(response) => {
|
|
|
- this.groupList = response.data;
|
|
|
+ this.groupList = response.data
|
|
|
}
|
|
|
- );
|
|
|
+ )
|
|
|
+ },
|
|
|
+ getCollege(name) {
|
|
|
+ getChooseList({ name }).then((response) => {
|
|
|
+ // console.log(response);
|
|
|
+ this.collegeList = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getProfessor(name) {
|
|
|
+ getChooseList({ name }).then((response) => {
|
|
|
+ // console.log(response);
|
|
|
+ this.professorList = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getNj(name) {
|
|
|
+ getChooseList({ name }).then((response) => {
|
|
|
+ // console.log(response);
|
|
|
+ this.njList = response.data
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getClassName(name) {
|
|
|
+ getChooseList({ name }).then((response) => {
|
|
|
+ // console.log(response);
|
|
|
+ this.classNameList = response.data
|
|
|
+ })
|
|
|
},
|
|
|
checkGroup(row) {
|
|
|
- this.temp = Object.assign({}, row);
|
|
|
+ this.temp = Object.assign({}, row)
|
|
|
checkGroups({ userId: row.id }).then((response) => {
|
|
|
- this.groupWithDeviceList = response.data;
|
|
|
- });
|
|
|
- this.dialogCheckGroups = true;
|
|
|
+ this.groupWithDeviceList = response.data
|
|
|
+ })
|
|
|
+ this.dialogCheckGroups = true
|
|
|
},
|
|
|
bindGroup(row) {
|
|
|
- this.temp = Object.assign({}, row);
|
|
|
- this.dialogBindGroup = true;
|
|
|
+ this.temp = Object.assign({}, row)
|
|
|
+ this.dialogBindGroup = true
|
|
|
this.$nextTick(() => {
|
|
|
- this.$refs["dataForm"].clearValidate();
|
|
|
- });
|
|
|
+ this.$refs['dataForm'].clearValidate()
|
|
|
+ })
|
|
|
},
|
|
|
updateData() {
|
|
|
- this.$refs["dataForm"].validate((valid) => {
|
|
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- const tempData = Object.assign({}, this.temp);
|
|
|
+ const tempData = Object.assign({}, this.temp)
|
|
|
bindGroups({
|
|
|
id: tempData.id,
|
|
|
- groups: tempData.groupsId,
|
|
|
+ groups: tempData.groupsId
|
|
|
}).then(() => {
|
|
|
- this.dialogBindGroup = false;
|
|
|
+ this.dialogBindGroup = false
|
|
|
this.$notify({
|
|
|
- title: "绑定分组成功",
|
|
|
- type: "success",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- });
|
|
|
+ title: '绑定分组成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ })
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
unbindGroup(row) {
|
|
|
- this.temp = Object.assign({}, row);
|
|
|
+ this.temp = Object.assign({}, row)
|
|
|
checkGroups({ userId: row.id }).then((response) => {
|
|
|
- this.groupWithDeviceList = response.data;
|
|
|
- });
|
|
|
- this.dialogUnbindGroup = true;
|
|
|
+ this.groupWithDeviceList = response.data
|
|
|
+ })
|
|
|
+ this.dialogUnbindGroup = true
|
|
|
},
|
|
|
deleteGroup(row, index) {
|
|
|
- console.log(row, index);
|
|
|
- if (confirm("确定解绑吗?")) {
|
|
|
+ console.log(row, index)
|
|
|
+ if (confirm('确定解绑吗?')) {
|
|
|
deleteGroups({
|
|
|
id: this.temp.id,
|
|
|
- groups: [row.idGroup],
|
|
|
+ groups: [row.idGroup]
|
|
|
}).then(() => {
|
|
|
this.$notify({
|
|
|
- title: "解绑成功",
|
|
|
- type: "success",
|
|
|
- duration: 1500,
|
|
|
- });
|
|
|
- this.groupWithDeviceList.splice(index, 1);
|
|
|
- });
|
|
|
+ title: '解绑成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1500
|
|
|
+ })
|
|
|
+ this.groupWithDeviceList.splice(index, 1)
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
handleChangeFilter() {
|
|
|
if (!this.listQuery.name && !this.listQuery.cardNumber) {
|
|
|
- this.getUserList();
|
|
|
+ this.getUserList()
|
|
|
} else {
|
|
|
searchList(this.listQuery).then((response) => {
|
|
|
- this.list = response.data;
|
|
|
- this.total = response.total;
|
|
|
- });
|
|
|
+ this.list = response.data
|
|
|
+ this.total = response.total
|
|
|
+ })
|
|
|
}
|
|
|
},
|
|
|
handleFilter() {
|
|
|
- if (!this.listQuery.name && !this.listQuery.cardNumber) {
|
|
|
- alert("请输入搜索条件");
|
|
|
- } else {
|
|
|
- let temp = Object.assign({}, this.listQuery);
|
|
|
- temp.page = 1;
|
|
|
- searchList(temp).then((response) => {
|
|
|
- this.list = response.data;
|
|
|
- this.total = response.total;
|
|
|
- });
|
|
|
- this.listQuery.page = 1;
|
|
|
- }
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ this.list = []
|
|
|
+ this.total = 0
|
|
|
+ this.listQuery.page = 1
|
|
|
+ this.getUserList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -370,20 +493,11 @@ export default {
|
|
|
}
|
|
|
|
|
|
.form-head {
|
|
|
- margin: 0 40px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ margin: 20px 40px;
|
|
|
width: 1504px;
|
|
|
- line-height: 118px;
|
|
|
font-size: 9px;
|
|
|
-
|
|
|
- .input {
|
|
|
- display: inline-block;
|
|
|
- margin-right: 30px;
|
|
|
- width: 210px;
|
|
|
- }
|
|
|
-
|
|
|
- .button {
|
|
|
- margin-left: 41px;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
.form {
|