list.vue 17 KB

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