list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <a-card size="small" :bordered="false" class="shortageStatisticsCList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="销售日期">
  9. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="客户名称">
  14. <custList ref="custList" id="shortageStatisticsCList-buyerSn" @change="custChange"></custList>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="客户类型">
  19. <custList ref="custList" id="shortageStatisticsCList-buyerSn" @change="custChange"></custList>
  20. </a-form-item>
  21. </a-col>
  22. </a-row>
  23. <a-row :gutter="15">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="所在区域">
  26. <subarea id="shortageStatisticsCList-subarea" v-model="queryParam.subareaSn"></subarea>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="12" :sm="24">
  30. <a-row :gutter="15">
  31. <!-- 地址 -->
  32. <a-col span="8">
  33. <a-form-item prop="provinceSn">
  34. <a-select id="supplierInfoEdit-provinceSn" @change="getCityList" v-model="queryParam.provinceSn" placeholder="请选择省">
  35. <a-select-option v-for="item in addrProvinceList" :value="item.areaSn" :key="item.areaSn + 'a'">{{ item.name }}</a-select-option>
  36. </a-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col span="8">
  40. <a-form-item prop="citySn">
  41. <a-select id="supplierInfoEdit-citySn" @change="getAreaList" v-model="queryParam.citySn" placeholder="请选择市">
  42. <a-select-option v-for="item in addrCityList" :value="item.areaSn" :key="item.areaSn + 'b'">{{ item.name }}</a-select-option>
  43. </a-select>
  44. </a-form-item>
  45. </a-col>
  46. <a-col span="8">
  47. <a-form-item prop="districtSn">
  48. <a-select id="supplierInfoEdit-districtSn" @change="areaCharged" v-model="queryParam.districtSn" placeholder="请选择区/县">
  49. <a-select-option v-for="item in addrDistrictList" :value="item.areaSn" :key="item.areaSn + 'c'">{{ item.name }}</a-select-option>
  50. </a-select>
  51. </a-form-item>
  52. </a-col>
  53. </a-row>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="shortageStatisticsCList-refresh">查询</a-button>
  57. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="shortageStatisticsCList-reset">重置</a-button>
  58. </a-col>
  59. </a-row>
  60. </a-form>
  61. </div>
  62. <!-- 列表 -->
  63. <s-table
  64. class="sTable"
  65. ref="table"
  66. size="small"
  67. :rowKey="(record) => record.id"
  68. :columns="columns"
  69. :data="loadData"
  70. :scroll="{ x: 2880, y: tableHeight }"
  71. bordered>
  72. </s-table>
  73. </a-card>
  74. </template>
  75. <script>
  76. import moment from 'moment'
  77. import getDate from '@/libs/getDate.js'
  78. import { STable, VSelect } from '@/components'
  79. import rangeDate from '@/views/common/rangeDate.vue'
  80. import custList from '@/views/common/custList.vue'
  81. import subarea from '@/views/common/subarea.js'
  82. import { getArea } from '@/api/data'
  83. import { oosBuyerList, oosBuyerDetailCount, oosBuyerDetailPageCount, oosDetailExport } from '@/api/oos'
  84. export default {
  85. components: { STable, VSelect, custList, subarea, rangeDate },
  86. data () {
  87. return {
  88. advanced: false, // 高级搜索 展开/关闭
  89. tableHeight: 0,
  90. queryParam: { // 查询条件
  91. beginDate: '',
  92. endDate: '',
  93. buyerSn: undefined,
  94. subareaSn: undefined, // 区域
  95. provinceSn: undefined,
  96. citySn: undefined,
  97. districtSn: undefined
  98. },
  99. disabled: false, // 查询、重置按钮是否可操作
  100. exportLoading: false, // 导出loading
  101. addrProvinceList: [], // 省下拉
  102. addrCityList: [], // 市下拉
  103. addrDistrictList: [], // 区下拉
  104. time: [], // 创建时间
  105. columns: [
  106. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  107. { title: '区域',
  108. dataIndex: 'area',
  109. width: 150,
  110. align: 'center',
  111. customRender: (text, row, index) => {
  112. if (text == '合计') {
  113. return {
  114. children: <span>{ text }</span>,
  115. attrs: {
  116. colSpan: 4
  117. }
  118. }
  119. }
  120. return text
  121. }
  122. },
  123. { title: '省份',
  124. dataIndex: 'provinceName',
  125. width: 150,
  126. align: 'center',
  127. customRender: function (text, row, index) {
  128. if (text == '合计') {
  129. return {
  130. children: <span>{ text }</span>,
  131. attrs: {
  132. colSpan: 0
  133. }
  134. }
  135. }
  136. return text || '--'
  137. } },
  138. { title: '客户名称',
  139. dataIndex: 'custName',
  140. width: 200,
  141. align: 'center',
  142. customRender: function (text, row, index) {
  143. if (text == '合计') {
  144. return {
  145. children: <span>{ text }</span>,
  146. attrs: {
  147. colSpan: 0
  148. }
  149. }
  150. }
  151. return text || '--'
  152. } },
  153. { title: '客户类型',
  154. dataIndex: 'custType',
  155. width: 200,
  156. align: 'center',
  157. customRender: function (text, row, index) {
  158. if (text == '合计') {
  159. return {
  160. children: <span>{ text }</span>,
  161. attrs: {
  162. colSpan: 0
  163. }
  164. }
  165. }
  166. return text || '--'
  167. } },
  168. { title: '品牌',
  169. align: 'center',
  170. children: [
  171. {
  172. title: '箭牌',
  173. align: 'center',
  174. children: [
  175. {
  176. title: '滤清器',
  177. dataIndex: 'pp1',
  178. align: 'center',
  179. width: 100,
  180. customRender: function (text) { return text ? ('¥' + text) : '--' }
  181. },
  182. {
  183. title: '雨刮片',
  184. dataIndex: 'pp2',
  185. align: 'center',
  186. width: 100,
  187. customRender: function (text) { return text ? ('¥' + text) : '--' }
  188. },
  189. {
  190. title: '喇叭',
  191. dataIndex: 'pp3',
  192. align: 'center',
  193. width: 100,
  194. customRender: function (text) { return text ? ('¥' + text) : '--' }
  195. },
  196. {
  197. title: '刹车片',
  198. dataIndex: 'pp4',
  199. align: 'center',
  200. width: 100,
  201. customRender: function (text) { return text ? ('¥' + text) : '--' }
  202. },
  203. {
  204. title: '感应线',
  205. dataIndex: 'pp5',
  206. align: 'center',
  207. width: 100,
  208. customRender: function (text) { return text ? ('¥' + text) : '--' }
  209. }
  210. ]
  211. },
  212. {
  213. title: '冠牌',
  214. align: 'center',
  215. children: [
  216. {
  217. title: '滤清器',
  218. dataIndex: 'pp6',
  219. align: 'center',
  220. width: 100,
  221. customRender: function (text) { return text ? ('¥' + text) : '--' }
  222. },
  223. {
  224. title: '雨刮片',
  225. dataIndex: 'pp7',
  226. align: 'center',
  227. width: 100,
  228. customRender: function (text) { return text ? ('¥' + text) : '--' }
  229. },
  230. {
  231. title: '刹车片',
  232. dataIndex: 'pp8',
  233. align: 'center',
  234. width: 100,
  235. customRender: function (text) { return text ? ('¥' + text) : '--' }
  236. }
  237. ]
  238. },
  239. {
  240. title: '汇箭',
  241. dataIndex: 'pp9',
  242. align: 'center',
  243. width: 100,
  244. customRender: function (text) { return text ? ('¥' + text) : '--' }
  245. },
  246. {
  247. title: '德路斯',
  248. dataIndex: 'pp10',
  249. align: 'center',
  250. width: 100,
  251. customRender: function (text) { return text ? ('¥' + text) : '--' }
  252. },
  253. {
  254. title: '稳升',
  255. dataIndex: 'pp11',
  256. align: 'center',
  257. width: 100,
  258. customRender: function (text) { return text ? ('¥' + text) : '--' }
  259. },
  260. {
  261. title: 'TBU',
  262. dataIndex: 'pp12',
  263. align: 'center',
  264. width: 100,
  265. customRender: function (text) { return text ? ('¥' + text) : '--' }
  266. }
  267. ] },
  268. { title: '代理品牌',
  269. align: 'center',
  270. children: [
  271. {
  272. title: 'NGK',
  273. dataIndex: 'pp13',
  274. align: 'center',
  275. width: 100,
  276. customRender: function (text) { return text ? ('¥' + text) : '--' }
  277. },
  278. {
  279. title: '飞利浦',
  280. dataIndex: 'pp14',
  281. align: 'center',
  282. width: 100,
  283. customRender: function (text) { return text ? ('¥' + text) : '--' }
  284. },
  285. {
  286. title: '车仆',
  287. dataIndex: 'pp15',
  288. align: 'center',
  289. width: 100,
  290. customRender: function (text) { return text ? ('¥' + text) : '--' }
  291. },
  292. {
  293. title: '瓦尔塔',
  294. dataIndex: 'pp16',
  295. align: 'center',
  296. width: 100,
  297. customRender: function (text) { return text ? ('¥' + text) : '--' }
  298. },
  299. {
  300. title: '雷贝斯托',
  301. dataIndex: 'pp17',
  302. align: 'center',
  303. width: 100,
  304. customRender: function (text) { return text ? ('¥' + text) : '--' }
  305. },
  306. {
  307. title: '德尔福',
  308. dataIndex: 'pp18',
  309. align: 'center',
  310. width: 100,
  311. customRender: function (text) { return text ? ('¥' + text) : '--' }
  312. },
  313. {
  314. title: '巴诺德',
  315. dataIndex: 'pp19',
  316. align: 'center',
  317. width: 100,
  318. customRender: function (text) { return text ? ('¥' + text) : '--' }
  319. }
  320. ] },
  321. { title: '实际销售合计金额', width: 200, dataIndex: 'totalAmount', align: 'center', customRender: function (text) { return text ? ('¥' + text) : '--' } }
  322. ],
  323. // 加载数据方法 必须为 Promise 对象
  324. loadData: parameter => {
  325. // this.disabled = true
  326. // if (this.tableHeight == 0) {
  327. // this.tableHeight = window.innerHeight - 380
  328. // }
  329. // const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  330. // const params = Object.assign(parameter, this.queryParam) // 无分页
  331. // return oosBuyerList(params).then(res => {
  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. // return data
  339. // })
  340. const _this = this
  341. return new Promise(function (resolve, reject) {
  342. const data = {
  343. pageNo: 1,
  344. pageSize: 10,
  345. list: [{
  346. area: 'A区',
  347. provinceName: '广东省',
  348. custName: '支持省级',
  349. custType: '省级服务中心',
  350. pp1: '125.02',
  351. pp2: '73.00',
  352. pp3: '0',
  353. pp4: '0',
  354. pp5: '0',
  355. pp6: '0',
  356. pp7: '0',
  357. pp8: '0',
  358. pp9: '0',
  359. pp10: '0',
  360. pp11: '0',
  361. pp12: '0',
  362. pp13: '0',
  363. pp14: '0',
  364. pp15: '0',
  365. pp16: '0',
  366. pp17: '0',
  367. pp18: '0',
  368. pp19: '0',
  369. totalAmount: '198.02'
  370. },
  371. {
  372. area: '合计',
  373. provinceName: '合计',
  374. custName: '合计',
  375. custType: '合计',
  376. pp1: '125.02',
  377. pp2: '73.00',
  378. pp3: '0',
  379. pp4: '0',
  380. pp5: '0',
  381. pp6: '0',
  382. pp7: '0',
  383. pp8: '0',
  384. pp9: '0',
  385. pp10: '0',
  386. pp11: '0',
  387. pp12: '0',
  388. pp13: '0',
  389. pp14: '0',
  390. pp15: '0',
  391. pp16: '0',
  392. pp17: '0',
  393. pp18: '0',
  394. pp19: '0',
  395. totalAmount: '198.02'
  396. }],
  397. count: 1
  398. }
  399. for (var i = 0; i < data.list.length; i++) {
  400. data.list[i].no = i + 1
  401. }
  402. _this.disabled = false
  403. resolve(data)
  404. })
  405. },
  406. productType: [],
  407. productTotal: null,
  408. currentTotal: null
  409. }
  410. },
  411. methods: {
  412. // 创建时间 change
  413. dateChange (date) {
  414. this.queryParam.beginDate = date[0]
  415. this.queryParam.endDate = date[1]
  416. },
  417. custChange (obj) {
  418. this.queryParam.buyerSn = obj.key
  419. },
  420. // 获取城市列表
  421. getCityList (val) {
  422. const index = this.addrProvinceList.findIndex(item => item.areaSn == val)
  423. if (index >= 0) {
  424. this.queryParam.provinceName = this.addrProvinceList[index].name
  425. }
  426. this.addrCityList = []
  427. this.addrDistrictList = []
  428. this.queryParam.citySn = undefined
  429. this.queryParam.districtSn = undefined
  430. this.queryParam.address = ''
  431. this.getArea('city', val)
  432. },
  433. // 获取区县列表
  434. getAreaList (val) {
  435. const index = this.addrCityList.findIndex(item => item.areaSn == val)
  436. if (index >= 0) {
  437. this.queryParam.cityName = this.addrCityList[index].name
  438. }
  439. this.addrDistrictList = []
  440. this.queryParam.districtSn = undefined
  441. this.queryParam.address = ''
  442. this.getArea('district', val)
  443. },
  444. // 区县变更
  445. areaCharged (val) {
  446. const index = this.addrDistrictList.findIndex(item => item.areaSn == val)
  447. if (index >= 0) {
  448. this.queryParam.districtName = this.addrDistrictList[index].name
  449. }
  450. this.queryParam.address = ''
  451. },
  452. // 省/市/区
  453. getArea (leve, sn) {
  454. let params
  455. if (leve == 'province') {
  456. params = { type: '2' }
  457. } else {
  458. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  459. }
  460. getArea(params).then(res => {
  461. if (res.status == 200) {
  462. if (leve == 'province') {
  463. this.addrProvinceList = res.data || []
  464. } else if (leve == 'city') {
  465. this.addrCityList = res.data || []
  466. } else if (leve == 'district') {
  467. this.addrDistrictList = res.data || []
  468. }
  469. } else {
  470. if (leve == 'province') {
  471. this.addrProvinceList = []
  472. } else if (leve == 'city') {
  473. this.addrCityList = []
  474. } else if (leve == 'district') {
  475. this.addrDistrictList = []
  476. }
  477. }
  478. })
  479. },
  480. // 重置
  481. resetSearchForm () {
  482. this.$refs.rangeDate.resetDate(this.time)
  483. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  484. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  485. this.queryParam.buyerSn = undefined
  486. this.queryParam.subareaSn = undefined
  487. this.queryParam.productName = ''
  488. this.queryParam.productCode = ''
  489. this.queryParam.productTypeSn1 = ''
  490. this.queryParam.productTypeSn2 = ''
  491. this.queryParam.productTypeSn3 = ''
  492. this.queryParam.salesBillNo = ''
  493. this.productType = []
  494. this.$refs.table.refresh(true)
  495. },
  496. // 详情
  497. handleDetail (row) {
  498. this.$router.push({ name: 'salesDetail', params: { sn: row.salesBillSn } })
  499. },
  500. // 导出
  501. handleExport () {
  502. const params = this.queryParam
  503. if (this.time && this.time.length) {
  504. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD')
  505. params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  506. } else {
  507. params.beginDate = ''
  508. params.endDate = ''
  509. }
  510. this.exportLoading = true
  511. oosDetailExport(params).then(res => {
  512. this.exportLoading = false
  513. this.download(res)
  514. })
  515. },
  516. download (data) {
  517. if (!data) { return }
  518. const url = window.URL.createObjectURL(new Blob([data]))
  519. const link = document.createElement('a')
  520. link.style.display = 'none'
  521. link.href = url
  522. const a = moment().format('YYYYMMDDHHmmss')
  523. const fname = '缺货统计(按客户)' + a
  524. link.setAttribute('download', fname + '.xlsx')
  525. document.body.appendChild(link)
  526. link.click()
  527. }
  528. },
  529. beforeRouteEnter (to, from, next) {
  530. next(vm => {
  531. vm.getArea('province')
  532. })
  533. }
  534. }
  535. </script>