公众号回复调整

This commit is contained in:
Jason 2022-09-30 14:05:38 +08:00
parent 8052475e40
commit e191fc8d26
9 changed files with 152 additions and 66 deletions

View File

@ -1,4 +1,5 @@
import request from '@/utils/request' import request from '@/utils/request'
import { firstToUpperCase } from '@/utils/util'
// 微信公众号配置保存 // 微信公众号配置保存
export function setOaConfig(params: any) { export function setOaConfig(params: any) {
@ -47,12 +48,11 @@ export function setOaMenuPublish(params: Menu | any) {
} }
/** /**
* @return { Promise } * @description
* @param { string } type
* @description
*/ */
export function getOaReplyList(params: { type: string }) { export function getOaReplyList(params: any) {
return request.get({ url: '/channel/oaReply/list', params }) const type = firstToUpperCase(params.type)
return request.get({ url: `/channel/oaReply${type}/list`, params })
} }
/** /**
@ -60,8 +60,9 @@ export function getOaReplyList(params: { type: string }) {
* @param { number } id * @param { number } id
* @description * @description
*/ */
export function oaReplyDel(params: { id: number }) { export function oaReplyDel(params: any) {
return request.post({ url: '/channel/oaReply/del', params }) const type = firstToUpperCase(params.type)
return request.post({ url: `/channel/oaReply${type}/del`, params })
} }
/** /**
@ -69,8 +70,9 @@ export function oaReplyDel(params: { id: number }) {
* @param { number } id * @param { number } id
* @description * @description
*/ */
export function changeOaReplyStatus(params: { id: number }) { export function changeOaReplyStatus(params: any) {
return request.post({ url: '/channel/oaReply/status', params }) const type = firstToUpperCase(params.type)
return request.post({ url: `/channel/oaReply${type}/status`, params })
} }
export interface Reply { export interface Reply {
@ -85,25 +87,26 @@ export interface Reply {
} }
/** /**
* @return { Promise } * @return { Promise }
* @description * @description
*/ */
export function oaReplyAdd(params: Reply) { export function oaReplyAdd(params: Reply) {
return request.post({ url: '/channel/oaReply/add', params }) const type = firstToUpperCase(params.type)
return request.post({ url: `/channel/oaReply${type}/add`, params })
} }
/** /**
* @return { Promise } * @return { Promise }
* @description * @description
*/ */
export function oaReplyEdit(params: Reply) { export function oaReplyEdit(params: Reply) {
return request.post({ url: '/channel/oaReply/edit', params }) const type = firstToUpperCase(params.type)
return request.post({ url: `/channel/oaReply${type}/edit`, params })
} }
/** /**
* @return { Promise } * @description
* @param { string } type
* @description
*/ */
export function getOaReplyDetail(params: { id: number }) { export function getOaReplyDetail(params: any) {
return request.get({ url: '/channel/oaReply/detail', params }) const type = firstToUpperCase(params.type)
return request.get({ url: `/channel/oaReply${type}/detail`, params })
} }

View File

@ -2,7 +2,7 @@ const config = {
terminal: 1, //终端 terminal: 1, //终端
title: '后台管理系统', //网站默认标题 title: '后台管理系统', //网站默认标题
version: '1.2.0', //版本号 version: '1.2.0', //版本号
baseUrl: `${import.meta.env.VITE_APP_BASE_URL}/`, //请求接口域名 baseUrl: `${import.meta.env.VITE_APP_BASE_URL || ''}/`, //请求接口域名
urlPrefix: 'api', //请求默认前缀 urlPrefix: 'api', //请求默认前缀
timeout: 10 * 1000 //请求超时时长 timeout: 10 * 1000 //请求超时时长
} }

View File

@ -160,3 +160,12 @@ export const getNonDuplicateID = (length = 8) => {
idStr += Math.random().toString(36).substring(3, length) idStr += Math.random().toString(36).substring(3, length)
return idStr return idStr
} }
/**
* @description
* @param { String } str
* @return { String } id
*/
export const firstToUpperCase = (str = '') => {
return str.toLowerCase().replace(/( |^)[a-z]/g, ($1) => $1.toUpperCase())
}

View File

@ -37,9 +37,9 @@
<el-card class="!border-none mt-4" shadow="never"> <el-card class="!border-none mt-4" shadow="never">
<div> <div>
<router-link <router-link
v-perms="['article:add']" v-perms="['article:add', 'article:add/edit']"
:to="{ :to="{
path: getRoutePath('article:edit') path: getRoutePath('article:add/edit')
}" }"
> >
<el-button type="primary" class="mb-4"> <el-button type="primary" class="mb-4">
@ -89,10 +89,10 @@
<el-table-column label="发布时间" prop="createTime" min-width="120" /> <el-table-column label="发布时间" prop="createTime" min-width="120" />
<el-table-column label="操作" width="120" fixed="right"> <el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button v-perms="['article:edit']" type="primary" link> <el-button v-perms="['article:edit','article:add/edit']" type="primary" link>
<router-link <router-link
:to="{ :to="{
path: getRoutePath('article:edit'), path: getRoutePath('article:add/edit'),
query: { query: {
id: row.id id: row.id
} }

View File

@ -10,24 +10,30 @@
</el-card> </el-card>
<el-card class="!border-none mt-4" shadow="never"> <el-card class="!border-none mt-4" shadow="never">
<div> <div>
<el-button class="mb-4" type="primary" @click="handleAdd()"> <el-button
v-perms="['channel:oaReplyDefault:add']"
class="mb-4"
type="primary"
@click="handleAdd()"
>
<template #icon> <template #icon>
<icon name="el-icon-Plus" /> <icon name="el-icon-Plus" />
</template> </template>
新增 新增
</el-button> </el-button>
</div> </div>
<el-table size="large" :data="lists"> <el-table size="large" :data="pager.lists" v-loading="pager.loading">
<el-table-column label="规则名称" prop="name" min-width="120" /> <el-table-column label="规则名称" prop="name" min-width="120" />
<el-table-column label="回复类型" min-width="120"> <el-table-column label="回复类型" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
{{ getContentType(1) }} {{ getContentType(row.contentType) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="回复内容" prop="content" min-width="120" /> <el-table-column label="回复内容" prop="content" min-width="120" />
<el-table-column label="状态" min-width="120"> <el-table-column label="状态" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-perms="['channel:oaReplyDefault:status']"
v-model="row.status" v-model="row.status"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
@ -38,25 +44,40 @@
<el-table-column label="排序" prop="sort" min-width="120" /> <el-table-column label="排序" prop="sort" min-width="120" />
<el-table-column label="操作" width="120" fixed="right"> <el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link @click="handleEdit(row)"> 编辑 </el-button> <el-button
<el-button type="danger" link @click="handleDelete(row.id)"> v-perms="['channel:oaReplyDefault:edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['channel:oaReplyDefault:del']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除 删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="flex justify-end mt-4">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card> </el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" /> <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa' import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>() const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false) const showEdit = ref(false)
const lists = ref() const type = 'default'
const getContentType = computed(() => { const getContentType = computed(() => {
return (val: number) => { return (val: number) => {
switch (val) { switch (val) {
@ -66,33 +87,36 @@ const getContentType = computed(() => {
} }
}) })
const getLists = async () => { const { pager, getLists } = usePaging({
lists.value = await getOaReplyList({ type: 'default' }) fetchFun: getOaReplyList,
} params: {
type
}
})
const handleAdd = async () => { const handleAdd = async () => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('add', 'default') editRef.value?.open('add', type)
} }
const handleEdit = async (data: any) => { const handleEdit = async (data: any) => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('edit', 'default') editRef.value?.open('edit', type)
editRef.value?.getDetail(data) editRef.value?.getDetail(data)
} }
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?') await feedback.confirm('确定要删除?')
await oaReplyDel({ id }) await oaReplyDel({ id, type })
feedback.msgSuccess('删除成功') feedback.msgSuccess('删除成功')
getLists() getLists()
} }
const changeStatus = async (id: number) => { const changeStatus = async (id: number) => {
try { try {
await changeOaReplyStatus({ id }) await changeOaReplyStatus({ id, type })
feedback.msgSuccess('修改成功') feedback.msgSuccess('修改成功')
getLists() getLists()
} catch (error) { } catch (error) {

View File

@ -72,7 +72,7 @@
</el-form-item> --> </el-form-item> -->
<el-form-item label="排序"> <el-form-item label="排序">
<div class="flex-1"> <div class="flex-1">
<el-input v-model="formData.sort" placeholder="请输入" /> <el-input-number v-model="formData.sort" :min="0"/>
</div> </div>
</el-form-item> </el-form-item>
<el-form-item label="启用状态"> <el-form-item label="启用状态">
@ -172,7 +172,8 @@ const setFormData = (data: Record<any, any>) => {
const getDetail = async (row: Record<string, any>) => { const getDetail = async (row: Record<string, any>) => {
const data = await getOaReplyDetail({ const data = await getOaReplyDetail({
id: row.id id: row.id,
type: formData.type
}) })
setFormData(data) setFormData(data)
} }

View File

@ -10,14 +10,19 @@
</el-card> </el-card>
<el-card class="!border-none mt-4" shadow="never"> <el-card class="!border-none mt-4" shadow="never">
<div> <div>
<el-button class="mb-4" type="primary" @click="handleAdd()"> <el-button
v-perms="['channel:oaReplyFollow:add']"
class="mb-4"
type="primary"
@click="handleAdd()"
>
<template #icon> <template #icon>
<icon name="el-icon-Plus" /> <icon name="el-icon-Plus" />
</template> </template>
新增 新增
</el-button> </el-button>
</div> </div>
<el-table size="large" :data="lists"> <el-table size="large" :data="pager.lists" v-loading="pager.loading">
<el-table-column label="规则名称" prop="name" min-width="120" /> <el-table-column label="规则名称" prop="name" min-width="120" />
<el-table-column label="回复类型" min-width="120"> <el-table-column label="回复类型" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
@ -28,6 +33,7 @@
<el-table-column label="状态" min-width="120"> <el-table-column label="状态" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-perms="['channel:oaReplyFollow:status']"
v-model="row.status" v-model="row.status"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
@ -38,25 +44,41 @@
<el-table-column label="排序" prop="sort" min-width="120" /> <el-table-column label="排序" prop="sort" min-width="120" />
<el-table-column label="操作" width="120" fixed="right"> <el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link @click="handleEdit(row)"> 编辑 </el-button> <el-button
<el-button type="danger" link @click="handleDelete(row.id)"> v-perms="['channel:oaReplyFollow:edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['channel:oaReplyFollow:del']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除 删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="flex justify-end mt-4">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card> </el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" /> <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa' import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>() const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false) const showEdit = ref(false)
const lists = ref() const type = 'follow'
const getContentType = computed(() => { const getContentType = computed(() => {
return (val: number) => { return (val: number) => {
switch (val) { switch (val) {
@ -66,33 +88,36 @@ const getContentType = computed(() => {
} }
}) })
const getLists = async () => { const { pager, getLists } = usePaging({
lists.value = await getOaReplyList({ type: 'follow' }) fetchFun: getOaReplyList,
} params: {
type
}
})
const handleAdd = async () => { const handleAdd = async () => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('add', 'follow') editRef.value?.open('add', type)
} }
const handleEdit = async (data: any) => { const handleEdit = async (data: any) => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('edit', 'follow') editRef.value?.open('edit', type)
editRef.value?.getDetail(data) editRef.value?.getDetail(data)
} }
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?') await feedback.confirm('确定要删除?')
await oaReplyDel({ id }) await oaReplyDel({ id, type })
feedback.msgSuccess('删除成功') feedback.msgSuccess('删除成功')
getLists() getLists()
} }
const changeStatus = async (id: number) => { const changeStatus = async (id: number) => {
try { try {
await changeOaReplyStatus({ id }) await changeOaReplyStatus({ id, type })
feedback.msgSuccess('修改成功') feedback.msgSuccess('修改成功')
getLists() getLists()
} catch (error) { } catch (error) {

View File

@ -10,14 +10,19 @@
</el-card> </el-card>
<el-card class="!border-none mt-4" shadow="never"> <el-card class="!border-none mt-4" shadow="never">
<div> <div>
<el-button class="mb-4" type="primary" @click="handleAdd()"> <el-button
v-perms="['channel:oaReplyKeyword:add']"
class="mb-4"
type="primary"
@click="handleAdd()"
>
<template #icon> <template #icon>
<icon name="el-icon-Plus" /> <icon name="el-icon-Plus" />
</template> </template>
新增 新增
</el-button> </el-button>
</div> </div>
<el-table size="large" :data="lists"> <el-table size="large" :data="pager.lists" v-loading="pager.loading">
<el-table-column label="规则名称" prop="name" min-width="120" /> <el-table-column label="规则名称" prop="name" min-width="120" />
<el-table-column label="关键词" prop="keyword" min-width="120" /> <el-table-column label="关键词" prop="keyword" min-width="120" />
@ -34,6 +39,7 @@
<el-table-column label="状态" min-width="120"> <el-table-column label="状态" min-width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-switch <el-switch
v-perms="['channel:oaReplyKeyword:status']"
v-model="row.status" v-model="row.status"
:active-value="1" :active-value="1"
:inactive-value="0" :inactive-value="0"
@ -44,24 +50,39 @@
<el-table-column label="排序" prop="sort" min-width="120" /> <el-table-column label="排序" prop="sort" min-width="120" />
<el-table-column label="操作" width="120" fixed="right"> <el-table-column label="操作" width="120" fixed="right">
<template #default="{ row }"> <template #default="{ row }">
<el-button type="primary" link @click="handleEdit(row)"> 编辑 </el-button> <el-button
<el-button type="danger" link @click="handleDelete(row.id)"> v-perms="['channel:oaReplyKeyword:edit']"
type="primary"
link
@click="handleEdit(row)"
>
编辑
</el-button>
<el-button
v-perms="['channel:oaReplyKeyword:del']"
type="danger"
link
@click="handleDelete(row.id)"
>
删除 删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<div class="flex justify-end mt-4">
<pagination v-model="pager" @change="getLists" />
</div>
</el-card> </el-card>
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" /> <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa' import { oaReplyDel, getOaReplyList, changeOaReplyStatus } from '@/api/channel/wx_oa'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback' import feedback from '@/utils/feedback'
import EditPopup from './edit.vue' import EditPopup from './edit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>() const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false) const showEdit = ref(false)
const lists = ref()
const getMatchingType = computed(() => { const getMatchingType = computed(() => {
return (val: number) => { return (val: number) => {
@ -82,34 +103,37 @@ const getContentType = computed(() => {
} }
} }
}) })
const type = 'keyword'
const getLists = async () => { const { pager, getLists } = usePaging({
lists.value = await getOaReplyList({ type: 'keyword' }) fetchFun: getOaReplyList,
} params: {
type
}
})
const handleAdd = async () => { const handleAdd = async () => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('add', 'keyword') editRef.value?.open('add', type)
} }
const handleEdit = async (data: any) => { const handleEdit = async (data: any) => {
showEdit.value = true showEdit.value = true
await nextTick() await nextTick()
editRef.value?.open('edit', 'keyword') editRef.value?.open('edit', type)
editRef.value?.getDetail(data) editRef.value?.getDetail(data)
} }
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
await feedback.confirm('确定要删除?') await feedback.confirm('确定要删除?')
await oaReplyDel({ id }) await oaReplyDel({ id, type })
feedback.msgSuccess('删除成功') feedback.msgSuccess('删除成功')
getLists() getLists()
} }
const changeStatus = async (id: number) => { const changeStatus = async (id: number) => {
try { try {
await changeOaReplyStatus({ id }) await changeOaReplyStatus({ id, type })
feedback.msgSuccess('修改成功') feedback.msgSuccess('修改成功')
getLists() getLists()
} catch (error) { } catch (error) {

View File

@ -9,7 +9,7 @@
<el-radio :label="0">关闭</el-radio> <el-radio :label="0">关闭</el-radio>
</el-radio-group> </el-radio-group>
<div class="form-tips">默认开关闭则前端不显示该功能</div> <div class="form-tips">默认开关闭则前端不显示该功能</div>
</div> </div>
</el-form-item> </el-form-item>
</el-form> </el-form>