Commit a341c44c4dae92fde95a61abf4a1e276ac41dba0

Authored by YunaiV
1 parent d1cc9dde

mp:实现 tag 模块的前端界面

yudao-ui-admin/src/api/wechatMp/wxAccountFansTag.js renamed to yudao-ui-admin/src/api/mp/tag.js
1 import request from '@/utils/request' 1 import request from '@/utils/request'
2 2
3 -// 创建粉丝标签关联  
4 -export function createWxAccountFansTag(data) { 3 +// 创建公众号标签
  4 +export function createTag(data) {
5 return request({ 5 return request({
6 - url: '/wechatMp/wx-account-fans-tag/create', 6 + url: '/mp/tag/create',
7 method: 'post', 7 method: 'post',
8 data: data 8 data: data
9 }) 9 })
10 } 10 }
11 11
12 -// 更新粉丝标签关联  
13 -export function updateWxAccountFansTag(data) { 12 +// 更新公众号标签
  13 +export function updateTag(data) {
14 return request({ 14 return request({
15 - url: '/wechatMp/wx-account-fans-tag/update', 15 + url: '/mp/tag/update',
16 method: 'put', 16 method: 'put',
17 data: data 17 data: data
18 }) 18 })
19 } 19 }
20 20
21 -// 删除粉丝标签关联  
22 -export function deleteWxAccountFansTag(id) { 21 +// 删除公众号标签
  22 +export function deleteTag(id) {
23 return request({ 23 return request({
24 - url: '/wechatMp/wx-account-fans-tag/delete?id=' + id, 24 + url: '/mp/tag/delete?id=' + id,
25 method: 'delete' 25 method: 'delete'
26 }) 26 })
27 } 27 }
28 28
29 -// 获得粉丝标签关联  
30 -export function getWxAccountFansTag(id) { 29 +// 获得公众号标签
  30 +export function getTag(id) {
31 return request({ 31 return request({
32 - url: '/wechatMp/wx-account-fans-tag/get?id=' + id, 32 + url: '/mp/tag/get?id=' + id,
33 method: 'get' 33 method: 'get'
34 }) 34 })
35 } 35 }
36 36
37 -// 获得粉丝标签关联分页  
38 -export function getWxAccountFansTagPage(query) { 37 +// 获得公众号标签分页
  38 +export function getTagPage(query) {
39 return request({ 39 return request({
40 - url: '/wechatMp/wx-account-fans-tag/page', 40 + url: '/mp/tag/page',
41 method: 'get', 41 method: 'get',
42 params: query 42 params: query
43 }) 43 })
44 } 44 }
45 45
46 -// 导出粉丝标签关联 Excel  
47 -export function exportWxAccountFansTagExcel(query) { 46 +// 同步公众号标签
  47 +export function syncTag(accountId) {
48 return request({ 48 return request({
49 - url: '/wechatMp/wx-account-fans-tag/export-excel',  
50 - method: 'get',  
51 - params: query,  
52 - responseType: 'blob' 49 + url: '/mp/tag/sync?accountId=' + accountId,
  50 + method: 'post'
53 }) 51 })
54 } 52 }
yudao-ui-admin/src/api/wechatMp/wxFansTag.js deleted
1 -import request from '@/utils/request'  
2 -  
3 -// 创建粉丝标签  
4 -export function createWxFansTag(data) {  
5 - return request({  
6 - url: '/wechatMp/fans-tag/create',  
7 - method: 'post',  
8 - data: data  
9 - })  
10 -}  
11 -  
12 -// 更新粉丝标签  
13 -export function updateWxFansTag(data) {  
14 - return request({  
15 - url: '/wechatMp/fans-tag/update',  
16 - method: 'put',  
17 - data: data  
18 - })  
19 -}  
20 -  
21 -// 删除粉丝标签  
22 -export function deleteWxFansTag(id) {  
23 - return request({  
24 - url: '/wechatMp/fans-tag/delete?id=' + id,  
25 - method: 'delete'  
26 - })  
27 -}  
28 -  
29 -// 获得粉丝标签  
30 -export function getWxFansTag(id) {  
31 - return request({  
32 - url: '/wechatMp/fans-tag/get?id=' + id,  
33 - method: 'get'  
34 - })  
35 -}  
36 -  
37 -// 获得粉丝标签分页  
38 -export function getWxFansTagList(query) {  
39 - return request({  
40 - url: '/wechatMp/fans-tag/list',  
41 - method: 'get',  
42 - params: query  
43 - })  
44 -}  
45 -  
46 -// 导出粉丝标签 Excel  
47 -export function exportWxFansTagExcel(query) {  
48 - return request({  
49 - url: '/wechatMp/fans-tag/export-excel',  
50 - method: 'get',  
51 - params: query,  
52 - responseType: 'blob'  
53 - })  
54 -}  
yudao-ui-admin/src/views/mp/account/index.vue
@@ -137,8 +137,6 @@ export default { @@ -137,8 +137,6 @@ export default {
137 return { 137 return {
138 // 遮罩层 138 // 遮罩层
139 loading: true, 139 loading: true,
140 - // 导出遮罩层  
141 - exportLoading: false,  
142 // 显示搜索条件 140 // 显示搜索条件
143 showSearch: true, 141 showSearch: true,
144 // 总条数 142 // 总条数
@@ -167,8 +165,6 @@ export default { @@ -167,8 +165,6 @@ export default {
167 appSecret: [{required: true, message: '公众号密钥不能为空', trigger: 'blur'}], 165 appSecret: [{required: true, message: '公众号密钥不能为空', trigger: 'blur'}],
168 token: [{required: true, message: '公众号 token 不能为空', trigger: 'blur'}], 166 token: [{required: true, message: '公众号 token 不能为空', trigger: 'blur'}],
169 }, 167 },
170 - // 禁用属性  
171 - disabled: false,  
172 } 168 }
173 }, 169 },
174 created() { 170 created() {
@@ -190,7 +186,6 @@ export default { @@ -190,7 +186,6 @@ export default {
190 /** 取消按钮 */ 186 /** 取消按钮 */
191 cancel() { 187 cancel() {
192 this.open = false 188 this.open = false
193 - this.disabled = false  
194 this.reset() 189 this.reset()
195 }, 190 },
196 /** 表单重置 */ 191 /** 表单重置 */
@@ -232,7 +227,6 @@ export default { @@ -232,7 +227,6 @@ export default {
232 this.form = response.data 227 this.form = response.data
233 this.open = true 228 this.open = true
234 this.title = '修改公众号账号' 229 this.title = '修改公众号账号'
235 - this.disabled = true  
236 }) 230 })
237 }, 231 },
238 /** 提交按钮 */ 232 /** 提交按钮 */
@@ -283,7 +277,7 @@ export default { @@ -283,7 +277,7 @@ export default {
283 /** 清空二维码 API 配额的按钮操作 */ 277 /** 清空二维码 API 配额的按钮操作 */
284 handleCleanQuota(row) { 278 handleCleanQuota(row) {
285 const id = row.id 279 const id = row.id
286 - this.$modal.confirm('是否清空生成公众号账号编号为"' + row.name + '"的 API 配额?').then(function () { 280 + this.$modal.confirm('是否确认清空生成公众号账号编号为"' + row.name + '"的 API 配额?').then(function () {
287 return clearAccountQuota(id) 281 return clearAccountQuota(id)
288 }).then(() => { 282 }).then(() => {
289 this.$modal.msgSuccess('清空 API 配额成功') 283 this.$modal.msgSuccess('清空 API 配额成功')
yudao-ui-admin/src/views/mp/tag/index.vue
@@ -3,10 +3,14 @@ @@ -3,10 +3,14 @@
3 3
4 <!-- 搜索工作栏 --> 4 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  6 + <el-form-item label="公众号" prop="accountId">
  7 + <el-select v-model="queryParams.accountId" placeholder="请选择公众号">
  8 + <el-option v-for="item in accounts" :key="parseInt(item.id)" :label="item.name" :value="parseInt(item.id)" />
  9 + </el-select>
  10 + </el-form-item>
6 <el-form-item label="标签名称" prop="name"> 11 <el-form-item label="标签名称" prop="name">
7 <el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/> 12 <el-input v-model="queryParams.name" placeholder="请输入标签名称" clearable @keyup.enter.native="handleQuery"/>
8 </el-form-item> 13 </el-form-item>
9 -  
10 <el-form-item> 14 <el-form-item>
11 <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> 15 <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
12 <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> 16 <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
@@ -17,54 +21,41 @@ @@ -17,54 +21,41 @@
17 <el-row :gutter="10" class="mb8"> 21 <el-row :gutter="10" class="mb8">
18 <el-col :span="1.5"> 22 <el-col :span="1.5">
19 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" 23 <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
20 - v-hasPermi="['wechatMp:fans-tag:create']">新增 24 + v-hasPermi="['mp:tag:create']">新增
21 </el-button> 25 </el-button>
22 </el-col> 26 </el-col>
23 <el-col :span="1.5"> 27 <el-col :span="1.5">
24 - <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"  
25 - :loading="exportLoading"  
26 - v-hasPermi="['wechatMp:fans-tag:export']">导出 28 + <el-button type="info" plain icon="el-icon-refresh" size="mini" @click="handleSync"
  29 + v-hasPermi="['mp:tag:sync']">同步
27 </el-button> 30 </el-button>
28 </el-col> 31 </el-col>
29 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> 32 <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
30 </el-row> 33 </el-row>
31 - <div style="display: flex;width: auto">  
32 - <div class="left_column" style="border: 1px solid #EBEEF5FF; width: 15%;height: auto">  
33 - <div style="padding: 10px 20px; border-bottom: 1px solid #ebeef5; box-sizing: border-box;"><span  
34 - style="font-size: 16px">公众号名称</span></div>  
35 -  
36 - <div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">  
37 - <input type="text" placeholder="输入关键字进行过滤"  
38 - class="el-input__inner"/>  
39 - </div>  
40 -  
41 - <div style="margin-top: 10px;margin-right: 5px;margin-left: 5px">  
42 - <div style="margin-right: 5px;margin-left: 5px" v-for="(account,index) in accountList" @click="getAccountTag(account.appId)">{{ account.name }}</div>  
43 - </div>  
44 - </div>  
45 - <div class="right_column" style="width: 85%">  
46 - <!-- 列表 -->  
47 - <el-table v-loading="loading" :data="list">  
48 - <el-table-column label="编号" align="center" prop="id"/>  
49 - <el-table-column label="标签名称" align="center" prop="name"/>  
50 - <el-table-column label="操作" align="center" class-name="small-padding fixed-width">  
51 - <template slot-scope="scope">  
52 - <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"  
53 - v-hasPermi="['wechatMp:fans-tag:update']">修改  
54 - </el-button>  
55 - <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"  
56 - v-hasPermi="['wechatMp:fans-tag:delete']">删除  
57 - </el-button>  
58 - </template>  
59 - </el-table-column>  
60 - </el-table>  
61 - <!-- 分页组件 -->  
62 - <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"  
63 - @pagination="getList"/>  
64 -  
65 - </div>  
66 - </div>  
67 34
  35 + <!-- 列表 -->
  36 + <el-table v-loading="loading" :data="list">
  37 + <el-table-column label="编号" align="center" prop="id"/>
  38 + <el-table-column label="标签名称" align="center" prop="name"/>
  39 + <el-table-column label="粉丝数" align="center" prop="count"/>
  40 + <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  41 + <template slot-scope="scope">
  42 + <span>{{ parseTime(scope.row.createTime) }}</span>
  43 + </template>
  44 + </el-table-column>
  45 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  46 + <template slot-scope="scope">
  47 + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  48 + v-hasPermi="['mp:tag:update']">修改
  49 + </el-button>
  50 + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  51 + v-hasPermi="['mp:tag:delete']">删除
  52 + </el-button>
  53 + </template>
  54 + </el-table-column>
  55 + </el-table>
  56 + <!-- 分页组件 -->
  57 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  58 + @pagination="getList"/>
68 59
69 <!-- 对话框(添加 / 修改) --> 60 <!-- 对话框(添加 / 修改) -->
70 <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> 61 <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@@ -72,12 +63,6 @@ @@ -72,12 +63,6 @@
72 <el-form-item label="标签名称" prop="name"> 63 <el-form-item label="标签名称" prop="name">
73 <el-input v-model="form.name" placeholder="请输入标签名称"/> 64 <el-input v-model="form.name" placeholder="请输入标签名称"/>
74 </el-form-item> 65 </el-form-item>
75 - <el-form-item label="粉丝数量" prop="count">  
76 - <el-input v-model="form.count" placeholder="请输入粉丝数量"/>  
77 - </el-form-item>  
78 - <el-form-item label="微信账号ID" prop="wxAccountId">  
79 - <el-input v-model="form.wxAccountId" placeholder="请输入微信账号ID"/>  
80 - </el-form-item>  
81 </el-form> 66 </el-form>
82 <div slot="footer" class="dialog-footer"> 67 <div slot="footer" class="dialog-footer">
83 <el-button type="primary" @click="submitForm">确 定</el-button> 68 <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -87,89 +72,83 @@ @@ -87,89 +72,83 @@
87 </div> 72 </div>
88 </template> 73 </template>
89 74
90 -<style>  
91 -.left_column {  
92 - height: 100%;  
93 - position: relative;  
94 - overflow: auto;  
95 -}  
96 -</style>  
97 -  
98 <script> 75 <script>
99 import { 76 import {
100 - createWxFansTag,  
101 - deleteWxFansTag,  
102 - exportWxFansTagExcel,  
103 - getWxFansTag,  
104 - getWxFansTagList,  
105 - updateWxFansTag  
106 -} from '@/api/wechatMp/wxFansTag'  
107 -import {getAccountPage} from '@/api/mp/account' 77 + createTag,
  78 + updateTag,
  79 + deleteTag,
  80 + getTag,
  81 + getTagPage,
  82 + syncTag,
  83 +} from '@/api/mp/tag'
  84 +import { getSimpleAccounts} from '@/api/mp/account'
108 85
109 export default { 86 export default {
110 - name: 'WxFansTag', 87 + name: 'MpTag',
111 components: {}, 88 components: {},
112 data() { 89 data() {
113 return { 90 return {
114 // 遮罩层 91 // 遮罩层
115 loading: true, 92 loading: true,
116 - // 导出遮罩层  
117 - exportLoading: false,  
118 // 显示搜索条件 93 // 显示搜索条件
119 showSearch: true, 94 showSearch: true,
120 // 总条数 95 // 总条数
121 total: 0, 96 total: 0,
122 - // 粉丝标签列表 97 + // 公众号标签列表
123 list: [], 98 list: [],
124 - // 账号列表  
125 - accountList: [],  
126 // 弹出层标题 99 // 弹出层标题
127 title: '', 100 title: '',
128 // 是否显示弹出层 101 // 是否显示弹出层
129 open: false, 102 open: false,
130 - dateRangeCreateTime: [],  
131 // 查询参数 103 // 查询参数
132 queryParams: { 104 queryParams: {
133 - appId: null, 105 + accountId: null,
  106 + name: null,
134 }, 107 },
135 // 表单参数 108 // 表单参数
136 - form: {}, 109 + form: {
  110 + accountId: undefined,
  111 + name: undefined,
  112 + },
137 // 表单校验 113 // 表单校验
138 - rules: {} 114 + rules: {
  115 + name: [{ required: true, message: '请输入标签名称', trigger: 'blur' }]
  116 + },
  117 +
  118 + // 公众号账号列表
  119 + accounts: []
139 } 120 }
140 }, 121 },
141 created() { 122 created() {
142 - this.getAccountList() 123 + getSimpleAccounts().then(response => {
  124 + this.accounts = response.data;
  125 + // 默认选中第一个
  126 + if (this.accounts.length > 0) {
  127 + this.queryParams.accountId = this.accounts[0].id;
  128 + }
  129 + // 加载数据
  130 + this.getList();
  131 + })
143 }, 132 },
144 methods: { 133 methods: {
145 /** 查询列表 */ 134 /** 查询列表 */
146 - getList(appId) { 135 + getList() {
  136 + // 如果没有选中公众号账号,则进行提示。
  137 + if (!this.queryParams.accountId) {
  138 + this.$message.error('未选中公众号,无法查询标签')
  139 + return false
  140 + }
  141 +
147 this.loading = false 142 this.loading = false
148 - this.queryParams.appId = appId  
149 // 处理查询参数 143 // 处理查询参数
150 let params = {...this.queryParams} 144 let params = {...this.queryParams}
151 // 执行查询 145 // 执行查询
152 - getWxFansTagList(params).then(response => {  
153 - this.list = response.data 146 + getTagPage(params).then(response => {
  147 + this.list = response.data.list
  148 + this.total = response.data.total
154 this.loading = false 149 this.loading = false
155 }) 150 })
156 }, 151 },
157 - /** 查询列表 */  
158 - getAccountList() {  
159 - // 执行查询  
160 - getAccountPage().then(response => {  
161 - this.accountList = response.data.list  
162 - })  
163 - },  
164 -  
165 - /**  
166 - * 获取帐户标签  
167 - * @param appId 公众号appId  
168 - */  
169 - getAccountTag(appId) {  
170 - this.getList(appId)  
171 - },  
172 -  
173 /** 取消按钮 */ 152 /** 取消按钮 */
174 cancel() { 153 cancel() {
175 this.open = false 154 this.open = false
@@ -178,7 +157,8 @@ export default { @@ -178,7 +157,8 @@ export default {
178 /** 表单重置 */ 157 /** 表单重置 */
179 reset() { 158 reset() {
180 this.form = { 159 this.form = {
181 - appId: undefined, 160 + accountId: undefined,
  161 + name: undefined,
182 } 162 }
183 this.resetForm('form') 163 this.resetForm('form')
184 }, 164 },
@@ -189,24 +169,27 @@ export default { @@ -189,24 +169,27 @@ export default {
189 }, 169 },
190 /** 重置按钮操作 */ 170 /** 重置按钮操作 */
191 resetQuery() { 171 resetQuery() {
192 - this.dateRangeCreateTime = []  
193 this.resetForm('queryForm') 172 this.resetForm('queryForm')
  173 + // 默认选中第一个
  174 + if (this.accounts.length > 0) {
  175 + this.queryParams.accountId = this.accounts[0].id;
  176 + }
194 this.handleQuery() 177 this.handleQuery()
195 }, 178 },
196 /** 新增按钮操作 */ 179 /** 新增按钮操作 */
197 handleAdd() { 180 handleAdd() {
198 this.reset() 181 this.reset()
199 this.open = true 182 this.open = true
200 - this.title = '添加粉丝标签' 183 + this.title = '添加公众号标签'
201 }, 184 },
202 /** 修改按钮操作 */ 185 /** 修改按钮操作 */
203 handleUpdate(row) { 186 handleUpdate(row) {
204 this.reset() 187 this.reset()
205 const id = row.id 188 const id = row.id
206 - getWxFansTag(id).then(response => { 189 + getTag(id).then(response => {
207 this.form = response.data 190 this.form = response.data
208 this.open = true 191 this.open = true
209 - this.title = '修改粉丝标签' 192 + this.title = '修改公众号标签'
210 }) 193 })
211 }, 194 },
212 /** 提交按钮 */ 195 /** 提交按钮 */
@@ -215,9 +198,10 @@ export default { @@ -215,9 +198,10 @@ export default {
215 if (!valid) { 198 if (!valid) {
216 return 199 return
217 } 200 }
  201 + this.form.accountId = this.queryParams.accountId;
218 // 修改的提交 202 // 修改的提交
219 if (this.form.id != null) { 203 if (this.form.id != null) {
220 - updateWxFansTag(this.form).then(response => { 204 + updateTag(this.form).then(response => {
221 this.$modal.msgSuccess('修改成功') 205 this.$modal.msgSuccess('修改成功')
222 this.open = false 206 this.open = false
223 this.getList() 207 this.getList()
@@ -225,7 +209,7 @@ export default { @@ -225,7 +209,7 @@ export default {
225 return 209 return
226 } 210 }
227 // 添加的提交 211 // 添加的提交
228 - createWxFansTag(this.form).then(response => { 212 + createTag(this.form).then(response => {
229 this.$modal.msgSuccess('新增成功') 213 this.$modal.msgSuccess('新增成功')
230 this.open = false 214 this.open = false
231 this.getList() 215 this.getList()
@@ -235,31 +219,24 @@ export default { @@ -235,31 +219,24 @@ export default {
235 /** 删除按钮操作 */ 219 /** 删除按钮操作 */
236 handleDelete(row) { 220 handleDelete(row) {
237 const id = row.id 221 const id = row.id
238 - this.$modal.confirm('是否确认删除粉丝标签编号为"' + id + '"的数据项?').then(function () {  
239 - return deleteWxFansTag(id) 222 + this.$modal.confirm('是否确认删除公众号标签编号为"' + id + '"的数据项?').then(function () {
  223 + return deleteTag(id)
240 }).then(() => { 224 }).then(() => {
241 this.getList() 225 this.getList()
242 this.$modal.msgSuccess('删除成功') 226 this.$modal.msgSuccess('删除成功')
243 }).catch(() => { 227 }).catch(() => {
244 }) 228 })
245 }, 229 },
246 - /** 导出按钮操作 */  
247 - handleExport() {  
248 - // 处理查询参数  
249 - let params = {...this.queryParams}  
250 - params.pageNo = undefined  
251 - params.pageSize = undefined  
252 - this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime')  
253 - // 执行导出  
254 - this.$modal.confirm('是否确认导出所有粉丝标签数据项?').then(() => {  
255 - this.exportLoading = true  
256 - return exportWxFansTagExcel(params)  
257 - }).then(response => {  
258 - this.$download.excel(response, '粉丝标签.xls')  
259 - this.exportLoading = false 230 + /** 同步标签 */
  231 + handleSync() {
  232 + const accountId = this.queryParams.accountId
  233 + this.$modal.confirm('是否确认同步标签?').then(function () {
  234 + return syncTag(accountId)
  235 + }).then(() => {
  236 + this.$modal.msgSuccess('同步标签成功')
260 }).catch(() => { 237 }).catch(() => {
261 }) 238 })
262 - } 239 + },
263 } 240 }
264 } 241 }
265 </script> 242 </script>