对接批量更新用户状态接口

调整用户列表查询条件
master
panqihua 2 years ago
parent dfa31d833a
commit 2c1d292491
  1. 9
      src/api/system/user.js
  2. 84
      src/views/system/user/index.vue

@ -141,3 +141,12 @@ export function phoneSelect(phonenumber) {
method: "get", method: "get",
}); });
} }
//批量更新状态
export function updateStatus(data) {
return request({
url: "/system/user/updateStatus",
method: "put",
params: data,
});
}

@ -5,50 +5,53 @@
<el-col :span="24" :xs="24"> <el-col :span="24" :xs="24">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch"
label-width="68px"> label-width="68px">
<el-form-item label="用户名称" prop="userName"> <el-form-item label="用户昵称" prop="nickName">
<el-input v-model="queryParams.userName" placeholder="请输入用户名称" clearable style="width: 240px" <el-input v-model="queryParams.nickName" placeholder="请输入用户昵称" clearable style="width: 240px"
@keyup.enter.native="handleQuery" />
</el-form-item>
<el-form-item label="ID" prop="userId">
<el-input v-model="queryParams.userId" placeholder="请输入用户ID" clearable style="width: 240px"
@keyup.enter.native="handleQuery" /> @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="手机号码" prop="phonenumber"> <el-form-item label="手机号码" prop="phonenumber">
<el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 240px" <el-input v-model="queryParams.phonenumber" placeholder="请输入手机号码" clearable style="width: 240px"
@keyup.enter.native="handleQuery" /> @keyup.enter.native="handleQuery" />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="性别" prop="sex">
<el-select v-model="queryParams.status" placeholder="用户状态" clearable style="width: 240px"> <el-select v-model="queryParams.sex" placeholder="请选择性别" clearable>
<el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label" <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
:value="dict.value" /> :value="dict.value"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="注册时间">
<el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange" <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker> range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> <el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="用户状态" clearable style="width: 240px">
<el-option v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.label"
:value="dict.value" />
</el-select>
</el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" <el-button type="primary" size="mini" @click="handleAdd" v-hasPermi="['system:user:add']">新增用户</el-button>
v-hasPermi="['system:user:add']">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" <el-button size="mini" v-hasPermi="['system:user:edit']" @click="updateStatusByUserId('0')">批量开启</el-button>
v-hasPermi="['system:user:edit']">修改</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" <el-button size="mini" v-hasPermi="['system:user:edit']" @click="updateStatusByUserId('1')">批量禁用</el-button>
v-hasPermi="['system:user:remove']">删除</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport" <el-button size="mini" @click="handleExport" v-hasPermi="['system:user:export']">导出</el-button>
v-hasPermi="['system:user:import']">导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['system:user:export']">导出</el-button>
</el-col> </el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
</el-row> </el-row>
@ -236,7 +239,7 @@
</template> </template>
<script> <script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect, phoneSelect } from "@/api/system/user"; import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, phoneSelect, updateStatus } from "@/api/system/user";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -265,12 +268,8 @@ export default {
userList: null, userList: null,
// //
title: "", title: "",
//
deptOptions: undefined,
// //
open: false, open: false,
//
deptName: undefined,
// //
initPassword: undefined, initPassword: undefined,
// //
@ -304,10 +303,11 @@ export default {
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
userName: undefined, userId: undefined,
nickName: undefined,
phonenumber: undefined, phonenumber: undefined,
status: undefined, status: undefined,
deptId: undefined sex: undefined
}, },
// //
columns: [ columns: [
@ -345,24 +345,24 @@ export default {
} }
}; };
}, },
watch: {
//
deptName(val) {
this.$refs.tree.filter(val);
}
},
created() { created() {
this.getList(); this.getList();
this.getDeptTree();
this.getConfigKey("sys.user.initPassword").then(response => { this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg; this.initPassword = response.msg;
}); });
}, },
methods: { methods: {
handleSelectPhone(item) { //
debugger updateStatusByUserId(status) {
form.referrerId = item.userId updateStatus({
userIds: this.ids.join(","),
status
}).then(response => {
this.$modal.msgSuccess(`批量${status === "0" ? "开启" : "禁用"}成功`);
this.getList()
})
}, },
//
queryByPhone(queryString, cb) { queryByPhone(queryString, cb) {
phoneSelect(queryString).then(response => { phoneSelect(queryString).then(response => {
const data = response.data.map(item => { const data = response.data.map(item => {
@ -385,12 +385,6 @@ export default {
} }
); );
}, },
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data;
});
},
// //
filterNode(value, data) { filterNode(value, data) {
if (!value) return true; if (!value) return true;
@ -398,7 +392,6 @@ export default {
}, },
// //
handleNodeClick(data) { handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.handleQuery(); this.handleQuery();
}, },
// //
@ -421,7 +414,6 @@ export default {
reset() { reset() {
this.form = { this.form = {
userId: undefined, userId: undefined,
deptId: undefined,
userName: undefined, userName: undefined,
nickName: undefined, nickName: undefined,
password: undefined, password: undefined,
@ -447,8 +439,6 @@ export default {
resetQuery() { resetQuery() {
this.dateRange = []; this.dateRange = [];
this.resetForm("queryForm"); this.resetForm("queryForm");
this.queryParams.deptId = undefined;
this.$refs.tree.setCurrentKey(null);
this.handleQuery(); this.handleQuery();
}, },
// //

Loading…
Cancel
Save