list.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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" target="_blank" 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 { STable, VSelect } from '@/components'
  57. import { taskList } from '@/api/dowloadFile'
  58. import rangeDate from '@/views/common/rangeDate.vue'
  59. export default {
  60. components: { STable, VSelect, rangeDate },
  61. data () {
  62. return {
  63. spinning: false,
  64. tableHeight: 0,
  65. queryParam: { // 查询条件
  66. beginDate: '',
  67. endDate: '',
  68. fileName: '',
  69. taskState: undefined
  70. },
  71. disabled: false, // 查询、重置按钮是否可操作
  72. columns: [
  73. { title: '序号', dataIndex: 'no', width: '10%', align: 'center' },
  74. { title: '创建时间', dataIndex: 'createDate', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  75. { title: '文件名称', dataIndex: 'fileName', align: 'center', width: '40%', customRender: function (text) { return text || '--' }, ellipsis: true },
  76. { title: '状态', dataIndex: 'taskStateDictValue', align: 'center', width: '20%', customRender: function (text) { return text || '--' } },
  77. { title: '操作', scopedSlots: { customRender: 'action' }, width: '15%', align: 'center' }
  78. ],
  79. // 加载数据方法 必须为 Promise 对象
  80. loadData: parameter => {
  81. this.disabled = true
  82. this.spinning = true
  83. return taskList(Object.assign(parameter, this.queryParam)).then(res => {
  84. let data
  85. if (res.status == 200) {
  86. data = res.data
  87. const no = (data.pageNo - 1) * data.pageSize
  88. for (var i = 0; i < data.list.length; i++) {
  89. data.list[i].no = no + i + 1
  90. }
  91. this.total = data.count || 0
  92. this.disabled = false
  93. }
  94. this.spinning = false
  95. return data
  96. })
  97. },
  98. total: 0, // 合计
  99. openModal: false, // 编辑 弹框
  100. openDetailModal: false, // 详情 弹框
  101. itemId: '' // 当前产品id
  102. }
  103. },
  104. methods: {
  105. // 时间 change
  106. dateChange (date) {
  107. this.queryParam.beginDate = date[0] ? date[0] + ' 00:00:00' : ''
  108. this.queryParam.endDate = date[1] ? date[1] + ' 23:59:59' : ''
  109. },
  110. // 重置
  111. resetSearchForm () {
  112. this.queryParam.beginDate = null
  113. this.queryParam.endDate = null
  114. this.queryParam.fileName = ''
  115. this.queryParam.type = undefined
  116. this.queryParam.taskState = undefined
  117. this.$refs.table.refresh(true)
  118. },
  119. pageInit () {
  120. const _this = this
  121. this.$nextTick(() => { // 页面渲染完成后的回调
  122. _this.setTableH()
  123. })
  124. },
  125. setTableH () {
  126. const tableSearchH = this.$refs.tableSearch.offsetHeight
  127. this.tableHeight = window.innerHeight - tableSearchH - 235
  128. }
  129. },
  130. watch: {
  131. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  132. this.setTableH()
  133. }
  134. },
  135. mounted () {
  136. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  137. this.pageInit()
  138. this.resetSearchForm()
  139. }
  140. },
  141. activated () {
  142. // 如果是新页签打开,则重置当前页面
  143. if (this.$store.state.app.isNewTab) {
  144. this.pageInit()
  145. this.resetSearchForm()
  146. }
  147. // 仅刷新列表,不重置页面
  148. if (this.$store.state.app.updateList) {
  149. this.pageInit()
  150. this.$refs.table.refresh()
  151. }
  152. }
  153. }
  154. </script>