teamClassList.vue 14 KB

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