yearQueryList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="yearQueryList-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="yearQueryList-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="queryDate">
  16. <a-select
  17. id="yearQueryList-time"
  18. style="width: 100%"
  19. placeholder="请选择年份"
  20. :value="queryParam.queryDate"
  21. @change="changeYear"
  22. allowClear>
  23. <a-select-option v-for="item in years" :value="item" :key="item">
  24. {{ item }}
  25. </a-select-option>
  26. </a-select>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-model-item label="地区">
  31. <AreaList id="yearQueryList-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="区域/分区">
  36. <subarea id="yearQueryList-subarea" ref="subarea" @change="subareaChange"></subarea>
  37. </a-form-item>
  38. </a-col>
  39. <template v-if="advanced">
  40. <a-col :md="6" :sm="24">
  41. <a-form-model-item label="客户名称">
  42. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="yearQueryList-dealerName" @change="custChange" />
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="客户级别">
  47. <v-select
  48. v-model="queryParam.dealerLevel"
  49. ref="dealerLevel"
  50. id="yearQueryList-dealerLevel"
  51. code="DEALER_LEVEL"
  52. placeholder="请选择客户级别"
  53. allowClear></v-select>
  54. </a-form-model-item>
  55. </a-col>
  56. </template>
  57. <a-col :md="6" :sm="24">
  58. <a-button
  59. type="primary"
  60. @click="handleSearch"
  61. :disabled="disabled"
  62. id="yearQueryList-refresh">查询</a-button>
  63. <a-button
  64. style="margin-left: 8px"
  65. @click="resetSearchForm"
  66. :disabled="disabled"
  67. id="yearQueryList-reset">重置</a-button>
  68. <a-button
  69. style="margin-left: 10px"
  70. type="primary"
  71. class="button-warning"
  72. @click="handleExport"
  73. :disabled="disabled"
  74. :loading="exportLoading"
  75. v-if="$hasPermissions('B_tireFeeExport')"
  76. id="yearQueryList-export">导出</a-button>
  77. <a @click="advanced=!advanced" style="margin-left: 5px">
  78. {{ advanced ? '收起' : '展开' }}
  79. <a-icon :type="advanced ? 'up' : 'down'" />
  80. </a>
  81. </a-col>
  82. </a-row>
  83. </a-form-model>
  84. </div>
  85. </a-card>
  86. <a-card size="small" :bordered="false">
  87. <a-spin :spinning="spinning" tip="Loading...">
  88. <!-- 列表 -->
  89. <s-table
  90. class="sTable fixPagination"
  91. ref="table"
  92. size="small"
  93. :rowKey="(record) => record.no"
  94. rowKeyName="no"
  95. :style="{ height: tableHeight+70+'px' }"
  96. :columns="columns"
  97. :data="loadData"
  98. :scroll="{ y: tableHeight-120}"
  99. :defaultLoadData="false"
  100. bordered>
  101. <!-- 地区 -->
  102. <template slot="addressInfo" slot-scope="text, record">
  103. {{ record.dealerEntity.provinceName }}{{ '/'+record.dealerEntity.cityName }}{{ '/'+record.dealerEntity.districtName }}
  104. </template>
  105. <template slot="footer">
  106. <a-row :gutter="15">
  107. <a-col :md="4" :sm="24">轮胎省仓返利金额:{{ (totalData && (totalData.rebateAmountProvince || totalData.rebateAmountProvince==0)) ? toThousands(totalData.rebateAmountProvince): '--' }}</a-col>
  108. <a-col :md="4" :sm="24">平台出库数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty: '--' }}</a-col>
  109. <a-col :md="4" :sm="24">平台返利点数:{{ (totalData && (totalData.rebatePointsSys || totalData.rebatePointsSys==0)) ? (totalData.rebatePointsSys*100).toFixed(2)+'%': '--' }}</a-col>
  110. <a-col :md="4" :sm="24">开单金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount): '--' }}</a-col>
  111. <a-col :md="4" :sm="24">平台返利金额:{{ (totalData && (totalData.rebateAmountSys || totalData.rebateAmountSys==0)) ? toThousands(totalData.rebateAmountSys): '--' }}</a-col>
  112. </a-row>
  113. </template>
  114. </s-table>
  115. </a-spin>
  116. </a-card>
  117. <!-- 导出提示框 -->
  118. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  119. </div>
  120. </template>
  121. <script>
  122. import { commonMixin } from '@/utils/mixin'
  123. import { hdExportExcel } from '@/libs/exportExcel'
  124. import moment from 'moment'
  125. // 组件
  126. import { STable, VSelect } from '@/components'
  127. import subarea from '@/views/common/subarea.js'
  128. import AreaList from '@/views/common/areaList.js'
  129. import reportModal from '@/views/common/reportModal.vue'
  130. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  131. // 接口
  132. import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
  133. export default {
  134. name: 'YearQueryList',
  135. mixins: [commonMixin],
  136. components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, reportModal },
  137. data () {
  138. return {
  139. spinning: false,
  140. disabled: false, // 查询、重置按钮是否可操作
  141. advanced: true, // 高级搜索 展开/关闭
  142. tableHeight: 0, // 表格高度
  143. exportLoading: false, // 导出按钮加载状态
  144. showExport: false, // 导出弹窗
  145. toYears: new Date().getFullYear(), // 今年
  146. // 查询条件
  147. queryParam: {
  148. queryType: 'year', // 轮胎年度费用报表
  149. queryDate: moment().year(), // 选择年份
  150. dealerLevel: undefined, // 客户等级
  151. customSn: undefined, // 客户sn
  152. subareaArea: {
  153. subareaSn: '', // 区域
  154. subareaAreaSn: '' // 分区
  155. },
  156. dealerEntity: {
  157. dealerName: undefined, // 客户名称
  158. provinceSn: undefined, // 省
  159. citySn: undefined, // 市
  160. districtSn: undefined // 区
  161. },
  162. provinceFlag: '1'// 是轮胎省仓
  163. },
  164. totalData: null, // 合计
  165. yearInfo: '',
  166. showOutDetail: false, // 出库明细弹窗
  167. rules: {
  168. 'queryDate': [{ required: true, message: '请选择查询年份', trigger: 'change' }]
  169. },
  170. // 加载数据方法 必须为 Promise 对象
  171. loadData: parameter => {
  172. this.disabled = true
  173. this.spinning = true
  174. const oldParams = Object.assign(parameter, this.queryParam)
  175. const params = JSON.parse(JSON.stringify(oldParams))
  176. // 获取列表数据 有分页
  177. return tireFeeReportList(params).then(res => {
  178. let data
  179. if (res.status == 200) {
  180. data = res.data
  181. // 计算表格序号
  182. const no = (data.pageNo - 1) * data.pageSize
  183. for (var i = 0; i < data.list.length; i++) {
  184. data.list[i].no = no + i + 1
  185. }
  186. this.disabled = false
  187. // 获取统计数据
  188. this.getCount(params)
  189. }
  190. this.spinning = false
  191. return data
  192. })
  193. }
  194. }
  195. },
  196. watch: {
  197. advanced (newValue, oldValue) {
  198. const _this = this
  199. this.$nextTick(() => { // 页面渲染完成后的回调
  200. _this.setTableH()
  201. })
  202. },
  203. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  204. this.setTableH()
  205. }
  206. },
  207. computed: {
  208. // 获取年份数据
  209. years () {
  210. const years = []
  211. const lens = (this.toYears - 2023) + 1
  212. for (let i = 0; i < lens; i++) {
  213. years.push(this.toYears - i)
  214. }
  215. return years
  216. },
  217. columns () {
  218. const _this = this
  219. const arr = [
  220. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  221. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '15%', align: 'center' },
  222. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  223. { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  224. { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  225. { title: <a-tooltip placement='top' title='平台销售给该轮胎省仓及轮胎省仓差价绑定的加盟商的数量合计'>平台出库数量&nbsp;<a-icon type="question-circle" /></a-tooltip>, dataIndex: 'outQty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. { title: '开单金额', dataIndex: 'outAmount', width: '13%', align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '轮胎省仓返利点数', dataIndex: 'rebatePointProvince', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? (text * 100) + '%' : '--') } },
  228. { title: '轮胎省仓返利金额', dataIndex: 'rebateAmountProvince', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  229. ]
  230. return arr
  231. }
  232. },
  233. methods: {
  234. // 选择查询年份 change
  235. changeYear (val) {
  236. if (!val) {
  237. this.queryParam.queryDate = void 0
  238. } else {
  239. this.queryParam.queryDate = val
  240. }
  241. },
  242. // 查询
  243. handleSearch () {
  244. const _this = this
  245. this.$refs.ruleForm.validate(valid => {
  246. if (valid) {
  247. _this.$refs.table.refresh(true)
  248. } else {
  249. _this.$message.error('请选择查询年份')
  250. return false
  251. }
  252. })
  253. },
  254. // 客户名称 change
  255. custChange (val) {
  256. this.queryParam.dealerEntity.dealerName = val.name
  257. this.queryParam.customSn = val.key
  258. },
  259. // 统计
  260. getCount (params) {
  261. tireFeeReportCount(params).then(res => {
  262. if (res.status == 200 && res.data) {
  263. this.totalData = res.data
  264. } else {
  265. this.totalData = null
  266. }
  267. })
  268. },
  269. // 地区
  270. areaChange (val) {
  271. this.queryParam.dealerEntity.provinceSn = val[0] ? val[0] : undefined
  272. this.queryParam.dealerEntity.citySn = val[1] ? val[1] : undefined
  273. this.queryParam.dealerEntity.districtSn = val[2] ? val[2] : undefined
  274. },
  275. // 区域分区 change
  276. subareaChange (val) {
  277. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
  278. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : ''
  279. },
  280. // 重置
  281. resetSearchForm () {
  282. this.queryParam.queryType = 'year'
  283. const lastYear = moment().year()
  284. this.queryParam.queryDate = lastYear
  285. this.queryParam.dealerEntity.provinceSn = undefined
  286. this.queryParam.dealerEntity.citySn = undefined
  287. this.queryParam.dealerEntity.districtSn = undefined
  288. this.queryParam.dealerEntity.dealerName = undefined
  289. this.queryParam.customSn = undefined
  290. this.queryParam.subareaArea.subareaSn = ''
  291. this.queryParam.subareaArea.subareaAreaSn = ''
  292. this.queryParam.dealerLevel = undefined
  293. this.$refs.subarea.clearData()
  294. this.$refs.areaList.clearData()
  295. if (this.advanced) {
  296. this.$refs.dealerSubareaScopeList.resetForm()
  297. }
  298. this.totalData = null
  299. this.$refs.table.clearTable()
  300. this.$refs.ruleForm.resetFields()
  301. },
  302. // 导出 必填判断
  303. handleExport () {
  304. const _this = this
  305. this.$refs.ruleForm.validate(valid => {
  306. if (valid) {
  307. _this.exportList()
  308. } else {
  309. _this.$message.error('请选择查询年份')
  310. return false
  311. }
  312. })
  313. },
  314. // 导出
  315. exportList () {
  316. const _this = this
  317. const params = JSON.parse(JSON.stringify(_this.queryParam))
  318. _this.exportLoading = true
  319. _this.spinning = true
  320. _this.showExport = true
  321. hdExportExcel(tireFeeListExport, params, '轮胎年度费用报表', function () {
  322. _this.exportLoading = false
  323. _this.spinning = false
  324. })
  325. },
  326. // 初始化
  327. pageInit () {
  328. this.$nextTick(() => { // 页面渲染完成后的回调
  329. this.setTableH()
  330. })
  331. },
  332. // 计算表格高度
  333. setTableH () {
  334. const tableSearchH = this.$refs.tableSearch.offsetHeight
  335. this.tableHeight = window.innerHeight - tableSearchH - 280
  336. }
  337. },
  338. mounted () {
  339. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  340. this.pageInit()
  341. }
  342. },
  343. activated () {
  344. // 如果是新页签打开,则重置当前页面
  345. if (this.$store.state.app.isNewTab) {
  346. this.pageInit()
  347. }
  348. },
  349. beforeRouteEnter (to, from, next) {
  350. next(vm => {})
  351. }
  352. }
  353. </script>