list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <a-card>
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-tabs v-model="activeKey" type="card" @change="callback">
  5. <a-tab-pane :key="item.id" :tab="item.name" v-for="item in tabsList">
  6. </a-tab-pane>
  7. </a-tabs>
  8. <div class="table-page-search-wrapper">
  9. <a-form-model
  10. id="returnGoodsPresentationList-form"
  11. ref="ruleForm"
  12. class="form-model-con"
  13. layout="inline"
  14. :rules="rules"
  15. :model="queryParam"
  16. @keyup.enter.native="handleSearch">
  17. <a-row :gutter="15">
  18. <!-- <a-col :md="6" :sm="24">
  19. <a-form-model-item label="创建时间" prop="time">
  20. <a-date-picker
  21. style="width:100%"
  22. placeholder="请选择年份"
  23. format="YYYY"
  24. mode="year"
  25. :disabledDate="disabledDate"
  26. @change="onChange"
  27. :value="year"
  28. :open="open"
  29. @openChange="openChange"
  30. @panelChange="panelChange"
  31. />
  32. </a-form-model-item>
  33. </a-col> -->
  34. <a-col :md="6" :sm="24">
  35. <a-form-model-item label="所在区域">
  36. <subarea id="returnGoodsPresentationList-subareaSn" v-model="queryParam.dealer.subareaSn"></subarea>
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24" v-if="activeKey == 0">
  40. <a-form-model-item prop="dealerProvinceSn" style="margin: 0;" label="地区">
  41. <a-select v-model="queryParam.dealer.provinceSn" allowClear placeholder="请选择省">
  42. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  43. </a-select>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="returnGoodsPresentationList-refresh">查询</a-button>
  48. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="returnGoodsPresentationList-reset">重置</a-button>
  49. <a-button
  50. style="margin-left: 5px"
  51. type="primary"
  52. class="button-warning"
  53. @click="handleExport"
  54. :disabled="disabled"
  55. :loading="exportLoading"
  56. v-if="$hasPermissions('B_returnGoodsPresentationExport')"
  57. id="returnGoodsPresentationList-export">导出</a-button>
  58. </a-col>
  59. </a-row>
  60. </a-form-model>
  61. </div>
  62. <!-- 列表 -->
  63. <s-table
  64. class="sTable"
  65. ref="table"
  66. size="small"
  67. :defaultLoadData="false"
  68. :rowKey="(record) => record.id"
  69. :columns="columns"
  70. :showPagination="false"
  71. :data="loadData"
  72. :scroll="{ x: 2370 }"
  73. bordered>
  74. <template slot="footer">
  75. <a-row>
  76. <a-col span="2">合计:</a-col>
  77. <a-col span="22">
  78. <a-row>
  79. <a-col span="4">1月:{{ (totalData && (totalData.jpYgpAmount || totalData.jpYgpAmount==0)) ? totalData.jpYgpAmount : '--' }}</a-col>
  80. <a-col span="4">2月:{{ (totalData && (totalData.jpLbAmount || totalData.jpLbAmount==0)) ? totalData.jpLbAmount : '--' }}</a-col>
  81. <a-col span="4">3月:{{ (totalData && (totalData.jpScpAmount || totalData.jpScpAmount==0)) ? totalData.jpScpAmount : '--' }}</a-col>
  82. <a-col span="4">4月:{{ (totalData && (totalData.jpGyxAmount || totalData.jpGyxAmount==0)) ? totalData.jpGyxAmount : '--' }}</a-col>
  83. <a-col span="4">5月:{{ (totalData && (totalData.gpYgpAmount || totalData.gpYgpAmount==0)) ? totalData.gpYgpAmount : '--' }}</a-col>
  84. <a-col span="4">6月:{{ (totalData && (totalData.gpLqqAmount || totalData.gpLqqAmount==0)) ? totalData.gpLqqAmount : '--' }}</a-col>
  85. <a-col span="4">7月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  86. <a-col span="4">8月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  87. <a-col span="4">9月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  88. <a-col span="4">10月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  89. <a-col span="4">11月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  90. <a-col span="4">12月:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  91. <a-col span="4">1-12月费用:{{ (totalData && (totalData.hjAmount || totalData.hjAmount==0)) ? totalData.hjAmount : '--' }}</a-col>
  92. <a-col span="4">实际销售额:{{ (totalData && (totalData.dlsAmount || totalData.dlsAmount==0)) ? totalData.dlsAmount : '--' }}</a-col>
  93. <a-col span="4">费用占比(%):{{ (totalData && (totalData.wsAmount || totalData.wsAmount==0)) ? totalData.wsAmount : '--' }}</a-col>
  94. <a-col span="4">正常配送品费用:{{ (totalData && (totalData.wsAmount || totalData.wsAmount==0)) ? totalData.wsAmount : '--' }}</a-col>
  95. <a-col span="4">正常促销品费用:{{ (totalData && (totalData.wsAmount || totalData.wsAmount==0)) ? totalData.wsAmount : '--' }}</a-col>
  96. <a-col span="4">特殊申请配送品费用:{{ (totalData && (totalData.tbuAmount || totalData.tbuAmount==0)) ? totalData.tbuAmount : '--' }}</a-col>
  97. <a-col span="4">特殊申请促销品费用:{{ (totalData && (totalData.tbupAmount || totalData.tbupAmount==0)) ? totalData.tbupAmount : '--' }}</a-col>
  98. </a-row>
  99. </a-col>
  100. </a-row>
  101. </template>
  102. </s-table>
  103. </a-spin>
  104. <!-- 导出提示框 -->
  105. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  106. </a-card>
  107. </template>
  108. <script>
  109. import { commonMixin } from '@/utils/mixin'
  110. import { STable, VSelect } from '@/components'
  111. import rangeDate from '@/views/common/rangeDate.vue'
  112. import reportModal from '@/views/common/reportModal.vue'
  113. import { getArea } from '@/api/data'
  114. import subarea from '@/views/common/subarea.js'
  115. import { reportSalesReturnThjdReportList } from '@/api/reportData'
  116. import moment from 'moment'
  117. import reportData from '@/libs/reportData.js'
  118. export default {
  119. name: 'AllCountryCostReportList',
  120. mixins: [commonMixin],
  121. components: { STable, VSelect, rangeDate, subarea, moment, reportModal },
  122. data () {
  123. return {
  124. spinning: false,
  125. tabsList: [{ id: 0, name: '全国客户费用统计' }, { id: 1, name: '区域促销费用统计' }],
  126. activeKey: 0,
  127. open: false,
  128. year: '',
  129. showExport: false, // 导出弹窗初始值
  130. queryParam: {
  131. time: [],
  132. beginDate: '',
  133. endDate: '',
  134. dealer: {
  135. 'dealerName': '',
  136. 'provinceSn': undefined,
  137. 'citySn': undefined,
  138. 'districtSn': undefined,
  139. 'subareaSn': undefined,
  140. 'dealerLevel': undefined
  141. }
  142. },
  143. addrProvinceList: [], // 省下拉
  144. disabled: false, // 查询、重置按钮是否可操作
  145. exportLoading: false,
  146. rules: {
  147. 'time': [{ required: true, message: '请选择月份', trigger: 'change' }]
  148. },
  149. // 加载数据方法 必须为 Promise 对象
  150. loadData: parameter => {
  151. const _this = this
  152. _this.disabled = true
  153. _this.spinning = true
  154. return new Promise(function (resolve, reject) {
  155. const data = {
  156. list: reportData.nationalCustomerCostStatisticsList
  157. }
  158. for (var i = 0; i < data.list.length; i++) {
  159. data.list[i].no = i + 1
  160. }
  161. _this.spinning = false
  162. _this.disabled = false
  163. resolve(data)
  164. })
  165. // const paramsPage = Object.assign(this.queryParam) // 有分页
  166. // return reportSalesReturnThjdReportList(paramsPage).then(res => {
  167. // let data
  168. // if (res.status == 200) {
  169. // data = res.data
  170. // // this.getCount(paramsPage)
  171. // const no = (data.pageNo - 1) * data.pageSize
  172. // for (var i = 0; i < data.list.length; i++) {
  173. // data.list[i].no = no + i + 1
  174. // }
  175. // this.disabled = false
  176. // }
  177. // this.spinning = false
  178. // return data
  179. // })
  180. },
  181. totalData: null
  182. }
  183. },
  184. computed: {
  185. columns () {
  186. const arr = [
  187. {
  188. title: '区域',
  189. dataIndex: 'area',
  190. width: 200,
  191. align: 'center',
  192. customRender: function (text) {
  193. return text || '--'
  194. }
  195. },
  196. {
  197. title: '客户名称',
  198. dataIndex: '',
  199. align: 'center',
  200. customRender: function (text) {
  201. return text || '--'
  202. },
  203. width: 120,
  204. ellipsis: true
  205. },
  206. {
  207. title: '费用类型',
  208. dataIndex: '',
  209. width: 120,
  210. align: 'center',
  211. customRender: function (text) {
  212. return ((text || text == 0) ? text : '--')
  213. }
  214. },
  215. {
  216. title: '1月',
  217. dataIndex: '',
  218. width: 120,
  219. align: 'center',
  220. customRender: function (text) {
  221. return ((text || text == 0) ? text : '--')
  222. }
  223. },
  224. {
  225. title: '2月',
  226. dataIndex: '',
  227. width: 120,
  228. align: 'center',
  229. customRender: function (text) {
  230. return ((text || text == 0) ? text : '--')
  231. }
  232. },
  233. {
  234. title: '3月',
  235. dataIndex: '',
  236. width: 120,
  237. align: 'center',
  238. customRender: function (text) {
  239. return ((text || text == 0) ? text : '--')
  240. }
  241. },
  242. {
  243. title: '4月',
  244. dataIndex: '',
  245. width: 120,
  246. align: 'center',
  247. customRender: function (text) {
  248. return ((text || text == 0) ? text : '--')
  249. }
  250. },
  251. {
  252. title: '5月',
  253. dataIndex: '',
  254. width: 120,
  255. align: 'center',
  256. customRender: function (text) {
  257. return ((text || text == 0) ? text : '--')
  258. }
  259. },
  260. {
  261. title: '6月',
  262. dataIndex: '',
  263. width: 120,
  264. align: 'center',
  265. customRender: function (text) {
  266. return ((text || text == 0) ? text : '--')
  267. }
  268. },
  269. {
  270. title: '7月',
  271. dataIndex: '',
  272. width: 120,
  273. align: 'center',
  274. customRender: function (text) {
  275. return ((text || text == 0) ? text : '--')
  276. }
  277. },
  278. {
  279. title: '8月',
  280. dataIndex: '',
  281. width: 120,
  282. align: 'center',
  283. customRender: function (text) {
  284. return ((text || text == 0) ? text : '--')
  285. }
  286. },
  287. {
  288. title: '9月',
  289. dataIndex: '',
  290. width: 120,
  291. align: 'center',
  292. customRender: function (text) {
  293. return ((text || text == 0) ? text : '--')
  294. }
  295. },
  296. {
  297. title: '10月',
  298. dataIndex: '',
  299. width: 120,
  300. align: 'center',
  301. customRender: function (text) {
  302. return ((text || text == 0) ? text : '--')
  303. }
  304. },
  305. {
  306. title: '11月',
  307. dataIndex: '',
  308. width: 120,
  309. align: 'center',
  310. customRender: function (text) {
  311. return ((text || text == 0) ? text : '--')
  312. }
  313. },
  314. {
  315. title: '12月',
  316. dataIndex: '',
  317. width: 120,
  318. align: 'center',
  319. customRender: function (text) {
  320. return ((text || text == 0) ? text : '--')
  321. }
  322. },
  323. {
  324. title: '1-12月费用合计',
  325. dataIndex: '',
  326. width: 140,
  327. align: 'center',
  328. customRender: function (text) {
  329. return ((text || text == 0) ? text : '--')
  330. }
  331. },
  332. {
  333. title: '实际销售额合计',
  334. dataIndex: '',
  335. width: 140,
  336. align: 'center',
  337. customRender: (value, row, index) => {
  338. const obj = {
  339. children: value,
  340. attrs: {}
  341. }
  342. if (index === 0) {
  343. obj.attrs.rowSpan = 5
  344. }
  345. if (index === 1) {
  346. obj.attrs.rowSpan = 0
  347. }
  348. if (index === 2) {
  349. obj.attrs.rowSpan = 0
  350. }
  351. if (index === 3) {
  352. obj.attrs.rowSpan = 0
  353. }
  354. if (index === 4) {
  355. obj.attrs.rowSpan = 0
  356. }
  357. if (index === 5) {
  358. obj.attrs.rowSpan = 5
  359. }
  360. if (index === 6) {
  361. obj.attrs.rowSpan = 0
  362. }
  363. if (index === 7) {
  364. obj.attrs.rowSpan = 0
  365. }
  366. if (index === 8) {
  367. obj.attrs.rowSpan = 0
  368. }
  369. if (index === 9) {
  370. obj.attrs.rowSpan = 0
  371. }
  372. if (index === 10) {
  373. obj.attrs.rowSpan = 5
  374. }
  375. if (index === 11) {
  376. obj.attrs.rowSpan = 0
  377. }
  378. if (index === 12) {
  379. obj.attrs.rowSpan = 0
  380. }
  381. if (index === 13) {
  382. obj.attrs.rowSpan = 0
  383. }
  384. if (index === 14) {
  385. obj.attrs.rowSpan = 0
  386. }
  387. return obj
  388. }
  389. },
  390. {
  391. title: '费用占比(%)',
  392. dataIndex: '',
  393. width: 140,
  394. align: 'center',
  395. customRender: function (text) {
  396. return ((text || text == 0) ? text : '--')
  397. }
  398. },
  399. {
  400. title: '正常配送品费用',
  401. dataIndex: '',
  402. width: 120,
  403. align: 'center',
  404. customRender: function (text) {
  405. return ((text || text == 0) ? text : '--')
  406. }
  407. },
  408. {
  409. title: '正常促销品费用',
  410. dataIndex: '',
  411. width: 120,
  412. align: 'center',
  413. customRender: function (text) {
  414. return ((text || text == 0) ? text : '--')
  415. }
  416. },
  417. {
  418. title: '特殊申请配送品费用',
  419. dataIndex: '',
  420. width: 120,
  421. align: 'center',
  422. customRender: function (text) {
  423. return ((text || text == 0) ? text : '--')
  424. }
  425. },
  426. {
  427. title: '特殊申请促销品费用',
  428. dataIndex: '',
  429. width: 120,
  430. align: 'center',
  431. customRender: function (text) {
  432. return ((text || text == 0) ? text : '--')
  433. }
  434. }
  435. ]
  436. if (this.activeKey == 0) {
  437. arr.splice(1, 0, { title: '省份', dataIndex: 'province', width: 90, align: 'center', customRender: function (text) { return text || '--' } })
  438. }
  439. return arr
  440. }
  441. },
  442. methods: {
  443. callback (key) {
  444. this.activeKey = key
  445. console.log(key, this.activeKey)
  446. },
  447. onChange (date, dateString) {
  448. console.log(date, dateString)
  449. },
  450. openChange (status) {
  451. if (status) {
  452. this.open = true
  453. } else {
  454. this.open = false
  455. }
  456. },
  457. panelChange (value) {
  458. this.year = value
  459. this.open = false
  460. },
  461. // 禁止选择的年份
  462. disabledDate (currentDate) {
  463. console.log(currentDate)
  464. return currentDate && currentDate < moment().endOf('year')
  465. },
  466. // 分页
  467. // 查询省
  468. getProvinceData (leve, sn) {
  469. let params
  470. if (leve == 'province') {
  471. params = { type: '2' }
  472. } else {
  473. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  474. }
  475. getArea(params).then(res => {
  476. if (res.status == 200) {
  477. console.log(res, '=============地区')
  478. if (leve == 'province') {
  479. this.addrProvinceList = res.data || []
  480. } else if (leve == 'city') {
  481. this.addrCityList = res.data || []
  482. } else if (leve == 'district') {
  483. this.addrDistrictList = res.data || []
  484. }
  485. } else {
  486. if (leve == 'province') {
  487. this.addrProvinceList = []
  488. } else if (leve == 'city') {
  489. this.addrCityList = []
  490. } else if (leve == 'district') {
  491. this.addrDistrictList = []
  492. }
  493. }
  494. })
  495. },
  496. // 创建时间 change
  497. dateChange (date) {
  498. if (date[0] && date[1]) {
  499. this.queryParam.time = date
  500. } else {
  501. this.queryParam.time = []
  502. }
  503. this.queryParam.beginDate = date[0] || ''
  504. this.queryParam.endDate = date[1] || ''
  505. },
  506. // 查询
  507. handleSearch () {
  508. const _this = this
  509. this.$refs.ruleForm.validate(valid => {
  510. if (valid) {
  511. _this.$refs.table.refresh(true)
  512. } else {
  513. return false
  514. }
  515. })
  516. },
  517. // 重置
  518. resetSearchForm () {
  519. this.queryParam.time = []
  520. this.$refs.rangeDate.resetDate(this.queryParam.time)
  521. this.queryParam.beginDate = ''
  522. this.queryParam.endDate = ''
  523. this.queryParam.dealer = {
  524. 'dealerName': '',
  525. 'provinceSn': undefined,
  526. 'citySn': undefined,
  527. 'districtSn': undefined,
  528. 'subareaSn': undefined,
  529. 'dealerLevel': undefined
  530. }
  531. this.totalData = null
  532. this.$refs.ruleForm.resetFields()
  533. this.$refs.table.clearTable()
  534. },
  535. // 导出
  536. handleExport () {
  537. const _this = this
  538. this.$refs.ruleForm.validate(valid => {
  539. if (valid) {
  540. _this.showExport = true
  541. const params = _this.queryParam
  542. _this.exportLoading = true
  543. _this.spinning = true
  544. hdExportExcel(reportRebateExport, params, '全国各省品类实际销售明细报表', function () {
  545. _this.exportLoading = false
  546. _this.spinning = false
  547. })
  548. } else {
  549. return false
  550. }
  551. })
  552. },
  553. pageInit () {
  554. this.activeKey = 0
  555. this.getProvinceData('province')
  556. }
  557. },
  558. mounted () {
  559. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  560. this.pageInit()
  561. // this.resetSearchForm()
  562. }
  563. },
  564. activated () {
  565. // 如果是新页签打开,则重置当前页面
  566. if (this.$store.state.app.isNewTab) {
  567. this.pageInit()
  568. // this.resetSearchForm()
  569. }
  570. },
  571. beforeRouteEnter (to, from, next) {
  572. next(vm => {})
  573. }
  574. }
  575. </script>
  576. <style style="less">
  577. .regionTypeSalesReportList-wrap{
  578. }
  579. </style>