list.vue 16 KB

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