serviceFreightList.vue 13 KB

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