list.vue 7.9 KB

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