messageSendCondition-list.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <div>
  3. <el-row class="button-group">
  4. <el-button
  5. type="primary"
  6. size="small"
  7. plain
  8. icon="el-icon-circle-plus"
  9. @click="handleAdd"
  10. >新增</el-button
  11. >
  12. <el-button
  13. type="primary"
  14. size="small"
  15. plain
  16. icon="el-icon-circle-plus"
  17. :disabled="multipleSelection.length == 0"
  18. @click="handleBatchDelete"
  19. >删除选中项</el-button
  20. >
  21. </el-row>
  22. <el-table
  23. :data="tableData"
  24. v-loading="loading"
  25. stripe
  26. @sort-change="sortChange"
  27. @selection-change="handleSelectionChange"
  28. >
  29. <el-table-column type="selection" width="55"></el-table-column>
  30. <el-table-column
  31. prop="companyName"
  32. label="单位"
  33. sortable="no"
  34. width="180"
  35. ></el-table-column>
  36. <el-table-column
  37. prop="companyStructName"
  38. label="单位机构"
  39. sortable="no"
  40. width="180"
  41. ></el-table-column>
  42. <el-table-column
  43. prop="roleName"
  44. label="人员角色"
  45. sortable="no"
  46. width="180"
  47. ></el-table-column>
  48. <el-table-column label="操作">
  49. <template slot-scope="{ row }">
  50. <el-button size="mini" type="warning" @click="handleEdit(row)"
  51. >编辑</el-button
  52. >
  53. <el-button size="mini" type="danger" @click="handleDelete(row)"
  54. >删除</el-button
  55. >
  56. </template>
  57. </el-table-column>
  58. </el-table>
  59. <el-pagination
  60. :current-page.sync="pageIndex"
  61. :total="totalElements"
  62. :page-sizes="pageSizeList"
  63. @current-change="changePage"
  64. @size-change="pageSizeChange"
  65. layout="total, sizes, prev, pager, next, jumper"
  66. ></el-pagination>
  67. <messageSendCondition-detail
  68. v-if="showModal"
  69. :businessKey="businessKey"
  70. :messageId="messageId"
  71. :title="modalTitle"
  72. @close="onDetailModalClose"
  73. ></messageSendCondition-detail>
  74. </div>
  75. </template>
  76. <script>
  77. import Constant from "@/constant";
  78. import MessageSendConditionDetail from "./messageSendCondition-detail";
  79. import messageSendConditionApi from "@/api/base/messageSendCondition";
  80. import NProgress from "nprogress"; // progress bar
  81. import "nprogress/nprogress.css"; // progress bar style
  82. export default {
  83. props: ["messageId"],
  84. data() {
  85. var self = this;
  86. return {
  87. loading: false,
  88. tableData: [],
  89. pageIndex: 1,
  90. pageSize: 10,
  91. totalPages: 0,
  92. totalElements: 0,
  93. field: "",
  94. direction: "",
  95. pageSizeList: [10, 20, 30],
  96. multipleSelection: [],
  97. showModal: false,
  98. modalTitle: "",
  99. businessKey: "",
  100. };
  101. },
  102. methods: {
  103. changePage(pageIndex) {
  104. var self = this;
  105. self.loading = true;
  106. self.pageIndex = pageIndex;
  107. var formData = new FormData();
  108. formData.append("pageIndex", self.pageIndex);
  109. formData.append("pageSize", self.pageSize);
  110. formData.append("messageId", self.messageId);
  111. if (this.field != null) {
  112. formData.append("field", this.field);
  113. }
  114. if (this.direction != null) {
  115. formData.append("direction", this.direction);
  116. }
  117. messageSendConditionApi
  118. .pageList(formData)
  119. .then(function (response) {
  120. self.loading = false;
  121. var jsonData = response.data.data;
  122. self.tableData = jsonData.data;
  123. self.totalPages = jsonData.totalPages;
  124. self.totalElements = jsonData.recordsTotal;
  125. })
  126. .catch((error) => {
  127. self.loading = false;
  128. // self.$message.error(error + "");
  129. });
  130. },
  131. pageSizeChange(pageSize) {
  132. this.pageSize = pageSize;
  133. this.$nextTick(() => {
  134. this.changePage(this.pageIndex);
  135. });
  136. },
  137. sortChange(data) {
  138. this.field = data.column.field;
  139. this.direction = data.order;
  140. this.changePage(this.pageIndex);
  141. },
  142. handleSelectionChange(val) {
  143. this.multipleSelection = val;
  144. },
  145. handleReset(name) {
  146. this.$refs[name].resetFields();
  147. },
  148. handleAdd() {
  149. this.modalTitle = "新增";
  150. this.businessKey = "";
  151. this.showModal = true;
  152. },
  153. handleEdit(record) {
  154. this.modalTitle = "编辑";
  155. this.businessKey = record.id;
  156. this.showModal = true;
  157. },
  158. handleDelete(record) {
  159. var self = this;
  160. self
  161. .$confirm("是否确认删除?", "提示", {
  162. confirmButtonText: "确定",
  163. cancelButtonText: "取消",
  164. type: "warning",
  165. })
  166. .then(() => {
  167. messageSendConditionApi.remove(record.id).then(function (response) {
  168. var jsonData = response.data;
  169. if (jsonData.result) {
  170. self.changePage(self.pageIndex);
  171. self.$message({
  172. type: "success",
  173. message: "删除成功!",
  174. });
  175. }
  176. });
  177. });
  178. },
  179. handleBatchDelete() {
  180. var self = this;
  181. var idList = this.multipleSelection.map((record) => {
  182. return record.id;
  183. });
  184. this.$confirm("是否确认删除选中项?", "提示", {
  185. confirmButtonText: "确定",
  186. cancelButtonText: "取消",
  187. type: "warning",
  188. }).then(() => {
  189. messageSendConditionApi.batchRemove(idList).then(function (response) {
  190. var jsonData = response.data;
  191. if (jsonData.result) {
  192. self.changePage(self.pageIndex);
  193. self.$message({
  194. type: "success",
  195. message: "删除成功!",
  196. });
  197. }
  198. });
  199. });
  200. },
  201. onDetailModalClose(refreshed) {
  202. //保存成功后回调
  203. this.showModal = false;
  204. if (refreshed) {
  205. this.changePage(this.pageIndex);
  206. }
  207. },
  208. },
  209. mounted: function () {
  210. this.changePage(1);
  211. },
  212. components: {
  213. "messageSendCondition-detail": MessageSendConditionDetail,
  214. },
  215. };
  216. </script>
  217. <style lang="scss" scoped>
  218. .el-breadcrumb {
  219. margin: 10px;
  220. line-height: 20px;
  221. }
  222. .el-divider {
  223. margin: 5px 0;
  224. }
  225. .demo-form-inline {
  226. margin-left: 10px;
  227. text-align: left;
  228. }
  229. .button-group {
  230. margin-left: 10px;
  231. text-align: left;
  232. }
  233. </style>