reportlist.vue 5.3 KB

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