history-data.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="pre-export">
  3. <ex-table
  4. style="margin-top: -10px"
  5. v-loading="loading"
  6. :table="table"
  7. :data="tableData"
  8. :columns="columns"
  9. :page="pageInfo"
  10. :size="size"
  11. @page-curr-change="handlePageChange"
  12. @page-size-change="handleSizeChange"
  13. @screen-reset="
  14. pageInfo.curr = 1;
  15. parmValue.page = 1;
  16. searchList();
  17. "
  18. @screen-submit="
  19. pageInfo.curr = 1;
  20. parmValue.page = 1;
  21. searchList();
  22. "
  23. >
  24. <template #table-header="{}">
  25. <div style="width: 100%">
  26. <el-row style="padding: 0 0 0 80px">
  27. <el-col :span="24">
  28. <el-col :span="12" style="width: 355px">
  29. <el-alert
  30. :closable="false"
  31. title="申请导出后,文件会在几分钟后生成!"
  32. type="warning"
  33. >
  34. </el-alert>
  35. </el-col>
  36. <el-col
  37. :span="3"
  38. style="width: 66px; float: right"
  39. v-if="powers.some((item) => item == '002')"
  40. >
  41. <el-button
  42. :size="searchSize"
  43. type="primary"
  44. style="float: right; margin-left: 5px"
  45. @click="searchList"
  46. >
  47. 刷新
  48. </el-button>
  49. </el-col>
  50. </el-col>
  51. </el-row>
  52. </div>
  53. </template>
  54. <template #status="{ scope }">
  55. <el-tag
  56. :size="tablebtnSize"
  57. :type="
  58. (statusOptions.find((item) => item.id == scope.row.status) || {})
  59. .type || ''
  60. "
  61. v-text="
  62. (statusOptions.find((item) => item.id == scope.row.status) || {})
  63. .label || '--'
  64. "
  65. ></el-tag>
  66. </template>
  67. <template #operation="{ scope }">
  68. <el-tooltip
  69. effect="dark"
  70. content="申请导出"
  71. placement="top"
  72. v-if="powers.some((item) => item == '049')"
  73. >
  74. <i class="el-icon-thumb tb-icon" @click="setStatus(scope.row.id)"></i>
  75. </el-tooltip>
  76. <el-tooltip
  77. v-if="powers.some((item) => item == '049') && scope.row.status == '2'"
  78. effect="dark"
  79. content="导出"
  80. placement="top"
  81. >
  82. <i
  83. class="el-icon-download tb-icon"
  84. @click="batchExport(scope.row.down_url)"
  85. ></i>
  86. </el-tooltip>
  87. </template>
  88. </ex-table>
  89. </div>
  90. </template>
  91. <script>
  92. import mixinPage from "@/mixins/elPaginationHandle";
  93. import asyncRequest from "@/apis/service/search/standBook";
  94. import ExTable from "@/components/ExTableNew.vue";
  95. import { mapGetters } from "vuex";
  96. import urlConfig from "@/apis/url-config";
  97. import resToken from "@/mixins/resToken";
  98. export default {
  99. name: "Account",
  100. components: {
  101. ExTable,
  102. },
  103. mixins: [mixinPage, resToken],
  104. computed: {
  105. ...mapGetters(["tablebtnSize", "searchSize", "size"]),
  106. powers() {
  107. let tran =
  108. this.$store.getters.btnList.find(
  109. (item) => item.menu_route == "standBook"
  110. ) || {};
  111. if (tran && tran.action && tran.action.length > 0) {
  112. return tran.action;
  113. } else {
  114. return [];
  115. }
  116. },
  117. },
  118. data() {
  119. return {
  120. fileUrl: urlConfig.testURL,
  121. // 状态
  122. statusOptions: [
  123. { id: "0", label: "待申请", type: "info" },
  124. { id: "1", label: "系统处理中", type: "warning" },
  125. { id: "2", label: "已完成", type: "success" },
  126. { id: "3", label: "导出失败", type: "danger" },
  127. ],
  128. loading: true,
  129. showModel: false,
  130. sitem: null,
  131. parmValue: {
  132. page: 1, // 页码
  133. size: 15, // 每页显示条数
  134. },
  135. // 表格 - 数据
  136. tableData: [],
  137. // 表格 - 参数
  138. table: {
  139. stripe: true,
  140. border: true,
  141. _defaultHeader_: ["setcol"],
  142. },
  143. // 表格 - 分页
  144. pageInfo: {
  145. size: 15,
  146. curr: 1,
  147. total: 0,
  148. },
  149. // 表格 - 列参数
  150. columns: [
  151. {
  152. prop: "name",
  153. label: "业务表名称",
  154. },
  155. {
  156. prop: "status",
  157. label: "状态",
  158. _slot_: "status",
  159. },
  160. {
  161. prop: "remark",
  162. label: "下载反馈备注",
  163. },
  164. {
  165. prop: "expiretime",
  166. label: "文件过期时间",
  167. },
  168. {
  169. prop: "updatetime",
  170. label: "更新时间",
  171. },
  172. {
  173. prop: "addtime",
  174. label: "创建时间",
  175. },
  176. {
  177. prop: "",
  178. label: "操作",
  179. fixed: "right",
  180. width: "80px",
  181. _slot_: "operation",
  182. },
  183. ],
  184. };
  185. },
  186. mounted() {
  187. this.searchList();
  188. },
  189. methods: {
  190. restSearch() {
  191. this.parmValue = {
  192. page: 1, // 页码
  193. size: 15, // 每页显示条数
  194. };
  195. this.searchList();
  196. },
  197. openModal(sitem) {
  198. this.showModel = true;
  199. this.sitem = sitem;
  200. },
  201. batchExport(content) {
  202. if (!this.loading) {
  203. this.loading = true;
  204. let aEle = document.createElement("a"); // 创建a标签
  205. // aEle.download = fileName; // 设置下载文件的文件名
  206. aEle.href = this.fileUrl + content; // content为后台返回的下载地址
  207. aEle.click(); // 设置点击事件
  208. // document.body.removeChild(aEle); //下载完成移除元素
  209. this.$message.success(`导出成功!`);
  210. setTimeout(() => {
  211. this.loading = false;
  212. }, 500);
  213. }
  214. },
  215. async setStatus(id) {
  216. if (!this.loading) {
  217. this.loading = true;
  218. const model = {
  219. id: id,
  220. };
  221. const res = await asyncRequest.download(model);
  222. if (res && res.code === 0) {
  223. this.loading = false;
  224. this.$notify.success({
  225. title: "申请成功,请等待系统执行完成!",
  226. message: "",
  227. });
  228. await this.searchList();
  229. } else if (res && res.code >= 100 && res.code <= 104) {
  230. await this.logout();
  231. } else {
  232. this.$message.warning(res.message);
  233. }
  234. }
  235. },
  236. async searchList() {
  237. this.loading = true;
  238. const res = await asyncRequest.hlist(this.parmValue);
  239. if (res && res.code === 0 && res.data) {
  240. this.tableData = res.data.list;
  241. this.tableData.forEach((v) => {
  242. if (v.status !== "3") {
  243. v.remark = "";
  244. }
  245. });
  246. this.pageInfo.total = Number(res.data.count);
  247. } else if (res && res.code >= 100 && res.code <= 104) {
  248. await this.logout();
  249. } else {
  250. this.tableData = [];
  251. this.pageInfo.total = 0;
  252. }
  253. this.loading = false;
  254. },
  255. },
  256. };
  257. </script>
  258. <style lang="scss" scoped>
  259. .account {
  260. }
  261. </style>