list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <a-card size="small" :bordered="false" class="backorderList-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="backorderList-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. <custList ref="custList" id="backorderList-buyerSn" @change="custChange"></custList>
  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="backorderList-refresh">查询</a-button>
  26. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="backorderList-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. :scroll="{ x: 1120, y: tableHeight }"
  40. bordered>
  41. <!-- 操作 -->
  42. <template slot="action" slot-scope="text, record">
  43. <a-button size="small" type="link" @click="handleDetail(record)" id="backorderList-detail-btn">详情</a-button>
  44. </template>
  45. </s-table>
  46. <!-- 详情 -->
  47. <backorder-detail-modal :openModal="openModal" :itemSn="itemSn" @close="closeModal" />
  48. </a-card>
  49. </template>
  50. <script>
  51. import moment from 'moment'
  52. import custList from '@/views/common/custList.vue'
  53. import { STable, VSelect } from '@/components'
  54. import backorderDetailModal from './detailModal.vue'
  55. import { oosList } from '@/api/oos'
  56. export default {
  57. components: { STable, VSelect, custList, backorderDetailModal },
  58. data () {
  59. return {
  60. tableHeight: 0, // 表格高度
  61. queryParam: { // 查询条件
  62. buyerSn: undefined
  63. },
  64. disabled: false, // 查询、重置按钮是否可操作
  65. dateFormat: 'YYYY-MM-DD',
  66. time: [], // 创建时间
  67. columns: [
  68. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  69. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  70. { title: '销售单号', dataIndex: 'salesBillNo', align: 'center' },
  71. { title: '客户名称', dataIndex: 'dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  72. { title: '缺货款数', dataIndex: 'totalCategory', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  73. { title: '缺货数量', dataIndex: 'totalQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  74. { title: '缺货金额', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  75. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  76. ],
  77. // 加载数据方法 必须为 Promise 对象
  78. loadData: parameter => {
  79. this.disabled = true
  80. if (this.tableHeight == 0) {
  81. this.tableHeight = window.innerHeight - 380
  82. }
  83. // 时间
  84. if (this.time && this.time.length > 0) {
  85. this.queryParam.beginDate = moment(this.time[0]).format(this.dateFormat)
  86. this.queryParam.endDate = moment(this.time[1]).format(this.dateFormat)
  87. } else {
  88. this.queryParam.beginDate = undefined
  89. this.queryParam.endDate = undefined
  90. }
  91. return oosList(Object.assign(parameter, this.queryParam)).then(res => {
  92. const data = res.data
  93. const no = (data.pageNo - 1) * data.pageSize
  94. for (var i = 0; i < data.list.length; i++) {
  95. data.list[i].no = no + i + 1
  96. }
  97. this.disabled = false
  98. return data
  99. })
  100. },
  101. openModal: false,
  102. itemSn: ''
  103. }
  104. },
  105. methods: {
  106. // 不可选日期
  107. disabledDate (date, dateStrings) {
  108. return date && date.valueOf() > Date.now()
  109. },
  110. custChange (obj) {
  111. this.queryParam.buyerSn = obj.key
  112. },
  113. // 重置
  114. resetSearchForm () {
  115. this.queryParam.buyerSn = undefined
  116. this.time = []
  117. this.$refs.table.refresh(true)
  118. },
  119. // 关闭
  120. closeModal () {
  121. this.itemSn = ''
  122. this.openModal = false
  123. },
  124. // 详情
  125. handleDetail (row) {
  126. this.itemSn = row.oosBillSn
  127. this.openModal = true
  128. }
  129. }
  130. }
  131. </script>