list.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  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 _this = this
  187. const arr = [
  188. {
  189. title: '区域',
  190. dataIndex: 'area',
  191. width: 200,
  192. align: 'center',
  193. customRender: function (text) {
  194. return text || '--'
  195. }
  196. },
  197. {
  198. title: '客户名称',
  199. dataIndex: '',
  200. align: 'center',
  201. customRender: function (text) {
  202. return text || '--'
  203. },
  204. width: 120,
  205. ellipsis: true
  206. },
  207. {
  208. title: '费用类型',
  209. dataIndex: '',
  210. width: 120,
  211. align: 'center',
  212. customRender: function (text) {
  213. return ((text || text == 0) ? text : '--')
  214. }
  215. },
  216. {
  217. title: '1月',
  218. dataIndex: '',
  219. width: 120,
  220. align: 'center',
  221. customRender: function (text) {
  222. return ((text || text == 0) ? text : '--')
  223. }
  224. },
  225. {
  226. title: '2月',
  227. dataIndex: '',
  228. width: 120,
  229. align: 'center',
  230. customRender: function (text) {
  231. return ((text || text == 0) ? text : '--')
  232. }
  233. },
  234. {
  235. title: '3月',
  236. dataIndex: '',
  237. width: 120,
  238. align: 'center',
  239. customRender: function (text) {
  240. return ((text || text == 0) ? text : '--')
  241. }
  242. },
  243. {
  244. title: '4月',
  245. dataIndex: '',
  246. width: 120,
  247. align: 'center',
  248. customRender: function (text) {
  249. return ((text || text == 0) ? text : '--')
  250. }
  251. },
  252. {
  253. title: '5月',
  254. dataIndex: '',
  255. width: 120,
  256. align: 'center',
  257. customRender: function (text) {
  258. return ((text || text == 0) ? text : '--')
  259. }
  260. },
  261. {
  262. title: '6月',
  263. dataIndex: '',
  264. width: 120,
  265. align: 'center',
  266. customRender: function (text) {
  267. return ((text || text == 0) ? text : '--')
  268. }
  269. },
  270. {
  271. title: '7月',
  272. dataIndex: '',
  273. width: 120,
  274. align: 'center',
  275. customRender: function (text) {
  276. return ((text || text == 0) ? text : '--')
  277. }
  278. },
  279. {
  280. title: '8月',
  281. dataIndex: '',
  282. width: 120,
  283. align: 'center',
  284. customRender: function (text) {
  285. return ((text || text == 0) ? text : '--')
  286. }
  287. },
  288. {
  289. title: '9月',
  290. dataIndex: '',
  291. width: 120,
  292. align: 'center',
  293. customRender: function (text) {
  294. return ((text || text == 0) ? text : '--')
  295. }
  296. },
  297. {
  298. title: '10月',
  299. dataIndex: '',
  300. width: 120,
  301. align: 'center',
  302. customRender: function (text) {
  303. return ((text || text == 0) ? text : '--')
  304. }
  305. },
  306. {
  307. title: '11月',
  308. dataIndex: '',
  309. width: 120,
  310. align: 'center',
  311. customRender: function (text) {
  312. return ((text || text == 0) ? text : '--')
  313. }
  314. },
  315. {
  316. title: '12月',
  317. dataIndex: '',
  318. width: 120,
  319. align: 'center',
  320. customRender: function (text) {
  321. return ((text || text == 0) ? text : '--')
  322. }
  323. },
  324. {
  325. title: '1-12月费用合计',
  326. dataIndex: '',
  327. width: 140,
  328. align: 'right',
  329. customRender: function (text) {
  330. return ((text || text == 0) ? _this.toThousands(text) : '--')
  331. }
  332. },
  333. {
  334. title: '实际销售额合计',
  335. dataIndex: '',
  336. width: 140,
  337. align: 'right',
  338. customRender: (value, row, index) => {
  339. const obj = {
  340. children: _this.toThousands(value),
  341. attrs: {}
  342. }
  343. if (index === 0) {
  344. obj.attrs.rowSpan = 5
  345. }
  346. if (index === 1) {
  347. obj.attrs.rowSpan = 0
  348. }
  349. if (index === 2) {
  350. obj.attrs.rowSpan = 0
  351. }
  352. if (index === 3) {
  353. obj.attrs.rowSpan = 0
  354. }
  355. if (index === 4) {
  356. obj.attrs.rowSpan = 0
  357. }
  358. if (index === 5) {
  359. obj.attrs.rowSpan = 5
  360. }
  361. if (index === 6) {
  362. obj.attrs.rowSpan = 0
  363. }
  364. if (index === 7) {
  365. obj.attrs.rowSpan = 0
  366. }
  367. if (index === 8) {
  368. obj.attrs.rowSpan = 0
  369. }
  370. if (index === 9) {
  371. obj.attrs.rowSpan = 0
  372. }
  373. if (index === 10) {
  374. obj.attrs.rowSpan = 5
  375. }
  376. if (index === 11) {
  377. obj.attrs.rowSpan = 0
  378. }
  379. if (index === 12) {
  380. obj.attrs.rowSpan = 0
  381. }
  382. if (index === 13) {
  383. obj.attrs.rowSpan = 0
  384. }
  385. if (index === 14) {
  386. obj.attrs.rowSpan = 0
  387. }
  388. return obj
  389. }
  390. },
  391. {
  392. title: '费用占比(%)',
  393. dataIndex: '',
  394. width: 140,
  395. align: 'center',
  396. customRender: function (text) {
  397. return ((text || text == 0) ? text : '--')
  398. }
  399. },
  400. {
  401. title: '正常配送品费用',
  402. dataIndex: '',
  403. width: 120,
  404. align: 'right',
  405. customRender: function (text) {
  406. return ((text || text == 0) ? _this.toThousands(text) : '--')
  407. }
  408. },
  409. {
  410. title: '正常促销品费用',
  411. dataIndex: '',
  412. width: 120,
  413. align: 'right',
  414. customRender: function (text) {
  415. return ((text || text == 0) ? _this.toThousands(text) : '--')
  416. }
  417. },
  418. {
  419. title: '特殊申请配送品费用',
  420. dataIndex: '',
  421. width: 120,
  422. align: 'right',
  423. customRender: function (text) {
  424. return ((text || text == 0) ? _this.toThousands(text) : '--')
  425. }
  426. },
  427. {
  428. title: '特殊申请促销品费用',
  429. dataIndex: '',
  430. width: 120,
  431. align: 'right',
  432. customRender: function (text) {
  433. return ((text || text == 0) ? _this.toThousands(text) : '--')
  434. }
  435. }
  436. ]
  437. if (this.activeKey == 0) {
  438. arr.splice(1, 0, { title: '省份', dataIndex: 'province', width: 90, align: 'center', customRender: function (text) { return text || '--' } })
  439. }
  440. return arr
  441. }
  442. },
  443. methods: {
  444. callback (key) {
  445. this.activeKey = key
  446. console.log(key, this.activeKey)
  447. },
  448. onChange (date, dateString) {
  449. console.log(date, dateString)
  450. },
  451. openChange (status) {
  452. if (status) {
  453. this.open = true
  454. } else {
  455. this.open = false
  456. }
  457. },
  458. panelChange (value) {
  459. this.year = value
  460. this.open = false
  461. },
  462. // 禁止选择的年份
  463. disabledDate (currentDate) {
  464. console.log(currentDate)
  465. return currentDate && currentDate < moment().endOf('year')
  466. },
  467. // 分页
  468. // 查询省
  469. getProvinceData (leve, sn) {
  470. let params
  471. if (leve == 'province') {
  472. params = { type: '2' }
  473. } else {
  474. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  475. }
  476. getArea(params).then(res => {
  477. if (res.status == 200) {
  478. console.log(res, '=============地区')
  479. if (leve == 'province') {
  480. this.addrProvinceList = res.data || []
  481. } else if (leve == 'city') {
  482. this.addrCityList = res.data || []
  483. } else if (leve == 'district') {
  484. this.addrDistrictList = res.data || []
  485. }
  486. } else {
  487. if (leve == 'province') {
  488. this.addrProvinceList = []
  489. } else if (leve == 'city') {
  490. this.addrCityList = []
  491. } else if (leve == 'district') {
  492. this.addrDistrictList = []
  493. }
  494. }
  495. })
  496. },
  497. // 创建时间 change
  498. dateChange (date) {
  499. if (date[0] && date[1]) {
  500. this.queryParam.time = date
  501. } else {
  502. this.queryParam.time = []
  503. }
  504. this.queryParam.beginDate = date[0] || ''
  505. this.queryParam.endDate = date[1] || ''
  506. },
  507. // 查询
  508. handleSearch () {
  509. const _this = this
  510. this.$refs.ruleForm.validate(valid => {
  511. if (valid) {
  512. _this.$refs.table.refresh(true)
  513. } else {
  514. return false
  515. }
  516. })
  517. },
  518. // 重置
  519. resetSearchForm () {
  520. this.queryParam.time = []
  521. this.$refs.rangeDate.resetDate(this.queryParam.time)
  522. this.queryParam.beginDate = ''
  523. this.queryParam.endDate = ''
  524. this.queryParam.dealer = {
  525. 'dealerName': '',
  526. 'provinceSn': undefined,
  527. 'citySn': undefined,
  528. 'districtSn': undefined,
  529. 'subareaSn': undefined,
  530. 'dealerLevel': undefined
  531. }
  532. this.totalData = null
  533. this.$refs.ruleForm.resetFields()
  534. this.$refs.table.clearTable()
  535. },
  536. // 导出
  537. handleExport () {
  538. const _this = this
  539. this.$refs.ruleForm.validate(valid => {
  540. if (valid) {
  541. _this.showExport = true
  542. const params = _this.queryParam
  543. _this.$store.state.app.curActionPermission = 'B_returnGoodsPresentationExport'
  544. _this.exportLoading = true
  545. _this.spinning = true
  546. hdExportExcel(reportRebateExport, params, '全国各省品类实际销售明细报表', function () {
  547. _this.exportLoading = false
  548. _this.spinning = false
  549. _this.$store.state.app.curActionPermission = ''
  550. })
  551. } else {
  552. return false
  553. }
  554. })
  555. },
  556. pageInit () {
  557. this.activeKey = 0
  558. this.getProvinceData('province')
  559. }
  560. },
  561. mounted () {
  562. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  563. this.pageInit()
  564. // this.resetSearchForm()
  565. }
  566. },
  567. activated () {
  568. // 如果是新页签打开,则重置当前页面
  569. if (this.$store.state.app.isNewTab) {
  570. this.pageInit()
  571. // this.resetSearchForm()
  572. }
  573. },
  574. beforeRouteEnter (to, from, next) {
  575. next(vm => {})
  576. }
  577. }
  578. </script>
  579. <style style="less">
  580. .regionTypeSalesReportList-wrap{
  581. }
  582. </style>