quarterQueryList.vue 13 KB

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