后端
/**
* 获取血压规则已绑定的用户
*/
@PostMapping("/boundUserInfo")
public TableDataInfo getBoundUserInfo(@RequestBody Map<String, Object> map) {
startPage();
List<SysUser> sysUsers = iSysUserService.selectBoundUserInfoByPlanId(map);
return getDataTable(sysUsers);
}
/**
* 获取血压规则未绑定的用户
*/
@PostMapping("/unboundUserInfo")
public TableDataInfo getUnboundUserInfo(@RequestBody Map<String, Object> map) {
startPage();
List<SysUser> sysUsers = iSysUserService.selectUnboundUserInfoByPlanId(map);
return getDataTable(sysUsers);
}
/**
* 血压规则绑定用户
*/
@Log(title = "血压规则绑定用户", businessType = BusinessType.INSERT)
@PostMapping("/addBoundUser")
public AjaxResult addBoundUser(@RequestBody Map<String, Object> map) {
bloodPlanService.removeBoundUsers(map);//重新绑定的时候,解绑之前所有已绑定的用户。
return toAjax(bloodPlanService.addBoundUser(map));
}
/**
* 血压规则解绑用户
*/
@Log(title = "血压规则解绑用户", businessType = BusinessType.DELETE)
@PostMapping("/removeBoundUser")
public AjaxResult removeBoundUser(@RequestBody Map<String, Object> map) {
return toAjax(bloodPlanService.removeBoundUser(map));
}
<insert id="addBoundUser" parameterType="Map">
insert into sys_blood_plan_user(blood_plan_id,user_id) values
<foreach collection="ids" item="id" separator=",">
((SELECT id FROM `sys_blood_plan` WHERE id=#{planId}), #{id})
</foreach>
</insert>
<delete id="removeBoundUser" parameterType="Map">
delete from sys_blood_plan_user where blood_plan_id=(SELECT id FROM `sys_blood_plan` WHERE id=#{planId})
and user_id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="removeBoundUsers" parameterType="Map">
delete from sys_blood_plan_user where user_id in
<foreach collection="ids" index="index" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
Index
<template>
<div class="app-container">
<!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="血压正常时间" prop="normalBloodGood">
<el-input
v-model="queryParams.normalBloodGood"
placeholder="请输入血压正常时间"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="检测间隔时间" prop="bloodIntervalTime">
<el-input
v-model="queryParams.bloodIntervalTime"
placeholder="请输入检测间隔时间"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<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-form-item>
</el-form> -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
v-hasPermi="['syphPlan:syphPlan:add']">新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
v-hasPermi="['syphPlan:syphPlan:edit']">修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
v-hasPermi="['syphPlan:syphPlan:remove']">删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
v-hasPermi="['syphPlan:syphPlan:export']">导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="syphPlanList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="规则类型" align="center" prop="ruleType" /> -->
<!-- <el-table-column label="血压正常时间" align="center" prop="normalBloodGood" /> -->
<el-table-column label="血压检测间隔时间" align="center" prop="bloodIntervalTime">
<template #default="scope">
{{ scope.row.bloodIntervalTime }} 天
</template>
</el-table-column>
<el-table-column label="已绑定用户" align="center">
<template #default="scope">
<el-button size="medium" type="primary" @click="openUserInforDialog(scope.row)">查看</el-button>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
v-hasPermi="['syphPlan:syphPlan:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
v-hasPermi="['syphPlan:syphPlan:remove']">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
@pagination="getList" />
<!-- 添加或修改血压计划设置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<!-- <el-form-item label="规则类型" prop="ruleType">
<el-input v-model="form.ruleType" placeholder="请输入规则类型" />
</el-form-item> -->
<!-- <el-form-item label="血压正常时间" prop="normalBloodGood">
<el-input v-model="form.normalBloodGood" placeholder="请输入血压正常时间" />
</el-form-item> -->
<el-form-item label="血压检测间隔时间" prop="bloodIntervalTime">
<el-input v-model="form.bloodIntervalTime" placeholder="请输入血压检测间隔时间" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<el-dialog title="已绑定用户列表" :visible.sync="userDialogVisible" v-if="userDialogVisible" width="60%" append-to-body>
<!-- 传递给子组件的值 -->
<boundUser :planId="planId"></boundUser>
</el-dialog>
</div>
</template>
<script>
import { listSyphPlan, getSyphPlan, delSyphPlan, addSyphPlan, updateSyphPlan } from "@/api/syphPlan/syphPlan";
import boundUser from "./boundUserInfo";
export default {
name: "SyphPlan",
components: { boundUser },
data() {
return {
// 控制弹框是否展示标识
userDialogVisible: false,
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 血压计划设置表格数据
syphPlanList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
ruleType: null,
normalBloodGood: null,
bloodIntervalTime: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
}
};
},
created() {
this.getList();
},
methods: {
/** 打开已绑定用户信息弹出层 */
openUserInforDialog(row) {
this.userDialogVisible = true;
this.planId = row.id;
},
/** 查询血压计划设置列表 */
getList() {
this.loading = true;
listSyphPlan(this.queryParams).then(response => {
this.syphPlanList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
ruleType: 3,
normalBloodGood: null,
bloodIntervalTime: null,
createTime: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加血压计划设置";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getSyphPlan(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改血压计划设置";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateSyphPlan(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addSyphPlan(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除血压计划设置编号为"' + ids + '"的数据项?').then(function () {
return delSyphPlan(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => { });
},
/** 导出按钮操作 */
handleExport() {
this.download('syphPlan/syphPlan/export', {
...this.queryParams
}, `syphPlan_${new Date().getTime()}.xlsx`)
}
}
};
</script>
boundUserInfo
<template>
<div class="app-container">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
ref="tree"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
<el-col :span="20" :xs="24">
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="用户姓名" prop="nickName">
<el-input
v-model="queryParams.nickName"
placeholder="请输入用户姓名"
clearable
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<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-form-item>
</el-form>
<!--工具栏-->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>绑定新用户</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>解绑</el-button
>
</el-col>
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<!-- 绑定用户信息表格 -->
<el-table
v-loading="loading"
:data="userInfoList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户名称" align="center" prop="nickName" />
<el-table-column label="用户工号" align="center" prop="jobNumber" />
<el-table-column label="工号" align="center" prop="jobNumber" />
<el-table-column label="角色" align="center" prop="roles">
<template slot-scope="scope">
<span v-for="(val, index) in scope.row.roles" :key="index">
{{ val.roleName }}
</span>
</template>
</el-table-column>
<el-table-column label="IC卡卡号" align="center" prop="cardkey" />
<el-table-column label="车牌号" align="center" prop="keyBusNumber" />
<el-table-column label="部门" align="center" prop="dept.deptName" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>
解除绑定
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
<el-dialog
title="未绑定用户列表"
:visible.sync="userDialogVisible"
v-if="userDialogVisible"
width="60%"
append-to-body
>
<!-- 传递给子组件的值 -->
<unboundUser :planId="planId" ref="unboundUserRef" @handleSaveSuccess="getList"></unboundUser>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="banding()">绑定</el-button>
<el-button @click="cancel()">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { deptTreeSelect } from "@/api/system/user";
import { boundUserInfo, removeBoundUser } from "@/api/syphPlan/syphPlan";
import unboundUser from "./unboundUserInfo";
export default {
name: "boundUser",
props: ["planId"],
components: { unboundUser },
data() {
return {
// 部门树选项
deptOptions: undefined,
defaultProps: {
children: "children",
label: "label",
},
// 遮罩层
loading: true,
// 选中用户ID数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 已绑定用户信息表格数据
userInfoList: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
planId: null,
nickName: undefined,
deptId: undefined,
},
// 控制弹框是否展示标识
userDialogVisible: false,
// 解绑用户参数
removeParams: {
planId: null,
ids: [],
},
};
},
created() {
this.getList();
this.getDeptTree();
},
methods: {
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then((response) => {
this.deptOptions = response.data;
});
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.getList();
},
/** 查询已绑定用户 */
getList() {
this.loading = true;
this.queryParams.planId = this.planId;
boundUserInfo(this.queryParams).then((response) => {
this.userInfoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 用户列表多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 绑定按钮
banding(){
this.$refs.unboundUserRef.handleAdd();
},
// 取消按钮
cancel() {
this.userDialogVisible = false;
this.getList();
},
/** 绑定按钮操作 */
handleAdd() {
this.userDialogVisible = true;
},
/** 解除绑定按钮操作 */
handleDelete(row) {
if (row.userId != null) {
this.ids = [];
this.ids.push(row.userId);
}
this.removeParams.ids = this.ids;
this.removeParams.planId = this.planId;
const removeParams = this.removeParams;
this.$modal
.confirm("是否确认解绑勾选用户?")
.then(function () {
return removeBoundUser(removeParams);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("解绑成功");
})
.catch(() => {});
},
},
};
</script>
unboundUserInfo
<template>
<div class="app-container">
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
<div class="head-container">
<el-tree
:data="deptOptions"
:props="defaultProps"
:expand-on-click-node="false"
ref="tree"
default-expand-all
highlight-current
@node-click="handleNodeClick"
/>
</div>
</el-col>
<el-col :span="20" :xs="24">
<!--工具栏-->
<el-form
:model="queryParams"
ref="queryForm"
size="small"
:inline="true"
v-show="showSearch"
label-width="68px"
>
<el-form-item label="用户姓名" prop="nickName">
<el-input
v-model="queryParams.nickName"
placeholder="请输入用户姓名"
clearable
style="width: 150px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<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-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['system:info:add']"
>绑定</el-button
>
</el-col> -->
<right-toolbar
:showSearch.sync="showSearch"
@queryTable="getList"
></right-toolbar>
</el-row>
<!-- 绑定用户信息表格 -->
<el-table
v-loading="loading"
:data="userInfoList"
@selection-change="handleSelectionChange"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="用户名称" align="center" prop="nickName" />
<el-table-column label="用户工号" align="center" prop="jobNumber" />
<el-table-column label="工号" align="center" prop="jobNumber" />
<el-table-column label="角色" align="center" prop="roles">
<template slot-scope="scope">
<span v-for="(val, index) in scope.row.roles" :key="index">
{{ val.roleName }}
</span>
</template>
</el-table-column>
<el-table-column label="IC卡卡号" align="center" prop="cardkey" />
<el-table-column label="车牌号" align="center" prop="keyBusNumber" />
<el-table-column label="部门" align="center" prop="dept.deptName" />
<el-table-column
label="操作"
align="center"
class-name="small-padding fixed-width"
>
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-circle-plus-outline"
@click="handleAdd(scope.row)"
>
绑定
</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
</el-col>
</el-row>
</div>
</template>
<script>
import { deptTreeSelect } from "@/api/system/user";
import { addBoundUser, unboundUserInfo } from "@/api/syphPlan/syphPlan";
export default {
name: "unboundUserInfo",
props: ["planId"],
data() {
return {
// 部门树选项
deptOptions: undefined,
defaultProps: {
children: "children",
label: "label",
},
// 遮罩层
loading: true,
// 选中用户ID数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 未绑定用户信息表格数据
userInfoList: [],
//
queryParams: {
pageNum: 1,
pageSize: 10,
planId: null,
nickName: undefined,
deptId: undefined,
},
// 绑定用户参数
addParams: {
planId: null,
ids: [],
},
};
},
created() {
this.getList();
this.getDeptTree();
},
methods: {
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 查询部门下拉树结构 */
getDeptTree() {
deptTreeSelect().then((response) => {
this.deptOptions = response.data;
});
},
// 节点单击事件
handleNodeClick(data) {
this.queryParams.deptId = data.id;
this.getList();
},
/** 查询未绑定用户 */
getList() {
this.loading = true;
this.queryParams.planId = this.planId;
unboundUserInfo(this.queryParams).then((response) => {
this.userInfoList = response.rows;
this.total = response.total;
this.loading = false;
});
},
// 用户列表多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map((item) => item.userId);
this.single = selection.length !== 1;
this.multiple = !selection.length;
},
/** 绑定按钮操作 */
handleAdd(row) {
if (row != null && row.userId != null) {
this.ids.push(row.userId);
}
this.addParams.ids = this.ids;
this.addParams.planId = this.planId;
const addParams = this.addParams;
const vm=this;
this.$modal
.confirm("是否确认绑定勾选用户?")
.then(function () {
return addBoundUser(addParams);
})
.then(() => {
this.getList();
this.$modal.msgSuccess("绑定成功");
vm.$emit("handleSaveSuccess");
})
.catch(() => {});
},
},
};
</script>