table.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <scTable ref="table" :apiObj="list.apiObj" :params="searchKey" @selectionChange="selectionChange" row-key="id" border>
  3. <el-table-column type="selection" width="50" fixed="left"></el-table-column>
  4. <el-table-column label="代理名称" width="150" fixed="left" prop="truename"></el-table-column>
  5. <el-table-column label="联系人" width="150" prop="contact"></el-table-column>
  6. <el-table-column label="代理ID" width="150" prop="agent_id"></el-table-column>
  7. <el-table-column label="主账号登录账号" prop="truename" width="200">
  8. <template #default="scope">
  9. <span v-if="scope.row.user">{{ scope.row.user.username?scope.row.user.username:'-' }}</span>
  10. <span class="status-danger" v-else>未设置</span>
  11. </template>
  12. </el-table-column>
  13. <el-table-column label="手机号码" prop="mobile" width="150">
  14. <template #default="scope">
  15. <span v-if="scope.row.mobile">{{ scope.row.mobile }}</span>
  16. <span class="status-danger" v-else>-</span>
  17. </template>
  18. </el-table-column>
  19. <el-table-column label="到期时间" prop="vip_at" width="220"></el-table-column>
  20. <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
  21. <el-table-column label="状态" prop="status" width="120" align="center">
  22. <template #default="scope">
  23. <div class="status-success" v-if="scope.row.status==1"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  24. <div class="status-danger" v-if="scope.row.status==2"><sc-status-indicator type="danger"></sc-status-indicator> 已冻结</div>
  25. <div class="status-danger" v-if="scope.row.status==3"><sc-status-indicator type="danger"></sc-status-indicator> 已到期</div>
  26. </template>
  27. </el-table-column>
  28. <el-table-column label="操作" width="200" align="right" fixed="right">
  29. <template #default="scope">
  30. <el-button-group>
  31. <el-button text size="small" @click="table_user(scope.row)">用户管理</el-button>
  32. <el-button text type="warning" size="small" @click="table_passwd(scope.row)">编辑</el-button>
  33. <el-popconfirm title="确定删除吗?" @confirm="table_del(scope.row, scope.$index)">
  34. <template #reference>
  35. <el-button text type="danger" size="small">删除</el-button>
  36. </template>
  37. </el-popconfirm>
  38. </el-button-group>
  39. </template>
  40. </el-table-column>
  41. </scTable>
  42. <passwd ref="userPasswd"></passwd>
  43. <formMain ref="formMain" @success="handleSuccess"></formMain>
  44. <userMain ref="userMain" @success="handleSuccess"></userMain>
  45. </template>
  46. <script>
  47. import passwd from "@/views/manage/components/password";
  48. import formMain from './form';
  49. import userMain from '../user/list';
  50. export default {
  51. components: {
  52. passwd,formMain,userMain
  53. },
  54. props: {
  55. type: { type: String, default: "1" }
  56. },
  57. data(){
  58. return {
  59. list: {
  60. apiObj: this.$API.agent.list
  61. },
  62. dataSelect:[],
  63. dataSelectFull:[],
  64. searchKey:{}
  65. }
  66. },
  67. methods: {
  68. async table_del(data){
  69. var resp = await this.$API.agent.del.post({"id":data.id});
  70. if (resp.code == 0) {
  71. return this.$message.warning(resp.msg);
  72. }
  73. this.$message.success(resp.msg);
  74. this.$refs.table.refresh()
  75. },
  76. table_user(row){
  77. this.$nextTick(() => {
  78. this.$refs.userMain.open("edit").setData(row)
  79. })
  80. },
  81. refresh(){
  82. this.$refs.table.refresh()
  83. },
  84. upData(data){
  85. this.$refs.table.upData(data)
  86. },
  87. handleSuccess(){
  88. this.$refs.table.refresh()
  89. },
  90. sortChange(event){
  91. if (event.order) {
  92. var data = {
  93. "field":event.prop,
  94. "order":event.order
  95. }
  96. this.$refs.table.upData(data)
  97. } else {
  98. this.$refs.table.reload(this.searchKey)
  99. }
  100. return ;
  101. },
  102. selectionChange(event){
  103. this.dataSelect = [];
  104. var arr = [];
  105. var arrCompany = [];
  106. event.forEach(function(val,index){
  107. arr[index] = val.id;
  108. arrCompany[index] = val;
  109. });
  110. this.dataSelectFull = arrCompany;
  111. this.dataSelect = arr;
  112. this.$emit("success",this.dataSelect);
  113. this.$emit("successFull",this.dataSelectFull);
  114. },
  115. table_passwd(row){
  116. this.$nextTick(() => {
  117. this.$refs.formMain.open("edit").setData(row)
  118. })
  119. },
  120. }
  121. }
  122. </script>