dayReportList.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <a-card size="small" :bordered="false" class="approveStore-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="日期">
  10. <rangeDate ref="rangeDate" v-model="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="经销商">
  15. <storeList ref="storeList" @change="custChange"></storeList>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <div>
  20. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="approveStore-refresh">查询</a-button>
  21. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="approveStore-reset">重置</a-button>
  22. </div>
  23. </a-col>
  24. </a-row>
  25. </a-form>
  26. </div>
  27. <!-- 列表 -->
  28. <s-table
  29. class="sTable fixPagination"
  30. ref="table"
  31. :style="{ height: tableHeight+84.5+'px' }"
  32. size="small"
  33. :rowKey="(record) => record.no"
  34. rowkeyName="no"
  35. :columns="columns"
  36. :data="loadData"
  37. :scroll="{ y: tableHeight }"
  38. :defaultLoadData="false"
  39. bordered>
  40. <!-- 数量-->
  41. <template slot="countVal" slot-scope="text, record">
  42. <a-button class="button-info" type="link" @click="handleDetail(record)" id="approveStore-refresh">{{ record.queryCount||record.queryCount==0? record.queryCount:'--' }}</a-button>
  43. </template>
  44. </s-table>
  45. </a-spin>
  46. <!-- 数量 -->
  47. <recordModal ref="recordModal" :openModal="openRecordModal" @close="openRecordModal=false" />
  48. </a-card>
  49. </template>
  50. <script>
  51. // 组件
  52. import { STable, VSelect } from '@/components'
  53. import rangeDate from '@/views/common/rangeDate.vue'
  54. import storeList from '@/views/common/storeList.vue'
  55. import recordModal from './recordModal.vue'
  56. // 接口
  57. import { vinPartLogDayList } from '@/api/vinPartLog'
  58. export default {
  59. components: { STable, VSelect, rangeDate, storeList, recordModal },
  60. data () {
  61. return {
  62. spinning: false,
  63. tableHeight: 0, // 表格高度
  64. disabled: false, // 查询、重置按钮是否可操作
  65. // 查询条件
  66. queryParam: {
  67. dealerSn: undefined, // 经销商sn
  68. beginDate: undefined, // 开始日期
  69. endDate: undefined// 结束日期
  70. },
  71. time: [], // 查询日期
  72. openRecordModal: false, // 数量弹窗
  73. // 表头
  74. columns: [
  75. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  76. { title: '日期', dataIndex: 'dateInfo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  77. { title: '经销商名称', dataIndex: 'dealerName', width: '40%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  78. { title: '数量', dataIndex: 'queryCount', width: '20%', align: 'center', scopedSlots: { customRender: 'countVal' } }
  79. ],
  80. // 加载数据方法 必须为 Promise 对象
  81. loadData: parameter => {
  82. this.disabled = true
  83. this.spinning = true
  84. const parames = Object.assign(parameter, this.queryParam)
  85. return vinPartLogDayList(parames).then(res => {
  86. let data
  87. if (res.status == 200) {
  88. data = res.data
  89. const no = (data.pageNo - 1) * data.pageSize
  90. for (var i = 0; i < data.list.length; i++) {
  91. data.list[i].no = no + i + 1
  92. if (data.list[i].queryYeary && data.list[i].queryMonth && data.list[i].queryDay) {
  93. data.list[i].dateInfo = data.list[i].queryYeary + '-' + String(data.list[i].queryMonth).padStart(2, '0') + '-' + String(data.list[i].queryDay).padStart(2, '0')
  94. }
  95. }
  96. this.disabled = false
  97. }
  98. this.spinning = false
  99. return data
  100. })
  101. }
  102. }
  103. },
  104. methods: {
  105. // 时间 change
  106. dateChange (date) {
  107. this.queryParam.beginDate = date[0] + ' 00:00:00'
  108. this.queryParam.endDate = date[1] + ' 23:59:60'
  109. },
  110. // 经销商查询
  111. custChange (val) {
  112. this.queryParam.dealerSn = val ? val.key : undefined
  113. },
  114. // 数量弹窗
  115. handleDetail (row) {
  116. const ajaxData = {
  117. dealerSn: row.tenantId,
  118. queryYeary: row.queryYeary,
  119. queryMonth: row.queryMonth,
  120. queryDay: row.queryDay
  121. }
  122. this.$refs.recordModal.pageInit(ajaxData)
  123. this.$nextTick(() => {
  124. this.openRecordModal = true
  125. })
  126. },
  127. // 重置
  128. resetSearchForm () {
  129. this.time = []
  130. this.queryParam.dealerSn = undefined
  131. this.queryParam.beginDate = undefined
  132. this.queryParam.endDate = undefined
  133. this.$refs.rangeDate.resetDate(this.time)
  134. this.$refs.storeList.resetForm()
  135. this.$refs.table.refresh(true)
  136. },
  137. setTableH () {
  138. const tableSearchH = this.$refs.tableSearch.offsetHeight
  139. this.tableHeight = window.innerHeight - tableSearchH - 330
  140. },
  141. pageInit () {
  142. const _this = this
  143. this.$nextTick(() => { // 页面渲染完成后的回调
  144. _this.setTableH()
  145. _this.resetSearchForm()
  146. })
  147. }
  148. },
  149. mounted () {
  150. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  151. this.pageInit()
  152. }
  153. },
  154. watch: {
  155. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  156. this.setTableH()
  157. }
  158. },
  159. activated () {
  160. // 如果是新页签打开,则重置当前页面
  161. if (this.$store.state.app.isNewTab) {
  162. this.pageInit()
  163. }
  164. // 仅刷新列表,不重置页面
  165. if (this.$store.state.app.updateList) {
  166. this.setTableH()
  167. this.$refs.table.refresh()
  168. }
  169. }
  170. }
  171. </script>