list.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <a-card size="small" :bordered="false" class="giftRecordList-wrap">
  3. <!-- 搜索条件 -->
  4. <div ref="tableSearch" 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" :itemSn="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 fixPagination"
  48. ref="table"
  49. :style="{ height: tableHeight+84.5+'px' }"
  50. size="small"
  51. :rowKey="(record) => record.id"
  52. :columns="columns"
  53. :data="loadData"
  54. :scroll="{ y: tableHeight }"
  55. :defaultLoadData="false"
  56. bordered>
  57. </s-table>
  58. </a-card>
  59. </template>
  60. <script>
  61. import { STable, VSelect } from '@/components'
  62. import custList from '@/views/common/custList.vue'
  63. import rangeDate from '@/views/common/rangeDate.vue'
  64. import { giftsDetailList } from '@/api/dealerProduct'
  65. export default {
  66. components: { STable, VSelect, rangeDate, custList },
  67. data () {
  68. return {
  69. tableHeight: 0,
  70. advanced: true, // 高级搜索 展开/关闭
  71. queryParam: { // 查询条件
  72. beginDate: '',
  73. endDate: '',
  74. productCode: '', // 产品编码
  75. productOrigCode: '', // 原厂编码
  76. salesBillNo: '', // 关联销售单号
  77. customerSn: undefined // 赠送客户
  78. },
  79. disabled: false, // 查询、重置按钮是否可操作
  80. columns: [
  81. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  82. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  83. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  84. { title: '赠品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  85. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  86. { title: '赠送数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  87. { title: '关联销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '赠送客户', dataIndex: 'customerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  89. { title: '成本价', dataIndex: 'cost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  90. { title: '成本小计', dataIndex: 'totalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  91. ],
  92. // 加载数据方法 必须为 Promise 对象
  93. loadData: parameter => {
  94. this.disabled = true
  95. this.spinning = true
  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. this.spinning = false
  104. return data
  105. })
  106. }
  107. }
  108. },
  109. methods: {
  110. // 时间 change
  111. dateChange (date) {
  112. this.queryParam.beginDate = date[0]
  113. this.queryParam.endDate = date[1]
  114. },
  115. // 客户 change
  116. custChange (obj) {
  117. this.queryParam.customerSn = obj.key || undefined
  118. },
  119. // 重置
  120. resetSearchForm () {
  121. this.$refs.rangeDate.resetDate()
  122. this.queryParam.beginDate = ''
  123. this.queryParam.endDate = ''
  124. this.queryParam.productCode = ''
  125. this.queryParam.productOrigCode = ''
  126. this.queryParam.salesBillNo = ''
  127. this.queryParam.customerSn = undefined
  128. if (this.advanced) {
  129. this.$refs.custList.resetForm()
  130. }
  131. this.$refs.table.refresh(true)
  132. },
  133. pageInit () {
  134. const _this = this
  135. this.$nextTick(() => { // 页面渲染完成后的回调
  136. _this.setTableH()
  137. })
  138. },
  139. setTableH () {
  140. const tableSearchH = this.$refs.tableSearch.offsetHeight
  141. this.tableHeight = window.innerHeight - tableSearchH - 195
  142. }
  143. },
  144. watch: {
  145. advanced (newValue, oldValue) {
  146. const _this = this
  147. setTimeout(() => {
  148. _this.setTableH()
  149. }, 400)
  150. }
  151. },
  152. mounted () {
  153. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  154. this.pageInit()
  155. this.resetSearchForm()
  156. }
  157. },
  158. activated () {
  159. // 如果是新页签打开,则重置当前页面
  160. if (this.$store.state.app.isNewTab) {
  161. this.pageInit()
  162. this.resetSearchForm()
  163. }
  164. },
  165. beforeRouteEnter (to, from, next) {
  166. next(vm => {})
  167. }
  168. }
  169. </script>