userManageList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <a-card :bordered="false" class="shopOrder-table-page-search-wrapper">
  3. <div class="shopOrder-searchForm">
  4. <a-form layout="inline" v-bind="formItemLayout" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="48">
  6. <a-col :span="6">
  7. <a-form-item label="用户手机" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  8. <a-input id="shopOrder-contactPhone" allowClear :maxLength="11" v-model="queryParam.contactPhone" placeholder="请输入用户手机" />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :span="6">
  12. <a-form-item label="乐豆余额" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  13. <div class="input-number">
  14. <a-input-number
  15. id="inputNumber"
  16. v-model="queryParam.value1"
  17. :min="1"
  18. :max="10"
  19. @change="onChange" />-<a-input-number
  20. id="inputNumber"
  21. v-model="queryParam.value2"
  22. :min="1"
  23. :max="10"
  24. @change="onChange"
  25. />
  26. </div>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="6">
  30. <a-form-item label="账户状态" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  31. <v-select
  32. v-model="queryParam.orderStatus"
  33. ref="orderStatus"
  34. id="shopOrder-status"
  35. code="SETTLE_STATUS_ALL"
  36. placeholder="请选择订单状态"
  37. allowClear></v-select>
  38. </a-form-item>
  39. </a-col>
  40. <a-col :span="6">
  41. <a-button class="handle-btn serach-btn" id="shopOrder-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  42. <a-button class="handle-btn" type="" id="shopOrder-btn-reset" @click="handleReset">重置</a-button>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <a-divider />
  48. <div class="table-operator">
  49. <a-button class="export-btn" id="shopOrder-btn-export" type="" :loading="loading" @click="handleExport">导出</a-button>
  50. </div>
  51. <s-table
  52. ref="table"
  53. size="default"
  54. :rowKey="(record) => record.id"
  55. :columns="columns"
  56. :data="loadData"
  57. bordered>
  58. <!-- 订单状态 -->
  59. <template slot="orderStatus" slot-scope="text, record">
  60. <span>{{ record.orderStatus==1 ? '已启用' : '已禁用' }}</span>
  61. </template>
  62. <!-- 订单总额 -->
  63. <template slot="orderPrice" slot-scope="text, record">
  64. <span>{{ record.orderPrice || 0 }}乐豆</span>
  65. </template>
  66. <!--启用禁用 -->
  67. <span slot="state" slot-scope="text, record">
  68. <a-switch
  69. v-hasPermission="'B_goodsClass_enable'"
  70. checkedChildren="启用"
  71. unCheckedChildren="禁用"
  72. id="bannerSetting-changeFlagHandle"
  73. :checked="record.state == 1 ? true : false"
  74. @change="changeFlagHandle(text, record)" />
  75. </span>
  76. <!-- 操作 -->
  77. <template slot="action" slot-scope="text, record">
  78. <a-button id="shopOrder-handleView" type="link" @click="handleUser(record)">用户详情</a-button>
  79. <a-button id="shopOrder-handleView" type="link" @click="handleLd(record)">乐豆明细</a-button>
  80. </template>
  81. </s-table>
  82. </a-card>
  83. </template>
  84. <script>
  85. import { STable, VSelect } from '@/components'
  86. import getDate from '@/libs/getDate.js'
  87. import moment from 'moment'
  88. export default {
  89. name: 'ShopOrder',
  90. components: { STable, VSelect },
  91. data () {
  92. return {
  93. formItemLayout: {
  94. labelCol: { span: 7 },
  95. wrapperCol: { span: 17 }
  96. },
  97. // 查询参数
  98. queryParam: {
  99. beginDate: null, // 开始时间
  100. endDate: null, // 结束时间
  101. contactPhone: '', // 用户手机
  102. orderNo: '', // 订单编号
  103. orderStatus: null, // 订单状态
  104. value1: '',
  105. value2: ''
  106. },
  107. loading: false, // 导出loading
  108. // 表头
  109. columns: [
  110. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  111. { title: '用户手机', dataIndex: 'userMoblie', width: 200, align: 'center' },
  112. { title: '乐豆余额', dataIndex: 'orderDate', width: 200, align: 'center' },
  113. { title: '累计乐豆', dataIndex: 'orderNo', width: 200, align: 'center' },
  114. { title: '注册时间', scopedSlots: { customRender: 'orderStatus' }, width: 200, align: 'center' },
  115. { title: '最后登录时间', scopedSlots: { customRender: 'orderPrice' }, width: 200, align: 'center' },
  116. { title: '最后投递时间', scopedSlots: { customRender: 'orderPrice' }, width: 200, align: 'center' },
  117. { title: '状态', width: 100, dataIndex: 'state', align: 'center', scopedSlots: { customRender: 'state' } },
  118. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center' }
  119. ],
  120. // 加载数据方法 必须为 Promise 对象
  121. loadData: parameter => {
  122. // return getTenantsList(Object.assign(parameter, this.queryParam)).then(res => {
  123. // if (res.status == 200) {
  124. // const no = (res.data.pageNo - 1) * res.data.pageSize
  125. // for (let i = 0; i < res.data.list.length; i++) {
  126. // const _item = res.data.list[i]
  127. // _item.no = no + i + 1
  128. // _item.status = _item.status + '' === '1'
  129. // }
  130. // return res.data
  131. // }
  132. // })
  133. return new Promise((resolve) => {
  134. const data = [
  135. { no: 1, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155' },
  136. { no: 2, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155' },
  137. { no: 3, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155' },
  138. { no: 4, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155' },
  139. { no: 5, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155' },
  140. { no: 6, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155' }
  141. ]
  142. resolve(data)
  143. })
  144. },
  145. // 将默认当天时间日期回显在时间选择框中
  146. time: [
  147. moment(getDate.getToday().starttime, this.dateFormat),
  148. moment(getDate.getToday().endtime, this.dateFormat)
  149. ],
  150. dateFormat: 'YYYY-MM-DD'
  151. }
  152. },
  153. beforeRouteEnter (to, from, next) {
  154. next(vm => {
  155. vm.handleReset()
  156. })
  157. },
  158. methods: {
  159. moment,
  160. // 不可选日期
  161. disabledDate (date, dateStrings) {
  162. return date && date.valueOf() > Date.now()
  163. },
  164. // 创建时间change
  165. onChange (dates, dateStrings) {
  166. if ((dates, dateStrings)) {
  167. this.queryParam.beginDate = dateStrings[0]
  168. this.queryParam.endDate = dateStrings[1]
  169. }
  170. },
  171. // 查看用户详情
  172. handleUser (row) {
  173. this.$router.push({ path: `/userInfo/userManageList_user/detail/${row.id}` })
  174. },
  175. // 查看乐豆详情
  176. handleLd (row) {
  177. this.$router.push({ path: `/userInfo/userManageList_Ld/detail/${row.id}` })
  178. },
  179. // 重置
  180. handleReset () {
  181. // this.queryParam.beginDate = getDate.getToday().starttime
  182. // this.queryParam.endDate = getDate.getToday().endtime
  183. // this.time = [
  184. // moment(getDate.getToday().starttime, this.dateFormat),
  185. // moment(getDate.getToday().endtime, this.dateFormat)
  186. // ]
  187. this.queryParam.contactPhone = ''
  188. this.queryParam.orderNo = ''
  189. this.queryParam.orderStatus = null
  190. this.$refs.table.refresh(true)
  191. },
  192. // 导出
  193. handleExport () {
  194. const params = {
  195. beginDate: this.queryParam.beginDate == null ? getDate.getToday().starttime : this.queryParam.beginDate,
  196. endDate: this.queryParam.endDate == null ? getDate.getToday().endtime : this.queryParam.endDate,
  197. contactPhone: this.queryParam.contactPhone,
  198. orderNo: this.queryParam.orderNo,
  199. orderStatus: this.queryParam.orderStatus
  200. }
  201. if (!params.beginDate && !params.endDate) {
  202. this.$message.error('请先选择需要导出的下单时间区间再进行导出!')
  203. return
  204. }
  205. // 判断两个时间段是否相差m个月 第二个参数指相差单位,第三个参数指是否返回浮点形式(小数)
  206. if (moment(params.endDate).diff(moment(params.beginDate), 'months', true) > 3) {
  207. this.$message.error('单次最多只能导出3个月的数据,请缩小查询区间后再进行导出!')
  208. }
  209. // this.loading = true
  210. // exportBundle(params).then(res => {
  211. // this.loading = false
  212. // this.download(res)
  213. // })
  214. },
  215. download (data) {
  216. if (!data) { return }
  217. const url = window.URL.createObjectURL(new Blob([data]))
  218. const link = document.createElement('a')
  219. link.style.display = 'none'
  220. link.href = url
  221. const a = moment().format('YYYYMMDDhhmmss')
  222. const fname = '订单记录-' + a
  223. link.setAttribute('download', fname + '.xlsx')
  224. document.body.appendChild(link)
  225. link.click()
  226. }
  227. }
  228. }
  229. </script>
  230. <style lang="less" scoped>
  231. .shopOrder-table-page-search-wrapper{
  232. .shopOrder-searchForm{
  233. .ant-form-inline .ant-form-item{
  234. width: 100%;
  235. }
  236. // 搜索框的下间距
  237. .ant-form-item {
  238. margin-bottom: 10px;
  239. }
  240. .input-number{
  241. display: flex;
  242. margin-top:3px;
  243. }
  244. .handle-btn{
  245. margin-top: 4px;
  246. }
  247. .serach-btn{
  248. margin-right: 10px;
  249. }
  250. }
  251. .export-btn{
  252. background-color: #ff9900;
  253. border-color: #ff9900;
  254. color: #fff;
  255. }
  256. .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){
  257. color: #fff;
  258. border-color: #ff9900;
  259. }
  260. .blue {
  261. color: #1890FF;
  262. }
  263. .green {
  264. color: #16b50e;
  265. }
  266. .red {
  267. color: red;
  268. }
  269. }
  270. </style>