list.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <template>
  2. <a-card size="small" :bordered="false" class="priceDifferenceDetailList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form-model
  7. id="priceDifferenceDetailList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="4" :sm="24">
  16. <a-form-model-item label="月份" prop="month">
  17. <a-month-picker
  18. placeholder="请选择月份"
  19. locale="zh-cn"
  20. v-model="queryParam.month"
  21. @change="onChange"
  22. :disabled-date="disabledDate"
  23. style="width: 100%;"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="4" :sm="24">
  27. <a-form-model-item label="省份" prop="provinceSn">
  28. <Area id="priceDifferenceDetailList-provinceSn" v-model="queryParam.provinceSn" placeholder="请选择省"></Area>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="5" :sm="24">
  32. <a-form-model-item label="记账门店">
  33. <custList id="priceDifferenceDetailList-rebateDealer" ref="rebateDealerList" @change="rebateDealerChange"></custList>
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="5" :sm="24">
  37. <a-form-model-item label="客户名称">
  38. <custList id="priceDifferenceDetailList-custList" ref="custList" :itemSn="queryParam.dealerSn" @change="custChange"></custList>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  42. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="priceDifferenceDetailList-refresh">查询</a-button>
  43. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceDifferenceDetailList-reset">重置</a-button>
  44. <a-button
  45. style="margin-left: 5px"
  46. type="primary"
  47. class="button-warning"
  48. @click="handleExport"
  49. :disabled="disabled"
  50. :loading="exportLoading"
  51. v-if="$hasPermissions('B_priceDifferenceDetail_Export')"
  52. id="allocationDetailsList-export">导出</a-button>
  53. </a-col>
  54. </a-row>
  55. </a-form-model>
  56. </div>
  57. <!-- 列表 -->
  58. <s-table
  59. class="sTable"
  60. ref="table"
  61. size="small"
  62. :rowKey="(record) => record.no"
  63. rowKeyName="no"
  64. :columns="columns"
  65. :data="loadData"
  66. :defaultLoadData="false"
  67. bordered>
  68. <template slot="footer">
  69. <table>
  70. <tr>
  71. <td width="51%" colspan="4"></td>
  72. <td width="8%">
  73. <div>实售金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ? toThousands(totalData.totalRealAmount) : '--' }}</div>
  74. </td>
  75. <td width="8%">
  76. <div>开单金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</div>
  77. </td>
  78. <td width="8%">
  79. <div>差价金额:{{ (totalData && (totalData.rebateAmount || totalData.rebateAmount==0)) ? toThousands(totalData.rebateAmount) : '--' }}</div>
  80. </td>
  81. <td width="25%" colspan="2"></td>
  82. </tr>
  83. </table>
  84. </template>
  85. </s-table>
  86. </a-spin>
  87. <!-- 导出提示框 -->
  88. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  89. </a-card>
  90. </template>
  91. <script>
  92. import { commonMixin } from '@/utils/mixin'
  93. import moment from 'moment'
  94. import { STable, VSelect } from '@/components'
  95. import custList from '@/views/common/custList.vue'
  96. import Area from '@/views/common/area.js'
  97. import subarea from '@/views/common/subarea.js'
  98. import rangeDate from '@/views/common/rangeDate.vue'
  99. import reportModal from '@/views/common/reportModal.vue'
  100. import { hdExportExcel } from '@/libs/exportExcel'
  101. import { reportRebateReportList, reportRebateCount, reportRebateExport } from '@/api/reportData'
  102. export default {
  103. name: 'PriceDifferenceDetailReportList',
  104. mixins: [commonMixin],
  105. components: { STable, VSelect, custList, subarea, Area, rangeDate, reportModal },
  106. data () {
  107. return {
  108. spinning: false,
  109. advanced: false, // 高级搜索 展开/关闭
  110. exportLoading: false,
  111. showExport: false,
  112. queryParam: { // 查询条件
  113. month: moment().format('YYYY-MM'),
  114. provinceSn: undefined,
  115. rebateDealerSn: undefined,
  116. dealerSn: undefined
  117. },
  118. rules: {
  119. 'month': [{ required: true, message: '请选择月份', trigger: 'change' }],
  120. 'provinceSn': [{ required: true, message: '请选择省份', trigger: 'change' }]
  121. },
  122. disabled: false, // 查询、重置按钮是否可操作
  123. // 加载数据方法 必须为 Promise 对象
  124. loadData: parameter => {
  125. this.disabled = true
  126. const params = Object.assign(parameter, this.queryParam)
  127. if (params.month) {
  128. params.month = params.month + '-01'
  129. }
  130. this.spinning = true
  131. return reportRebateReportList(params).then(res => {
  132. let data
  133. if (res.status == 200) {
  134. data = res.data
  135. // 总计
  136. this.getCount(params)
  137. const no = (data.pageNo - 1) * data.pageSize
  138. for (var i = 0; i < data.list.length; i++) {
  139. data.list[i].no = no + i + 1
  140. }
  141. this.disabled = false
  142. }
  143. this.spinning = false
  144. return data
  145. })
  146. },
  147. totalData: null
  148. }
  149. },
  150. computed: {
  151. columns () {
  152. const _this = this
  153. const arr = [
  154. { title: '月份', dataIndex: 'month', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '省份', dataIndex: 'provinceName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  156. { title: '记账门店', dataIndex: 'rebateDealerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  157. { title: '客户名称', dataIndex: 'dealerName', width: '16%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  158. { title: '产品品牌+二级分类', dataIndex: 'productBrandAndType2', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  159. { title: '类型', dataIndex: 'bizType', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  160. ]
  161. arr.splice(4, 0, { title: '实售金额', dataIndex: 'totalRealAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  162. arr.splice(5, 0, { title: '开单金额', dataIndex: 'totalAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  163. arr.splice(6, 0, { title: '差价金额', dataIndex: 'rebateAmount', width: '8%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  164. return arr
  165. }
  166. },
  167. methods: {
  168. onChange (date, dateString) {
  169. this.queryParam.month = dateString
  170. },
  171. disabledDate (current) {
  172. return current && current > moment().endOf('day')
  173. },
  174. // 合计
  175. getCount (params) {
  176. reportRebateCount(params).then(res => {
  177. if (res.status == 200) {
  178. this.totalData = res.data
  179. } else {
  180. this.totalData = null
  181. }
  182. })
  183. },
  184. // 查询
  185. handleSearch () {
  186. const _this = this
  187. this.$refs.ruleForm.validate(valid => {
  188. if (valid) {
  189. _this.$refs.table.refresh(true)
  190. } else {
  191. _this.$message.error('请选择月份和省份')
  192. return false
  193. }
  194. })
  195. },
  196. rebateDealerChange (val) {
  197. this.queryParam.rebateDealerSn = val.key
  198. },
  199. custChange (val) {
  200. this.queryParam.dealerSn = val.key
  201. },
  202. // 重置
  203. resetSearchForm () {
  204. this.queryParam.month = moment().format('YYYY-MM')
  205. this.queryParam.provinceSn = undefined
  206. this.queryParam.rebateDealerSn = undefined
  207. this.queryParam.dealerSn = undefined
  208. this.$refs.rebateDealerList.resetForm()
  209. this.totalData = null
  210. if (this.advanced) {
  211. this.$refs.custList.resetForm()
  212. }
  213. this.$refs.ruleForm.resetFields()
  214. this.$refs.table.clearTable()
  215. },
  216. // 导出
  217. handleExport () {
  218. const _this = this
  219. this.$refs.ruleForm.validate(valid => {
  220. if (valid) {
  221. const params = _this.queryParam
  222. _this.$store.state.app.curActionPermission = 'B_priceDifferenceDetail_Export'
  223. _this.showExport = true
  224. _this.exportLoading = true
  225. _this.spinning = true
  226. hdExportExcel(reportRebateExport, params, '差价明细报表', function () {
  227. _this.exportLoading = false
  228. _this.spinning = false
  229. _this.$store.state.app.curActionPermission = ''
  230. })
  231. } else {
  232. return false
  233. }
  234. })
  235. }
  236. },
  237. mounted () {
  238. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  239. this.resetSearchForm()
  240. }
  241. },
  242. activated () {
  243. // 如果是新页签打开,则重置当前页面
  244. if (this.$store.state.app.isNewTab) {
  245. this.resetSearchForm()
  246. }
  247. },
  248. beforeRouteEnter (to, from, next) {
  249. next(vm => {})
  250. }
  251. }
  252. </script>