userManageList.vue 9.2 KB

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