index.vue 19 KB

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