userManageList.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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="0" @change="onChange" />-
  15. <a-input-number id="inputNumber" v-model="queryParam.currentGoldMax" :min="0" @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_LdDetails'">乐豆明细</a-button>
  68. <span v-if="!$hasPermissions('B_user_userManage_userDetails') && (!$hasPermissions('B_user_userManage_LdDetails'))">--</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: 'totalGold',
  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. customRender: (text) => {
  144. return text || '--'
  145. }
  146. },
  147. {
  148. title: '最后登录时间',
  149. dataIndex: 'lastLoginTime',
  150. width: 200,
  151. align: 'center',
  152. customRender: (text) => {
  153. return text || '--'
  154. }
  155. },
  156. {
  157. title: '最后投递时间',
  158. dataIndex: 'lastDeliveryTime',
  159. width: 200,
  160. align: 'center',
  161. customRender: (text) => {
  162. return text || '--'
  163. }
  164. },
  165. {
  166. title: '状态',
  167. width: 100,
  168. dataIndex: 'state',
  169. align: 'center',
  170. scopedSlots: {
  171. customRender: 'state'
  172. }
  173. },
  174. {
  175. title: '操作',
  176. scopedSlots: {
  177. customRender: 'action'
  178. },
  179. width: 100,
  180. align: 'center'
  181. }
  182. ],
  183. // 加载数据方法 必须为 Promise 对象
  184. loadData: parameter => {
  185. return customerList(Object.assign(parameter, this.queryParam)).then(res => {
  186. if (res.status == 200) {
  187. const no = (res.data.pageNo - 1) * res.data.pageSize
  188. for (let i = 0; i < res.data.list.length; i++) {
  189. const _item = res.data.list[i]
  190. _item.no = no + i + 1
  191. _item.status = _item.status + '' === '1'
  192. }
  193. return res.data
  194. }
  195. })
  196. }
  197. }
  198. },
  199. beforeRouteEnter (to, from, next) {
  200. next(vm => {
  201. vm.handleReset()
  202. })
  203. },
  204. methods: {
  205. // 查询条件change
  206. onChange () {
  207. },
  208. refresh () {
  209. // const isVal = this.queryParam.currentGoldMin && this.queryParam.currentGoldMin != 0
  210. if (((this.queryParam.currentGoldMin && this.queryParam.currentGoldMin != 0) && this.queryParam.currentGoldMax) && (this.queryParam.currentGoldMin > this.queryParam.currentGoldMax)) {
  211. this.$message.error('请输入正确的查询范围!')
  212. return
  213. }
  214. if (((!this.queryParam.currentGoldMin && this.queryParam.currentGoldMin != 0) && this.queryParam.currentGoldMax) || (this.queryParam.currentGoldMin && !this.queryParam.currentGoldMax)) {
  215. this.$message.error('请输入正确的查询范围!')
  216. return
  217. } else {
  218. this.$refs.table.refresh()
  219. }
  220. this.$refs.table.refresh()
  221. },
  222. // 查看用户详情
  223. handleUser (row) {
  224. this.$router.push({
  225. path: `/userInfo/userManageList_user/detail/${row.id}`
  226. })
  227. },
  228. // 查看乐豆详情
  229. handleLd (row) {
  230. this.$router.push({
  231. path: `/userInfo/userManageList_Ld/detail/${row.customerNo}`
  232. })
  233. },
  234. // 启用禁用
  235. // 更改启用禁用状态
  236. changeFlagHandle (text, record) {
  237. console.log(text)
  238. const _this = this
  239. const _data = {
  240. id: record.id,
  241. state: record.state == 1 ? '0' : '1'
  242. }
  243. changeStatus(_data).then(res => {
  244. if (res.status == 200) {
  245. _this.$message.success(res.message)
  246. _this.$refs.table.refresh()
  247. } else {
  248. record.state = !record.state
  249. }
  250. })
  251. },
  252. // 重置
  253. handleReset () {
  254. this.queryParam.mobile = ''
  255. this.queryParam.currentGoldMin = ''
  256. this.queryParam.currentGoldMax = ''
  257. this.queryParam.state = ''
  258. this.$refs.table.refresh(true)
  259. },
  260. // 导出
  261. handleExport () {
  262. const params = {
  263. mobile: this.queryParam.mobile,
  264. currentGoldMin: this.queryParam.currentGoldMin,
  265. currentGoldMax: this.queryParam.currentGoldMax,
  266. state: this.queryParam.state = ''
  267. }
  268. this.loading = true
  269. customeExport(params).then(res => {
  270. this.loading = false
  271. this.download(res)
  272. })
  273. },
  274. download (data) {
  275. if (!data) {
  276. return
  277. }
  278. const url = window.URL.createObjectURL(new Blob([data]))
  279. const link = document.createElement('a')
  280. link.style.display = 'none'
  281. link.href = url
  282. // const a = moment().format('YYYYMMDDhhmmss')
  283. const fname = '用户列表'
  284. link.setAttribute('download', fname + '.xlsx')
  285. document.body.appendChild(link)
  286. link.click()
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="less" scoped>
  292. .shopOrder-table-page-search-wrapper {
  293. .shopOrder-searchForm {
  294. .ant-form-inline .ant-form-item {
  295. width: 100%;
  296. }
  297. // 搜索框的下间距
  298. .ant-form-item {
  299. margin-bottom: 10px;
  300. }
  301. .input-number {
  302. display: flex;
  303. margin-top: 3px;
  304. }
  305. .handle-btn {
  306. margin-top: 4px;
  307. }
  308. .serach-btn {
  309. margin-right: 10px;
  310. }
  311. }
  312. .export-btn {
  313. background-color: #ff9900;
  314. border-color: #ff9900;
  315. color: #fff;
  316. }
  317. .export-btn.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger),
  318. .export-btn.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger) {
  319. color: #fff;
  320. border-color: #ff9900;
  321. }
  322. .blue {
  323. color: #1890FF;
  324. }
  325. .green {
  326. color: #16b50e;
  327. }
  328. .red {
  329. color: red;
  330. }
  331. }
  332. </style>