transStudent.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="选择学员"
  5. append-to-body
  6. width="800px"
  7. :visible.sync="transStudentVisible"
  8. >
  9. <el-form
  10. :model="form"
  11. ref="form"
  12. label-suffix=": "
  13. inline
  14. label-width="90px"
  15. >
  16. <el-row>
  17. <el-col :span="12">
  18. <el-form-item
  19. :label="'声部筛选'"
  20. style="margin-right: 0"
  21. prop="sound"
  22. >
  23. <select-all
  24. v-model="form.sound"
  25. style="width: 100%"
  26. clearable
  27. multiple
  28. collapse-tags
  29. filterable
  30. placeholder="请选择声部"
  31. >
  32. <el-option
  33. v-for="(item, index) in soundList"
  34. :key="index"
  35. :label="item.name"
  36. :value="item.id"
  37. ></el-option>
  38. </select-all>
  39. </el-form-item>
  40. </el-col>
  41. </el-row>
  42. <el-transfer
  43. filterable
  44. :titles="['所有学员', '已选学员']"
  45. filter-placeholder="请输入学生姓名"
  46. :filter-method="filterStudent"
  47. v-model="seleched"
  48. :render-content="renderFunc"
  49. :data="data"
  50. :class="{ hideReturn: !canDelUser }"
  51. >
  52. <template #left-footer>
  53. <div class="footer line">
  54. <span>姓名</span>
  55. <span>性别</span>
  56. <span>专业</span>
  57. </div>
  58. </template>
  59. <template #right-footer>
  60. <div class="footer line">
  61. <span>姓名</span>
  62. <span>性别</span>
  63. <span>专业</span>
  64. </div>
  65. </template>
  66. </el-transfer>
  67. </el-form>
  68. <div slot="footer" class="dialog-footer">
  69. <el-button @click="$listeners.close">取 消</el-button>
  70. <el-button type="primary" @click="submit">确 定</el-button>
  71. </div>
  72. </el-dialog>
  73. </div>
  74. </template>
  75. <script>
  76. import { genderType } from "@/constant";
  77. import { uniqBy } from "lodash";
  78. export default {
  79. props: ["studentList", "soundList", "activeType", "activeListStudent"],
  80. computed: {
  81. data() {
  82. return uniqBy([...this.studentList, ...this.activeListStudent], "userId")
  83. .filter((item) => {
  84. if (this.form.sound.length) {
  85. return (
  86. this.form.sound.includes(item.subjectId) ||
  87. this.seleched.includes(item.userId)
  88. );
  89. }
  90. return true;
  91. })
  92. .map((item) => ({
  93. value: item.userId,
  94. key: item.userId,
  95. name: item.name,
  96. subjectName: item.subjectName,
  97. gender: genderType[item.gender],
  98. }));
  99. },
  100. showName() {
  101. return !this.isOnlyChangeUser && this.activeType != "MUSIC_NETWORK";
  102. },
  103. canDelUser() {
  104. // console.log(this.isStudentRemove)
  105. return (
  106. this.$route.query.type !== "resetTeam" ||
  107. !this.isOnlyChangeUser ||
  108. this.isStudentRemove
  109. );
  110. },
  111. },
  112. data() {
  113. return {
  114. sound: [],
  115. form: {
  116. name: "",
  117. coreTeacher: "",
  118. assistant: "",
  119. sound: [],
  120. },
  121. seleched: [],
  122. transStudentVisible: true,
  123. };
  124. },
  125. watch: {
  126. activeListStudent() {
  127. this.setSelectedUser();
  128. },
  129. },
  130. mounted() {
  131. this.setSelectedUser();
  132. },
  133. methods: {
  134. setSelectedUser() {
  135. const ids = this.activeListStudent.map((item) => item.userId);
  136. this.seleched = [...ids];
  137. },
  138. filterStudent(query, item) {
  139. return (
  140. item.name.indexOf(query) > -1 ||
  141. item.subjectName.indexOf(query) > -1 ||
  142. item.gender.indexOf(query) > -1
  143. );
  144. },
  145. renderFunc(h, option) {
  146. return (
  147. <div class="line">
  148. <el-tooltip
  149. class="item"
  150. effect="dark"
  151. placement="top"
  152. open-delay={300}
  153. >
  154. <span slot="content">{option.name}</span>
  155. <span class="select-item">{option.name}</span>
  156. </el-tooltip>
  157. <span>{option.gender}</span>
  158. <el-tooltip
  159. class="item"
  160. effect="dark"
  161. placement="top"
  162. open-delay={300}
  163. >
  164. <span slot="content">{option.subjectName}</span>
  165. <span class="select-item">{option.subjectName}</span>
  166. </el-tooltip>
  167. </div>
  168. );
  169. },
  170. change(val) {
  171. this.$listeners.changeActiveChioseSound(val);
  172. this.$listeners.searchStudent();
  173. },
  174. submit() {
  175. if (
  176. !this.isOnlyChangeUser &&
  177. this.activeType == "HIGH_ONLINE" &&
  178. (this.seleched.length < 1 || this.seleched.length > 6)
  179. ) {
  180. return this.$message.error("线上技能班必须为1-6人");
  181. }
  182. this.$emit("submit", this.seleched);
  183. this.transStudentVisible = false
  184. },
  185. openDialog() {
  186. this.transStudentVisible = true;
  187. },
  188. },
  189. };
  190. </script>
  191. <style lang="less" scoped>
  192. ::v-deep .el-transfer {
  193. display: flex;
  194. align-items: center;
  195. .el-transfer__buttons {
  196. display: flex;
  197. width: 110px;
  198. flex-direction: column;
  199. > button {
  200. &:last-child {
  201. margin-left: 0;
  202. }
  203. }
  204. }
  205. .el-transfer-panel {
  206. width: 300px;
  207. }
  208. }
  209. .footer {
  210. margin-left: 35px;
  211. margin-right: auto;
  212. height: 40px;
  213. line-height: 40px;
  214. }
  215. .hideReturn {
  216. ::v-deep .el-transfer__buttons button:first-child {
  217. display: none;
  218. }
  219. }
  220. ::v-deep .el-checkbox-group {
  221. padding-bottom: 40px;
  222. }
  223. ::v-deep .line {
  224. width: 220px;
  225. display: flex;
  226. justify-content: space-around;
  227. height: 30px;
  228. line-height: 30px;
  229. .select-item {
  230. width: 33.33333%;
  231. white-space: nowrap;
  232. overflow: hidden;
  233. text-overflow: ellipsis;
  234. }
  235. }
  236. ::v-deep .dialog-footer {
  237. margin-top: 20px;
  238. display: block;
  239. text-align: right;
  240. }
  241. </style>