Commit a364d574 by 芋道源码 Committed by Gitee

!133 版本 1.7.2 发布

Merge pull request !133 from 芋道源码/dev
parents 738d1508 917a2441
{
"name": "yudao-ui-admin-vue3",
"version": "1.7.1-snapshot.1961",
"version": "1.7.2-snapshot",
"description": "基于vue3、vite4、element-plus、typesScript",
"author": "xingyu",
"private": false,
......
......@@ -272,7 +272,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
{
path: '/manager/task-assign-rule',
component: () => import('@/views/bpm/taskAssignRule/index.vue'),
name: 'BpmTaskAssignRule',
name: 'BpmTaskAssignRuleList',
meta: {
noCache: true,
hidden: true,
......
import type { RouteLocationNormalized, Router, RouteRecordNormalized } from 'vue-router'
import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
import type { Router, RouteLocationNormalized, RouteRecordNormalized } from 'vue-router'
import { isUrl } from '@/utils/is'
import { omit, cloneDeep } from 'lodash-es'
import { cloneDeep, omit } from 'lodash-es'
const modules = import.meta.glob('../views/**/*.{vue,tsx}')
/**
* 注册一个异步组件
* @param componentPath 例:/bpm/oa/leave/detail
*/
export const registerComponent = (componentPath: string) => {
for (const item in modules) {
if (item.includes(componentPath)) {
// 使用异步组件的方式来动态加载组件
// @ts-ignore
return defineAsyncComponent(modules[item])
}
}
}
/* Layout */
export const Layout = () => import('@/layout/Layout.vue')
......
......@@ -44,10 +44,13 @@ import { CommonStatusEnum } from '@/utils/constants'
import * as FormApi from '@/api/bpm/form'
import FcDesigner from '@form-create/designer'
import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate'
import { useTagsViewStore } from '@/store/modules/tagsView'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息
const { query } = useRoute() // 路由
const { push, currentRoute } = useRouter() // 路由
const { query } = useRoute() // 路由信息
const { delView } = useTagsViewStore() // 视图操作
const designer = ref() // 表单设计器
const dialogVisible = ref(false) // 弹窗是否展示
......@@ -88,10 +91,16 @@ const submitForm = async () => {
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
close()
} finally {
formLoading.value = false
}
}
/** 关闭按钮 */
const close = () => {
delView(unref(currentRoute))
push('/bpm/manager/form')
}
/** 初始化 **/
onMounted(async () => {
......
......@@ -2,26 +2,33 @@
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="表单名" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入表单名"
class="!w-240px"
clearable
placeholder="请输入表单名"
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" plain @click="openForm" v-hasPermi="['bpm:form:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['bpm:form:create']" plain type="primary" @click="openForm">
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
</el-form-item>
</el-form>
......@@ -30,38 +37,38 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="表单名" align="center" prop="name" />
<el-table-column label="状态" align="center" prop="status">
<el-table-column align="center" label="编号" prop="id" />
<el-table-column align="center" label="表单名" prop="name" />
<el-table-column align="center" label="状态" prop="status">
<template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column align="center" label="备注" prop="remark" />
<el-table-column
label="创建时间"
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
:formatter="dateFormatter"
/>
<el-table-column label="操作" align="center">
<el-table-column align="center" label="操作">
<template #default="scope">
<el-button
v-hasPermi="['bpm:form:update']"
link
type="primary"
@click="openForm(scope.row.id)"
v-hasPermi="['bpm:form:update']"
>
编辑
</el-button>
<el-button link @click="openDetail(scope.row.id)" v-hasPermi="['bpm:form:query']">
<el-button v-hasPermi="['bpm:form:query']" link @click="openDetail(scope.row.id)">
详情
</el-button>
<el-button
v-hasPermi="['bpm:form:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['bpm:form:delete']"
>
删除
</el-button>
......@@ -70,27 +77,28 @@
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单详情的弹窗 -->
<Dialog title="表单详情" v-model="detailVisible" width="800">
<form-create :rule="detailData.rule" :option="detailData.option" />
<Dialog v-model="detailVisible" title="表单详情" width="800">
<form-create :option="detailData.option" :rule="detailData.rule" />
</Dialog>
</template>
<script setup lang="ts" name="BpmForm">
<script lang="ts" name="BpmForm" setup>
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import * as FormApi from '@/api/bpm/form'
import { setConfAndFields2 } from '@/utils/formCreate'
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const { push } = useRouter() // 路由
const { currentRoute, push } = useRouter() // 路由
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
......@@ -128,12 +136,16 @@ const resetQuery = () => {
/** 添加/修改操作 */
const openForm = (id?: number) => {
push({
name: 'BpmFormEditor',
query: {
const toRouter: { name: string; query?: { id: number } } = {
name: 'BpmFormEditor'
}
// 表单新建的时候id传的是event需要排除
if (typeof id === 'number') {
toRouter.query = {
id
}
})
}
push(toRouter)
}
/** 删除按钮操作 */
......@@ -162,7 +174,16 @@ const openDetail = async (rowId: number) => {
// 弹窗打开
detailVisible.value = true
}
/**表单保存返回后重新加载列表 */
watch(
() => currentRoute.value,
() => {
getList()
},
{
immediate: true
}
)
/** 初始化 **/
onMounted(() => {
getList()
......
......@@ -11,7 +11,7 @@
<el-input v-model="formData.name" placeholder="请输入组名" />
</el-form-item>
<el-form-item label="描述">
<el-input v-model="formData.name" placeholder="请输入描述" type="textarea" />
<el-input v-model="formData.description" placeholder="请输入描述" type="textarea" />
</el-form-item>
<el-form-item label="成员" prop="memberUserIds">
<el-select v-model="formData.memberUserIds" multiple placeholder="请选择成员">
......
<template>
<ContentWrap>
<el-descriptions border :column="1">
<el-descriptions :column="1" border>
<el-descriptions-item label="请假类型">
<dict-tag :type="DICT_TYPE.BPM_OA_LEAVE_TYPE" :value="detailData.type" />
</el-descriptions-item>
......@@ -21,6 +21,7 @@ import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import * as LeaveApi from '@/api/bpm/leave'
const { query } = useRoute() // 查询参数
const props = defineProps({
......@@ -34,7 +35,7 @@ const queryId = query.id as unknown as number // 从 URL 传递过来的 id 编
const getInfo = async () => {
detailLoading.value = true
try {
detailData.value = await LeaveApi.getLeave(queryId || props.id)
detailData.value = await LeaveApi.getLeave(props.id || queryId)
} finally {
detailLoading.value = false
}
......
......@@ -2,81 +2,78 @@
<ContentWrap>
<!-- 审批信息 -->
<el-card
class="box-card"
v-loading="processInstanceLoading"
v-for="(item, index) in runningTasks"
:key="index"
v-loading="processInstanceLoading"
class="box-card"
>
<template #header>
<span class="el-icon-picture-outline">审批任务【{{ item.name }}</span>
</template>
<el-col :span="16" :offset="6">
<el-col :offset="6" :span="16">
<el-form
:ref="'form' + index"
:model="auditForms[index]"
:rules="auditRule"
label-width="100px"
>
<el-form-item label="流程名" v-if="processInstance && processInstance.name">
<el-form-item v-if="processInstance && processInstance.name" label="流程名">
{{ processInstance.name }}
</el-form-item>
<el-form-item label="流程发起人" v-if="processInstance && processInstance.startUser">
<el-form-item v-if="processInstance && processInstance.startUser" label="流程发起人">
{{ processInstance.startUser.nickname }}
<el-tag type="info" size="small">{{ processInstance.startUser.deptName }}</el-tag>
<el-tag size="small" type="info">{{ processInstance.startUser.deptName }}</el-tag>
</el-form-item>
<el-form-item label="审批建议" prop="reason">
<el-input
type="textarea"
v-model="auditForms[index].reason"
placeholder="请输入审批建议"
type="textarea"
/>
</el-form-item>
</el-form>
<div style="margin-left: 10%; margin-bottom: 20px; font-size: 14px">
<el-button type="success" @click="handleAudit(item, true)">
<Icon icon="ep:select" /> 通过
<Icon icon="ep:select" />
通过
</el-button>
<el-button type="danger" @click="handleAudit(item, false)">
<Icon icon="ep:close" /> 不通过
<Icon icon="ep:close" />
不通过
</el-button>
<el-button type="primary" @click="openTaskUpdateAssigneeForm(item.id)">
<Icon icon="ep:edit" /> 转办
<Icon icon="ep:edit" />
转办
</el-button>
<el-button type="primary" @click="handleDelegate(item)">
<Icon icon="ep:position" /> 委派
<Icon icon="ep:position" />
委派
</el-button>
<el-button type="warning" @click="handleBack(item)">
<Icon icon="ep:back" /> 回退
<Icon icon="ep:back" />
回退
</el-button>
</div>
</el-col>
</el-card>
<!-- 申请信息 -->
<el-card class="box-card" v-loading="processInstanceLoading">
<el-card v-loading="processInstanceLoading" class="box-card">
<template #header>
<span class="el-icon-document">申请信息【{{ processInstance.name }}</span>
</template>
<!-- 情况一:流程表单 -->
<el-col v-if="processInstance?.processDefinition?.formType === 10" :span="16" :offset="6">
<el-col v-if="processInstance?.processDefinition?.formType === 10" :offset="6" :span="16">
<form-create
ref="fApi"
:rule="detailForm.rule"
:option="detailForm.option"
v-model="detailForm.value"
:option="detailForm.option"
:rule="detailForm.rule"
/>
</el-col>
<!-- 情况二:流程表单 -->
<!-- 情况二:业务表单 -->
<div v-if="processInstance?.processDefinition?.formType === 20">
<router-link
:to="
processInstance.processDefinition.formCustomViewPath +
'?id=' +
processInstance.businessKey
"
>
<el-button type="primary"><Icon icon="ep:view" /> 点击查看</el-button>
</router-link>
<BusinessFormComponent :id="processInstance.businessKey" />
</div>
</el-card>
......@@ -85,18 +82,18 @@
<!-- 高亮流程图 -->
<ProcessInstanceBpmnViewer
:id="id"
:process-instance="processInstance"
:id="`${id}`"
:bpmn-xml="bpmnXML"
:loading="processInstanceLoading"
:process-instance="processInstance"
:tasks="tasks"
:bpmn-xml="bpmnXML"
/>
<!-- 弹窗:转派审批人 -->
<TaskUpdateAssigneeForm ref="taskUpdateAssigneeFormRef" @success="getDetail" />
</ContentWrap>
</template>
<script setup lang="ts" name="BpmProcessInstanceDetail">
<script lang="ts" name="BpmProcessInstanceDetail" setup>
import { useUserStore } from '@/store/modules/user'
import { setConfAndFields2 } from '@/utils/formCreate'
import type { ApiAttrs } from '@form-create/element-ui/types/config'
......@@ -106,6 +103,8 @@ import * as TaskApi from '@/api/bpm/task'
import TaskUpdateAssigneeForm from './TaskUpdateAssigneeForm.vue'
import ProcessInstanceBpmnViewer from './ProcessInstanceBpmnViewer.vue'
import ProcessInstanceTaskList from './ProcessInstanceTaskList.vue'
import { registerComponent } from '@/utils/routerHelper'
const { query } = useRoute() // 查询参数
const message = useMessage() // 消息弹窗
const { proxy } = getCurrentInstance() as any
......@@ -186,6 +185,7 @@ const getDetail = () => {
}
/** 加载流程实例 */
const BusinessFormComponent = ref(null) // 异步组件
const getProcessInstance = async () => {
try {
processInstanceLoading.value = true
......@@ -210,10 +210,12 @@ const getProcessInstance = async () => {
fApi.value?.fapi?.resetBtn.show(false)
fApi.value?.fapi?.disabled(true)
})
} else {
BusinessFormComponent.value = registerComponent(data.processDefinition.formCustomViewPath)
}
// 加载流程图
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(processDefinition.id)
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(processDefinition.id as number)
} finally {
processInstanceLoading.value = false
}
......
......@@ -5,46 +5,53 @@
<!-- 搜索 -->
<ContentWrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="表名称" prop="tableName">
<el-input
v-model="queryParams.tableName"
placeholder="请输入表名称"
class="!w-240px"
clearable
placeholder="请输入表名称"
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="表描述" prop="tableComment">
<el-input
v-model="queryParams.tableComment"
placeholder="请输入表描述"
class="!w-240px"
clearable
placeholder="请输入表描述"
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item label="创建时间" prop="createTime">
<el-date-picker
v-model="queryParams.createTime"
value-format="YYYY-MM-dd HH:mm:ss"
type="daterange"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
class="!w-240px"
end-placeholder="结束日期"
start-placeholder="开始日期"
type="daterange"
value-format="YYYY-MM-dd HH:mm:ss"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" />搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" />重置</el-button>
<el-button type="primary" v-hasPermi="['infra:codegen:create']" @click="openImportTable()">
<Icon icon="ep:zoom-in" class="mr-5px" /> 导入
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['infra:codegen:create']" type="primary" @click="openImportTable()">
<Icon class="mr-5px" icon="ep:zoom-in" />
导入
</el-button>
</el-form-item>
</el-form>
......@@ -53,75 +60,75 @@
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list">
<el-table-column label="数据源" align="center">
<el-table-column align="center" label="数据源">
<template #default="scope">
{{
dataSourceConfigList.find((config) => config.id === scope.row.dataSourceConfigId)?.name
}}
</template>
</el-table-column>
<el-table-column label="表名称" align="center" prop="tableName" width="200" />
<el-table-column align="center" label="表名称" prop="tableName" width="200" />
<el-table-column
label="表描述"
:show-overflow-tooltip="true"
align="center"
label="表描述"
prop="tableComment"
:show-overflow-tooltip="true"
width="200"
/>
<el-table-column label="实体" align="center" prop="className" width="200" />
<el-table-column align="center" label="实体" prop="className" width="200" />
<el-table-column
label="创建时间"
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column
label="更新时间"
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="createTime"
width="180"
:formatter="dateFormatter"
/>
<el-table-column label="操作" align="center" width="300px" fixed="right">
<el-table-column align="center" fixed="right" label="操作" width="300px">
<template #default="scope">
<el-button
v-hasPermi="['infra:codegen:preview']"
link
type="primary"
@click="handlePreview(scope.row)"
v-hasPermi="['infra:codegen:preview']"
>
预览
</el-button>
<el-button
v-hasPermi="['infra:codegen:update']"
link
type="primary"
@click="handleUpdate(scope.row.id)"
v-hasPermi="['infra:codegen:update']"
>
编辑
</el-button>
<el-button
v-hasPermi="['infra:codegen:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
v-hasPermi="['infra:codegen:delete']"
>
删除
</el-button>
<el-button
v-hasPermi="['infra:codegen:update']"
link
type="primary"
@click="handleSyncDB(scope.row)"
v-hasPermi="['infra:codegen:update']"
>
同步
</el-button>
<el-button
v-hasPermi="['infra:codegen:download']"
link
type="primary"
@click="handleGenTable(scope.row)"
v-hasPermi="['infra:codegen:download']"
>
生成代码
</el-button>
......@@ -130,25 +137,26 @@
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 弹窗:导入表 -->
<ImportTable ref="importRef" success="getList" />
<ImportTable ref="importRef" @success="getList" />
<!-- 弹窗:预览代码 -->
<PreviewCode ref="previewRef" />
</template>
<script setup lang="ts" name="InfraCodegen">
<script lang="ts" name="InfraCodegen" setup>
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as CodegenApi from '@/api/infra/codegen'
import * as DataSourceConfigApi from '@/api/infra/dataSourceConfig'
import ImportTable from './ImportTable.vue'
import PreviewCode from './PreviewCode.vue'
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const { push } = useRouter() // 路由跳转
......
......@@ -171,6 +171,7 @@ const loadEchartOptions = (stats) => {
}
onBeforeMount(() => {
// TODO @hiiwbs 微信,优化使用 Echart 组件
readRedisInfo()
})
</script>
<template>
<el-table v-loading="props.loading" :data="props.list">
<el-table-column
label="请求消息类型"
align="center"
prop="requestMessageType"
v-if="msgType === MsgType.Message"
/>
<el-table-column
label="关键词"
align="center"
prop="requestKeyword"
v-if="msgType === MsgType.Keyword"
/>
<el-table-column
label="匹配类型"
align="center"
prop="requestMatch"
v-if="msgType === MsgType.Keyword"
>
<template #default="scope">
<dict-tag :type="DICT_TYPE.MP_AUTO_REPLY_REQUEST_MATCH" :value="scope.row.requestMatch" />
</template>
</el-table-column>
<el-table-column label="回复消息类型" align="center">
<template #default="scope">
<dict-tag :type="DICT_TYPE.MP_MESSAGE_TYPE" :value="scope.row.responseMessageType" />
</template>
</el-table-column>
<el-table-column label="回复内容" align="center">
<template #default="scope">
<div v-if="scope.row.responseMessageType === 'text'">{{ scope.row.responseContent }}</div>
<div v-else-if="scope.row.responseMessageType === 'voice'">
<WxVoicePlayer v-if="scope.row.responseMediaUrl" :url="scope.row.responseMediaUrl" />
</div>
<div v-else-if="scope.row.responseMessageType === 'image'">
<a target="_blank" :href="scope.row.responseMediaUrl">
<img :src="scope.row.responseMediaUrl" style="width: 100px" />
</a>
</div>
<div
v-else-if="
scope.row.responseMessageType === 'video' ||
scope.row.responseMessageType === 'shortvideo'
"
>
<WxVideoPlayer
v-if="scope.row.responseMediaUrl"
:url="scope.row.responseMediaUrl"
style="margin-top: 10px"
/>
</div>
<div v-else-if="scope.row.responseMessageType === 'news'">
<WxNews :articles="scope.row.responseArticles" />
</div>
<div v-else-if="scope.row.responseMessageType === 'music'">
<WxMusic
:title="scope.row.responseTitle"
:description="scope.row.responseDescription"
:thumb-media-url="scope.row.responseThumbMediaUrl"
:music-url="scope.row.responseMusicUrl"
:hq-music-url="scope.row.responseHqMusicUrl"
/>
</div>
</template>
</el-table-column>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180"
/>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button
type="primary"
link
@click="emit('on-update', scope.row.id)"
v-hasPermi="['mp:auto-reply:update']"
>
修改
</el-button>
<el-button
type="danger"
link
@click="emit('on-delete', scope.row.id)"
v-hasPermi="['mp:auto-reply:delete']"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</template>
<script setup lang="ts">
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
import WxMusic from '@/views/mp/components/wx-music/main.vue'
import WxNews from '@/views/mp/components/wx-news/main.vue'
import { dateFormatter } from '@/utils/formatTime'
import { DICT_TYPE } from '@/utils/dict'
import { MsgType } from './types'
const props = defineProps<{
loading: boolean
list: any[]
msgType: MsgType
}>()
const emit = defineEmits<{
(e: 'on-update', v: number)
(e: 'on-delete', v: number)
}>()
</script>
// 消息类型(Follow: 关注时回复;Message: 消息回复;Keyword: 关键词回复)
// 作为 tab.name,enum 的数字不能随意修改,与 api 参数相关
export enum MsgType {
Follow = 1,
Message = 2,
Keyword = 3
}
type ReplyType = 'text' | 'image' | 'voice' | 'video' | 'shortvideo' | 'location' | 'link'
export interface ReplyForm {
// relation:
id?: number
accountId?: number
type?: MsgType
// request:
requestMessageType?: ReplyType
requestMatch?: number
requestKeyword?: string
// response:
responseMessageType?: ReplyType
responseContent?: string
responseMediaId?: number
responseMediaUrl?: string
responseTitle?: string
responseDescription?: number
responseThumbMediaId?: string
responseThumbMediaUrl?: string
responseArticles?: any[]
responseMusicUrl?: string
responseHqMusicUrl?: string
}
// TODO @Dhb52:ObjData 这个类名可以在看看,ObjData 有点通用
export interface ObjData {
type: ReplyType
accountId?: number
content?: string
mediaId?: number
url?: string
title?: string
description?: string
thumbMediaId?: number
thumbMediaUrl?: string
articles?: any[]
musicUrl?: string
hqMusicUrl?: string
}
......@@ -22,11 +22,14 @@ const handleQuery = async () => {
// 默认选中第一个
if (accountList.value.length > 0) {
account.id = accountList.value[0].id
account.name = accountList.value[0].name
emit('change', account.id, account.name)
}
}
const onChanged = () => {
const onChanged = (id?: number) => {
const found = accountList.value.find((v) => v.id === id)
account.name = found ? found.name : ''
emit('change', account.id, account.name)
}
......
<!--
【微信消息 - 定位】
【微信消息 - 定位】TODO @Dhb52 目前未启用
-->
<template>
<div>
......
......@@ -126,7 +126,7 @@
</div>
<div class="msg-send" v-loading="sendLoading">
<WxReplySelect ref="replySelectRef" :objData="objData" />
<el-button type="success" size="small" class="send-but" @click="sendMsg">发送(S)</el-button>
<el-button type="success" class="send-but" @click="sendMsg">发送(S)</el-button>
</div>
</ContentWrap>
</template>
......@@ -231,12 +231,8 @@ const sendMsg = async () => {
list.value = [...list.value, ...[data]]
scrollToBottom()
//ts检查的時候会判断这个组件可能是空的,所以需要进行断言。
//避免 tab 的数据未清理
const deleteObj = replySelectRef.value?.deleteObj
if (deleteObj) {
deleteObj()
}
// 发送后清空数据
replySelectRef.value?.clear()
}
const loadingMore = () => {
......@@ -333,6 +329,7 @@ const scrollToBottom = () => {
.send-but {
float: right;
margin-top: 8px !important;
margin-top: 8px;
margin-bottom: 8px;
}
</style>
<template>
<el-tab-pane name="image">
<template #label>
<el-row align="middle"><Icon icon="ep:picture" class="mr-5px" /> 图片</el-row>
</template>
<!-- 情况一:已经选择好素材、或者上传好图片 -->
<div class="select-item" v-if="objData.url">
<img class="material-img" :src="objData.url" />
<p class="item-name" v-if="objData.name">{{ objData.name }}</p>
<el-row class="ope-row" justify="center">
<el-button type="danger" circle @click="onDelete">
<Icon icon="ep:delete" />
</el-button>
</el-row>
</div>
<!-- 情况二:未做完上述操作 -->
<el-row v-else style="text-align: center" align="middle">
<!-- 选择素材 -->
<el-col :span="12" class="col-select">
<el-button type="success" @click="showDialog = true">
素材库选择 <Icon icon="ep:circle-check" />
</el-button>
<el-dialog
title="选择图片"
v-model="showDialog"
width="90%"
append-to-body
destroy-on-close
>
<WxMaterialSelect :objData="objData" @select-material="selectMaterial" />
</el-dialog>
</el-col>
<!-- 文件上传 -->
<el-col :span="12" class="col-add">
<el-upload
:action="UPLOAD_URL"
:headers="HEADERS"
multiple
:limit="1"
:file-list="fileList"
:data="uploadData"
:before-upload="beforeImageUpload"
:on-success="onUploadSuccess"
>
<el-button type="primary">上传图片</el-button>
<template #tip>
<span>
<div class="el-upload__tip">支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M</div>
</span>
</template>
</el-upload>
</el-col>
</el-row>
</el-tab-pane>
</template>
<script setup lang="ts">
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
import type { UploadRawFile } from 'element-plus'
import { getAccessToken } from '@/utils/auth'
import { ObjData } from './types'
const message = useMessage()
const UPLOAD_URL = import.meta.env.VITE_API_BASEPATH + '/admin-api/mp/material/upload-temporary'
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 设置上传的请求头部
const props = defineProps<{
modelValue: ObjData
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: ObjData)
}>()
const objData = computed<ObjData>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
const showDialog = ref(false)
const fileList = ref([])
const uploadData = reactive({
accountId: objData.value.accountId,
type: 'image',
title: '',
introduction: ''
})
const beforeImageUpload = (rawFile: UploadRawFile) =>
useBeforeUpload(MaterialType.Image, 2)(rawFile)
const onUploadSuccess = (res: any) => {
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
}
// 清空上传时的各种数据
fileList.value = []
uploadData.title = ''
uploadData.introduction = ''
// 上传好的文件,本质是个素材,所以可以进行选中
selectMaterial(res.data)
}
const onDelete = () => {
objData.value.mediaId = null
objData.value.url = null
objData.value.name = null
}
const selectMaterial = (item) => {
showDialog.value = false
objData.value.type = 'image'
objData.value.mediaId = item.mediaId
objData.value.url = item.url
objData.value.name = item.name
}
</script>
<style lang="scss" scoped>
.select-item {
width: 280px;
padding: 10px;
margin: 0 auto 10px auto;
border: 1px solid #eaeaea;
.material-img {
width: 100%;
}
.item-name {
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
.item-infos {
width: 30%;
margin: auto;
}
.ope-row {
padding-top: 10px;
text-align: center;
}
}
.col-select {
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
}
.col-add {
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
float: right;
.el-upload__tip {
line-height: 18px;
text-align: center;
}
}
}
</style>
<template>
<el-tab-pane name="music">
<template #label>
<el-row align="middle"><Icon icon="ep:service" />音乐</el-row>
</template>
<el-row align="middle" justify="center">
<el-col :span="6">
<el-row align="middle" justify="center" class="thumb-div">
<el-col :span="24">
<el-row align="middle" justify="center">
<img style="width: 100px" v-if="objData.thumbMediaUrl" :src="objData.thumbMediaUrl" />
<icon v-else icon="ep:plus" />
</el-row>
<el-row align="middle" justify="center" style="margin-top: 2%">
<div class="thumb-but">
<el-upload
:action="UPLOAD_URL"
:headers="HEADERS"
multiple
:limit="1"
:file-list="fileList"
:data="uploadData"
:before-upload="beforeImageUpload"
:on-success="onUploadSuccess"
>
<template #trigger>
<el-button type="primary" link>本地上传</el-button>
</template>
<el-button type="primary" link @click="showDialog = true" style="margin-left: 5px"
>素材库选择
</el-button>
</el-upload>
</div>
</el-row>
</el-col>
</el-row>
<el-dialog
title="选择图片"
v-model="showDialog"
width="80%"
append-to-body
destroy-on-close
>
<WxMaterialSelect
:objData="{ type: 'image', accountId: objData.accountId }"
@select-material="selectMaterial"
/>
</el-dialog>
</el-col>
<el-col :span="18">
<el-input v-model="objData.title" placeholder="请输入标题" />
<div style="margin: 20px 0"></div>
<el-input v-model="objData.description" placeholder="请输入描述" />
</el-col>
</el-row>
<div style="margin: 20px 0"></div>
<el-input v-model="objData.musicUrl" placeholder="请输入音乐链接" />
<div style="margin: 20px 0"></div>
<el-input v-model="objData.hqMusicUrl" placeholder="请输入高质量音乐链接" />
</el-tab-pane>
</template>
<script setup lang="ts">
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import type { UploadRawFile } from 'element-plus'
import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
import { getAccessToken } from '@/utils/auth'
import { ObjData } from './types'
const message = useMessage()
const UPLOAD_URL = import.meta.env.VITE_API_BASEPATH + '/admin-api/mp/material/upload-temporary'
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 设置上传的请求头部
const props = defineProps<{
modelValue: ObjData
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: ObjData)
}>()
const objData = computed<ObjData>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
const showDialog = ref(false)
const fileList = ref([])
const uploadData = reactive({
accountId: objData.value.accountId,
type: 'thumb', // 音乐类型为thumb
title: '',
introduction: ''
})
const beforeImageUpload = (rawFile: UploadRawFile) =>
useBeforeUpload(MaterialType.Image, 2)(rawFile)
const onUploadSuccess = (res: any) => {
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
}
// 清空上传时的各种数据
fileList.value = []
uploadData.title = ''
uploadData.introduction = ''
// 上传好的文件,本质是个素材,所以可以进行选中
selectMaterial(res.data)
}
const selectMaterial = (item: any) => {
showDialog.value = false
objData.value.thumbMediaId = item.mediaId
objData.value.thumbMediaUrl = item.url
}
</script>
<template>
<el-tab-pane name="news">
<template #label>
<el-row align="middle"><Icon icon="ep:reading" /> 图文</el-row>
</template>
<el-row>
<div class="select-item" v-if="objData.articles?.length > 0">
<WxNews :articles="objData.articles" />
<el-col class="ope-row">
<el-button type="danger" circle @click="onDelete">
<Icon icon="ep:delete" />
</el-button>
</el-col>
</div>
<!-- 选择素材 -->
<el-col :span="24" v-if="!objData.content">
<el-row style="text-align: center" align="middle">
<el-col :span="24">
<el-button type="success" @click="showDialog = true">
{{ newsType === NewsType.Published ? '选择已发布图文' : '选择草稿箱图文' }}
<Icon icon="ep:circle-check" />
</el-button>
</el-col>
</el-row>
</el-col>
<el-dialog title="选择图文" v-model="showDialog" width="90%" append-to-body destroy-on-close>
<WxMaterialSelect
:objData="objData"
@select-material="selectMaterial"
:newsType="newsType"
/>
</el-dialog>
</el-row>
</el-tab-pane>
</template>
<script setup lang="ts">
import WxNews from '@/views/mp/components/wx-news/main.vue'
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import { ObjData, NewsType } from './types'
const props = defineProps<{
modelValue: ObjData
newsType: NewsType
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: ObjData)
}>()
const objData = computed<ObjData>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
const showDialog = ref(false)
const selectMaterial = (item: any) => {
showDialog.value = false
objData.value.articles = item.content.newsItem
}
const onDelete = () => {
objData.value.articles = []
}
</script>
<style lang="scss" scoped>
.select-item {
width: 280px;
padding: 10px;
margin: 0 auto 10px auto;
border: 1px solid #eaeaea;
.ope-row {
padding-top: 10px;
text-align: center;
}
}
</style>
<template>
<el-tab-pane name="text">
<template #label>
<el-row align="middle"><Icon icon="ep:document" /> 文本</el-row>
</template>
<el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="content" />
</el-tab-pane>
</template>
<script setup lang="ts">
const props = defineProps<{
modelValue: string | null
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: string | null)
(e: 'input', v: string | null)
}>()
const content = computed<string | null>({
get: () => props.modelValue,
set: (val: string | null) => {
emit('update:modelValue', val)
emit('input', val)
}
})
</script>
<template>
<el-tab-pane name="video">
<template #label>
<el-row align="middle"><Icon icon="ep:share" /> 视频</el-row>
</template>
<el-row>
<el-input v-model="objData.title" class="input-margin-bottom" placeholder="请输入标题" />
<el-input
class="input-margin-bottom"
v-model="objData.description"
placeholder="请输入描述"
/>
<el-row class="ope-row" justify="center">
<WxVideoPlayer v-if="objData.url" :url="objData.url" />
</el-row>
<el-col>
<el-row style="text-align: center" align="middle">
<!-- 选择素材 -->
<el-col :span="12">
<el-button type="success" @click="showDialog = true">
素材库选择 <Icon icon="ep:circle-check" />
</el-button>
<el-dialog
title="选择视频"
v-model="showDialog"
width="90%"
append-to-body
destroy-on-close
>
<WxMaterialSelect :objData="objData" @select-material="selectMaterial" />
</el-dialog>
</el-col>
<!-- 文件上传 -->
<el-col :span="12">
<el-upload
:action="UPLOAD_URL"
:headers="HEADERS"
multiple
:limit="1"
:file-list="fileList"
:data="uploadData"
:before-upload="beforeVideoUpload"
:on-success="onUploadSuccess"
>
<el-button type="primary">新建视频 <Icon icon="ep:upload" /></el-button>
</el-upload>
</el-col>
</el-row>
</el-col>
</el-row>
</el-tab-pane>
</template>
<script setup lang="ts">
import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue'
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import type { UploadRawFile } from 'element-plus'
import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
import { getAccessToken } from '@/utils/auth'
import { ObjData } from './types'
const message = useMessage()
const UPLOAD_URL = import.meta.env.VITE_API_BASEPATH + '/admin-api/mp/material/upload-temporary'
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() }
const props = defineProps<{
modelValue: ObjData
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: ObjData)
}>()
const objData = computed<ObjData>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
const showDialog = ref(false)
const fileList = ref([])
const uploadData = reactive({
accountId: objData.value.accountId,
type: 'video',
title: '',
introduction: ''
})
const beforeVideoUpload = (rawFile: UploadRawFile) =>
useBeforeUpload(MaterialType.Video, 10)(rawFile)
const onUploadSuccess = (res: any) => {
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
}
// 清空上传时的各种数据
fileList.value = []
uploadData.title = ''
uploadData.introduction = ''
selectMaterial(res.data)
}
/** 选择素材后设置 */
const selectMaterial = (item: any) => {
showDialog.value = false
objData.value.mediaId = item.mediaId
objData.value.url = item.url
objData.value.name = item.name
// title、introduction:从 item 到 tempObjItem,因为素材里有 title、introduction
if (item.title) {
objData.value.title = item.title || ''
}
if (item.introduction) {
objData.value.description = item.introduction || ''
}
}
</script>
<style lang="scss" scoped>
.input-margin-bottom {
margin-bottom: 2%;
}
.ope-row {
width: 100%;
padding-top: 10px;
text-align: center;
}
</style>
<template>
<el-tab-pane name="voice">
<template #label>
<el-row align="middle"><Icon icon="ep:phone" /> 语音</el-row>
</template>
<div class="select-item2" v-if="objData.url">
<p class="item-name">{{ objData.name }}</p>
<el-row class="ope-row" justify="center">
<WxVoicePlayer :url="objData.url" />
</el-row>
<el-row class="ope-row" justify="center">
<el-button type="danger" circle @click="onDelete"><Icon icon="ep:delete" /></el-button>
</el-row>
</div>
<el-row v-else style="text-align: center">
<!-- 选择素材 -->
<el-col :span="12" class="col-select">
<el-button type="success" @click="showDialog = true">
素材库选择<Icon icon="ep:circle-check" />
</el-button>
<el-dialog
title="选择语音"
v-model="showDialog"
width="90%"
append-to-body
destroy-on-close
>
<WxMaterialSelect :objData="objData" @select-material="selectMaterial" />
</el-dialog>
</el-col>
<!-- 文件上传 -->
<el-col :span="12" class="col-add">
<el-upload
:action="UPLOAD_URL"
:headers="HEADERS"
multiple
:limit="1"
:file-list="fileList"
:data="uploadData"
:before-upload="beforeVoiceUpload"
:on-success="onUploadSuccess"
>
<el-button type="primary">点击上传</el-button>
<template #tip>
<div class="el-upload__tip">
格式支持 mp3/wma/wav/amr,文件大小不超过 2M,播放长度不超过 60s
</div>
</template>
</el-upload>
</el-col>
</el-row>
</el-tab-pane>
</template>
<script setup lang="ts">
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue'
import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
import type { UploadRawFile } from 'element-plus'
import { getAccessToken } from '@/utils/auth'
import { ObjData } from './types'
const message = useMessage()
const UPLOAD_URL = import.meta.env.VITE_API_BASEPATH + '/admin-api/mp/material/upload-temporary'
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 设置上传的请求头部
const props = defineProps<{
modelValue: ObjData
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: ObjData)
}>()
const objData = computed<ObjData>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
const showDialog = ref(false)
const fileList = ref([])
const uploadData = reactive({
accountId: objData.value.accountId,
type: 'voice',
title: '',
introduction: ''
})
const beforeVoiceUpload = (rawFile: UploadRawFile) =>
useBeforeUpload(MaterialType.Voice, 10)(rawFile)
const onUploadSuccess = (res: any) => {
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
}
// 清空上传时的各种数据
fileList.value = []
uploadData.title = ''
uploadData.introduction = ''
// 上传好的文件,本质是个素材,所以可以进行选中
selectMaterial(res.data)
}
const onDelete = () => {
objData.value.mediaId = null
objData.value.url = null
objData.value.name = null
}
const selectMaterial = (item: ObjData) => {
showDialog.value = false
objData.value.type = 'voice'
objData.value.mediaId = item.mediaId
objData.value.url = item.url
objData.value.name = item.name
}
</script>
<style lang="scss" scoped>
.select-item2 {
padding: 10px;
margin: 0 auto 10px auto;
border: 1px solid #eaeaea;
.item-name {
font-size: 12px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
.ope-row {
width: 100%;
padding-top: 10px;
text-align: center;
}
}
.col-select {
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
}
.col-add {
border: 1px solid rgb(234, 234, 234);
padding: 50px 0px;
height: 160px;
width: 49.5%;
float: right;
.el-upload__tip {
line-height: 18px;
text-align: center;
}
}
}
</style>
type ReplyType = '' | 'news' | 'image' | 'voice' | 'video' | 'music' | 'text'
interface ObjData {
accountId: number
type: ReplyType
name: string | null
content: string | null
mediaId: string | null
url: string | null
title: string | null
description: string | null
thumbMediaId: string | null
thumbMediaUrl: string | null
musicUrl: string | null
hqMusicUrl: string | null
introduction: string | null
articles: any[]
}
enum NewsType {
Published = '1',
Draft = '2'
}
export { ObjData, NewsType }
......@@ -14,26 +14,24 @@
<div @click="playVideo()">
<!-- 提示 -->
<div>
<Icon icon="ep:video-play" class="mr-5px" />
<p>点击播放视频</p>
<Icon icon="ep:video-play" :size="32" class="mr-5px" />
<p class="text-sm">点击播放视频</p>
</div>
<!-- 弹窗播放 -->
<el-dialog v-model="dialogVideo" title="视频播放" width="40%" append-to-body>
<template #footer>
<video-player
v-if="dialogVideo"
class="video-player vjs-big-play-centered"
:src="url"
poster=""
crossorigin="anonymous"
playsinline
controls
:volume="0.6"
:height="320"
:playback-rates="[0.7, 1.0, 1.5, 2.0]"
/>
</template>
<el-dialog v-model="dialogVideo" title="视频播放" append-to-body>
<video-player
v-if="dialogVideo"
class="video-player vjs-big-play-centered"
:src="props.url"
poster=""
crossorigin="anonymous"
playsinline
controls
:volume="0.6"
:width="800"
:playback-rates="[0.7, 1.0, 1.5, 2.0]"
/>
<!-- 事件,暫時沒用
@mounted="handleMounted"-->
<!-- @ready="handleEvent($event)"-->
......@@ -50,36 +48,24 @@
</div>
</template>
<script lang="ts" name="WxVideoPlayer">
//升级videojs6.0版本,重寫6.0版本
<script setup lang="ts" name="WxVideoPlayer">
import 'video.js/dist/video-js.css'
import { defineComponent } from 'vue'
import { VideoPlayer } from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
export default defineComponent({
components: {
VideoPlayer
},
props: {
url: {
// 视频地址,例如说:https://vjs.zencdn.net/v/oceans.mp4
type: String,
required: true
}
},
setup() {
// const videoPlayerRef = ref(null)
const dialogVideo = ref(false)
const handleEvent = (log) => {
console.log('Basic player event', log)
}
const playVideo = () => {
dialogVideo.value = true
}
return { handleEvent, playVideo, dialogVideo }
const props = defineProps({
url: {
type: String,
required: true
}
})
const dialogVideo = ref(false)
// const handleEvent = (log) => {
// console.log('Basic player event', log)
// }
const playVideo = () => {
dialogVideo.value = true
}
</script>
......@@ -12,8 +12,8 @@
<template>
<div class="wx-voice-div" @click="playVoice">
<el-icon>
<Icon v-if="playing !== true" icon="ep:video-play" />
<Icon v-else icon="ep:video-pause" />
<Icon v-if="playing !== true" icon="ep:video-play" :size="32" />
<Icon v-else icon="ep:video-pause" :size="32" />
<span class="amr-duration" v-if="duration">{{ duration }}</span>
</el-icon>
<div v-if="content">
......@@ -25,7 +25,6 @@
<script setup lang="ts" name="WxVoicePlayer">
// 因为微信语音是 amr 格式,所以需要用到 amr 解码器:https://www.npmjs.com/package/benz-amr-recorder
import BenzAMRRecorder from 'benz-amr-recorder'
const props = defineProps({
......@@ -90,6 +89,12 @@ const amrStop = () => {
padding: 5px;
background-color: #eaeaea;
border-radius: 10px;
width: 40px;
height: 40px;
display: flex;
justify-content: center;
align-items: center;
}
.amr-duration {
font-size: 11px;
......
<template>
<div>
<p>封面:</p>
<div class="thumb-div">
<el-image
v-if="newsItem.thumbUrl"
style="width: 300px; max-height: 300px"
:src="newsItem.thumbUrl"
fit="contain"
/>
<Icon
v-else
icon="ep:plus"
class="avatar-uploader-icon"
:class="isFirst ? 'avatar' : 'avatar1'"
/>
<div class="thumb-but">
<el-upload
:action="UPLOAD_URL"
:headers="HEADERS"
multiple
:limit="1"
:file-list="fileList"
:data="uploadData"
:before-upload="onBeforeUpload"
:on-error="onUploadError"
:on-success="onUploadSuccess"
>
<template #trigger>
<el-button size="small" type="primary" :loading="isUploading" disabled="isUploading">
{{ isUploading ? '正在上传' : '本地上传' }}
</el-button>
</template>
<el-button
size="small"
type="primary"
@click="showImageDialog = true"
style="margin-left: 5px"
>
素材库选择
</el-button>
<template #tip>
<div class="el-upload__tip">支持 bmp/png/jpeg/jpg/gif 格式,大小不超过 2M</div>
</template>
</el-upload>
</div>
<el-dialog
title="选择图片"
v-model="showImageDialog"
width="80%"
append-to-body
destroy-on-close
>
<WxMaterialSelect
:objData="{ type: 'image', accountId: accountId }"
@select-material="onMaterialSelected"
/>
</el-dialog>
</div>
</div>
</template>
<script setup lang="ts">
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import { getAccessToken } from '@/utils/auth'
import type { UploadFiles, UploadProps, UploadRawFile } from 'element-plus'
import { NewsItem } from './types'
const message = useMessage()
// const UPLOAD_URL = 'http://localhost:8000/upload/' // 上传永久素材的地址
const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent' // 上传永久素材的地址
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 设置上传的请求头部
const props = defineProps<{
modelValue: NewsItem
isFirst: boolean
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: NewsItem)
}>()
const newsItem = computed<NewsItem>({
get() {
return props.modelValue
},
set(val) {
emit('update:modelValue', val)
}
})
const accountId = inject<number>('accountId')
const showImageDialog = ref(false)
const fileList = ref<UploadFiles>([])
interface UploadData {
type: 'image' | 'video' | 'audio'
accountId?: number
}
const uploadData: UploadData = reactive({
type: 'image',
accountId: accountId
})
const isUploading = ref(false)
/** 素材选择完成事件*/
const onMaterialSelected = (item: any) => {
showImageDialog.value = false
newsItem.value.thumbMediaId = item.mediaId
newsItem.value.thumbUrl = item.url
}
const onBeforeUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) => {
const isType = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/jpg'].includes(
rawFile.type
)
if (!isType) {
message.error('上传图片格式不对!')
return false
}
if (rawFile.size / 1024 / 1024 > 2) {
message.error('上传图片大小不能超过 2M!')
return false
}
// 校验通过
return true
}
const onUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
}
// 重置上传文件的表单
fileList.value = []
// 设置草稿的封面字段
newsItem.value.thumbMediaId = res.data.mediaId
newsItem.value.thumbUrl = res.data.url
}
const onUploadError = (err: Error) => {
message.error('上传失败: ' + err.message)
}
</script>
<style lang="scss" scoped>
.el-upload__tip {
margin-left: 5px;
}
.thumb-div {
display: inline-block;
width: 100%;
text-align: center;
.avatar-uploader-icon {
width: 120px;
height: 120px;
font-size: 28px;
line-height: 120px;
color: #8c939d;
text-align: center;
border: 1px solid #d9d9d9;
}
.avatar {
width: 230px;
height: 120px;
}
.avatar1 {
width: 120px;
height: 120px;
}
.thumb-but {
margin: 5px;
}
}
</style>
<template>
<div class="waterfall" v-loading="props.loading">
<template v-for="item in props.list" :key="item.articleId">
<div class="waterfall-item" v-if="item.content && item.content.newsItem">
<WxNews :articles="item.content.newsItem" />
<!-- 操作按钮 -->
<el-row>
<el-button
type="success"
circle
@click="emit('publish', item)"
v-hasPermi="['mp:free-publish:submit']"
>
<Icon icon="fa:upload" />
</el-button>
<el-button
type="primary"
circle
@click="emit('update', item)"
v-hasPermi="['mp:draft:update']"
>
<Icon icon="ep:edit" />
</el-button>
<el-button
type="danger"
circle
@click="emit('delete', item)"
v-hasPermi="['mp:draft:delete']"
>
<Icon icon="ep:delete" />
</el-button>
</el-row>
</div>
</template>
</div>
</template>
<script setup lang="ts">
import WxNews from '@/views/mp/components/wx-news/main.vue'
import { Article } from './types'
const props = defineProps<{
list: Article[]
loading: boolean
}>()
const emit = defineEmits<{
(e: 'publish', v: Article)
(e: 'update', v: Article)
(e: 'delete', v: Article)
}>()
</script>
<style lang="scss" scoped>
.waterfall {
width: 100%;
column-gap: 10px;
column-count: 5;
margin: 0 auto;
.waterfall-item {
padding: 10px;
margin-bottom: 10px;
break-inside: avoid;
border: 1px solid #eaeaea;
}
}
@media (min-width: 992px) and (max-width: 1300px) {
.waterfall {
column-count: 3;
}
}
@media (min-width: 768px) and (max-width: 991px) {
.waterfall {
column-count: 2;
}
}
@media (max-width: 767px) {
.waterfall {
column-count: 1;
}
}
</style>
<template>
<el-container>
<el-aside width="40%">
<div class="select-item">
<div v-for="(news, index) in newsList" :key="index">
<div
class="news-main father"
v-if="index === 0"
:class="{ activeAddNews: activeNewsIndex === index }"
@click="activeNewsIndex = index"
>
<div class="news-content">
<img class="material-img" :src="news.thumbUrl" />
<div class="news-content-title">{{ news.title }}</div>
</div>
<div class="child" v-if="newsList.length > 1">
<el-button type="info" circle size="small" @click="() => moveDownNews(index)">
<Icon icon="ep:arrow-down-bold" />
</el-button>
<el-button
v-if="isCreating"
type="danger"
circle
size="small"
@click="() => removeNews(index)"
>
<Icon icon="ep:delete" />
</el-button>
</div>
</div>
<div
class="news-main-item father"
v-if="index > 0"
:class="{ activeAddNews: activeNewsIndex === index }"
@click="activeNewsIndex = index"
>
<div class="news-content-item">
<div class="news-content-item-title">{{ news.title }}</div>
<div class="news-content-item-img">
<img class="material-img" :src="news.thumbUrl" width="100%" />
</div>
</div>
<div class="child">
<el-button
v-if="newsList.length > index + 1"
circle
type="info"
size="small"
@click="() => moveDownNews(index)"
>
<Icon icon="ep:arrow-down-bold" />
</el-button>
<el-button
v-if="index > 0"
type="info"
circle
size="small"
@click="() => moveUpNews(index)"
>
<Icon icon="ep:arrow-up-bold" />
</el-button>
<el-button
v-if="isCreating"
type="danger"
size="small"
circle
@click="() => removeNews(index)"
>
<Icon icon="ep:delete" />
</el-button>
</div>
</div>
</div>
<el-row justify="center" class="ope-row">
<el-button
type="primary"
circle
@click="plusNews"
v-if="newsList.length < 8 && isCreating"
>
<Icon icon="ep:plus" />
</el-button>
</el-row>
</div>
</el-aside>
<el-main>
<div v-if="newsList.length > 0">
<!-- 标题、作者、原文地址 -->
<el-row :gutter="20">
<el-input v-model="activeNewsItem.title" placeholder="请输入标题(必填)" />
<el-input
v-model="activeNewsItem.author"
placeholder="请输入作者"
style="margin-top: 5px"
/>
<el-input
v-model="activeNewsItem.contentSourceUrl"
placeholder="请输入原文地址"
style="margin-top: 5px"
/>
</el-row>
<!-- 封面和摘要 -->
<el-row :gutter="20">
<el-col :span="12">
<CoverSelect v-model="activeNewsItem" :is-first="activeNewsIndex === 0" />
</el-col>
<el-col :span="12">
<p>摘要:</p>
<el-input
:rows="8"
type="textarea"
v-model="activeNewsItem.digest"
placeholder="请输入摘要"
class="digest"
maxlength="120"
/>
</el-col>
</el-row>
<!--富文本编辑器组件-->
<el-row>
<Editor v-model="activeNewsItem.content" :editor-config="editorConfig" />
</el-row>
</div>
</el-main>
</el-container>
</template>
<script setup lang="ts">
import { Editor } from '@/components/Editor'
import { createEditorConfig } from '../editor-config'
import CoverSelect from './CoverSelect.vue'
import { type NewsItem, createEmptyNewsItem } from './types'
const message = useMessage()
const props = defineProps<{
isCreating: boolean
modelValue: NewsItem[] | null
}>()
const accountId = inject<number>('accountId')
// ========== 文件上传 ==========
const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent' // 上传永久素材的地址
const editorConfig = createEditorConfig(UPLOAD_URL, accountId)
// v-model=newsList
const emit = defineEmits<{
(e: 'update:modelValue', v: NewsItem[])
}>()
const newsList = computed<NewsItem[]>({
get() {
return props.modelValue === null ? [createEmptyNewsItem()] : props.modelValue
},
set(val) {
emit('update:modelValue', val)
}
})
const activeNewsIndex = ref(0)
const activeNewsItem = computed<NewsItem>(() => newsList.value[activeNewsIndex.value])
// 将图文向下移动
const moveDownNews = (index: number) => {
const temp = newsList.value[index]
newsList.value[index] = newsList.value[index + 1]
newsList.value[index + 1] = temp
activeNewsIndex.value = index + 1
}
// 将图文向上移动
const moveUpNews = (index: number) => {
const temp = newsList.value[index]
newsList.value[index] = newsList.value[index - 1]
newsList.value[index - 1] = temp
activeNewsIndex.value = index - 1
}
// 删除指定 index 的图文
const removeNews = async (index: number) => {
try {
await message.confirm('确定删除该图文吗?')
newsList.value.splice(index, 1)
if (activeNewsIndex.value === index) {
activeNewsIndex.value = 0
}
} catch {}
}
// 添加一个图文
const plusNews = () => {
newsList.value.push(createEmptyNewsItem())
activeNewsIndex.value = newsList.value.length - 1
}
</script>
<style lang="scss" scoped>
.ope-row {
padding-top: 5px;
margin-top: 5px;
text-align: center;
border-top: 1px solid #eaeaea;
}
.el-row {
margin-bottom: 20px;
}
.el-row:last-child {
margin-bottom: 0;
}
.digest {
display: inline-block;
width: 100%;
vertical-align: top;
}
/* 新增图文 */
.news-main {
width: 100%;
height: 120px;
margin: auto;
background-color: #fff;
}
.news-content {
position: relative;
width: 100%;
height: 120px;
background-color: #acadae;
}
.news-content-title {
position: absolute;
bottom: 0;
left: 0;
display: inline-block;
width: 98%;
height: 25px;
padding: 1%;
overflow: hidden;
font-size: 15px;
color: #fff;
text-overflow: ellipsis;
white-space: nowrap;
background-color: black;
opacity: 0.65;
}
.news-main-item {
width: 100%;
padding: 5px 0;
margin: auto;
background-color: #fff;
border-top: 1px solid #eaeaea;
}
.news-content-item {
position: relative;
margin-left: -3px;
}
.news-content-item-title {
display: inline-block;
width: 70%;
font-size: 12px;
}
.news-content-item-img {
display: inline-block;
width: 25%;
background-color: #acadae;
}
.select-item {
width: 60%;
padding: 10px;
margin: 0 auto 10px;
border: 1px solid #eaeaea;
.activeAddNews {
border: 5px solid #2bb673;
}
}
.father .child {
position: relative;
bottom: 25px;
display: none;
text-align: center;
}
.father:hover .child {
display: block;
}
.material-img {
width: 100%;
height: 100%;
}
</style>
import type { Article, NewsItem, NewsItemList } from './types'
import { createEmptyNewsItem } from './types'
import DraftTable from './DraftTable.vue'
import NewsForm from './NewsForm.vue'
export { DraftTable, NewsForm, createEmptyNewsItem }
export type { Article, NewsItem, NewsItemList }
interface NewsItem {
title: string
thumbMediaId: string
author: string
digest: string
showCoverPic: string
content: string
contentSourceUrl: string
needOpenComment: string
onlyFansCanComment: string
thumbUrl: string
}
interface NewsItemList {
newsItem: NewsItem[]
}
interface Article {
mediaId: string
content: NewsItemList
updateTime: number
}
const createEmptyNewsItem = (): NewsItem => {
return {
title: '',
thumbMediaId: '',
author: '',
digest: '',
showCoverPic: '',
content: '',
contentSourceUrl: '',
needOpenComment: '',
onlyFansCanComment: '',
thumbUrl: ''
}
}
export type { Article, NewsItem, NewsItemList }
export { createEmptyNewsItem }
import type { UploadRawFile } from 'element-plus'
const message = useMessage() // 消息
enum MaterialType {
Image = 'image',
Voice = 'voice',
Video = 'video'
}
const useBeforeUpload = (type: MaterialType, maxSizeMB: number) => {
const fn = (rawFile: UploadRawFile): boolean => {
let allowTypes: string[] = []
let name = ''
switch (type) {
case MaterialType.Image:
allowTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/jpg']
maxSizeMB = 2
name = '图片'
break
case MaterialType.Voice:
allowTypes = ['audio/mp3', 'audio/mpeg', 'audio/wma', 'audio/wav', 'audio/amr']
maxSizeMB = 2
name = '语音'
break
case MaterialType.Video:
allowTypes = ['video/mp4']
maxSizeMB = 10
name = '视频'
break
}
// 格式不正确
if (!allowTypes.includes(rawFile.type)) {
message.error(`上传${name}格式不对!`)
return false
}
// 大小不正确
if (rawFile.size / 1024 / 1024 > maxSizeMB) {
message.error(`上传${name}大小不能超过${maxSizeMB}M!`)
return false
}
return true
}
return fn
}
export { MaterialType, useBeforeUpload }
......@@ -6,12 +6,13 @@
:limit="1"
:file-list="fileList"
:data="uploadData"
:on-progress="() => (uploading = true)"
:before-upload="beforeUpload"
:on-success="handleUploadSuccess"
:on-progress="(isUploading = true)"
:on-error="onUploadError"
:before-upload="onBeforeUpload"
:on-success="onUploadSuccess"
>
<el-button type="primary" plain :loading="uploading" :disabled="uploading">
{{ uploading ? '正在上传' : '点击上传' }}
<el-button type="primary" plain :loading="isUploading" :disabled="isUploading">
{{ isUploading ? '正在上传' : '点击上传' }}
</el-button>
<template #tip>
<span class="el-upload__tip" style="margin-left: 5px">
......@@ -33,7 +34,7 @@ import {
const message = useMessage()
const props = defineProps<{ type: boolean }>()
const props = defineProps<{ type: MaterialType }>()
const fileList = ref<UploadUserFile[]>([])
const emit = defineEmits<{
......@@ -45,11 +46,13 @@ const uploadData: UploadData = reactive({
title: '',
introduction: ''
})
const uploading = ref(false)
const isUploading = ref(false)
const beforeUpload = props.type == MaterialType.Image ? beforeImageUpload : beforeVoiceUpload
/** 上传前检查 */
const onBeforeUpload = props.type === MaterialType.Image ? beforeImageUpload : beforeVoiceUpload
const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
/** 上传成功处理 */
const onUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
if (res.code !== 0) {
message.alertError('上传出错:' + res.msg)
return false
......@@ -61,7 +64,16 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
uploadData.introduction = ''
message.notifySuccess('上传成功')
uploading.value = false
isUploading.value = false
emit('uploaded')
}
/** 上传失败处理 */
const onUploadError = (err: Error) => message.error('上传失败: ' + err.message)
</script>
<style lang="scss" scoped>
.el-upload__tip {
margin-left: 5px;
}
</style>
......@@ -8,8 +8,9 @@
:file-list="fileList"
:data="uploadData"
:before-upload="beforeVideoUpload"
:on-progress="() => (uploading = true)"
:on-success="handleUploadSuccess"
:on-progress="(isUploading = true)"
:on-error="onUploadError"
:on-success="onUploadSuccess"
ref="uploadVideoRef"
:auto-upload="false"
class="mb-5"
......@@ -22,7 +23,7 @@
>
</el-upload>
<el-divider />
<el-form :model="uploadData" :rules="uploadRules" ref="uploadFormRef" v-loading="uploading">
<el-form :model="uploadData" :rules="uploadRules" ref="uploadFormRef" v-loading="isUploading">
<el-form-item label="标题" prop="title">
<el-input
v-model="uploadData.title"
......@@ -40,7 +41,7 @@
</el-form>
<template #footer>
<el-button @click="showDialog = false">取 消</el-button>
<el-button type="primary" @click="submitVideo" :loading="uploading" :disabled="uploading"
<el-button type="primary" @click="submitVideo" :loading="isUploading" :disabled="isUploading"
>提 交</el-button
>
</template>
......@@ -75,7 +76,7 @@ const emit = defineEmits<{
(e: 'uploaded', v: void)
}>()
const showDialog = computed({
const showDialog = computed<boolean>({
get() {
return props.modelValue
},
......@@ -84,7 +85,7 @@ const showDialog = computed({
}
})
const uploading = ref(false)
const isUploading = ref(false)
const fileList = ref<UploadUserFile[]>([])
......@@ -106,8 +107,9 @@ const submitVideo = () => {
})
}
const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
uploading.value = false
/** 上传成功处理 */
const onUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
isUploading.value = false
if (res.code !== 0) {
message.error('上传出错:' + res.msg)
return false
......@@ -122,4 +124,7 @@ const handleUploadSuccess: UploadProps['onSuccess'] = (res: any) => {
message.notifySuccess('上传成功')
emit('uploaded')
}
/** 上传失败处理 */
const onUploadError = (err: Error) => message.error(`上传失败: ${err.message}`)
</script>
import type { UploadProps, UploadRawFile } from 'element-plus'
import { getAccessToken } from '@/utils/auth'
const message = useMessage() // 消息
import { MaterialType, useBeforeUpload } from '@/views/mp/hooks/useUpload'
const HEADERS = { Authorization: 'Bearer ' + getAccessToken() } // 请求头
// const UPLOAD_URL = 'http://127.0.0.1:8000/upload/' // 上传地址
const UPLOAD_URL = import.meta.env.VITE_BASE_URL + '/admin-api/mp/material/upload-permanent' // 上传地址
enum MaterialType {
Image = 'image',
Voice = 'voice',
Video = 'video'
}
interface UploadData {
type: MaterialType
title: string
introduction: string
}
const beforeUpload = (rawFile: UploadRawFile, materialType: MaterialType): boolean => {
let allowTypes: string[] = []
let maxSizeMB = 0
let name = ''
switch (materialType) {
case MaterialType.Image:
allowTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/bmp', 'image/jpg']
maxSizeMB = 2
name = '图片'
break
case MaterialType.Voice:
allowTypes = ['audio/mp3', 'audio/mpeg', 'audio/wma', 'audio/wav', 'audio/amr']
maxSizeMB = 2
name = '图片'
break
case MaterialType.Video:
allowTypes = ['video/mp4']
maxSizeMB = 10
name = '视频'
break
}
// 格式不正确
if (!allowTypes.includes(rawFile.type)) {
message.error(`上传${name}格式不对!`)
return false
}
// 大小不正确
if (rawFile.size / 1024 / 1024 > maxSizeMB) {
message.error(`上传${name}大小不能超过${maxSizeMB}M!`)
return false
}
return true
}
const beforeImageUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
beforeUpload(rawFile, MaterialType.Image)
useBeforeUpload(MaterialType.Image, 2)(rawFile)
const beforeVoiceUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
beforeUpload(rawFile, MaterialType.Voice)
useBeforeUpload(MaterialType.Voice, 2)(rawFile)
const beforeVideoUpload: UploadProps['beforeUpload'] = (rawFile: UploadRawFile) =>
beforeUpload(rawFile, MaterialType.Video)
useBeforeUpload(MaterialType.Video, 10)(rawFile)
export {
HEADERS,
......
<template>
<div>
<div class="configure_page">
<div class="delete_btn">
<el-button type="danger" @click="emit('delete')">
<Icon icon="ep:delete" />
删除当前菜单
</el-button>
</div>
<div>
<span>菜单名称:</span>
<el-input
class="input_width"
v-model="menu.name"
placeholder="请输入菜单名称"
:maxlength="isParent ? 4 : 7"
clearable
/>
</div>
<div v-if="isLeave">
<div class="menu_content">
<span>菜单标识:</span>
<el-input
class="input_width"
v-model="menu.menuKey"
placeholder="请输入菜单 KEY"
clearable
/>
</div>
<div class="menu_content">
<span>菜单内容:</span>
<el-select v-model="menu.type" clearable placeholder="请选择" class="menu_option">
<el-option
v-for="item in menuOptions"
:label="item.label"
:value="item.value"
:key="item.value"
/>
</el-select>
</div>
<div class="configur_content" v-if="menu.type === 'view'">
<span>跳转链接:</span>
<el-input class="input_width" v-model="menu.url" placeholder="请输入链接" clearable />
</div>
<div class="configur_content" v-if="menu.type === 'miniprogram'">
<div class="applet">
<span>小程序的 appid :</span>
<el-input
class="input_width"
v-model="menu.miniProgramAppId"
placeholder="请输入小程序的appid"
clearable
/>
</div>
<div class="applet">
<span>小程序的页面路径:</span>
<el-input
class="input_width"
v-model="menu.miniProgramPagePath"
placeholder="请输入小程序的页面路径,如:pages/index"
clearable
/>
</div>
<div class="applet">
<span>小程序的备用网页:</span>
<el-input
class="input_width"
v-model="menu.url"
placeholder="不支持小程序的老版本客户端将打开本网页"
clearable
/>
</div>
<p class="blue">tips:需要和公众号进行关联才可以把小程序绑定带微信菜单上哟!</p>
</div>
<div class="configur_content" v-if="menu.type === 'article_view_limited'">
<el-row>
<div class="select-item" v-if="menu && menu.replyArticles">
<WxNews :articles="menu.replyArticles" />
<el-row class="ope-row" justify="center" align="middle">
<el-button type="danger" circle @click="deleteMaterial">
<icon icon="ep:delete" />
</el-button>
</el-row>
</div>
<div v-else>
<el-row justify="center">
<el-col :span="24" style="text-align: center">
<el-button type="success" @click="showNewsDialog = true">
素材库选择
<Icon icon="ep:circle-check" />
</el-button>
</el-col>
</el-row>
</div>
<el-dialog title="选择图文" v-model="showNewsDialog" width="80%" destroy-on-close>
<WxMaterialSelect
:objData="{ type: 'news', accountId: props.accountId }"
@select-material="selectMaterial"
/>
</el-dialog>
</el-row>
</div>
<div
class="configur_content"
v-if="menu.type === 'click' || menu.type === 'scancode_waitmsg'"
>
<WxReplySelect v-if="hackResetWxReplySelect" :objData="menu.reply" />
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import WxReplySelect from '@/views/mp/components/wx-reply/main.vue'
import WxNews from '@/views/mp/components/wx-news/main.vue'
import WxMaterialSelect from '@/views/mp/components/wx-material-select/main.vue'
import menuOptions from './menuOptions'
const message = useMessage()
const props = defineProps<{
accountId?: number
modelValue: any
isParent: boolean
}>()
const emit = defineEmits<{
(e: 'delete', v: void)
(e: 'update:modelValue', v: any)
}>()
// TODO @Dhb52 输入的 table 切换时,表单应该保留
const menu = computed({
get() {
return props.modelValue
},
set(val) {
emit('update:modelValue', val)
}
})
const showNewsDialog = ref(false)
const hackResetWxReplySelect = ref(false)
const isLeave = computed<boolean>(() => !(menu.value.children?.length > 0))
watch(menu, () => {
hackResetWxReplySelect.value = false // 销毁组件
nextTick(() => {
hackResetWxReplySelect.value = true // 重建组件
})
})
// ======================== 菜单编辑(素材选择) ========================
const selectMaterial = (item: any) => {
const articleId = item.articleId
const articles = item.content.newsItem
// 提示,针对多图文
if (articles.length > 1) {
message.alertWarning('您选择的是多图文,将默认跳转第一篇')
}
showNewsDialog.value = false
// 设置菜单的回复
menu.value.articleId = articleId
menu.value.replyArticles = []
articles.forEach((article) => {
menu.value.replyArticles.push({
title: article.title,
description: article.digest,
picUrl: article.picUrl,
url: article.url
})
})
}
const deleteMaterial = () => {
delete menu.value['articleId']
delete menu.value['replyArticles']
}
</script>
<style lang="scss" scoped>
.el-input {
width: 70%;
margin-right: 2%;
}
.configure_page {
.delete_btn {
margin-bottom: 15px;
text-align: right;
}
.menu_content {
margin-top: 20px;
}
.configur_content {
padding: 20px 10px;
margin-top: 20px;
background-color: #fff;
border-radius: 5px;
.select-item {
width: 280px;
padding: 10px;
margin: 0 auto 10px;
border: 1px solid #eaeaea;
.ope-row {
padding-top: 10px;
text-align: center;
}
}
}
.blue {
margin-top: 10px;
color: #29b6f6;
}
.applet {
margin-bottom: 20px;
span {
width: 20%;
}
}
.input_width {
width: 40%;
}
.material {
.input_width {
width: 30%;
}
.el-textarea {
width: 80%;
}
}
}
</style>
<template>
<div class="menu_bottom" v-for="(parent, x) of menuList" :key="x">
<!-- 一级菜单 -->
<div
@click="menuClicked(parent, x)"
class="menu_item"
:class="{ active: props.activeIndex === `${x}` }"
>
<Icon icon="ep:fold" color="black" />{{ parent.name }}
</div>
<!-- 以下为二级菜单-->
<div class="submenu" v-if="parentIndex === x && parent.children">
<div class="subtitle menu_bottom" v-for="(child, y) in parent.children" :key="y">
<div
class="menu_subItem"
v-if="parent.children"
:class="{ active: props.activeIndex === `${x}-${y}` }"
@click="subMenuClicked(child, x, y)"
>
{{ child.name }}
</div>
</div>
<!-- 二级菜单加号, 当长度 小于 5 才显示二级菜单的加号 -->
<div
class="menu_bottom menu_addicon"
v-if="!parent.children || parent.children.length < 5"
@click="addSubMenu(x, parent)"
>
<Icon icon="ep:plus" class="plus" />
</div>
</div>
</div>
<!-- 一级菜单加号 -->
<div class="menu_bottom menu_addicon" v-if="menuList.length < 3" @click="addMenu">
<Icon icon="ep:plus" class="plus" />
</div>
</template>
<script setup lang="ts">
import { Menu } from './types'
const props = defineProps<{
modelValue: Menu[]
activeIndex: string
parentIndex: number
accountId?: number
}>()
const emit = defineEmits<{
(e: 'update:modelValue', v: Menu[])
(e: 'menu-clicked', parent: Menu, x: number)
(e: 'submenu-clicked', child: Menu, x: number, y: number)
}>()
const menuList = computed<Menu[]>({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val)
})
// 添加横向一级菜单
const addMenu = () => {
const index = menuList.value.length
const menu = {
name: '菜单名称',
children: [],
reply: {
// 用于存储回复内容
type: 'text',
accountId: props.accountId // 保证组件里,可以使用到对应的公众号
}
}
menuList.value[index] = menu
menuClicked(menu, index - 1)
}
// 添加横向二级菜单;parent 表示要操作的父菜单
const addSubMenu = (i: number, parent: any) => {
const subMenuKeyLength = parent.children.length // 获取二级菜单key长度
const addButton = {
name: '子菜单名称',
reply: {
// 用于存储回复内容
type: 'text',
accountId: props.accountId // 保证组件里,可以使用到对应的公众号
}
}
parent.children[subMenuKeyLength] = addButton
subMenuClicked(parent.children[subMenuKeyLength], i, subMenuKeyLength)
}
const menuClicked = (parent: Menu, x: number) => {
emit('menu-clicked', parent, x)
}
const subMenuClicked = (child: Menu, x: number, y: number) => {
emit('submenu-clicked', child, x, y)
}
</script>
<style lang="scss" scoped>
.menu_bottom {
position: relative;
display: inline-block;
float: left;
width: 85.5px;
text-align: center;
cursor: pointer;
background-color: #fff;
border: 1px solid #ebedee;
box-sizing: border-box;
&.menu_addicon {
height: 46px;
line-height: 46px;
.plus {
color: #2bb673;
}
}
.menu_item {
display: flex;
width: 100%;
height: 44px;
line-height: 44px;
// text-align: center;
box-sizing: border-box;
align-items: center;
justify-content: center;
&.active {
border: 1px solid #2bb673;
}
}
.menu_subItem {
height: 44px;
line-height: 44px;
text-align: center;
box-sizing: border-box;
&.active {
border: 1px solid #2bb673;
}
}
}
/* 第二级菜单 */
.submenu {
position: absolute;
bottom: 45px;
width: 85.5px;
.subtitle {
background-color: #fff;
box-sizing: border-box;
}
}
</style>
export interface Replay {
title: string
description: string
picUrl: string
url: string
}
export type MenuType =
| ''
| 'click'
| 'view'
| 'scancode_waitmsg'
| 'scancode_push'
| 'pic_sysphoto'
| 'pic_photo_or_album'
| 'pic_weixin'
| 'location_select'
| 'article_view_limited'
interface _RawMenu {
// db
id: number
parentId: number
accountId: number
appId: string
createTime: number
// mp-native
name: string
menuKey: string
type: MenuType
url: string
miniProgramAppId: string
miniProgramPagePath: string
articleId: string
replyMessageType: string
replyContent: string
replyMediaId: string
replyMediaUrl: string
replyThumbMediaId: string
replyThumbMediaUrl: string
replyTitle: string
replyDescription: string
replyArticles: Replay
replyMusicUrl: string
replyHqMusicUrl: string
}
export type RawMenu = Partial<_RawMenu>
interface _Reply {
type: string
accountId: number
content: string
mediaId: string
url: string
thumbMediaId: string
thumbMediaUrl: string
title: string
description: string
articles: null | Replay[]
musicUrl: string
hqMusicUrl: string
}
export type Reply = Partial<_Reply>
interface _Menu extends RawMenu {
children: _Menu[]
reply: Reply
}
export type Menu = Partial<_Menu>
......@@ -212,7 +212,7 @@ const handleDelete = async (id: number) => {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await NotifyTemplateApi.deleteNotifyTemplateApi(id)
await NotifyTemplateApi.deleteNotifyTemplate(id)
message.success('删除成功')
// 刷新列表
await getList()
......
......@@ -91,6 +91,7 @@ const open = async (row: RoleApi.RoleVO) => {
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
if (!formRef) return
......@@ -109,6 +110,8 @@ const submitForm = async () => {
await PermissionApi.assignRoleMenu(data)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
......
......@@ -107,6 +107,7 @@ const open = async (row: RoleApi.RoleVO) => {
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
formLoading.value = true
try {
......@@ -121,6 +122,8 @@ const submitForm = async () => {
await PermissionApi.assignRoleDataScope(data)
message.success(t('common.updateSuccess'))
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
......
......@@ -156,9 +156,9 @@
<!-- 表单弹窗:添加/修改 -->
<RoleForm ref="formRef" @success="getList" />
<!-- 表单弹窗:菜单权限 -->
<RoleAssignMenuForm ref="assignMenuFormRef" />
<RoleAssignMenuForm ref="assignMenuFormRef" @success="getList" />
<!-- 表单弹窗:数据权限 -->
<RoleDataPermissionForm ref="dataPermissionFormRef" />
<RoleDataPermissionForm ref="dataPermissionFormRef" @success="getList" />
</template>
<script lang="ts" name="SystemRole" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
......
......@@ -230,7 +230,7 @@ const queryFormRef = ref() // 搜索的表单
const getList = async () => {
loading.value = true
try {
const data = await UserApi.getUserPage(queryParams.value)
const data = await UserApi.getUserPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment