list.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <a-card size="small" :bordered="false" class="noticeList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="创建时间">
  9. <a-range-picker
  10. style="width:100%"
  11. id="noticeList-creatTime"
  12. :disabledDate="disabledDate"
  13. v-model="time"
  14. :format="dateFormat"
  15. :placeholder="['开始时间', '结束时间']" />
  16. </a-form-item>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :md="6" :sm="24">
  20. <a-form-item label="公告名称">
  21. <a-input id="noticeList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入公告名称"/>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :md="6" :sm="24">
  25. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="noticeList-refresh">查询</a-button>
  26. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="noticeList-reset">重置</a-button>
  27. </a-col>
  28. </a-row>
  29. </a-form>
  30. </div>
  31. <!-- 列表 -->
  32. <s-table
  33. class="sTable"
  34. ref="table"
  35. size="default"
  36. :rowKey="(record) => record.id"
  37. :columns="columns"
  38. :data="loadData"
  39. bordered>
  40. <!-- 操作 -->
  41. <template slot="action" slot-scope="text, record">
  42. <a-button size="small" type="primary" class="button-success" @click="handleDetail(record)" id="noticeList-detail-btn">详情</a-button>
  43. </template>
  44. </s-table>
  45. <!-- 公告详情 -->
  46. <notice-detail-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  47. </a-card>
  48. </template>
  49. <script>
  50. import moment from 'moment'
  51. import { STable } from '@/components'
  52. import noticeDetailModal from './detailModal.vue'
  53. import { urgentList } from '@/api/urgent'
  54. export default {
  55. components: { STable, noticeDetailModal },
  56. data () {
  57. return {
  58. queryParam: { // 查询条件
  59. buyerName: undefined // 客户名称
  60. },
  61. disabled: false, // 查询、重置按钮是否可操作
  62. dateFormat: 'YYYY-MM-DD',
  63. time: [], // 创建时间
  64. columns: [
  65. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  66. { title: '创建时间', dataIndex: 'createDate', align: 'center' },
  67. { title: '公告名称', dataIndex: 'buyerName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  68. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
  69. ],
  70. // 加载数据方法 必须为 Promise 对象
  71. loadData: parameter => {
  72. this.disabled = true
  73. // 创建时间
  74. if (this.time && this.time.length > 0) {
  75. this.queryParam.beginDate = moment(this.time[0]).format(this.dateFormat)
  76. this.queryParam.endDate = moment(this.time[1]).format(this.dateFormat)
  77. } else {
  78. this.queryParam.beginDate = undefined
  79. this.queryParam.endDate = undefined
  80. }
  81. return urgentList(Object.assign(parameter, this.queryParam)).then(res => {
  82. const data = res.data
  83. const no = (data.pageNo - 1) * data.pageSize
  84. for (var i = 0; i < data.list.length; i++) {
  85. data.list[i].no = no + i + 1
  86. }
  87. this.disabled = false
  88. return data
  89. })
  90. },
  91. openModal: false, // 查看客户详情 弹框
  92. itemId: '' // 当前客户id
  93. }
  94. },
  95. methods: {
  96. // 不可选日期
  97. disabledDate (date, dateStrings) {
  98. return date && date.valueOf() > Date.now()
  99. },
  100. // 重置
  101. resetSearchForm () {
  102. this.queryParam.buyerName = undefined
  103. this.time = []
  104. this.$refs.table.refresh(true)
  105. },
  106. // 详情
  107. handleDetail (row) {
  108. this.itemId = row.id
  109. this.openModal = true
  110. },
  111. // 关闭弹框
  112. closeModal () {
  113. this.itemId = ''
  114. this.openModal = false
  115. }
  116. }
  117. }
  118. </script>