teamClassList.vue 13 KB

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