Procházet zdrojové kódy

feat: 😀增加消息模板类型字段,并优化消息模板功能

喵你个旺呀 před 1 rokem
rodič
revize
061e3d2bcb

+ 6 - 0
Admin.NET/Admin.NET.Core/Entity/SysTemplate.cs

@@ -22,6 +22,12 @@ public partial class SysTemplate : EntityTenant
     [SugarColumn(ColumnDescription = "名称", Length = 128)]
     public virtual string Name { get; set; }
 
+    /// <summary>
+    /// 分组名称
+    /// </summary>
+    [SugarColumn(ColumnDescription = "分组名称")]
+    public virtual TemplateTypeEnum Type { get; set; }
+
     /// <summary>
     /// 编码
     /// </summary>

+ 50 - 0
Admin.NET/Admin.NET.Core/Enum/TemplateTypeEnum.cs

@@ -0,0 +1,50 @@
+// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
+//
+// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
+//
+// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
+
+namespace Admin.NET.Core;
+
+/// <summary>
+/// 消息模板类型枚举
+/// </summary>
+[Description("消息模板类型枚举")]
+public enum TemplateTypeEnum
+{
+    /// <summary>
+    /// 通知公告
+    /// </summary>
+    [Description("通知")]
+    Notice = 1,
+
+    /// <summary>
+    /// 短信
+    /// </summary>
+    [Description("短信")]
+    SMS = 2,
+
+    /// <summary>
+    /// 邮件
+    /// </summary>
+    [Description("邮件")]
+    Email = 3,
+
+    /// <summary>
+    /// 微信
+    /// </summary>
+    [Description("微信")]
+    Wechat = 4,
+
+    /// <summary>
+    /// 钉钉
+    /// </summary>
+    [Description("钉钉")]
+    DingTalk = 5,
+
+    /// <summary>
+    /// 企业微信
+    /// </summary>
+    [Description("企业微信")]
+    WeChatWork = 7
+}

+ 1 - 1
Admin.NET/Admin.NET.Core/SeedData/SysMenuSeedData.cs

@@ -131,7 +131,7 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
             new SysMenu{ Id=1300300050801, Pid=1300300050101, Title="编辑字典值", Permission="sysDictData:update", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
             new SysMenu{ Id=1300300050901, Pid=1300300050101, Title="字典迁移", Permission="sysDictType:move", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
 
-            new SysMenu{ Id=1300300051101, Pid=1300300000101, Title="模板管理", Path="/platform/template", Name="sysTemplate", Component="/system/template/index", Icon="ele-Collection", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=135 },
+            new SysMenu{ Id=1300300051101, Pid=1300300000101, Title="模板管理", Path="/platform/template", Name="sysTemplate", Component="/system/template/index", Icon="ele-Document", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=135 },
             new SysMenu{ Id=1300300051201, Pid=1300300051101, Title="查询", Permission="sysTemplate:page", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
             new SysMenu{ Id=1300300051301, Pid=1300300051101, Title="编辑", Permission="sysTemplate:update", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },
             new SysMenu{ Id=1300300051401, Pid=1300300051101, Title="增加", Permission="sysTemplate:add", Type=MenuTypeEnum.Btn, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=100 },

+ 11 - 0
Admin.NET/Admin.NET.Core/Service/Template/Dto/SysTemplateInput.cs

@@ -23,6 +23,11 @@ public class PageTemplateInput : BasePageInput
     /// </summary>
     public string GroupName { get; set; }
 
+    /// <summary>
+    /// 模板类型
+    /// </summary>
+    public TemplateTypeEnum? Type { get; set; }
+
     /// <summary>
     /// 租户Id
     /// </summary>
@@ -40,6 +45,12 @@ public class AddTemplateInput : SysTemplate
     [Required(ErrorMessage = "名称不能为空")]
     public override string Name { get; set; }
 
+    /// <summary>
+    /// 模板类型
+    /// </summary>
+    [Dict(nameof(TemplateTypeEnum))]
+    public override TemplateTypeEnum Type { get; set; }
+
     /// <summary>
     /// 编码
     /// </summary>

+ 2 - 1
Admin.NET/Admin.NET.Core/Service/Template/SysTemplateService.cs

@@ -7,7 +7,7 @@
 namespace Admin.NET.Core.Service;
 
 /// <summary>
-/// 系统模板服务 🧩
+/// 系统消息模板服务 🧩
 /// </summary>
 [ApiDescriptionSettings(Order = 305)]
 public class SysTemplateService : IDynamicApiController, ITransient
@@ -40,6 +40,7 @@ public class SysTemplateService : IDynamicApiController, ITransient
             .WhereIF(_userManager.SuperAdmin && input.TenantId > 0, u => u.TenantId == input.TenantId)
             .WhereIF(!string.IsNullOrWhiteSpace(input.Name), u => u.Name.Contains(input.Name))
             .WhereIF(!string.IsNullOrWhiteSpace(input.Code), u => u.Code.Contains(input.Code))
+            .WhereIF(input.Type.HasValue, u => u.Type == input.Type)
             .OrderBy(u => new { u.OrderNo, u.Id })
             .ToPagedListAsync(input.Page, input.PageSize);
     }

+ 4 - 4
Web/api_build/build.bat

@@ -22,15 +22,15 @@ if "%1"=="approvalFlow" (
 )
 
 if exist %apiServicesPath% (
-    echo ================================ 删除目录 %moduleName% ================================
+    echo ================================ ???? %moduleName% ================================
     rd /s /q %apiServicesPath%
 )
 
-echo ================================ 开始生成 %moduleName% ================================
+echo ================================ ???? %moduleName% ================================
 
 java -jar %dir%swagger-codegen-cli.jar generate -i %apiUrl% -l typescript-axios -o %apiServicesPath%
 
-@rem 删除不必要的文件和文件夹
+@rem ????????????
 rd /s /q %apiServicesPath%.swagger-codegen
 del /q %apiServicesPath%.gitignore
 del /q %apiServicesPath%.npmignore
@@ -40,4 +40,4 @@ del /q %apiServicesPath%package.json
 del /q %apiServicesPath%README.md
 del /q %apiServicesPath%tsconfig.json
 
-echo ================================ 生成结束 ================================
+echo ================================ ???? ================================

+ 7 - 0
Web/src/api-services/models/add-template-input.ts

@@ -11,6 +11,7 @@
  * https://github.com/swagger-api/swagger-codegen.git
  * Do not edit the class manually.
  */
+import { TemplateTypeEnum } from './template-type-enum';
 /**
  * 新增模板输入参数
  * @export
@@ -89,6 +90,12 @@ export interface AddTemplateInput {
      * @memberof AddTemplateInput
      */
     name: string;
+    /**
+     * 
+     * @type {TemplateTypeEnum}
+     * @memberof AddTemplateInput
+     */
+    type?: TemplateTypeEnum;
     /**
      * 编码
      * @type {string}

+ 1 - 0
Web/src/api-services/models/index.ts

@@ -379,6 +379,7 @@ export * from './sys-wechat-user';
 export * from './sys-wx-open-upload-avatar-body';
 export * from './table-output';
 export * from './table-unique-config-item';
+export * from './template-type-enum';
 export * from './tenant-id-input';
 export * from './tenant-input';
 export * from './tenant-menu-input';

+ 7 - 0
Web/src/api-services/models/page-template-input.ts

@@ -13,6 +13,7 @@
  */
 import { Filter } from './filter';
 import { Search } from './search';
+import { TemplateTypeEnum } from './template-type-enum';
 /**
  * 
  * @export
@@ -85,6 +86,12 @@ export interface PageTemplateInput {
      * @memberof PageTemplateInput
      */
     groupName?: string | null;
+    /**
+     * 
+     * @type {TemplateTypeEnum}
+     * @memberof PageTemplateInput
+     */
+    type?: TemplateTypeEnum;
     /**
      * 租户Id
      * @type {number}

+ 7 - 0
Web/src/api-services/models/sys-template.ts

@@ -11,6 +11,7 @@
  * https://github.com/swagger-api/swagger-codegen.git
  * Do not edit the class manually.
  */
+import { TemplateTypeEnum } from './template-type-enum';
 /**
  * 系统模板表
  * @export
@@ -77,6 +78,12 @@ export interface SysTemplate {
      * @memberof SysTemplate
      */
     name?: string | null;
+    /**
+     * 
+     * @type {TemplateTypeEnum}
+     * @memberof SysTemplate
+     */
+    type?: TemplateTypeEnum;
     /**
      * 编码
      * @type {string}

+ 27 - 0
Web/src/api-services/models/template-type-enum.ts

@@ -0,0 +1,27 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Admin.NET 通用权限开发平台
+ * 让 .NET 开发更简单、更通用、更流行。整合最新技术,模块插件式开发,前后端分离,开箱即用。<br/><u><b><font color='FF0000'> 👮不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!</font></b></u>
+ *
+ * OpenAPI spec version: 1.0.0
+ * 
+ *
+ * NOTE: This class is auto generated by the swagger code generator program.
+ * https://github.com/swagger-api/swagger-codegen.git
+ * Do not edit the class manually.
+ */
+/**
+ * 消息模板类型枚举<br />&nbsp;通知 Notice = 1<br />&nbsp;短信 SMS = 2<br />&nbsp;邮件 Email = 3<br />&nbsp;微信 Wechat = 4<br />&nbsp;钉钉 DingTalk = 5<br />&nbsp;企业微信 WeChatWork = 7<br />
+ * @export
+ * @enum {string}
+ */
+export enum TemplateTypeEnum {
+    NUMBER_1 = 1,
+    NUMBER_2 = 2,
+    NUMBER_3 = 3,
+    NUMBER_4 = 4,
+    NUMBER_5 = 5,
+    NUMBER_7 = 7
+}
+

+ 7 - 0
Web/src/api-services/models/update-template-input.ts

@@ -11,6 +11,7 @@
  * https://github.com/swagger-api/swagger-codegen.git
  * Do not edit the class manually.
  */
+import { TemplateTypeEnum } from './template-type-enum';
 /**
  * 更新模板输入参数
  * @export
@@ -83,6 +84,12 @@ export interface UpdateTemplateInput {
      * @memberof UpdateTemplateInput
      */
     name: string;
+    /**
+     * 
+     * @type {TemplateTypeEnum}
+     * @memberof UpdateTemplateInput
+     */
+    type?: TemplateTypeEnum;
     /**
      * 编码
      * @type {string}

+ 5 - 0
Web/src/components/editor/index.vue

@@ -117,6 +117,11 @@ watch(
 		deep: true,
 	}
 );
+
+// 暴露 editorRef
+defineExpose({
+	ref: editorRef,
+});
 </script>
 <style lang="less">
 .editor-container {

+ 23 - 3
Web/src/views/system/template/component/editTemplate.vue

@@ -26,6 +26,11 @@
 									<el-input v-model="state.ruleForm.groupName" placeholder="分组" clearable />
 								</el-form-item>
 							</el-col>
+							<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
+								<el-form-item label="类型" prop="type" :rules="[{ required: true, message: '类型不能为空', trigger: 'blur' }]">
+									<g-sys-dict v-model="state.ruleForm.type" code="TemplateTypeEnum" render-as="select"/>
+								</el-form-item>
+							</el-col>
 							<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
 								<el-form-item label="排序">
 									<el-input-number v-model="state.ruleForm.orderNo" placeholder="排序" class="w100" />
@@ -46,12 +51,13 @@
 										<el-radio :value="1">富文本</el-radio>
 										<el-radio :value="2">纯文本</el-radio>
 									</el-radio-group>
+									<el-button class="ml35" @click="() => editorRef?.ref?.insertNode({ text: '@(name)' })">插入参数</el-button>
 								</el-form-item>
 							</el-col>
 							<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
 								<el-form-item label="内容" prop="content" :rules="[{ required: true, message: '内容不能为空', trigger: 'blur' }]">
-									<Editor v-model:get-html="state.ruleForm.content" v-if="state.contentType == 1" />
-									<el-input v-model="state.ruleForm.content" v-else type="textarea" rows="15" show-word-limit clearable></el-input>
+									<Editor v-model:get-html="state.ruleForm.content" ref="editorRef" height="200px" v-if="state.contentType == 1" />
+									<el-input v-model="state.ruleForm.content" v-else type="textarea" rows="15" show-word-limit clearable />
 								</el-form-item>
 							</el-col>
 							<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20" style="user-select: none;">
@@ -95,15 +101,17 @@
 </template>
 
 <script lang="ts" setup name="sysEditConfig">
-import { reactive, ref } from 'vue';
+import {reactive, ref, watch} from 'vue';
 import { getAPI } from '/@/utils/axios-utils';
 import { SysTemplateApi } from '/@/api-services/api';
 import { UpdateTemplateInput } from '/@/api-services/models';
 import Editor from "/@/components/editor/index.vue";
+import GSysDict from "/@/components/sysDict/sysDict.vue";
 
 const props = defineProps({
 	title: String,
 });
+const editorRef = ref();
 const ruleFormRef = ref();
 const emits = defineEmits(['updateData']);
 const state = reactive({
@@ -163,6 +171,18 @@ const submit = () => {
 	});
 };
 
+watch(
+		() => state.ruleForm.content,
+		() => {
+			state.ruleForm.content.match(/@\((.*?)\)/g)?.forEach((pa: string, index) => {
+				const key = pa.substring(2, pa.length - 1);
+				if (!state.renderData.find((e: [string, string]) => e[0] === key)) {
+					state.renderData.push([key, '参数' + (index + 1)]);
+				}
+			});
+		}
+)
+
 // 导出对象
 defineExpose({ openDialog });
 </script>

+ 8 - 2
Web/src/views/system/template/index.vue

@@ -8,6 +8,9 @@
 				<template #command>
 					<el-button type="primary" icon="ele-Plus" @click="openAddTemplate" v-auth="'sysConfig:add'"> 新增 </el-button>
 				</template>
+				<template #type="scope">
+					<g-sys-dict v-model="scope.row.type" code="TemplateTypeEnum" />
+				</template>
 				<template #remark="scope">
 					<ModifyRecord :data="scope.row" />
 				</template>
@@ -29,6 +32,7 @@ import { SysTemplateApi } from "/@/api-services";
 import { EmptyObjectType, RefType } from '/@/types/global';
 import ModifyRecord from '/@/components/table/modifyRecord.vue';
 import EditTemplate from './component/editTemplate.vue';
+import GSysDict from "/@/components/sysDict/sysDict.vue";
 
 // 引入组件
 const TableSearch = defineAsyncComponent(() => import('/@/components/table/search.vue'));
@@ -38,7 +42,7 @@ const tableRef = ref<RefType>();
 
 const state = reactive({
 	editTemplateTitle: '',
-	selectlist: [] as EmptyObjectType[],
+	selectList: [] as EmptyObjectType[],
 	groupList: [] as Array<String>,
 });
 
@@ -48,6 +52,7 @@ const tb = reactive<TableDemoState>({
 		columns: [
 			{ prop: 'name', minWidth: 150, label: '模板名称', headerAlign: 'center', sortable: 'custom', isCheck: true, hideCheck: true },
 			{ prop: 'code', minWidth: 150, label: '模板编码', headerAlign: 'center', toolTip: true, sortable: 'custom', isCheck: true },
+			{ prop: 'type', width: 120, label: '模板类型', align: 'center', sortable: 'custom', isCheck: true },
 			{ prop: 'groupName', width: 120, label: '分组编码', align: 'center', sortable: 'custom', isCheck: true },
 			{ prop: 'orderNo', width: 80, label: '排序', align: 'center', sortable: 'custom', isCheck: true },
 			{ prop: 'remark', width: 100, label: '修改记录', align: 'center', headerAlign: 'center', showOverflowTooltip: true, isCheck: true },
@@ -67,6 +72,7 @@ const tb = reactive<TableDemoState>({
 		search: [
 			{ label: '名称', prop: 'name', placeholder: '搜索模板名称', required: false, type: 'input' },
 			{ label: '编码', prop: 'code', placeholder: '搜索模板编码', required: false, type: 'input' },
+			{ label: '类型', prop: 'type', placeholder: '搜索模板类型', required: false, type: 'select', dictCode: 'TemplateTypeEnum' },
 		],
 		param: {},
 		defaultSort: {
@@ -134,7 +140,7 @@ const updateData = () => {
 // 打开新增页面
 const openAddTemplate = () => {
 	state.editTemplateTitle = '添加模板';
-	editTemplateRef.value?.openDialog({ sysFlag: 2, orderNo: 100 });
+	editTemplateRef.value?.openDialog({ type: 1, orderNo: 100 });
 };
 
 // 打开编辑页面