Blame view

src/views/community/communityMiniList.vue 3.65 KB
1f3f7892   wuxw   开发完成admin 系统小区公众号
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  <template>
    <div class="community-mini-container">
      <el-row :gutter="20">
        <el-col :span="4">
          <select-admin-community :community-id="communityId" @changeCommunity="handleCommunityChange" />
        </el-col>
  
        <el-col :span="20">
          <el-card>
            <div slot="header" class="clearfix flex justify-between">
              <span>{{ $t('communityMini.title') }}</span>
              <div class="header-tools">
                <el-button v-if="smallWeChats.length === 0 && conditions.communityId" type="primary" size="small"
                  icon="el-icon-plus" @click="openAddModal">
                  {{ $t('communityMini.add') }}
                </el-button>
              </div>
            </div>
  
            <el-table :data="smallWeChats" border style="width: 100%">
              <el-table-column prop="name" :label="$t('communityMini.name')" align="center" />
              <el-table-column prop="communityName" :label="$t('communityMini.communityName')" align="center" />
              <el-table-column prop="appId" label="APPID" align="center" />
              <el-table-column :label="$t('communityMini.appSecret')" align="center">
                <template >
                  ********
                </template>
              </el-table-column>
              <el-table-column prop="remarks" :label="$t('communityMini.description')" align="center" />
              <el-table-column :label="$t('communityMini.operation')" align="center" width="120">
                <template slot-scope="scope">
                  <el-button type="text" size="small" @click="openEditModal(scope.row)">
                    {{ $t('communityMini.edit') }}
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-card>
        </el-col>
      </el-row>
  
      <add-community-wechat ref="addModal" @success="loadSmallWeChats" />
      <edit-community-wechat ref="editModal" @success="loadSmallWeChats" />
    </div>
  </template>
  
  <script>
  import { listAdminSmallWeChats } from '@/api/community/communityMiniApi'
  import SelectAdminCommunity from '@/components/community/selectAdminCommunity'
  import AddCommunityWechat from '@/components/community/addCommunityWechat'
  import EditCommunityWechat from '@/components/community/editCommunityWechat'
  
  export default {
    name: 'CommunityMiniList',
    components: {
      SelectAdminCommunity,
      AddCommunityWechat,
      EditCommunityWechat
    },
    data() {
      return {
        conditions: {
          communityId: '',
          weChatType: '1000',
          page: 1,
          row: 100
        },
        smallWeChats: [],
        loading: false
      }
    },
    mounted() {
      this.loadSmallWeChats()
    },
    methods: {
      async loadSmallWeChats() {
        this.loading = true
        try {
          const res = await listAdminSmallWeChats(this.conditions)
          if (res.code === 0) {
            this.smallWeChats = res.data || []
          } else {
            this.$message.error(res.msg || '加载小程序列表失败')
          }
        } catch (error) {
          console.error('加载小程序列表失败:', error)
        } finally {
          this.loading = false
        }
      },
      handleCommunityChange(community) {
        this.conditions.communityId = community.communityId
        this.loadSmallWeChats()
      },
      openAddModal() {
        const params = {
          objId: this.conditions.communityId,
          communityId: this.conditions.communityId,
          weChatType: '1000'
        }
        this.$refs.addModal.open(params)
      },
      openEditModal(row) {
        this.$refs.editModal.open(row)
      }
    }
  }
  </script>
  
  <style scoped>
  .community-mini-container {
    padding: 20px;
  }
  
  .header-tools {
    float: right;
  }
  
  .clearfix:after {
    content: "";
    display: table;
    clear: both;
  }
  </style>