list.vue 17 KB

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