allLdDetail.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <a-card :bordered="false" class="allLdDetail-page-info">
  3. <!-- 搜索条件 -->
  4. <div class="allLdDetail-searchForm">
  5. <a-form layout="inline" v-bind="formItemLayout" @keyup.enter.native="refresh">
  6. <a-row :gutter="24">
  7. <a-col :xs="24" :sm="12" :md="8" :lg="5">
  8. <a-form-item label="创建时间" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  9. <a-range-picker
  10. id="allLdDetail-time"
  11. v-model="time"
  12. style="width: 100%;"
  13. :format="dateFormat"
  14. :placeholder="['开始时间','结束时间']"
  15. :disabledDate="disabledDate"
  16. @change="onChange" />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :xs="24" :sm="12" :md="8" :lg="5">
  20. <a-form-item label="变动类型" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  21. <v-select
  22. v-model="queryParam.changeType"
  23. ref="changeType"
  24. id="allLdDetail-status"
  25. code="GOLD_CHANGE_TYPE"
  26. placeholder="请选择"
  27. allowClear></v-select>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :xs="24" :sm="12" :md="8" :lg="5">
  31. <a-form-item label="变动原因" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  32. <v-select
  33. v-model="queryParam.operateType"
  34. ref="operateType"
  35. id="allLdDetail-status"
  36. code="GOLD_OPERATE_TYPE_ALL"
  37. placeholder="请选择"
  38. allowClear></v-select>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :xs="24" :sm="12" :md="8" :lg="5">
  42. <a-form-item label="用户手机" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  43. <a-input id="allLdDetail-customerMobile" allowClear :maxLength="11" v-model="queryParam.customerMobile" placeholder="请输入用户手机" />
  44. </a-form-item>
  45. </a-col>
  46. <a-col :xs="24" :sm="12" :md="8" :lg="4">
  47. <a-button class="handle-btn serach-btn" id="allLdDetail-btn-serach" type="primary" @click="refresh">查询</a-button>
  48. <a-button class="handle-btn" type="" id="allLdDetail-btn-reset" @click="handleReset">重置</a-button>
  49. </a-col>
  50. </a-row>
  51. </a-form>
  52. </div>
  53. <!-- 总计 -->
  54. <a-alert type="info" showIcon style="margin-bottom:15px">
  55. <div class="ftext" slot="message">共<span> {{ total }} </span>条,乐豆变动总计<span> {{ ldChangeNum }} </span>个</div>
  56. </a-alert>
  57. <!-- 列表 -->
  58. <s-table
  59. ref="table"
  60. size="default"
  61. :rowKey="(record) => record.id"
  62. :columns="columns"
  63. :data="loadData"
  64. bordered>
  65. </s-table>
  66. </a-card>
  67. </template>
  68. <script>
  69. import { STable, VSelect } from '@/components'
  70. import { offPartnerGoldLog, getStatistic } from '@/api/userInfo.js'
  71. import moment from 'moment'
  72. import getDate from '@/libs/getDate.js'
  73. export default {
  74. name: 'AllLdDetail',
  75. components: { STable, VSelect },
  76. data () {
  77. return {
  78. formItemLayout: {
  79. labelCol: { span: 7 },
  80. wrapperCol: { span: 17 }
  81. },
  82. // 将默认近七天时间日期回显在时间选择框中
  83. time: [
  84. moment(getDate.getRecentday().starttime, this.dateFormat),
  85. moment(getDate.getRecentday().endtime, this.dateFormat)
  86. ],
  87. total: 0, // 总条数
  88. ldChangeNum: 0, // 乐豆变动量总计
  89. dateFormat: 'YYYY-MM-DD',
  90. // 查询参数
  91. queryParam: {
  92. beginDate: null, // 开始时间
  93. endDate: null, // 结束时间
  94. customerMobile: '', // 用户手机
  95. changeType: '', // 类型
  96. operateType: '' // 原因
  97. },
  98. // 表头
  99. columns: [
  100. { title: '序号', dataIndex: 'no', width: 60, align: 'center' },
  101. { title: '创建时间', dataIndex: 'createDate', width: 200, align: 'center' },
  102. { title: '用户手机', dataIndex: 'customerMobile', width: 200, align: 'center' },
  103. { title: '变动类型', dataIndex: 'changeTypeDictValue', width: 200, align: 'center' },
  104. { title: '变动原因', dataIndex: 'operateTypeDictValue', width: 200, align: 'center' },
  105. { title: '乐豆变动量(个)', dataIndex: 'changeNum', width: 200, align: 'center' }
  106. ],
  107. // 加载数据方法 必须为 Promise 对象
  108. loadData: parameter => {
  109. const searchData = Object.assign(parameter, this.queryParam)
  110. if (this.time && this.time.length) {
  111. searchData.beginDate = moment(this.time[0]).format('YYYY-MM-DD')
  112. searchData.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  113. } else {
  114. searchData.beginDate = null
  115. searchData.endDate = null
  116. }
  117. return offPartnerGoldLog(Object.assign(parameter, searchData)).then(res => {
  118. if (res.status == 200) {
  119. const no = (res.data.pageNo - 1) * res.data.pageSize
  120. for (let i = 0; i < res.data.list.length; i++) {
  121. const _item = res.data.list[i]
  122. _item.no = no + i + 1
  123. }
  124. // 总条数
  125. this.total = res.data.count
  126. return res.data
  127. }
  128. })
  129. }
  130. }
  131. },
  132. methods: {
  133. // 不可选日期
  134. disabledDate (date, dateStrings) {
  135. return date && date.valueOf() > Date.now()
  136. },
  137. // 创建时间change
  138. onChange (dates, dateStrings) {
  139. if ((dates, dateStrings)) {
  140. this.queryParam.beginDate = dateStrings[0]
  141. this.queryParam.endDate = dateStrings[1]
  142. }
  143. },
  144. // 查询
  145. refresh () {
  146. this.$refs.table.refresh(true)
  147. this.getTotal()
  148. },
  149. // 重置
  150. handleReset () {
  151. this.time = [
  152. moment(getDate.getRecentday().starttime, this.dateFormat),
  153. moment(getDate.getRecentday().endtime, this.dateFormat)
  154. ]
  155. this.queryParam = {
  156. beginDate: null, // 开始时间
  157. endDate: null, // 结束时间
  158. customerMobile: '', // 用户手机
  159. changeType: '', // 类型
  160. operateType: '' // 原因
  161. }
  162. this.$refs.table.refresh(true)
  163. this.getTotal()
  164. },
  165. // 总计
  166. getTotal () {
  167. const params = this.queryParam
  168. if (this.time && this.time.length) {
  169. params.beginDate = moment(this.time[0]).format('YYYY-MM-DD')
  170. params.endDate = moment(this.time[1]).format('YYYY-MM-DD')
  171. } else {
  172. params.beginDate = null
  173. params.endDate = null
  174. }
  175. getStatistic(params).then(res => {
  176. if (res.status == 200) {
  177. this.ldChangeNum = res.data || 0
  178. } else {
  179. this.ldChangeNum = 0
  180. }
  181. })
  182. }
  183. },
  184. mounted () {
  185. this.getTotal()
  186. },
  187. beforeRouteEnter (to, from, next) {
  188. next(vm => {
  189. vm.time = [
  190. moment(getDate.getRecentday().starttime, this.dateFormat),
  191. moment(getDate.getRecentday().endtime, this.dateFormat)
  192. ]
  193. vm.queryParam = {
  194. beginDate: null, // 开始时间
  195. endDate: null, // 结束时间
  196. customerMobile: '', // 用户手机
  197. changeType: '', // 类型
  198. operateType: '' // 原因
  199. }
  200. })
  201. }
  202. }
  203. </script>
  204. <style lang="less" scoped>
  205. .allLdDetail-page-info{
  206. .page-header{
  207. margin-bottom: 15px;
  208. span{
  209. margin-left: 20px;
  210. }
  211. .page-header-info{
  212. margin-left:0;
  213. font-weight: bold;
  214. }
  215. }
  216. .allLdDetail-searchForm{
  217. .ant-form-inline .ant-form-item{
  218. width: 100%;
  219. }
  220. // 搜索框的下间距
  221. .ant-form-item {
  222. margin-bottom: 15px;
  223. }
  224. .handle-btn{
  225. margin-top: 4px;
  226. }
  227. .serach-btn{
  228. margin-right: 10px;
  229. }
  230. }
  231. }
  232. </style>