monthQueryList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="monthQueryList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="monthQueryList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :rules="rules"
  12. :model="queryParam">
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="查询月份" prop="beginDate">
  16. <a-month-picker
  17. id="monthQueryList-monthBox"
  18. class="monthBox"
  19. :disabled-date="disabledDate"
  20. v-model="monthVal"
  21. placeholder="请选择月份"
  22. @change="onChangeMonth" />
  23. </a-form-model-item>
  24. </a-col>
  25. <a-col :md="6" :sm="24">
  26. <a-form-model-item label="地区">
  27. <AreaList id="monthQueryList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="24">
  31. <a-form-item label="区域/分区">
  32. <subarea id="monthQueryList-subarea" ref="subarea" @change="subareaChange"></subarea>
  33. </a-form-item>
  34. </a-col>
  35. <template v-if="advanced">
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="客户名称">
  38. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="monthQueryList-dealerName" @change="custChange" />
  39. </a-form-model-item>
  40. </a-col>
  41. <a-col :md="6" :sm="24">
  42. <a-form-model-item label="轮胎省仓名称">
  43. <dealerSubareaScopeList ref="provinceDealerList" placeholder="请输入轮胎省仓名称" id="monthQueryList-provinceDealerName" @change="custProvinceChange" />
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :md="6" :sm="24">
  47. <a-form-model-item label="客户级别">
  48. <v-select
  49. v-model="queryParam.dealerLevel"
  50. ref="dealerLevel"
  51. id="monthQueryList-dealerLevel"
  52. code="DEALER_LEVEL"
  53. placeholder="请选择客户级别"
  54. allowClear></v-select>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :md="6" :sm="24">
  58. <a-form-model-item label="轮胎省仓">
  59. <a-select id="monthQueryList-provinceFlag" placeholder="请选择是否是轮胎省仓" v-model="queryParam.provinceFlag">
  60. <a-select-option value="1">
  61. </a-select-option>
  62. <a-select-option value="0">
  63. </a-select-option>
  64. </a-select>
  65. </a-form-model-item>
  66. </a-col>
  67. </template>
  68. <a-col :md="6" :sm="24">
  69. <a-button
  70. type="primary"
  71. @click="handleSearch"
  72. :disabled="disabled"
  73. id="monthQueryList-refresh">查询</a-button>
  74. <a-button
  75. style="margin-left: 8px"
  76. @click="resetSearchForm"
  77. :disabled="disabled"
  78. id="monthQueryList-reset">重置</a-button>
  79. <a-button
  80. style="margin-left: 10px"
  81. type="primary"
  82. class="button-warning"
  83. @click="handleExport"
  84. :disabled="disabled"
  85. :loading="exportLoading"
  86. v-if="$hasPermissions('B_tireFeeExport')"
  87. id="monthQueryList-export">导出</a-button>
  88. <a @click="advanced=!advanced" style="margin-left: 5px">
  89. {{ advanced ? '收起' : '展开' }}
  90. <a-icon :type="advanced ? 'up' : 'down'" />
  91. </a>
  92. </a-col>
  93. </a-row>
  94. </a-form-model>
  95. </div>
  96. </a-card>
  97. <a-card size="small" :bordered="false">
  98. <a-spin :spinning="spinning" tip="Loading...">
  99. <!-- 列表 -->
  100. <s-table
  101. class="sTable fixPagination"
  102. ref="table"
  103. size="small"
  104. :rowKey="(record) => record.no"
  105. rowKeyName="no"
  106. :style="{ height: tableHeight+70+'px' }"
  107. :columns="columns"
  108. :data="loadData"
  109. :scroll="{ y: tableHeight-120}"
  110. :defaultLoadData="false"
  111. bordered>
  112. <!-- 地区 -->
  113. <template slot="addressInfo" slot-scope="text, record">
  114. {{ record.dealerEntity.provinceName }}{{ '/'+record.dealerEntity.cityName }}{{ '/'+record.dealerEntity.districtName }}
  115. </template>
  116. <!-- 是否是省仓客户 -->
  117. <template slot="provinceFlag" slot-scope="text, record">
  118. {{ record.provinceFlag?record.provinceFlag==0?'否':'是':'--' }}
  119. </template>
  120. <template slot="footer">
  121. <a-row :gutter="15">
  122. <a-col :md="4" :sm="24">总量提升奖励:{{ (totalData && (totalData.increaseRewardAmount || totalData.increaseRewardAmount==0)) ? toThousands(totalData.increaseRewardAmount): '--' }}</a-col>
  123. <a-col :md="4" :sm="24">总量工厂承担60%:{{ (totalData && (totalData.increaseRewardShareFactory || totalData.increaseRewardShareFactory==0)) ? toThousands(totalData.increaseRewardShareFactory): '--' }}</a-col>
  124. <a-col :md="5" :sm="24">总量供应链管理部承担40%:{{ (totalData && (totalData.increaseRewardShareSys || totalData.increaseRewardShareSys==0)) ? toThousands(totalData.increaseRewardShareSys): '--' }}</a-col>
  125. <a-col :md="4" :sm="24">运费补贴:{{ (totalData && (totalData.transSubsidy || totalData.transSubsidy==0)) ? toThousands(totalData.transSubsidy): '--' }}</a-col>
  126. <a-col :md="4" :sm="24">累计积分:{{ (totalData && (totalData.totalPoint || totalData.totalPoint==0)) ? toThousands(totalData.totalPoint): '--' }}</a-col>
  127. <a-col :md="4" :sm="24">当期积分返利券:{{ (totalData && (totalData.currentPoint || totalData.currentPoint==0)) ? toThousands(totalData.currentPoint): '--' }}</a-col>
  128. <a-col :md="4" :sm="24">积分工厂承担60%:{{ (totalData && (totalData.currentPointShareFactory || totalData.currentPointShareFactory==0)) ? toThousands(totalData.currentPointShareFactory): '--' }}</a-col>
  129. <a-col :md="5" :sm="24">积分供应链管理部承担40%:{{ (totalData && (totalData.currentPointShareSys || totalData.currentPointShareSys==0)) ?toThousands(totalData.currentPointShareSys): '--' }}</a-col>
  130. <a-col :md="4" :sm="24">平台服务费:{{ (totalData && (totalData.serviceAmountSys || totalData.serviceAmountSys==0)) ? toThousands(totalData.serviceAmountSys): '--' }}</a-col>
  131. <a-col :md="4" :sm="24">轮胎省仓服务费:{{ (totalData && (totalData.serviceAmountProvince || totalData.serviceAmountProvince==0)) ? toThousands(totalData.serviceAmountProvince): '--' }}</a-col>
  132. </a-row>
  133. </template>
  134. </s-table>
  135. </a-spin>
  136. </a-card>
  137. <!-- 导出提示框 -->
  138. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  139. </div>
  140. </template>
  141. <script>
  142. import { commonMixin } from '@/utils/mixin'
  143. import { hdExportExcel } from '@/libs/exportExcel'
  144. import moment from 'moment'
  145. // 组件
  146. import { STable, VSelect } from '@/components'
  147. import subarea from '@/views/common/subarea.js'
  148. import AreaList from '@/views/common/areaList.js'
  149. import reportModal from '@/views/common/reportModal.vue'
  150. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  151. // 接口
  152. import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
  153. export default {
  154. name: 'MonthQueryList',
  155. mixins: [commonMixin],
  156. components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, reportModal },
  157. data () {
  158. return {
  159. spinning: false,
  160. disabled: false, // 查询、重置按钮是否可操作
  161. advanced: true, // 高级搜索 展开/关闭
  162. tableHeight: 0, // 表格高度
  163. exportLoading: false, // 导出按钮加载状态
  164. showExport: false, // 导出弹窗
  165. monthVal: moment().format('YYYY-MM'), // 初始化月份值
  166. // 查询条件
  167. queryParam: {
  168. queryType: 'month', // 轮胎月度费用报表
  169. beginDate: this.getMonthDetailDay().firstDay, // 开始时间
  170. endDate: this.getMonthDetailDay().lastDay, // 结束时间
  171. dealerLevel: undefined, // 客户等级
  172. customSn: undefined, // 客户sn
  173. parentDealerSn: undefined, // 轮胎省仓sn
  174. dealerEntity: {
  175. dealerName: undefined, // 客户名称
  176. provinceSn: undefined, // 省
  177. citySn: undefined, // 市
  178. districtSn: undefined // 区
  179. },
  180. parentDealerEntity: {
  181. dealerName: undefined // 轮胎省仓名称
  182. },
  183. subareaArea: {
  184. subareaSn: '', // 区域
  185. subareaAreaSn: '' // 分区
  186. },
  187. provinceFlag: undefined// 是否是轮胎省仓 1是 0否
  188. },
  189. totalData: null, // 合计
  190. rules: {
  191. 'beginDate': [{ required: true, message: '请选择查询月份', trigger: 'change' }]
  192. },
  193. // 加载数据方法 必须为 Promise 对象
  194. loadData: parameter => {
  195. this.disabled = true
  196. this.spinning = true
  197. const oldParams = Object.assign(parameter, this.queryParam)
  198. const params = JSON.parse(JSON.stringify(oldParams))
  199. // 获取列表数据 有分页
  200. return tireFeeReportList(params).then(res => {
  201. let data
  202. if (res.status == 200) {
  203. data = res.data
  204. // 计算表格序号
  205. const no = (data.pageNo - 1) * data.pageSize
  206. for (var i = 0; i < data.list.length; i++) {
  207. data.list[i].no = no + i + 1
  208. }
  209. this.disabled = false
  210. this.getCount(params)
  211. }
  212. this.spinning = false
  213. return data
  214. })
  215. }
  216. }
  217. },
  218. watch: {
  219. advanced (newValue, oldValue) {
  220. const _this = this
  221. this.$nextTick(() => { // 页面渲染完成后的回调
  222. _this.setTableH()
  223. })
  224. },
  225. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  226. this.setTableH()
  227. }
  228. },
  229. computed: {
  230. columns () {
  231. const _this = this
  232. const arr = [
  233. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  234. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '15%', align: 'center' },
  235. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '13%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  237. { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '轮胎省仓', dataIndex: 'provinceFlag', scopedSlots: { customRender: 'provinceFlag' }, width: '10%', align: 'center' },
  239. { title: '轮胎省仓名称', dataIndex: 'parentDealerEntity.dealerName', width: '13%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  240. { title: '总量提升奖励', dataIndex: 'increaseRewardAmount', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  241. { title: <div>总量工厂<div>承担60%</div></div>, dataIndex: 'increaseRewardShareFactory', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  242. { title: <div>总量供应链管理部<div>承担40%</div></div>, dataIndex: 'increaseRewardShareSys', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  243. { title: <a-tooltip placement='top' title='轮胎轮胎省仓出库加盟商数量*5'>运费补贴&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'transSubsidy', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  244. { title: <a-tooltip placement='top' title='截止当前时间的往期累计积分'>累计积分&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'totalPoint', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  245. { title: <div>当期积分<div>返利券</div></div>, dataIndex: 'currentPoint', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  246. { title: <div>积分工厂<div>承担60%</div></div>, dataIndex: 'currentPointShareFactory', width: '12%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  247. { title: <div>积分供应链管理部<div>承担40%</div></div>, dataIndex: 'currentPointShareSys', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  248. { title: '平台服务费', dataIndex: 'serviceAmountSys', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  249. { title: '省仓服务费', dataIndex: 'serviceAmountProvince', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  250. ]
  251. return arr
  252. }
  253. },
  254. methods: {
  255. // 根据月份获取第一天和最后一天
  256. getMonthDetailDay (dateInfo) {
  257. let nowDate = ''
  258. if (!dateInfo) {
  259. nowDate = moment().format('YYYY-MM')
  260. } else {
  261. nowDate = dateInfo
  262. }
  263. // 月份的第一天
  264. const firstDayOfMonth = moment(nowDate).format('YYYY-MM-DD') + ' 00:00:00'
  265. // 月份的最后一天
  266. const lastDayOfMonth = moment(nowDate).endOf('month').format('YYYY-MM-DD') + ' 23:59:59'
  267. return { firstDay: firstDayOfMonth, lastDay: lastDayOfMonth }
  268. },
  269. // 选择月份 禁用选择当月以后日期
  270. disabledDate (current) {
  271. return current && current >= moment().endOf('day')
  272. },
  273. // 选择月份 change
  274. onChangeMonth (date, dateString) {
  275. this.monthVal = dateString
  276. if (date && dateString != '') {
  277. const timeObj = this.getMonthDetailDay(dateString)
  278. this.queryParam.beginDate = timeObj.firstDay
  279. this.queryParam.endDate = timeObj.lastDay
  280. } else {
  281. this.queryParam.beginDate = void 0
  282. this.queryParam.endDate = void 0
  283. }
  284. },
  285. // 查询
  286. handleSearch () {
  287. const _this = this
  288. this.$refs.ruleForm.validate(valid => {
  289. if (valid) {
  290. _this.$refs.table.refresh(true)
  291. } else {
  292. _this.$message.error('请选择查询月份')
  293. return false
  294. }
  295. })
  296. },
  297. // 客户名称 change
  298. custChange (val) {
  299. this.queryParam.dealerEntity.dealerName = val.name
  300. this.queryParam.customSn = val.key
  301. },
  302. // 轮胎省仓客户名称 change
  303. custProvinceChange (val) {
  304. this.queryParam.parentDealerEntity.dealerName = val.name
  305. this.queryParam.parentDealerSn = val.key
  306. },
  307. // 统计
  308. getCount (params) {
  309. tireFeeReportCount(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. areaChange (val) {
  319. this.queryParam.dealerEntity.provinceSn = val[0] ? val[0] : undefined
  320. this.queryParam.dealerEntity.citySn = val[1] ? val[1] : undefined
  321. this.queryParam.dealerEntity.districtSn = val[2] ? val[2] : undefined
  322. },
  323. // 区域分区 change
  324. subareaChange (val) {
  325. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
  326. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : ''
  327. },
  328. // 重置
  329. resetSearchForm () {
  330. this.queryParam.queryType = 'month'
  331. const timeObj = this.getMonthDetailDay()
  332. this.monthVal = moment().format('YYYY-MM')
  333. this.queryParam.beginDate = timeObj.firstDay // 开始时间
  334. this.queryParam.endDate = timeObj.lastDay// 结束时间
  335. this.queryParam.dealerEntity.provinceSn = undefined
  336. this.queryParam.dealerEntity.citySn = undefined
  337. this.queryParam.dealerEntity.districtSn = undefined
  338. this.queryParam.dealerEntity.dealerName = undefined
  339. this.queryParam.parentDealerEntity.dealerName = undefined
  340. this.queryParam.customSn = undefined
  341. this.queryParam.parentDealerSn = undefined
  342. this.queryParam.subareaArea.subareaSn = ''
  343. this.queryParam.subareaArea.subareaAreaSn = ''
  344. this.queryParam.dealerLevel = undefined
  345. this.queryParam.provinceFlag = undefined
  346. this.$refs.subarea.clearData()
  347. this.$refs.dealerSubareaScopeList.resetForm()
  348. this.$refs.provinceDealerList.resetForm()
  349. this.totalData = null
  350. this.$refs.areaList.clearData()
  351. this.$refs.table.clearTable()
  352. this.$refs.ruleForm.resetFields()
  353. },
  354. // 导出 必填判断
  355. handleExport () {
  356. const _this = this
  357. this.$refs.ruleForm.validate(valid => {
  358. if (valid) {
  359. _this.exportList()
  360. } else {
  361. _this.$message.error('请选择查询月份')
  362. return false
  363. }
  364. })
  365. },
  366. // 导出
  367. exportList () {
  368. const _this = this
  369. const params = JSON.parse(JSON.stringify(_this.queryParam))
  370. _this.exportLoading = true
  371. _this.spinning = true
  372. _this.showExport = true
  373. hdExportExcel(tireFeeListExport, params, '轮胎月度费用报表', function () {
  374. _this.exportLoading = false
  375. _this.spinning = false
  376. })
  377. },
  378. // 初始化
  379. pageInit () {
  380. this.$nextTick(() => { // 页面渲染完成后的回调
  381. this.setTableH()
  382. })
  383. },
  384. // 计算表格高度
  385. setTableH () {
  386. const tableSearchH = this.$refs.tableSearch.offsetHeight
  387. this.tableHeight = window.innerHeight - tableSearchH - 280
  388. }
  389. },
  390. mounted () {
  391. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  392. this.pageInit()
  393. }
  394. },
  395. activated () {
  396. // 如果是新页签打开,则重置当前页面
  397. if (this.$store.state.app.isNewTab) {
  398. this.pageInit()
  399. }
  400. },
  401. beforeRouteEnter (to, from, next) {
  402. next(vm => {})
  403. }
  404. }
  405. </script>
  406. <style lang="less" scoped>
  407. .monthBox{
  408. width: 100%;
  409. /deep/.ant-calendar-picker-icon{
  410. display:none !important;
  411. }
  412. /deep/.ant-calendar-picker input{
  413. text-align:center;
  414. }
  415. }
  416. </style>