list.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  1. <template>
  2. <a-card size="small" :bordered="false" class="salesAmountReportList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="salesAmountReportList-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="salesAmountReportList-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="salesAmountReportList-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="salesAmountReportList-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="salesAmountReportList-refresh">查询</a-button>
  72. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="salesAmountReportList-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_salesAmountReport_export')"
  81. id="returnSlipReportList-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. :defaultLoadData="false"
  96. :rowKey="(record) => record.id"
  97. :columns="columns"
  98. :data="loadData"
  99. :scroll="{ x: 2250 }"
  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">TBU-P:{{ (totalData && (totalData.tbupAmount || totalData.tbupAmount==0)) ? totalData.tbupAmount : '--' }}</a-col>
  119. <a-col span="4">布瑞斯:{{ (totalData && (totalData.brsAmount || totalData.brsAmount==0)) ? totalData.brsAmount : '--' }}</a-col>
  120. <a-col span="4">NGK:{{ (totalData && (totalData.ngkAmount || totalData.ngkAmount==0)) ? totalData.ngkAmount : '--' }}</a-col>
  121. <a-col span="4">飞利浦:{{ (totalData && (totalData.flpAmount || totalData.flpAmount==0)) ? totalData.flpAmount : '--' }}</a-col>
  122. <a-col span="4">车仆:{{ (totalData && (totalData.cpAmount || totalData.cpAmount==0)) ? totalData.cpAmount : '--' }}</a-col>
  123. <a-col span="4">瓦尔塔:{{ (totalData && (totalData.wetAmount || totalData.wetAmount==0)) ? totalData.wetAmount : '--' }}</a-col>
  124. <a-col span="4">雷贝斯托:{{ (totalData && (totalData.lbstAmount || totalData.lbstAmount==0)) ? totalData.lbstAmount : '--' }}</a-col>
  125. <a-col span="4">德尔福:{{ (totalData && (totalData.defAmount || totalData.defAmount==0)) ? totalData.defAmount : '--' }}</a-col>
  126. <a-col span="4">巴诺德:{{ (totalData && (totalData.bndAmount || totalData.bndAmount==0)) ? totalData.bndAmount : '--' }}</a-col>
  127. <a-col span="6" v-if="$hasPermissions('B_isShowPrice')">开单销售合计金额:{{ (totalData && (totalData.totalAmount || totalData.totalAmount==0)) ? totalData.totalAmount : '--' }}</a-col>
  128. </a-row>
  129. </a-col>
  130. </a-row>
  131. </template>
  132. </s-table>
  133. </a-spin>
  134. </a-card>
  135. </template>
  136. <script>
  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 { hdExportExcel } from '@/libs/exportExcel'
  144. import { salesBillReportGroupByBuyerList, salesBillReportCount } from '@/api/salesBillReport'
  145. import { salesAmountExport } from '@/api/reportData'
  146. export default {
  147. components: { STable, VSelect, rangeDate, subarea, custList },
  148. data () {
  149. return {
  150. spinning: false,
  151. advanced: true, // 高级搜索 展开/关闭
  152. tableHeight: 0,
  153. queryParam: { // 查询条件
  154. time: [
  155. getDate.getCurrMonthDays().starttime,
  156. getDate.getCurrMonthDays().endtime
  157. ],
  158. beginDate: getDate.getCurrMonthDays().starttime,
  159. endDate: getDate.getCurrMonthDays().endtime,
  160. dealer: {
  161. 'dealerSn': undefined,
  162. 'provinceSn': undefined,
  163. 'citySn': undefined,
  164. 'districtSn': undefined,
  165. 'subareaSn': undefined,
  166. 'dealerLevel': undefined
  167. }
  168. },
  169. rules: {
  170. 'time': [{ required: true, message: '请选择销售日期', trigger: 'change' }]
  171. },
  172. disabled: false, // 查询、重置按钮是否可操作
  173. exportLoading: false,
  174. // 加载数据方法 必须为 Promise 对象
  175. loadData: parameter => {
  176. this.disabled = true
  177. this.spinning = true
  178. if (this.tableHeight == 0) {
  179. this.tableHeight = window.innerHeight - 380
  180. }
  181. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  182. return salesBillReportGroupByBuyerList(paramsPage).then(res => {
  183. let data
  184. if (res.status == 200) {
  185. data = res.data
  186. this.getCount(paramsPage)
  187. const no = (data.pageNo - 1) * data.pageSize
  188. for (var i = 0; i < data.list.length; i++) {
  189. data.list[i].no = no + i + 1
  190. }
  191. this.disabled = false
  192. }
  193. this.spinning = false
  194. return data
  195. })
  196. },
  197. totalData: null,
  198. addrProvinceList: [], // 省下拉
  199. addrCityList: [], // 市下拉
  200. addrDistrictList: [] // 区下拉
  201. }
  202. },
  203. computed: {
  204. columns () {
  205. const arr = [
  206. { title: '区域', dataIndex: 'dealer.subareaNameSet', width: 120, align: 'center', customRender: function (text) { return (text && text.length > 0) ? text.join('/') : '--' } },
  207. { title: '省份', dataIndex: 'dealer.provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  208. { title: '客户名称', dataIndex: 'dealer.dealerName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  209. { title: '客户级别', dataIndex: 'dealer.dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  210. { title: '品牌',
  211. align: 'center',
  212. children: [
  213. {
  214. title: '箭牌',
  215. align: 'center',
  216. children: [
  217. {
  218. title: '滤清器',
  219. dataIndex: 'jpLqqAmount',
  220. align: 'center',
  221. width: 80,
  222. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  223. },
  224. {
  225. title: '雨刮片',
  226. dataIndex: 'jpYgpAmount',
  227. align: 'center',
  228. width: 80,
  229. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  230. },
  231. {
  232. title: '喇叭',
  233. dataIndex: 'jpLbAmount',
  234. align: 'center',
  235. width: 80,
  236. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  237. },
  238. {
  239. title: '刹车片',
  240. dataIndex: 'jpScpAmount',
  241. align: 'center',
  242. width: 80,
  243. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  244. },
  245. {
  246. title: '感应线',
  247. dataIndex: 'jpGyxAmount',
  248. align: 'center',
  249. width: 80,
  250. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  251. }
  252. ]
  253. },
  254. {
  255. title: '冠牌',
  256. align: 'center',
  257. children: [
  258. {
  259. title: '滤清器',
  260. dataIndex: 'gpLqqAmount',
  261. align: 'center',
  262. width: 80,
  263. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  264. },
  265. {
  266. title: '雨刮片',
  267. dataIndex: 'gpYgpAmount',
  268. align: 'center',
  269. width: 80,
  270. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  271. },
  272. {
  273. title: '刹车片',
  274. dataIndex: 'gpScpAmount',
  275. align: 'center',
  276. width: 80,
  277. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  278. }
  279. ]
  280. },
  281. {
  282. title: '汇箭',
  283. dataIndex: 'hjAmount',
  284. align: 'center',
  285. width: 80,
  286. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  287. },
  288. {
  289. title: '德路斯',
  290. dataIndex: 'dlsAmount',
  291. align: 'center',
  292. width: 80,
  293. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  294. },
  295. {
  296. title: '稳升',
  297. dataIndex: 'wsAmount',
  298. align: 'center',
  299. width: 80,
  300. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  301. },
  302. {
  303. title: 'TBU',
  304. dataIndex: 'tbuAmount',
  305. align: 'center',
  306. width: 80,
  307. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  308. },
  309. {
  310. title: 'TBU-P',
  311. dataIndex: 'tbupAmount',
  312. align: 'center',
  313. width: 80,
  314. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  315. },
  316. {
  317. title: '布瑞斯',
  318. dataIndex: 'brsAmount',
  319. align: 'center',
  320. width: 80,
  321. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  322. }
  323. ]
  324. },
  325. { title: '代理品牌',
  326. align: 'center',
  327. children: [
  328. {
  329. title: 'NGK',
  330. dataIndex: 'ngkAmount',
  331. align: 'center',
  332. width: 80,
  333. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  334. },
  335. {
  336. title: '飞利浦',
  337. dataIndex: 'flpAmount',
  338. align: 'center',
  339. width: 80,
  340. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  341. },
  342. {
  343. title: '车仆',
  344. dataIndex: 'cpAmount',
  345. align: 'center',
  346. width: 80,
  347. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  348. },
  349. {
  350. title: '瓦尔塔',
  351. dataIndex: 'wetAmount',
  352. align: 'center',
  353. width: 80,
  354. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  355. },
  356. {
  357. title: '雷贝斯托',
  358. dataIndex: 'lbstAmount',
  359. align: 'center',
  360. width: 80,
  361. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  362. },
  363. {
  364. title: '德尔福',
  365. dataIndex: 'defAmount',
  366. align: 'center',
  367. width: 80,
  368. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  369. },
  370. {
  371. title: '巴诺德',
  372. dataIndex: 'bndAmount',
  373. align: 'center',
  374. width: 80,
  375. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  376. }
  377. ]
  378. }
  379. // { title: '开单销售合计金额', width: 90, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' } }
  380. ]
  381. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  382. arr.splice(arr.length, 0, { title: '开单销售合计金额', width: 90, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' } })
  383. }
  384. return arr
  385. }
  386. },
  387. methods: {
  388. // 导出
  389. handleExport () {
  390. const _this = this
  391. this.$refs.ruleForm.validate(valid => {
  392. if (valid) {
  393. const params = _this.queryParam
  394. _this.exportLoading = true
  395. _this.spinning = true
  396. hdExportExcel(salesAmountExport, params, '开单销售报表', function () {
  397. _this.exportLoading = false
  398. _this.spinning = false
  399. })
  400. } else {
  401. return false
  402. }
  403. })
  404. },
  405. // 总计
  406. getCount (params) {
  407. salesBillReportCount(params).then(res => {
  408. if (res.status == 200 && res.data) {
  409. this.totalData = res.data
  410. } else {
  411. this.totalData = null
  412. }
  413. })
  414. },
  415. handleSearch () {
  416. const _this = this
  417. this.$refs.ruleForm.validate(valid => {
  418. if (valid) {
  419. _this.$refs.table.refresh(true)
  420. } else {
  421. return false
  422. }
  423. })
  424. },
  425. // 创建时间 change
  426. dateChange (date) {
  427. if (date[0] && date[1]) {
  428. this.queryParam.time = date
  429. } else {
  430. this.queryParam.time = []
  431. }
  432. this.queryParam.beginDate = date[0] || ''
  433. this.queryParam.endDate = date[1] || ''
  434. },
  435. custChange (val) {
  436. this.queryParam.dealer.dealerSn = val.key
  437. },
  438. // 重置
  439. resetSearchForm () {
  440. this.queryParam.time = [
  441. getDate.getCurrMonthDays().starttime,
  442. getDate.getCurrMonthDays().endtime
  443. ]
  444. this.$refs.rangeDate.resetDate(this.queryParam.time)
  445. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  446. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  447. this.queryParam.dealer = {
  448. 'dealerSn': undefined,
  449. 'provinceSn': undefined,
  450. 'citySn': undefined,
  451. 'districtSn': undefined,
  452. 'subareaSn': undefined,
  453. 'dealerLevel': undefined
  454. }
  455. this.totalData = null
  456. this.$refs.custList.resetForm()
  457. this.$refs.ruleForm.resetFields()
  458. this.$refs.table.clearTable()
  459. },
  460. // 获取城市列表
  461. getCityList (val) {
  462. this.addrCityList = []
  463. this.addrDistrictList = []
  464. this.queryParam.dealerCitySn = undefined
  465. this.queryParam.dealerCountySn = undefined
  466. if (val) {
  467. this.getArea('city', val)
  468. }
  469. },
  470. // 获取区县列表
  471. getAreaList (val) {
  472. this.addrDistrictList = []
  473. this.queryParam.dealerCountySn = undefined
  474. if (val) {
  475. this.getArea('district', val)
  476. }
  477. },
  478. // 省/市/区
  479. getArea (leve, sn) {
  480. let params
  481. if (leve == 'province') {
  482. params = { type: '2' }
  483. } else {
  484. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  485. }
  486. getArea(params).then(res => {
  487. if (res.status == 200) {
  488. if (leve == 'province') {
  489. this.addrProvinceList = res.data || []
  490. } else if (leve == 'city') {
  491. this.addrCityList = res.data || []
  492. } else if (leve == 'district') {
  493. this.addrDistrictList = res.data || []
  494. }
  495. } else {
  496. if (leve == 'province') {
  497. this.addrProvinceList = []
  498. } else if (leve == 'city') {
  499. this.addrCityList = []
  500. } else if (leve == 'district') {
  501. this.addrDistrictList = []
  502. }
  503. }
  504. })
  505. },
  506. pageInit () {
  507. this.getArea('province')
  508. }
  509. },
  510. mounted () {
  511. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  512. this.pageInit()
  513. this.resetSearchForm()
  514. }
  515. },
  516. activated () {
  517. // 如果是新页签打开,则重置当前页面
  518. if (this.$store.state.app.isNewTab) {
  519. this.pageInit()
  520. this.resetSearchForm()
  521. }
  522. },
  523. beforeRouteEnter (to, from, next) {
  524. next(vm => {})
  525. }
  526. }
  527. </script>