quarterQueryList.vue 14 KB

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