table.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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="truename">
  5. <template #default="scope">
  6. <span v-if="scope.row.truename">{{ scope.row.truename }}</span>
  7. <span class="status-danger" v-else>未设置</span>
  8. </template>
  9. </el-table-column>
  10. <el-table-column label="账户ID" width="150" prop="user_id"></el-table-column>
  11. <el-table-column label="登录账号" prop="username" width="150">
  12. <template #default="scope">
  13. <span v-if="scope.row.username">{{ scope.row.username }}</span>
  14. <span class="status-danger" v-else>未设置</span>
  15. </template>
  16. </el-table-column>
  17. <el-table-column label="账户类型" prop="type" width="120" align="center">
  18. <template #default="scope">
  19. <div class="status-success" v-if="scope.row.type==1"><sc-status-indicator type="success"></sc-status-indicator> 系统管理员</div>
  20. <div class="status-danger" v-if="scope.row.type==2"><sc-status-indicator type="danger"></sc-status-indicator> 代理账号</div>
  21. <div class="status-info" v-if="scope.row.type==3"><sc-status-indicator type="info"></sc-status-indicator> 店铺账号</div>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="手机号码" prop="mobile" width="150">
  25. <template #default="scope">
  26. <span v-if="scope.row.mobile">{{ scope.row.mobile }}</span>
  27. <span class="status-danger" v-else>-</span>
  28. </template>
  29. </el-table-column>
  30. <el-table-column label="登录时间" prop="login_at" width="180">
  31. <template #default="scope">
  32. {{scope.row.login_at?scope.row.login_at:'-'}}
  33. </template>
  34. </el-table-column>
  35. <el-table-column label="登录IP" prop="login_ip" width="180">
  36. <template #default="scope">
  37. {{scope.row.login_ip?scope.row.login_ip:'-'}}
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="登录次数" prop="login_num" width="180"></el-table-column>
  41. <el-table-column label="注册时间" prop="create_at" width="180"></el-table-column>
  42. <el-table-column label="注册IP" prop="create_ip" width="180"></el-table-column>
  43. <el-table-column label="状态" prop="status" width="120" align="center">
  44. <template #default="scope">
  45. <el-popconfirm title="确定要启用或冻结该账号吗?" @confirm="table_state(scope.row)">
  46. <template #reference>
  47. <div class="status-success" v-if="scope.row.status==1"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  48. <div class="status-danger" v-else><sc-status-indicator type="danger"></sc-status-indicator> 禁用</div>
  49. </template>
  50. </el-popconfirm>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="操作" width="160" align="right" fixed="right">
  54. <template #default="scope">
  55. <el-button-group>
  56. <el-button text type="warning" size="small" @click="table_passwd(scope.row)">修改密码</el-button>
  57. <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
  58. <template #reference>
  59. <el-button text type="danger" size="small">删除</el-button>
  60. </template>
  61. </el-popconfirm>
  62. </el-button-group>
  63. </template>
  64. </el-table-column>
  65. </scTable>
  66. <passwd ref="userPasswd"></passwd>
  67. </template>
  68. <script>
  69. import passwd from "@/views/manage/user/password";
  70. export default {
  71. components: {
  72. passwd
  73. },
  74. props: {
  75. type: { type: String, default: "1" }
  76. },
  77. data(){
  78. return {
  79. list: {
  80. apiObj: this.$API.user.list
  81. },
  82. dataSelect:[],
  83. dataSelectFull:[],
  84. searchKey:{}
  85. }
  86. },
  87. methods: {
  88. async table_state(data){
  89. var status = 1;
  90. if (data.status == 1) {
  91. status = 0;
  92. }
  93. var resp = await this.$API.user.state.post({"id":data.id});
  94. if (resp.code == 0) {
  95. this.$message.warning(resp.msg)
  96. return false;
  97. }
  98. this.$message.success(resp.msg)
  99. this.$refs.table.refresh()
  100. },
  101. refresh(){
  102. this.$refs.table.refresh()
  103. },
  104. upData(data){
  105. this.$refs.table.upData(data)
  106. },
  107. handleSuccess(){
  108. this.$refs.table.refresh()
  109. },
  110. sortChange(event){
  111. if (event.order) {
  112. var data = {
  113. "field":event.prop,
  114. "order":event.order
  115. }
  116. this.$refs.table.upData(data)
  117. } else {
  118. this.$refs.table.reload(this.searchKey)
  119. }
  120. return ;
  121. },
  122. selectionChange(event){
  123. this.dataSelect = [];
  124. var arr = [];
  125. var arrCompany = [];
  126. event.forEach(function(val,index){
  127. arr[index] = val.id;
  128. arrCompany[index] = val;
  129. });
  130. this.dataSelectFull = arrCompany;
  131. this.dataSelect = arr;
  132. this.$emit("success",this.dataSelect);
  133. this.$emit("successFull",this.dataSelectFull);
  134. },
  135. table_passwd(row){
  136. this.$nextTick(() => {
  137. this.$refs.userPasswd.open("edit").setData(row)
  138. })
  139. },
  140. }
  141. }
  142. </script>