transClass.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="创建班级"
  5. append-to-body
  6. width="800px"
  7. :visible.sync="transClassVisible"
  8. >
  9. <div v-if="transClassVisible">
  10. <el-alert type="warning" :closable="false" class="tramsAlert">
  11. <p class="title">温馨提醒:</p>
  12. <p class="descript">您正在操作声部课、集训声部课转换线上基础技能课</p>
  13. <p class="descript">
  14. 若转换后仅创建1个线上基础技能班,转换后班级将根据转换前课程总时长排课
  15. </p>
  16. <p class="descript">
  17. 若转转后创建多个线上基础技能班,则转换后班级按转换前课时数排课
  18. </p>
  19. </el-alert>
  20. <el-form :model="form" ref="form">
  21. <div
  22. class="classWrap"
  23. v-for="(item, index) in form.classList"
  24. :key="index"
  25. >
  26. <h2 class="classTitle">
  27. <span>线上基础技能班{{ index + 1 }}</span>
  28. <i
  29. @click="remove(index)"
  30. v-if="form.classList.length > 1"
  31. class="close-icon el-icon-delete-solid"
  32. ></i>
  33. </h2>
  34. <el-row :gutter="40">
  35. <el-col :span="12">
  36. <el-form-item
  37. :prop="'classList.' + index + '.name'"
  38. :rules="[
  39. {
  40. required: true,
  41. message: '输入班级名称',
  42. trigger: 'blur',
  43. },
  44. ]"
  45. ref="paymentDate"
  46. >
  47. <template slot="label">
  48. <p style="position: relative">
  49. <span style="color: #f56c6c; margin-right: 4px">*</span>
  50. 班级名称
  51. </p>
  52. </template>
  53. <el-input
  54. v-model="item.name"
  55. style="width: 100%"
  56. placeholder="请输入班级名称"
  57. />
  58. </el-form-item>
  59. </el-col>
  60. <el-col :span="12">
  61. <el-form-item
  62. :label="'声部'"
  63. style="margin-right: 0"
  64. :prop="'classList.' + index + '.subjectIdList'"
  65. :rules="[
  66. { required: true, message: '请选择声部', trigger: 'blur' },
  67. ]"
  68. >
  69. <template slot="label">
  70. <p style="position: relative">
  71. <span style="color: #f56c6c; margin-right: 4px">*</span>
  72. 网络教室声部
  73. </p>
  74. </template>
  75. <el-select
  76. v-model="item.subjectIdList"
  77. style="width: 100% !important"
  78. clearable
  79. collapse-tags
  80. filterable
  81. placeholder="请选择声部"
  82. >
  83. <el-option
  84. v-for="(item, index) in soundList"
  85. :key="index"
  86. :label="item.name"
  87. :value="item.id"
  88. ></el-option>
  89. </el-select>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row :gutter="40">
  94. <el-col :span="12">
  95. <el-form-item
  96. label="主教老师"
  97. :prop="'classList.' + index + '.coreTeacher'"
  98. :rules="[{ required: true, message: '请选择主教老师' }]"
  99. >
  100. <template slot="label">
  101. <p style="position: relative">
  102. <span style="color: #f56c6c; margin-right: 4px">*</span>
  103. 主教老师
  104. </p>
  105. </template>
  106. <el-select
  107. v-model.trim="item.coreTeacher"
  108. placeholder="请选择主教老师"
  109. clearable
  110. filterable
  111. style="width: 100% !important"
  112. >
  113. <el-option
  114. v-for="(item, index) in teacherList"
  115. :key="index"
  116. :label="item.realName"
  117. :value="String(item.id)"
  118. >
  119. <span style="float: left">{{ item.realName }}</span>
  120. <span
  121. style="float: right; color: #8492a6; font-size: 13px"
  122. >{{ String(item.id) }}</span
  123. >
  124. </el-option>
  125. </el-select>
  126. <!-- <remote-search :commit="'setTeachers'" v-model="form.coreTeacher" /> -->
  127. </el-form-item>
  128. </el-col>
  129. <el-col :span="12">
  130. <el-form-item>
  131. <template slot="label">
  132. <p style="position: relative">
  133. &nbsp;
  134. <!-- <span style="color: #f56c6c; margin-right: 4px">*</span> -->
  135. </p>
  136. </template>
  137. <div class="studentTitle">
  138. <p>
  139. 已选择<span style="color: red">{{
  140. item.studentList.length
  141. }}</span
  142. >名
  143. </p>
  144. <el-button type="text" @click="chioseStudent(index)"
  145. >选择学员 >></el-button
  146. >
  147. </div>
  148. </el-form-item>
  149. </el-col>
  150. </el-row>
  151. </div>
  152. <el-button class="addButton" @click="addClass">添加+</el-button>
  153. </el-form>
  154. <transStudent
  155. ref="transStudent"
  156. @close="
  157. () => {
  158. showStudentVisible = false;
  159. }
  160. "
  161. @submit="setStudent"
  162. v-if="showStudentVisible"
  163. :soundList="soundList"
  164. :studentList="studentList"
  165. :activeListStudent="activeListStudent"
  166. activeType="HIGH_ONLINE"
  167. />
  168. </div>
  169. <div slot="footer" class="dialog-footer">
  170. <el-button @click="transClassVisible = false">取 消</el-button>
  171. <el-button type="primary" @click="gotoNext">下一步</el-button>
  172. </div>
  173. </el-dialog>
  174. </div>
  175. </template>
  176. <script>
  177. import { getCourseScheduleConvert } from "../../api";
  178. import { findSound, getTeacher } from "@/api/buildTeam";
  179. import transStudent from "./transStudent";
  180. export default {
  181. props: {
  182. students: {
  183. type: Array,
  184. default: [],
  185. },
  186. },
  187. data() {
  188. return {
  189. transClassVisible: false,
  190. getStudentList: [],
  191. form: {
  192. classList: [
  193. {
  194. expectStudentNum: 6,
  195. groupType: "MUSIC",
  196. musicGroupId: this.$route.query.id,
  197. name: "",
  198. studentList: [],
  199. coreTeacher: "",
  200. type: "HIGH_ONLINE",
  201. },
  202. ],
  203. },
  204. soundList: [],
  205. teacherList: [],
  206. teamid: "",
  207. organId: "",
  208. showStudentVisible: false,
  209. activeStudentIndex: 0,
  210. activeListStudent: [],
  211. studentList: [],
  212. };
  213. },
  214. components: {
  215. transStudent,
  216. },
  217. mounted() {
  218. this.init();
  219. },
  220. methods: {
  221. async openDialog() {
  222. // 获取列表
  223. this.transClassVisible = true;
  224. },
  225. getList() {},
  226. gotoNext() {
  227. this.$refs.form.validate((flag) => {});
  228. },
  229. remove(index) {
  230. this.form.classList.splice(index, 1);
  231. },
  232. init() {
  233. this.teamid = this.$route.query.id;
  234. this.organId = this.$route.query.organId;
  235. getTeacher({ organId: this.organId }).then((res) => {
  236. if (res.code == 200) {
  237. this.teacherList = res.data;
  238. if (this.teacherList.length <= 0) {
  239. this.$bus.$emit("showguide", ["teacher"]);
  240. return;
  241. }
  242. }
  243. });
  244. findSound({ musicGroupId: this.teamid }).then((res) => {
  245. if (res.code == 200) {
  246. this.soundList = res.data;
  247. }
  248. });
  249. },
  250. addClass() {
  251. this.form.classList.push({
  252. expectStudentNum: 6,
  253. groupType: "MUSIC",
  254. musicGroupId: this.$route.query.id,
  255. name: "",
  256. studentList: [],
  257. coreTeacher: "",
  258. type: "HIGH_ONLINE",
  259. });
  260. },
  261. setStudent(student) {
  262. this.form.classList[this.activeStudentIndex].studentList = [...student];
  263. // 提交完的学生
  264. },
  265. chioseStudent(index) {
  266. this.activeStudentIndex = index;
  267. this.activeListStudent = [];
  268. this.students.forEach((item) => {
  269. if (
  270. this.form?.classList[index]?.studentList.indexOf(item.userId) != -1
  271. ) {
  272. this.activeListStudent.push(item);
  273. }
  274. });
  275. console.log(this.waitStudentList, this.waitStudentList.length);
  276. this.studentList = this.waitStudentList;
  277. this.showStudentVisible = true;
  278. this.$nextTick(() => {
  279. console.log(this.$refs.transStudent);
  280. this.$refs.transStudent.openDialog();
  281. });
  282. },
  283. },
  284. computed: {
  285. chioseCourse() {
  286. return this.activeCourseList;
  287. },
  288. waitStudentList() {
  289. let chioseIdList = [];
  290. this.form.classList.forEach((classes) => {
  291. classes.studentList.forEach((stu) => {
  292. chioseIdList.push(stu);
  293. });
  294. });
  295. console.log(chioseIdList)
  296. let arr = this.students.filter((item) => {
  297. console.log(chioseIdList.indexOf(item.userId) != -1)
  298. return chioseIdList.indexOf(item.userId) == -1;
  299. });
  300. return arr;
  301. },
  302. },
  303. };
  304. </script>
  305. <style lang="scss" scoped>
  306. .subtitle {
  307. margin-bottom: 20px;
  308. span {
  309. color: red;
  310. }
  311. }
  312. .tramsAlert {
  313. margin-bottom: 20px;
  314. p {
  315. font-size: 12px;
  316. line-height: 20px;
  317. }
  318. }
  319. .classWrap {
  320. background-color: #f2f2f2;
  321. padding: 20px 20px 10px;
  322. margin-bottom: 20px;
  323. .classTitle {
  324. // width: 760px;
  325. display: flex;
  326. flex-direction: row;
  327. align-items: center;
  328. justify-content: space-between;
  329. margin-bottom: 20px;
  330. .close-icon {
  331. color: #c1c1c1;
  332. cursor: pointer;
  333. // background: #c1c1c1;
  334. }
  335. }
  336. }
  337. ::v-deep .el-form-item__label {
  338. display: block;
  339. width: 100%;
  340. text-align: left;
  341. &::before {
  342. content: "" !important;
  343. position: absolute;
  344. color: transparent;
  345. margin-right: 4px;
  346. }
  347. }
  348. ::v-deep .el-form-item__content {
  349. display: block;
  350. margin-left: 0;
  351. }
  352. .addButton {
  353. width: 100%;
  354. }
  355. .studentTitle {
  356. display: flex;
  357. flex-direction: row;
  358. width: 100%;
  359. p {
  360. margin-right: 10px;
  361. }
  362. }
  363. </style>>