index.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  4. <el-form-item label="是否机密" prop="isSecret">
  5. <el-switch v-model="form.isSecret" active-value="1" inactive-value="0" @change="shareChange()"> 如果选择机密,则共享用户打开时需要输入自己的用户密码才能查看。</el-switch>
  6. </el-form-item>
  7. <el-form-item label="阅后即焚" prop="onlyOneTime">
  8. <el-switch v-model="form.onlyOneTime" active-value="1" inactive-value="0" @change="shareChange()"> 如果阅后即焚,则共享用户只能打开一次。</el-switch>
  9. </el-form-item>
  10. </el-form>
  11. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  12. <el-form-item label="用户ID" prop="userId">
  13. <el-input v-model="queryParams.userId" placeholder="请输入用户ID" clearable @keyup.enter.native="handleQuery" />
  14. </el-form-item>
  15. <el-form-item label="用户姓名" prop="userName">
  16. <el-input v-model="queryParams.userName" placeholder="请输入用户姓名" clearable @keyup.enter.native="handleQuery" />
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  20. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <el-row :gutter="10" class="mb8">
  24. <el-col :span="1.5">
  25. <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  26. v-hasPermi="['doc:groupUser:add']">添加人员</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button type="danger" plain icon="el-icon-circle-close" size="mini" :disabled="multiple"
  30. @click="cancelGroupUserAll" v-hasPermi="['doc:groupUser:remove']">删除人员</el-button>
  31. </el-col>
  32. <el-col :span="1.5">
  33. <el-button type="warning" plain icon="el-icon-close" size="mini" @click="handleClose">关闭</el-button>
  34. </el-col>
  35. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  36. </el-row>
  37. <el-table v-loading="loading" :data="groupUserList" @selection-change="handleSelectionChange">
  38. <el-table-column type="selection" width="55" align="center" />
  39. <el-table-column label="用户名称" prop="userName" :show-overflow-tooltip="true" />
  40. <el-table-column label="用户昵称" prop="nickName" :show-overflow-tooltip="true" />
  41. <el-table-column label="邮箱" prop="email" :show-overflow-tooltip="true" />
  42. <el-table-column label="手机" prop="phonenumber" :show-overflow-tooltip="true" />
  43. <el-table-column label="状态" align="center" prop="status">
  44. <template slot-scope="scope">
  45. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status" />
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  49. <template slot-scope="scope">
  50. <el-button size="mini" type="text" icon="el-icon-circle-close" @click="cancelGroupUser(scope.row)"
  51. v-hasPermi="['doc:groupUser:remove']">删除人员</el-button>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
  56. @pagination="getList" />
  57. <select-user ref="select" :docId="queryParams.docId" @ok="handleQuery" />
  58. </div>
  59. </template>
  60. <script>
  61. import {
  62. listShareAccepter,
  63. getShareAccepter,
  64. delShareAccepter,
  65. addShareAccepter,
  66. updateShareAccepter,
  67. shareUserCancelAll
  68. } from "@/api/doc/shareAccepter";
  69. import {
  70. listShare,
  71. getShare,
  72. delShare,
  73. addShare,
  74. updateShare
  75. } from "@/api/doc/share";
  76. import selectUser from "./selectUser";
  77. export default {
  78. name: "GroupUser",
  79. dicts: ['sys_yes_no'],
  80. components: {
  81. selectUser
  82. },
  83. data() {
  84. return {
  85. // 遮罩层
  86. loading: true,
  87. // 选中数组
  88. ids: [],
  89. // 非单个禁用
  90. single: true,
  91. // 非多个禁用
  92. multiple: true,
  93. // 显示搜索条件
  94. showSearch: true,
  95. // 总条数
  96. total: 0,
  97. // 分组成员表格数据
  98. groupUserList: [],
  99. // 弹出层标题
  100. title: "",
  101. // 是否显示弹出层
  102. open: false,
  103. // 查询参数
  104. queryParams: {
  105. pageNum: 1,
  106. pageSize: 10,
  107. userId: null,
  108. userName: null
  109. },
  110. // 表单参数
  111. form: {},
  112. // 表单校验
  113. rules: {}
  114. };
  115. },
  116. created() {
  117. const docId = this.$route.params && this.$route.params.docId;
  118. if (docId) {
  119. this.queryParams.docId = docId;
  120. this.getList();
  121. }
  122. },
  123. methods: {
  124. shareChange() {
  125. this.form.docId = this.queryParams.docId;
  126. updateShare(this.form).then(response => {
  127. this.$modal.msgSuccess("修改成功");
  128. });
  129. },
  130. // 返回按钮
  131. handleClose() {
  132. const obj = {
  133. path: "/info"
  134. };
  135. this.$tab.closeOpenPage(obj);
  136. },
  137. /** 查询分组成员列表 */
  138. getList() {
  139. this.loading = true;
  140. getShare(this.queryParams.docId).then(response => {
  141. this.form.isSecret = response.data.isSecret;
  142. this.form.onlyOneTime = response.data.onlyOneTime;
  143. });
  144. listShareAccepter(this.queryParams).then(response => {
  145. this.groupUserList = response.rows;
  146. this.total = response.total;
  147. this.loading = false;
  148. });
  149. },
  150. // 取消按钮
  151. cancel() {
  152. this.open = false;
  153. this.reset();
  154. },
  155. // 表单重置
  156. reset() {
  157. this.form = {
  158. docId: null,
  159. userId: null,
  160. userName: null
  161. };
  162. this.resetForm("form");
  163. },
  164. /** 搜索按钮操作 */
  165. handleQuery() {
  166. this.queryParams.pageNum = 1;
  167. this.getList();
  168. },
  169. /** 重置按钮操作 */
  170. resetQuery() {
  171. this.resetForm("queryForm");
  172. this.handleQuery();
  173. },
  174. // 多选框选中数据
  175. handleSelectionChange(selection) {
  176. this.ids = selection.map(item => item.userId)
  177. this.single = selection.length !== 1
  178. this.multiple = !selection.length
  179. },
  180. /** 新增按钮操作 */
  181. handleAdd() {
  182. this.$refs.select.show();
  183. },
  184. /** 提交按钮 */
  185. submitForm() {
  186. this.$refs["form"].validate(valid => {
  187. if (valid) {
  188. if (this.form.docId != null) {
  189. updateGroupUser(this.form).then(response => {
  190. this.$modal.msgSuccess("修改成功");
  191. this.open = false;
  192. this.getList();
  193. });
  194. } else {
  195. addGroupUser(this.form).then(response => {
  196. this.$modal.msgSuccess("新增成功");
  197. this.open = false;
  198. this.getList();
  199. });
  200. }
  201. }
  202. });
  203. },
  204. /** 删除按钮操作 */
  205. cancelGroupUserAll(row) {
  206. const docId = this.queryParams.docId;
  207. const userIds = this.ids.join(",");
  208. this.$modal.confirm('是否确认删除选中的分组成员?').then(function() {
  209. return shareUserCancelAll({
  210. docId: docId,
  211. userIds: userIds
  212. });
  213. }).then(() => {
  214. this.getList();
  215. this.$modal.msgSuccess("删除成功");
  216. }).catch(() => {});
  217. },
  218. /** 删除按钮操作 */
  219. cancelGroupUser(row) {
  220. const docId = this.queryParams.docId;
  221. const userIds = row.userId
  222. this.$modal.confirm('是否确认删除分组成员"' + row.userName + '"的数据项?').then(function() {
  223. return shareUserCancelAll({
  224. docId: docId,
  225. userIds: userIds
  226. });
  227. }).then(() => {
  228. this.getList();
  229. this.$modal.msgSuccess("删除成功");
  230. }).catch(() => {});
  231. },
  232. },
  233. };
  234. </script>