selectUser.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <!-- 授权用户 -->
  3. <el-dialog title="选择用户" :visible.sync="visible" width="1540px" top="5vh" append-to-body class="role-select-user"
  4. :close-on-click-modal="false">
  5. <el-form :model="queryParams" ref="queryForm" :inline="true">
  6. <el-form-item label="姓名" prop="nickName">
  7. <el-input
  8. v-model="queryParams.nickName"
  9. placeholder="请输入姓名"
  10. maxlength="10"
  11. clearable
  12. size="small"
  13. />
  14. </el-form-item>
  15. <!--<el-form-item label="身份" prop="deptId">-->
  16. <!--<el-select v-model="queryParams.deptId" placeholder="请选择身份" clearable size="small">-->
  17. <!--<el-option-->
  18. <!--v-for="dict in userTypeList"-->
  19. <!--:key="dict.deptId"-->
  20. <!--:label="dict.deptName"-->
  21. <!--:value="dict.deptId"-->
  22. <!--&gt;</el-option>-->
  23. <!--</el-select>-->
  24. <!--</el-form-item>-->
  25. <el-form-item label="工号/学号" prop="userName">
  26. <el-input
  27. v-model="queryParams.userName"
  28. placeholder="请输入工号/学号"
  29. clearable
  30. maxlength="20"
  31. size="small"
  32. style="width: 240px"
  33. />
  34. </el-form-item>
  35. <el-form-item label="联系方式" prop="phonenumber">
  36. <el-input
  37. v-model="queryParams.phonenumber"
  38. placeholder="请输入联系方式"
  39. clearable
  40. size="small"
  41. />
  42. </el-form-item>
  43. <el-form-item label="学院" prop="deptId">
  44. <el-select v-model="queryParams.deptId" placeholder="请选择学院" clearable size="small">
  45. <el-option
  46. v-for="dict in deptOptions"
  47. :key="dict.deptId"
  48. :label="dict.deptName"
  49. :value="dict.deptId"
  50. ></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item>
  54. <p class="inquire-button-one" @click="handleQuery">查询</p>
  55. <p class="reset-button-one" @click="resetQuery">重置</p>
  56. </el-form-item>
  57. </el-form>
  58. <!--<div class="sheet-expand-box">-->
  59. <!--<i class="el-icon-warning" style="color:#0045AF;"></i>-->
  60. <!--<p class="color_99">已选择 {{selectedNum}} 项</p>-->
  61. <!--<p class="color_one cursor_hover" @click="selectPage">全选本页</p>-->
  62. <!--<p class="color_warn cursor_hover" @click="clearSelection">清除选项</p>-->
  63. <!--<p class="color_one border-solid-color-one cursor_hover"-->
  64. <!--@click="selectAll">选择全部</p>-->
  65. <!--</div>-->
  66. <el-row>
  67. <el-table @row-click="clickRow" border ref="table" :data="userList" @selection-change="handleSelectionChange" height="400px" :row-key="getRowKeys">
  68. <el-table-column type="selection" width="55" align="center"></el-table-column>
  69. <!--<el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />-->
  70. <el-table-column label="姓名" prop="nickName" align="left" :show-overflow-tooltip="true" />
  71. <!--<el-table-column label="身份" prop="userType" align="left" :show-overflow-tooltip="true" />-->
  72. <el-table-column label="工号/学号" prop="userName" align="left" :show-overflow-tooltip="true" />
  73. <!--<el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />-->
  74. <el-table-column label="联系方式" prop="phonenumber" align="left" :show-overflow-tooltip="true" />
  75. <el-table-column label="学院" prop="deptName" align="left" :show-overflow-tooltip="true" />
  76. <!--<el-table-column label="状态" align="center" prop="status">-->
  77. <!--<template slot-scope="scope">-->
  78. <!--<dict-tag :options="statusOptions" :value="scope.row.status"/>-->
  79. <!--</template>-->
  80. <!--</el-table-column>-->
  81. <!--<el-table-column label="创建时间" align="center" prop="createTime" width="180">-->
  82. <!--<template slot-scope="scope">-->
  83. <!--<span>{{ parseTime(scope.row.createTime) }}</span>-->
  84. <!--</template>-->
  85. <!--</el-table-column>-->
  86. </el-table>
  87. <pagination :page-sizes="[20, 30, 40, 50]"
  88. v-show="total>0"
  89. :total="total"
  90. layout="total, prev, pager, next, sizes, jumper"
  91. :page.sync="queryParams.pageNum"
  92. :limit.sync="queryParams.pageSize"
  93. @pagination="getList"
  94. />
  95. </el-row>
  96. <div slot="footer" class="dialog-footer">
  97. <el-button @click="visible = false">取 消</el-button>
  98. <el-button type="primary" @click="handleSelectUser">确 定</el-button>
  99. </div>
  100. </el-dialog>
  101. </template>
  102. <script>
  103. // import { unallocatedUserList, authUserSelectAll } from "@/api/system/role";
  104. import { noJoinPositionByList, bingUserByPosition } from "@/api/system/user";
  105. import { listDepartments } from "@/api/system/dept";
  106. export default {
  107. props: {
  108. // 角色编号
  109. postId: {}
  110. },
  111. data() {
  112. return {
  113. // 遮罩层
  114. visible: false,
  115. // 选中数组值
  116. userIds: [],
  117. //学院
  118. deptOptions:[],
  119. // 角色身份
  120. userTypeList:[
  121. {
  122. deptId:"11",
  123. deptName:"教职工"
  124. },
  125. {
  126. deptId:"22",
  127. deptName:"学生"
  128. },
  129. ],
  130. // 总条数
  131. total: 0,
  132. // 未授权用户数据
  133. userList: [],
  134. // 状态数据字典
  135. statusOptions: [],
  136. // 查询参数
  137. queryParams: {
  138. pageNum: 1,
  139. pageSize:20,
  140. postId: '',
  141. nickName: '',
  142. userName: '',
  143. phonenumber: '',
  144. deptId: '',
  145. },
  146. //表格扩展选择器---需要在@selection-change绑定的方法内监控selection数组长度
  147. selectedNum:0,
  148. };
  149. },
  150. created() {
  151. this.getDicts("sys_normal_disable").then(response => {
  152. this.statusOptions = response.data;
  153. });
  154. console.log(this.postId)
  155. this.getDeptList();
  156. },
  157. methods: {
  158. /** 查询学院列表 */
  159. getDeptList()
  160. {
  161. listDepartments().then(response => {
  162. // this.deptOptions = response.data;
  163. this.$set(this, 'deptOptions', response.data)
  164. });
  165. },
  166. selectAll(){
  167. },
  168. //=========表格扩展选择器方法---开始=========
  169. //选择本页
  170. selectPage(){
  171. console.log(this.$refs.multipleTable)
  172. this.$refs.table.toggleAllSelection()
  173. // console.log(this.$refs.multipleTable.selection)
  174. },
  175. //清除选择
  176. clearSelection(){
  177. this.$refs.table.clearSelection()
  178. },
  179. /*===记录勾选数据===
  180. 需要再el-table 添加 :row-key="getRowKeys"
  181. 需要在selection 添加 :reserve-selection="true"
  182. */
  183. getRowKeys(row) {
  184. return row.id
  185. },
  186. //=========表格扩展选择器方法---结束=========
  187. // 显示弹框
  188. show() {
  189. this.queryParams.postId = this.postId;
  190. this.queryParams.pageNum = 1;
  191. this.queryParams.nickName = '';
  192. this.queryParams.userName = '';
  193. this.queryParams.phonenumber = '';
  194. this.queryParams.deptId = '';
  195. this.getList();
  196. this.visible = true;
  197. },
  198. clickRow(row) {
  199. this.$refs.table.toggleRowSelection(row);
  200. },
  201. // 多选框选中数据
  202. handleSelectionChange(selection) {
  203. this.userIds = selection.map(item => item.userId);
  204. },
  205. // 查询表数据
  206. getList() {
  207. noJoinPositionByList(this.queryParams).then(res => {
  208. this.userList = res.rows;
  209. this.total = res.total;
  210. });
  211. },
  212. /** 搜索按钮操作 */
  213. handleQuery() {
  214. this.queryParams.pageNum = 1;
  215. this.getList();
  216. },
  217. /** 重置按钮操作 */
  218. resetQuery() {
  219. // this.resetForm("queryForm");
  220. this.$set(this,'queryParams',{
  221. pageNum: 1,
  222. pageSize:20,
  223. postId: '',
  224. nickName: '',
  225. userName: '',
  226. phonenumber: '',
  227. deptId: '',
  228. });
  229. this.handleQuery();
  230. },
  231. /** 选择授权用户操作 */
  232. handleSelectUser() {
  233. if(!this.userIds[0]){
  234. this.msgError('请选择要添加的用户')
  235. return
  236. }
  237. const postId = this.queryParams.postId;
  238. const userIds = this.userIds.join(",");
  239. bingUserByPosition({ position: postId, userIds: userIds }).then(res => {
  240. this.msgSuccess(res.msg);
  241. if (res.code === 200) {
  242. this.visible = false;
  243. this.$emit("ok");
  244. }
  245. });
  246. }
  247. }
  248. };
  249. </script>
  250. <style scoped lang="scss">
  251. .role-select-user {
  252. .sheet-expand-box{
  253. height:40px;
  254. display:flex;
  255. background:rgba(1,131,250,0.1);
  256. border-radius: 5px;
  257. margin-bottom:18px;
  258. font-size:14px;
  259. i{
  260. margin:10px 16px 0 14px;
  261. height:20px;
  262. width:20px;
  263. font-size:20px;
  264. display: block;
  265. }
  266. p{
  267. margin:0;
  268. }
  269. p:nth-child(2){
  270. width:132px;
  271. font-size:14px;
  272. height:40px;
  273. line-height:40px;
  274. }
  275. p:nth-child(3){
  276. width:60px;
  277. font-size:14px;
  278. height:40px;
  279. line-height:40px;
  280. margin-right:20px;
  281. }
  282. p:nth-child(4){
  283. width:60px;
  284. font-size:14px;
  285. height:40px;
  286. line-height:40px;
  287. margin-right:20px;
  288. }
  289. p:nth-child(5){
  290. font-size:14px;
  291. line-height:30px;
  292. width: 100px;
  293. height: 30px;
  294. border-radius: 6px;
  295. text-align: center;
  296. margin-top:5px;
  297. margin-right:20px;
  298. }
  299. p:nth-child(6){
  300. font-size:14px;
  301. line-height:30px;
  302. width: 100px;
  303. height: 30px;
  304. border-radius: 6px;
  305. text-align: center;
  306. margin-top:5px;
  307. }
  308. }
  309. }
  310. </style>