list.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <a-card size="small" :bordered="false" class="allocationPresentationList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="allocationPresentationList-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. <a-input id="allocationPresentationList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入客户名称"/>
  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="allocationPresentationList-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="allocationPresentationList-allocateNo" v-model.trim="queryParam.allocateNo" 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="allocationPresentationList-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="allocationPresentationList-refresh">查询</a-button>
  77. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocationPresentationList-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_allocationPresentationExport')"
  86. id="allocationPresentationList-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: 1840 }"
  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.pspdb || totalData.pspdb==0)) ? totalData.pspdb : '--' }}</a-col>
  112. <a-col span="4">有偿调拨:{{ (totalData && (totalData.ycdb || totalData.ycdb==0)) ? totalData.ycdb : '--' }}</a-col>
  113. <a-col span="4">促销调拨:{{ (totalData && (totalData.cxdb || totalData.cxdb==0)) ? totalData.cxdb : '--' }}</a-col>
  114. <a-col span="4">退换品调拨:{{ (totalData && (totalData.thpdb || totalData.thpdb==0)) ? totalData.thpdb : '--' }}</a-col>
  115. <a-col span="4">样品调拨:{{ (totalData && (totalData.ypdb || totalData.ypdb==0)) ? totalData.ypdb : '--' }}</a-col>
  116. <a-col span="4">仓库误差调拨:{{ (totalData && (totalData.ckwcdb || totalData.ckwcdb==0)) ? totalData.ckwcdb : '--' }}</a-col>
  117. <a-col span="4">TBU刹车片配送品调拨:{{ (totalData && (totalData.tbudb || totalData.tbudb==0)) ? totalData.tbudb : '--' }}</a-col>
  118. <a-col span="4">NGK配送品调拨:{{ (totalData && (totalData.ngkdb || totalData.ngkdb==0)) ? totalData.ngkdb : '--' }}</a-col>
  119. <a-col span="4">德路斯调拨:{{ (totalData && (totalData.dlsdb || totalData.dlsdb==0)) ? totalData.dlsdb : '--' }}</a-col>
  120. <a-col span="4">新加盟商政策调拨:{{ (totalData && (totalData.xjmszcdb || totalData.xjmszcdb==0)) ? totalData.xjmszcdb : '--' }}</a-col>
  121. <a-col span="4">特殊申请配送品调拨:{{ (totalData && (totalData.tssqpspdb || totalData.tssqpspdb==0)) ? totalData.tssqpspdb : '--' }}</a-col>
  122. <a-col span="4">特殊申请促销调拨:{{ (totalData && (totalData.tssqcxdb || totalData.tssqcxdb==0)) ? totalData.tssqcxdb : '--' }}</a-col>
  123. <a-col span="4">卡扣配送品调拨:{{ (totalData && (totalData.kkpspdb || totalData.kkpspdb==0)) ? totalData.kkpspdb : '--' }}</a-col>
  124. <a-col span="4">客诉样品调拨:{{ (totalData && (totalData.ksypdb || totalData.ksypdb==0)) ? totalData.ksypdb : '--' }}</a-col>
  125. <a-col span="6" v-if="$hasPermissions('B_isShowPrice')">调拨单合计金额:{{ (totalData && (totalData.totalCost || totalData.totalCost==0)) ? totalData.totalCost : '--' }}</a-col>
  126. </a-row>
  127. </a-col>
  128. </a-row>
  129. </template>
  130. </s-table>
  131. </a-spin>
  132. </a-card>
  133. </template>
  134. <script>
  135. import { STable, VSelect } from '@/components'
  136. import rangeDateTime from '@/views/common/rangeDateTime.vue'
  137. import subarea from '@/views/common/subarea.js'
  138. import { getArea } from '@/api/data'
  139. import { hdExportExcel } from '@/libs/exportExcel'
  140. import { reportAllocateDbjdReportList, reportAllocateDbjdReportCount, reportAllocateDbjdReportExport } from '@/api/reportData'
  141. export default {
  142. components: { STable, VSelect, rangeDateTime, subarea },
  143. data () {
  144. return {
  145. spinning: false,
  146. advanced: true, // 高级搜索 展开/关闭
  147. queryParam: { // 查询条件
  148. time: [],
  149. beginDate: '',
  150. endDate: '',
  151. allocateNo: '',
  152. targetName: '',
  153. dealer: {
  154. 'provinceSn': undefined,
  155. 'citySn': undefined,
  156. 'districtSn': undefined,
  157. 'subareaSn': undefined,
  158. 'dealerLevel': undefined
  159. }
  160. },
  161. rules: {
  162. 'time': [{ required: true, message: '请选择调拨日期', trigger: 'change' }]
  163. },
  164. disabled: false, // 查询、重置按钮是否可操作
  165. exportLoading: false,
  166. // 加载数据方法 必须为 Promise 对象
  167. loadData: parameter => {
  168. this.disabled = true
  169. this.spinning = true
  170. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize }) // 有分页
  171. return reportAllocateDbjdReportList(paramsPage).then(res => {
  172. let data
  173. if (res.status == 200) {
  174. data = res.data
  175. this.getCount(paramsPage)
  176. const no = (data.pageNo - 1) * data.pageSize
  177. for (var i = 0; i < data.list.length; i++) {
  178. data.list[i].no = no + i + 1
  179. }
  180. this.disabled = false
  181. }
  182. this.spinning = false
  183. return data
  184. })
  185. },
  186. totalData: null,
  187. addrProvinceList: [], // 省下拉
  188. addrCityList: [], // 市下拉
  189. addrDistrictList: [] // 区下拉
  190. }
  191. },
  192. computed: {
  193. columns () {
  194. const arr = [
  195. { title: '区域', dataIndex: 'dealerEntity.subareaNameSet', width: 120, align: 'center', customRender: function (text) { return (text && text.length > 0) ? text.join('/') : '--' } },
  196. { title: '调拨单号', dataIndex: 'allocateNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  197. { title: '省份', dataIndex: 'dealerEntity.provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  198. { title: '客户名称', dataIndex: 'targetName', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  199. { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  200. { title: '调拨类型',
  201. align: 'center',
  202. children: [
  203. {
  204. title: '配送品调拨',
  205. dataIndex: 'pspdb',
  206. align: 'center',
  207. width: 80,
  208. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  209. },
  210. {
  211. title: '有偿调拨',
  212. dataIndex: 'ycdb',
  213. align: 'center',
  214. width: 80,
  215. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  216. },
  217. {
  218. title: '促销调拨',
  219. dataIndex: 'cxdb',
  220. align: 'center',
  221. width: 80,
  222. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  223. },
  224. {
  225. title: '退换品调拨',
  226. dataIndex: 'thpdb',
  227. align: 'center',
  228. width: 80,
  229. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  230. },
  231. {
  232. title: '样品调拨',
  233. dataIndex: 'ypdb',
  234. align: 'center',
  235. width: 80,
  236. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  237. },
  238. {
  239. title: '仓库误差调拨',
  240. dataIndex: 'ckwcdb',
  241. align: 'center',
  242. width: 80,
  243. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  244. },
  245. {
  246. title: 'TBU刹车片配送品调拨',
  247. dataIndex: 'tbudb',
  248. align: 'center',
  249. width: 80,
  250. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  251. },
  252. {
  253. title: 'NGK配送品调拨',
  254. dataIndex: 'ngkdb',
  255. align: 'center',
  256. width: 80,
  257. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  258. },
  259. {
  260. title: '德路斯调拨',
  261. dataIndex: 'dlsdb',
  262. align: 'center',
  263. width: 80,
  264. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  265. },
  266. {
  267. title: '新加盟商政策调拨',
  268. dataIndex: 'xjmszcdb',
  269. align: 'center',
  270. width: 80,
  271. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  272. },
  273. {
  274. title: '特殊申请配送品调拨',
  275. dataIndex: 'tssqpspdb',
  276. align: 'center',
  277. width: 80,
  278. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  279. },
  280. {
  281. title: '特殊申请促销调拨',
  282. dataIndex: 'tssqcxdb',
  283. align: 'center',
  284. width: 80,
  285. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  286. },
  287. {
  288. title: '卡扣配送品调拨',
  289. dataIndex: 'kkpspdb',
  290. align: 'center',
  291. width: 80,
  292. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  293. },
  294. {
  295. title: '客诉样品调拨',
  296. dataIndex: 'ksypdb',
  297. align: 'center',
  298. width: 80,
  299. customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' }
  300. }
  301. ]
  302. }
  303. // { title: '调拨单合计金额', width: 90, dataIndex: 'totalCost', align: 'center', customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' } }
  304. ]
  305. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  306. arr.splice(arr.length, 0, { title: '调拨单合计金额', width: 90, dataIndex: 'totalCost', align: 'center', customRender: function (text) { return (text || text == 0) ? ('¥' + text) : '--' } })
  307. }
  308. return arr
  309. }
  310. },
  311. methods: {
  312. // 导出
  313. handleExport () {
  314. const _this = this
  315. this.$refs.ruleForm.validate(valid => {
  316. if (valid) {
  317. const params = _this.queryParam
  318. delete params.time
  319. _this.exportLoading = true
  320. _this.spinning = true
  321. hdExportExcel(reportAllocateDbjdReportExport, params, '调拨交单报表', function () {
  322. _this.exportLoading = false
  323. _this.spinning = false
  324. })
  325. } else {
  326. return false
  327. }
  328. })
  329. },
  330. // 总计
  331. getCount (params) {
  332. reportAllocateDbjdReportCount(params).then(res => {
  333. if (res.status == 200 && res.data) {
  334. this.totalData = res.data
  335. } else {
  336. this.totalData = null
  337. }
  338. })
  339. },
  340. handleSearch () {
  341. const _this = this
  342. this.$refs.ruleForm.validate(valid => {
  343. if (valid) {
  344. _this.$refs.table.refresh(true)
  345. } else {
  346. return false
  347. }
  348. })
  349. },
  350. // 创建时间 change
  351. dateChange (date) {
  352. if (date[0] && date[1]) {
  353. this.queryParam.time = date
  354. } else {
  355. this.queryParam.time = []
  356. }
  357. this.queryParam.beginDate = date[0] || ''
  358. this.queryParam.endDate = date[1] || ''
  359. },
  360. // 重置
  361. resetSearchForm () {
  362. this.queryParam.time = []
  363. this.$refs.rangeDate.resetDate(this.queryParam.time)
  364. this.queryParam.beginDate = ''
  365. this.queryParam.endDate = ''
  366. this.queryParam.allocateNo = ''
  367. this.queryParam.targetName = ''
  368. this.queryParam.dealer = {
  369. 'provinceSn': undefined,
  370. 'citySn': undefined,
  371. 'districtSn': undefined,
  372. 'subareaSn': undefined,
  373. 'dealerLevel': undefined
  374. }
  375. this.totalData = null
  376. this.$refs.ruleForm.resetFields()
  377. this.$refs.table.clearTable()
  378. },
  379. // 获取城市列表
  380. getCityList (val) {
  381. this.addrCityList = []
  382. this.addrDistrictList = []
  383. this.queryParam.dealer.citySn = undefined
  384. this.queryParam.dealer.districtSn = undefined
  385. if (val) {
  386. this.getArea('city', val)
  387. }
  388. },
  389. // 获取区县列表
  390. getAreaList (val) {
  391. this.addrDistrictList = []
  392. this.queryParam.dealer.districtSn = undefined
  393. if (val) {
  394. this.getArea('district', val)
  395. }
  396. },
  397. // 省/市/区
  398. getArea (leve, sn) {
  399. let params
  400. if (leve == 'province') {
  401. params = { type: '2' }
  402. } else {
  403. params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
  404. }
  405. getArea(params).then(res => {
  406. if (res.status == 200) {
  407. if (leve == 'province') {
  408. this.addrProvinceList = res.data || []
  409. } else if (leve == 'city') {
  410. this.addrCityList = res.data || []
  411. } else if (leve == 'district') {
  412. this.addrDistrictList = res.data || []
  413. }
  414. } else {
  415. if (leve == 'province') {
  416. this.addrProvinceList = []
  417. } else if (leve == 'city') {
  418. this.addrCityList = []
  419. } else if (leve == 'district') {
  420. this.addrDistrictList = []
  421. }
  422. }
  423. })
  424. },
  425. pageInit () {
  426. this.getArea('province')
  427. }
  428. },
  429. mounted () {
  430. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  431. this.pageInit()
  432. this.resetSearchForm()
  433. }
  434. },
  435. activated () {
  436. // 如果是新页签打开,则重置当前页面
  437. if (this.$store.state.app.isNewTab) {
  438. this.pageInit()
  439. this.resetSearchForm()
  440. }
  441. },
  442. beforeRouteEnter (to, from, next) {
  443. next(vm => {})
  444. }
  445. }
  446. </script>