index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <a-card size="small" :bordered="false" class="promotionSalesRealTimeReport-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-tabs default-active-key="1" @change="handleChange">
  5. <a-tab-pane key="1" tab="促销销售单报表">
  6. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  7. <a-form-model
  8. layout="inline"
  9. ref="ruleForm"
  10. :rules="rules"
  11. :model="queryParam">
  12. <a-row :gutter="15">
  13. <a-col :md="6" :sm="24">
  14. <a-form-model-item label="销售审核日期" prop="salesDate">
  15. <rangeDate ref="rangeDate" :value="queryParam.salesDate" @change="salesDateChange" />
  16. </a-form-model-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <!-- :disabledDate="disabledDate" -->
  20. <a-form-model-item label="促销开始时间">
  21. <a-range-picker
  22. style="width:100%"
  23. v-model="time"
  24. :format="dateFormat"
  25. :placeholder="['开始时间', '结束时间']"
  26. @change="dateChange"></a-range-picker>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="促销名称">
  31. <a-input id="promotionSalesRealTimeReport-title" v-model.trim="queryParam.promoRuleReport.title" allowClear placeholder="请输入促销名称"/>
  32. </a-form-model-item>
  33. </a-col>
  34. <template v-if="advanced">
  35. <a-col :md="6" :sm="24">
  36. <a-form-model-item label="促销类型">
  37. <v-select
  38. v-model="queryParam.promoRuleReport.promotionRuleType"
  39. ref="ruleType"
  40. id="promotionSalesRealTimeReport-ruleType"
  41. code="PROMOTION_RULE_TYPE"
  42. placeholder="请选择促销类型"
  43. allowClear></v-select>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="规则">
  48. <a-input id="promotionSalesRealTimeReport-description" v-model.trim="queryParam.promoRuleReport.description" allowClear placeholder="请输入规则关键字"/>
  49. </a-form-model-item>
  50. </a-col>
  51. <a-col :md="6" :sm="24">
  52. <a-form-model-item label="销售单号">
  53. <a-input id="promotionSalesRealTimeReport-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  54. </a-form-model-item>
  55. </a-col>
  56. <a-col :md="6" :sm="24">
  57. <a-form-model-item label="客户级别">
  58. <v-select
  59. v-model="queryParam.buyerLevel"
  60. ref="buyerLevel"
  61. id="promotionSalesRealTimeReport-buyerLevel"
  62. code="DEALER_LEVEL"
  63. placeholder="请选择客户级别"
  64. allowClear></v-select>
  65. </a-form-model-item>
  66. </a-col>
  67. <a-col :md="6" :sm="24">
  68. <a-form-model-item label="客户名称">
  69. <a-input id="promotionSalesRealTimeReport-buyerName" v-model.trim="queryParam.buyerName" allowClear placeholder="请输入客户名称"/>
  70. </a-form-model-item>
  71. </a-col>
  72. <a-col :md="6" :sm="24">
  73. <a-form-model-item label="所在区域">
  74. <subarea ref="subarea" id="promotionSalesRealTimeReport-subarea" @change="subareaChange"></subarea>
  75. </a-form-model-item>
  76. </a-col>
  77. <a-col :md="6" :sm="24">
  78. <a-form-model-item label="地区">
  79. <AreaList id="promotionSalesRealTimeReport-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  80. </a-form-model-item>
  81. </a-col>
  82. </template>
  83. <a-col :md="6" :sm="24">
  84. <span class="table-page-search-submitButtons">
  85. <a-button type="primary" :disabled="disabled" @click="testForm('search')" >查询</a-button>
  86. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm">重置</a-button>
  87. <a-button
  88. style="margin-left: 10px"
  89. type="primary"
  90. class="button-warning"
  91. @click="testForm('export')"
  92. :disabled="disabled"
  93. :loading="exportLoading"
  94. v-if="$hasPermissions('B_promotionSalesExport')"
  95. >导出</a-button>
  96. <a @click="advanced=!advanced" style="margin-left: 8px">
  97. {{ advanced ? '收起' : '展开' }}
  98. <a-icon :type="advanced ? 'up' : 'down'"/>
  99. </a>
  100. </span>
  101. </a-col>
  102. </a-row>
  103. </a-form-model>
  104. </div>
  105. <!-- 列表 -->
  106. <s-table
  107. class="sTable"
  108. ref="table"
  109. size="small"
  110. :rowKey="(record) => record.no"
  111. rowKeyName="no"
  112. :columns="columns"
  113. :data="loadData"
  114. :style="{ height: tableHeight+84.5+'px' }"
  115. :scroll="{ y: tableHeight-40,x:1890}"
  116. :defaultLoadData="false"
  117. bordered>
  118. <!-- 促销时间 -->
  119. <template slot="promotionTime" slot-scope="text, record">
  120. <span>{{ record.promotion.promotionDateStart }}-{{ record.promotion.promotionDateEnd }}</span>
  121. </template>
  122. <!-- 规则 -->
  123. <template slot="promotionDesc" slot-scope="text, record">
  124. <span v-if="record.promotionRule.promotionRuleType=='PROMO_PROD'">{{ record.promotionRule.promotionRuleTypeDictValue }}</span>
  125. <span v-else-if="record.promotionRule.promotionRuleType=='RATIO_AMOUNT'">{{ record.promotionRule.regularSameFlag==1?'同款':'不同款' }}产品购买满{{ record.promotionRule.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品</span>
  126. <span v-else>购买满{{ record.promotionRule.regularAmount }}元正价产品,送{{ record.promotionRule.giveAmount }}元促销品采购额{{ record.promotionRule.accrualFlag&&record.promotionRule.accrualFlag==1?'(金额叠加)':'(金额不叠加)' }}</span>
  127. </template>
  128. <!-- 地区 -->
  129. <template slot="addressInfo" slot-scope="text, record">
  130. <span>{{ record.provinceName }}{{ record.cityName?'/'+record.cityName:'' }}{{ record.districtName?'/'+record.districtName :'' }}</span>
  131. </template>
  132. <template slot="footer">
  133. <a-row>
  134. <a-col span="24">
  135. <a-row>
  136. <a-col span="4">数量(非促):{{ (totalData && (totalData.notGiftQty || totalData.notGiftQty==0)) ? totalData.notGiftQty : '--' }}</a-col>
  137. <a-col span="4">数量(促):{{ (totalData && (totalData.giftQty || totalData.giftQty==0)) ? toThousands(totalData.giftQty) : '--' }}</a-col>
  138. <a-col span="4">实售金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ?totalData.totalRealAmount : '--' }}</a-col>
  139. <a-col span="4">开单金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</a-col>
  140. <a-col span="4">成本金额:{{ (totalData && (totalData.totalRealCost || totalData.totalRealCost==0)) ? totalData.totalRealCost : '--' }}</a-col>
  141. <a-col span="4">损失成本:{{ (totalData && (totalData.lossCost || totalData.lossCost==0)) ? toThousands(totalData.lossCost) : '--' }}</a-col>
  142. <a-col span="4">损失费用:{{ (totalData && (totalData.lossAmount || totalData.lossAmount==0)) ? toThousands(totalData.lossAmount) : '--' }}</a-col>
  143. <a-col span="4">采购额结余:{{ (totalData && (totalData.surplusPromoGiftsAmount || totalData.surplusPromoGiftsAmount==0)) ? toThousands(totalData.surplusPromoGiftsAmount) : '--' }}</a-col>
  144. <a-col span="4">采购额超出:{{ (totalData && (totalData.outPromoGiftsAmount || totalData.outPromoGiftsAmount==0)) ? toThousands(totalData.outPromoGiftsAmount) : '--' }}</a-col>
  145. </a-row>
  146. </a-col>
  147. </a-row>
  148. </template>
  149. </s-table>
  150. </a-tab-pane>
  151. <a-tab-pane key="2" tab="促销销售单实时报表" force-render>
  152. <gatherList></gatherList>
  153. </a-tab-pane>
  154. </a-tabs>
  155. <!-- 导出提示框 -->
  156. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  157. </a-spin>
  158. </a-card>
  159. </template>
  160. <script>
  161. import { commonMixin } from '@/utils/mixin'
  162. import { STable, VSelect } from '@/components'
  163. import reportModal from '@/views/common/reportModal.vue'
  164. import { salesPromoReportList, salesPromoReportQueryCount, exportSalesPromoReport } from '@/api/reportData'
  165. import { hdExportExcel } from '@/libs/exportExcel'
  166. import gatherList from './list'
  167. import rangeDate from '@/views/common/rangeDate.vue'
  168. import getDate from '@/libs/getDate.js'
  169. import subarea from '@/views/common/subarea.js'
  170. import AreaList from '@/views/common/areaList.js'
  171. import moment from 'moment'
  172. export default {
  173. name: 'PriceDifferenceDetailReportList',
  174. mixins: [commonMixin],
  175. components: { STable, VSelect, gatherList, reportModal, AreaList, rangeDate, subarea },
  176. data () {
  177. const _this = this
  178. return {
  179. advanced: true, // 高级搜索 展开/关闭
  180. time: undefined,
  181. spinning: false,
  182. queryParam: {
  183. salesDate: [
  184. getDate.getCurrMonthDays().starttime,
  185. getDate.getCurrMonthDays().endtime
  186. ],
  187. beginAuditDate: getDate.getCurrMonthDays().starttime, // 审核开始时间
  188. endAuditDate: getDate.getCurrMonthDays().endtime, // 审核结束时间
  189. promoRuleReport: {
  190. promotionDateStart: undefined, // 促销时间-开始
  191. promotionDateEnd: undefined, // 促销时间-结束
  192. title: '', // 促销名称
  193. promotionRuleType: undefined, // 促销类型
  194. description: ''// 规则
  195. },
  196. salesBillNo: '', // 销售单号
  197. buyerLevel: undefined, // 客户级别
  198. buyerName: '', // 客户名称
  199. subareaArea: {
  200. subareaSn: '',
  201. subareaAreaSn: ''
  202. },
  203. dealerProvinceSn: undefined, // 省份编码
  204. dealerCitySn: undefined, // 城市编码
  205. dealerDistrictSn: undefined // 区域编码
  206. },
  207. rules: {
  208. salesDate: [{ required: true, message: '请选择销售审核日期', trigger: 'change' }]
  209. },
  210. dateFormat: 'YYYY-MM-DD',
  211. tabVal: 1,
  212. disabled: false,
  213. tableHeight: 0,
  214. totalData: null, // 合计
  215. exportLoading: false,
  216. showExport: false,
  217. columns: [
  218. { title: '促销名称', dataIndex: 'promotion.title', width: '160px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left', ellipsis: true },
  219. { title: '促销时间', scopedSlots: { customRender: 'promotionTime' }, width: '130px', align: 'center', fixed: 'left' },
  220. { title: '费用所属部门', dataIndex: 'departmentName', width: '160px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true, fixed: 'left' },
  221. { title: '促销类型', dataIndex: 'promotionRule.promotionRuleTypeDictValue', width: '100px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
  222. { title: '规则', dataIndex: 'promotionRule.description', width: '180px', align: 'center', scopedSlots: { customRender: 'promotionDesc' }, fixed: 'left' },
  223. { title: '销售单号', dataIndex: 'salesBillNo', width: '120px', align: 'center', customRender: function (text) { return text || '--' }, fixed: 'left' },
  224. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '地区', dataIndex: 'provinceName', width: '160px', align: 'center', scopedSlots: { customRender: 'addressInfo' } },
  227. { title: '客户名称', dataIndex: 'buyerName', width: '140px', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  228. { title: '客户级别', dataIndex: 'buyerLevelDictValue', width: '80px', align: 'center', customRender: function (text) { return text || '--' } },
  229. { title: '销售审核日期', dataIndex: 'auditDate', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  230. { title: '数量(非促)', dataIndex: 'notGiftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. { title: '数量(促)', dataIndex: 'giftQty', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  232. { title: '实售金额', dataIndex: 'totalRealAmount', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  233. { title: '开单金额', dataIndex: 'totalAmount', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  234. { title: '成本金额', dataIndex: 'totalRealCost', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  235. { title: '损失成本', dataIndex: 'lossCost', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  236. { title: '损失费用', dataIndex: 'lossAmount', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  237. { title: '采购额结余', dataIndex: 'surplusPromoGiftsAmount', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  238. { title: '采购额超出', dataIndex: 'outPromoGiftsAmount', width: '100px', align: 'center', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  239. { title: '促销品费用归属品牌', dataIndex: 'promoProductBrandName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } },
  240. { title: '促销品费用归属分类', dataIndex: 'promoProductTypeName', width: '120px', align: 'center', customRender: function (text) { return text || '--' } }
  241. ],
  242. // 加载数据方法 必须为 Promise 对象
  243. loadData: parameter => {
  244. this.disabled = true
  245. const params = Object.assign(parameter, this.queryParam)
  246. const newParams = JSON.parse(JSON.stringify(params))
  247. delete newParams.salesDate
  248. this.spinning = true
  249. return salesPromoReportList(newParams).then(res => {
  250. let data
  251. if (res.status == 200) {
  252. data = res.data
  253. const no = (data.pageNo - 1) * data.pageSize
  254. for (var i = 0; i < data.list.length; i++) {
  255. data.list[i].no = no + i + 1
  256. }
  257. this.disabled = false
  258. }
  259. this.spinning = false
  260. return data
  261. })
  262. }
  263. }
  264. },
  265. methods: {
  266. salesDateChange (date) {
  267. if (date[0] && date[1]) {
  268. this.queryParam.salesDate = date
  269. } else {
  270. this.queryParam.salesDate = []
  271. }
  272. this.queryParam.beginAuditDate = date[0] || ''
  273. this.queryParam.endAuditDate = date[1] || ''
  274. },
  275. dateChange (date, dateString) {
  276. this.time = date
  277. if (dateString[0] != '' && dateString[1] != '') {
  278. this.queryParam.promoRuleReport.promotionDateStart = dateString[0] + ' 00:00:00'
  279. this.queryParam.promoRuleReport.promotionDateEnd = dateString[1] + ' 23:59:59'
  280. } else {
  281. this.$set(this.queryParam.promoRuleReport, 'promotionDateStart', undefined)
  282. this.$set(this.queryParam.promoRuleReport, 'promotionDateEnd', undefined)
  283. }
  284. },
  285. // // 不可选日期
  286. // disabledDate (date, dateStrings) {
  287. // return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
  288. // },
  289. // 统计
  290. getCount (params) {
  291. salesPromoReportQueryCount(params).then(res => {
  292. if (res.status == 200) {
  293. this.totalData = res.data
  294. } else {
  295. this.totalData = null
  296. }
  297. })
  298. },
  299. subareaChange (val) {
  300. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  301. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  302. },
  303. // tab
  304. handleChange (val) {
  305. this.tabVal = val
  306. },
  307. // 导出
  308. handleExport () {
  309. const _this = this
  310. const params = this.queryParam
  311. _this.exportLoading = true
  312. _this.spinning = true
  313. const ajaxUrl = _this.tabVal == 1 ? exportSalesPromoReport : exportSalesPromoRealReport
  314. const ajaxName = _this.tabVal == 1 ? '促销销售单报表导出' : '促销销售单实时报表导出'
  315. hdExportExcel(ajaxUrl, params, ajaxName, function () {
  316. _this.exportLoading = false
  317. _this.spinning = false
  318. _this.showExport = true
  319. })
  320. },
  321. // 验证表单 type值 search查询 export导出
  322. testForm (type) {
  323. const _this = this
  324. if (!_this.queryParam.salesDate[0] || !_this.queryParam.salesDate[1]) {
  325. _this.$message.error('请选择销售审核日期')
  326. return
  327. }
  328. _this.$refs.ruleForm.validate(valid => {
  329. if (valid) {
  330. if (type == 'search') {
  331. _this.handleSearch()
  332. } else {
  333. _this.handleExport()
  334. }
  335. } else {
  336. _this.$message.error('请选择销售审核日期')
  337. return false
  338. }
  339. })
  340. },
  341. areaChange (val) {
  342. this.queryParam.dealerProvinceSn = val[0] ? val[0] : ''
  343. this.queryParam.dealerCitySn = val[1] ? val[1] : ''
  344. this.queryParam.dealerDistrictSn = val[2] ? val[2] : ''
  345. },
  346. // 查询
  347. handleSearch () {
  348. const _this = this
  349. // 总计
  350. const paramData = JSON.parse(JSON.stringify(this.queryParam))
  351. delete paramData.salesDate
  352. _this.getCount(paramData)
  353. _this.$refs.table.refresh(true)
  354. },
  355. // 重置
  356. resetSearchForm () {
  357. this.$refs.ruleForm.resetFields()
  358. this.queryParam = {
  359. salesDate: [
  360. getDate.getCurrMonthDays().starttime,
  361. getDate.getCurrMonthDays().endtime
  362. ],
  363. beginAuditDate: getDate.getCurrMonthDays().starttime, // 审核开始时间
  364. endAuditDate: getDate.getCurrMonthDays().endtime, // 审核结束时间
  365. promoRuleReport: {
  366. promotionDateStart: undefined, // 促销时间-开始
  367. promotionDateEnd: undefined, // 促销时间-结束
  368. title: '', // 促销名称
  369. promotionRuleType: undefined, // 促销类型
  370. description: ''// 规则
  371. },
  372. salesBillNo: '', // 销售单号
  373. buyerLevel: undefined, // 客户级别
  374. buyerName: '', // 客户名称
  375. subareaArea: {
  376. subareaSn: '',
  377. subareaAreaSn: ''
  378. },
  379. dealerProvinceSn: undefined, // 省份编码
  380. dealerCitySn: undefined, // 城市编码
  381. dealerDistrictSn: undefined // 区域编码
  382. }
  383. this.time = undefined
  384. this.$refs.subarea.clearData()
  385. this.$refs.areaList.clearData()
  386. this.$refs.rangeDate.resetDate(this.queryParam.salesDate)
  387. this.$refs.table.clearTable()
  388. },
  389. pageInit () {
  390. const _this = this
  391. this.$nextTick(() => { // 页面渲染完成后的回调
  392. _this.setTableH()
  393. })
  394. },
  395. setTableH () {
  396. const tableSearchH = this.$refs.tableSearch.offsetHeight
  397. this.tableHeight = window.innerHeight - tableSearchH - 260
  398. }
  399. },
  400. watch: {
  401. advanced (newValue, oldValue) {
  402. const _this = this
  403. this.$nextTick(() => { // 页面渲染完成后的回调
  404. _this.setTableH()
  405. })
  406. },
  407. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  408. this.setTableH()
  409. }
  410. },
  411. mounted () {
  412. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  413. this.pageInit()
  414. }
  415. },
  416. activated () {
  417. // 如果是新页签打开,则重置当前页面
  418. if (this.$store.state.app.isNewTab) {
  419. this.pageInit()
  420. }
  421. }
  422. }
  423. </script>
  424. <style lang="less" scoped>
  425. .monthBox{
  426. /deep/.ant-calendar-picker-icon{
  427. display:none !important;
  428. }
  429. /deep/.ant-calendar-picker input{
  430. text-align:center;
  431. }
  432. }
  433. </style>