studentBlacklist.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <el-page-header
  5. @back="onCancel"
  6. :content="$route.query.name + '黑名单'"
  7. ></el-page-header>
  8. </h2>
  9. <div class="m-core">
  10. <el-form :inline="true" :model="searchForm">
  11. <el-form-item>
  12. <el-input
  13. v-model.trim="searchForm.search"
  14. clearable
  15. @keyup.enter.native="search"
  16. placeholder="学员名/编号/手机号"
  17. ></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-button @click="search" type="primary">搜索</el-button>
  21. <el-button @click="onReSet" type="danger">重置</el-button>
  22. </el-form-item>
  23. </el-form>
  24. <div class="btnWrap">
  25. <auth auths="imLiveRoomBlack/add">
  26. <el-button
  27. @click="addBlack"
  28. type="primary"
  29. style="margin-bottom: 10px"
  30. >添加黑名单</el-button
  31. >
  32. </auth>
  33. <auth auths="imLiveRoomBlack/delete">
  34. <el-button @click="removes" type="primary" style="margin-bottom: 10px"
  35. >移除黑名单</el-button
  36. >
  37. </auth>
  38. </div>
  39. <div class="tableWrap">
  40. <el-table
  41. style="width: 100%"
  42. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  43. :data="tableList"
  44. @selection-change="handleSelectionChange"
  45. @select="onTableSelect"
  46. ref="multipleSelection"
  47. >
  48. <el-table-column type="selection" width="55"> </el-table-column>
  49. <el-table-column
  50. align="center"
  51. prop="userId"
  52. label="学员编号"
  53. ></el-table-column>
  54. <el-table-column
  55. align="center"
  56. prop="username"
  57. label="学员姓名"
  58. ></el-table-column>
  59. <el-table-column
  60. align="center"
  61. prop="phone"
  62. label="手机号"
  63. ></el-table-column>
  64. <el-table-column align="center" prop="studentId" label="操作">
  65. <template slot-scope="scope">
  66. <div>
  67. <auth auths="imLiveRoomBlack/delete">
  68. <el-button type="text" @click="deteleBlack(scope.row)"
  69. >删除</el-button
  70. >
  71. </auth>
  72. </div>
  73. </template>
  74. </el-table-column>
  75. </el-table>
  76. <pagination
  77. sync
  78. :total.sync="rules.total"
  79. :page.sync="rules.page"
  80. :limit.sync="rules.limit"
  81. :page-sizes="rules.page_size"
  82. @pagination="getList"
  83. />
  84. </div>
  85. </div>
  86. <setBlack @getList="getList" ref="setBlack" />
  87. </div>
  88. </template>
  89. <script>
  90. import { addLiveGoodsMapper, getBlackList, deteleBlackList } from "./api";
  91. import { getLiveGoodsMapperList } from "@/views/liveShopManger/api";
  92. import pagination from "@/components/Pagination/index";
  93. import setBlack from "./modals/setBlack";
  94. export default {
  95. name: "eidtPostMsg",
  96. components: { pagination, setBlack },
  97. data() {
  98. return {
  99. searchForm: {
  100. search: "",
  101. },
  102. tableList: [],
  103. organList: [],
  104. rules: {
  105. // 分页规则
  106. limit: 10, // 限制显示条数
  107. page: 1, // 当前页
  108. total: 0, // 总条数
  109. page_size: [10, 20, 40, 50], // 选择限制显示条数
  110. },
  111. addMuiscVisible: false,
  112. multipleSelection: [],
  113. chioseIdList: [],
  114. isNewPage: false,
  115. lookVisible: false,
  116. activeRow: { sendFlag: false },
  117. };
  118. },
  119. mounted() {
  120. this.getList();
  121. },
  122. methods: {
  123. async getList() {
  124. try {
  125. const res = await getBlackList({
  126. ...this.searchForm,
  127. page: this.rules.page,
  128. rows: this.rules.limit,
  129. roomUid: this.$route.query.roomUid,
  130. });
  131. this.tableList = res.data.rows;
  132. this.rules.total = res.data.total;
  133. let idList = this.chioseIdList.map((group) => {
  134. return group.userId;
  135. });
  136. this.isNewPage = true;
  137. this.$nextTick(() => {
  138. this.tableList.forEach((course) => {
  139. if (idList.indexOf(course.userId) != -1) {
  140. this.$refs.multipleSelection.toggleRowSelection(course, true);
  141. }
  142. });
  143. this.isNewPage = false;
  144. });
  145. } catch (e) {
  146. console.log(e);
  147. }
  148. },
  149. search() {
  150. this.rules.page = 1;
  151. this.getList();
  152. },
  153. onReSet() {
  154. this.searchForm.search = "";
  155. this.clearCom();
  156. this.search();
  157. },
  158. async submit() {
  159. if (!this.chioseIdList || this.chioseIdList.length <= 0) {
  160. this.$message.error("请至少选择一名学员");
  161. return;
  162. }
  163. try {
  164. let idList = this.chioseIdList
  165. .map((group) => {
  166. return group.userId;
  167. })
  168. .join(",");
  169. const res = await addLiveGoodsMapper({
  170. liveGoodsIds: idList,
  171. liveId: this.activeRow.roomUid,
  172. });
  173. this.$message.success("添加成功");
  174. this.$emit("getList");
  175. this.onClose();
  176. } catch (e) {
  177. console.log(e);
  178. }
  179. // 开始 addGroupMessageList
  180. /**
  181. *
  182. */
  183. console.log(this.chioseIdList);
  184. },
  185. handleSelectionChange(val) {
  186. if (val.length > 0) {
  187. this.chioseIdList = this.chioseIdList.concat(val);
  188. this.chioseIdList = this.$helpers.lodash.uniqBy(
  189. this.chioseIdList,
  190. "userId"
  191. );
  192. } else {
  193. if (this.isNewPage) return;
  194. let idList = this.chioseIdList.map((group) => {
  195. return group.userId;
  196. });
  197. this.$nextTick(() => {
  198. let tableIdList = [];
  199. this.tableList.forEach((group) => {
  200. tableIdList.push(group.userId);
  201. if (idList.indexOf(group.userId) != -1) {
  202. this.$refs.multipleSelection.toggleRowSelection(group, false);
  203. }
  204. });
  205. this.chioseIdList = this.$helpers.lodash.remove(
  206. this.chioseIdList,
  207. function (item) {
  208. return tableIdList.indexOf(item.userId) == -1;
  209. }
  210. );
  211. if (this.chioseIdList.length <= 0) {
  212. this.clearCom();
  213. }
  214. });
  215. }
  216. },
  217. clearCom() {
  218. this.chioseIdList = [];
  219. this.$refs.multipleSelection.clearSelection();
  220. },
  221. onTableSelect(rows, row) {
  222. let idList = this.chioseIdList.map((group) => {
  223. return group.userId;
  224. });
  225. if (idList.indexOf(row.userId) != -1) {
  226. this.chioseIdList.splice(idList.indexOf(row.userId), 1);
  227. if (this.chioseIdList.length <= 0) {
  228. this.clearCom();
  229. }
  230. }
  231. },
  232. onCancel() {
  233. this.$router.push("/liveClassManager");
  234. this.$store.dispatch("delVisitedViews", this.$route);
  235. },
  236. async deteleBlack(row) {
  237. this.$confirm(`你确定将${row.username}移除黑名单?`, "提示", {
  238. confirmButtonText: "确定",
  239. cancelButtonText: "取消",
  240. type: "warning",
  241. })
  242. .then(async () => {
  243. try {
  244. const res = await deteleBlackList({
  245. roomUid: this.$route.query.roomUid,
  246. userIdList: row.userId + "",
  247. });
  248. this.getList();
  249. } catch (e) {
  250. console.log(e);
  251. }
  252. })
  253. .catch();
  254. },
  255. addBlack() {
  256. this.$refs.setBlack.openDioag({ roomUid: this.$route.query.roomUid });
  257. },
  258. removes() {
  259. if (!this.chioseIdList || this.chioseIdList.length <= 0) {
  260. this.$message.error("请至少选择一名学员");
  261. return;
  262. }
  263. let str = this.chioseIdList
  264. .map((group) => {
  265. return group.username;
  266. })
  267. .join(",");
  268. this.$confirm(`你确定将${str}移除黑名单?`, "提示", {
  269. confirmButtonText: "确定",
  270. cancelButtonText: "取消",
  271. type: "warning",
  272. })
  273. .then(async () => {
  274. let idList = this.chioseIdList
  275. .map((group) => {
  276. return group.userId;
  277. })
  278. .join(",");
  279. try {
  280. const res = await deteleBlackList({
  281. roomUid: this.$route.query.roomUid,
  282. userIdList: idList,
  283. });
  284. this.$message.success("删除成功");
  285. this.getList();
  286. } catch (e) {
  287. console.log(e);
  288. }
  289. })
  290. .catch();
  291. },
  292. },
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. .w100 {
  297. width: 100%;
  298. }
  299. .btnWrap {
  300. justify-content: flex-start;
  301. }
  302. </style>