chatDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <!-- -->
  2. <template>
  3. <div class="m-container">
  4. <h2>
  5. <el-page-header @back="onCancel" :content="detail.name"></el-page-header>
  6. </h2>
  7. <div class="m-core">
  8. <descriptions :column="3" class="desc">
  9. <descriptions-item label="群聊名称:">
  10. <div class="flexBox">
  11. {{ detail.name || "--" }}
  12. <i class="el-icon-edit" @click="reseDetail('name')"></i>
  13. </div>
  14. </descriptions-item>
  15. <descriptions-item label="所属乐团:">
  16. <div class="flexBox">
  17. {{ detail.memo || "--" }}
  18. <i class="el-icon-edit" @click="reseDetail('memo')"></i>
  19. </div>
  20. </descriptions-item>
  21. <descriptions-item label="群聊类型:">
  22. <div class="flexBox">
  23. {{ detail.groupType | catgGoupType }}
  24. <i class="el-icon-edit" @click="reseDetail('type')"></i>
  25. </div>
  26. </descriptions-item>
  27. </descriptions>
  28. <save-form
  29. :inline="true"
  30. :model="searchForm"
  31. @submit="search"
  32. @reset="onReSet"
  33. ref="searchForm"
  34. >
  35. <el-form-item prop="search">
  36. <el-input
  37. v-model="searchForm.search"
  38. placeholder="成员姓名/手机号"
  39. ></el-input>
  40. </el-form-item>
  41. <el-form-item prop="roleType">
  42. <el-select
  43. v-model.trim="searchForm.roleType"
  44. filterable
  45. clearable
  46. placeholder="角色"
  47. >
  48. <el-option
  49. v-for="(item, index) in catRoleList"
  50. :key="index"
  51. :label="item.label"
  52. :value="item.value"
  53. ></el-option>
  54. </el-select>
  55. </el-form-item>
  56. <el-form-item>
  57. <el-button native-type="submit" type="primary">搜索</el-button>
  58. <el-button native-type="reset" type="danger">重置</el-button>
  59. </el-form-item>
  60. </save-form>
  61. <div class="bWrap">
  62. <!-- -->
  63. <auth auths="imGroupMember/addGroupMember">
  64. <el-button type="primary" @click="addMembers">添加成员</el-button>
  65. </auth>
  66. <auth auths="imGroup/quitGroup" style="margin-left: 10px">
  67. <el-button type="danger" @click="deteleMembers">移除成员</el-button>
  68. </auth>
  69. </div>
  70. <div class="tableWrap">
  71. <el-table
  72. style="width: 100%"
  73. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  74. :data="tableList"
  75. @selection-change="handleSelectionChange"
  76. @select="onTableSelect"
  77. ref="multipleSelection"
  78. >
  79. <el-table-column type="selection" width="55"> </el-table-column>
  80. <el-table-column
  81. align="center"
  82. prop="userId"
  83. label="编号"
  84. ></el-table-column>
  85. <el-table-column
  86. align="center"
  87. prop="user.username"
  88. label="姓名"
  89. ></el-table-column>
  90. <el-table-column
  91. align="center"
  92. prop="user.phone"
  93. label="手机号"
  94. ></el-table-column>
  95. <el-table-column align="center" prop="roleType" label="角色">
  96. <template slot-scope="scope">
  97. <div>
  98. {{ scope.row.roleType ? scope.row.roleType : "学员" }}
  99. </div>
  100. </template>
  101. </el-table-column>
  102. <el-table-column align="center" prop="roleType" label="操作">
  103. <template slot-scope="scope">
  104. <div>
  105. <auth auths="imGroup/updateRoleType" v-if="scope.row.roleType">
  106. <el-button type="text" @click="resetroleType(scope.row)"
  107. >修改角色</el-button
  108. >
  109. </auth>
  110. <auth auths="imGroup/quitGroup" v-if="!scope.row.sendFlag">
  111. <el-button type="text" @click="deleteStudent(scope.row)"
  112. >移除成员</el-button
  113. >
  114. </auth>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <pagination
  120. sync
  121. :total.sync="rules.total"
  122. :page.sync="rules.page"
  123. :limit.sync="rules.limit"
  124. :page-sizes="rules.page_size"
  125. @pagination="getList"
  126. />
  127. </div>
  128. </div>
  129. <eidtCatInfo ref="eidtCatInfo" @getList="getDetail" />
  130. <addMember ref="addMember" @getList="getList" />
  131. <resetRoleType ref="resetRoleType" @getList="getList" />
  132. </div>
  133. </template>
  134. <script>
  135. import axios from "axios";
  136. import { getToken } from "@/utils/auth";
  137. import pagination from "@/components/Pagination/index";
  138. import load from "@/utils/loading";
  139. import { getGroupMemberList, getGroupDetail, quitGroupMember } from "./api";
  140. import { getSubject } from "@/api/buildTeam";
  141. import countTo from "vue-count-to";
  142. import { catRoleList } from "@/utils/searchArray";
  143. import eidtCatInfo from "./model/eidtCatInfo";
  144. import resetRoleType from "./model/resetRoleType";
  145. import addMember from "./model/addMember";
  146. // catRoleFilter
  147. export default {
  148. components: {
  149. pagination,
  150. "count-to": countTo,
  151. eidtCatInfo,
  152. addMember,
  153. resetRoleType,
  154. },
  155. data() {
  156. return {
  157. catRoleList,
  158. searchForm: {
  159. search: null,
  160. groupType: null,
  161. },
  162. detail: {
  163. groupType: "",
  164. id: "",
  165. img: "",
  166. introduce: "",
  167. memberNum: 0,
  168. memo: "",
  169. name: "",
  170. tags: "",
  171. tenantId: 0,
  172. type: "",
  173. },
  174. chatName: "",
  175. tableList: [{}],
  176. soundList: [],
  177. cooperationList: [],
  178. musicList: [],
  179. rules: {
  180. // 分页规则
  181. limit: 10, // 限制显示条数
  182. page: 1, // 当前页
  183. total: 0, // 总条数
  184. page_size: [10, 20, 40, 50], // 选择限制显示条数
  185. },
  186. multipleSelection: [],
  187. chioseIdList: [],
  188. isNewPage: false,
  189. };
  190. },
  191. //生命周期 - 创建完成(可以访问当前this实例)
  192. created() {},
  193. //生命周期 - 挂载完成(可以访问DOM元素)
  194. mounted() {
  195. // 获取分部
  196. this.imGroupId = this.$route.query.imGroupId;
  197. this.$store.dispatch("setBranchs");
  198. this.init();
  199. },
  200. methods: {
  201. init() {
  202. getSubject({}).then((res) => {
  203. if (res.code == 200) {
  204. this.soundList = res.data;
  205. }
  206. });
  207. this.getDetail();
  208. this.getList();
  209. },
  210. async getDetail() {
  211. try {
  212. const res = await getGroupDetail({ imGroupId: this.imGroupId });
  213. this.detail = { ...res.data };
  214. } catch (e) {
  215. console.log(e);
  216. }
  217. },
  218. async getList() {
  219. try {
  220. const res = await getGroupMemberList({
  221. page: this.rules.page,
  222. rows: this.rules.limit,
  223. ...this.searchForm,
  224. imGroupId: this.$route.query.imGroupId,
  225. });
  226. // this.tableList = res.data;
  227. this.tableList = res.data.rows;
  228. this.rules.total = res.data.total;
  229. let idList = this.chioseIdList.map((group) => {
  230. return group.id;
  231. });
  232. this.isNewPage = true;
  233. this.$nextTick(() => {
  234. this.tableList.forEach((course) => {
  235. if (idList.indexOf(course.id) != -1) {
  236. this.$refs.multipleSelection.toggleRowSelection(course, true);
  237. }
  238. });
  239. this.isNewPage = false;
  240. });
  241. } catch (e) {
  242. console.log(e);
  243. }
  244. },
  245. search() {
  246. this.rules.page = 1;
  247. this.getList();
  248. },
  249. handleSelectionChange(val) {
  250. if (val.length > 0) {
  251. this.chioseIdList = this.chioseIdList.concat(val);
  252. this.chioseIdList = this.$helpers.lodash.uniqBy(
  253. this.chioseIdList,
  254. "id"
  255. );
  256. } else {
  257. if (this.isNewPage) return;
  258. let idList = this.chioseIdList.map((group) => {
  259. return group.id;
  260. });
  261. this.$nextTick(() => {
  262. let tableIdList = [];
  263. this.tableList.forEach((group) => {
  264. tableIdList.push(group.id);
  265. if (idList.indexOf(group.id) != -1) {
  266. this.$refs.multipleSelection.toggleRowSelection(group, false);
  267. }
  268. });
  269. this.chioseIdList = this.$helpers.lodash.remove(
  270. this.chioseIdList,
  271. function (item) {
  272. return tableIdList.indexOf(item.id) == -1;
  273. }
  274. );
  275. if (this.chioseIdList.length <= 0) {
  276. this.clearCom();
  277. }
  278. });
  279. }
  280. },
  281. clearCom() {
  282. this.chioseIdList = [];
  283. this.$refs.multipleSelection.clearSelection();
  284. },
  285. onTableSelect(rows, row) {
  286. let idList = this.chioseIdList.map((group) => {
  287. return group.id;
  288. });
  289. if (idList.indexOf(row.id) != -1) {
  290. this.chioseIdList.splice(idList.indexOf(row.id), 1);
  291. if (this.chioseIdList.length <= 0) {
  292. this.clearCom();
  293. }
  294. }
  295. },
  296. onReSet() {
  297. this.rules = {
  298. ...this.rules,
  299. page: 1,
  300. };
  301. this.$refs.searchForm.resetFields();
  302. this.search();
  303. },
  304. onCancel() {
  305. this.$store.dispatch("delVisitedViews", this.$route);
  306. this.$router.push({
  307. path: "/groupChatManager",
  308. });
  309. },
  310. async deleteStudent(row) {
  311. try {
  312. await this.$confirm(
  313. `是否确认移除成员 "${row.user.username}" ?`,
  314. "提示",
  315. {
  316. type: "warning",
  317. }
  318. );
  319. await quitGroupMember({
  320. imGroupId: this.$route.query.imGroupId,
  321. userId: row.userId,
  322. });
  323. this.$message.success("移除成功");
  324. this.getList();
  325. } catch (error) {
  326. console.log(error);
  327. }
  328. },
  329. reseDetail(type) {
  330. this.$refs.eidtCatInfo.openResetDioag(this.detail, type);
  331. },
  332. addMembers() {
  333. this.$refs.addMember.openDioag();
  334. },
  335. async deteleMembers() {
  336. if (!this.chioseIdList || this.chioseIdList.length <= 0) {
  337. this.$message.error(`请至少选择一位${str}`);
  338. return;
  339. }
  340. try {
  341. let idList = this.chioseIdList
  342. .map((group) => {
  343. return group.userId;
  344. })
  345. .join(",");
  346. let strName = this.chioseIdList
  347. .map((group) => {
  348. return group.user.username;
  349. })
  350. .join(",");
  351. strName.substring(0, strName.length - 1);
  352. await this.$confirm(`是否确认移除成员 "${strName}" ?`, "提示", {
  353. type: "warning",
  354. });
  355. await quitGroupMember({
  356. imGroupId: this.$route.query.imGroupId,
  357. userId: idList,
  358. });
  359. this.$message.success("移除成功");
  360. this.getList();
  361. } catch (error) {
  362. console.log(error);
  363. }
  364. },
  365. resetroleType(row) {
  366. this.$refs.resetRoleType.openDioag(row);
  367. },
  368. },
  369. };
  370. </script>
  371. <style lang='scss' scoped>
  372. .bWrap {
  373. display: flex;
  374. flex-direction: row;
  375. margin-bottom: 20px;
  376. }
  377. .statistic {
  378. .statistic-content > span {
  379. font-size: 20px !important;
  380. &:first-child {
  381. font-size: 24px !important;
  382. color: rgba(0, 0, 0, 0.85);
  383. font-weight: bold;
  384. }
  385. }
  386. }
  387. .desc {
  388. margin-bottom: 20px;
  389. }
  390. .flexBox {
  391. display: flex;
  392. flex-direction: row;
  393. align-items: center;
  394. justify-content: space-between;
  395. i {
  396. font-size: 18px;
  397. cursor: pointer;
  398. }
  399. }
  400. </style>