incrementalSubsidyYearList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="incSubSidyYear-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="incSubSidyYear-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :rules="rules"
  12. :model="queryParam">
  13. <a-row :gutter="15" type="flex">
  14. <a-col :flex="1">
  15. <a-form-model-item prop="bizYear">
  16. <div style="display: inline;" slot="label">
  17. <a-popover placement="top">
  18. <template slot="content">
  19. <p>1、销售单(非转单)下推时间</p>
  20. <p>2、销售单(转单)转单完结时间</p>
  21. <p>3、销售退货单客服确认时间</p>
  22. </template>
  23. 查询年份 <a-icon type="question-circle" />
  24. </a-popover>
  25. </div>
  26. <a-select
  27. id="yearQueryList-time"
  28. style="width: 100%"
  29. placeholder="请选择年份"
  30. :value="queryParam.bizYear"
  31. @change="changeYear"
  32. allowClear>
  33. <a-select-option v-for="item in years" :value="item" :key="item">
  34. {{ item }}
  35. </a-select-option>
  36. </a-select>
  37. </a-form-model-item>
  38. </a-col>
  39. <a-col :flex="1">
  40. <a-form-item label="所在区域">
  41. <subarea id="incSubSidyYear-subarea" ref="subarea" @change="subareaChange"></subarea>
  42. </a-form-item>
  43. </a-col>
  44. <a-col :flex="1">
  45. <a-form-model-item label="地区">
  46. <AreaList id="incSubSidyYear-areaList" changeOnSelect ref="areaList" @change="areaChange" defValKey="id"></AreaList>
  47. </a-form-model-item>
  48. </a-col>
  49. <a-col :flex="2">
  50. <a-form-model-item label="客户名称">
  51. <custList id="incSubSidyYear-dealerName" dataAuthFlag="0" placeholder="请输入客户名称" ref="custList" @change="custChange" />
  52. </a-form-model-item>
  53. </a-col>
  54. <a-col :flex="2">
  55. <a-button
  56. type="primary"
  57. @click="handleSearch"
  58. :disabled="disabled"
  59. id="incSubSidyYear-refresh">查询</a-button>
  60. <a-button
  61. style="margin-left: 8px"
  62. @click="resetSearchForm"
  63. :disabled="disabled"
  64. id="incSubSidyYear-reset">重置</a-button>
  65. <a-button
  66. style="margin-left: 10px"
  67. type="primary"
  68. class="button-warning"
  69. @click="handleExport"
  70. :disabled="disabled"
  71. :loading="exportLoading"
  72. v-if="$hasPermissions('M_tireSubsidyExport')"
  73. id="incSubSidyYear-export">导出</a-button>
  74. </a-col>
  75. </a-row>
  76. </a-form-model>
  77. </div>
  78. </a-card>
  79. <a-card size="small" :bordered="false">
  80. <a-spin :spinning="spinning" tip="Loading...">
  81. <!-- 列表 -->
  82. <s-table
  83. class="sTable fixPagination"
  84. ref="table"
  85. size="small"
  86. :rowKey="(record) => record.no"
  87. rowKeyName="no"
  88. :style="{ height: tableHeight+20+'px' }"
  89. :columns="columns"
  90. :data="loadData"
  91. :scroll="{ y: tableHeight-80}"
  92. :pageSize="50"
  93. :pagination="{pageSizeOptions: ['20','50','100','200','500']}"
  94. :defaultLoadData="false"
  95. bordered>
  96. <template slot="footer">
  97. <a-row :gutter="15">
  98. <a-col :md="4" :sm="24">增量已贴金额:{{ (totalData && (totalData.settleAmountFinish || totalData.settleAmountFinish==0)) ? toThousands(totalData.settleAmountFinish): '--' }}</a-col>
  99. <a-col :md="4" :sm="24">剩余增量补贴金额:{{ (totalData && (totalData.settleAmountWait || totalData.settleAmountWait==0)) ? toThousands(totalData.settleAmountWait): '--' }}</a-col>
  100. </a-row>
  101. </template>
  102. </s-table>
  103. </a-spin>
  104. </a-card>
  105. </div>
  106. </template>
  107. <script>
  108. import { commonMixin } from '@/utils/mixin'
  109. import { hdExportExcel } from '@/libs/exportExcel'
  110. import moment from 'moment'
  111. // 组件
  112. import { STable, VSelect } from '@/components'
  113. import subarea from '@/views/common/subarea.js'
  114. import AreaList from '@/views/common/areaList.js'
  115. import custList from '@/views/common/custList.vue'
  116. // 接口
  117. import { subsidyStepList, subsidyStepCount, subsidyStepExport } from '@/api/reportData'
  118. export default {
  119. name: 'QuarterQueryList',
  120. mixins: [commonMixin],
  121. components: { STable, VSelect, subarea, AreaList, custList },
  122. data () {
  123. return {
  124. spinning: false,
  125. disabled: false, // 查询、重置按钮是否可操作
  126. advanced: false, // 高级搜索 展开/关闭
  127. tableHeight: 0, // 表格高度
  128. exportLoading: false, // 导出按钮加载状态
  129. toYears: new Date().getFullYear(), // 今年
  130. // 查询条件
  131. queryParam: {
  132. subsidyType: 'YEAR', // 轮胎年度费用报表
  133. bizYear: moment().year(), // 选择年份
  134. subareaArea: {
  135. subareaSn: '', // 区域
  136. subareaAreaSn: '' // 分区
  137. },
  138. customSn: undefined, // 客户sn
  139. dealer: {
  140. dealerName: undefined, // 客户名称
  141. provinceSn: undefined, // 省
  142. citySn: undefined, // 市
  143. districtSn: undefined // 区
  144. }
  145. },
  146. totalData: null, // 合计
  147. rules: {
  148. 'bizYear': [{ required: true, message: '请选择查询年份', trigger: 'change' }]
  149. },
  150. // 加载数据方法 必须为 Promise 对象
  151. loadData: parameter => {
  152. this.disabled = true
  153. this.spinning = true
  154. const params = Object.assign(parameter, this.queryParam)
  155. // 获取列表数据 有分页
  156. return subsidyStepList(params).then(res => {
  157. let data
  158. if (res.status == 200) {
  159. data = res.data
  160. // 计算表格序号
  161. const no = (data.pageNo - 1) * data.pageSize
  162. for (var i = 0; i < data.list.length; i++) {
  163. data.list[i].no = no + i + 1
  164. }
  165. this.disabled = false
  166. // 获取统计数据
  167. this.getCount(params)
  168. }
  169. this.spinning = false
  170. return data
  171. })
  172. }
  173. }
  174. },
  175. watch: {
  176. advanced (newValue, oldValue) {
  177. const _this = this
  178. this.$nextTick(() => { // 页面渲染完成后的回调
  179. _this.setTableH()
  180. })
  181. },
  182. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  183. this.setTableH()
  184. }
  185. },
  186. computed: {
  187. // 获取年份数据
  188. years () {
  189. const years = []
  190. const lens = (this.toYears - 2023) + 1
  191. for (let i = 0; i < lens; i++) {
  192. years.push(this.toYears - i)
  193. }
  194. return years
  195. },
  196. columns () {
  197. const _this = this
  198. const arr = [
  199. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  200. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  201. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  202. { title: '省份', dataIndex: 'provinceName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  203. { title: '客户名称', dataIndex: 'dealerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  204. { title: '总部订货数量', dataIndex: 'salesQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. { title: '转单订货数量', dataIndex: 'transferQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. { title: '总部退货数量', dataIndex: 'returnQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  207. { title: '合计订货数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  208. { title: '年度目标', dataIndex: 'subsidyTarget', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  209. { title: '年度增量补贴', dataIndex: 'subsidyValue', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  210. { title: '增量补贴金额', dataIndex: 'subsidyAmount', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  211. { title: '增量已补金额', dataIndex: 'settleAmountFinish', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  212. { title: '剩余增量补贴金额', dataIndex: 'settleAmountWait', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } }
  213. ]
  214. return arr
  215. }
  216. },
  217. methods: {
  218. // 选择查询年份 change
  219. changeYear (val) {
  220. if (!val) {
  221. this.queryParam.bizYear = void 0
  222. } else {
  223. this.queryParam.bizYear = val
  224. }
  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.dealerName = val.name
  241. this.queryParam.belongDealerSn = val.key
  242. },
  243. // 统计
  244. getCount (params) {
  245. subsidyStepCount(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.dealer.provinceSn = val[0] ? val[0] : undefined
  256. this.queryParam.dealer.citySn = val[1] ? val[1] : undefined
  257. this.queryParam.dealer.districtSn = val[2] ? val[2] : undefined
  258. },
  259. // 区域分区 change
  260. subareaChange (val) {
  261. this.queryParam.subareaArea.subareaSn = val[0] ? val[0] : ''
  262. this.queryParam.subareaArea.subareaAreaSn = val[1] ? val[1] : ''
  263. },
  264. // 重置
  265. resetSearchForm () {
  266. this.queryParam.subsidyType = 'YEAR'
  267. this.queryParam.bizYear = moment().year()
  268. this.queryParam.dealer.provinceSn = undefined
  269. this.queryParam.dealer.citySn = undefined
  270. this.queryParam.dealer.districtSn = undefined
  271. this.queryParam.dealerName = undefined
  272. this.queryParam.belongDealerSn = undefined
  273. this.queryParam.subareaArea.subareaSn = ''
  274. this.queryParam.subareaArea.subareaAreaSn = ''
  275. this.$refs.subarea.clearData()
  276. this.$refs.custList.resetForm()
  277. this.totalData = null
  278. this.$refs.areaList.clearData()
  279. this.$refs.table.clearTable()
  280. this.$refs.ruleForm.resetFields()
  281. },
  282. // 导出 必填判断
  283. handleExport () {
  284. const _this = this
  285. this.$refs.ruleForm.validate(valid => {
  286. if (valid) {
  287. _this.exportList()
  288. } else {
  289. _this.$message.error('请选择查询年度')
  290. return false
  291. }
  292. })
  293. },
  294. // 导出
  295. exportList () {
  296. const _this = this
  297. _this.exportLoading = true
  298. _this.spinning = true
  299. hdExportExcel(subsidyStepExport, _this.queryParam, '增量补贴报表(' + this.queryParam.bizYear + '年度)-', function () {
  300. _this.exportLoading = false
  301. _this.spinning = false
  302. })
  303. },
  304. // 初始化
  305. pageInit () {
  306. this.$nextTick(() => { // 页面渲染完成后的回调
  307. this.setTableH()
  308. })
  309. this.resetSearchForm()
  310. },
  311. // 计算表格高度
  312. setTableH () {
  313. const tableSearchH = this.$refs.tableSearch.offsetHeight
  314. this.tableHeight = window.innerHeight - tableSearchH - 230
  315. }
  316. },
  317. mounted () {
  318. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  319. this.pageInit()
  320. }
  321. },
  322. activated () {
  323. // 如果是新页签打开,则重置当前页面
  324. if (this.$store.state.app.isNewTab) {
  325. this.pageInit()
  326. }
  327. }
  328. }
  329. </script>