userList.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <!--分级管控/人员列表-->
  2. <template>
  3. <div class="userList" v-if="userOpen">
  4. <el-dialog title="选择用户" :visible.sync="userOpen" width="1500px" append-to-body>
  5. <div class="gradeManage-userList" style="height:626px;display: flex;flex-direction: column">
  6. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
  7. <el-form-item label="姓名" prop="nickName" label-width="80px">
  8. <el-input
  9. style="width:160px;"
  10. maxlength="10"
  11. v-model="queryParams.nickName"
  12. placeholder="请输入姓名"
  13. clearable
  14. size="small"
  15. />
  16. </el-form-item>
  17. <el-form-item label="身份" prop="position" label-width="50px">
  18. <el-select style="width:160px;" v-model="queryParams.position" placeholder="请选择身份" clearable>
  19. <el-option
  20. v-for="dict in typeList"
  21. :key="dict.postId"
  22. :label="dict.postName"
  23. :value="dict.postId"
  24. ></el-option>
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item label="工号/学号" prop="userName" label-width="80px">
  28. <el-input
  29. style="width:160px;"
  30. maxlength="20"
  31. v-model="queryParams.userName"
  32. placeholder="请输入工号/学号"
  33. clearable
  34. size="small"
  35. />
  36. </el-form-item>
  37. <el-form-item label="联系方式" prop="phonenumber" label-width="80px">
  38. <el-input
  39. style="width:160px;"
  40. maxlength="11"
  41. v-model="queryParams.phonenumber"
  42. placeholder="请输入联系方式"
  43. clearable
  44. size="small"
  45. />
  46. </el-form-item>
  47. <el-form-item label="学院" prop="deptName" label-width="80px">
  48. <el-select style="width:160px;" v-model="queryParams.deptId" placeholder="请选择学院" clearable>
  49. <el-option
  50. v-for="dict in deptList"
  51. :key="dict.deptId"
  52. :label="dict.deptName"
  53. :value="dict.deptId"
  54. ></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item>
  58. <p class="inquire-button-one" @click="handleQuery">查询</p>
  59. <p class="reset-button-one" @click="resetQuery">重置</p>
  60. </el-form-item>
  61. </el-form>
  62. <div class="sheet-expand-box" style="height:40px;display:flex;background:rgba(1,131,250,0.1);border-radius: 5px;margin-bottom:18px;font-size:14px;">
  63. <i class="el-icon-warning" style="color:#0045AF;margin:10px 16px 0 14px;height:20px;width:20px;font-size:20px;display: block;"></i>
  64. <p class="color_99" style="margin:0;width:132px;font-size:14px;height:40px;line-height:40px;">已选择 {{selectedNum}} 项</p>
  65. <p class="color_one cursor_hover" style="margin:0;width:60px;font-size:14px;height:40px;line-height:40px;margin-right:20px;" @click="selectPage">全选本页</p>
  66. <p class="color_warn cursor_hover" style="margin:0;width:60px;font-size:14px;height:40px;line-height:40px;margin-right:20px;" @click="clearSelection">清除选项</p>
  67. </div>
  68. <el-table v-loading="loading" border :data="userList" @selection-change="handleSelectionChange" ref="multipleTable" :row-key="getRowKeys">
  69. <el-table-column type="selection" width="55" :reserve-selection="true" align="center" />
  70. <el-table-column label="姓名" align="left" prop="nickName" />
  71. <el-table-column label="身份" align="left" prop="positionName" />
  72. <el-table-column label="工号/学号" align="left" prop="userName" />
  73. <el-table-column label="联系方式" align="left" prop="phonenumber" />
  74. <el-table-column label="学院" align="left" prop="dept.deptName" />
  75. </el-table>
  76. <pagination :page-sizes="[20, 30, 40, 50]"
  77. v-show="total>0"
  78. :total="total"
  79. :page.sync="queryParams.pageNum"
  80. :limit.sync="queryParams.pageSize"
  81. @pagination="getList"
  82. />
  83. <div style="margin-top:30px;padding-top:20px;display: flex;border-top:1px solid #dedede">
  84. <p style="flex:1;"></p>
  85. <p style="margin-right:20px;" class="reset-button-one" @click="show(2)">取消</p>
  86. <p class="inquire-button-one" @click="okButton">确定</p>
  87. </div>
  88. </div>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script>
  93. import { listDepartments } from "@/api/system/dept";
  94. import { optionselect } from "@/api/laboratory/gradeManage";
  95. import { listUser } from "@/api/permissionRequired";
  96. import { listClassifiedAll } from "@/api/laboratory/classified";
  97. import { listClasstypeAll } from "@/api/laboratory/classtype";
  98. export default {
  99. name: "userList",
  100. props:{
  101. },
  102. data() {
  103. return {
  104. userOpen:false,
  105. loading:false,
  106. // 显示搜索条件
  107. showSearch: true,
  108. // 总条数
  109. total: 0,
  110. queryParams:{
  111. pageNum:1,
  112. pageSize:20,
  113. nickName:null,
  114. position:null,
  115. userName:null,
  116. phonenumber:null,
  117. deptName:null,
  118. },
  119. userList:[],
  120. //已选中数量
  121. selectedNum:0,
  122. //已选中
  123. ids:[],
  124. idData:[],
  125. // 非单个禁用
  126. single: true,
  127. // 非多个禁用
  128. multiple: true,
  129. //分类数据
  130. typeList:[],
  131. //分级数据
  132. levelList:[]
  133. }
  134. },
  135. created(){
  136. },
  137. mounted(){
  138. // this.getListClasstypeAll();
  139. // this.getListClassifiedAll();
  140. this.listDepartments();
  141. this.optionselect();
  142. this.getList();
  143. },
  144. methods:{
  145. //确定按钮
  146. okButton(){
  147. if(!this.ids[0]){
  148. this.msgError("请勾选人员")
  149. return
  150. }
  151. this.$parent.takeUserData(this.ids,this.idData);
  152. },
  153. show(data){
  154. let self = this;
  155. this.userOpen = !this.userOpen;
  156. if(data){
  157. this.queryParams.pageNum = 1;
  158. setTimeout(function(){
  159. for(let i=0;i<data.length;i++){
  160. self.$refs.multipleTable.toggleRowSelection(data[i],true)
  161. }
  162. self.getList();
  163. },100);
  164. }
  165. // if(type == 1){
  166. // this.userOpen = true;
  167. // }else if(type == 2){
  168. // this.userOpen = false;
  169. // }
  170. },
  171. //获取学院
  172. listDepartments(){
  173. listDepartments().then(response => {
  174. this.deptList = response.data;
  175. });
  176. },
  177. //获取身份
  178. optionselect(){
  179. optionselect().then(response => {
  180. this.typeList = response.data;
  181. });
  182. },
  183. //获取数据列表
  184. getList(){
  185. this.loading = true;
  186. listUser(this.queryParams).then(response => {
  187. this.userList = response.rows;
  188. this.total = response.total;
  189. this.loading = false;
  190. });
  191. },
  192. /** 搜索按钮操作 */
  193. handleQuery() {
  194. this.queryParams.pageNum = 1;
  195. this.getList();
  196. },
  197. /** 重置按钮操作 */
  198. resetQuery() {
  199. this.resetForm("queryForm");
  200. this.handleQuery();
  201. },
  202. /*===记录勾选数据===
  203. 需要再el-table 添加 :row-key="getRowKeys"
  204. 需要在selection 添加 :reserve-selection="true"
  205. */
  206. getRowKeys(row) {
  207. return row.userId
  208. },
  209. //选择本页
  210. selectPage(){
  211. console.log(this.$refs.multipleTable)
  212. this.$refs.multipleTable.toggleAllSelection()
  213. // console.log(this.$refs.multipleTable.selection)
  214. },
  215. //清除选择
  216. clearSelection(){
  217. this.$refs.multipleTable.clearSelection()
  218. },
  219. // 多选框选中数据
  220. handleSelectionChange(selection) {
  221. console.log("selection",selection)
  222. this.selectedNum = selection.length;
  223. this.ids = selection.map(item => item.userId);
  224. this.idData = selection.map(item => item);
  225. this.single = selection.length!==1
  226. this.multiple = !selection.length
  227. },
  228. //查询安全分级
  229. getListClassifiedAll(){
  230. listClassifiedAll().then(response=>{
  231. if(response.code==200){
  232. console.log(response)
  233. this.levelList=response.data
  234. }
  235. })
  236. },
  237. //查询安全分类
  238. getListClasstypeAll(){
  239. listClasstypeAll().then(response=>{
  240. if(response.code==200){
  241. this.typeList=response.data;
  242. }
  243. });
  244. },
  245. }
  246. }
  247. </script>
  248. <style lang="scss" scoped>
  249. .userList{
  250. height:700px;
  251. display: flex!important;
  252. flex-direction: column;
  253. }
  254. </style>