incrementalSubsidyList.vue 14 KB

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