table.vue 5.6 KB

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