list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="priceDifferenceDetailList-wrap searchBoxNormal">
  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="6" :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="6" :sm="24">
  27. <a-form-model-item label="省份">
  28. <Area id="priceDifferenceDetailList-provinceSn" v-model="queryParam.provinceSn" placeholder="请选择省"></Area>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="6" :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="6" :sm="24">
  37. <a-form-model-item label="客户名称">
  38. <dealerSubareaScopeList id="priceDifferenceDetailList-custList" ref="custList" :itemSn="queryParam.buyerSn" @change="custChange"></dealerSubareaScopeList>
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  42. <a-form-item label="客服">
  43. <customerService ref="customerName" v-model="queryParam.bizUserSn"></customerService>
  44. </a-form-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="所在区域">
  48. <subarea id="priceDifferenceDetailList-allocateTypeSn" placeholder="请选择区域" showLeve="1" ref="subarea" @change="subareaChange"></subarea>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24" v-show="isShowCustomerSearch">
  52. <a-form-item label="单据类型">
  53. <v-select
  54. v-model="queryParam.bizType"
  55. ref="bizType"
  56. id="priceDifferenceDetailList-bizType"
  57. code="REBATE_BILL_BIZ_TYPE"
  58. placeholder="请选择单据类型"
  59. allowClear></v-select>
  60. </a-form-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  63. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="priceDifferenceDetailList-refresh">查询</a-button>
  64. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="priceDifferenceDetailList-reset">重置</a-button>
  65. <a-button
  66. style="margin-left: 5px"
  67. type="primary"
  68. class="button-warning"
  69. @click="handleExport"
  70. :disabled="disabled"
  71. :loading="exportLoading"
  72. v-if="$hasPermissions('B_priceDifferenceDetail_Export')"
  73. id="allocationDetailsList-export">导出</a-button>
  74. </a-col>
  75. </a-row>
  76. </a-form-model>
  77. </div>
  78. </a-card>
  79. <!-- 列表 -->
  80. <a-card size="small" :bordered="false">
  81. <a-spin :spinning="spinning" tip="Loading...">
  82. <s-table
  83. class="sTable fixPagination"
  84. ref="table"
  85. size="small"
  86. :rowKey="(record) => record.no"
  87. rowKeyName="no"
  88. :columns="columns"
  89. :data="loadData"
  90. :defaultLoadData="false"
  91. :pageSize="30"
  92. :style="{ height: tableHeight+70+'px' }"
  93. :scroll="{ y: tableHeight-30 }"
  94. bordered>
  95. <template slot="footer">
  96. <table>
  97. <tr>
  98. <td width="16%" colspan="3">总计:</td>
  99. <td width="76%" colspan="8" style="display:flex;justify-content: space-between;">
  100. <span>实售金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ? toThousands(totalData.totalRealAmount) : '--' }}</span>
  101. <span>开单金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</span>
  102. <span>销售一部差价金额:{{ (totalData && (totalData.directRebateAmount || totalData.directRebateAmount==0)) ? toThousands(totalData.directRebateAmount) : '--' }}</span>
  103. <span>销售二部差价金额:{{ (totalData && (totalData.directRebateAmount || totalData.directRebateAmount==0)) ? toThousands(totalData.directRebateAmount) : '--' }}</span>
  104. <span>差价金额:{{ (totalData && (totalData.directRebateAmount || totalData.directRebateAmount==0)) ? toThousands(totalData.directRebateAmount) : '--' }}</span>
  105. </td>
  106. <td width="8%"></td>
  107. </tr>
  108. </table>
  109. </template>
  110. </s-table>
  111. </a-spin>
  112. <!-- 导出提示框 -->
  113. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  114. </a-card>
  115. </div>
  116. </template>
  117. <script>
  118. import { commonMixin } from '@/utils/mixin'
  119. import moment from 'moment'
  120. import { STable, VSelect } from '@/components'
  121. import custList from '@/views/common/custList.vue'
  122. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  123. import Area from '@/views/common/area.js'
  124. import subarea from '@/views/common/subarea.js'
  125. import rangeDate from '@/views/common/rangeDate.vue'
  126. import reportModal from '@/views/common/reportModal.vue'
  127. import customerService from '@/views/common/customerService.vue'
  128. import { hdExportExcel } from '@/libs/exportExcel'
  129. import { reportRebateReportList, reportRebateCount, reportRebateExport } from '@/api/reportData'
  130. export default {
  131. name: 'PriceDifferenceDetailReportList',
  132. mixins: [commonMixin],
  133. components: { STable, VSelect, custList, dealerSubareaScopeList, subarea, Area, rangeDate, reportModal, customerService },
  134. data () {
  135. return {
  136. spinning: false,
  137. exportLoading: false,
  138. showExport: false,
  139. queryParam: { // 查询条件
  140. month: moment().format('YYYY-MM'),
  141. provinceSn: undefined,
  142. parentDealerSn: undefined,
  143. buyerSn: undefined,
  144. bizUserSn: undefined,
  145. bizType: undefined, // 单据类型
  146. subareaArea: {
  147. subareaSn: undefined,
  148. subareaAreaSn: undefined
  149. }
  150. },
  151. rules: {
  152. 'month': [{ required: true, message: '请选择月份', trigger: 'change' }],
  153. 'provinceSn': [{ required: true, message: '请选择省份', trigger: 'change' }]
  154. },
  155. disabled: false, // 查询、重置按钮是否可操作
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. this.disabled = true
  159. const params = Object.assign(parameter, this.queryParam)
  160. if (params.month) {
  161. params.month = params.month + '-01'
  162. }
  163. this.spinning = true
  164. return reportRebateReportList(params).then(res => {
  165. let data
  166. if (res.status == 200) {
  167. data = res.data
  168. // 总计
  169. this.getCount(params)
  170. const no = (data.pageNo - 1) * data.pageSize
  171. for (var i = 0; i < data.list.length; i++) {
  172. data.list[i].no = no + i + 1
  173. }
  174. this.disabled = false
  175. }
  176. this.spinning = false
  177. return data
  178. })
  179. },
  180. totalData: null,
  181. tableHeight: 0
  182. }
  183. },
  184. computed: {
  185. columns () {
  186. const _this = this
  187. const arr = [
  188. { title: '月份', dataIndex: 'bizDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '区域', dataIndex: 'subareaArea.subareaName', show: true, width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', show: true, width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  191. { title: '省份', dataIndex: 'provinceName', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  192. { title: '记账门店', dataIndex: 'parentDealerName', width: '14%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  193. { title: '客户名称', dataIndex: 'buyerName', width: '15%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  194. { title: '产品品牌+二级分类', dataIndex: 'productBrandAndType2', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  195. { title: '单据类型', dataIndex: 'bizTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' } }
  196. ]
  197. arr.splice(4, 0, { title: '实售金额', dataIndex: 'totalRealAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  198. arr.splice(5, 0, { title: '开单金额', dataIndex: 'totalAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  199. arr.splice(6, 0, { title: '差价金额', dataIndex: 'directRebateAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  200. arr.splice(7, 0, { title: '记账费用', dataIndex: 'rebateAmount', width: '6%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  201. return arr
  202. }
  203. },
  204. methods: {
  205. onChange (date, dateString) {
  206. this.queryParam.month = dateString
  207. },
  208. disabledDate (current) {
  209. return current && current > moment().endOf('day')
  210. },
  211. // 区域分区
  212. subareaChange (val) {
  213. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  214. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  215. },
  216. // 合计
  217. getCount (params) {
  218. reportRebateCount(params).then(res => {
  219. if (res.status == 200) {
  220. this.totalData = res.data
  221. } else {
  222. this.totalData = null
  223. }
  224. })
  225. },
  226. // 查询
  227. handleSearch () {
  228. const _this = this
  229. this.$refs.ruleForm.validate(valid => {
  230. if (valid) {
  231. _this.$refs.table.refresh(true)
  232. } else {
  233. _this.$message.error('请选择月份')
  234. return false
  235. }
  236. })
  237. },
  238. rebateDealerChange (val) {
  239. this.queryParam.parentDealerSn = val.key
  240. },
  241. custChange (val) {
  242. this.queryParam.buyerSn = val.key
  243. },
  244. // 重置
  245. resetSearchForm () {
  246. this.queryParam.month = moment().format('YYYY-MM')
  247. this.queryParam.provinceSn = undefined
  248. this.queryParam.parentDealerSn = undefined
  249. this.queryParam.buyerSn = undefined
  250. this.queryParam.bizUserSn = undefined
  251. this.queryParam.bizType = undefined
  252. this.queryParam.subareaArea.subareaSn = undefined
  253. this.queryParam.subareaArea.subareaAreaSn = undefined
  254. this.$refs.rebateDealerList.resetForm()
  255. this.totalData = null
  256. this.$refs.custList.resetForm()
  257. this.$refs.subarea.clearData()
  258. this.$refs.ruleForm.resetFields()
  259. this.$refs.table.clearTable()
  260. },
  261. // 导出
  262. handleExport () {
  263. const _this = this
  264. this.$refs.ruleForm.validate(valid => {
  265. if (valid) {
  266. const params = _this.queryParam
  267. _this.$store.state.app.curActionPermission = 'B_priceDifferenceDetail_Export'
  268. _this.showExport = true
  269. _this.exportLoading = true
  270. _this.spinning = true
  271. hdExportExcel(reportRebateExport, params, '差价明细报表', function () {
  272. _this.exportLoading = false
  273. _this.spinning = false
  274. _this.$store.state.app.curActionPermission = ''
  275. })
  276. } else {
  277. return false
  278. }
  279. })
  280. },
  281. setTableH () {
  282. const tableSearchH = this.$refs.tableSearch.offsetHeight
  283. this.tableHeight = window.innerHeight - tableSearchH - 200
  284. }
  285. },
  286. mounted () {
  287. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  288. this.resetSearchForm()
  289. this.setTableH()
  290. }
  291. },
  292. activated () {
  293. // 如果是新页签打开,则重置当前页面
  294. if (this.$store.state.app.isNewTab) {
  295. this.resetSearchForm()
  296. this.setTableH()
  297. }
  298. },
  299. beforeRouteEnter (to, from, next) {
  300. next(vm => {})
  301. }
  302. }
  303. </script>