list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <div class="productInfoList-wrap">
  4. <div ref="tableSearch" class="table-page-search-wrapper newTableSearchName">
  5. <a-form-model layout="inline" ref="ruleForm" :rules="rules" :model="newQueryParam">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-model-item label="销售审核日期" prop="salesDate">
  9. <rangeDate ref="rangeDate" :value="newQueryParam.salesDate" @change="salesDateChange" />
  10. </a-form-model-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <!-- :disabledDate="disabledDate" -->
  14. <a-form-model-item label="促销开始时间">
  15. <a-range-picker
  16. style="width:100%"
  17. v-model="time"
  18. :format="dateFormat"
  19. :placeholder="['开始时间', '结束时间']"
  20. @change="dateChange"></a-range-picker>
  21. </a-form-model-item>
  22. </a-col>
  23. <a-col :md="6" :sm="24">
  24. <a-form-model-item label="促销名称">
  25. <a-input
  26. id="promotionSalesRealTimeReport-title"
  27. v-model.trim="newQueryParam.promoRuleReport.title"
  28. allowClear
  29. placeholder="请输入促销名称" />
  30. </a-form-model-item>
  31. </a-col>
  32. <template v-if="advanced">
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="促销类型">
  35. <v-select
  36. v-model="newQueryParam.promoRuleReport.promotionRuleType"
  37. ref="ruleType"
  38. id="promotionSalesRealTimeReport-ruleType"
  39. code="PROMOTION_RULE_TYPE"
  40. placeholder="请选择促销类型"
  41. allowClear></v-select>
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="规则">
  46. <a-input
  47. id="promotionSalesRealTimeReport-description"
  48. v-model.trim="newQueryParam.promoRuleReport.description"
  49. allowClear
  50. placeholder="请输入规则关键字" />
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-model-item label="销售单号">
  55. <a-input
  56. id="promotionSalesRealTimeReport-salesBillNo"
  57. v-model.trim="newQueryParam.salesBillNo"
  58. allowClear
  59. placeholder="请输入销售单号" />
  60. </a-form-model-item>
  61. </a-col>
  62. <a-col :md="6" :sm="24">
  63. <a-form-model-item label="客户级别">
  64. <v-select
  65. v-model="newQueryParam.buyerLevel"
  66. ref="buyerLevel"
  67. id="promotionSalesRealTimeReport-buyerLevel"
  68. code="DEALER_LEVEL"
  69. placeholder="请选择客户级别"
  70. allowClear></v-select>
  71. </a-form-model-item>
  72. </a-col>
  73. <a-col :md="6" :sm="24">
  74. <a-form-model-item label="客户名称">
  75. <a-input
  76. id="promotionSalesRealTimeReport-buyerName"
  77. v-model.trim="newQueryParam.buyerName"
  78. allowClear
  79. placeholder="请输入客户名称" />
  80. </a-form-model-item>
  81. </a-col>
  82. <a-col :md="6" :sm="24">
  83. <a-form-model-item label="所在区域">
  84. <subarea ref="subarea" id="promotionSalesRealTimeReport-subarea" @change="subareaChange"></subarea>
  85. </a-form-model-item>
  86. </a-col>
  87. <a-col :md="6" :sm="24">
  88. <a-form-model-item label="地区">
  89. <AreaList id="promotionSalesRealTimeReport-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  90. </a-form-model-item>
  91. </a-col>
  92. </template>
  93. <a-col :md="6" :sm="24">
  94. <span class="table-page-search-submitButtons">
  95. <a-button type="primary" :disabled="disabled" @click="testForm('search')">查询</a-button>
  96. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm">重置</a-button>
  97. <a-button
  98. style="margin-left: 10px"
  99. type="primary"
  100. class="button-warning"
  101. @click="testForm('export')"
  102. :disabled="disabled"
  103. :loading="exportLoading"
  104. v-if="$hasPermissions('B_promotionSalesExport')">导出</a-button>
  105. <a @click="advanced=!advanced" style="margin-left: 8px">
  106. {{ advanced ? '收起' : '展开' }}
  107. <a-icon :type="advanced ? 'up' : 'down'" />
  108. </a>
  109. </span>
  110. </a-col>
  111. </a-row>
  112. </a-form-model>
  113. </div>
  114. <!-- 列表 -->
  115. <s-table
  116. class="sTable"
  117. ref="table"
  118. size="small"
  119. :rowKey="(record) => record.no"
  120. rowKeyName="no"
  121. :columns="columns"
  122. :data="loadData"
  123. :style="{ height: tableHeight+84.5+'px' }"
  124. :scroll="{ y: tableHeight-40,x:1890}"
  125. :defaultLoadData="false"
  126. bordered>
  127. <!-- 促销时间 -->
  128. <template slot="promotionTime" slot-scope="text, record">
  129. <span>{{ record.promotion.promotionDateStart }}-{{ record.promotion.promotionDateEnd }}</span>
  130. </template>
  131. <!-- 规则 -->
  132. <template slot="promotionDesc" slot-scope="text, record">
  133. <span v-if="record.promotionRule.promotionRuleType=='PROMO_PROD'">{{ record.promotionRule.promotionRuleTypeDictValue }}</span>
  134. <span v-else-if="record.promotionRule.promotionRuleType=='RATIO_AMOUNT'">{{ record.promotionRule.regularSameFlag==1?'同款':'不同款' }}产品购买满{{ record.promotionRule.regularQty }}个正价产品,送{{ record.promotionQty }}个促销产品</span>
  135. <span v-else>购买满{{ record.promotionRule.regularAmount }}元正价产品,送{{ record.promotionRule.giveAmount }}元促销品采购额{{ record.promotionRule.accrualFlag&&record.promotionRule.accrualFlag==1?'(金额叠加)':'(金额不叠加)' }}</span>
  136. </template>
  137. <!-- 地区 -->
  138. <template slot="addressInfo" slot-scope="text, record">
  139. <span>{{ record.provinceName }}{{ record.cityName?'/'+record.cityName:'' }}{{ record.districtName?'/'+record.districtName :'' }}</span>
  140. </template>
  141. <template slot="footer">
  142. <a-row>
  143. <a-col span="24">
  144. <a-row>
  145. <a-col
  146. span="3">实时数量(非促):{{ (totalData && (totalData.notGiftQty || totalData.notGiftQty==0)) ? totalData.notGiftQty : '--' }}</a-col>
  147. <a-col
  148. span="3">实时数量(促):{{ (totalData && (totalData.giftQty || totalData.giftQty==0)) ? totalData.giftQty : '--' }}</a-col>
  149. <a-col
  150. span="3">实时实售金额:{{ (totalData && (totalData.totalRealAmount || totalData.totalRealAmount==0)) ? toThousands(totalData.totalRealAmount) : '--' }}</a-col>
  151. <a-col
  152. span="3">实时开单金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? toThousands(totalData.totalAmount) : '--' }}</a-col>
  153. <a-col
  154. span="3">实时成本金额:{{ (totalData && (totalData.totalRealCost || totalData.totalRealCost==0)) ? toThousands(totalData.totalRealCost) : '--' }}</a-col>
  155. <a-col
  156. span="4">实时损失成本:{{ (totalData && (totalData.lossCost || totalData.lossCost==0)) ? toThousands(totalData.lossCost) : '--' }}</a-col>
  157. <a-col
  158. span="5">实时损失费用:{{ (totalData && (totalData.lossAmount || totalData.lossAmount==0)) ? toThousands(totalData.lossAmount) : '--' }}</a-col>
  159. </a-row>
  160. </a-col>
  161. </a-row>
  162. </template>
  163. </s-table>
  164. </div>
  165. <!-- 导出提示框 -->
  166. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  167. </a-spin>
  168. </template>
  169. <script>
  170. import {
  171. commonMixin
  172. } from '@/utils/mixin'
  173. import {
  174. salesPromoRealReportList,
  175. salesPromoRealReportCount,
  176. exportSalesPromoRealReport
  177. } from '@/api/reportData'
  178. import {
  179. hdExportExcel
  180. } from '@/libs/exportExcel'
  181. import {
  182. STable,
  183. VSelect
  184. } from '@/components'
  185. import reportModal from '@/views/common/reportModal.vue'
  186. import rangeDate from '@/views/common/rangeDate.vue'
  187. import subarea from '@/views/common/subarea.js'
  188. import AreaList from '@/views/common/areaList.js'
  189. import getDate from '@/libs/getDate.js'
  190. export default {
  191. name: 'QueryPart',
  192. mixins: [commonMixin],
  193. components: {
  194. STable,
  195. VSelect,
  196. reportModal,
  197. AreaList,
  198. rangeDate,
  199. subarea
  200. },
  201. data () {
  202. const _this = this
  203. return {
  204. advanced: true, // 高级搜索 展开/关闭
  205. time: undefined,
  206. spinning: false,
  207. disabled: false,
  208. tableHeight: 0,
  209. newQueryParam: { // 查询条件
  210. salesDate: [
  211. getDate.getCurrMonthDays().starttime,
  212. getDate.getCurrMonthDays().endtime
  213. ],
  214. beginAuditDate: getDate.getCurrMonthDays().starttime, // 审核开始时间
  215. endAuditDate: getDate.getCurrMonthDays().endtime, // 审核结束时间
  216. promoRuleReport: {
  217. promotionDateStart: undefined, // 促销时间-开始
  218. promotionDateEnd: undefined, // 促销时间-结束
  219. title: '', // 促销名称
  220. promotionRuleType: undefined, // 促销类型
  221. description: '' // 规则
  222. },
  223. salesBillNo: '', // 销售单号
  224. buyerLevel: undefined, // 客户级别
  225. buyerName: '', // 客户名称
  226. subareaArea: {
  227. subareaSn: '',
  228. subareaAreaSn: ''
  229. },
  230. dealerProvinceSn: undefined, // 省份编码
  231. dealerCitySn: undefined, // 城市编码
  232. dealerDistrictSn: undefined // 区域编码
  233. },
  234. rules: {
  235. salesDate: [{
  236. required: true,
  237. message: '请选择销售审核日期',
  238. trigger: 'change'
  239. }]
  240. },
  241. dateFormat: 'YYYY-MM-DD',
  242. totalData: null, // 合计
  243. exportLoading: false,
  244. showExport: false,
  245. columns: [{
  246. title: '促销名称',
  247. dataIndex: 'promotion.title',
  248. width: '160px',
  249. align: 'center',
  250. customRender: function (text) {
  251. return text || '--'
  252. },
  253. fixed: 'left',
  254. ellipsis: true
  255. },
  256. {
  257. title: '促销时间',
  258. scopedSlots: {
  259. customRender: 'promotionTime'
  260. },
  261. width: '130px',
  262. align: 'center',
  263. fixed: 'left'
  264. },
  265. {
  266. title: '费用所属部门',
  267. dataIndex: 'departmentName',
  268. width: '160px',
  269. align: 'center',
  270. customRender: function (text) {
  271. return text || '--'
  272. },
  273. ellipsis: true,
  274. fixed: 'left'
  275. },
  276. {
  277. title: '促销类型',
  278. dataIndex: 'promotionRule.promotionRuleTypeDictValue',
  279. width: '100px',
  280. align: 'center',
  281. customRender: function (text) {
  282. return text || '--'
  283. },
  284. fixed: 'left'
  285. },
  286. { title: '规则', dataIndex: 'promotionRule.description', width: '180px', align: 'center', scopedSlots: { customRender: 'promotionDesc' }, fixed: 'left' },
  287. {
  288. title: '销售单号',
  289. dataIndex: 'salesBillNo',
  290. width: '120px',
  291. align: 'center',
  292. customRender: function (text) {
  293. return text || '--'
  294. },
  295. fixed: 'left'
  296. },
  297. {
  298. title: '区域',
  299. dataIndex: 'subareaArea.subareaName',
  300. width: '80px',
  301. align: 'center',
  302. customRender: function (text) {
  303. return text || '--'
  304. }
  305. },
  306. {
  307. title: '分区',
  308. dataIndex: 'subareaArea.subareaAreaName',
  309. width: '80px',
  310. align: 'center',
  311. customRender: function (text) {
  312. return text || '--'
  313. }
  314. },
  315. {
  316. title: '地区',
  317. dataIndex: 'provinceName',
  318. width: '160px',
  319. align: 'center',
  320. scopedSlots: { customRender: 'addressInfo' }
  321. },
  322. {
  323. title: '客户名称',
  324. dataIndex: 'buyerName',
  325. width: '140px',
  326. align: 'center',
  327. customRender: function (text) {
  328. return text || '--'
  329. },
  330. ellipsis: true
  331. },
  332. {
  333. title: '客户级别',
  334. dataIndex: 'buyerLevelDictValue',
  335. width: '80px',
  336. align: 'center',
  337. customRender: function (text) {
  338. return text || '--'
  339. }
  340. },
  341. {
  342. title: '销售审核日期',
  343. dataIndex: 'auditDate',
  344. width: '120px',
  345. align: 'center',
  346. customRender: function (text) {
  347. return text || '--'
  348. }
  349. },
  350. {
  351. title: '实时数量(非促)',
  352. dataIndex: 'notGiftQty',
  353. width: '100px',
  354. align: 'center',
  355. customRender: function (text) {
  356. return ((text || text == 0) ? text : '--')
  357. }
  358. },
  359. {
  360. title: '实时数量(促)',
  361. dataIndex: 'giftQty',
  362. width: '100px',
  363. align: 'center',
  364. customRender: function (text) {
  365. return ((text || text == 0) ? text : '--')
  366. }
  367. },
  368. {
  369. title: '实时实售金额',
  370. dataIndex: 'totalRealAmount',
  371. width: '100px',
  372. align: 'center',
  373. customRender: function (text) {
  374. return ((text || text == 0) ? _this.toThousands(text) : '--')
  375. }
  376. },
  377. {
  378. title: '实时开单金额',
  379. dataIndex: 'totalAmount',
  380. width: '100px',
  381. align: 'center',
  382. customRender: function (text) {
  383. return ((text || text == 0) ? _this.toThousands(text) : '--')
  384. }
  385. },
  386. {
  387. title: '实时成本金额',
  388. dataIndex: 'totalRealCost',
  389. width: '100px',
  390. align: 'center',
  391. customRender: function (text) {
  392. return ((text || text == 0) ? _this.toThousands(text) : '--')
  393. }
  394. },
  395. {
  396. title: '实时损失成本',
  397. dataIndex: 'lossCost',
  398. width: '100px',
  399. align: 'center',
  400. customRender: function (text) {
  401. return ((text || text == 0) ? _this.toThousands(text) : '--')
  402. }
  403. },
  404. {
  405. title: '实时损失费用',
  406. dataIndex: 'lossAmount',
  407. width: '100px',
  408. align: 'center',
  409. customRender: function (text) {
  410. return ((text || text == 0) ? _this.toThousands(text) : '--')
  411. }
  412. }
  413. ],
  414. // 加载数据方法 必须为 Promise 对象
  415. loadData: parameter => {
  416. this.spinning = true
  417. this.disabled = true
  418. const params = Object.assign(parameter, this.newQueryParam)
  419. return salesPromoRealReportList(params).then(res => {
  420. let data
  421. if (res.status == 200) {
  422. data = res.data
  423. for (var i = 0; i < data.length; i++) {
  424. data[i].no = i + 1
  425. }
  426. this.disabled = false
  427. }
  428. this.spinning = false
  429. return data
  430. })
  431. }
  432. }
  433. },
  434. watch: {
  435. advanced (newValue, oldValue) {
  436. const _this = this
  437. this.$nextTick(() => { // 页面渲染完成后的回调
  438. _this.setTableH()
  439. })
  440. },
  441. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  442. this.setTableH()
  443. }
  444. },
  445. methods: {
  446. salesDateChange (date) {
  447. if (date[0] && date[1]) {
  448. this.newQueryParam.salesDate = date
  449. } else {
  450. this.newQueryParam.salesDate = []
  451. }
  452. this.newQueryParam.beginAuditDate = date[0] || ''
  453. this.newQueryParam.endAuditDate = date[1] || ''
  454. },
  455. areaChange (val) {
  456. this.newQueryParam.dealerProvinceSn = val[0] ? val[0] : ''
  457. this.newQueryParam.dealerCitySn = val[1] ? val[1] : ''
  458. this.newQueryParam.dealerDistrictSn = val[2] ? val[2] : ''
  459. },
  460. dateChange (date, dateString) {
  461. this.time = date
  462. if (dateString[0] != '' && dateString[1] != '') {
  463. this.newQueryParam.promoRuleReport.promotionDateStart = dateString[0] + ' 00:00:00'
  464. this.newQueryParam.promoRuleReport.promotionDateEnd = dateString[1] + ' 23:59:59'
  465. } else {
  466. this.$set(this.newQueryParam.promoRuleReport, 'promotionDateStart', undefined)
  467. this.$set(this.newQueryParam.promoRuleReport, 'promotionDateEnd', undefined)
  468. }
  469. },
  470. subareaChange (val) {
  471. this.newQueryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  472. this.newQueryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  473. },
  474. // 查询
  475. testForm (type) {
  476. const _this = this
  477. if (!_this.newQueryParam.salesDate && (!_this.newQueryParam.salesDate[0] || !_this.newQueryParam.salesDate[1])) {
  478. _this.$message.error('请选择销售审核日期')
  479. return
  480. }
  481. _this.$refs.ruleForm.validate(valid => {
  482. if (valid) {
  483. if (type == 'search') {
  484. _this.resetCurForm()
  485. } else {
  486. _this.handleExport()
  487. }
  488. } else {
  489. _this.$message.error('请选择销售审核日期')
  490. return false
  491. }
  492. })
  493. },
  494. // 统计
  495. getCount (params) {
  496. salesPromoRealReportCount(params).then(res => {
  497. if (res.status == 200) {
  498. this.totalData = res.data
  499. } else {
  500. this.totalData = null
  501. }
  502. })
  503. },
  504. // 刷新当前页面
  505. resetCurForm () {
  506. const params = JSON.parse(JSON.stringify(this.newQueryParam))
  507. delete params.salesDate
  508. this.$nextTick(() => {
  509. this.getCount(params)
  510. this.$refs.table.refresh()
  511. })
  512. },
  513. // 导出
  514. handleExport () {
  515. const _this = this
  516. const params = this.newQueryParam
  517. _this.exportLoading = true
  518. _this.spinning = true
  519. hdExportExcel(exportSalesPromoRealReport, params, '促销销售单实时报表导出', function () {
  520. _this.exportLoading = false
  521. _this.spinning = false
  522. _this.showExport = true
  523. })
  524. },
  525. resetSearchForm () {
  526. this.$refs.ruleForm.resetFields()
  527. this.newQueryParam = {
  528. beginAuditDate: getDate.getCurrMonthDays().starttime, // 审核开始时间
  529. endAuditDate: getDate.getCurrMonthDays().endtime, // 审核结束时间
  530. promoRuleReport: {
  531. promotionDateStart: undefined, // 促销时间-开始
  532. promotionDateEnd: undefined, // 促销时间-结束
  533. title: '', // 促销名称
  534. promotionRuleType: undefined, // 促销类型
  535. description: '' // 规则
  536. },
  537. salesBillNo: '', // 销售单号
  538. buyerLevel: undefined, // 客户级别
  539. buyerName: '', // 客户名称
  540. subareaArea: {
  541. subareaSn: '',
  542. subareaAreaSn: ''
  543. },
  544. dealerProvinceSn: undefined, // 省份编码
  545. dealerCitySn: undefined, // 城市编码
  546. dealerDistrictSn: undefined // 区域编码
  547. }
  548. this.$set(this.newQueryParam, 'salesDate', [
  549. getDate.getCurrMonthDays().starttime,
  550. getDate.getCurrMonthDays().endtime
  551. ])
  552. this.time = undefined
  553. this.$refs.subarea.clearData()
  554. this.$refs.areaList.clearData()
  555. this.$refs.rangeDate.resetDate(this.newQueryParam.salesDate)
  556. this.$refs.table.clearTable()
  557. },
  558. pageInit () {
  559. const _this = this
  560. this.$nextTick(() => { // 页面渲染完成后的回调
  561. _this.setTableH()
  562. })
  563. },
  564. setTableH () {
  565. const tableSearchH = this.$refs.tableSearch.offsetHeight
  566. this.tableHeight = window.innerHeight - tableSearchH - 260
  567. }
  568. },
  569. mounted () {
  570. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  571. this.pageInit()
  572. }
  573. },
  574. activated () {
  575. // 如果是新页签打开,则重置当前页面
  576. if (this.$store.state.app.isNewTab) {
  577. this.pageInit()
  578. }
  579. }
  580. }
  581. </script>
  582. <style lang="less" scoped>
  583. .productInfoList-wrap {
  584. .ellipsisCon {
  585. display: flex;
  586. justify-content: space-between;
  587. align-items: center;
  588. .ellipsisText {
  589. width: 100%;
  590. overflow: hidden;
  591. text-overflow: ellipsis;
  592. display: box;
  593. display: -webkit-box;
  594. -webkit-line-clamp: 1;
  595. -webkit-box-orient: vertical;
  596. }
  597. }
  598. }
  599. </style>