index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item>
  5. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  6. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  7. </el-form-item>
  8. </el-form>
  9. <el-row :gutter="10" class="mb8">
  10. <el-col :span="1.5">
  11. <el-button
  12. type="primary"
  13. plain
  14. icon="el-icon-plus"
  15. size="mini"
  16. @click="handleAdd"
  17. v-hasPermi="['doc:msgAccepter:add']"
  18. >新增</el-button>
  19. </el-col>
  20. <el-col :span="1.5">
  21. <el-button
  22. type="success"
  23. plain
  24. icon="el-icon-edit"
  25. size="mini"
  26. :disabled="single"
  27. @click="handleUpdate"
  28. v-hasPermi="['doc:msgAccepter:edit']"
  29. >修改</el-button>
  30. </el-col>
  31. <el-col :span="1.5">
  32. <el-button
  33. type="danger"
  34. plain
  35. icon="el-icon-delete"
  36. size="mini"
  37. :disabled="multiple"
  38. @click="handleDelete"
  39. v-hasPermi="['doc:msgAccepter:remove']"
  40. >删除</el-button>
  41. </el-col>
  42. <el-col :span="1.5">
  43. <el-button
  44. type="warning"
  45. plain
  46. icon="el-icon-download"
  47. size="mini"
  48. @click="handleExport"
  49. v-hasPermi="['doc:msgAccepter:export']"
  50. >导出</el-button>
  51. </el-col>
  52. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  53. </el-row>
  54. <el-table v-loading="loading" :data="msgAccepterList" @selection-change="handleSelectionChange">
  55. <el-table-column type="selection" width="55" align="center" />
  56. <el-table-column label="消息ID" align="center" prop="msgId" />
  57. <el-table-column label="用户ID" align="center" prop="userId" />
  58. <el-table-column label="已读状态" align="center" prop="msgStatus" />
  59. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  60. <template slot-scope="scope">
  61. <el-button
  62. size="mini"
  63. type="text"
  64. icon="el-icon-edit"
  65. @click="handleUpdate(scope.row)"
  66. v-hasPermi="['doc:msgAccepter:edit']"
  67. >修改</el-button>
  68. <el-button
  69. size="mini"
  70. type="text"
  71. icon="el-icon-delete"
  72. @click="handleDelete(scope.row)"
  73. v-hasPermi="['doc:msgAccepter:remove']"
  74. >删除</el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <pagination
  79. v-show="total>0"
  80. :total="total"
  81. :page.sync="queryParams.pageNum"
  82. :limit.sync="queryParams.pageSize"
  83. @pagination="getList"
  84. />
  85. <!-- 添加或修改消息接收对象对话框 -->
  86. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  87. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  88. </el-form>
  89. <div slot="footer" class="dialog-footer">
  90. <el-button type="primary" @click="submitForm">确 定</el-button>
  91. <el-button @click="cancel">取 消</el-button>
  92. </div>
  93. </el-dialog>
  94. </div>
  95. </template>
  96. <script>
  97. import { listMsgAccepter, getMsgAccepter, delMsgAccepter, addMsgAccepter, updateMsgAccepter } from "@/api/doc/msgAccepter";
  98. export default {
  99. name: "MsgAccepter",
  100. data() {
  101. return {
  102. // 遮罩层
  103. loading: true,
  104. // 选中数组
  105. ids: [],
  106. // 非单个禁用
  107. single: true,
  108. // 非多个禁用
  109. multiple: true,
  110. // 显示搜索条件
  111. showSearch: true,
  112. // 总条数
  113. total: 0,
  114. // 消息接收对象表格数据
  115. msgAccepterList: [],
  116. // 弹出层标题
  117. title: "",
  118. // 是否显示弹出层
  119. open: false,
  120. // 查询参数
  121. queryParams: {
  122. pageNum: 1,
  123. pageSize: 10,
  124. msgStatus: null
  125. },
  126. // 表单参数
  127. form: {},
  128. // 表单校验
  129. rules: {
  130. }
  131. };
  132. },
  133. created() {
  134. this.getList();
  135. },
  136. methods: {
  137. /** 查询消息接收对象列表 */
  138. getList() {
  139. this.loading = true;
  140. listMsgAccepter(this.queryParams).then(response => {
  141. this.msgAccepterList = response.rows;
  142. this.total = response.total;
  143. this.loading = false;
  144. });
  145. },
  146. // 取消按钮
  147. cancel() {
  148. this.open = false;
  149. this.reset();
  150. },
  151. // 表单重置
  152. reset() {
  153. this.form = {
  154. msgId: null,
  155. userId: null,
  156. msgStatus: null
  157. };
  158. this.resetForm("form");
  159. },
  160. /** 搜索按钮操作 */
  161. handleQuery() {
  162. this.queryParams.pageNum = 1;
  163. this.getList();
  164. },
  165. /** 重置按钮操作 */
  166. resetQuery() {
  167. this.resetForm("queryForm");
  168. this.handleQuery();
  169. },
  170. // 多选框选中数据
  171. handleSelectionChange(selection) {
  172. this.ids = selection.map(item => item.msgId)
  173. this.single = selection.length!==1
  174. this.multiple = !selection.length
  175. },
  176. /** 新增按钮操作 */
  177. handleAdd() {
  178. this.reset();
  179. this.open = true;
  180. this.title = "添加消息接收对象";
  181. },
  182. /** 修改按钮操作 */
  183. handleUpdate(row) {
  184. this.reset();
  185. const msgId = row.msgId || this.ids
  186. getMsgAccepter(msgId).then(response => {
  187. this.form = response.data;
  188. this.open = true;
  189. this.title = "修改消息接收对象";
  190. });
  191. },
  192. /** 提交按钮 */
  193. submitForm() {
  194. this.$refs["form"].validate(valid => {
  195. if (valid) {
  196. if (this.form.msgId != null) {
  197. updateMsgAccepter(this.form).then(response => {
  198. this.$modal.msgSuccess("修改成功");
  199. this.open = false;
  200. this.getList();
  201. });
  202. } else {
  203. addMsgAccepter(this.form).then(response => {
  204. this.$modal.msgSuccess("新增成功");
  205. this.open = false;
  206. this.getList();
  207. });
  208. }
  209. }
  210. });
  211. },
  212. /** 删除按钮操作 */
  213. handleDelete(row) {
  214. const msgIds = row.msgId || this.ids;
  215. this.$modal.confirm('是否确认删除消息接收对象编号为"' + msgIds + '"的数据项?').then(function() {
  216. return delMsgAccepter(msgIds);
  217. }).then(() => {
  218. this.getList();
  219. this.$modal.msgSuccess("删除成功");
  220. }).catch(() => {});
  221. },
  222. /** 导出按钮操作 */
  223. handleExport() {
  224. this.download('doc/msgAccepter/export', {
  225. ...this.queryParams
  226. }, `msgAccepter_${new Date().getTime()}.xlsx`)
  227. }
  228. }
  229. };
  230. </script>