index.vue 22 KB

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