list.vue 22 KB

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