table.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id">
  3. <el-table-column type="selection" width="50" fixed="left"></el-table-column>
  4. <el-table-column label="会员名称" width="150" fixed="left" prop="name"></el-table-column>
  5. <el-table-column label="会员卡号" width="150" prop="user_no"></el-table-column>
  6. <el-table-column label="手机号码" width="150" prop="tel"></el-table-column>
  7. <el-table-column label="可用余额(元)" prop="login_at" width="180">
  8. <template #default="scope">
  9. {{scope.row.format_balance?scope.row.format_balance:'0.00'}}
  10. </template>
  11. </el-table-column>
  12. <el-table-column label="累计消费金额(元)" prop="login_at" width="180">
  13. <template #default="scope">
  14. {{scope.row.format_total?scope.row.format_total:'0.00'}}
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="性别" width="150" prop="format_sex" align="center"></el-table-column>
  18. <el-table-column label="会员生日" width="150" prop="brithday">
  19. <template #default="scope">
  20. {{scope.row.brithday?scope.row.brithday:'-'}}
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="最后充值时间" prop="login_at" width="180">
  24. <template #default="scope">
  25. {{scope.row.last_at?scope.row.last_at:'-'}}
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="注册时间" prop="create_at" width="180"></el-table-column>
  29. <el-table-column label="注册IP" prop="create_ip" width="180"></el-table-column>
  30. <el-table-column label="操作" width="160" align="left" fixed="right">
  31. <template #default="scope">
  32. <el-button-group>
  33. <!-- <el-button text type="primary" size="small" @click="table_edit(scope.row)">编辑</el-button> -->
  34. <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
  35. <template #reference>
  36. <el-button text type="danger" size="small">删除</el-button>
  37. </template>
  38. </el-popconfirm>
  39. </el-button-group>
  40. </template>
  41. </el-table-column>
  42. </scTable>
  43. <formMain ref="formMain" @success="handleSuccess"></formMain>
  44. </template>
  45. <script>
  46. import formMain from './form';
  47. export default {
  48. components: {
  49. formMain
  50. },
  51. data(){
  52. return {
  53. list: {
  54. apiObj: this.$API.storeUser.get
  55. },
  56. dataSelect:[],
  57. dataSelectFull:[],
  58. searchKey:{}
  59. }
  60. },
  61. methods: {
  62. table_edit(data){
  63. this.$nextTick(() => {
  64. this.$refs.formMain.open("edit").setData(data)
  65. })
  66. },
  67. async table_del(data){
  68. var resp = await this.$API.storeUser.del.post({"id":data.id});
  69. if (resp.code == 0) {
  70. return this.$message.warning(resp.msg)
  71. }
  72. this.$message.success(resp.msg);
  73. this.$refs.table.refresh()
  74. },
  75. refresh(){
  76. this.$refs.table.refresh()
  77. },
  78. upData(data){
  79. this.$refs.table.upData(data)
  80. },
  81. handleSuccess(){
  82. this.$refs.table.refresh()
  83. },
  84. sortChange(event){
  85. if (event.order) {
  86. var data = {
  87. "field":event.prop,
  88. "order":event.order
  89. }
  90. this.$refs.table.upData(data)
  91. } else {
  92. this.$refs.table.reload(this.searchKey)
  93. }
  94. return ;
  95. },
  96. selectionChange(event){
  97. this.dataSelect = [];
  98. var arr = [];
  99. var arrCompany = [];
  100. event.forEach(function(val,index){
  101. arr[index] = val.id;
  102. arrCompany[index] = val;
  103. });
  104. this.dataSelectFull = arrCompany;
  105. this.dataSelect = arr;
  106. this.$emit("success",this.dataSelect);
  107. this.$emit("successFull",this.dataSelectFull);
  108. },
  109. table_passwd(row){
  110. this.$nextTick(() => {
  111. this.$refs.userPasswd.open("edit").setData(row)
  112. })
  113. },
  114. }
  115. }
  116. </script>