list.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="promotionSalesList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper newTableSearchName" ref="tableSearch">
  6. <a-form-model
  7. id="promotionSalesList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="form"
  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="monthInfo">
  17. <div class="monthBox" style="display:flex;align-item:center;">
  18. <a-month-picker
  19. :disabled-date="disabledStartDate"
  20. format="YYYY-MM"
  21. v-model="startValue"
  22. placeholder="开始月份"
  23. @openChange="handleStartOpenChange"
  24. @change="getStartDate"
  25. />
  26. <span>~</span>
  27. <a-month-picker
  28. :disabled-date="disabledEndDate"
  29. format="YYYY-MM"
  30. v-model="endValue"
  31. placeholder="结束月份"
  32. :open="endOpen"
  33. @openChange="handleEndOpenChange"
  34. @change="getEndDate"
  35. />
  36. </div>
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-model-item label="区域/分区">
  41. <subarea id="promotionSalesList-allocateTypeSn" ref="subarea" @change="subareaChange"></subarea>
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="区域负责人">
  46. <BizUser v-model="queryParam.subareaArea.bizUserSn"></BizUser>
  47. </a-form-model-item>
  48. </a-col>
  49. <a-form-model-item label="省份">
  50. <Area id="promotionSalesList-provinceSn" v-model="queryParam.provinceSn" placeholder="请选择省"></Area>
  51. </a-form-model-item>
  52. <template v-if="advanced">
  53. <a-col :md="6" :sm="24">
  54. <a-form-model-item label="客户名称">
  55. <dealerSubareaScopeList ref="custList" id="salesAmountReportList-dealerSn" @change="custChange" />
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="客户级别">
  60. <v-select
  61. v-model="queryParam.dealerLevel"
  62. ref="dealerLevel"
  63. id="promotionSalesList-dealerLevel"
  64. code="DEALER_LEVEL"
  65. placeholder="请选择客户级别"
  66. allowClear></v-select>
  67. </a-form-item>
  68. </a-col>
  69. <a-col :md="6" :sm="24">
  70. <a-form-item label="产品品牌">
  71. <ProductBrand id="productInfoList-productBrand" v-model="queryParam.productBrand"></ProductBrand>
  72. </a-form-item>
  73. </a-col>
  74. <a-col :md="6" :sm="24">
  75. <a-form-item label="产品分类">
  76. <productTypeAll
  77. expandType="click"
  78. :changeOnSelect="false"
  79. placeholder="请选择产品分类"
  80. :level="2"
  81. @change="changeProductType"
  82. v-model="productType"
  83. id="productInfoList-productType"></productTypeAll>
  84. </a-form-item>
  85. </a-col>
  86. </template>
  87. <a-col :md="24" :sm="24" style="text-align:center;margin-bottom: 10px;">
  88. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="promotionSalesList-refresh">查询</a-button>
  89. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="promotionSalesList-reset">重置</a-button>
  90. <a-button
  91. style="margin-left: 10px"
  92. type="primary"
  93. class="button-warning"
  94. @click="handleExport"
  95. :disabled="disabled"
  96. :loading="exportLoading"
  97. v-if="$hasPermissions('B_brandTypeReportExport')"
  98. id="promotionSalesList-export">导出</a-button>
  99. <a @click="advanced=!advanced" style="margin-left: 8px">
  100. {{ advanced ? '收起' : '展开' }}
  101. <a-icon :type="advanced ? 'up' : 'down'"/>
  102. </a>
  103. </a-col>
  104. </a-row>
  105. </a-form-model>
  106. </div>
  107. </a-card>
  108. <a-card size="small" :bordered="false">
  109. <a-spin :spinning="spinning" tip="Loading...">
  110. <!-- 列表 -->
  111. <s-table
  112. class="sTable fixPagination"
  113. ref="table"
  114. size="small"
  115. :defaultLoadData="true"
  116. :rowKey="(record) => record.no"
  117. rowKeyName="no"
  118. :columns="columns"
  119. :data="loadData"
  120. :pageSize="30"
  121. :style="{ height: tableHeight+84.5+'px' }"
  122. :scroll="{ x:1890,y: tableHeight-136 }"
  123. bordered>
  124. <!-- 品牌-->
  125. <template slot="brandName" slot-scope="text, record">
  126. {{ record.allProductBrandFlag?'全品类':record.brandName?record.brandName:'--' }}
  127. </template>
  128. <!-- 分类 -->
  129. <template slot="brandtypeName" slot-scope="text, record">
  130. {{ record.allProductTypeFlag?'全分类':record.brandtypeName?record.brandtypeName:'--' }}
  131. </template>
  132. <template slot="footer" v-if="totalData">
  133. <a-row>
  134. <a-col span="24">
  135. <a-row>
  136. <a-col
  137. span="4">销售额:{{ (totalData.totalSaleAmount || totalData.totalSaleAmount==0) ? toThousands(totalData.totalSaleAmount) : '--' }}</a-col>
  138. <a-col
  139. span="4">促销成本费用:{{ (totalData.promoCostFee || totalData.promoCostFee==0) ? toThousands(totalData.promoCostFee) : '--' }}</a-col>
  140. <a-col
  141. span="4">促销成本费用比:{{ totalData.promoCostFeeRate ? toThousands(totalData.promoCostFeeRate*100)+'%' : '--' }}</a-col>
  142. <a-col
  143. span="4">促销销售费用:{{ (totalData.promoSaleFee || totalData.promoSaleFee==0) ? toThousands(totalData.promoSaleFee) : '--' }}</a-col>
  144. <a-col
  145. span="4">促销销售费用比:{{ totalData.promoSaleFeeRate ? toThousands(totalData.promoSaleFeeRate*100)+'%' : '--' }}</a-col>
  146. <a-col
  147. span="4">参与活动销售额:{{ (totalData.promoSaleAmount || totalData.promoSaleAmount==0) ? toThousands(totalData.promoSaleAmount) : '--' }}</a-col>
  148. <a-col
  149. span="4">未参与活动销售额:{{ (totalData.notpromotionSale || totalData.notpromotionSale==0) ? toThousands(totalData.notpromotionSale) : '--' }}</a-col>
  150. <a-col
  151. span="4">调拨物料成本费用:{{ (totalData.allocateCost || totalData.allocateCost==0) ? toThousands(totalData.allocateCost) : '--' }}</a-col>
  152. <a-col
  153. span="4">调拨物料销售费用:{{ (totalData.allocateSaleAmount || totalData.allocateSaleAmount==0) ? toThousands(totalData.allocateSaleAmount) : '--' }}</a-col>
  154. <a-col
  155. span="4">促销成本费用+物料成本费用合计:{{ (totalData.promoCostFeeAndAllocateCost || totalData.promoCostFeeAndAllocateCost==0)? toThousands(totalData.promoCostFeeAndAllocateCost) : '--' }}</a-col>
  156. <a-col
  157. span="4">成本合计占比:{{ totalData.totalCostRate ? toThousands(totalData.totalCostRate*100)+'%' : '--' }}</a-col>
  158. <a-col
  159. span="4">促销销售费用+物料销售费用合计:{{ (totalData.promoSaleFeeAndAllocateAmount || totalData.promoSaleFeeAndAllocateAmount==0) ? toThousands(totalData.promoSaleFeeAndAllocateAmount) : '--' }}</a-col>
  160. <a-col
  161. span="4">销售合计占比:{{ totalData.totalSaleRate ? toThousands(totalData.totalSaleRate*100)+'%' : '--' }}</a-col>
  162. </a-row>
  163. </a-col>
  164. </a-row>
  165. </template>
  166. </s-table>
  167. </a-spin>
  168. <!-- 导出提示框 -->
  169. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  170. </a-card>
  171. </div>
  172. </template>
  173. <script>
  174. import { commonMixin } from '@/utils/mixin'
  175. import moment from 'moment'
  176. import { STable, VSelect } from '@/components'
  177. import ProductBrand from '@/views/common/productBrand.js'
  178. import productTypeAll from '@/views/common/productType.js'
  179. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  180. import subarea from '@/views/common/subarea.js'
  181. import reportModal from '@/views/common/reportModal.vue'
  182. import Area from '@/views/common/area.js'
  183. import BizUser from '@/views/common/bizUser.js'
  184. import { hdExportExcel } from '@/libs/exportExcel'
  185. import { brandTypeReportList, brandTypeReportCount, brandTypeReportExport } from '@/api/reportData'
  186. export default {
  187. name: 'PromotionSalesOrderReport',
  188. mixins: [commonMixin],
  189. components: { STable, VSelect, subarea, dealerSubareaScopeList, reportModal, Area, BizUser, ProductBrand, productTypeAll },
  190. data () {
  191. return {
  192. spinning: false,
  193. advanced: true, // 高级搜索 展开/关闭
  194. tableHeight: 0,
  195. showExport: false,
  196. queryParam: { // 查询条件
  197. brandTypeBeginDate: moment().format('YYYYMM'),
  198. brandTypeEndDate: moment().format('YYYYMM'),
  199. dealerSn: undefined,
  200. provinceSn: undefined,
  201. subareaArea: {
  202. subareaSn: undefined,
  203. subareaAreaSn: undefined,
  204. bizUserSn: undefined
  205. },
  206. productBrand: undefined,
  207. productTypeSn1: '', // 产品一级分类
  208. productType: '', // 产品二级分类
  209. dealerLevel: undefined
  210. },
  211. productType: [],
  212. form: {
  213. monthInfo: [moment().format('YYYY-MM'), moment().format('YYYY-MM')]
  214. },
  215. columns: [
  216. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '100px', align: 'center', customRender: function (text) { return text || '--' } },
  217. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '100px', align: 'center', customRender: function (text) { return text || '--' } },
  218. { title: '区域负责人', dataIndex: 'bizUserName', width: '90px', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '省份', dataIndex: 'dealerInfo.provinceName', width: '100px', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '客户名称', dataIndex: 'dealerInfo.dealerName', width: '130px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '客户级别', dataIndex: 'dealerInfo.dealerLevelDictValue', width: '90px', align: 'center', customRender: function (text) { return text || '--' } },
  222. { title: '品牌', dataIndex: 'brandName', width: '90px', align: 'center', scopedSlots: { customRender: 'brandName' } },
  223. { title: '二级分类', dataIndex: 'brandtypeName', width: '90px', align: 'center', scopedSlots: { customRender: 'brandtypeName' } },
  224. { title: '销售额', dataIndex: 'totalSaleAmount', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  225. { title: '促销成本费用', dataIndex: 'promoCostFee', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  226. { title: '促销成本费用比', dataIndex: 'promoCostFeeRate', width: '96px', align: 'right', customRender: text => (text ? this.toThousands(text * 100) + '%' : '--') },
  227. { title: '促销销售费用', dataIndex: 'promoSaleFee', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  228. { title: '促销销售费用比', dataIndex: 'promoSaleFeeRate', width: '96px', align: 'right', customRender: text => (text ? this.toThousands(text * 100) + '%' : '--') },
  229. { title: '参与活动销售额', dataIndex: 'promoSaleAmount', width: '96px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  230. { title: '未参与活动销售额', dataIndex: 'notpromotionSale', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  231. { title: '调拨物料成本费用', dataIndex: 'allocateCost', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  232. { title: '调拨物料销售费用', dataIndex: 'allocateSaleAmount', width: '90px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  233. { title: '促销成本费用+物料成本费用合计', dataIndex: 'promoCostFeeAndAllocateCost', width: '100px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  234. { title: '成本合计占比', dataIndex: 'totalCostRate', width: '90px', align: 'right', customRender: text => (text ? this.toThousands(text * 100) + '%' : '--') },
  235. { title: '促销销售费用+物料销售费用合计', dataIndex: 'promoSaleFeeAndAllocateAmount', width: '100px', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  236. { title: '销售合计占比', dataIndex: 'totalSaleRate', width: '90px', align: 'right', customRender: text => (text ? this.toThousands(text * 100) + '%' : '--') }
  237. ],
  238. rules: {
  239. monthInfo: [{ required: true, message: '请选择统计月份', trigger: 'change' }]
  240. },
  241. disabled: false, // 查询、重置按钮是否可操作
  242. exportLoading: false,
  243. startValue: moment().format('YYYY-MM'), // 统计月份
  244. endValue: moment().format('YYYY-MM'),
  245. endOpen: false,
  246. // 加载数据方法 必须为 Promise 对象
  247. loadData: parameter => {
  248. this.disabled = true
  249. this.spinning = true
  250. const newParamsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  251. const paramsPage = JSON.parse(JSON.stringify(newParamsPage))
  252. delete paramsPage.productTypeSn1
  253. if (!paramsPage.subareaArea.subareaSn && !paramsPage.subareaArea.subareaAreaSn && !paramsPage.subareaArea.bizUserSn) {
  254. delete paramsPage.subareaArea
  255. }
  256. return brandTypeReportList(paramsPage).then(res => {
  257. let data
  258. if (res.status == 200) {
  259. data = res.data
  260. this.getCount(paramsPage)
  261. const no = (data.pageNo - 1) * data.pageSize
  262. for (var i = 0; i < data.list.length; i++) {
  263. data.list[i].no = no + i + 1
  264. }
  265. this.disabled = false
  266. }
  267. this.spinning = false
  268. return data
  269. })
  270. },
  271. totalData: null
  272. }
  273. },
  274. watch: {
  275. advanced (newValue, oldValue) {
  276. const _this = this
  277. this.$nextTick(() => { // 页面渲染完成后的回调
  278. _this.setTableH()
  279. })
  280. },
  281. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  282. this.setTableH()
  283. }
  284. },
  285. methods: {
  286. // 统计月份 选择月份限制
  287. disabledStartDate (current) {
  288. const endValue = this.endValue
  289. const md = moment(current).startOf('month').valueOf()
  290. const cd = moment().startOf('month').valueOf() // 当前月份
  291. if (!current || !endValue) {
  292. return md > cd
  293. }
  294. const ed = moment(endValue).startOf('month').valueOf()
  295. return md > ed || md > cd
  296. },
  297. disabledEndDate (current) {
  298. const startValue = this.startValue
  299. const md = moment(current).startOf('month').valueOf()
  300. const cd = moment().startOf('month').valueOf() // 当前月份
  301. if (!current || !startValue) {
  302. return md > cd
  303. }
  304. const sd = moment(startValue).startOf('month').valueOf()
  305. return md < sd || md > cd
  306. },
  307. // 开始时间
  308. handleStartOpenChange (open) {
  309. if (!open) {
  310. this.endOpen = true
  311. }
  312. },
  313. getStartDate (date, dateString) {
  314. this.form.monthInfo[0] = dateString
  315. this.queryParam.brandTypeBeginDate = date ? moment(dateString).startOf('month').format('YYYYMM') : ''
  316. },
  317. // 结束时间
  318. handleEndOpenChange (open) {
  319. this.endOpen = open
  320. },
  321. getEndDate (date, dateString) {
  322. this.form.monthInfo[1] = dateString
  323. this.queryParam.brandTypeEndDate = date ? moment(dateString).endOf('month').format('YYYYMM') : ''
  324. },
  325. // 导出
  326. handleExport () {
  327. const _this = this
  328. this.$refs.ruleForm.validate(valid => {
  329. if (valid) {
  330. const params = _this.queryParam
  331. _this.showExport = true
  332. _this.exportLoading = true
  333. _this.spinning = true
  334. hdExportExcel(brandTypeReportExport, params, '促销销售单报表(统计)', function () {
  335. _this.exportLoading = false
  336. _this.spinning = false
  337. })
  338. } else {
  339. return false
  340. }
  341. })
  342. },
  343. // 总计
  344. getCount (params) {
  345. brandTypeReportCount(params).then(res => {
  346. if (res.status == 200) {
  347. this.totalData = res.data || null
  348. } else {
  349. this.totalData = null
  350. }
  351. })
  352. },
  353. handleSearch () {
  354. const _this = this
  355. if (!_this.form.monthInfo[0] || !_this.form.monthInfo[1]) {
  356. _this.$message.error('请选择统计月份')
  357. return
  358. }
  359. this.$refs.ruleForm.validate(valid => {
  360. if (valid) {
  361. _this.$refs.table.refresh(true)
  362. } else {
  363. _this.$message.error('请选择统计月份')
  364. return false
  365. }
  366. })
  367. },
  368. // 客户名称
  369. custChange (val) {
  370. this.queryParam.dealerSn = val.key
  371. },
  372. // 区域分区
  373. subareaChange (val) {
  374. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  375. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  376. },
  377. // 产品分类 change
  378. changeProductType (val, opt) {
  379. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  380. this.queryParam.productType = val[1] ? val[1] : ''
  381. },
  382. // 重置
  383. resetSearchForm () {
  384. this.form.monthInfo = [moment().format('YYYY-MM'), moment().format('YYYY-MM')]
  385. this.startValue = moment().format('YYYY-MM')
  386. this.endValue = moment().format('YYYY-MM')
  387. this.queryParam.brandTypeBeginDate = moment().format('YYYYMM')
  388. this.queryParam.brandTypeEndDate = moment().format('YYYYMM')
  389. this.queryParam.dealerSn = undefined
  390. this.queryParam.provinceSn = undefined
  391. this.queryParam.subareaArea.subareaSn = undefined
  392. this.queryParam.subareaArea.subareaAreaSn = undefined
  393. this.queryParam.subareaArea.bizUserSn = undefined
  394. this.queryParam.productBrand = undefined
  395. this.queryParam.productTypeSn1 = undefined
  396. this.queryParam.productType = undefined
  397. this.queryParam.dealerLevel = undefined
  398. this.productType = []
  399. this.totalData = null
  400. if (this.advanced) {
  401. this.$refs.custList.resetForm()
  402. }
  403. this.$refs.subarea.clearData()
  404. this.$refs.ruleForm.resetFields()
  405. this.$refs.table.refresh()
  406. },
  407. setTableH () {
  408. const tableSearchH = this.$refs.tableSearch.offsetHeight
  409. this.tableHeight = window.innerHeight - tableSearchH - 215
  410. }
  411. },
  412. mounted () {
  413. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  414. this.setTableH()
  415. }
  416. },
  417. activated () {
  418. // 如果是新页签打开,则重置当前页面
  419. if (this.$store.state.app.isNewTab) {
  420. this.setTableH()
  421. }
  422. },
  423. beforeRouteEnter (to, from, next) {
  424. next(vm => {})
  425. }
  426. }
  427. </script>
  428. <style lang="less" scoped>
  429. .monthBox{
  430. /deep/.ant-calendar-picker-icon{
  431. display:none !important;
  432. }
  433. /deep/.ant-calendar-picker input{
  434. text-align:center;
  435. }
  436. }
  437. </style>