list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="searchBoxNormal">
  4. <a-spin :spinning="spinning" tip="Loading...">
  5. <!-- 搜索条件 -->
  6. <div class="table-page-search-wrapper" ref="tableSearch">
  7. <a-form-model
  8. id="allocationPresentationList-form"
  9. ref="ruleForm"
  10. class="form-model-con"
  11. layout="inline"
  12. :model="queryParam"
  13. :rules="rules"
  14. @keyup.enter.native="handleSearch">
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="调拨日期" prop="time">
  18. <rangeDate ref="rangeDate" id="allocationPresentationList-time" :value="queryParam.time" @change="dateChange" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="调拨单号">
  23. <a-input id="allocationPresentationList-allocateNo" v-model.trim="queryParam.allocateNo" allowClear placeholder="请输入调拨单号"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-model-item label="客户名称">
  28. <a-input id="allocationPresentationList-targetName" v-model.trim="queryParam.targetName" allowClear placeholder="请输入客户名称"/>
  29. </a-form-model-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :sm="24">
  33. <a-form-model-item label="客户级别">
  34. <v-select
  35. v-model="queryParam.dealer.dealerLevel"
  36. ref="dealerLevel"
  37. id="allocationPresentationList-dealerLevel"
  38. code="DEALER_LEVEL"
  39. placeholder="请选择客户级别"
  40. allowClear></v-select>
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24">
  44. <a-form-model-item label="所在区域">
  45. <subarea id="allocationPresentationList-subareaSn" ref="subarea" @change="subareaChange"></subarea>
  46. </a-form-model-item>
  47. </a-col>
  48. <a-col :md="6" :sm="24">
  49. <a-form-model-item label="地区">
  50. <AreaList id="allocationPresentationList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  51. </a-form-model-item>
  52. </a-col>
  53. <a-col :md="6" :sm="24">
  54. <a-form-model-item label="新/老客户">
  55. <a-select id="allocationPresentationList-dealerNewFlag" v-model="queryParam.dealerNewFlag" placeholder="请选择" allowClear>
  56. <a-select-option value="1">新客户</a-select-option>
  57. <a-select-option value="0">老客户</a-select-option>
  58. </a-select>
  59. </a-form-model-item>
  60. </a-col>
  61. </template>
  62. <a-col :md="6" :sm="24">
  63. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="allocationPresentationList-refresh">查询</a-button>
  64. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="allocationPresentationList-reset">重置</a-button>
  65. <a-button
  66. style="margin-left: 5px"
  67. type="primary"
  68. class="button-warning"
  69. @click="handleExport"
  70. :disabled="disabled"
  71. :loading="exportLoading"
  72. v-if="$hasPermissions('B_allocationPresentationExport')"
  73. id="allocationPresentationList-export">导出</a-button>
  74. <a @click="advanced=!advanced" style="margin-left: 5px">
  75. {{ advanced ? '收起' : '展开' }}
  76. <a-icon :type="advanced ? 'up' : 'down'"/>
  77. </a>
  78. </a-col>
  79. </a-row>
  80. </a-form-model>
  81. </div>
  82. </a-spin>
  83. </a-card>
  84. <a-tabs :tabBarStyle="{'background':'#fff'}">
  85. <a-tab-pane key="1" tab="费用/调拨类型列表">
  86. <a-card size="small" :bordered="false" class="allocationPresentationList-wrap" :style="{'margin-top':'-16px'}">
  87. <!-- 列表 -->
  88. <s-table
  89. class="sTable fixPagination"
  90. ref="table"
  91. size="small"
  92. :defaultLoadData="false"
  93. :rowKey="(record) => record.no"
  94. :pageSize="30"
  95. rowKeyName="no"
  96. :columns="columns"
  97. :data="loadData"
  98. :style="{ height: tableHeight+84.5+'px' }"
  99. :scroll="{ x: 680 + tableWidth,y: tableHeight-40}"
  100. bordered>
  101. </s-table>
  102. </a-card>
  103. </a-tab-pane>
  104. <a-tab-pane key="2" tab="费用/调拨类型合计" force-render>
  105. <a-card size="small" :bordered="false" class="allocationPresentationList-wrap" :style="{'height':tableHeight*1+110*1+'px',overflow:'auto','margin-top':'-16px'}">
  106. <div class="h-title">
  107. <div><div>费用类型</div></div>
  108. <div><div>调拨类别</div></div>
  109. <div><div>调拨类型</div></div>
  110. </div>
  111. <div class="leve1" v-for="item in totalData" :key="item.name">
  112. <div>
  113. <div>
  114. {{ item.name }}
  115. </div>
  116. <div>
  117. {{ item.cost }}
  118. </div>
  119. </div>
  120. <div>
  121. <!-- 二级 -->
  122. <div class="leve2" v-for="item2 in item.treeList" :key="item2.name">
  123. <div>
  124. <div>
  125. {{ item2.name }}
  126. </div>
  127. <div>
  128. {{ item2.cost }}
  129. </div>
  130. </div>
  131. <div>
  132. <!-- 三级 -->
  133. <div class="leve3" v-for="item3 in item2.treeList" :key="item3.name">
  134. <div>
  135. <div>
  136. {{ item3.name }}
  137. </div>
  138. <div>
  139. {{ item3.cost }}
  140. </div>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </div>
  147. <div v-if="!totalData" style="text-align: center;padding:100px 0;">暂无合计数据</div>
  148. </a-card>
  149. </a-tab-pane>
  150. </a-tabs>
  151. </a-spin>
  152. <!-- 导出提示框 -->
  153. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  154. </div>
  155. </template>
  156. <script>
  157. import { commonMixin } from '@/utils/mixin'
  158. import { hdExportExcel } from '@/libs/exportExcel'
  159. // 组件
  160. import { STable, VSelect } from '@/components'
  161. import rangeDate from '@/views/common/rangeDate.vue'
  162. import reportModal from '@/views/common/reportModal.vue'
  163. import subarea from '@/views/common/subarea.js'
  164. import { allocateTypeTreeList } from '@/api/allocateType'
  165. import AreaList from '@/views/common/areaList.js'
  166. // 接口
  167. import { reportAllocateDbjdReportList, reportAllocateDbjdReportCount, reportAllocateDbjdReportExport } from '@/api/reportData'
  168. export default {
  169. name: 'AllocationPresentationList',
  170. mixins: [commonMixin],
  171. components: { STable, VSelect, rangeDate, subarea, AreaList, reportModal },
  172. data () {
  173. return {
  174. spinning: false,
  175. advanced: true, // 高级搜索 展开/关闭
  176. showExport: false, // 导出提示框
  177. tableHeight: 0, // 表格高度
  178. disabled: false, // 查询、重置按钮是否可操作
  179. exportLoading: false, // 导出按钮加载状态
  180. tableWidth: 0, // 表格宽度
  181. // 查询条件
  182. queryParam: {
  183. time: [], // 调拨日期
  184. beginDate: '', // 开始日期
  185. endDate: '', // 结束日期
  186. allocateNo: '', // 调拨单号
  187. targetName: '', // 客户名称
  188. dealerNewFlag: undefined,
  189. subareaArea: {
  190. subareaSn: undefined, // 区域
  191. subareaAreaSn: undefined// 分区
  192. },
  193. dealer: {
  194. provinceSn: undefined, // 省
  195. citySn: undefined, // 市
  196. districtSn: undefined, // 区
  197. dealerLevel: undefined// 客户级别
  198. }
  199. },
  200. rules: {
  201. 'time': [{ required: true, message: '请选择调拨日期', trigger: 'change' }]
  202. },
  203. // 加载数据方法 必须为 Promise 对象
  204. loadData: parameter => {
  205. this.disabled = true
  206. this.spinning = true
  207. const paramsPage = Object.assign(this.queryParam, { pageNo: parameter.pageNo, pageSize: parameter.pageSize })
  208. // 获取列表数据 有分页
  209. return reportAllocateDbjdReportList(paramsPage).then(res => {
  210. let data
  211. if (res.status == 200) {
  212. data = res.data
  213. // 获取 费用/调拨类型合计 数据
  214. this.getCount(paramsPage)
  215. // 计算表格序号
  216. const no = (data.pageNo - 1) * data.pageSize
  217. for (var i = 0; i < data.list.length; i++) {
  218. data.list[i].no = no + i + 1
  219. }
  220. this.disabled = false
  221. }
  222. this.spinning = false
  223. return data
  224. })
  225. },
  226. totalData: null, // 费用/调拨类型合计 数据
  227. allocateType: [], // 调拨类型
  228. atypeColList: []// 重组调拨类型数据
  229. }
  230. },
  231. computed: {
  232. columns () {
  233. let arr = [
  234. { title: '区域', dataIndex: 'subareaName', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  235. { title: '分区', dataIndex: 'subareaAreaName', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '调拨单号', dataIndex: 'allocateNo', width: 160, align: 'center', customRender: function (text) { return text || '--' } },
  237. { title: '省份', dataIndex: 'provinceName', width: 90, align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '客户名称', dataIndex: 'dealerName', width: 120, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  239. { title: '客户级别', dataIndex: 'dealerLevelDictValue', width: 120, align: 'center', customRender: function (text) { return text || '--' } }
  240. ]
  241. arr = arr.concat(this.atypeColList)
  242. arr.splice(arr.length, 0, { title: '调拨单合计金额', width: 90, dataIndex: 'totalCost', align: 'right', customRender: function (text) { return (text || text == 0) ? text : '--' } })
  243. return arr
  244. }
  245. },
  246. watch: {
  247. // 展开关闭时,监听表格高度
  248. advanced (newValue, oldValue) {
  249. const _this = this
  250. this.$nextTick(() => { // 页面渲染完成后的回调
  251. _this.setTableH()
  252. })
  253. },
  254. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  255. this.setTableH()
  256. }
  257. },
  258. methods: {
  259. // 组合调拨类型 数据
  260. getCol (data, key) {
  261. const ret = []
  262. for (let i = 0; i < data.length; i++) {
  263. const row = data[i]
  264. row.paths = key ? (key + '_' + row.allocateTypeSn) : row.allocateTypeSn
  265. const params = {
  266. title: row.name
  267. }
  268. if (!row.sonList) {
  269. params.dataIndex = row.paths
  270. params.width = 100
  271. params.align = 'right'
  272. params.customRender = function (text) {
  273. return text || '--'
  274. }
  275. this.tableWidth += 100
  276. } else {
  277. params.children = this.getCol(row.sonList, row.paths)
  278. }
  279. ret.push(params)
  280. }
  281. return ret
  282. },
  283. // 获取调拨类型
  284. getAllocateType () {
  285. allocateTypeTreeList({}).then(res => {
  286. if (res.status == 200) {
  287. this.allocateType = res.data
  288. this.atypeColList = this.getCol(this.allocateType, '')
  289. } else {
  290. this.allocateType = []
  291. }
  292. })
  293. },
  294. // 导出
  295. handleExport () {
  296. const _this = this
  297. this.$refs.ruleForm.validate(valid => {
  298. if (valid) {
  299. const params = _this.queryParam
  300. _this.$store.state.app.curActionPermission = 'B_allocationPresentationExport'
  301. _this.showExport = true
  302. delete params.time
  303. _this.exportLoading = true
  304. _this.spinning = true
  305. hdExportExcel(reportAllocateDbjdReportExport, params, '调拨交单报表', function () {
  306. _this.exportLoading = false
  307. _this.spinning = false
  308. _this.$store.state.app.curActionPermission = ''
  309. })
  310. } else {
  311. return false
  312. }
  313. })
  314. },
  315. // 总计
  316. getCount (params) {
  317. reportAllocateDbjdReportCount(params).then(res => {
  318. if (res.status == 200 && res.data) {
  319. this.totalData = res.data
  320. } else {
  321. this.totalData = null
  322. }
  323. })
  324. },
  325. // 查询
  326. handleSearch () {
  327. const _this = this
  328. this.$refs.ruleForm.validate(valid => {
  329. if (valid) {
  330. _this.$refs.table.refresh(true)
  331. } else {
  332. _this.$message.error('请选择调拨日期')
  333. return false
  334. }
  335. })
  336. },
  337. // 调拨日期 change
  338. dateChange (date) {
  339. if (date[0] && date[1]) {
  340. this.queryParam.time = date
  341. } else {
  342. this.queryParam.time = []
  343. }
  344. this.queryParam.beginDate = date[0] || ''
  345. this.queryParam.endDate = date[1] || ''
  346. },
  347. // 区域分区 change
  348. subareaChange (val) {
  349. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : undefined
  350. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : undefined
  351. },
  352. // 重置
  353. resetSearchForm () {
  354. this.queryParam.time = []
  355. this.$refs.rangeDate.resetDate(this.queryParam.time)
  356. this.queryParam.beginDate = ''
  357. this.queryParam.endDate = ''
  358. this.queryParam.allocateNo = ''
  359. this.queryParam.targetName = ''
  360. this.queryParam.dealerNewFlag = undefined
  361. this.queryParam.subareaArea = {
  362. subareaSn: undefined,
  363. subareaAreaSn: undefined
  364. }
  365. this.queryParam.dealer = {
  366. provinceSn: undefined,
  367. citySn: undefined,
  368. districtSn: undefined,
  369. dealerLevel: undefined
  370. }
  371. this.totalData = null
  372. if (this.advanced) {
  373. this.$refs.areaList.clearData()
  374. this.$refs.subarea.clearData()
  375. }
  376. this.$refs.ruleForm.resetFields()
  377. this.$refs.table.clearTable()
  378. },
  379. // 地区
  380. areaChange (val) {
  381. this.queryParam.dealer.provinceSn = val[0] ? val[0] : ''
  382. this.queryParam.dealer.citySn = val[1] ? val[1] : ''
  383. this.queryParam.dealer.districtSn = val[2] ? val[2] : ''
  384. },
  385. // 初始化
  386. pageInit () {
  387. this.getAllocateType()
  388. this.resetSearchForm()
  389. this.setTableH()
  390. },
  391. // 计算表格高度
  392. setTableH () {
  393. const tableSearchH = this.$refs.tableSearch.offsetHeight
  394. this.tableHeight = window.innerHeight - tableSearchH - 255
  395. }
  396. },
  397. mounted () {
  398. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  399. this.pageInit()
  400. }
  401. },
  402. activated () {
  403. // 如果是新页签打开,则重置当前页面
  404. if (this.$store.state.app.isNewTab) {
  405. this.pageInit()
  406. }
  407. },
  408. beforeRouteEnter (to, from, next) {
  409. next(vm => {})
  410. }
  411. }
  412. </script>
  413. <style lang="less" scoped>
  414. .allocationPresentationList-wrap{
  415. .h-title{
  416. display: flex;
  417. align-items: center;
  418. margin-top:10px;
  419. > div{
  420. padding: 10px;
  421. width: 33.3%;
  422. background:#f8f8f8;
  423. border-left:1px solid #eee;
  424. > div{
  425. width: 50%;
  426. text-align: center;
  427. font-weight:bold;
  428. border-right:1px solid #eee;
  429. }
  430. }
  431. }
  432. .leve1{
  433. border:1px solid #eee;
  434. > div{
  435. &:first-child{
  436. width: 33.3%;
  437. display: flex;
  438. align-items: center;
  439. > div{
  440. width: 50%;
  441. height: 100%;
  442. text-align: center;
  443. border-left:1px solid #eee;
  444. display: flex;
  445. align-items: center;
  446. justify-content: center;
  447. }
  448. }
  449. &:last-child{
  450. align-items: center;
  451. width: 66.6%;
  452. }
  453. }
  454. }
  455. .leve2{
  456. border-bottom:1px solid #eee;
  457. > div{
  458. &:first-child{
  459. width: 50%;
  460. display: flex;
  461. align-items: center;
  462. > div{
  463. width: 50%;
  464. height: 100%;
  465. padding: 10px;
  466. text-align: center;
  467. border-left:1px solid #eee;
  468. display: flex;
  469. align-items: center;
  470. justify-content: center;
  471. }
  472. }
  473. &:last-child{
  474. align-items: center;
  475. width: 50%;
  476. border-left:1px solid #eee;
  477. }
  478. }
  479. &:last-child{
  480. border-bottom:0;
  481. }
  482. }
  483. .leve3{
  484. border-bottom:1px solid #eee;
  485. > div{
  486. width: 100%;
  487. display: flex;
  488. align-items: center;
  489. > div{
  490. width: 50%;
  491. height: 100%;
  492. padding: 10px;
  493. text-align: center;
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. &:last-child{
  498. border-left:1px solid #eee;
  499. }
  500. }
  501. }
  502. &:last-child{
  503. border-bottom:0;
  504. }
  505. }
  506. .leve1,.leve2,.leve3{
  507. display:flex;
  508. }
  509. /deep/.ant-card-body{
  510. margin-top:-11px !important;
  511. }
  512. }
  513. </style>