list.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <a-card size="small" :bordered="false" class="giftRecordList-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. <rangeDate ref="rangeDate" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码">
  14. <a-input id="giftRecordList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="原厂编码">
  19. <a-input id="giftRecordList-productOrigCode" v-model.trim="queryParam.productOrigCode" allowClear placeholder="请输入原厂编码"/>
  20. </a-form-item>
  21. </a-col>
  22. <template v-if="advanced">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="关联销售单号">
  25. <a-input id="giftRecordList-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入关联销售单号"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="赠送客户">
  30. <custList ref="custList" @change="custChange" v-model="queryParam.customerSn"></custList>
  31. </a-form-item>
  32. </a-col>
  33. </template>
  34. <a-col :md="6" :sm="24">
  35. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="giftRecordList-refresh">查询</a-button>
  36. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="giftRecordList-reset">重置</a-button>
  37. <a @click="advanced=!advanced" style="margin-left: 8px">
  38. {{ advanced ? '收起' : '展开' }}
  39. <a-icon :type="advanced ? 'up' : 'down'"/>
  40. </a>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <!-- 列表 -->
  46. <s-table
  47. class="sTable"
  48. ref="table"
  49. size="small"
  50. :rowKey="(record) => record.id"
  51. :columns="columns"
  52. :data="loadData"
  53. :scroll="{ x: 1620, y: tableHeight }"
  54. bordered>
  55. </s-table>
  56. </a-card>
  57. </template>
  58. <script>
  59. import { STable, VSelect } from '@/components'
  60. import custList from '@/views/common/custList.vue'
  61. import rangeDate from '@/views/common/rangeDate.vue'
  62. import { giftsDetailList } from '@/api/dealerProduct'
  63. export default {
  64. components: { STable, VSelect, rangeDate, custList },
  65. data () {
  66. return {
  67. tableHeight: 0,
  68. advanced: false, // 高级搜索 展开/关闭
  69. queryParam: { // 查询条件
  70. beginDate: '',
  71. endDate: '',
  72. productCode: '', // 产品编码
  73. productOrigCode: '', // 原厂编码
  74. salesBillNo: '', // 关联销售单号
  75. customerSn: undefined // 赠送客户
  76. },
  77. disabled: false, // 查询、重置按钮是否可操作
  78. columns: [
  79. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  80. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  81. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  82. { title: '赠品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  83. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '赠送数量', dataIndex: 'qty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  85. { title: '关联销售单号', dataIndex: 'salesBillNo', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '赠送客户', dataIndex: 'customerName', width: 200, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  87. { title: '成本价(¥)', dataIndex: 'cost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  88. { title: '成本小计(¥)', dataIndex: 'totalCost', width: 120, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  89. ],
  90. // 加载数据方法 必须为 Promise 对象
  91. loadData: parameter => {
  92. this.disabled = true
  93. if (this.tableHeight == 0) {
  94. this.tableHeight = window.innerHeight - 260
  95. }
  96. return giftsDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  97. const data = res.data
  98. const no = (data.pageNo - 1) * data.pageSize
  99. for (var i = 0; i < data.list.length; i++) {
  100. data.list[i].no = no + i + 1
  101. }
  102. this.disabled = false
  103. return data
  104. })
  105. }
  106. }
  107. },
  108. methods: {
  109. // 时间 change
  110. dateChange (date) {
  111. this.queryParam.beginDate = date[0]
  112. this.queryParam.endDate = date[1]
  113. },
  114. // 客户 change
  115. custChange (obj) {
  116. this.queryParam.customerSn = obj.key || undefined
  117. },
  118. // 重置
  119. resetSearchForm () {
  120. this.$refs.rangeDate.resetDate()
  121. this.queryParam.beginDate = ''
  122. this.queryParam.endDate = ''
  123. this.queryParam.productCode = ''
  124. this.queryParam.productOrigCode = ''
  125. this.queryParam.salesBillNo = ''
  126. this.queryParam.customerSn = undefined
  127. if (this.advanced) {
  128. this.$refs.custList.resetForm()
  129. }
  130. this.$refs.table.refresh(true)
  131. }
  132. },
  133. beforeRouteEnter (to, from, next) {
  134. next(vm => {})
  135. }
  136. }
  137. </script>