addStudentModel.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. <template>
  2. <div>
  3. <el-dialog
  4. width="1000px"
  5. title="添加学员"
  6. :visible.sync="lookVisible"
  7. :before-close="onClose"
  8. append-to-body
  9. >
  10. <div>
  11. <el-form :inline="true" :model="searchForm">
  12. <el-form :inline="true" :model="searchForm">
  13. <el-form-item>
  14. <el-input
  15. v-model.trim="searchForm.search"
  16. clearable
  17. @keyup.enter.native="search"
  18. placeholder="学员名/编号/手机号"
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item prop="organIdList">
  22. <select-all
  23. class="multiple"
  24. clearable
  25. filterable
  26. collapse-tags
  27. multiple
  28. v-model.trim="searchForm.organIdList"
  29. placeholder="请选择分部"
  30. @change="onBranchChange"
  31. >
  32. <el-option
  33. v-for="(item, index) in selects.branchs"
  34. :key="index"
  35. :label="item.name"
  36. :value="item.id"
  37. ></el-option>
  38. </select-all>
  39. </el-form-item>
  40. <el-form-item>
  41. <el-select
  42. multiple
  43. collapse-tags
  44. v-model.trim="searchForm.cooperationOrganId"
  45. clearable
  46. filterable
  47. placeholder="请选择合作单位"
  48. :disabled="searchForm.organIdList.length <= 0"
  49. >
  50. <el-option
  51. v-for="(item, index) in cooperationList"
  52. :key="index"
  53. :value="item.id"
  54. :label="item.name"
  55. ></el-option>
  56. </el-select>
  57. </el-form-item>
  58. <el-form-item>
  59. <el-select
  60. multiple
  61. collapse-tags
  62. :disabled="searchForm.organIdList.length <= 0"
  63. v-model.trim="searchForm.musicGroupId"
  64. clearable
  65. filterable
  66. placeholder="请选择乐团"
  67. >
  68. <el-option
  69. v-for="(item, index) in teamList"
  70. :key="index"
  71. :value="item.id"
  72. :label="item.name"
  73. ></el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item prop="subjectId">
  77. <el-select
  78. v-model="searchForm.subjectId"
  79. clearable
  80. filterable
  81. placeholder="请选择声部"
  82. >
  83. <el-option
  84. v-for="item in selects.subjects"
  85. :value="item.id"
  86. :label="item.name"
  87. :key="item.id"
  88. ></el-option>
  89. </el-select>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-select
  93. multiple
  94. collapse-tags
  95. v-model.trim="searchForm.groupList"
  96. clearable
  97. filterable
  98. placeholder="请选择群聊"
  99. >
  100. <el-option
  101. v-for="(item, index) in groupList"
  102. :key="index"
  103. :value="item.id"
  104. :label="item.name"
  105. ></el-option>
  106. </el-select>
  107. </el-form-item>
  108. <el-form-item>
  109. <el-button @click="search" type="primary">搜索</el-button>
  110. <el-button @click="onReSet" type="danger">重置</el-button>
  111. </el-form-item>
  112. </el-form>
  113. </el-form>
  114. <auth auths="imLiveRoomPurview/addByCondition">
  115. <el-button @click="addAllStudent" type="primary" style="margin-bottom: 10px"
  116. >一键添加</el-button
  117. >
  118. </auth>
  119. <div class="tableWrap">
  120. <el-table
  121. style="width: 100%"
  122. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  123. :data="tableList"
  124. @selection-change="handleSelectionChange"
  125. @select="onTableSelect"
  126. ref="multipleSelection"
  127. >
  128. <el-table-column type="selection" width="55"> </el-table-column>
  129. <el-table-column
  130. align="center"
  131. prop="userId"
  132. label="学员编号"
  133. ></el-table-column>
  134. <el-table-column
  135. align="center"
  136. prop="username"
  137. label="学员姓名"
  138. ></el-table-column>
  139. <el-table-column align="center" prop="phone" label="手机号">
  140. </el-table-column>
  141. <el-table-column align="center" prop="subjectName" label="声部">
  142. </el-table-column>
  143. </el-table>
  144. <pagination
  145. sync
  146. :total.sync="rules.total"
  147. :page.sync="rules.page"
  148. :limit.sync="rules.limit"
  149. :page-sizes="rules.page_size"
  150. @pagination="getList"
  151. />
  152. </div>
  153. </div>
  154. <div slot="footer" class="dialog-footer">
  155. <el-button type="primary" @click="submit">确 定</el-button>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { addLiveStudentList, getWaitLiveStudentList, addByCondition } from "../api";
  162. import pagination from "@/components/Pagination/index";
  163. import { getGroupList } from "@/views/groupChatManager/api";
  164. import { queryByOrganId } from "@/api/systemManage";
  165. import { getTeamList } from "@/api/teamServer";
  166. export default {
  167. name: "eidtPostMsg",
  168. components: { pagination },
  169. data() {
  170. return {
  171. searchForm: {
  172. search: "",
  173. organIdList: [],
  174. cooperationOrganId: [],
  175. musicGroupId: [],
  176. groupList: [],
  177. },
  178. tableList: [],
  179. organList: [],
  180. cooperationList: [],
  181. groupList: [],
  182. teamList: [],
  183. rules: {
  184. // 分页规则
  185. limit: 10, // 限制显示条数
  186. page: 1, // 当前页
  187. total: 0, // 总条数
  188. page_size: [10, 20, 40, 50], // 选择限制显示条数
  189. },
  190. addMuiscVisible: false,
  191. multipleSelection: [],
  192. chioseIdList: [],
  193. isNewPage: false,
  194. lookVisible: false,
  195. activeRow: { sendFlag: false },
  196. };
  197. },
  198. mounted() {
  199. this.$store.dispatch("setSubjects");
  200. this.$store.dispatch("setBranchs");
  201. this.getGroupList();
  202. },
  203. methods: {
  204. async getGroupList() {
  205. console.log("getGroupList");
  206. try {
  207. const res = await getGroupList({ page: 1, rows: 9999 });
  208. this.groupList = res.data.rows;
  209. } catch (e) {
  210. console.log(e);
  211. }
  212. },
  213. async getList() {
  214. try {
  215. const {
  216. organIdList,
  217. cooperationOrganId,
  218. musicGroupId,
  219. groupList,
  220. ...rest
  221. } = this.searchForm;
  222. const res = await getWaitLiveStudentList({
  223. organIds: organIdList.join(","),
  224. schoolIds: cooperationOrganId.join(","),
  225. teamIds: musicGroupId.join(","),
  226. groupIds: groupList.join(","),
  227. ...rest,
  228. page: this.rules.page,
  229. rows: this.rules.limit,
  230. roomUid: this.activeRow.roomUid,
  231. });
  232. this.tableList = res.data.rows;
  233. this.rules.total = res.data.total;
  234. let idList = this.chioseIdList.map((group) => {
  235. return group.userId;
  236. });
  237. this.isNewPage = true;
  238. this.$nextTick(() => {
  239. this.tableList.forEach((course) => {
  240. if (idList.indexOf(course.userId) != -1) {
  241. this.$refs.multipleSelection.toggleRowSelection(course, true);
  242. }
  243. });
  244. this.isNewPage = false;
  245. });
  246. } catch (e) {
  247. console.log(e);
  248. }
  249. },
  250. search() {
  251. this.rules.page = 1;
  252. this.getList();
  253. },
  254. onReSet() {
  255. (this.searchForm = {
  256. search: "",
  257. organIdList: [],
  258. cooperationOrganId: [],
  259. musicGroupId: [],
  260. groupList: [],
  261. }),
  262. this.clearCom();
  263. this.search();
  264. this.clearCom();
  265. this.search();
  266. },
  267. async submit() {
  268. if (!this.chioseIdList || this.chioseIdList.length <= 0) {
  269. this.$message.error("请至少选择一名学生");
  270. return;
  271. }
  272. try {
  273. let idList = this.chioseIdList
  274. .map((group) => {
  275. return group.userId;
  276. })
  277. .join(",");
  278. const res = await addLiveStudentList({
  279. ids: idList,
  280. roomUid: this.activeRow.roomUid,
  281. });
  282. this.$message.success("添加成功");
  283. this.$emit("getList");
  284. this.onClose();
  285. } catch (e) {
  286. console.log(e);
  287. }
  288. // 开始 addGroupMessageList
  289. /**
  290. *
  291. */
  292. console.log(this.chioseIdList);
  293. },
  294. handleSelectionChange(val) {
  295. if (val.length > 0) {
  296. this.chioseIdList = this.chioseIdList.concat(val);
  297. this.chioseIdList = this.$helpers.lodash.uniqBy(this.chioseIdList, "userId");
  298. } else {
  299. if (this.isNewPage) return;
  300. let idList = this.chioseIdList.map((group) => {
  301. return group.userId;
  302. });
  303. this.$nextTick(() => {
  304. let tableIdList = [];
  305. this.tableList.forEach((group) => {
  306. tableIdList.push(group.userId);
  307. if (idList.indexOf(group.userId) != -1) {
  308. this.$refs.multipleSelection.toggleRowSelection(group, false);
  309. }
  310. });
  311. this.chioseIdList = this.$helpers.lodash.remove(
  312. this.chioseIdList,
  313. function (item) {
  314. return tableIdList.indexOf(item.userId) == -1;
  315. }
  316. );
  317. if (this.chioseIdList.length <= 0) {
  318. this.clearCom();
  319. }
  320. });
  321. }
  322. },
  323. clearCom() {
  324. this.chioseIdList = [];
  325. this.$refs.multipleSelection.clearSelection();
  326. },
  327. onTableSelect(rows, row) {
  328. let idList = this.chioseIdList.map((group) => {
  329. return group.userId;
  330. });
  331. if (idList.indexOf(row.userId) != -1) {
  332. this.chioseIdList.splice(idList.indexOf(row.userId), 1);
  333. if (this.chioseIdList.length <= 0) {
  334. this.clearCom();
  335. }
  336. }
  337. },
  338. onClose() {
  339. this.clearCom();
  340. this.searchForm.search = "";
  341. this.lookVisible = false;
  342. },
  343. openDioag(row) {
  344. this.activeRow = row;
  345. this.lookVisible = true;
  346. this.getList();
  347. },
  348. async onBranchChange(val) {
  349. // this.searchForm.cooperationOrganId = [];
  350. this.$set(this.searchForm, "cooperationOrganId", []);
  351. this.$set(this.searchForm, "musicGroupId", []);
  352. if (val && val.length > 0) {
  353. let organId = val.join(",");
  354. try {
  355. await queryByOrganId({ organId }).then((res) => {
  356. if (res.code == 200) {
  357. this.cooperationList = res.data;
  358. }
  359. });
  360. await getTeamList({ organId, page: 1, rows: 9999, status: "PROGRESS" }).then(
  361. (res) => {
  362. if (res.code == 200) {
  363. this.teamList = res.data.rows;
  364. }
  365. }
  366. );
  367. } catch (e) {
  368. console.log(e);
  369. }
  370. }
  371. },
  372. async addAllStudent() {
  373. const {
  374. organIdList,
  375. cooperationOrganId,
  376. musicGroupId,
  377. groupList,
  378. ...rest
  379. } = this.searchForm;
  380. if (
  381. !organIdList.join(",") &&
  382. !cooperationOrganId.join(",") &&
  383. !musicGroupId.join(",") &&
  384. !groupList.join(",") &&
  385. !this.searchForm.search &&
  386. !subjectId
  387. ) {
  388. this.$message.error("请至少选择一个搜索条件");
  389. return;
  390. }
  391. try {
  392. await this.$confirm("确认后当前所选条件下所有学生都可观看直播", "提示", {
  393. type: "warning",
  394. });
  395. const res = await addByCondition({
  396. organIds: organIdList.join(","),
  397. schoolIds: cooperationOrganId.join(","),
  398. teamIds: musicGroupId.join(","),
  399. groupIds: groupList.join(","),
  400. ...rest,
  401. roomUid: this.activeRow.roomUid,
  402. });
  403. this.$message.success("添加成功");
  404. this.$emit("getList");
  405. this.onClose();
  406. } catch (e) {}
  407. },
  408. },
  409. };
  410. </script>
  411. <style lang="scss" scoped>
  412. .w100 {
  413. width: 100%;
  414. }
  415. .btnWrap {
  416. justify-content: flex-start;
  417. }
  418. </style>