accountManager.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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
  76. align="center"
  77. prop="userId"
  78. label="用户编号"
  79. ></el-table-column>
  80. <el-table-column align="center" prop="organName" label="分部"></el-table-column>
  81. <el-table-column
  82. align="center"
  83. prop="schoolName"
  84. label="合作单位"
  85. ></el-table-column>
  86. <el-table-column
  87. align="center"
  88. prop="username"
  89. label="老师姓名"
  90. ></el-table-column>
  91. <el-table-column align="center" prop="userType" label="账号类型">
  92. <template slot-scope="scope">
  93. <div>{{ scope.row.userType | schoolUserType }}</div>
  94. </template>
  95. </el-table-column>
  96. <el-table-column align="center" prop="status" label="账号状态">
  97. <template slot-scope="scope">
  98. <div>{{ scope.row.status | schoolUserStatus }}</div>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. align="center"
  103. prop="mobile"
  104. label="联系电话"
  105. ></el-table-column>
  106. <el-table-column
  107. align="center"
  108. prop="createTime"
  109. label="注册日期"
  110. ></el-table-column>
  111. <el-table-column align="center" prop="studentId" label="操作">
  112. <template slot-scope="scope">
  113. <div>
  114. <auth auths="schoolStaff/update">
  115. <el-button
  116. type="text"
  117. v-if="scope.row.status == 1"
  118. @click="updateStatus(scope.row)"
  119. >冻结</el-button
  120. >
  121. <el-button
  122. type="text"
  123. v-if="scope.row.status == 9"
  124. @click="updateStatus(scope.row)"
  125. >启用</el-button
  126. >
  127. </auth>
  128. <auth auths="schoolStaff/updateAccount">
  129. <el-button type="text" @click="resetCount(scope.row)">修改</el-button>
  130. </auth>
  131. <auth auths="schoolStaff/remove">
  132. <el-button
  133. type="text"
  134. v-if="scope.row.status == 9"
  135. @click="removeTeacherCount(scope.row)"
  136. >删除</el-button
  137. ></auth
  138. >
  139. <auth auths="schoolStaff/resetPassword">
  140. <el-button type="text" @click="resetPwd(scope.row)"
  141. >重置密码</el-button
  142. ></auth
  143. >
  144. </div>
  145. </template>
  146. </el-table-column>
  147. </el-table>
  148. <pagination
  149. sync
  150. :total.sync="rules.total"
  151. :page.sync="rules.page"
  152. :limit.sync="rules.limit"
  153. :page-sizes="rules.page_size"
  154. @pagination="getList"
  155. />
  156. </div>
  157. </div>
  158. <el-dialog title="修改" width="450px" :visible.sync="dialogFormVisible">
  159. <updateAccountModels
  160. :activeRow="activeRow"
  161. ref="updateAccountModelsRef"
  162. v-if="dialogFormVisible"
  163. @close="
  164. () => {
  165. dialogFormVisible = false;
  166. getList();
  167. }
  168. "
  169. />
  170. <span slot="footer" class="dialog-footer">
  171. <el-button @click="dialogFormVisible = false">取 消</el-button>
  172. <el-button @click="submitMessage" type="primary">确 定</el-button>
  173. </span>
  174. </el-dialog>
  175. </div>
  176. </template>
  177. <script>
  178. import axios from "axios";
  179. import { getToken } from "@/utils/auth";
  180. import pagination from "@/components/Pagination/index";
  181. import load from "@/utils/loading";
  182. import { getTimes } from "@/utils";
  183. import { queryByOrganId } from "@/api/systemManage";
  184. import { courseType, courseListType } from "@/utils/searchArray";
  185. import {
  186. getSchoolStaff,
  187. schoolStaffUpdate,
  188. schoolStaffRemove,
  189. schoolStaffResetPwd,
  190. } from "./api";
  191. import updateAccountModels from "./modals/updateAccountModels";
  192. export default {
  193. components: { pagination, updateAccountModels },
  194. data() {
  195. return {
  196. searchForm: {
  197. keyword: null,
  198. organId: null,
  199. schoolId: null,
  200. },
  201. courseType,
  202. tableList: [],
  203. organList: [],
  204. cooperationList: [],
  205. rules: {
  206. // 分页规则
  207. limit: 10, // 限制显示条数
  208. page: 1, // 当前页
  209. total: 0, // 总条数
  210. page_size: [10, 20, 40, 50], // 选择限制显示条数
  211. },
  212. dialogFormVisible: false,
  213. activeRow: null,
  214. };
  215. },
  216. //生命周期 - 创建完成(可以访问当前this实例)
  217. created() {},
  218. //生命周期 - 挂载完成(可以访问DOM元素)
  219. mounted() {
  220. // 获取分部
  221. this.$store.dispatch("setBranchs");
  222. this.init();
  223. },
  224. methods: {
  225. init() {
  226. this.getList();
  227. },
  228. async getList() {
  229. try {
  230. let { timer, ...rest } = this.searchForm;
  231. let params = {
  232. ...rest,
  233. page: this.rules.page,
  234. rows: this.rules.limit,
  235. ...getTimes(timer, ["startTime", "endTime"]),
  236. };
  237. const res = await getSchoolStaff({
  238. ...params,
  239. page: this.rules.page,
  240. rows: this.rules.limit,
  241. });
  242. this.tableList = res.data.rows;
  243. this.rules.total = res.data.total;
  244. } catch (e) {
  245. console.log(e);
  246. }
  247. },
  248. search() {
  249. this.rules.page = 1;
  250. this.getList();
  251. },
  252. onReSet() {
  253. this.$nextTick(() => {
  254. this.getList();
  255. });
  256. },
  257. resetCount(row) {
  258. this.activeRow = row;
  259. this.dialogFormVisible = true;
  260. console.log(row);
  261. },
  262. async updateStatus(row) {
  263. let str = "";
  264. let status = "";
  265. if (row.status == 1) {
  266. // 冻结
  267. str = `是否冻结"${row.username}"该老师账号`;
  268. status = "9";
  269. } else {
  270. // 启用
  271. str = `是否启用"${row.username}"该老师账号`;
  272. status = "1";
  273. }
  274. this.$confirm(str, "提示", {
  275. confirmButtonText: "确定",
  276. cancelButtonText: "取消",
  277. type: "warning",
  278. })
  279. .then(async () => {
  280. try {
  281. const res = await schoolStaffUpdate({ id: row.id, status });
  282. if (row.status == 1) {
  283. this.$message.success("冻结成功");
  284. } else {
  285. this.$message.success("启用成功");
  286. }
  287. this.getList();
  288. } catch (e) {
  289. console.log(e);
  290. }
  291. })
  292. .catch((e) => {
  293. console.log(e);
  294. });
  295. console.log(row);
  296. },
  297. async removeTeacherCount(row) {
  298. try {
  299. await this.$confirm(`是否删除"${row.username}"该老师`, "提示", {
  300. confirmButtonText: "确定",
  301. cancelButtonText: "取消",
  302. type: "warning",
  303. });
  304. const res = await schoolStaffRemove({ id: row.id });
  305. this.$message.success("删除成功");
  306. this.getList();
  307. } catch (e) {
  308. console.log(e);
  309. }
  310. },
  311. async resetPwd(row) {
  312. try {
  313. await this.$confirm(
  314. `是否将"${row.username}"该老师的密码重置为gym+手机号后4位`,
  315. "提示",
  316. {
  317. confirmButtonText: "确定",
  318. cancelButtonText: "取消",
  319. type: "warning",
  320. }
  321. );
  322. const res = await schoolStaffResetPwd({ userId: row.userId });
  323. this.$message.success("重置成功");
  324. this.getList();
  325. } catch (error) {
  326. console.log(error);
  327. }
  328. },
  329. submitMessage() {
  330. this.$refs.updateAccountModelsRef.submit();
  331. },
  332. },
  333. watch: {
  334. "searchForm.organId"(val) {
  335. if (val) {
  336. queryByOrganId({ organId: val, enable: false }).then((res) => {
  337. if (res.code == 200) {
  338. this.cooperationList = res.data;
  339. }
  340. });
  341. }
  342. },
  343. // "searchForm.cooperationId"(val) {
  344. // if (val) {
  345. // getMusicGroup({ cooperationId: val }).then((res) => {
  346. // this.musicList = res.data;
  347. // });
  348. // }
  349. // },
  350. },
  351. };
  352. </script>
  353. <style lang="scss">
  354. .seachInput {
  355. .el-input__inner {
  356. width: 200px !important;
  357. }
  358. }
  359. </style>