Ver Código Fonte

feat: 企微工具 - 小程序管理 - "列表"前端页面

zhengxy 2 anos atrás
pai
commit
a1fa439112

+ 11 - 11
project/src/components/manage/accountManage/accountManage.vue

@@ -1,5 +1,5 @@
1 1
 <template>
2
-  <div v-loading="loading" class="platformManage-wrap">
2
+  <div v-loading="loading" class="accountManage-wrap">
3 3
     <div class="screenBox flex">
4 4
       <div></div><!-- 占位 -->
5 5
       <div class="right">
@@ -34,7 +34,7 @@
34 34
       </el-table-column>
35 35
       <el-table-column label="操作" min-width="160" align="center">
36 36
         <template slot-scope="{ row }">
37
-          <el-button type="primary" size="mini" @click="onClickEditPlatform(row)">编辑</el-button>
37
+          <el-button type="primary" size="mini" @click="onClickEditAccount(row)">编辑</el-button>
38 38
           <el-button v-if="row.enable == 1" type="danger" size="mini" @click="onClickEnable(row, 0)">禁用</el-button>
39 39
           <el-button v-else type="primary" size="mini" @click="onClickEnable(row, 1)">启用</el-button>
40 40
         </template>
@@ -49,25 +49,25 @@
49 49
     <addAccountDialog
50 50
       :dialogVisible="addAccountDialogVisible"
51 51
       :accountInfo="currentAccountInfo"
52
-      @confirm="handleAddPlatformConfirm"
53
-      @cancel="handleAddPlatformCancel"
52
+      @confirm="handleAddAccountConfirm"
53
+      @cancel="handleAddAccountCancel"
54 54
     />
55 55
     <!-- E 添加账号 & 编辑账号 -->
56 56
 
57
-    <!-- S 短剧列表 & 编辑账号 -->
57
+    <!-- S 短剧列表 -->
58 58
     <playletListDialog
59 59
       :dialogVisible="playletListDialogVisible"
60 60
       :accountInfo="currentAccountInfo"
61 61
       @close="handlePlayletListClose"
62 62
     />
63
-    <!-- E 短剧列表 & 编辑账号 -->
63
+    <!-- E 短剧列表 -->
64 64
   </div>
65 65
 </template>
66 66
 <script>
67 67
 import addAccountDialog from './dialog/addAccountDialog.vue'
68 68
 import playletListDialog from './dialog/playletListDialog.vue'
69 69
 export default {
70
-  name: 'platformManage',
70
+  name: 'accountManage',
71 71
   components: {
72 72
     addAccountDialog,
73 73
     playletListDialog,
@@ -138,18 +138,18 @@ export default {
138 138
       this.addAccountDialogVisible = true
139 139
     },
140 140
     // 监听点击"编辑账号"
141
-    onClickEditPlatform(accountInfo) {
141
+    onClickEditAccount(accountInfo) {
142 142
       this.currentAccountInfo = accountInfo
143 143
       this.addAccountDialogVisible = true
144 144
     },
145 145
     // 添加账号 & 编辑账号 => 确定
146
-    handleAddPlatformConfirm({ isEdit }) {
146
+    handleAddAccountConfirm({ isEdit }) {
147 147
       this.addAccountDialogVisible = false
148 148
       if (!isEdit) this.pagination.page = 1
149 149
       this.handleGetAccount()
150 150
     },
151 151
     // 添加账号 & 编辑账号 => 取消
152
-    handleAddPlatformCancel() {
152
+    handleAddAccountCancel() {
153 153
       this.addAccountDialogVisible = false
154 154
     },
155 155
     // E 添加 & 编辑账号
@@ -220,7 +220,7 @@ export default {
220 220
   background: #fff;
221 221
   padding: 5px 20px;
222 222
 }
223
-.platformManage-wrap {
223
+.accountManage-wrap {
224 224
   .playlet-num {
225 225
     cursor: pointer;
226 226
     color: #32B38A;

+ 196 - 0
project/src/components/manage/miniProManage/dialog/addMiniProDialog.vue

@@ -0,0 +1,196 @@
1
+<template>
2
+  <el-dialog
3
+    :visible.sync="dialogVisible"
4
+    :before-close="handleCancel"
5
+    class="addAccount-dialog"
6
+    :title="dialogTitle"
7
+    width="450px"
8
+  >
9
+    <div class="form-wrap" v-loading="loading">
10
+      <div class="form-item">
11
+        <span class="lable"><em>*</em>账号</span>
12
+        <el-input v-model="form.accountNumber" size="small" placeholder="请输入账号" clearable />
13
+      </div>
14
+      <div class="form-item">
15
+        <span class="lable"><em>*</em>平台</span>
16
+        <el-select v-model="form.platform" size="small" placeholder="请选择平台" clearable filterable>
17
+          <el-option v-for="item in platformOptions" :key="item.account_id" :label="item.account_id" :value="item.account_id" />
18
+        </el-select>
19
+      </div>
20
+      <div class="form-item">
21
+        <span class="lable">描述</span>
22
+        <el-input v-model="form.accountDesc" size="small" placeholder="请输入描述" clearable />
23
+      </div>
24
+      <div class="form-item">
25
+        <span class="lable"><em>*</em>是否启用</span>
26
+        <el-switch v-model="form.accountEnable" active-color="#43B083" :active-value="1"  inactive-color="#ccc" :inactive-value="0" />
27
+      </div>
28
+    </div>
29
+    <div slot="footer" class="dialog-footer">
30
+      <el-button size="mini" @click="handleCancel">取 消</el-button>
31
+      <el-button size="mini" type="primary" @click="handleConfirm" :disabled="loading">确 定</el-button>
32
+    </div>
33
+  </el-dialog>
34
+</template>
35
+
36
+<script>
37
+export default {
38
+  name: "addAccountDialog",
39
+  props: {
40
+    // 控制弹框是否显示
41
+    dialogVisible: {
42
+      type: Boolean,
43
+      default: () => false
44
+    },
45
+    // 账号信息
46
+    accountInfo: {
47
+      type: Object,
48
+      default: () => ({})
49
+    },
50
+  },
51
+  data() {
52
+    return {
53
+      loading: false,
54
+      platformOptions: [], // 平台选项
55
+      form: {
56
+        accountNumber: '', // 账号
57
+        platform: '', // 平台
58
+        accountDesc: '', // 描述
59
+        accountEnable: 1, // 是否启用
60
+      }
61
+    }
62
+  },
63
+  computed: {
64
+    // 当前操作是否为"编辑"
65
+    isEdit() {
66
+      return this.accountInfo && this.accountInfo.id
67
+    },
68
+    // 弹框标题
69
+    dialogTitle() {
70
+      return this.isEdit ? '编辑账号' : '添加账号'
71
+    }
72
+  },
73
+  watch: {
74
+    dialogVisible(isShow) {
75
+      // 弹框显示 => 初始化表单数据
76
+      if (isShow) {
77
+        this.handleGetPlatformOptions()
78
+        this.handleInitData()
79
+      }
80
+    },
81
+  },
82
+  methods: {
83
+    // 获取平台选项列表
84
+    async handleGetPlatformOptions() {
85
+      const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.adqAccount_list, {
86
+        params: {
87
+          is_select: 1
88
+        }
89
+      })
90
+      if (res && res.errno == 0) {
91
+        this.platformOptions = res.rst
92
+      } else if (res.errno != 4002) {
93
+        this.$message.warning(res.err)
94
+      }
95
+    },
96
+    // 获取弹框表单数据
97
+    handleInitData() {
98
+      this.loading = false
99
+      if (this.isEdit) { // 编辑
100
+        const { accountNumber, platform, accountDesc, accountEnable } = this.accountInfo
101
+        this.form.accountNumber = accountNumber
102
+        this.form.platform = platform
103
+        this.form.accountDesc = accountDesc
104
+        this.form.accountEnable = accountEnable
105
+      } else { // 新建
106
+        this.form.accountNumber = ''
107
+        this.form.platform = ''
108
+        this.form.accountDesc = ''
109
+        this.form.accountEnable = 1
110
+      }
111
+    },
112
+    async handleConfirm() {
113
+      console.log('handleConfirm => ')
114
+      try {
115
+        // 表单校验
116
+        await this.handleFormValidate()
117
+        let url = `${this.URL.BASEURL}${this.URL.xxx}`
118
+        const params = { ...this.form }
119
+
120
+        if (this.isEdit) { // 编辑操作
121
+          url = `${this.URL.BASEURL}${this.URL.xxx}`
122
+          params.id = this.accountInfo.id
123
+        }
124
+
125
+        console.log('url => ', url)
126
+        console.log('params => ', params)
127
+        this.$emit('confirm', { isEdit: this.isEdit }) // mock
128
+        return // mock
129
+
130
+        this.loading = true
131
+        const { data: res = {} } = await this.$axios.post(url, params)
132
+        if (res && res.errno == 0) {
133
+          this.$message.success('操作成功')
134
+          this.$emit('confirm', { isEdit: this.isEdit })
135
+        } else if (res.errno != 4002) {
136
+          this.$message.warning(res.err || '操作失败')
137
+        }
138
+      } catch (error) {
139
+        console.log('error => ', error)
140
+      } finally {
141
+        this.loading = false
142
+      }
143
+    },
144
+    handleCancel() {
145
+      this.$emit('cancel')
146
+    },
147
+    // 执行表单校验
148
+    handleFormValidate() {
149
+      return new Promise((resolve, reject) => {
150
+        const { accountNumber, platform } = this.form
151
+        if (!accountNumber) {
152
+          this.$message.warning('请输入账号')
153
+          reject('表单校验未通过')
154
+        } else if (!platform) {
155
+          this.$message.warning('请选择平台')
156
+          reject('表单校验未通过')
157
+        } else {
158
+          resolve('表单校验通过')
159
+        }
160
+      })
161
+    },
162
+  },
163
+};
164
+</script>
165
+
166
+<style lang="scss" scoped>
167
+.addAccount-dialog {
168
+  .form-wrap {
169
+    padding: 0 10px;
170
+    .form-item {
171
+      display: flex;
172
+      align-items: center;
173
+      margin-top: 16px;
174
+      &:first-child {
175
+        margin-top: 0;
176
+      }
177
+      .lable {
178
+        width: 70px;
179
+        margin-right: 16px;
180
+        font-weight: 500;
181
+        flex-shrink: 0;
182
+        text-align: right;
183
+        em {
184
+          color: red;
185
+        }
186
+      }
187
+      .el-select {
188
+        width: 100%;
189
+      }
190
+    }
191
+  }
192
+  .dialog-footer {
193
+    text-align: center;
194
+  }
195
+}
196
+</style>

+ 198 - 0
project/src/components/manage/miniProManage/miniProManage.vue

@@ -0,0 +1,198 @@
1
+<template>
2
+  <div v-loading="loading" class="miniProManage-wrap">
3
+    <div class="screenBox flex">
4
+      <div class="flex">
5
+        <selfInput label_name="搜索小程序" @inputChange="onInputKeyword" />
6
+      </div>
7
+      <div class="right">
8
+        <el-button type="primary" size="mini" @click="onClickAddMiniPro">添加小程序</el-button>
9
+      </div>
10
+    </div>
11
+    <el-table :height="height" :data="miniProList" tooltip-effect="dark" style="width: 100%;margin-top:10px">
12
+      <el-table-column label="小程序" prop="name" min-width="200" align="center" />
13
+      <el-table-column label="APPID" prop="name" min-width="200" align="center" />
14
+      <el-table-column label="创建时间" prop="created_at" min-width="160" align="center" />
15
+      <el-table-column label="状态" min-width="160" align="center">
16
+        <template slot-scope="{ row }">
17
+          <span v-if="row.enable == 1" class="c-448AFF">启用</span>
18
+          <span v-else class="c-F03F5C">禁用</span>
19
+        </template>
20
+      </el-table-column>
21
+      <el-table-column label="操作" min-width="160" align="center">
22
+        <template slot-scope="{ row }">
23
+          <el-button type="primary" size="mini" @click="onClickEditMiniPro(row)">编辑</el-button>
24
+          <el-button v-if="row.enable == 1" type="danger" size="mini" @click="onClickEnable(row, 0)">禁用</el-button>
25
+          <el-button v-else type="primary" size="mini" @click="onClickEnable(row, 1)">启用</el-button>
26
+        </template>
27
+      </el-table-column>
28
+    </el-table>
29
+    <div class="pagination" v-show="pagination.total > 0">
30
+      <el-pagination background :current-page="pagination.page" @current-change="handleCurrentChange" layout="prev, pager, next" :page-count="Number(pagination.pages)">
31
+      </el-pagination>
32
+    </div>
33
+
34
+    <!-- S 添加小程序 & 编辑小程序 -->
35
+    <addMiniProDialog
36
+      :dialogVisible="addMiniProDialogVisible"
37
+      :miniProInfo="currentMiniProInfo"
38
+      @confirm="handleAddMiniProConfirm"
39
+      @cancel="handleAddMiniProCancel"
40
+    />
41
+    <!-- E 添加小程序 & 编辑小程序 -->
42
+  </div>
43
+</template>
44
+<script>
45
+import selfInput from '@/components/assembly/screen/input.vue'
46
+import addMiniProDialog from './dialog/addMiniProDialog.vue'
47
+export default {
48
+  name: 'miniProManage',
49
+  components: {
50
+    selfInput,
51
+    addMiniProDialog,
52
+  },
53
+  data () {
54
+    return {
55
+      height: '',
56
+      loading: false,
57
+      pagination: {
58
+        page: 1,
59
+        page_size: 20,
60
+        pages: 0,
61
+        total: 0,
62
+      },
63
+      filter: {
64
+        keyword: '',
65
+      },
66
+      miniProList: [],
67
+
68
+      addMiniProDialogVisible: false, // 控制"添加账号"弹框显示
69
+      currentMiniProInfo: {}, // 当前编辑的账号信息
70
+    }
71
+  },
72
+  created () {
73
+    this.height = document.documentElement.clientHeight - 200 > 400 ? document.documentElement.clientHeight - 200 : 400
74
+    this.handleGetMiniPro()
75
+  },
76
+  methods: {
77
+    // 获取列表数据
78
+    async handleGetMiniPro() {
79
+      try {
80
+        this.loading = true
81
+        const url = `${this.URL.BASEURL}${this.URL.pitcher_dramaList}`
82
+        const params = {
83
+          is_select: 0,
84
+          keyword: this.filter.keyword,
85
+          page: this.pagination.page,
86
+          page_size: this.pagination.page_size,
87
+        }
88
+        const { data: res = {} } = await this.$axios.get(url, { params })
89
+        if (res && res.errno == 0 && Array.isArray(res.rst.data)) {
90
+          this.miniProList = res.rst.data;
91
+          this.pagination.total = res.rst.pageInfo.total;
92
+          this.pagination.pages = res.rst.pageInfo.pages;
93
+        } else if (res.errno != 4002) {
94
+          this.$message.warning(res.err)
95
+          this.miniProList = [];
96
+          this.pagination.total = 0;
97
+          this.pagination.pages = 0;
98
+        }
99
+      } catch (error) {
100
+        console.log(error)
101
+        this.miniProList = [];
102
+        this.pagination.total = 0;
103
+        this.pagination.pages = 0;
104
+      } finally {
105
+        this.loading = false
106
+      }
107
+    },
108
+    // 监听当前页数变化
109
+    handleCurrentChange(currentPage) {
110
+      this.pagination.page = currentPage
111
+      this.handleGetMiniPro()
112
+    },
113
+    // 监听搜索小程序变化
114
+    onInputKeyword(val) {
115
+      console.log('onInputKeyword => ', val)
116
+      this.filter.keyword = val || ''
117
+      this.pagination.page = 1
118
+      this.handleGetMiniPro()
119
+    },
120
+
121
+    // S 添加 & 编辑账号
122
+    // 监听点击"添加账号"
123
+    onClickAddMiniPro() {
124
+      this.currentMiniProInfo = {}
125
+      this.addMiniProDialogVisible = true
126
+    },
127
+    // 监听点击"编辑账号"
128
+    onClickEditMiniPro(miniProInfo) {
129
+      this.currentMiniProInfo = miniProInfo
130
+      this.addMiniProDialogVisible = true
131
+    },
132
+    // 添加小程序 & 编辑小程序 => 确定
133
+    handleAddMiniProConfirm({ isEdit }) {
134
+      this.addMiniProDialogVisible = false
135
+      if (!isEdit) this.pagination.page = 1
136
+      this.handleGetMiniPro()
137
+    },
138
+    // 添加小程序 & 编辑小程序 => 取消
139
+    handleAddMiniProCancel() {
140
+      this.addMiniProDialogVisible = false
141
+    },
142
+    // E 添加 & 编辑账号
143
+
144
+    // S 禁用、启用平台
145
+    // 监听点击"禁用"、"启用"按钮
146
+    async onClickEnable(currentAccount, eventCode) {
147
+      try {
148
+        const h = this.$createElement
149
+        await this.$confirm('', {
150
+          message:h('div', null, [
151
+            h('span', null, `确定${eventCode === 0 ? '禁用' : '启用'}`),
152
+            h('span', { style:'color: #32B38A;' }, `${currentAccount.name}`),
153
+            h('span', null, '吗?'),
154
+          ]),
155
+          confirmButtonText: '确定',
156
+          cancelButtonText: '取消',
157
+          type: 'warning',
158
+        })
159
+        this.handleEnable(currentAccount, eventCode)
160
+      } catch (error) {
161
+        console.log(error)
162
+      }
163
+    },
164
+    // 执行"禁用"、"启用"
165
+    async handleEnable(currentAccount, eventCode) {
166
+      try {
167
+        let url = `${this.URL.BASEURL}${this.URL.xxx}`
168
+        const params = {
169
+          id: currentAccount.id,
170
+          enable: eventCode,
171
+        }
172
+        console.log('url => ', url)
173
+        console.log('params => ', params)
174
+        return // mock
175
+        this.loading = true
176
+        const { data: res = {} } = await this.$axios.post(url, params)
177
+        if (res && res.errno == 0) {
178
+          this.$message.success('操作成功')
179
+          this.handleGetMiniPro()
180
+        } else if (res.errno != 4002) {
181
+          this.$message.warning(res.err || '操作失败')
182
+        }
183
+      } catch (error) {
184
+        console.log('error => ', error)
185
+      } finally {
186
+        this.loading = false
187
+      }
188
+    },
189
+    // E 禁用、启用平台
190
+  }
191
+}
192
+</script>
193
+<style lang="scss" scoped>
194
+.screenBox {
195
+  background: #fff;
196
+  padding: 5px 20px;
197
+}
198
+</style>

+ 12 - 0
project/src/router/allRouter.js

@@ -64,6 +64,8 @@ const loseUserTrends = () => import(/* webpackChunkName: 'loseUserTrends' */ '@/
64 64
 
65 65
 // 平台账号管理
66 66
 const accountManage = () => import(/* webpackChunkName: 'accountManage' */ '@/components/manage/accountManage/accountManage.vue')
67
+// 小程序管理
68
+const miniProManage = () => import(/* webpackChunkName: 'miniProManage' */ '@/components/manage/miniProManage/miniProManage.vue')
67 69
 
68 70
 // name与菜单配置的页面路由一致
69 71
 // meta下isData:true为数据看板,否则为助手
@@ -326,6 +328,16 @@ export var allRouter = [
326 328
         }
327 329
       },
328 330
       {
331
+        path: 'miniProManage',
332
+        name: 'miniProManage',
333
+        component: miniProManage,
334
+        meta: {
335
+          keepAlive: false,
336
+          isLogin: true,
337
+          title: '小程序管理'
338
+        }
339
+      },
340
+      {
329 341
         path: 'memberManage',
330 342
         name: 'memberManage',
331 343
         component: memberManage,