index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="goodList">
  3. <Form ref="pagination" :model="formValidate" @submit.native.prevent>
  4. <FormItem label="用户昵称:" label-for="title">
  5. <Input v-model="formValidate.nickname" placeholder="请输入用户昵称" class="input-add mr14" />
  6. <Button type="primary" @click="userSearchs()">查询</Button>
  7. </FormItem>
  8. </Form>
  9. <Table ref="table" no-data-text="暂无数据" @on-select-all="selectAll" @on-select-all-cancel="cancelAll"
  10. @on-select="TableSelectRow" @on-select-cancel="TableSelectCancelRow" no-filtered-data-text="暂无筛选结果"
  11. :columns="columns4" :data="tableList" :loading="loading" class="mr-20" height="500">
  12. <template slot-scope="{ row }" slot="avatar">
  13. <viewer>
  14. <div class="tabBox_img">
  15. <img v-lazy="row.headimgurl||row.user.headimgurl" />
  16. </div>
  17. </viewer>
  18. </template>
  19. <template slot-scope="{ row, index }" slot="user_type">
  20. <span v-if="row.user_type === 'wechat'">公众号</span>
  21. <span v-if="row.user_type === 'routine'">小程序</span>
  22. <span v-if="row.user_type === 'h5'">H5</span>
  23. <span v-if="row.user_type === 'pc'">PC</span>
  24. </template>
  25. </Table>
  26. <div class="acea-row row-right page">
  27. <Page :total="total" show-elevator show-total @on-change="pageChange" :page-size="formValidate.limit" />
  28. </div>
  29. <div class="footer" slot="footer" >
  30. <Button type="primary" size="large" :loading="modal_loading" long @click="ok">确定</Button>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { kefucreateApi } from "@/api/setting";
  36. import {
  37. mapState
  38. } from "vuex";
  39. import {
  40. getYgList
  41. } from '@/api/store'
  42. export default {
  43. name: "index",
  44. props: {
  45. is_reservation: {
  46. type: Number,
  47. default: 1
  48. },
  49. },
  50. data() {
  51. return {
  52. //选中商品集合
  53. selectEquips: [],
  54. // 选中的id集合
  55. selectEquipsIds: [],
  56. cateIds: [],
  57. modal_loading: false,
  58. formValidate: {
  59. page: 1,
  60. limit: 10,
  61. nickname: ''
  62. },
  63. total: 0,
  64. loading: false,
  65. tableList: [],
  66. columns4: [{
  67. type: 'selection',
  68. width: 60,
  69. align: 'center'
  70. },
  71. {
  72. title: "用户UID",
  73. key: "uid",
  74. width: 60,
  75. },
  76. {
  77. title: "头像",
  78. slot: "avatar",
  79. width: 60,
  80. },
  81. {
  82. title: "昵称",
  83. key: "nickname",
  84. minWidth: 80,
  85. },
  86. // {
  87. // title: "别称",
  88. // key: "alias",
  89. // minWidth: 80,
  90. // },
  91. {
  92. title: "用户类型",
  93. slot: "user_type",
  94. minWidth: 100,
  95. },
  96. // {
  97. // title: "创建时间",
  98. // key: "create_time",
  99. // minWidth: 100,
  100. // },
  101. ],
  102. images: [],
  103. };
  104. },
  105. created() {
  106. },
  107. mounted() {
  108. this.getList();
  109. },
  110. methods: {
  111. // 判断是否选中
  112. sortData() {
  113. if (this.selectEquipsIds.length) {
  114. this.tableList.forEach(ele => {
  115. if (this.selectEquipsIds.includes(ele.id)) ele._checked = true;
  116. })
  117. }
  118. },
  119. // 选中一行
  120. TableSelectRow(selection, row) {
  121. console.log(selection, row,'selection, row')
  122. if (!this.selectEquipsIds.includes(row.uid)) {
  123. this.selectEquipsIds.push(row.uid);
  124. this.selectEquips.push(row);
  125. }
  126. },
  127. // 取消选中一行
  128. TableSelectCancelRow(selection, row) {
  129. var _index = this.selectEquipsIds.indexOf(row.uid);
  130. if (_index != -1) {
  131. this.selectEquipsIds.splice(_index, 1);
  132. this.selectEquips.splice(_index, 1);
  133. }
  134. },
  135. // 选中所有
  136. selectAll() {
  137. for (let i = this.tableList.length - 1; i >= 0; i--) {
  138. this.TableSelectRow(null, this.tableList[i]);
  139. }
  140. },
  141. // 取消选中所有
  142. cancelAll() {
  143. for (let i = this.tableList.length - 1; i >= 0; i--) {
  144. this.TableSelectCancelRow(null, this.tableList[i]);
  145. }
  146. },
  147. pageChange(index) {
  148. this.formValidate.page = index;
  149. this.getList();
  150. },
  151. // 列表
  152. getList() {
  153. this.loading = true;
  154. kefucreateApi(this.formValidate)
  155. .then(async (res) => {
  156. let data = res.data;
  157. this.tableList = data.list;
  158. this.total = res.data.count;
  159. this.sortData();
  160. this.loading = false;
  161. })
  162. .catch((res) => {
  163. this.loading = false;
  164. this.$Message.error(res.msg);
  165. });
  166. },
  167. changeCheckbox(selection) {
  168. let images = [];
  169. selection.forEach(function(item) {
  170. let imageObject = {
  171. image: item.image,
  172. product_id: item.id,
  173. store_name: item.store_name,
  174. temp_id: item.temp_id
  175. };
  176. images.push(imageObject);
  177. });
  178. this.images = images;
  179. this.$emit("getProductDiy", selection);
  180. },
  181. ok() {
  182. console.log("getProductId", this.selectEquips)
  183. this.$emit("getProductId", this.selectEquips);
  184. },
  185. treeSearchs(value) {
  186. this.formValidate.page = 1;
  187. this.getList();
  188. },
  189. // 表格搜索
  190. userSearchs() {
  191. this.formValidate.page = 1;
  192. this.getList();
  193. },
  194. clear() {
  195. },
  196. },
  197. };
  198. </script>
  199. <style scoped lang="stylus">
  200. /deep/.ivu-table-header thead tr th {
  201. padding: 8px 5px;
  202. }
  203. /deep/.ivu-radio-wrapper {
  204. margin-right: 0 !important;
  205. }
  206. .footer {
  207. margin: 15px 0;
  208. }
  209. .tabBox_img {
  210. width: 36px;
  211. height: 36px;
  212. border-radius: 100px;
  213. overflow: hidden;
  214. cursor: pointer;
  215. img {
  216. width: 100%;
  217. height: 100%;
  218. }
  219. }
  220. .tabform {
  221. >>>.ivu-form-item {
  222. margin-bottom: 16px !important;
  223. }
  224. }
  225. .btn {
  226. margin-top: 20px;
  227. float: right;
  228. }
  229. .goodList {}
  230. .mr-20 {
  231. margin-right: 10px;
  232. }
  233. </style>