list.vue 21 KB

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