list.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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" :value="time" @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. import getDate from '@/libs/getDate.js'
  66. export default {
  67. components: { STable, VSelect, rangeDate, custList },
  68. data () {
  69. return {
  70. tableHeight: 0,
  71. advanced: true, // 高级搜索 展开/关闭setTimeout
  72. time: [
  73. getDate.getCurrMonthDays().starttime,
  74. getDate.getCurrMonthDays().endtime
  75. ],
  76. queryParam: { // 查询条件
  77. beginDate: getDate.getCurrMonthDays().starttime,
  78. endDate: getDate.getCurrMonthDays().endtime,
  79. productCode: '', // 产品编码
  80. productOrigCode: '', // 原厂编码
  81. salesBillNo: '', // 关联销售单号
  82. customerSn: undefined // 赠送客户
  83. },
  84. disabled: false, // 查询、重置按钮是否可操作
  85. columns: [
  86. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  87. { title: '创建时间', dataIndex: 'createDate', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  88. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  89. { title: '赠品名称', dataIndex: 'dealerProductEntity.name', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  90. { title: '原厂编码', dataIndex: 'dealerProductEntity.origCode', width: '11%', align: 'center', customRender: function (text) { return text || '--' } },
  91. { title: '赠送数量', dataIndex: 'qty', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  92. { title: '关联销售单号', dataIndex: 'salesBillNo', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  93. { title: '赠送客户', dataIndex: 'customerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  94. { title: '成本价', dataIndex: 'cost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  95. { title: '成本小计', dataIndex: 'totalCost', width: '6%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  96. ],
  97. // 加载数据方法 必须为 Promise 对象
  98. loadData: parameter => {
  99. this.disabled = true
  100. this.spinning = true
  101. return giftsDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  102. let data
  103. if (res.status == 200) {
  104. data = res.data
  105. const no = (data.pageNo - 1) * data.pageSize
  106. for (var i = 0; i < data.list.length; i++) {
  107. data.list[i].no = no + i + 1
  108. }
  109. this.disabled = false
  110. }
  111. this.spinning = false
  112. return data
  113. })
  114. }
  115. }
  116. },
  117. methods: {
  118. // 时间 change
  119. dateChange (date) {
  120. this.queryParam.beginDate = date[0]
  121. this.queryParam.endDate = date[1]
  122. },
  123. // 客户 change
  124. custChange (obj) {
  125. this.queryParam.customerSn = obj.key || undefined
  126. },
  127. // 重置
  128. resetSearchForm () {
  129. this.$refs.rangeDate.resetDate(this.time)
  130. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  131. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  132. this.queryParam.productCode = ''
  133. this.queryParam.productOrigCode = ''
  134. this.queryParam.salesBillNo = ''
  135. this.queryParam.customerSn = undefined
  136. if (this.advanced) {
  137. this.$refs.custList.resetForm()
  138. }
  139. this.$refs.table.refresh(true)
  140. },
  141. pageInit () {
  142. const _this = this
  143. this.$nextTick(() => { // 页面渲染完成后的回调
  144. _this.setTableH()
  145. })
  146. },
  147. setTableH () {
  148. const tableSearchH = this.$refs.tableSearch.offsetHeight
  149. this.tableHeight = window.innerHeight - tableSearchH - 195
  150. }
  151. },
  152. watch: {
  153. advanced (newValue, oldValue) {
  154. const _this = this
  155. setTimeout(() => {
  156. _this.setTableH()
  157. }, 400)
  158. },
  159. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  160. this.setTableH()
  161. }
  162. },
  163. mounted () {
  164. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  165. this.pageInit()
  166. this.resetSearchForm()
  167. }
  168. },
  169. activated () {
  170. // 如果是新页签打开,则重置当前页面
  171. if (this.$store.state.app.isNewTab) {
  172. this.pageInit()
  173. this.resetSearchForm()
  174. }
  175. },
  176. beforeRouteEnter (to, from, next) {
  177. next(vm => {})
  178. }
  179. }
  180. </script>