list.vue 19 KB

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