addStudentList.vue 14 KB

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