list.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <a-card size="small" :bordered="false" class="noticeManagementList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="创建时间">
  10. <rangeDate ref="rangeDate" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="文件名称">
  15. <a-input id="noticeManagementList-fileName" v-model.trim="queryParam.fileName" allowClear placeholder="请输入文件名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="状态">
  20. <v-select code="EXPORT_TASK_STATE" id="noticeManagementList-taskState" v-model="queryParam.taskState" allowClear placeholder="请选择状态"></v-select>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  24. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="noticeManagementList-refresh">查询</a-button>
  25. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="noticeManagementList-reset">重置</a-button>
  26. </a-col>
  27. </a-row>
  28. </a-form>
  29. </div>
  30. <!-- 总计 -->
  31. <a-alert type="info" style="margin-bottom:10px">
  32. <div slot="message">注意:所有文件只保留7天,超过7天后,状态变为过期,不能下载</div>
  33. </a-alert>
  34. <!-- 列表 -->
  35. <s-table
  36. class="sTable fixPagination"
  37. ref="table"
  38. :style="{ height: tableHeight+84.5+'px' }"
  39. size="small"
  40. :rowKey="(record) => record.id"
  41. :columns="columns"
  42. :data="loadData"
  43. :scroll="{ y: tableHeight }"
  44. :defaultLoadData="true"
  45. bordered>
  46. <!-- 操作 -->
  47. <template slot="action" slot-scope="text, record">
  48. <a :href="record.fileUrl" style="padding: 5px 0 0 23px;display: block;" v-if="record.taskState=='SUCCESS'">下载文件</a>
  49. <span v-else>--</span>
  50. </template>
  51. </s-table>
  52. </a-spin>
  53. </a-card>
  54. </template>
  55. <script>
  56. import { commonMixin } from '@/utils/mixin'
  57. import { STable, VSelect } from '@/components'
  58. import { taskList, dowloadFile } from '@/api/dowloadFile'
  59. import rangeDate from '@/views/common/rangeDate.vue'
  60. export default {
  61. name: 'DowloadFile',
  62. mixins: [commonMixin],
  63. components: { STable, VSelect, rangeDate },
  64. data () {
  65. return {
  66. spinning: false,
  67. tableHeight: 0,
  68. queryParam: { // 查询条件
  69. beginDate: '',
  70. endDate: '',
  71. fileName: '',
  72. taskState: undefined
  73. },
  74. disabled: false, // 查询、重置按钮是否可操作
  75. columns: [
  76. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  77. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  78. { title: '文件名称', dataIndex: 'fileName', align: 'center', width: '40%', customRender: function (text) { return text || '--' }, ellipsis: true },
  79. { title: '状态', dataIndex: 'taskStateDictValue', align: 'center', width: '20%', customRender: function (text) { return text || '--' } },
  80. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  81. ],
  82. // 加载数据方法 必须为 Promise 对象
  83. loadData: parameter => {
  84. this.disabled = true
  85. this.spinning = true
  86. return taskList(Object.assign(parameter, this.queryParam)).then(res => {
  87. let data
  88. if (res.status == 200) {
  89. data = res.data
  90. const no = (data.pageNo - 1) * data.pageSize
  91. for (var i = 0; i < data.list.length; i++) {
  92. data.list[i].no = no + i + 1
  93. const furl = data.list[i].fileUrl
  94. data.list[i].fileUrl = furl ? furl.replace('http:',location.protocol) : ''
  95. }
  96. this.total = data.count || 0
  97. this.disabled = false
  98. }
  99. this.spinning = false
  100. return data
  101. })
  102. },
  103. total: 0, // 合计
  104. openModal: false, // 编辑 弹框
  105. openDetailModal: false, // 详情 弹框
  106. itemId: '' // 当前产品id
  107. }
  108. },
  109. methods: {
  110. dowloadExcel (url) {
  111. dowloadFile(url, '')
  112. // const elt = document.createElement('a')
  113. // elt.setAttribute('href', url)
  114. // elt.setAttribute('download', '')
  115. // elt.style.display = 'none'
  116. // document.body.appendChild(elt)
  117. // elt.click()
  118. // document.body.removeChild(elt)
  119. },
  120. // 时间 change
  121. dateChange (date) {
  122. this.queryParam.beginDate = date[0] ? date[0] : ''
  123. this.queryParam.endDate = date[1] ? date[1] : ''
  124. },
  125. // 重置
  126. resetSearchForm () {
  127. this.queryParam.beginDate = null
  128. this.queryParam.endDate = null
  129. this.queryParam.fileName = ''
  130. this.queryParam.type = undefined
  131. this.queryParam.taskState = undefined
  132. this.$refs.table.refresh(true)
  133. },
  134. pageInit () {
  135. const _this = this
  136. this.$nextTick(() => { // 页面渲染完成后的回调
  137. _this.setTableH()
  138. })
  139. },
  140. setTableH () {
  141. const tableSearchH = this.$refs.tableSearch.offsetHeight
  142. this.tableHeight = window.innerHeight - tableSearchH - 235
  143. }
  144. },
  145. watch: {
  146. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  147. this.setTableH()
  148. }
  149. },
  150. mounted () {
  151. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  152. this.pageInit()
  153. this.resetSearchForm()
  154. }
  155. },
  156. activated () {
  157. // 如果是新页签打开,则重置当前页面
  158. if (this.$store.state.app.isNewTab) {
  159. this.pageInit()
  160. this.resetSearchForm()
  161. }
  162. // 仅刷新列表,不重置页面
  163. if (this.$store.state.app.updateList) {
  164. this.pageInit()
  165. this.$refs.table.refresh()
  166. }
  167. }
  168. }
  169. </script>