ledouCollectRecord.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <a-card :bordered="false" class="ledouCollectRecord-table-page-search-wrapper">
  3. <div class="ledouCollectRecord-searchForm">
  4. <a-form layout="inline" @keyup.enter.native="refresh">
  5. <a-row :gutter="48">
  6. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  7. <a-form-item label="收取时间:" :label-col="{ span: 7 }" :wrapper-col="{ span: 17}">
  8. <a-range-picker
  9. style="width:100%"
  10. id="ledouCollectRecord-queryOrderDate"
  11. :disabledDate="disabledDate"
  12. v-model="queryOrderDate"
  13. :format="dateFormat"
  14. :placeholder="['开始时间', '结束时间']" />
  15. </a-form-item>
  16. </a-col>
  17. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  18. <a-form-item label="用户手机" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  19. <a-input id="ledouCollectRecord-customerMobile" allowClear :maxLength="11" v-model=" queryParam.customerMobile" placeholder="请输入用户手机" />
  20. </a-form-item>
  21. </a-col>
  22. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  23. <a-form-item label="商户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  24. <a-select
  25. placeholder="请选择"
  26. allowClear
  27. v-model="queryParam.officialPartnerNo"
  28. :showSearch="true"
  29. option-filter-prop="children"
  30. :filter-option="filterOption"
  31. >
  32. <a-select-option v-for="item in optionData" :key="item.officialPartnerNo" :value="item.officialPartnerNo">{{ item.name }}</a-select-option>
  33. </a-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :xs="24" :sm="12" :md="6" :lg="5">
  37. <a-form-item label="是否撤销" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  38. <v-select code="GOLD_LOG_CANCEL_FLAG" v-model="queryParam.cancelFlag" allowClear placeholder="请选择" id="ledouCollectRecord"></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :xs="24" :sm="12" :md="6" :lg="4">
  42. <a-button class="handle-btn serach-btn" id="ledouCollectRecord-serach" type="primary" @click="refresh">查询</a-button>
  43. <a-button class="handle-btn" id="ledouCollectRecord-reset" @click="handleReset">重置</a-button>
  44. <a-button class="handle-btn export-btn" id="ledouCollectRecord-export" :loading="loading" @click="handleExport" v-hasPermission="'B_ledouCollectRecord_export'">导出</a-button>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. </div>
  49. <!-- 合计 -->
  50. <a-alert type="info" showIcon style="margin-bottom:15px">
  51. <div class="ftext" slot="message">总计<span> {{ orderTotal }} </span>条记录,累计乐豆收取<span> {{ totalGold }} </span>个,其中 {{ cancelGold }} 个乐豆已撤销收取</div>
  52. </a-alert>
  53. <s-table
  54. ref="table"
  55. size="default"
  56. :rowKey="(record) => record.id"
  57. :columns="columns"
  58. :data="loadData"
  59. bordered>
  60. </s-table>
  61. </a-card>
  62. </template>
  63. <script>
  64. import { STable, VSelect } from '@/components'
  65. import { offPartnerGoldLogList, getOffPartnerGoldLogTotal, sellerList, exportOffPartnerGoldLog } from '@/api/ledouCollectRecord.js'
  66. import moment from 'moment'
  67. import getDate from '@/libs/getDate.js'
  68. export default {
  69. components: { STable, VSelect },
  70. data () {
  71. return {
  72. loading: false,
  73. form: this.$form.createForm(this),
  74. formItemLayout: {
  75. labelCol: { span: 4 },
  76. wrapperCol: { span: 16 }
  77. },
  78. // 将默认近7天时间日期回显在时间选择框中
  79. queryOrderDate: [
  80. moment(getDate.getRecentday().starttime, this.dateFormat),
  81. moment(getDate.getRecentday().endtime, this.dateFormat)
  82. ],
  83. dateFormat: 'YYYY-MM-DD',
  84. // 查询参数
  85. queryParam: {
  86. beginDate: null, // 开始时间
  87. endDate: null, // 结束时间
  88. customerMobile: '', // 用户手机
  89. officialPartnerNo: undefined, // 商户名称
  90. cancelFlag: '' // 是否撤销
  91. },
  92. optionData: [],
  93. orderTotal: 0, // 总单数
  94. totalGold: 0, // 总金额
  95. cancelGold: 0, // 撤销收取乐豆数
  96. // 表头
  97. columns: [
  98. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  99. { title: '收取时间', dataIndex: 'createDate', align: 'center' },
  100. { title: '收取乐豆个数', dataIndex: 'changeNum', width: 200, customRender: (text) => { return text || 0 }, align: 'center' },
  101. { title: '用户手机', dataIndex: 'customerMobile', align: 'center' },
  102. { title: '商户名称', dataIndex: 'officialPartnerName', align: 'center' },
  103. { title: '是否撤销乐豆收取', dataIndex: 'cancelFlagDictValue', align: 'center' }
  104. ],
  105. // 加载数据方法 必须为 Promise 对象
  106. loadData: parameter => {
  107. const searchData = Object.assign(parameter, this.queryParam)
  108. if (this.queryOrderDate && this.queryOrderDate.length) {
  109. searchData.beginDate = moment(this.queryOrderDate[0]).format('YYYY-MM-DD')
  110. searchData.endDate = moment(this.queryOrderDate[1]).format('YYYY-MM-DD')
  111. } else {
  112. searchData.beginDate = ''
  113. searchData.endDate = ''
  114. }
  115. return offPartnerGoldLogList(searchData).then(res => {
  116. if (res.status == 200) {
  117. const no = (res.data.pageNo - 1) * res.data.pageSize
  118. for (let i = 0; i < res.data.list.length; i++) {
  119. const _item = res.data.list[i]
  120. _item.no = no + i + 1
  121. }
  122. this.orderTotal = res.data.count
  123. this.getTotal()
  124. return res.data
  125. }
  126. })
  127. }
  128. }
  129. },
  130. beforeRouteEnter (to, from, next) {
  131. next(vm => {
  132. vm.queryOrderDate = [
  133. moment(getDate.getRecentday().starttime, vm.dateFormat),
  134. moment(getDate.getRecentday().endtime, vm.dateFormat)
  135. ]
  136. vm.queryParam.officialPartnerNo = undefined
  137. vm.queryParam.customerMobile = ''
  138. vm.queryParam.cancelFlag = ''
  139. vm.getSellerList()
  140. })
  141. },
  142. methods: {
  143. moment,
  144. // 不可选日期
  145. disabledDate (date, dateStrings) {
  146. return date && date.valueOf() > Date.now()
  147. },
  148. filterOption (input, option) {
  149. return (
  150. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  151. )
  152. },
  153. // 获取合作商数据
  154. getSellerList () {
  155. sellerList().then(res => {
  156. if (res.status == 200) {
  157. this.optionData = res.data || []
  158. }
  159. })
  160. },
  161. // 导出
  162. handleExport () {
  163. const params = this.queryParam
  164. if (this.queryOrderDate && this.queryOrderDate.length) {
  165. params.beginDate = moment(this.queryOrderDate[0]).format('YYYY-MM-DD')
  166. params.endDate = moment(this.queryOrderDate[1]).format('YYYY-MM-DD')
  167. } else {
  168. params.beginDate = ''
  169. params.endDate = ''
  170. }
  171. if (!params.beginDate && !params.endDate) {
  172. this.$message.error('请先选择收取时间后查询并导出!')
  173. return
  174. }
  175. // 判断两个时间段是否相差m个月 第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
  176. if (moment(params.endDate).diff(moment(params.beginDate), 'months', true) > 3) {
  177. this.$message.error('仅支持导出最多3个月的数据,请先修改收取时间再进行导出!')
  178. return
  179. }
  180. this.loading = true
  181. exportOffPartnerGoldLog(params).then(res => {
  182. this.loading = false
  183. this.download(res)
  184. })
  185. },
  186. download (data) {
  187. if (!data) { return }
  188. const url = window.URL.createObjectURL(new Blob([data]))
  189. const link = document.createElement('a')
  190. link.style.display = 'none'
  191. link.href = url
  192. const a = moment().format('YYYYMMDDhhmmss')
  193. const fname = '乐享亭乐豆收取记录-' + a
  194. link.setAttribute('download', fname + '.xlsx')
  195. document.body.appendChild(link)
  196. link.click()
  197. },
  198. // 查询
  199. refresh () {
  200. this.$refs.table.refresh(true)
  201. },
  202. // 合计
  203. getTotal () {
  204. const params = this.queryParam
  205. if (this.queryOrderDate && this.queryOrderDate.length) {
  206. params.beginDate = moment(this.queryOrderDate[0]).format('YYYY-MM-DD')
  207. params.endDate = moment(this.queryOrderDate[1]).format('YYYY-MM-DD')
  208. } else {
  209. params.beginDate = ''
  210. params.endDate = ''
  211. }
  212. getOffPartnerGoldLogTotal(params).then(res => {
  213. if (res.status == 200) {
  214. if (res.data) {
  215. this.totalGold = res.data.totalGold || 0
  216. this.cancelGold = res.data.totalCancelGold || 0
  217. } else {
  218. this.totalGold = 0
  219. this.cancelGold = 0
  220. }
  221. }
  222. })
  223. },
  224. // 重置
  225. handleReset () {
  226. this.queryOrderDate = [
  227. moment(getDate.getRecentday().starttime, this.dateFormat),
  228. moment(getDate.getRecentday().endtime, this.dateFormat)
  229. ]
  230. this.queryParam.officialPartnerNo = undefined
  231. this.queryParam.customerMobile = ''
  232. this.queryParam.cancelFlag = ''
  233. this.$refs.table.refresh(true)
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="less" scoped>
  239. .ledouCollectRecord-table-page-search-wrapper{
  240. .ledouCollectRecord-searchForm{
  241. .ant-form-inline .ant-form-item{
  242. width: 100%;
  243. }
  244. // 搜索框的下间距
  245. .ant-form-item {
  246. margin-bottom: 10px;
  247. }
  248. .handle-btn{
  249. margin-top: 4px;
  250. }
  251. .serach-btn{
  252. margin-right: 10px;
  253. }
  254. }
  255. .export-btn{
  256. background-color: #ff9900;
  257. border-color: #ff9900;
  258. color: #fff;
  259. margin-left: 10px;
  260. }
  261. .export-btn.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger), .export-btn.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger){
  262. color: #fff;
  263. border-color: #ff9900;
  264. }
  265. }
  266. </style>