reportlist.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" :page.sync="page"
  4. :permission="permissionList" @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
  5. @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
  6. @refresh-change="refreshChange" @on-load="onLoad">
  7. <template slot="menuLeft">
  8. <el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除
  9. </el-button>
  10. </template>
  11. <template slot-scope="scope" slot="menu">
  12. <el-button type="text" icon="el-icon-edit-outline" size="small" @click.stop="handleDesign(scope.row.name)"
  13. v-if="userInfo.role_name.includes('admin')">设计
  14. </el-button>
  15. <el-button type="text" icon="el-icon-view" size="small"
  16. @click.stop="handlePreview(scope.row.id, scope.row.name)" v-if="userInfo.role_name.includes('admin')">预览
  17. </el-button>
  18. </template>
  19. <template slot-scope="{row}" slot="name">
  20. <el-tag style="cursor:pointer" @click="handlePreview(row.id, row.name)">{{ row.name }}</el-tag>
  21. </template>
  22. </avue-crud>
  23. </basic-container>
  24. </template>
  25. <script>
  26. import { getList, remove } from "@/api/report/report";
  27. import { mapGetters } from "vuex";
  28. export default {
  29. data() {
  30. return {
  31. form: {},
  32. selectionList: [],
  33. query: {},
  34. loading: true,
  35. page: {
  36. pageSize: 10,
  37. currentPage: 1,
  38. total: 0
  39. },
  40. option: {
  41. height: 'auto',
  42. calcHeight: 30,
  43. tip: false,
  44. searchShow: true,
  45. searchMenuSpan: 6,
  46. border: true,
  47. index: true,
  48. selection: true,
  49. viewBtn: true,
  50. dialogClickModal: false,
  51. column: [
  52. {
  53. label: "文件名",
  54. prop: "name",
  55. search: true,
  56. slot: true,
  57. },
  58. {
  59. label: "创建时间",
  60. prop: "createTime",
  61. },
  62. {
  63. label: "更新时间",
  64. prop: "updateTime",
  65. }
  66. ]
  67. },
  68. data: []
  69. };
  70. },
  71. computed: {
  72. ...mapGetters(["userInfo", "permission"]),
  73. permissionList() {
  74. return {
  75. addBtn: false,
  76. viewBtn: false,
  77. delBtn: true,
  78. editBtn: false
  79. };
  80. },
  81. ids() {
  82. let ids = [];
  83. this.selectionList.forEach(ele => {
  84. ids.push(ele.id);
  85. });
  86. return ids.join(",");
  87. }
  88. },
  89. methods: {
  90. handlePreview(id, name) {
  91. //console.log(id)
  92. //console.log(name)
  93. let toUrl = encodeURIComponent(this.website.reportUrl + '/preview?_u=blade-' + name + "&id=" + id)
  94. this.$router.push({
  95. path: `/myiframe/urlPath?name=preview-${name}&src=${toUrl}`,
  96. });
  97. //path: `/myiframe/urlPath?name=preview-${name}&src=${this.website.reportUrl}/preview?_u=blade-${name}`
  98. },
  99. handleDesign(name) {
  100. this.$router.push({ path: `/myiframe/urlPath?name=designer-${name}&src=${this.website.reportUrl}/designer?_u=blade-${name}` });
  101. },
  102. rowDel(row) {
  103. this.$confirm("确定将选择数据删除?", {
  104. confirmButtonText: "确定",
  105. cancelButtonText: "取消",
  106. type: "warning"
  107. })
  108. .then(() => {
  109. return remove(row.id);
  110. })
  111. .then(() => {
  112. this.onLoad(this.page);
  113. this.$message({
  114. type: "success",
  115. message: "操作成功!"
  116. });
  117. });
  118. },
  119. searchReset() {
  120. this.query = {};
  121. this.onLoad(this.page);
  122. },
  123. searchChange(params, done) {
  124. this.query = params;
  125. this.page.currentPage = 1;
  126. this.onLoad(this.page, params);
  127. done();
  128. },
  129. selectionChange(list) {
  130. this.selectionList = list;
  131. },
  132. selectionClear() {
  133. this.selectionList = [];
  134. this.$refs.crud.toggleSelection();
  135. },
  136. handleDelete() {
  137. if (this.selectionList.length === 0) {
  138. this.$message.warning("请选择至少一条数据");
  139. return;
  140. }
  141. this.$confirm("确定将选择数据删除?", {
  142. confirmButtonText: "确定",
  143. cancelButtonText: "取消",
  144. type: "warning"
  145. })
  146. .then(() => {
  147. return remove(this.ids);
  148. })
  149. .then(() => {
  150. this.onLoad(this.page);
  151. this.$message({
  152. type: "success",
  153. message: "操作成功!"
  154. });
  155. this.$refs.crud.toggleSelection();
  156. });
  157. },
  158. currentChange(currentPage) {
  159. this.page.currentPage = currentPage;
  160. },
  161. sizeChange(pageSize) {
  162. this.page.pageSize = pageSize;
  163. },
  164. refreshChange() {
  165. this.onLoad(this.page, this.query);
  166. },
  167. onLoad(page, params = {}) {
  168. this.loading = true;
  169. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  170. const data = res.data.data;
  171. this.page.total = data.total;
  172. this.data = data.records;
  173. this.loading = false;
  174. this.selectionClear();
  175. });
  176. }
  177. }
  178. };
  179. </script>
  180. <style></style>