index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <div>
  3. <Card :bordered="false" dis-hover class="ivu-mt">
  4. <Form
  5. ref="userFrom"
  6. :model="userFrom"
  7. :label-width="labelWidth"
  8. :label-position="labelPosition"
  9. @submit.native.prevent
  10. >
  11. <Row class="mart">
  12. <Col class="mr">
  13. <FormItem label="用户搜索:" :labelWidth="80" label-for="nickname">
  14. <Input
  15. v-model="userFrom.keyword"
  16. placeholder="请输入ID或者手机号"
  17. element-id="nickname"
  18. style="width: 300px"
  19. clearable
  20. >
  21. <Select
  22. v-model="userFrom.field_key"
  23. slot="prepend"
  24. style="width: 80px"
  25. >
  26. <Option value="all">全部</Option>
  27. <Option value="uid">ID</Option>
  28. <Option value="phone">手机号</Option>
  29. </Select>
  30. </Input>
  31. </FormItem>
  32. </Col>
  33. <Col class="ivu-text-right userFrom ">
  34. <FormItem>
  35. <Button
  36. type="primary"
  37. label="default"
  38. class="mr15 search"
  39. @click="userSearchs"
  40. >搜索</Button
  41. >
  42. <Button class="ResetSearch search" @click="reset('userFrom')"
  43. >重置</Button
  44. >
  45. </FormItem>
  46. </Col>
  47. </Row>
  48. </Form>
  49. </Card>
  50. <Card :bordered="false" dis-hover class="ivu-mt">
  51. <Row type="flex" justify="space-between">
  52. <Col span="24">
  53. <Button class="button" :disabled="datanew.length<=0" @click="setLabel">批量设置标签</Button>
  54. </Col>
  55. <Col span="24">
  56. <Table :columns="columns"
  57. :data="dataList" ref="selection"
  58. @on-select-all="selectall"
  59. @on-select-all-cancel="selectall"
  60. @on-sort-change="sortChanged"
  61. @on-selection-change="select"
  62. :loading="loading" highlight-row
  63. no-userFrom-text="暂无数据"
  64. no-filtered-userFrom-text="暂无筛选结果"
  65. class="ivu-mt">
  66. <template slot-scope="{ row, index }" slot="avatars">
  67. <viewer>
  68. <div class="tabBox_img">
  69. <img v-lazy="row.avatar" />
  70. </div>
  71. </viewer>
  72. </template>
  73. <template slot-scope="{ row, index }" slot="nickname">
  74. <div class="acea-row">
  75. <Icon
  76. type="md-male"
  77. v-show="row.sex === '男'"
  78. color="#2db7f5"
  79. size="15"
  80. class="mr5"
  81. />
  82. <Icon
  83. type="md-female"
  84. v-show="row.sex === '女'"
  85. color="#ed4014"
  86. size="15"
  87. class="mr5"
  88. />
  89. <div>{{row.nickname}}<span style="color: #ed4014;" v-if="row.delete_time != null"> (已注销)</span></div>
  90. </div>
  91. <!-- <div v-show="row.vip_name" class="vipName">{{row.vip_name}}</div> -->
  92. </template>
  93. <template slot-scope="{ row, index }" slot="isMember">
  94. <div>{{ row.isMember ? "是" : "否" }}</div>
  95. </template>
  96. <template slot-scope="{ row, index }" slot="action">
  97. <a @click="detail(row)">详情</a>
  98. <Divider type="vertical" v-if="row.delete_time == null" />
  99. <a v-if="row.delete_time == null" @click="recharge(row)">充值</a>
  100. <!-- <Divider type="vertical" v-if="row.delete_time == null" />
  101. <a v-if="row.delete_time == null" @click="paying(row)">付费会员</a> -->
  102. <Divider type="vertical" v-if="row.delete_time == null" />
  103. <a v-if="row.delete_time == null" @click="openLabel(row)">设置标签</a>
  104. <!-- <Divider type="vertical"/>
  105. <a @click="setUser(row)">修改店员</a> -->
  106. </template>
  107. </Table>
  108. <div class="acea-row row-right page">
  109. <Page
  110. :total="total"
  111. :current="userFrom.page"
  112. show-elevator
  113. show-total
  114. @on-change="pageChange"
  115. :page-size="userFrom.limit"
  116. class="box"
  117. />
  118. </div>
  119. </Col>
  120. </Row>
  121. </Card>
  122. <!-- 详情-->
  123. <!-- <user-details ref="userDetails"></user-details> -->
  124. <!-- 充值 -->
  125. <Recharges ref="recharges"></Recharges>
  126. <Paying ref="payings"></Paying>
  127. <Setusers ref="setusers"></Setusers>
  128. <!-- 会员详情-->
  129. <user-details ref="userDetails" :group-list="groupList"></user-details>
  130. <!-- 选择用户标签 -->
  131. <Modal
  132. v-model="labelShow"
  133. scrollable
  134. title="请选择用户标签"
  135. :closable="false"
  136. width="320"
  137. :footer-hide="true"
  138. >
  139. <userLabel :uid="labelActive.uid" @close="labelClose"></userLabel>
  140. </Modal>
  141. </div>
  142. </template>
  143. <script>
  144. import Setusers from './components/setuser'
  145. import Recharges from './components/recharge'
  146. import Paying from './components/paying'
  147. import {userListApi, usersearchApi, userSetLabelApi,detailsApi, infoApi } from "@/api/user"
  148. // import userDetails from "./components/userDetails";
  149. import userLabel from "./components/userLabel";
  150. import userDetails from "./components/userDetails2";
  151. import { mapState } from "vuex";
  152. export default {
  153. name: 'user',
  154. components:{
  155. userDetails,
  156. userLabel,
  157. Recharges,
  158. Setusers,
  159. Paying
  160. },
  161. data () {
  162. return{
  163. total: 0,
  164. loading:false,
  165. groupList: [],
  166. columns: [
  167. {
  168. type: 'selection',
  169. width: 60,
  170. align: 'center'
  171. },
  172. {
  173. title: "ID",
  174. key: "uid",
  175. width: 60,
  176. },
  177. {
  178. title: "头像",
  179. slot: "avatars",
  180. minWidth: 60,
  181. },
  182. {
  183. title: "昵称",
  184. slot: "nickname",
  185. minWidth: 150,
  186. },
  187. // {
  188. // title: "付费会员",
  189. // slot: "isMember",
  190. // minWidth: 90,
  191. // },
  192. {
  193. title: "用户等级",
  194. key: "level",
  195. minWidth: 90,
  196. },
  197. {
  198. title: "标签",
  199. key: "labels",
  200. minWidth: 90,
  201. },
  202. {
  203. title: "手机号",
  204. key: "phone",
  205. minWidth: 100,
  206. },
  207. {
  208. title: "用户类型",
  209. key: "user_type",
  210. minWidth: 100,
  211. },
  212. {
  213. title: "余额",
  214. key: "now_money",
  215. sortable: "custom",
  216. minWidth: 100,
  217. },
  218. {
  219. title: "关联店员",
  220. key: "staff_name",
  221. minWidth: 100,
  222. },
  223. {
  224. title: '操作',
  225. slot: 'action',
  226. fixed: 'right',
  227. minWidth: 290,
  228. align: 'center'
  229. }
  230. ],
  231. dataList:[],
  232. datanew: [],
  233. dataid:[],
  234. userFrom: {
  235. keyword: "",
  236. page: 1,
  237. limit: 15,
  238. field_key: "all",
  239. },
  240. labelShow: false,
  241. labelActive: {
  242. uid: 0,
  243. }
  244. }
  245. },
  246. computed: {
  247. ...mapState("store/layout", ["isMobile"]),
  248. labelWidth() {
  249. return this.isMobile ? undefined : 120;
  250. },
  251. labelPosition() {
  252. return this.isMobile ? "top" : "right";
  253. }
  254. },
  255. mounted() {
  256. this.getList()
  257. },
  258. methods: {
  259. getList(){
  260. this.loading = true
  261. userListApi(this.userFrom).then(res=>{
  262. this.loading = false
  263. this.total = res.data.count
  264. this.dataList = res.data.list
  265. }).catch(err=>{
  266. this.loading = false
  267. this.$Message.error(err.msg)
  268. })
  269. },
  270. // 搜索
  271. userSearchs() {
  272. this.userFrom.page = 1
  273. if(this.userFrom.keyword == ''){
  274. // this.$Message.warning("请输入搜索内容")
  275. this.getList()
  276. }else{
  277. this.loading = true
  278. usersearchApi(this.userFrom).then(res=>{
  279. this.dataList = res.data.list
  280. this.total = res.data.count
  281. this.loading = false
  282. })
  283. }
  284. },
  285. // 重置
  286. reset(name) {
  287. this.userFrom = {
  288. keyword: "",
  289. field_key: "all",
  290. page: 1, // 当前页
  291. limit: 15, // 每页显示条数
  292. };
  293. this.getList();
  294. },
  295. select(e){
  296. this.datanew = e;
  297. let data = [];
  298. this.datanew.map((item) => {
  299. data.push(item.uid);
  300. });
  301. this.dataid = data;
  302. },
  303. selectall(e){
  304. if(e.length == 0){
  305. this.dataid = []
  306. }else{
  307. this.datanew = e
  308. let data = [];
  309. this.datanew.map((item) => {
  310. data.push(item.uid);
  311. });
  312. this.dataid = data;
  313. }
  314. },
  315. // 批量设置标签;
  316. setLabel() {
  317. if (this.datanew.length == 0) {
  318. this.$Message.warning("请选择要设置标签的用户");
  319. } else {
  320. let a = []
  321. a = this.dataid.join(",");
  322. let uids = { all: 0 };
  323. uids.uids = this.dataid;
  324. this.$modalForm(userSetLabelApi(uids)).then(() => this.getList());
  325. }
  326. },
  327. // 详情
  328. detail(row){
  329. this.$refs.userDetails.modals = true;
  330. this.$refs.userDetails.getDetails(row.uid);
  331. // detailsApi(data).then((res) => {
  332. // this.groupList = res.data.list;
  333. // });
  334. },
  335. // 充值
  336. recharge(row){
  337. this.$refs.recharges.modals = true
  338. this.$refs.recharges.getList(row.uid);
  339. },
  340. paying(row){
  341. this.$refs.payings.modals = true
  342. this.$refs.payings.getList(row.uid);
  343. },
  344. // 修改店员
  345. setUser(row){
  346. this.$refs.setusers.modals = true
  347. this.$refs.setusers.getId(row.uid);
  348. },
  349. // 设置标签弹窗
  350. openLabel(row){
  351. this.labelShow = true;
  352. this.labelActive.uid = row.uid;
  353. },
  354. // 标签弹窗关闭
  355. labelClose() {
  356. this.labelShow = false;
  357. this.labelActive.uid = 0;
  358. this.getList()
  359. },
  360. //分页
  361. pageChange(page) {
  362. this.userFrom.page = page;
  363. this.getList()
  364. },
  365. // 排序
  366. sortChanged(e) {
  367. this.userFrom[e.key] = e.order;
  368. this.getList();
  369. },
  370. }
  371. }
  372. </script>
  373. <style scoped lang="stylus">
  374. /deep/.ivu-form-label-left .ivu-form-item-label{
  375. text-align right
  376. }
  377. /deep/.ivu-card-body{
  378. padding-bottom 0px
  379. }
  380. /deep/.ivu-select-selected-value {
  381. font-size: 12px !important;}
  382. .mart{
  383. margin-top 10px
  384. }
  385. .listbox {
  386. >>>.ivu-divider-horizontal {
  387. margin: 0 !important;
  388. }
  389. }
  390. .userFrom {
  391. >>> .ivu-form-item-content {
  392. margin-left: 0px !important;
  393. }
  394. }
  395. .tabBox_img {
  396. width: 36px;
  397. height: 36px;
  398. border-radius: 4px;
  399. cursor: pointer;
  400. img {
  401. width: 100%;
  402. height: 100%;
  403. }
  404. }
  405. .search {
  406. width:86px;
  407. height:32px;
  408. }
  409. .box{padding-bottom: 20px;}
  410. .button{margin-left: 0px}
  411. </style>