list.vue 22 KB

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