list.vue 11 KB

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