list.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <a-card size="small" :bordered="false" class="actualSalesReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="actualSalesReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. @keyup.enter.native="handleSearch">
  14. <a-row :gutter="15">
  15. <a-col :md="6" :sm="24">
  16. <a-form-model-item label="销售日期" prop="time">
  17. <rangeDate ref="rangeDate" :value="queryParam.time" @change="dateChange" />
  18. </a-form-model-item>
  19. </a-col>
  20. <a-col :md="6" :sm="24">
  21. <a-form-model-item label="客户名称">
  22. <custList id="actualSalesReportList-allocateTypeSn" ref="custList" @change="custChange"></custList>
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="客户级别">
  27. <v-select
  28. v-model="queryParam.dealer.dealerLevel"
  29. ref="dealerLevel"
  30. id="actualSalesReportList-allocateTypeSn"
  31. code="DEALER_LEVEL"
  32. placeholder="请选择客户级别"
  33. allowClear></v-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <template v-if="advanced">
  37. <a-col :md="6" :sm="24">
  38. <a-form-model-item label="所在区域">
  39. <subarea id="actualSalesReportList-allocateTypeSn" v-model="queryParam.dealer.subareaSn"></subarea>
  40. </a-form-model-item>
  41. </a-col>
  42. <a-col :md="12" :sm="24">
  43. <a-row>
  44. <a-form-model-item label="地区" style="margin-bottom: 0!important;">
  45. <a-col span="7">
  46. <a-form-model-item prop="dealerProvinceSn" style="margin: 0;">
  47. <a-select v-model="queryParam.dealer.provinceSn" allowClear @change="getCityList" placeholder="请选择省">
  48. <a-select-option v-for="item in addrProvinceList" :value="item.id" :key="item.id + 'a'">{{ item.name }}</a-select-option>
  49. </a-select>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col span="7" offset="1">
  53. <a-form-model-item prop="dealerCitySn" style="margin: 0;">
  54. <a-select v-model="queryParam.dealer.citySn" allowClear @change="getAreaList" placeholder="请选择市">
  55. <a-select-option v-for="item in addrCityList" :value="item.id" :key="item.id + 'b'">{{ item.name }}</a-select-option>
  56. </a-select>
  57. </a-form-model-item>
  58. </a-col>
  59. <a-col span="7" offset="1">
  60. <a-form-model-item prop="dealerCountySn" style="margin: 0;">
  61. <a-select v-model="queryParam.dealer.districtSn" allowClear placeholder="请选择区/县">
  62. <a-select-option v-for="item in addrDistrictList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
  63. </a-select>
  64. </a-form-model-item>
  65. </a-col>
  66. </a-form-model-item>
  67. </a-row>
  68. </a-col>
  69. </template>
  70. <a-col :md="6" :sm="24">
  71. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="actualSalesReportList-refresh">查询</a-button>
  72. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="actualSalesReportList-reset">重置</a-button>
  73. <a-button
  74. style="margin-left: 10px"
  75. type="primary"
  76. class="button-warning"
  77. @click="handleExport"
  78. :disabled="disabled"
  79. :loading="exportLoading"
  80. v-if="$hasPermissions('B_actualSalesReport_export')"
  81. id="actualSalesReportList-export">导出</a-button>
  82. <a @click="advanced=!advanced" style="margin-left: 8px">
  83. {{ advanced ? '收起' : '展开' }}
  84. <a-icon :type="advanced ? 'up' : 'down'"/>
  85. </a>
  86. </a-col>
  87. </a-row>
  88. </a-form-model>
  89. </div>
  90. <!-- 列表 -->
  91. <s-table
  92. class="sTable"
  93. ref="table"
  94. size="small"
  95. :rowKey="(record) => record.id"
  96. :columns="columns"
  97. :data="loadData"
  98. :scroll="{ x: 3220 }"
  99. :defaultLoadData="false"
  100. bordered>
  101. <template slot="footer">
  102. <a-row>
  103. <a-col span="2">合计:</a-col>
  104. <a-col span="22">
  105. <a-row>
  106. <a-col span="4">箭牌滤清器:{{ (totalData && (totalData.jpLqqAmount || totalData.jpLqqAmount==0)) ? totalData.jpLqqAmount : '--' }}</a-col>
  107. <a-col span="4">箭牌雨刮片:{{ (totalData && (totalData.jpYgpAmount || totalData.jpYgpAmount==0)) ? totalData.jpYgpAmount : '--' }}</a-col>
  108. <a-col span="4">箭牌喇叭:{{ (totalData && (totalData.jpLbAmount || totalData.jpLbAmount==0)) ? totalData.jpLbAmount : '--' }}</a-col>
  109. <a-col span="4">箭牌刹车片:{{ (totalData && (totalData.jpScpAmount || totalData.jpScpAmount==0)) ? totalData.jpScpAmount : '--' }}</a-col>
  110. <a-col span="4">箭牌感应线:{{ (totalData && (totalData.jpGyxAmount || totalData.jpGyxAmount==0)) ? totalData.jpGyxAmount : '--' }}</a-col>
  111. <a-col span="4">冠牌滤清器:{{ (totalData && (totalData.gpLqqAmount || totalData.gpLqqAmount==0)) ? totalData.gpLqqAmount : '--' }}</a-col>
  112. <a-col span="4">冠牌雨刮片:{{ (totalData && (totalData.gpYgpAmount || totalData.gpYgpAmount==0)) ? totalData.gpYgpAmount : '--' }}</a-col>
  113. <a-col span="4">冠牌刹车片:{{ (totalData && (totalData.gpScpAmount || totalData.gpScpAmount==0)) ? totalData.gpScpAmount : '--' }}</a-col>
  114. <a-col span="4">汇箭:{{ (totalData && (totalData.hjAmount || totalData.hjAmount==0)) ? totalData.hjAmount : '--' }}</a-col>
  115. <a-col span="4">德路斯:{{ (totalData && (totalData.dlsAmount || totalData.dlsAmount==0)) ? totalData.dlsAmount : '--' }}</a-col>
  116. <a-col span="4">稳升:{{ (totalData && (totalData.wsAmount || totalData.wsAmount==0)) ? totalData.wsAmount : '--' }}</a-col>
  117. <a-col span="4">TBU:{{ (totalData && (totalData.tbuAmount || totalData.tbuAmount==0)) ? totalData.tbuAmount : '--' }}</a-col>
  118. <a-col span="4">布瑞斯:{{ (totalData && (totalData.brsAmount || totalData.brsAmount==0)) ? totalData.brsAmount : '--' }}</a-col>
  119. <a-col span="4">NGK:{{ (totalData && (totalData.ngkAmount || totalData.ngkAmount==0)) ? totalData.ngkAmount : '--' }}</a-col>
  120. <a-col span="4">飞利浦:{{ (totalData && (totalData.flpAmount || totalData.flpAmount==0)) ? totalData.flpAmount : '--' }}</a-col>
  121. <a-col span="4">车仆:{{ (totalData && (totalData.cpAmount || totalData.cpAmount==0)) ? totalData.cpAmount : '--' }}</a-col>
  122. <a-col span="4">瓦尔塔:{{ (totalData && (totalData.wetAmount || totalData.wetAmount==0)) ? totalData.wetAmount : '--' }}</a-col>
  123. <a-col span="4">雷贝斯托:{{ (totalData && (totalData.lbstAmount || totalData.lbstAmount==0)) ? totalData.lbstAmount : '--' }}</a-col>
  124. <a-col span="4">德尔福:{{ (totalData && (totalData.defAmount || totalData.defAmount==0)) ? totalData.defAmount : '--' }}</a-col>
  125. <a-col span="4">巴诺德:{{ (totalData && (totalData.bndAmount || totalData.bndAmount==0)) ? totalData.bndAmount : '--' }}</a-col>
  126. <a-col span="6">实售销售合计金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? totalData.totalAmount : '--' }}</a-col>
  127. </a-row>
  128. </a-col>
  129. </a-row>
  130. </template>
  131. </s-table>
  132. </a-spin>
  133. </a-card>
  134. </template>
  135. <script>
  136. import moment from 'moment'
  137. import getDate from '@/libs/getDate.js'
  138. import { STable, VSelect } from '@/components'
  139. import rangeDate from '@/views/common/rangeDate.vue'
  140. import custList from '@/views/common/custList.vue'
  141. import subarea from '@/views/common/subarea.js'
  142. import { getArea } from '@/api/data'
  143. import { salesBillRealAmountQueryPageList, salesBillRealReportCount } from '@/api/salesBillReport'
  144. import {actualSalesExport} from '@/api/reportData'
  145. export default {
  146. components: { STable, VSelect, rangeDate, subarea, custList },
  147. data () {
  148. return {
  149. spinning: false,
  150. advanced: true, // 高级搜索 展开/关闭
  151. tableHeight: 0,
  152. queryParam: { // 查询条件
  153. time: [
  154. getDate.getCurrMonthDays().starttime,
  155. getDate.getCurrMonthDays().endtime
  156. ],
  157. beginDate: getDate.getCurrMonthDays().starttime,
  158. endDate: getDate.getCurrMonthDays().endtime,
  159. dealer: {
  160. 'dealerSn': undefined,
  161. 'provinceSn': undefined,
  162. 'citySn': undefined,
  163. 'districtSn': undefined,
  164. 'subareaSn': undefined,
  165. 'dealerLevel': undefined
  166. }
  167. },
  168. rules: {
  169. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  170. },
  171. disabled: false, // 查询、重置按钮是否可操作
  172. exportLoading: false,
  173. columns: [
  174. { title: '序号', dataIndex: 'no', width: 80, align: 'center', fixed: 'left' },
  175. { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 220, align: 'center', customRender: function (text) { return (text && text.length > 0) ? text.join('/') : '--' } },
  176. { title: '省份', dataIndex: 'dealer.provinceName', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  177. { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  178. { title: '客户级别', dataIndex: 'dealer.dealerLevelDictValue', width: 200, align: 'center', customRender: function (text) { return text || '--' } },
  179. { title: '品牌',
  180. align: 'center',
  181. children: [
  182. {
  183. title: '箭牌',
  184. align: 'center',
  185. children: [
  186. {
  187. title: '滤清器',
  188. dataIndex: 'jpLqqAmount',
  189. align: 'center',
  190. width: 100,
  191. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  192. },
  193. {
  194. title: '雨刮片',
  195. dataIndex: 'jpYgpAmount',
  196. align: 'center',
  197. width: 100,
  198. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  199. },
  200. {
  201. title: '喇叭',
  202. dataIndex: 'jpLbAmount',
  203. align: 'center',
  204. width: 100,
  205. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  206. },
  207. {
  208. title: '刹车片',
  209. dataIndex: 'jpScpAmount',
  210. align: 'center',
  211. width: 100,
  212. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  213. },
  214. {
  215. title: '感应线',
  216. dataIndex: 'jpGyxAmount',
  217. align: 'center',
  218. width: 100,
  219. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  220. }
  221. ]
  222. },
  223. {
  224. title: '冠牌',
  225. align: 'center',
  226. children: [
  227. {
  228. title: '滤清器',
  229. dataIndex: 'gpLqqAmount',
  230. align: 'center',
  231. width: 100,
  232. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  233. },
  234. {
  235. title: '雨刮片',
  236. dataIndex: 'gpYgpAmount',
  237. align: 'center',
  238. width: 100,
  239. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  240. },
  241. {
  242. title: '刹车片',
  243. dataIndex: 'gpScpAmount',
  244. align: 'center',
  245. width: 100,
  246. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  247. }
  248. ]
  249. },
  250. {
  251. title: '汇箭',
  252. dataIndex: 'hjAmount',
  253. align: 'center',
  254. width: 100,
  255. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  256. },
  257. {
  258. title: '德路斯',
  259. dataIndex: 'dlsAmount',
  260. align: 'center',
  261. width: 100,
  262. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  263. },
  264. {
  265. title: '稳升',
  266. dataIndex: 'wsAmount',
  267. align: 'center',
  268. width: 100,
  269. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  270. },
  271. {
  272. title: 'TBU',
  273. dataIndex: 'tbuAmount',
  274. align: 'center',
  275. width: 100,
  276. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  277. },
  278. {
  279. title: '布瑞斯',
  280. dataIndex: 'brsAmount',
  281. align: 'center',
  282. width: 100,
  283. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  284. }
  285. ] },
  286. { title: '代理品牌',
  287. align: 'center',
  288. children: [
  289. {
  290. title: 'NGK',
  291. dataIndex: 'ngkAmount',
  292. align: 'center',
  293. width: 100,
  294. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  295. },
  296. {
  297. title: '飞利浦',
  298. dataIndex: 'flpAmount',
  299. align: 'center',
  300. width: 100,
  301. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  302. },
  303. {
  304. title: '车仆',
  305. dataIndex: 'cpAmount',
  306. align: 'center',
  307. width: 100,
  308. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  309. },
  310. {
  311. title: '瓦尔塔',
  312. dataIndex: 'wetAmount',
  313. align: 'center',
  314. width: 100,
  315. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  316. },
  317. {
  318. title: '雷贝斯托',
  319. dataIndex: 'lbstAmount',
  320. align: 'center',
  321. width: 100,
  322. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  323. },
  324. {
  325. title: '德尔福',
  326. dataIndex: 'defAmount',
  327. align: 'center',
  328. width: 100,
  329. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  330. },
  331. {
  332. title: '巴诺德',
  333. dataIndex: 'bndAmount',
  334. align: 'center',
  335. width: 100,
  336. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  337. }
  338. ] },
  339. { title: '实售销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' } }
  340. ],
  341. // 加载数据方法 必须为 Promise 对象
  342. loadData: parameter => {
  343. this.disabled = true
  344. this.spinning = true
  345. if (this.tableHeight == 0) {
  346. this.tableHeight = window.innerHeight - 380
  347. }
  348. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  349. return salesBillRealAmountQueryPageList(paramsPage).then(res => {
  350. this.getCount(paramsPage)
  351. const data = res.data
  352. const no = (data.pageNo - 1) * data.pageSize
  353. for (var i = 0; i < data.list.length; i++) {
  354. data.list[i].no = no + i + 1
  355. }
  356. this.disabled = false
  357. this.spinning = false
  358. return data
  359. })
  360. },
  361. totalData: null,
  362. addrProvinceList: [], // 省下拉
  363. addrCityList: [], // 市下拉
  364. addrDistrictList: [] // 区下拉
  365. }
  366. },
  367. methods: {
  368. // 导出
  369. handleExport () {
  370. const _this = this
  371. const params = this.queryParam
  372. this.exportLoading = true
  373. _this.spinning = true
  374. actualSalesExport(params).then(res => {
  375. this.exportLoading = false
  376. _this.spinning = false
  377. if (res.type == 'application/json') {
  378. var reader = new FileReader()
  379. reader.addEventListener('loadend', function () {
  380. const obj = JSON.parse(reader.result)
  381. _this.$notification.error({
  382. message: '提示',
  383. description: obj.message
  384. })
  385. })
  386. reader.readAsText(res)
  387. } else {
  388. this.download(res)
  389. }
  390. })
  391. },
  392. download (data) {
  393. if (!data) { return }
  394. const url = window.URL.createObjectURL(new Blob([data]))
  395. const link = document.createElement('a')
  396. link.style.display = 'none'
  397. link.href = url
  398. const a = moment().format('YYYYMMDDHHmmss')
  399. const fname = '实售销售报表' + a
  400. link.setAttribute('download', fname + '.xlsx')
  401. document.body.appendChild(link)
  402. link.click()
  403. },
  404. // 总计
  405. getCount (params) {
  406. salesBillRealReportCount(params).then(res => {
  407. if (res.status == 200 && res.data) {
  408. this.totalData = res.data
  409. } else {
  410. this.totalData = null
  411. }
  412. })
  413. },
  414. handleSearch () {
  415. const _this = this
  416. this.$refs.ruleForm.validate(valid => {
  417. if (valid) {
  418. _this.$refs.table.refresh(true)
  419. } else {
  420. return false
  421. }
  422. })
  423. },
  424. // 创建时间 change
  425. dateChange (date) {
  426. this.queryParam.time = date
  427. this.queryParam.beginDate = date[0] || ''
  428. this.queryParam.endDate = date[1] || ''
  429. },
  430. custChange (val) {
  431. this.queryParam.dealer.dealerSn = val.key
  432. },
  433. // 重置
  434. resetSearchForm () {
  435. this.queryParam.time = [
  436. getDate.getCurrMonthDays().starttime,
  437. getDate.getCurrMonthDays().endtime
  438. ]
  439. this.$refs.rangeDate.resetDate(this.queryParam.time)
  440. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  441. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  442. this.queryParam.dealer = {
  443. 'dealerSn': undefined,
  444. 'provinceSn': undefined,
  445. 'citySn': undefined,
  446. 'districtSn': undefined,
  447. 'subareaSn': undefined,
  448. 'dealerLevel': undefined
  449. }
  450. this.totalData = null
  451. this.$refs.custList.resetForm()
  452. this.$refs.ruleForm.resetFields()
  453. this.$refs.table.clearTable()
  454. },
  455. // 获取城市列表
  456. getCityList (val) {
  457. this.addrCityList = []
  458. this.addrDistrictList = []
  459. this.queryParam.dealerCitySn = undefined
  460. this.queryParam.dealerCountySn = undefined
  461. if (val) {
  462. this.getArea('city', val)
  463. }
  464. },
  465. // 获取区县列表
  466. getAreaList (val) {
  467. this.addrDistrictList = []
  468. this.queryParam.dealerCountySn = undefined
  469. if (val) {
  470. this.getArea('district', val)
  471. }
  472. },
  473. // 省/市/区
  474. getArea (leve, sn) {
  475. let params
  476. if (leve == 'province') {
  477. params = { type: '2' }
  478. } else {
  479. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  480. }
  481. getArea(params).then(res => {
  482. if (res.status == 200) {
  483. if (leve == 'province') {
  484. this.addrProvinceList = res.data || []
  485. } else if (leve == 'city') {
  486. this.addrCityList = res.data || []
  487. } else if (leve == 'district') {
  488. this.addrDistrictList = res.data || []
  489. }
  490. } else {
  491. if (leve == 'province') {
  492. this.addrProvinceList = []
  493. } else if (leve == 'city') {
  494. this.addrCityList = []
  495. } else if (leve == 'district') {
  496. this.addrDistrictList = []
  497. }
  498. }
  499. })
  500. }
  501. },
  502. mounted () {
  503. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  504. this.getArea('province')
  505. this.resetSearchForm()
  506. }
  507. },
  508. activated () {
  509. // 如果是新页签打开,则重置当前页面
  510. if (this.$store.state.app.isNewTab) {
  511. this.getArea('province')
  512. this.resetSearchForm()
  513. }
  514. },
  515. beforeRouteEnter (to, from, next) {
  516. next(vm => {})
  517. }
  518. }
  519. </script>