teamClassList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <div class="squrt"></div>
  6. 班级管理
  7. <filter-search
  8. v-if="permission('/teamCLassList/abnormal')"
  9. :keys="['lessThenThreeHighOnline']"
  10. @reload="reloadSearch"
  11. :moreKeys="['organId']"
  12. />
  13. </h2>
  14. <div class="m-core">
  15. <save-form
  16. ref="searchForm"
  17. :inline="true"
  18. :model="searchForm"
  19. @submit="search"
  20. @reset="onReSet"
  21. >
  22. <el-form-item prop="search">
  23. <el-input
  24. v-model.trim="searchForm.search"
  25. clearable
  26. @keyup.enter.native="
  27. (e) => {
  28. e.target.blur();
  29. $refs.searchForm.save();
  30. search();
  31. }
  32. "
  33. placeholder="乐团&班级编号名称"
  34. ></el-input>
  35. </el-form-item>
  36. <el-form-item prop="organIdList">
  37. <select-all
  38. class="multiple"
  39. filterable
  40. multiple
  41. v-model.trim="searchForm.organIdList"
  42. clearable
  43. placeholder="请选择分部"
  44. >
  45. <el-option
  46. v-for="(item, index) in selects.branchs"
  47. :key="index"
  48. :label="item.name"
  49. :value="item.id"
  50. ></el-option>
  51. </select-all>
  52. </el-form-item>
  53. <el-form-item>
  54. <el-select
  55. v-model.trim="searchForm.groupType"
  56. @change="
  57. () => {
  58. searchForm.type = '';
  59. }
  60. "
  61. filterable
  62. placeholder="课程组类型"
  63. >
  64. <el-option
  65. v-for="(item, index) in courseListType"
  66. :key="index"
  67. :value="item.value"
  68. :label="item.label"
  69. ></el-option>
  70. </el-select>
  71. </el-form-item>
  72. <!-- musicClassTypeList -->
  73. <el-form-item prop="type">
  74. <el-select
  75. v-model.trim="searchForm.type"
  76. filterable
  77. clearable
  78. :disabled="searchForm.groupType != 'MUSIC'"
  79. placeholder="班级类型"
  80. >
  81. <el-option
  82. v-for="(item, index) in musicClassTypeList"
  83. :key="index"
  84. :label="item.label"
  85. :value="item.value"
  86. ></el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item prop="mainTeacherUserId">
  90. <remote-search
  91. :commit="'setTeachers'"
  92. v-model="searchForm.mainTeacherUserId"
  93. :demissionFlag="true"
  94. :isForzenWithQueryCondition="true"
  95. />
  96. </el-form-item>
  97. <el-form-item>
  98. <el-button native-type="submit" type="primary">搜索</el-button>
  99. <el-button native-type="reset" type="danger">重置</el-button>
  100. <el-button
  101. type="primary"
  102. v-permission="'export/classGroup'"
  103. @click="exportClassGroup"
  104. >导出</el-button
  105. >
  106. </el-form-item>
  107. </save-form>
  108. <div class="tableWrap">
  109. <el-table
  110. style="width: 100%"
  111. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  112. :data="tableList"
  113. >
  114. <el-table-column
  115. align="center"
  116. prop="musicGroupId"
  117. label="课程组编号"
  118. >
  119. <template slot-scope="scope">
  120. <copy-text>{{ scope.row.musicGroupId }}</copy-text>
  121. </template>
  122. </el-table-column>
  123. <!-- <el-table-column align="center" prop="musicGroupId" label="课程编号">
  124. <template slot-scope="scope">
  125. <copy-text>{{ scope.row.id }}</copy-text>
  126. </template>
  127. </el-table-column> -->
  128. <el-table-column
  129. align="center"
  130. prop="musicGroupName"
  131. label="课程组名称"
  132. ></el-table-column>
  133. <el-table-column align="center" prop="organName" label="分部名称">
  134. <template slot-scope="scope">
  135. <copy-text>{{ scope.row.organName }}</copy-text>
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. align="center"
  140. prop="name"
  141. label="班级名称"
  142. ></el-table-column>
  143. <el-table-column align="center" prop="type" label="班级类型">
  144. <template slot-scope="scope">
  145. <div>{{ scope.row.type | classType }}</div>
  146. </template>
  147. </el-table-column>
  148. <el-table-column
  149. align="center"
  150. prop="studentNum"
  151. label="当前班级人数"
  152. >
  153. <template slot-scope="scope">
  154. <div>{{ scope.row.studentNum }}人</div>
  155. </template>
  156. </el-table-column>
  157. <el-table-column align="center" prop label="主教老师">
  158. <template slot-scope="scope">
  159. <div v-if="scope.row.classGroupTeacherMapperList">
  160. <p
  161. v-for="(item, index) in scope.row.classGroupTeacherMapperList"
  162. v-if="item.teacherRole == 'BISHOP'"
  163. :key="index"
  164. >
  165. {{ item.userName }}
  166. </p>
  167. </div>
  168. </template>
  169. </el-table-column>
  170. <el-table-column align="center" label="助教老师">
  171. <template slot-scope="scope">
  172. <div v-if="scope.row.classGroupTeacherMapperList">
  173. <p
  174. v-for="(item, index) in scope.row.classGroupTeacherMapperList"
  175. v-if="item.teacherRole == 'TEACHING'"
  176. :key="index"
  177. >
  178. {{ item.userName }}
  179. </p>
  180. </div>
  181. </template>
  182. </el-table-column>
  183. <el-table-column align="center" label="已上课时">
  184. <template slot-scope="scope">
  185. <div>{{ scope.row.currentClassTimes }}</div>
  186. </template>
  187. </el-table-column>
  188. <el-table-column align="center" label="总课数">
  189. <template slot-scope="scope">
  190. <div>{{ scope.row.totalClassTimes }}</div>
  191. </template>
  192. </el-table-column>
  193. <el-table-column
  194. fixed="right"
  195. width="160px"
  196. align="center"
  197. label="操作"
  198. >
  199. <template slot-scope="scope">
  200. <el-button
  201. type="text"
  202. v-if="
  203. permission('classGroup/update')
  204. "
  205. @click="resetClassName(scope.row)"
  206. >班级名称调整</el-button
  207. >
  208. <el-button
  209. type="text"
  210. @click="addCompound(scope.row)"
  211. v-if="
  212. scope.row.type != 'MUSIC_NETWORK' &&
  213. scope.row.groupType == 'MUSIC' &&
  214. !isAddCom(scope.row) &&
  215. permission('classGroup/spanGroupMergeClassSplitClassAffirm')
  216. "
  217. >添加合班</el-button
  218. >
  219. <el-button
  220. type="text"
  221. v-if="
  222. isAddCom(scope.row) &&
  223. permission('classGroup/spanGroupMergeClassSplitClassAffirm')
  224. "
  225. @click="cancleCompound(scope.row)"
  226. >取消合班</el-button
  227. >
  228. <el-button
  229. type="text"
  230. v-if="
  231. permission('classGroup/delSingle?page=teamCLassList') &&
  232. scope.row.groupType === 'MUSIC' &&
  233. (scope.row.studentNum == '0' ||
  234. scope.row.totalClassTimes == '0')
  235. "
  236. @click="removeClass(scope)"
  237. >删除</el-button
  238. >
  239. </template>
  240. </el-table-column>
  241. </el-table>
  242. <pagination
  243. sync
  244. :total.sync="rules.total"
  245. :page.sync="rules.page"
  246. :limit.sync="rules.limit"
  247. :page-sizes="rules.page_size"
  248. @pagination="getList"
  249. />
  250. </div>
  251. </div>
  252. <classCompound
  253. :compoundList="compoundList"
  254. v-if="
  255. permission('classGroup/spanGroupMergeClassSplitClassAffirm') &&
  256. compoundList.length > 0
  257. "
  258. @clearCom="clearCom"
  259. @getList="getList"
  260. @cancleCompound="cancleCompound"
  261. />
  262. <!-- 修改班级名称 -->
  263. <el-dialog
  264. title="班级名称调整"
  265. width="400px"
  266. :visible.sync="classNameVisible"
  267. v-if="classNameVisible"
  268. >
  269. <changeClassName
  270. :classGroupId="activeClass"
  271. :detail="classDetail"
  272. @submited="submitedResetClassName"
  273. @close="classNameVisible = false"
  274. />
  275. </el-dialog>
  276. </div>
  277. </template>
  278. <script>
  279. import axios from "axios";
  280. import { getToken } from "@/utils/auth";
  281. import pagination from "@/components/Pagination/index";
  282. import load from "@/utils/loading";
  283. import { courseListType } from "@/utils/searchArray";
  284. import { musicClassTypeList } from "@/utils/searchArray";
  285. import {
  286. getClassGroupPage,
  287. removeSingleClass,
  288. getAgreement,
  289. } from "@/api/buildTeam";
  290. import { permission } from "@/utils/directivePage";
  291. import classCompound from "./componentClass/classCompound";
  292. import { Export } from "@/utils/downLoadFile";
  293. import changeClassName from "@/views/teamDetail/components/modals/class-resetclass-name.vue";
  294. import {resetClassName} from '@/views/teamDetail/api'
  295. import qs from "qs";
  296. export default {
  297. components: { pagination, classCompound,changeClassName },
  298. data() {
  299. return {
  300. searchForm: {
  301. search: null,
  302. organIdList: [],
  303. type: "",
  304. groupType: "MUSIC",
  305. mainTeacherUserId:''
  306. },
  307. courseListType: courseListType,
  308. musicClassTypeList,
  309. tableList: [],
  310. compoundList: [],
  311. hightCount: 0,
  312. hightOnlineCount: 0,
  313. rules: {
  314. // 分页规则
  315. limit: 10, // 限制显示条数
  316. page: 1, // 当前页
  317. total: 0, // 总条数
  318. page_size: [10, 20, 40, 50], // 选择限制显示条数
  319. },
  320. classNameVisible:false,
  321. classDetail:null,
  322. activeClass:''
  323. };
  324. },
  325. //生命周期 - 创建完成(可以访问当前this实例)
  326. created() {},
  327. //生命周期 - 挂载完成(可以访问DOM元素)
  328. mounted() {
  329. const { query, params } = this.$route;
  330. if (params.search) {
  331. this.searchForm.search = params.search;
  332. }
  333. if (query.type) {
  334. this.searchForm.type = query.type;
  335. }
  336. if (query.organId) {
  337. this.searchForm.organIdList = [Number(query.organId)];
  338. }
  339. // 获取分部
  340. this.$store.dispatch("setBranchs");
  341. this.init();
  342. },
  343. methods: {
  344. async getAgreement() {
  345. try {
  346. const res = await getAgreement();
  347. if (!res.data) {
  348. this.$bus.$emit("showguide", ["agreement"]);
  349. }
  350. } catch (e) {}
  351. },
  352. reloadSearch() {
  353. this.rules.page = 1;
  354. this.getList();
  355. },
  356. init() {
  357. this.getList();
  358. this.getAgreement();
  359. },
  360. async getList() {
  361. try {
  362. let { organIdList, ...result } = this.searchForm;
  363. let obj = {
  364. ...result,
  365. lessThenThreeHighOnline: this.$route.query.lessThenThreeHighOnline,
  366. organIds: this.searchForm.organIdList.join(","),
  367. page: this.rules.page,
  368. rows: this.rules.limit,
  369. };
  370. const res = await getClassGroupPage(obj);
  371. this.rules.total = res.data.total;
  372. this.tableList = res.data.rows;
  373. } catch (err) {
  374. console.log(err);
  375. }
  376. },
  377. search() {
  378. this.rules.page = 1;
  379. this.getList();
  380. },
  381. onReSet() {
  382. this.$refs.searchForm.resetFields();
  383. this.searchForm.groupType = "MUSIC";
  384. this.search();
  385. },
  386. async removeClass(scope) {
  387. try {
  388. await this.$confirm("是否确定删除该班级?", "提示", {
  389. type: "warning",
  390. });
  391. await removeSingleClass({ classGroupId: scope.row.id });
  392. this.$message.success("删除成功");
  393. this.getList();
  394. } catch (error) {}
  395. },
  396. addCompound(row) {
  397. // scope.row.type != 'HIGH_ONLINE' &&scope.row.type != 'HIGH'&&
  398. this.hightOnlineCount = 0;
  399. this.hightCount = 0;
  400. this.compoundList.push(row);
  401. this.compoundList = [...new Set(this.compoundList)];
  402. this.compoundList.forEach((classes) => {
  403. if (classes.type == "HIGH") {
  404. this.hightCount++;
  405. }
  406. if (classes.type == "HIGH_ONLINE") {
  407. this.hightOnlineCount++;
  408. }
  409. });
  410. if (
  411. this.hightOnlineCount &&
  412. this.hightOnlineCount != this.compoundList.length
  413. ) {
  414. this.$message.error("线上基础技能班仅能和线上基础技能班合并");
  415. // this.hightOnlineCount = 0;
  416. // this.hightCount = 0;
  417. // this.compoundList = [];
  418. this.compoundList.splice(this.compoundList.length - 1, 1);
  419. }
  420. if (this.hightCount && this.hightCount != this.compoundList.length) {
  421. this.$message.error("基础技能班仅能和基础技能班合并");
  422. this.compoundList.splice(this.compoundList.length - 1, 1);
  423. // this.hightOnlineCount = 0;
  424. // this.hightCount = 0;
  425. // this.compoundList = [];
  426. }
  427. },
  428. isAddCom(row) {
  429. let flag = false;
  430. this.compoundList.forEach((com) => {
  431. if (com.id == row.id) {
  432. flag = true;
  433. }
  434. });
  435. return flag;
  436. },
  437. cancleCompound(row) {
  438. let indexNum = null;
  439. this.compoundList.forEach((com, index) => {
  440. if (com.id == row.id) {
  441. indexNum = index;
  442. if (row.type == "HIGH") this.hightCount--;
  443. if (row.type == "HIGH_ONLINE") this.hightOnlineCount--;
  444. }
  445. });
  446. if (indexNum + "") {
  447. this.compoundList.splice(indexNum, 1);
  448. }
  449. },
  450. clearCom() {
  451. this.compoundList = [];
  452. this.hightOnlineCount = 0;
  453. this.hightCount = 0;
  454. },
  455. permission(str, parent) {
  456. return permission(str, parent);
  457. },
  458. exportClassGroup() {
  459. let params = this.searchForm;
  460. Export(
  461. this,
  462. {
  463. method: "post",
  464. url: "/api-web/export/classGroup",
  465. params: qs.stringify({
  466. ...params,
  467. organIds: this.searchForm.organIdList.join(","),
  468. lessThenThreeHighOnline: this.$route.query.lessThenThreeHighOnline,
  469. }),
  470. },
  471. "是否确认导出报表?"
  472. );
  473. },
  474. resetClassName(row) {
  475. this.classDetail = row;
  476. this.classNameVisible = true;
  477. },
  478. async submitedResetClassName(data) {
  479. const obj = {...data};
  480. resetClassName(obj).then((res) => {
  481. if (res.code == 200) {
  482. this.$message.success("修改成功");
  483. this.classNameVisible = false;
  484. this.getList();
  485. }
  486. });
  487. },
  488. },
  489. };
  490. </script>
  491. <style lang='scss' scoped>
  492. </style>