accountManager.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 学校账号管理
  7. </h2>
  8. <div class="m-core">
  9. <save-form
  10. :inline="true"
  11. :model="searchForm"
  12. @submit="search"
  13. @reset="onReSet"
  14. ref="saveForm"
  15. >
  16. <el-form-item prop="keyword">
  17. <el-input
  18. v-model.trim="searchForm.keyword"
  19. class="seachInput"
  20. clearable
  21. @keyup.enter.native="
  22. (e) => {
  23. e.target.blur();
  24. $refs.saveForm.save();
  25. search();
  26. }
  27. "
  28. placeholder="老师姓名/编号/手机号"
  29. ></el-input>
  30. </el-form-item>
  31. <el-form-item prop="organId">
  32. <el-select
  33. style="width: 180px !important"
  34. class="multiple"
  35. v-model.trim="searchForm.organId"
  36. filterable
  37. clearable
  38. placeholder="请选择分部"
  39. >
  40. <el-option
  41. v-for="(item, index) in selects.branchs"
  42. :key="index"
  43. :label="item.name"
  44. :value="item.id"
  45. ></el-option>
  46. </el-select>
  47. </el-form-item>
  48. <el-form-item prop="schoolId">
  49. <el-select
  50. v-model.trim="searchForm.schoolId"
  51. :disabled="!searchForm.organId"
  52. filterable
  53. clearable
  54. placeholder="请选择合作单位"
  55. >
  56. <el-option
  57. v-for="(item, index) in cooperationList"
  58. :key="index"
  59. :label="item.name"
  60. :value="item.id"
  61. ></el-option>
  62. </el-select>
  63. </el-form-item>
  64. <el-form-item>
  65. <el-button native-type="submit" type="primary">搜索</el-button>
  66. <el-button native-type="reset" type="danger">重置</el-button>
  67. </el-form-item>
  68. </save-form>
  69. <div class="tableWrap">
  70. <el-table
  71. style="width: 100%"
  72. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  73. :data="tableList"
  74. >
  75. <el-table-column align="center" prop="id" label="编号"></el-table-column>
  76. <el-table-column align="center" prop="organName" label="分部"></el-table-column>
  77. <el-table-column
  78. align="center"
  79. prop="schoolName"
  80. label="合作单位"
  81. ></el-table-column>
  82. <el-table-column
  83. align="center"
  84. prop="username"
  85. label="老师姓名"
  86. ></el-table-column>
  87. <el-table-column align="center" prop="userType" label="账号类型">
  88. <template slot-scope="scope">
  89. <div>{{ scope.row.userType | schoolUserType }}</div>
  90. </template>
  91. </el-table-column>
  92. <el-table-column align="center" prop="status" label="账号状态">
  93. <template slot-scope="scope">
  94. <div>{{ scope.row.status | schoolUserStatus }}</div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. align="center"
  99. prop="mobile"
  100. label="联系电话"
  101. ></el-table-column>
  102. <el-table-column
  103. align="center"
  104. prop="createTime"
  105. label="注册日期"
  106. ></el-table-column>
  107. <el-table-column align="center" prop="studentId" label="操作">
  108. <template slot-scope="scope">
  109. <div>
  110. <auth auths="schoolStaff/update">
  111. <el-button
  112. type="text"
  113. v-if="scope.row.status == 1"
  114. @click="updateStatus(scope.row)"
  115. >冻结</el-button
  116. >
  117. <el-button
  118. type="text"
  119. v-if="scope.row.status == 9"
  120. @click="updateStatus(scope.row)"
  121. >启用</el-button
  122. >
  123. </auth>
  124. <auth auths="schoolStaff/remove">
  125. <el-button
  126. type="text"
  127. v-if="scope.row.status == 9"
  128. @click="removeTeacherCount(scope.row)"
  129. >删除</el-button
  130. ></auth
  131. >
  132. <auth auths="schoolStaff/resetPassword">
  133. <el-button
  134. type="text"
  135. v-if="scope.row.status == 9"
  136. @click="resetPwd(scope.row)"
  137. >重置密码</el-button
  138. ></auth
  139. >
  140. </div>
  141. </template>
  142. </el-table-column>
  143. </el-table>
  144. <pagination
  145. sync
  146. :total.sync="rules.total"
  147. :page.sync="rules.page"
  148. :limit.sync="rules.limit"
  149. :page-sizes="rules.page_size"
  150. @pagination="getList"
  151. />
  152. </div>
  153. </div>
  154. </div>
  155. </template>
  156. <script>
  157. import axios from "axios";
  158. import { getToken } from "@/utils/auth";
  159. import pagination from "@/components/Pagination/index";
  160. import load from "@/utils/loading";
  161. import { getTimes } from "@/utils";
  162. import { queryByOrganId } from "@/api/systemManage";
  163. import { courseType, courseListType } from "@/utils/searchArray";
  164. import {
  165. getSchoolStaff,
  166. schoolStaffUpdate,
  167. schoolStaffRemove,
  168. schoolStaffResetPwd,
  169. } from "./api";
  170. export default {
  171. components: { pagination },
  172. data() {
  173. return {
  174. searchForm: {
  175. keyword: null,
  176. organId: null,
  177. schoolId: null,
  178. },
  179. courseType,
  180. tableList: [],
  181. organList: [],
  182. cooperationList: [],
  183. rules: {
  184. // 分页规则
  185. limit: 10, // 限制显示条数
  186. page: 1, // 当前页
  187. total: 0, // 总条数
  188. page_size: [10, 20, 40, 50], // 选择限制显示条数
  189. },
  190. };
  191. },
  192. //生命周期 - 创建完成(可以访问当前this实例)
  193. created() {},
  194. //生命周期 - 挂载完成(可以访问DOM元素)
  195. mounted() {
  196. // 获取分部
  197. this.$store.dispatch("setBranchs");
  198. this.init();
  199. },
  200. methods: {
  201. init() {
  202. this.getList();
  203. },
  204. async getList() {
  205. try {
  206. let { timer, ...rest } = this.searchForm;
  207. let params = {
  208. ...rest,
  209. page: this.rules.page,
  210. rows: this.rules.limit,
  211. ...getTimes(timer, ["startTime", "endTime"]),
  212. };
  213. const res = await getSchoolStaff({
  214. ...params,
  215. page: this.rules.page,
  216. rows: this.rules.limit,
  217. });
  218. this.tableList = res.data.rows;
  219. this.rules.total = res.data.total;
  220. } catch (e) {
  221. console.log(e);
  222. }
  223. },
  224. search() {
  225. this.rules.page = 1;
  226. this.getList();
  227. },
  228. onReSet() {
  229. this.$nextTick(() => {
  230. this.getList();
  231. });
  232. },
  233. async updateStatus(row) {
  234. let str = "";
  235. let status = "";
  236. if (row.status == 1) {
  237. // 冻结
  238. str = `是否冻结"${row.username}"该老师账号`;
  239. status = "9";
  240. } else {
  241. // 启用
  242. str = `是否启用"${row.username}"该老师账号`;
  243. status = "1";
  244. }
  245. this.$confirm(str, "提示", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning",
  249. })
  250. .then(async () => {
  251. try {
  252. const res = await schoolStaffUpdate({ id: row.id, status });
  253. if (row.status == 1) {
  254. this.$message.success("冻结成功");
  255. } else {
  256. this.$message.success("启用成功");
  257. }
  258. this.getList();
  259. } catch (e) {
  260. console.log(e);
  261. }
  262. })
  263. .catch((e) => {
  264. console.log(e);
  265. });
  266. console.log(row);
  267. },
  268. async removeTeacherCount(row) {
  269. try {
  270. await this.$confirm(`是否删除"${row.username}"该老师`, "提示", {
  271. confirmButtonText: "确定",
  272. cancelButtonText: "取消",
  273. type: "warning",
  274. });
  275. const res = await schoolStaffRemove({ id: row.id });
  276. this.$message.success("删除成功");
  277. this.getList();
  278. } catch (e) {
  279. console.log(e);
  280. }
  281. },
  282. async resetPwd(row) {
  283. try {
  284. await this.$confirm(
  285. `是否删除"${row.username}"该老师的密码重置为gym+手机号后4位`,
  286. "提示",
  287. {
  288. confirmButtonText: "确定",
  289. cancelButtonText: "取消",
  290. type: "warning",
  291. }
  292. );
  293. const res = await schoolStaffResetPwd({ userId: row.userId });
  294. this.$message.success("重置成功");
  295. this.getList();
  296. } catch (error) {
  297. console.log(error);
  298. }
  299. },
  300. },
  301. watch: {
  302. "searchForm.organId"(val) {
  303. if (val) {
  304. queryByOrganId({ organId: val }).then((res) => {
  305. if (res.code == 200) {
  306. this.cooperationList = res.data;
  307. }
  308. });
  309. }
  310. },
  311. // "searchForm.cooperationId"(val) {
  312. // if (val) {
  313. // getMusicGroup({ cooperationId: val }).then((res) => {
  314. // this.musicList = res.data;
  315. // });
  316. // }
  317. // },
  318. },
  319. };
  320. </script>
  321. <style lang="scss">
  322. .seachInput {
  323. .el-input__inner {
  324. width: 200px !important;
  325. }
  326. }
  327. </style>