list.vue 13 KB

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