studentBlacklist.vue 8.7 KB

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