userManage.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div class="record-warp">
  3. <div class="record-main">
  4. <el-row>
  5. <el-col :span="24">
  6. <div class="search-head">
  7. <span>用户名:</span>
  8. <el-input v-model="name" clearable placeholder="请输入用户名"></el-input>&nbsp;&nbsp;&nbsp;&nbsp;
  9. <span>用户昵称:</span>
  10. <el-input v-model="userName" clearable placeholder="请输入用户昵称"></el-input>&nbsp;&nbsp;
  11. <el-button type="primary" round icon="el-icon-search" @click="searchTarget">搜索</el-button>
  12. <el-button type="info" round icon="el-icon-delete-solid" @click="clearSearch">清空</el-button>
  13. <el-button type="success" round class="add_class" icon="el-icon-plus" @click="addUser">新增用户</el-button>
  14. </div>
  15. </el-col>
  16. </el-row>
  17. <el-row class="add_user_class">
  18. <el-col :span="24">
  19. <div class="search-head">
  20. </div>
  21. </el-col>
  22. </el-row>
  23. <div class="table-content">
  24. <el-table :data="tableData" :row-style="{ height: '0px' }" :cell-style="{ padding: '5px' }">
  25. <!-- <el-table-column prop="name" label="姓名" align="center" width="" show-overflow-tooltip>
  26. </el-table-column> -->
  27. <el-table-column show-overflow-tooltip prop="name" label="用户名" align="center" width="">
  28. </el-table-column>
  29. <el-table-column prop="userName" label="用户昵称" align="center" width="">
  30. </el-table-column>
  31. <!-- <el-table-column prop="state" label="用户状态" align="center" :formatter="formatterDelete" width="">
  32. </el-table-column> -->
  33. <el-table-column prop="channelId" label="所属渠道ID" align="center" width=""></el-table-column>
  34. <el-table-column prop="type" label="所属角色" align="center" width="" :formatter="formatterRole"
  35. show-overflow-tooltip>
  36. </el-table-column>
  37. <el-table-column label="操作" width="510px" align="center">
  38. <template slot-scope="scope">
  39. <el-button @click="viewUser(scope.row)" v-if="scope.row.state != 0" type="text"
  40. size="small">查看</el-button>
  41. <el-button type="text" size="small" v-if="scope.row.state != 0"
  42. @click="editUser(scope.row)">编辑</el-button>
  43. <el-popconfirm v-if="scope.row.state != 0" title="确定删除吗?" placement="top"
  44. @confirm="deleteUser(scope.$index, scope.row)">
  45. <el-button size="small" style="margin-left: 10px" type="text" slot="reference">删除</el-button>
  46. </el-popconfirm>
  47. <el-popconfirm v-if="scope.row.state != 0" title="密码将重置为123456" placement="top"
  48. @confirm="resetUser(scope.$index, scope.row)">
  49. <el-button size="small" style="margin-left: 10px" type="text" slot="reference">重置密码</el-button>
  50. </el-popconfirm>
  51. </template>
  52. </el-table-column>
  53. </el-table>
  54. </div>
  55. <el-pagination small background @current-change="handleCurrentChange" :current-page.sync="pageNum"
  56. layout="total, prev, pager, next" :page-size="pageSize" :total="total">
  57. </el-pagination>
  58. <!-- <el-pagination small background layout="total prev, pager, next" :total="36">
  59. </el-pagination> -->
  60. </div>
  61. <Register ref="register" @search="searchTarget" />
  62. <el-dialog title="查看" :visible.sync="centerDialogVisible" width="60%" center>
  63. <div>
  64. <div class="user_out">
  65. <div class="user_out_sub">
  66. 用户名
  67. </div>
  68. <div class="user_out_subNext">
  69. {{ view.name }}
  70. </div>
  71. <div class="user_out_sub">
  72. 用户昵称
  73. </div>
  74. <div class="user_out_subNext">
  75. {{ view.userName }}
  76. </div>
  77. </div>
  78. <div class="user_out">
  79. <div class="user_out_sub">
  80. 所属渠道
  81. </div>
  82. <div class="user_out_subNext">
  83. {{ view.channelId }}
  84. </div>
  85. <div class="user_out_sub">
  86. 所属角色
  87. </div>
  88. <div class="user_out_subNext">
  89. {{ view.role }}
  90. </div>
  91. </div>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import { oSessionStorage } from "../../utils/utils";
  98. import register from "../../components/Register.vue";
  99. export default {
  100. name: "userManage",
  101. components: {
  102. Register: register,
  103. },
  104. data() {
  105. return {
  106. centerDialogVisible: false,
  107. editUserFlag: false,
  108. startTime: "",
  109. endTime: "",
  110. value1: null,
  111. total: 0,
  112. pageSize: 10,
  113. pageNum: 1,
  114. keyword: "",
  115. tableData: [],
  116. userInfo: {}, //用户信息
  117. userId: "", //用户id
  118. name: "", //根据名称搜索
  119. userName: "", //根据昵称搜索
  120. hospitalOrDepartment: "", //医院科室
  121. invitationCode: "",
  122. roleType: "0",
  123. type: 0,
  124. view: {
  125. name: '',
  126. userName: '',
  127. channelId: '',
  128. role: ''
  129. },
  130. };
  131. },
  132. created() { },
  133. mounted() {
  134. this.userInfo = JSON.parse(oSessionStorage.getItem("userInfo"));
  135. if (!this.userInfo) {
  136. //如果用户信息不存在跳转登陆页
  137. this.$router.push({ path: "/" });
  138. }
  139. this.searchTarget();
  140. },
  141. methods: {
  142. formatterDelete(row) {
  143. if (row.state == 0) {
  144. return '已删除'
  145. } else {
  146. return '正常'
  147. }
  148. },
  149. resetUser(index,val){
  150. console.log(val)
  151. this.$http.get(`/user/reset/${val.id}`, {}, (res) => {
  152. // this.$toast.success({message:'成功'});
  153. if (res && res.code == 200) {
  154. this.$message.success("重置成功");
  155. this.searchTarget();
  156. } else {
  157. this.$message.error(res.msg);
  158. }
  159. });
  160. //重置密码
  161. },
  162. editUser(row) {
  163. this.editRegisterUser(row)
  164. },
  165. viewUser(row) {
  166. this.view.name = row.name
  167. this.view.userName = row.userName
  168. this.view.channelId = row.channelId
  169. this.view.role = row.type == '0' ? '渠道用户' : ''
  170. this.centerDialogVisible = true;
  171. },
  172. addUser() {
  173. this.addRegisterUser(true);
  174. },
  175. clearSearch() {
  176. this.name = "";
  177. this.userName = "";
  178. this.searchTarget();
  179. },
  180. formatterRole(val) {
  181. if (val.type == "1") {
  182. return "超级管理员";
  183. } else {
  184. return "渠道用户";
  185. }
  186. },
  187. forma(val) {
  188. if (val.gender == "0") {
  189. return "男";
  190. } else {
  191. return "女";
  192. }
  193. },
  194. addRegisterUser(val) {
  195. this.$refs.register.open(val);
  196. },
  197. editRegisterUser(val){
  198. this.$refs.register.edit(val);
  199. },
  200. deleteUser(index, row) {
  201. this.$http.delete(`/user/delete/${row.id}`, {}, (res) => {
  202. // this.$toast.success({message:'成功'});
  203. if (res && res.code == 200) {
  204. this.$message.success("删除成功");
  205. this.searchTarget();
  206. } else {
  207. this.$message.error("删除失败");
  208. }
  209. });
  210. },
  211. handleCurrentChange(val) {
  212. this.pageNum = val;
  213. this.searchList();
  214. },
  215. //根据现有情况进行搜索
  216. searchList() {
  217. // let url =``
  218. this.$http.post(
  219. `/user/find`,
  220. {
  221. pageNum: this.pageNum,
  222. pageSize: this.pageSize,
  223. phone: "",
  224. name: this.name,
  225. userName: this.userName,
  226. },
  227. (res) => {
  228. // console.log(res,'用户测试记录')
  229. if (res && res.code == 200) {
  230. this.tableData = res.data.content;
  231. this.total = res.data.totalElements;
  232. } else {
  233. // this.$toast.fail(res.msg);
  234. this.$message.error(res.msg);
  235. }
  236. }
  237. );
  238. },
  239. searchTarget() {
  240. this.pageNum = 1;
  241. this.searchList();
  242. },
  243. //跳转首页
  244. goHome() {
  245. this.$router.push({ path: "/home" });
  246. },
  247. //跳转记录页
  248. goRecord() {
  249. this.$router.push({ path: "/record" });
  250. },
  251. //退出登陆
  252. logout() {
  253. oSessionStorage.removeItem("userInfo");
  254. oSessionStorage.removeItem("token");
  255. this.$router.push({ path: "/" });
  256. },
  257. //点击日历获取日期
  258. getDate(param) {
  259. // console.log(param,"日期。。。")
  260. this.userRecord(param.dateStr);
  261. },
  262. //点击获取月出勤次数
  263. getTimes(param) {
  264. this.monthTimes = param;
  265. },
  266. // 用户测试记录显示
  267. userRecord(date) {
  268. this.$http.get(
  269. `gameRecord/findListByUserIdAndDate/${this.userId}/${date}`,
  270. {},
  271. (res) => {
  272. // console.log(res,'用户测试记录')
  273. if (res && res.code == 200) {
  274. this.listData = res.data;
  275. } else {
  276. this.$toast.fail(res.msg);
  277. }
  278. }
  279. );
  280. },
  281. },
  282. };
  283. </script>
  284. <style lang="less" scoped>
  285. @import "../../styles/theme.less";
  286. .record-warp {
  287. width: 100%;
  288. height: 80vh;
  289. //background: url(../../assets/img/index/19.png) no-repeat center;
  290. //background-size: 100% 100%;
  291. position: relative;
  292. .record-main {
  293. width: 100%;
  294. height: 100%;
  295. box-sizing: border-box;
  296. overflow-y: auto;
  297. .search-head {
  298. width: 100%;
  299. display: flex;
  300. flex-direction: row;
  301. justify-content: flex-start;
  302. align-items: center;
  303. .zc-title {
  304. color: #606266;
  305. font-size: 14px;
  306. }
  307. }
  308. .table-content {
  309. margin: 10px 0;
  310. }
  311. }
  312. }
  313. .add_user_class {
  314. margin-top: 10px;
  315. }
  316. .user_out {
  317. display: flex;
  318. width: 100%;
  319. align-items: center;
  320. border: 1px solid #eeeeef;
  321. line-height: 50px;
  322. margin-top: 10px;
  323. }
  324. .user_out_sub {
  325. flex: 1;
  326. background-color: #fafafa;
  327. text-align: center;
  328. // color:#ffffff
  329. }
  330. .user_out_subNext {
  331. padding-left: 10px;
  332. flex: 3
  333. }
  334. </style>