notice_user.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <div class="app-container">
  3. <el-col :span="1.5">
  4. <div style="font-size: 16px;margin-left: 12px;line-height: 32px;font-weight: 700;color: #606266;">公告标题:{{ noticeTitle }}</div>
  5. </el-col>
  6. <br />
  7. <!-- <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">-->
  8. <!-- <el-form-item label="姓名" prop="name">-->
  9. <!-- <el-input v-model="queryParams.name" @keyup.enter="handleQuery"/>-->
  10. <!-- </el-form-item>-->
  11. <!-- <el-form-item>-->
  12. <!-- <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>-->
  13. <!-- <el-button icon="Refresh" @click="resetQuery">重置</el-button>-->
  14. <!-- </el-form-item>-->
  15. <!-- </el-form>-->
  16. <el-row :gutter="10" class="mb8">
  17. <el-col :span="1.5">
  18. <el-button
  19. type="primary"
  20. plain
  21. icon="Plus"
  22. @click="handleAddUser"
  23. >添加用户
  24. </el-button>
  25. </el-col>
  26. <el-col :span="1.5">
  27. <el-button
  28. type="danger"
  29. plain
  30. icon="Delete"
  31. :disabled="multiple"
  32. @click="handleDelete"
  33. >移除用户
  34. </el-button>
  35. </el-col>
  36. <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
  37. </el-row>
  38. <el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange" :row-key="getRowKey">
  39. <el-table-column type="selection" width="55" align="center"/>
  40. <el-table-column label="名字" align="center" prop="nickName"/>
  41. <!-- <el-table-column label="类型" align="center" prop="userType"/>-->
  42. <el-table-column label="状态" align="center" prop="status">
  43. <template #default="scope">
  44. <div v-if="scope.row.status == '0'">
  45. <span class="el-tag el-tag--danger el-tag--light" index="1" data-v-00e5bcbc=""><span class="el-tag__content">未读</span><!--v-if--></span>
  46. </div>
  47. <div v-else>
  48. <span class="el-tag el-tag--default el-tag--light" index="1" data-v-00e5bcbc=""><span class="el-tag__content">已读</span><!--v-if--></span>
  49. </div>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  53. <template #default="scope">
  54. <div v-if="scope.row.status == '0'">
  55. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)">移除</el-button>
  56. </div>
  57. <div v-else>
  58. ——
  59. </div>
  60. </template>
  61. </el-table-column>
  62. </el-table>
  63. <pagination
  64. v-show="total>0"
  65. :total="total"
  66. v-model:page="queryParams.pageNum"
  67. v-model:limit="queryParams.pageSize"
  68. @pagination="getList"
  69. />
  70. <!--关联学生-->
  71. <el-dialog title="选择用户" v-model="userOpen" append-to-body :style="{ width:'1200px','overflow-y': 'auto' }" width="1200px">
  72. <UserList @sendUsersToNotice="getUsers"></UserList>
  73. <template #footer>
  74. <div class="dialog-footer">
  75. <el-button type="success" @click="addUser">添加用户</el-button>
  76. </div>
  77. </template>
  78. </el-dialog>
  79. </div>
  80. </template>
  81. <script setup name="noticeUser">
  82. import {listNoticeUser, addNoticeUser, removeNoticeUser, delNotice} from "@/api/system/notice";
  83. import UserList from "@/views/system/notice/choose_user.vue";
  84. import {delProtocol} from "@/api/care/protocol";
  85. const router = useRoute();
  86. const {proxy} = getCurrentInstance();
  87. const noticeId=ref("");
  88. const noticeTitle = ref("");
  89. const routerType = ref("");
  90. const userList = ref([]);
  91. const loading = ref(true);
  92. const userOpen = ref(false);
  93. const showSearch = ref(true);
  94. const ids = ref([]);
  95. const single = ref(true);
  96. const multiple = ref(true);
  97. const total = ref(0);
  98. const title = ref("");
  99. const addUsers = ref([]);
  100. const data = reactive({
  101. form: {},
  102. queryParams: {
  103. pageNum: 1,
  104. pageSize: 10,
  105. name: null,
  106. userType: null
  107. },
  108. });
  109. const {queryParams, form} = toRefs(data);
  110. /** 保存选中的数据编号 */
  111. function getRowKey(row) {
  112. return row.userId;
  113. }
  114. function getUsers(value) {
  115. addUsers.value = value;
  116. }
  117. /** 查询已选择的用户列表 */
  118. function getList() {
  119. loading.value = true;
  120. listNoticeUser(noticeId.value, queryParams.value).then(response => {
  121. userList.value = response.rows;
  122. total.value = response.total;
  123. loading.value = false;
  124. });
  125. }
  126. /** 搜索按钮操作 */
  127. function handleQuery() {
  128. queryParams.value.pageNum = 1;
  129. getList();
  130. }
  131. /** 重置按钮操作 */
  132. function resetQuery() {
  133. proxy.resetForm("queryRef");
  134. handleQuery();
  135. }
  136. // 多选框选中数据
  137. function handleSelectionChange(selection) {
  138. ids.value = selection.map(item => item.userId);
  139. single.value = selection.length !== 1;
  140. multiple.value = !selection.length;
  141. }
  142. /** 添加学生按钮操作 */
  143. function handleAddUser() {
  144. userOpen.value = true;
  145. title.value = "选择学生";
  146. }
  147. function addUser() {
  148. if (addUsers.value.length > 0) {
  149. console.info(JSON.stringify(noticeId.value)+"-----"+JSON.stringify(addUsers.value));
  150. addNoticeUser(noticeId.value, addUsers.value).then(res => {
  151. if (res.code === 200) {
  152. proxy.$modal.confirm("添加成功,人数总共:" + res.data + "人,是否继续添加?", "提示", {
  153. confirmButtonText: "继续添加",
  154. cancelButtonText: "关闭窗口",
  155. showClose: false,
  156. type: "success",
  157. }).catch(() => {
  158. getList();
  159. userOpen.value = false;
  160. });
  161. }
  162. })
  163. } else {
  164. proxy.$modal.msgWarning("请先选择用户后再添加");
  165. }
  166. }
  167. /** 删除按钮操作 */
  168. function handleDelete(row) {
  169. const noticeUserIds = row.noticeUserId ? [row.noticeUserId] : ids.value;
  170. proxy.$modal.confirm('是否确认移除该用户?"' + noticeUserIds + '"').then(function() {
  171. return removeNoticeUser(noticeUserIds);
  172. }).then(() => {
  173. getList();
  174. proxy.$modal.msgSuccess("移除成功");
  175. }).catch(() => {});
  176. }
  177. (() => {
  178. noticeId.value = router.params.id;
  179. noticeTitle.value = router.query && router.query.noticeTitle;
  180. if (noticeId.value) {
  181. loading.value = true;
  182. getList();
  183. loading.value = false;
  184. }
  185. })();
  186. </script>