userManageList.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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="refresh">
  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="releaseRecordList-mobile" allowClear :maxLength="11" v-model="queryParam.mobile" 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 id="releaseRecordList-inputNumber" v-model="queryParam.currentGoldMin" :min="1" @change="onChange" />-
  15. <a-input-number id="inputNumber" v-model="queryParam.currentGoldMax" :min="1" @change="onChange" />
  16. </div>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="6">
  20. <a-form-item label="账户状态" :label-col="formItemLayout.labelCol" :wrapper-col="formItemLayout.wrapperCol">
  21. <v-select
  22. v-model="queryParam.state"
  23. id="releaseRecordList-state"
  24. code="ENABLE_FLAG"
  25. placeholder="请选择订单状态"
  26. allowClear></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="6">
  30. <a-button class="handle-btn serach-btn" id="releaseRecordList-btn-serach" type="primary" @click="refresh">查询</a-button>
  31. <a-button class="handle-btn" type="" id="releaseRecordList-btn-reset" @click="handleReset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <a-divider />
  37. <div class="table-operator">
  38. <a-button class="export-btn" id="releaseRecordList-btn-export" type="" :loading="loading" @click="handleExport">导出</a-button>
  39. </div>
  40. <s-table
  41. ref="table"
  42. size="default"
  43. :rowKey="(record) => record.id"
  44. :columns="columns"
  45. :data="loadData"
  46. bordered>
  47. <!--启用禁用 -->
  48. <span slot="state" slot-scope="text, record">
  49. <a-switch
  50. checkedChildren="启用"
  51. unCheckedChildren="禁用"
  52. id="releaseRecordList-changeFlagHandle"
  53. :checked="record.state == 1 ? true : false"
  54. @change="changeFlagHandle(text, record)" />
  55. </span>
  56. <!-- 操作 -->
  57. <template slot="action" slot-scope="text, record">
  58. <a-button id="releaseRecordList-handleUser" type="link" @click="handleUser(record)">用户详情</a-button>
  59. <a-button id="releaseRecordList-handleLd" type="link" @click="handleLd(record)">乐豆明细</a-button>
  60. </template>
  61. </s-table>
  62. </a-card>
  63. </template>
  64. <script>
  65. import {
  66. STable,
  67. VSelect
  68. } from '@/components'
  69. import {
  70. customerList,
  71. changeStatus,
  72. customeExport
  73. } from '@/api/userInfo.js'
  74. export default {
  75. name: 'UserManageList',
  76. components: {
  77. STable,
  78. VSelect
  79. },
  80. data () {
  81. return {
  82. formItemLayout: {
  83. labelCol: {
  84. span: 7
  85. },
  86. wrapperCol: {
  87. span: 17
  88. }
  89. },
  90. // 查询参数
  91. queryParam: {
  92. mobile: '', // 用户手机
  93. state: '', // 账户状态
  94. currentGoldMin: '', // 乐豆余额最小值
  95. currentGoldMax: '' // 乐豆余额最大值
  96. },
  97. loading: false, // 导出loading
  98. // 表头
  99. columns: [{
  100. title: '序号',
  101. dataIndex: 'no',
  102. width: 80,
  103. align: 'center'
  104. },
  105. {
  106. title: '用户手机',
  107. dataIndex: 'mobile',
  108. width: 100,
  109. align: 'center'
  110. },
  111. {
  112. title: '乐豆余额',
  113. dataIndex: 'currentGold',
  114. width: 100,
  115. align: 'center',
  116. customRender: (text) => {
  117. return text || 0
  118. }
  119. },
  120. {
  121. title: '累计乐豆',
  122. dataIndex: 'totalCarbon',
  123. width: 100,
  124. align: 'center',
  125. customRender: (text) => {
  126. return text || 0
  127. }
  128. },
  129. {
  130. title: '注册时间',
  131. dataIndex: 'registerTime',
  132. width: 200,
  133. align: 'center'
  134. },
  135. {
  136. title: '最后登录时间',
  137. dataIndex: 'lastLoginTime',
  138. width: 200,
  139. align: 'center'
  140. },
  141. {
  142. title: '最后投递时间',
  143. dataIndex: 'lastDeliveryTime',
  144. width: 200,
  145. align: 'center'
  146. },
  147. {
  148. title: '状态',
  149. width: 100,
  150. dataIndex: 'state',
  151. align: 'center',
  152. scopedSlots: {
  153. customRender: 'state'
  154. }
  155. },
  156. {
  157. title: '操作',
  158. scopedSlots: {
  159. customRender: 'action'
  160. },
  161. width: 100,
  162. align: 'center'
  163. }
  164. ],
  165. // 加载数据方法 必须为 Promise 对象
  166. loadData: parameter => {
  167. return customerList(Object.assign(parameter, this.queryParam)).then(res => {
  168. if (res.status == 200) {
  169. const no = (res.data.pageNo - 1) * res.data.pageSize
  170. for (let i = 0; i < res.data.list.length; i++) {
  171. const _item = res.data.list[i]
  172. _item.no = no + i + 1
  173. _item.status = _item.status + '' === '1'
  174. }
  175. return res.data
  176. }
  177. })
  178. }
  179. }
  180. },
  181. beforeRouteEnter (to, from, next) {
  182. next(vm => {
  183. vm.handleReset()
  184. })
  185. },
  186. methods: {
  187. // 查询条件change
  188. onChange () {
  189. },
  190. refresh () {
  191. if ((this.queryParam.currentGoldMin && this.queryParam.currentGoldMax) && (this.queryParam.currentGoldMin >= this.queryParam
  192. .currentGoldMax)) {
  193. this.$message.error('请输入正确的查询范围!')
  194. return
  195. }
  196. if ((!this.queryParam.currentGoldMin && this.queryParam.currentGoldMax) || (this.queryParam.currentGoldMin && !this.queryParam.currentGoldMax)) {
  197. this.$message.error('请输入正确的查询范围!')
  198. return
  199. } else {
  200. this.$refs.table.refresh()
  201. }
  202. this.$refs.table.refresh()
  203. },
  204. // 查看用户详情
  205. handleUser (row) {
  206. this.$router.push({
  207. path: `/userInfo/userManageList_user/detail/${row.id}`
  208. })
  209. },
  210. // 查看乐豆详情
  211. handleLd (row) {
  212. this.$router.push({
  213. path: `/userInfo/userManageList_Ld/detail/${row.customerNo}`
  214. })
  215. },
  216. // 启用禁用
  217. // 更改启用禁用状态
  218. changeFlagHandle (text, record) {
  219. console.log(text)
  220. const _this = this
  221. const _data = {
  222. id: record.id,
  223. state: record.state == 1 ? '0' : '1'
  224. }
  225. changeStatus(_data).then(res => {
  226. if (res.status == 200) {
  227. _this.$message.success(res.message)
  228. _this.$refs.table.refresh()
  229. } else {
  230. record.state = !record.state
  231. }
  232. })
  233. },
  234. // 重置
  235. handleReset () {
  236. this.queryParam.contactPhone = ''
  237. this.queryParam.currentGoldMin = ''
  238. this.queryParam.currentGoldMax = ''
  239. this.queryParam.state = ''
  240. this.$refs.table.refresh(true)
  241. },
  242. // 导出
  243. handleExport () {
  244. const params = {
  245. contactPhone: this.queryParam.contactPhone,
  246. orderNo: this.queryParam.orderNo,
  247. orderStatus: this.queryParam.orderStatus
  248. }
  249. this.loading = true
  250. customeExport(params).then(res => {
  251. this.loading = false
  252. this.download(res)
  253. })
  254. },
  255. download (data) {
  256. if (!data) {
  257. return
  258. }
  259. const url = window.URL.createObjectURL(new Blob([data]))
  260. const link = document.createElement('a')
  261. link.style.display = 'none'
  262. link.href = url
  263. // const a = moment().format('YYYYMMDDhhmmss')
  264. const fname = '用户列表'
  265. link.setAttribute('download', fname + '.xlsx')
  266. document.body.appendChild(link)
  267. link.click()
  268. }
  269. }
  270. }
  271. </script>
  272. <style lang="less" scoped>
  273. .shopOrder-table-page-search-wrapper {
  274. .shopOrder-searchForm {
  275. .ant-form-inline .ant-form-item {
  276. width: 100%;
  277. }
  278. // 搜索框的下间距
  279. .ant-form-item {
  280. margin-bottom: 10px;
  281. }
  282. .input-number {
  283. display: flex;
  284. margin-top: 3px;
  285. }
  286. .handle-btn {
  287. margin-top: 4px;
  288. }
  289. .serach-btn {
  290. margin-right: 10px;
  291. }
  292. }
  293. .export-btn {
  294. background-color: #ff9900;
  295. border-color: #ff9900;
  296. color: #fff;
  297. }
  298. .export-btn.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger),
  299. .export-btn.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger) {
  300. color: #fff;
  301. border-color: #ff9900;
  302. }
  303. .blue {
  304. color: #1890FF;
  305. }
  306. .green {
  307. color: #16b50e;
  308. }
  309. .red {
  310. color: red;
  311. }
  312. }
  313. </style>