Merge remote-tracking branch 'yudao/dev' into dev

This commit is contained in:
dhb52 2023-04-16 22:09:48 +08:00
commit 30b8eeaccb
19 changed files with 268 additions and 218 deletions

31
.env.stage Normal file
View File

@ -0,0 +1,31 @@
# 生产环境
NODE_ENV=production
VITE_DEV=false
# 请求路径
VITE_BASE_URL='http://api-dashboard.yudao.iocoder.cn'
# 上传路径
VITE_UPLOAD_URL='http://api-dashboard.yudao.iocoder.cn/admin-api/infra/file/upload'
# 接口前缀
VITE_API_BASEPATH=
# 接口地址
VITE_API_URL=/admin-api
# 是否删除debugger
VITE_DROP_DEBUGGER=true
# 是否删除console.log
VITE_DROP_CONSOLE=true
# 是否sourcemap
VITE_SOURCEMAP=false
# 打包路径
VITE_BASE_PATH='http://static-vue3.yudao.iocoder.cn/'
# 输出路径
VITE_OUT_DIR=dist-stage

View File

@ -25,7 +25,7 @@ VITE_DROP_CONSOLE=false
VITE_SOURCEMAP=true VITE_SOURCEMAP=true
# 打包路径 # 打包路径
VITE_BASE_PATH=/dist-test/ VITE_BASE_PATH=/
# 输出路径 # 输出路径
VITE_OUT_DIR=dist-test VITE_OUT_DIR=dist-test

View File

@ -11,6 +11,7 @@
"ts:check": "vue-tsc --noEmit", "ts:check": "vue-tsc --noEmit",
"build:pro": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode pro", "build:pro": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode pro",
"build:dev": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode dev", "build:dev": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode dev",
"build:stage": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode stage",
"build:test": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode test", "build:test": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode test",
"build:static": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode static", "build:static": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode static",
"build:front": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode front", "build:front": "node --max_old_space_size=8000 ./node_modules/vite/bin/vite.js build --mode front",

View File

@ -1,24 +1,17 @@
import request from '@/config/axios' import request from '@/config/axios'
export interface NotifyTemplateVO { export interface NotifyTemplateVO {
id: number | null id?: number
name: string name: string
nickname: string nickname: string
code: string code: string
content: string content: string
type: number | null type: number
params: string params: string
status: number | null status: number
remark: string remark: string
} }
export interface NotifyTemplatePageReqVO extends PageParam {
name?: string
code?: string
status?: number
createTime?: Date[]
}
export interface NotifySendReqVO { export interface NotifySendReqVO {
userId: number | null userId: number | null
templateCode: string templateCode: string
@ -26,22 +19,22 @@ export interface NotifySendReqVO {
} }
// 查询站内信模板列表 // 查询站内信模板列表
export const getNotifyTemplatePageApi = async (params: NotifyTemplatePageReqVO) => { export const getNotifyTemplatePage = async (params: PageParam) => {
return await request.get({ url: '/system/notify-template/page', params }) return await request.get({ url: '/system/notify-template/page', params })
} }
// 查询站内信模板详情 // 查询站内信模板详情
export const getNotifyTemplateApi = async (id: number) => { export const getNotifyTemplate = async (id: number) => {
return await request.get({ url: '/system/notify-template/get?id=' + id }) return await request.get({ url: '/system/notify-template/get?id=' + id })
} }
// 新增站内信模板 // 新增站内信模板
export const createNotifyTemplateApi = async (data: NotifyTemplateVO) => { export const createNotifyTemplate = async (data: NotifyTemplateVO) => {
return await request.post({ url: '/system/notify-template/create', data }) return await request.post({ url: '/system/notify-template/create', data })
} }
// 修改站内信模板 // 修改站内信模板
export const updateNotifyTemplateApi = async (data: NotifyTemplateVO) => { export const updateNotifyTemplate = async (data: NotifyTemplateVO) => {
return await request.put({ url: '/system/notify-template/update', data }) return await request.put({ url: '/system/notify-template/update', data })
} }
@ -51,6 +44,6 @@ export const deleteNotifyTemplateApi = async (id: number) => {
} }
// 发送站内信 // 发送站内信
export const sendNotifyApi = (data: NotifySendReqVO) => { export const sendNotify = (data: NotifySendReqVO) => {
return request.post({ url: '/system/notify-template/send-notify', data }) return request.post({ url: '/system/notify-template/send-notify', data })
} }

View File

@ -1,37 +1,11 @@
import { App } from 'vue'
import MyProcessDesigner from './designer' import MyProcessDesigner from './designer'
import MyProcessPenal from './penal' import MyProcessPenal from './penal'
import MyProcessViewer from './designer/index2' import MyProcessViewer from './designer/index2'
const components = [MyProcessDesigner, MyProcessPenal, MyProcessViewer] import './theme/index.scss'
import 'bpmn-js/dist/assets/diagram-js.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'
// const install = function (Vue) { export { MyProcessDesigner, MyProcessPenal, MyProcessViewer }
// components.forEach(component => {
// Vue.component(component.name, component)
// })
// }
// if (typeof window !== "undefined" && window.Vue) {
// install(window.Vue)
// }
// components.forEach(component => {
// Vue.component(component.name, component)
// })
const componentss = {
install: (Vue: App): void => {
components.forEach((component) => {
Vue.component(component.name, component)
})
}
}
// let version = "0.0.1"
export const MyPD = (app) => {
// export default {
// app.use(version)
// app.use(install)
// app.use(MyProcessDesigner)
// app.use(MyProcessPenal)
// app.use(MyProcessViewer)
// app.use(components)
app.use(componentss)
}

View File

@ -1,21 +1,6 @@
import type { App } from 'vue' import type { App } from 'vue'
import { Icon } from './Icon' import { Icon } from './Icon'
import { Form } from '@/components/Form'
import { Table } from '@/components/Table'
import { Search } from '@/components/Search'
import { XButton, XTextButton } from '@/components/XButton'
import { DictTag } from '@/components/DictTag'
import { ContentWrap } from '@/components/ContentWrap'
import { Descriptions } from '@/components/Descriptions'
export const setupGlobCom = (app: App<Element>): void => { export const setupGlobCom = (app: App<Element>): void => {
app.component('Icon', Icon) app.component('Icon', Icon)
app.component('Form', Form)
app.component('Table', Table)
app.component('Search', Search)
app.component('XButton', XButton)
app.component('XTextButton', XTextButton)
app.component('DictTag', DictTag)
app.component('ContentWrap', ContentWrap)
app.component('Descriptions', Descriptions)
} }

View File

@ -37,16 +37,6 @@ import App from './App.vue'
import './permission' import './permission'
import { MyPD } from '@/components/bpmnProcessDesigner/package/index.js'
import '@/components/bpmnProcessDesigner/package/theme/index.scss'
import 'bpmn-js/dist/assets/diagram-js.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-codes.css'
import 'bpmn-js/dist/assets/bpmn-font/css/bpmn-embedded.css'
import hljs from 'highlight.js' //导入代码高亮文件
import 'highlight.js/styles/github.css' //导入代码高亮样式 新版
import '@/plugins/tongji' // 百度统计 import '@/plugins/tongji' // 百度统计
import Logger from '@/utils/Logger' import Logger from '@/utils/Logger'
@ -55,18 +45,8 @@ import Logger from '@/utils/Logger'
const setupAll = async () => { const setupAll = async () => {
const app = createApp(App) const app = createApp(App)
//自定义一个代码高亮指令
app.directive('highlight', function (el) {
const blocks = el.querySelectorAll('code')
blocks.forEach((block: any) => {
hljs.highlightElement(block)
})
})
await setupI18n(app) await setupI18n(app)
MyPD(app)
setupStore(app) setupStore(app)
setupGlobCom(app) setupGlobCom(app)

View File

@ -17,7 +17,6 @@ import {
import formCreate from '@form-create/element-ui' import formCreate from '@form-create/element-ui'
import install from '@form-create/element-ui/auto-import' import install from '@form-create/element-ui/auto-import'
import FcDesigner from '@form-create/designer'
const components = [ const components = [
ElAside, ElAside,
@ -34,14 +33,11 @@ const components = [
ElTabPane ElTabPane
] ]
// 参考 http://www.form-create.com/v3/element-ui/auto-import.html 文档
export const setupFormCreate = (app: App<Element>) => { export const setupFormCreate = (app: App<Element>) => {
components.forEach((component) => { components.forEach((component) => {
app.component(component.name, component) app.component(component.name, component)
}) })
formCreate.use(install) formCreate.use(install)
app.use(formCreate) app.use(formCreate)
app.use(FcDesigner)
} }

View File

@ -84,7 +84,7 @@
<!-- 弹窗流程模型图的预览 --> <!-- 弹窗流程模型图的预览 -->
<Dialog title="流程图" v-model="bpmnDetailVisible" width="800"> <Dialog title="流程图" v-model="bpmnDetailVisible" width="800">
<my-process-viewer <MyProcessViewer
key="designer" key="designer"
v-model="bpmnXML" v-model="bpmnXML"
:value="bpmnXML" :value="bpmnXML"
@ -97,6 +97,7 @@
<script setup lang="ts" name="BpmProcessDefinition"> <script setup lang="ts" name="BpmProcessDefinition">
import { DICT_TYPE } from '@/utils/dict' import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package'
import * as DefinitionApi from '@/api/bpm/definition' import * as DefinitionApi from '@/api/bpm/definition'
import { setConfAndFields2 } from '@/utils/formCreate' import { setConfAndFields2 } from '@/utils/formCreate'
const { push } = useRouter() // const { push } = useRouter() //

View File

@ -1,14 +1,14 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 表单设计器 --> <!-- 表单设计器 -->
<fc-designer ref="designer" height="780px"> <FcDesigner ref="designer" height="780px">
<template #handle> <template #handle>
<el-button round size="small" type="primary" @click="handleSave"> <el-button round size="small" type="primary" @click="handleSave">
<Icon class="mr-5px" icon="ep:plus" /> <Icon class="mr-5px" icon="ep:plus" />
保存 保存
</el-button> </el-button>
</template> </template>
</fc-designer> </FcDesigner>
</ContentWrap> </ContentWrap>
<!-- 表单保存的弹窗 --> <!-- 表单保存的弹窗 -->
@ -42,6 +42,7 @@
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { CommonStatusEnum } from '@/utils/constants' import { CommonStatusEnum } from '@/utils/constants'
import * as FormApi from '@/api/bpm/form' import * as FormApi from '@/api/bpm/form'
import FcDesigner from '@form-create/designer'
import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate' import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate'
const { t } = useI18n() // const { t } = useI18n() //

View File

@ -1,7 +1,7 @@
<template> <template>
<ContentWrap> <ContentWrap>
<!-- 流程设计器负责绘制流程等 --> <!-- 流程设计器负责绘制流程等 -->
<my-process-designer <MyProcessDesigner
key="designer" key="designer"
v-if="xmlString !== undefined" v-if="xmlString !== undefined"
v-model="xmlString" v-model="xmlString"
@ -14,7 +14,7 @@
@save="save" @save="save"
/> />
<!-- 流程属性器负责编辑每个流程节点的属性 --> <!-- 流程属性器负责编辑每个流程节点的属性 -->
<my-properties-panel <MyProcessPenal
key="penal" key="penal"
:bpmnModeler="modeler" :bpmnModeler="modeler"
:prefix="controlForm.prefix" :prefix="controlForm.prefix"
@ -25,6 +25,7 @@
</template> </template>
<script setup lang="ts" name="BpmModelEditor"> <script setup lang="ts" name="BpmModelEditor">
import { MyProcessDesigner, MyProcessPenal } from '@/components/bpmnProcessDesigner/package'
// //
import CustomContentPadProvider from '@/components/bpmnProcessDesigner/package/designer/plugins/content-pad' import CustomContentPadProvider from '@/components/bpmnProcessDesigner/package/designer/plugins/content-pad'
// //

View File

@ -216,7 +216,7 @@
<!-- 弹窗流程模型图的预览 --> <!-- 弹窗流程模型图的预览 -->
<Dialog title="流程图" v-model="bpmnDetailVisible" width="800"> <Dialog title="流程图" v-model="bpmnDetailVisible" width="800">
<my-process-viewer <MyProcessViewer
key="designer" key="designer"
v-model="bpmnXML" v-model="bpmnXML"
:value="bpmnXML" :value="bpmnXML"
@ -229,6 +229,7 @@
<script setup lang="ts" name="BpmModel"> <script setup lang="ts" name="BpmModel">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter, formatDate } from '@/utils/formatTime' import { dateFormatter, formatDate } from '@/utils/formatTime'
import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package'
import * as ModelApi from '@/api/bpm/model' import * as ModelApi from '@/api/bpm/model'
import * as FormApi from '@/api/bpm/form' import * as FormApi from '@/api/bpm/form'
import ModelForm from './ModelForm.vue' import ModelForm from './ModelForm.vue'

View File

@ -3,7 +3,7 @@
<template #header> <template #header>
<span class="el-icon-picture-outline">流程图</span> <span class="el-icon-picture-outline">流程图</span>
</template> </template>
<my-process-viewer <MyProcessViewer
key="designer" key="designer"
:activityData="activityList" :activityData="activityList"
:prefix="bpmnControlForm.prefix" :prefix="bpmnControlForm.prefix"
@ -16,8 +16,8 @@
</template> </template>
<script lang="ts" name="BpmProcessInstanceBpmnViewer" setup> <script lang="ts" name="BpmProcessInstanceBpmnViewer" setup>
import { propTypes } from '@/utils/propTypes' import { propTypes } from '@/utils/propTypes'
import { MyProcessViewer } from '@/components/bpmnProcessDesigner/package'
import * as ActivityApi from '@/api/bpm/activity' import * as ActivityApi from '@/api/bpm/activity'
// import * as DefinitionApi from '@/api/bpm/definition'
const props = defineProps({ const props = defineProps({
loading: propTypes.bool, // loading: propTypes.bool, //

View File

@ -4,13 +4,13 @@
<el-col> <el-col>
<div class="mb-2 float-right"> <div class="mb-2 float-right">
<el-button size="small" type="primary" @click="showJson">生成 JSON</el-button> <el-button size="small" type="primary" @click="showJson">生成 JSON</el-button>
<el-button size="small" type="success" @click="showOption">生成O ptions</el-button> <el-button size="small" type="success" @click="showOption">生成 Options</el-button>
<el-button size="small" type="danger" @click="showTemplate">生成组件</el-button> <el-button size="small" type="danger" @click="showTemplate">生成组件</el-button>
</div> </div>
</el-col> </el-col>
<!-- 表单设计器 --> <!-- 表单设计器 -->
<el-col> <el-col>
<fc-designer ref="designer" height="780px" /> <FcDesigner ref="designer" height="780px" />
</el-col> </el-col>
</el-row> </el-row>
</ContentWrap> </ContentWrap>
@ -22,18 +22,17 @@
{{ t('common.copy') }} {{ t('common.copy') }}
</el-button> </el-button>
<el-scrollbar height="580"> <el-scrollbar height="580">
<div v-highlight> <div>
<code class="hljs"> <pre><code class="hljs" v-html="highlightedCode(formData)"></code></pre>
{{ formData }}
</code>
</div> </div>
</el-scrollbar> </el-scrollbar>
</div> </div>
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts" name="InfraBuild"> <script setup lang="ts" name="InfraBuild">
import formCreate from '@form-create/element-ui' import FcDesigner from '@form-create/designer'
import { useClipboard } from '@vueuse/core' import { useClipboard } from '@vueuse/core'
import { isString } from '@/utils/is'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
@ -109,4 +108,32 @@ const copy = async (text: string) => {
} }
} }
} }
/**
* 代码高亮
*/
import hljs from 'highlight.js' //
import 'highlight.js/styles/github.css' //
import xml from 'highlight.js/lib/languages/java'
import json from 'highlight.js/lib/languages/json'
const highlightedCode = (code) => {
//
let language = 'json'
if (formType.value === 2) {
language = 'xml'
}
if (!isString(code)) {
code = JSON.stringify(code)
}
//
const result = hljs.highlight(language, code, true)
return result.value || '&nbsp;'
}
/** 初始化 **/
onMounted(async () => {
//
hljs.registerLanguage('xml', xml)
hljs.registerLanguage('json', json)
})
</script> </script>

View File

@ -45,8 +45,8 @@
<el-button class="float-right" text type="primary" @click="copy(item.code)"> <el-button class="float-right" text type="primary" @click="copy(item.code)">
{{ t('common.copy') }} {{ t('common.copy') }}
</el-button> </el-button>
<div v-highlight> <div>
<code>{{ item.code }}</code> <pre><code class="hljs" v-html="highlightedCode(item)"></code></pre>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -180,6 +180,34 @@ const copy = async (text: string) => {
message.success(t('common.copySuccess')) message.success(t('common.copySuccess'))
} }
} }
/**
* 代码高亮
*/
import hljs from 'highlight.js' //
import 'highlight.js/styles/github.css' //
import java from 'highlight.js/lib/languages/java'
import xml from 'highlight.js/lib/languages/java'
import javascript from 'highlight.js/lib/languages/javascript'
import sql from 'highlight.js/lib/languages/sql'
import typescript from 'highlight.js/lib/languages/typescript'
const highlightedCode = (item) => {
const language = item.filePath.substring(item.filePath.lastIndexOf('.') + 1)
const result = hljs.highlight(language, item.code || '', true)
return result.value || '&nbsp;'
}
/** 初始化 **/
onMounted(async () => {
//
hljs.registerLanguage('java', java)
hljs.registerLanguage('xml', xml)
hljs.registerLanguage('html', xml)
hljs.registerLanguage('vue', xml)
hljs.registerLanguage('javascript', javascript)
hljs.registerLanguage('sql', sql)
hljs.registerLanguage('typescript', typescript)
})
</script> </script>
<style lang="scss"> <style lang="scss">
.app-infra-codegen-preview-container { .app-infra-codegen-preview-container {

View File

@ -25,7 +25,7 @@
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="parseInt(dict.value)" :value="dict.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
@ -34,7 +34,7 @@
<el-radio <el-radio
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :key="dict.value"
:label="parseInt(dict.value as string)" :label="dict.value as string"
> >
{{ dict.label }} {{ dict.label }}
</el-radio> </el-radio>
@ -81,6 +81,7 @@ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
/** 打开弹窗 */
const open = async (type: string, id?: number) => { const open = async (type: string, id?: number) => {
dialogVisible.value = true dialogVisible.value = true
dialogTitle.value = type dialogTitle.value = type
@ -90,7 +91,7 @@ const open = async (type: string, id?: number) => {
if (id) { if (id) {
formLoading.value = true formLoading.value = true
try { try {
formData.value = await NotifyTemplateApi.getNotifyTemplateApi(id) formData.value = await NotifyTemplateApi.getNotifyTemplate(id)
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
@ -107,12 +108,12 @@ const submitForm = async () => {
if (!valid) return if (!valid) return
formLoading.value = true formLoading.value = true
try { try {
const data = formData.value as NotifyTemplateApi.NotifyTemplateVO const data = formData.value as unknown as NotifyTemplateApi.NotifyTemplateVO
if (formType.value === 'create') { if (formType.value === 'create') {
await NotifyTemplateApi.createNotifyTemplateApi(data) await NotifyTemplateApi.createNotifyTemplate(data)
message.success('新增成功') message.success('新增成功')
} else { } else {
await NotifyTemplateApi.updateNotifyTemplateApi(data) await NotifyTemplateApi.updateNotifyTemplate(data)
message.success('修改成功') message.success('修改成功')
} }
dialogVisible.value = false dialogVisible.value = false

View File

@ -0,0 +1,127 @@
<template>
<Dialog v-model="dialogVisible" title="测试发送" :max-height="500">
<el-form
ref="formRef"
v-loading="formLoading"
:model="formData"
:rules="formRules"
label-width="140px"
>
<el-form-item label="模板内容" prop="content">
<el-input
v-model="formData.content"
placeholder="请输入模板内容"
readonly
type="textarea"
/>
</el-form-item>
<el-form-item label="接收人" prop="userId">
<el-select v-model="formData.userId" placeholder="请选择接收人">
<el-option
v-for="item in userOption"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item
v-for="param in formData.params"
:key="param"
:label="'参数 {' + param + '}'"
:prop="'templateParams.' + param"
>
<el-input
v-model="formData.templateParams[param]"
:placeholder="'请输入 ' + param + ' 参数'"
/>
</el-form-item>
</el-form>
<template #footer>
<el-button :disabled="formLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="dialogVisible = false"> </el-button>
</template>
</Dialog>
</template>
<script lang="ts" name="SystemNotifyTemplateSendForm" setup>
import * as SmsTemplateApi from '@/api/system/sms/smsTemplate'
import * as UserApi from '@/api/system/user'
import * as NotifyTemplateApi from '@/api/system/notify/template'
const message = useMessage() //
const dialogVisible = ref(false) //
const formLoading = ref(false) // 12
const formData = ref({
content: '',
params: {},
userId: null,
templateCode: '',
templateParams: new Map()
})
const formRules = reactive({
userId: [{ required: true, message: '用户编号不能为空', trigger: 'change' }],
templateCode: [{ required: true, message: '模版编号不能为空', trigger: 'blur' }],
templateParams: {}
})
const formRef = ref() // Ref
const userOption = ref<UserApi.UserVO[]>([])
const open = async (id: number) => {
dialogVisible.value = true
resetForm()
//
formLoading.value = true
try {
const data = await NotifyTemplateApi.getNotifyTemplate(id)
//
formData.value.content = data.content
formData.value.params = data.params
formData.value.templateCode = data.code
formData.value.templateParams = data.params.reduce((obj, item) => {
obj[item] = '' //
return obj
}, {})
formRules.templateParams = data.params.reduce((obj, item) => {
obj[item] = { required: true, message: '参数 ' + item + ' 不能为空', trigger: 'blur' }
return obj
}, {})
} finally {
formLoading.value = false
}
//
userOption.value = await UserApi.getSimpleUserList()
}
defineExpose({ open }) // open
/** 提交表单 */
const submitForm = async () => {
//
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data = formData.value as SmsTemplateApi.SendSmsReqVO
const logId = await SmsTemplateApi.sendSms(data)
if (logId) {
message.success('提交发送成功!发送结果,见发送日志编号:' + logId)
}
dialogVisible.value = false
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
content: '',
params: {},
mobile: '',
templateCode: '',
templateParams: new Map()
}
formRef.value?.resetFields()
}
</script>

View File

@ -1,8 +1,8 @@
<template> <template>
<doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" /> <doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
<ContentWrap>
<!-- 搜索工作栏 --> <!-- 搜索工作栏 -->
<ContentWrap>
<el-form <el-form
class="-mb-15px" class="-mb-15px"
:model="queryParams" :model="queryParams"
@ -99,7 +99,6 @@
width="200" width="200"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
/> />
<el-table-column label="开启状态" align="center" prop="status" width="80"> <el-table-column label="开启状态" align="center" prop="status" width="80">
<template #default="scope"> <template #default="scope">
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
@ -151,67 +150,22 @@
/> />
</ContentWrap> </ContentWrap>
<Dialog v-model="dialogFormVisible" title="测试发送" :max-height="500">
<el-form
ref="sendFormRef"
:model="sendFormData"
:rules="sendFormRules"
label-width="140px"
v-loading="formLoading"
>
<el-form-item label="模板内容" prop="content">
<el-input v-model="sendFormData.content" readonly />
</el-form-item>
<el-form-item label="接收人" prop="userId">
<el-select v-model="sendFormData.userId" placeholder="请选择接收人">
<el-option
v-for="item in userOption"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item
v-for="param in sendFormData.params"
:key="param"
:label="'参数 {' + param + '}'"
:prop="'templateParams.' + param"
>
<el-input
v-model="sendFormData.templateParams[param]"
:placeholder="'请输入 ' + param + ' 参数'"
/>
</el-form-item>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="submitForm"> 确定 </el-button>
</span>
</template>
</Dialog>
<!-- 表单弹窗添加/修改 --> <!-- 表单弹窗添加/修改 -->
<NotifyTemplateForm ref="formRef" @success="getList" /> <NotifyTemplateForm ref="formRef" @success="getList" />
<!-- 表单弹窗测试发送 -->
<NotifyTemplateSendForm ref="sendFormRef" />
</template> </template>
<script setup lang="ts" name="NotifySmsTemplate"> <script setup lang="ts" name="NotifySmsTemplate">
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime' import { dateFormatter } from '@/utils/formatTime'
import * as NotifyTemplateApi from '@/api/system/notify/template' import * as NotifyTemplateApi from '@/api/system/notify/template'
import { getSimpleUserList, UserVO } from '@/api/system/user'
import NotifyTemplateForm from './NotifyTemplateForm.vue' import NotifyTemplateForm from './NotifyTemplateForm.vue'
import NotifyTemplateSendForm from './NotifyTemplateSendForm.vue'
const message = useMessage() // const message = useMessage() //
const loading = ref(false) // const loading = ref(false) //
const total = ref(0) // const total = ref(0) //
const list = ref([]) // const list = ref([]) //
const queryFormRef = ref() //
const formLoading = ref(false)
const dialogFormVisible = ref(false)
const sendFormRef = ref() // Ref
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
@ -220,28 +174,13 @@ const queryParams = reactive({
code: undefined, code: undefined,
createTime: [] createTime: []
}) })
const queryFormRef = ref() //
const sendFormData = ref({
content: '',
params: {},
userId: null,
templateCode: '',
templateParams: {}
})
const sendFormRules = ref({
userId: [{ required: true, message: '用户编号不能为空', trigger: 'change' }],
templateCode: [{ required: true, message: '模版编号不能为空', trigger: 'blur' }],
templateParams: {}
})
const userOption = ref<UserVO[]>([])
/** 查询列表 */ /** 查询列表 */
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
const data = await NotifyTemplateApi.getNotifyTemplatePageApi(queryParams) const data = await NotifyTemplateApi.getNotifyTemplatePage(queryParams)
list.value = data.list list.value = data.list
total.value = data.total total.value = data.total
} finally { } finally {
@ -280,50 +219,14 @@ const handleDelete = async (id: number) => {
} catch {} } catch {}
} }
const openSendForm = (row: any) => { /** 发送站内信按钮 */
sendFormData.value.content = row.content const sendFormRef = ref() // Ref
sendFormData.value.params = row.params const openSendForm = (row: NotifyTemplateApi.NotifyTemplateVO) => {
sendFormData.value.templateCode = row.code sendFormRef.value.open(row.id)
sendFormData.value.templateParams = row.params.reduce(function (obj, item) {
obj[item] = undefined
return obj
}, {})
sendFormRules.value.templateParams = row.params.reduce(function (obj, item) {
obj[item] = { required: true, message: '参数 ' + item + ' 不能为空', trigger: 'change' }
return obj
}, {})
dialogFormVisible.value = true
}
/** 提交表单 */
const submitForm = async () => {
//
if (!sendFormRef) return
const valid = await sendFormRef.value.validate()
if (!valid) return
//
formLoading.value = true
try {
const data: NotifyTemplateApi.NotifySendReqVO = {
userId: sendFormData.value.userId,
templateCode: sendFormData.value.templateCode,
templateParams: sendFormData.value.templateParams as unknown as Map<string, Object>
}
const res = await NotifyTemplateApi.sendNotifyApi(data)
if (res) {
message.success('提交发送成功!发送结果,见消息记录编号:' + res)
}
dialogFormVisible.value = false
} finally {
formLoading.value = false
}
} }
/** 初始化 **/ /** 初始化 **/
onMounted(() => { onMounted(() => {
getList() getList()
getSimpleUserList().then((data) => {
userOption.value = data
})
}) })
</script> </script>