yearQueryList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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. <span v-if="record.dealerEntity&&record.dealerEntity.provinceName">
  104. {{ record.dealerEntity.provinceName }}{{ '/'+record.dealerEntity.cityName }}{{ '/'+record.dealerEntity.districtName }}
  105. </span>
  106. <span v-else>--</span>
  107. </template>
  108. <template slot="footer">
  109. <a-row :gutter="15">
  110. <a-col :md="4" :sm="24">平台出库数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty: '--' }}</a-col>
  111. <a-col :md="4" :sm="24">平台返利点数:{{ (totalData && (totalData.rebatePointsSys || totalData.rebatePointsSys==0)) ? (totalData.rebatePointsSys*100).toFixed(2)+'%': '--' }}</a-col>
  112. <a-col :md="4" :sm="24">开单金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? toThousands(totalData.outAmount): '--' }}</a-col>
  113. <a-col :md="4" :sm="24">平台返利金额:{{ (totalData && (totalData.rebateAmountSys || totalData.rebateAmountSys==0)) ? toThousands(totalData.rebateAmountSys): '--' }}</a-col>
  114. <a-col :md="4" :sm="24">轮胎省仓返利金额:{{ (totalData && (totalData.rebateAmountProvince || totalData.rebateAmountProvince==0)) ? toThousands(totalData.rebateAmountProvince): '--' }}</a-col>
  115. </a-row>
  116. </template>
  117. </s-table>
  118. </a-spin>
  119. </a-card>
  120. <!-- 导出提示框 -->
  121. <reportModal :visible="showExport" @close="showExport=false"></reportModal>
  122. </div>
  123. </template>
  124. <script>
  125. import { commonMixin } from '@/utils/mixin'
  126. import { hdExportExcel } from '@/libs/exportExcel'
  127. import moment from 'moment'
  128. // 组件
  129. import { STable, VSelect } from '@/components'
  130. import subarea from '@/views/common/subarea.js'
  131. import AreaList from '@/views/common/areaList.js'
  132. import reportModal from '@/views/common/reportModal.vue'
  133. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  134. // 接口
  135. import { tireFeeReportList, tireFeeReportCount, tireFeeListExport } from '@/api/reportData'
  136. export default {
  137. name: 'YearQueryList',
  138. mixins: [commonMixin],
  139. components: { STable, VSelect, subarea, AreaList, dealerSubareaScopeList, reportModal },
  140. data () {
  141. return {
  142. spinning: false,
  143. disabled: false, // 查询、重置按钮是否可操作
  144. advanced: true, // 高级搜索 展开/关闭
  145. tableHeight: 0, // 表格高度
  146. exportLoading: false, // 导出按钮加载状态
  147. showExport: false, // 导出弹窗
  148. toYears: new Date().getFullYear(), // 今年
  149. // 查询条件
  150. queryParam: {
  151. queryType: 'year', // 轮胎年度费用报表
  152. queryDate: moment().year(), // 选择年份
  153. dealerLevel: undefined, // 客户等级
  154. customSn: undefined, // 客户sn
  155. subareaArea: {
  156. subareaSn: '', // 区域
  157. subareaAreaSn: '' // 分区
  158. },
  159. dealerEntity: {
  160. dealerName: undefined, // 客户名称
  161. provinceSn: undefined, // 省
  162. citySn: undefined, // 市
  163. districtSn: undefined // 区
  164. },
  165. provinceFlag: '1'// 是轮胎省仓
  166. },
  167. totalData: null, // 合计
  168. yearInfo: '',
  169. showOutDetail: false, // 出库明细弹窗
  170. rules: {
  171. 'queryDate': [{ required: true, message: '请选择查询年份', trigger: 'change' }]
  172. },
  173. // 加载数据方法 必须为 Promise 对象
  174. loadData: parameter => {
  175. this.disabled = true
  176. this.spinning = true
  177. const oldParams = Object.assign(parameter, this.queryParam)
  178. const params = JSON.parse(JSON.stringify(oldParams))
  179. // 获取列表数据 有分页
  180. return tireFeeReportList(params).then(res => {
  181. let data
  182. if (res.status == 200) {
  183. data = res.data
  184. // 计算表格序号
  185. const no = (data.pageNo - 1) * data.pageSize
  186. for (var i = 0; i < data.list.length; i++) {
  187. data.list[i].no = no + i + 1
  188. }
  189. this.disabled = false
  190. // 获取统计数据
  191. this.getCount(params)
  192. }
  193. this.spinning = false
  194. return data
  195. })
  196. }
  197. }
  198. },
  199. watch: {
  200. advanced (newValue, oldValue) {
  201. const _this = this
  202. this.$nextTick(() => { // 页面渲染完成后的回调
  203. _this.setTableH()
  204. })
  205. },
  206. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  207. this.setTableH()
  208. }
  209. },
  210. computed: {
  211. // 获取年份数据
  212. years () {
  213. const years = []
  214. const lens = (this.toYears - 2023) + 1
  215. for (let i = 0; i < lens; i++) {
  216. years.push(this.toYears - i)
  217. }
  218. return years
  219. },
  220. columns () {
  221. const _this = this
  222. const arr = [
  223. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  224. { title: '地区', scopedSlots: { customRender: 'addressInfo' }, width: '15%', align: 'center' },
  225. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  226. { title: '客户名称', dataIndex: 'dealerEntity.dealerName', width: '18%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  227. { title: '客户级别', dataIndex: 'dealerEntity.dealerLevelDictValue', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  228. { 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 : '--') } },
  229. { title: '开单金额', dataIndex: 'outAmount', width: '13%', align: 'right', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  230. { title: '轮胎省仓返利点数', dataIndex: 'rebatePointProvince', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? (text * 100).toFixed(2) + '%' : '--') } },
  231. { title: '轮胎省仓返利金额', dataIndex: 'rebateAmountProvince', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  232. ]
  233. return arr
  234. }
  235. },
  236. methods: {
  237. // 选择查询年份 change
  238. changeYear (val) {
  239. if (!val) {
  240. this.queryParam.queryDate = void 0
  241. } else {
  242. this.queryParam.queryDate = val
  243. }
  244. },
  245. // 查询
  246. handleSearch () {
  247. const _this = this
  248. this.$refs.ruleForm.validate(valid => {
  249. if (valid) {
  250. _this.$refs.table.refresh(true)
  251. } else {
  252. _this.$message.error('请选择查询年份')
  253. return false
  254. }
  255. })
  256. },
  257. // 客户名称 change
  258. custChange (val) {
  259. this.queryParam.dealerEntity.dealerName = val.name
  260. this.queryParam.customSn = val.key
  261. },
  262. // 统计
  263. getCount (params) {
  264. tireFeeReportCount(params).then(res => {
  265. if (res.status == 200 && res.data) {
  266. this.totalData = res.data
  267. } else {
  268. this.totalData = null
  269. }
  270. })
  271. },
  272. // 地区
  273. areaChange (val) {
  274. this.queryParam.dealerEntity.provinceSn = val[0] ? val[0] : undefined
  275. this.queryParam.dealerEntity.citySn = val[1] ? val[1] : undefined
  276. this.queryParam.dealerEntity.districtSn = val[2] ? val[2] : undefined
  277. },
  278. // 区域分区 change
  279. subareaChange (val) {
  280. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
  281. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : ''
  282. },
  283. // 重置
  284. resetSearchForm () {
  285. this.queryParam.queryType = 'year'
  286. const nowYear = moment().year()
  287. this.queryParam.queryDate = nowYear
  288. this.queryParam.dealerEntity.provinceSn = undefined
  289. this.queryParam.dealerEntity.citySn = undefined
  290. this.queryParam.dealerEntity.districtSn = undefined
  291. this.queryParam.dealerEntity.dealerName = undefined
  292. this.queryParam.customSn = undefined
  293. this.queryParam.subareaArea.subareaSn = ''
  294. this.queryParam.subareaArea.subareaAreaSn = ''
  295. this.queryParam.dealerLevel = undefined
  296. this.$refs.subarea.clearData()
  297. this.$refs.areaList.clearData()
  298. if (this.advanced) {
  299. this.$refs.dealerSubareaScopeList.resetForm()
  300. }
  301. this.totalData = null
  302. this.$refs.table.clearTable()
  303. this.$refs.ruleForm.resetFields()
  304. },
  305. // 导出 必填判断
  306. handleExport () {
  307. const _this = this
  308. this.$refs.ruleForm.validate(valid => {
  309. if (valid) {
  310. _this.exportList()
  311. } else {
  312. _this.$message.error('请选择查询年份')
  313. return false
  314. }
  315. })
  316. },
  317. // 导出
  318. exportList () {
  319. const _this = this
  320. const params = JSON.parse(JSON.stringify(_this.queryParam))
  321. _this.exportLoading = true
  322. _this.spinning = true
  323. _this.showExport = true
  324. hdExportExcel(tireFeeListExport, params, '轮胎年度费用报表', function () {
  325. _this.exportLoading = false
  326. _this.spinning = false
  327. })
  328. },
  329. // 初始化
  330. pageInit () {
  331. this.$nextTick(() => { // 页面渲染完成后的回调
  332. this.setTableH()
  333. })
  334. this.resetSearchForm()
  335. },
  336. // 计算表格高度
  337. setTableH () {
  338. const tableSearchH = this.$refs.tableSearch.offsetHeight
  339. this.tableHeight = window.innerHeight - tableSearchH - 280
  340. }
  341. },
  342. mounted () {
  343. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  344. this.pageInit()
  345. }
  346. },
  347. activated () {
  348. // 如果是新页签打开,则重置当前页面
  349. if (this.$store.state.app.isNewTab) {
  350. this.pageInit()
  351. }
  352. }
  353. }
  354. </script>