incrementalSubsidyYearList.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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="30"
  93. :defaultLoadData="false"
  94. bordered>
  95. <!-- 季度增量补贴金额 -->
  96. <template slot="subsidyAmount" slot-scope="text, record">
  97. <span v-if="record.subsidyAmount||record.subsidyAmount==0">
  98. <span v-if="record.subsidyAmount>=0">{{ toThousands(record.subsidyAmount) }}</span>
  99. <span style="color:#ED1C24;" v-else>{{ toThousands(record.subsidyAmount) }}</span>
  100. </span>
  101. <span v-else>--</span>
  102. </template>
  103. <!-- 剩余增量补贴金额 -->
  104. <template slot="settleAmountWait" slot-scope="text, record">
  105. <span v-if="record.settleAmountWait||record.settleAmountWait==0">
  106. <span style="color:#ED1C24;" v-if="record.settleAmountWait>0">{{ toThousands(record.settleAmountWait) }}</span>
  107. <span v-else>{{ toThousands(record.settleAmountWait) }}</span>
  108. </span>
  109. <span v-else>--</span>
  110. </template>
  111. <!-- 统计 -->
  112. <template slot="footer">
  113. <a-row :gutter="15">
  114. <a-col :md="4" :sm="24">总部合计数量:{{ (totalData && (totalData.settleAmountFinish || totalData.settleAmountFinish==0)) ? toThousands(totalData.settleAmountFinish): '--' }}</a-col>
  115. <a-col :md="4" :sm="24">合计订货数量:{{ (totalData && (totalData.totalQty || totalData.totalQty==0)) ? toThousands(totalData.totalQty): '--' }}</a-col>
  116. <a-col :md="4" :sm="24">增量已贴金额:{{ (totalData && (totalData.settleAmountFinish || totalData.settleAmountFinish==0)) ? toThousands(totalData.settleAmountFinish): '--' }}</a-col>
  117. <a-col :md="4" :sm="24">剩余增量补贴金额:{{ (totalData && (totalData.settleAmountWait || totalData.settleAmountWait==0)) ? toThousands(totalData.settleAmountWait): '--' }}</a-col>
  118. </a-row>
  119. </template>
  120. </s-table>
  121. </a-spin>
  122. </a-card>
  123. </div>
  124. </template>
  125. <script>
  126. import { commonMixin } from '@/utils/mixin'
  127. import { hdExportExcel } from '@/libs/exportExcel'
  128. import moment from 'moment'
  129. // 组件
  130. import { STable, VSelect } from '@/components'
  131. import subarea from '@/views/common/subarea.js'
  132. import AreaList from '@/views/common/areaList.js'
  133. import custList from '@/views/common/custList.vue'
  134. // 接口
  135. import { subsidyStepList, subsidyStepCount, subsidyStepExport } from '@/api/reportData'
  136. export default {
  137. name: 'QuarterQueryList',
  138. mixins: [commonMixin],
  139. components: { STable, VSelect, subarea, AreaList, custList },
  140. data () {
  141. return {
  142. spinning: false,
  143. disabled: false, // 查询、重置按钮是否可操作
  144. advanced: false, // 高级搜索 展开/关闭
  145. tableHeight: 0, // 表格高度
  146. exportLoading: false, // 导出按钮加载状态
  147. toYears: new Date().getFullYear(), // 今年
  148. // 查询条件
  149. queryParam: {
  150. subsidyType: 'YEAR', // 轮胎年度费用报表
  151. bizYear: moment().year(), // 选择年份
  152. subareaArea: {
  153. subareaSn: '', // 区域
  154. subareaAreaSn: '' // 分区
  155. },
  156. customSn: undefined, // 客户sn
  157. dealer: {
  158. dealerName: undefined, // 客户名称
  159. provinceSn: undefined, // 省
  160. citySn: undefined, // 市
  161. districtSn: undefined // 区
  162. }
  163. },
  164. totalData: null, // 合计
  165. rules: {
  166. 'bizYear': [{ required: true, message: '请选择查询年份', trigger: 'change' }]
  167. },
  168. // 加载数据方法 必须为 Promise 对象
  169. loadData: parameter => {
  170. this.disabled = true
  171. this.spinning = true
  172. const params = Object.assign(parameter, this.queryParam)
  173. // 获取列表数据 有分页
  174. return subsidyStepList(params).then(res => {
  175. let data
  176. if (res.status == 200) {
  177. data = res.data
  178. // 计算表格序号
  179. const no = (data.pageNo - 1) * data.pageSize
  180. for (var i = 0; i < data.list.length; i++) {
  181. data.list[i].no = no + i + 1
  182. }
  183. this.disabled = false
  184. // 获取统计数据
  185. this.getCount(params)
  186. }
  187. this.spinning = false
  188. return data
  189. })
  190. }
  191. }
  192. },
  193. watch: {
  194. advanced (newValue, oldValue) {
  195. const _this = this
  196. this.$nextTick(() => { // 页面渲染完成后的回调
  197. _this.setTableH()
  198. })
  199. },
  200. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  201. this.setTableH()
  202. }
  203. },
  204. computed: {
  205. // 获取年份数据
  206. years () {
  207. const years = []
  208. const lens = (this.toYears - 2023) + 1
  209. for (let i = 0; i < lens; i++) {
  210. years.push(this.toYears - i)
  211. }
  212. return years
  213. },
  214. columns () {
  215. const _this = this
  216. const arr = [
  217. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  218. { title: '区域', dataIndex: 'subareaArea.subareaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '分区', dataIndex: 'subareaArea.subareaAreaName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  220. { title: '省份', dataIndex: 'provinceName', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  221. { title: '客户名称', dataIndex: 'dealerName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  222. { title: '总部订货数量', dataIndex: 'salesQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. { title: '总部退货数量', dataIndex: 'returnQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. { title: '总部合计数量', dataIndex: 'transferQty1', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. { title: '转单订货数量', dataIndex: 'transferQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  226. { title: '合计订货数量', dataIndex: 'totalQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  227. { title: '年度目标', dataIndex: 'subsidyTarget', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  228. { title: '年度增量补贴', dataIndex: 'subsidyValue', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  229. { title: '增量补贴金额', dataIndex: 'subsidyAmount', width: '10%', align: 'right', scopedSlots: { customRender: 'subsidyAmount' } },
  230. { title: '增量已补金额', dataIndex: 'settleAmountFinish', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  231. { title: '剩余增量补贴金额', dataIndex: 'settleAmountWait', width: '10%', align: 'right', scopedSlots: { customRender: 'settleAmountWait' } }
  232. ]
  233. return arr
  234. }
  235. },
  236. methods: {
  237. // 选择查询年份 change
  238. changeYear (val) {
  239. if (!val) {
  240. this.queryParam.bizYear = void 0
  241. } else {
  242. this.queryParam.bizYear = 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.dealerName = val.name
  260. this.queryParam.belongDealerSn = val.key
  261. },
  262. // 统计
  263. getCount (params) {
  264. subsidyStepCount(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.dealer.provinceSn = val[0] ? val[0] : undefined
  275. this.queryParam.dealer.citySn = val[1] ? val[1] : undefined
  276. this.queryParam.dealer.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.subsidyType = 'YEAR'
  286. this.queryParam.bizYear = moment().year()
  287. this.queryParam.dealer.provinceSn = undefined
  288. this.queryParam.dealer.citySn = undefined
  289. this.queryParam.dealer.districtSn = undefined
  290. this.queryParam.dealerName = undefined
  291. this.queryParam.belongDealerSn = undefined
  292. this.queryParam.subareaArea.subareaSn = ''
  293. this.queryParam.subareaArea.subareaAreaSn = ''
  294. this.$refs.subarea.clearData()
  295. this.$refs.custList.resetForm()
  296. this.totalData = null
  297. this.$refs.areaList.clearData()
  298. this.$refs.table.clearTable()
  299. this.$refs.ruleForm.resetFields()
  300. },
  301. // 导出 必填判断
  302. handleExport () {
  303. const _this = this
  304. this.$refs.ruleForm.validate(valid => {
  305. if (valid) {
  306. _this.exportList()
  307. } else {
  308. _this.$message.error('请选择查询年度')
  309. return false
  310. }
  311. })
  312. },
  313. // 导出
  314. exportList () {
  315. const _this = this
  316. _this.exportLoading = true
  317. _this.spinning = true
  318. hdExportExcel(subsidyStepExport, _this.queryParam, '增量补贴报表(' + this.queryParam.bizYear + '年度)-', function () {
  319. _this.exportLoading = false
  320. _this.spinning = false
  321. })
  322. },
  323. // 初始化
  324. pageInit () {
  325. this.$nextTick(() => { // 页面渲染完成后的回调
  326. this.setTableH()
  327. })
  328. this.resetSearchForm()
  329. },
  330. // 计算表格高度
  331. setTableH () {
  332. const tableSearchH = this.$refs.tableSearch.offsetHeight
  333. this.tableHeight = window.innerHeight - tableSearchH - 230
  334. }
  335. },
  336. mounted () {
  337. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  338. this.pageInit()
  339. }
  340. },
  341. activated () {
  342. // 如果是新页签打开,则重置当前页面
  343. if (this.$store.state.app.isNewTab) {
  344. this.pageInit()
  345. }
  346. }
  347. }
  348. </script>