personPopedom-list.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <el-dialog
  3. :visible.sync="showDialog"
  4. title="查看用户角色"
  5. :modal-append-to-body="false"
  6. append-to-body
  7. :modal="true"
  8. style="text-align: left"
  9. @close="closeDialog"
  10. :close-on-click-modal="false"
  11. width="970px"
  12. >
  13. <div>
  14. <!--
  15. 要resetFields起作用,必须配置:model和prop
  16. -->
  17. <el-divider></el-divider>
  18. <el-row class="button-group">
  19. <el-button
  20. type="primary"
  21. size="small"
  22. plain
  23. icon="el-icon-circle-plus"
  24. @click="handleAdd"
  25. >新增</el-button
  26. >
  27. <el-button
  28. type="primary"
  29. size="small"
  30. plain
  31. @click="handleReLoad"
  32. >刷新</el-button
  33. >
  34. </el-row>
  35. <el-table
  36. :data="tableData"
  37. style="min-height: 400px"
  38. v-loading="loading"
  39. stripe
  40. @sort-change="sortChange"
  41. @selection-change="handleSelectionChange"
  42. >
  43. <el-table-column
  44. prop="companyName"
  45. label="公司"
  46. width="180"
  47. ></el-table-column>
  48. <el-table-column
  49. prop="roleName"
  50. label="角色"
  51. width="150"
  52. ></el-table-column>
  53. <el-table-column
  54. prop="showIconId"
  55. label="图标信息"
  56. width="150"
  57. ></el-table-column>
  58. <el-table-column
  59. prop="remark"
  60. label="备注信息"
  61. width="150"
  62. ></el-table-column>
  63. <el-table-column prop="useEnable" label="默认" width="180">
  64. <template slot-scope="{ row }">
  65. <el-switch
  66. v-model="row.isDefault"
  67. active-color="#13ce66"
  68. inactive-color="#ff4949"
  69. @change="changeDefault(row)"
  70. :disabled="row.isDefault"
  71. ></el-switch>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" width="100">
  75. <template slot-scope="{ row }">
  76. <el-link type="danger" :underline="false" @click="handleDelete(row)"
  77. >删除</el-link
  78. >
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <el-pagination
  83. :current-page.sync="pageIndex"
  84. :total="totalElements"
  85. :page-sizes="pageSizeList"
  86. @current-change="changePage"
  87. @size-change="pageSizeChange"
  88. layout="total, sizes, prev, pager, next, jumper"
  89. ></el-pagination>
  90. <personPopedom-detail
  91. v-if="showModal"
  92. :businessKey="businessKey"
  93. :title="modalTitle"
  94. @close="onDetailModalClose"
  95. :personId="personId"
  96. ></personPopedom-detail>
  97. </div>
  98. </el-dialog>
  99. </template>
  100. <script>
  101. import Constant from "@/constant";
  102. import PersonPopedomDetail from "./personPopedom-detail";
  103. import personPopedomApi from "@/api/base/personPopedom";
  104. import NProgress from "nprogress"; // progress bar
  105. import "nprogress/nprogress.css"; // progress bar style
  106. export default {
  107. props: ["personId"],
  108. data() {
  109. var self = this;
  110. return {
  111. queryModel: {
  112. personId: "",
  113. },
  114. loading: false,
  115. tableData: [],
  116. pageIndex: 1,
  117. pageSize: 10,
  118. totalPages: 0,
  119. totalElements: 0,
  120. field: "",
  121. direction: "",
  122. pageSizeList: [10, 20, 30],
  123. multipleSelection: [],
  124. showModal: false,
  125. modalTitle: "",
  126. showDialog: true,
  127. };
  128. },
  129. methods: {
  130. closeDialog() {
  131. this.$emit("close", false);
  132. },
  133. changePage(pageIndex) {
  134. var self = this;
  135. self.loading = true;
  136. self.pageIndex = pageIndex;
  137. var formData = new FormData();
  138. formData.append("pageIndex", self.pageIndex);
  139. formData.append("pageSize", self.pageSize);
  140. formData.append("personId", self.personId);
  141. if (this.field != null) {
  142. formData.append("field", this.field);
  143. }
  144. if (this.direction != null) {
  145. formData.append("direction", this.direction);
  146. }
  147. personPopedomApi
  148. .pageList(formData)
  149. .then(function (response) {
  150. self.loading = false;
  151. var jsonData = response.data.data;
  152. console.log(jsonData.data);
  153. self.tableData = jsonData.data;
  154. self.totalPages = jsonData.totalPages;
  155. self.totalElements = jsonData.recordsTotal;
  156. })
  157. .catch((error) => {
  158. self.loading = false;
  159. // self.$message.error(error + "");
  160. });
  161. },
  162. pageSizeChange(pageSize) {
  163. this.pageSize = pageSize;
  164. },
  165. sortChange(data) {
  166. this.field = data.column.field;
  167. this.direction = data.order;
  168. this.changePage(this.pageIndex);
  169. },
  170. handleSelectionChange(val) {
  171. this.multipleSelection = val;
  172. },
  173. handleReset(name) {
  174. this.$refs[name].resetFields();
  175. },
  176. handleAdd() {
  177. this.modalTitle = "新增";
  178. this.businessKey = "";
  179. this.showModal = true;
  180. this.personId = this.personId;
  181. },
  182. handleDelete(record) {
  183. var self = this;
  184. this.$confirm("是否解除关联?", "提示", {
  185. confirmButtonText: "确定",
  186. cancelButtonText: "取消",
  187. type: "warning",
  188. distinguishCancelAndClose: true,
  189. })
  190. .then(() => {
  191. self.loading = true;
  192. personPopedomApi.remove(record.id).then(function (response) {
  193. var jsonData = response.data;
  194. self.loading = false;
  195. if (jsonData.result) {
  196. // var index = self.tableData.indexOf(record);
  197. // self.tableData.splice(index, 1);
  198. self.changePage(self.pageIndex);
  199. self.$message({
  200. type: "success",
  201. message: "解绑成功!",
  202. });
  203. }
  204. });
  205. })
  206. .catch((error) => {
  207. self.loading = false;
  208. // self.$message.error(error + "");
  209. });
  210. },
  211. onDetailModalClose(refreshed) {
  212. //保存成功后回调
  213. this.showModal = false;
  214. if (refreshed) {
  215. this.changePage(this.pageIndex);
  216. }
  217. },
  218. handleReLoad() {
  219. var self = this;
  220. self.changePage(self.pageIndex);
  221. },
  222. changeDefault(record) {
  223. var self = this;
  224. var formData = new FormData();
  225. self.loading = true;
  226. formData.append("id", record.id);
  227. formData.append("personId", this.personId);
  228. personPopedomApi.changeDefault(formData).then(function (response) {
  229. var jsonData = response.data;
  230. self.loading = false;
  231. if (jsonData.result) {
  232. self.changePage(self.pageIndex);
  233. }
  234. });
  235. },
  236. },
  237. mounted: function () {
  238. this.changePage(1);
  239. },
  240. components: {
  241. "personPopedom-detail": PersonPopedomDetail,
  242. },
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. .el-breadcrumb {
  247. margin: 10px;
  248. line-height: 20px;
  249. }
  250. .el-divider {
  251. margin: 5px 0;
  252. }
  253. .demo-form-inline {
  254. margin-left: 10px;
  255. text-align: left;
  256. }
  257. .button-group {
  258. margin-left: 10px;
  259. text-align: left;
  260. }
  261. </style>