Parcourir la source

fix: 短信渠道、短信模板、短信日志调整

Tong il y a 2 ans
Parent
commit
ea03f938c5

+ 9 - 0
src/api/sys/smsTempApi.ts

@@ -7,6 +7,7 @@ enum Api {
   smsTempAdd = '/sys/sms/temp/add',
   smsTempEdit = '/sys/sms/temp/edit',
   smsTempRemove = '/sys/sms/temp/removeByIds',
+  smsSend = '/sys/sms/temp/send/msg',
 }
 
 /**
@@ -112,3 +113,11 @@ export const smsTempEdit = (params?: object) => {
 export const smsTempRemove = (params: Array<string | number>) => {
   return defHttp.post({ url: Api.smsTempRemove, params: params });
 };
+
+/**
+ * @description: 发送短信,权限 - sms:temp:send
+ * @method: POST
+ */
+export const smsSend = (params?: object) => {
+  return defHttp.post({ url: Api.smsSend, params: params });
+};

+ 16 - 32
src/views/sys/sysSms/channel/data.ts

@@ -16,25 +16,17 @@ export const columns: BasicColumn[] = [
     dataIndex: 'type',
   },
   {
-    title: '短信 API账号',
+    title: '短信API账号',
     dataIndex: 'apiKey',
   },
   {
-    title: '短信 API 的秘钥',
-    dataIndex: 'apiSecret',
-  },
-  {
-    title: '短信发送回调 URL',
+    title: '发送回调URL',
     dataIndex: 'callbackUrl',
   },
   {
-    title: '是否启用',
+    title: '启用',
     dataIndex: 'disable',
   },
-  {
-    title: '备注',
-    dataIndex: 'remark',
-  },
 ];
 
 // 表单列定义
@@ -102,48 +94,48 @@ export const dataFormSchema: FormSchema[] = [
     },
   },
   {
-    label: '短信 API账号',
+    label: '短信API账号',
     field: 'apiKey',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入短信 API 的账号',
+      placeholder: '请输入短信API的账号',
     },
   },
   {
-    label: '短信 API秘钥',
+    label: '短信API秘钥',
     field: 'apiSecret',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入短信 API 的秘钥',
+      placeholder: '请输入短信API的秘钥',
     },
   },
   {
-    label: '短信发送回调 URL',
+    label: '发送回调URL',
     field: 'callbackUrl',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入短信发送回调 URL',
+      placeholder: '请输入短信发送回调URL',
     },
   },
   {
     label: '是否启用',
     field: 'disable',
-    component: 'ApiSelect',
+    component: 'ApiRadioGroup',
     componentProps: {
       api: listDictModel,
       params: {
         dictCode: 'sys_disable_type',
       },
     },
+    defaultValue: '0',
   },
   {
     label: '备注',
     field: 'remark',
-    required: true,
-    component: 'Input',
+    component: 'InputTextArea',
     componentProps: {
       placeholder: '请输入备注',
     },
@@ -168,31 +160,23 @@ export const viewSchema: DescItem[] = [
     field: 'type',
   },
   {
-    label: '短信 API账号',
+    label: '短信API账号',
     field: 'apiKey',
   },
   {
-    label: '短信 API秘钥',
+    label: '短信API秘钥',
     field: 'apiSecret',
   },
   {
-    label: '短信发送回调 URL',
+    label: '发送回调URL',
     field: 'callbackUrl',
   },
   {
-    label: '是否启用',
+    label: '启用',
     field: 'disable',
   },
   {
     label: '备注',
     field: 'remark',
   },
-  {
-    label: '创建时间',
-    field: 'createTime',
-  },
-  {
-    label: '更新时间',
-    field: 'updateTime',
-  },
 ];

+ 1 - 0
src/views/sys/sysSms/channel/formDrawer.vue

@@ -44,6 +44,7 @@
     if (unref(isUpdate)) {
       const resData = await smsChannelDetail(data.record.id);
       rowId.value = resData.id;
+      resData.disable = String(resData.disable);
       await setFieldsValue({
         ...resData,
       });

+ 1 - 1
src/views/sys/sysSms/channel/index.vue

@@ -107,7 +107,7 @@
   ]) as any;
 
   const [registerTable, { reload, getSelectRowKeys }] = useTable({
-    title: '门户列表 ',
+    title: ' ',
     api: smsChannelQueryPage,
     rowKey: 'id',
     columns,

+ 1 - 1
src/views/sys/sysSms/channel/viewDrawer.vue

@@ -43,7 +43,7 @@
     column: 2,
     size: 'middle',
     labelStyle: {
-      width: '120px',
+      width: '140px',
     },
   });
 </script>

+ 30 - 328
src/views/sys/sysSms/log/data.ts

@@ -3,46 +3,10 @@ import { DescItem } from '/@/components/Description';
 import { BasicColumn, FormSchema } from '/@/components/Table';
 
 export const columns: BasicColumn[] = [
-  {
-    title: '渠道id',
-    dataIndex: 'channelId',
-  },
-  {
-    title: '模板id',
-    dataIndex: 'templateId',
-  },
-  {
-    title: '模板编码',
-    dataIndex: 'templateCode',
-  },
-  {
-    title: '模板类型',
-    dataIndex: 'templateType',
-  },
-  {
-    title: '模板参数',
-    dataIndex: 'templateParams',
-  },
-  {
-    title: '模板内容',
-    dataIndex: 'templateContent',
-  },
-  {
-    title: '短信API的模板编号',
-    dataIndex: 'apiTemplateId',
-  },
   {
     title: '手机号',
     dataIndex: 'mobile',
   },
-  {
-    title: '接收用户id',
-    dataIndex: 'userid',
-  },
-  {
-    title: '用户类型',
-    dataIndex: 'userType',
-  },
   {
     title: '发送状态',
     dataIndex: 'sendStatus',
@@ -51,30 +15,6 @@ export const columns: BasicColumn[] = [
     title: '发送时间',
     dataIndex: 'sendTime',
   },
-  {
-    title: '发送结果编码',
-    dataIndex: 'sendCode',
-  },
-  {
-    title: '发送消息',
-    dataIndex: 'sendMsg',
-  },
-  {
-    title: 'API 结果编号',
-    dataIndex: 'apiSendCode',
-  },
-  {
-    title: 'API 错误信息',
-    dataIndex: 'apiSendMsg',
-  },
-  {
-    title: 'API 请求编号',
-    dataIndex: 'apiRequestId',
-  },
-  {
-    title: 'API 返回序号',
-    dataIndex: 'apiSerialNo',
-  },
   {
     title: '接收状态',
     dataIndex: 'receiveStatus',
@@ -84,33 +24,25 @@ export const columns: BasicColumn[] = [
     dataIndex: 'receiveTime',
   },
   {
-    title: 'API 接收结果编码',
-    dataIndex: 'apiReceiveCode',
+    title: '渠道',
+    dataIndex: 'channelName',
   },
   {
-    title: 'API 接收结果提示',
-    dataIndex: 'apiReceiveMsg',
+    title: '模板',
+    dataIndex: 'templateName',
   },
-];
-
-// 表单列定义
-export const searchFormSchema: FormSchema[] = [
   {
-    label: '渠道id',
-    field: 'channelId',
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入渠道id',
-    },
+    title: '模板编码',
+    dataIndex: 'templateCode',
   },
   {
-    label: '模板id',
-    field: 'templateId',
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板id',
-    },
+    title: '模板类型',
+    dataIndex: 'templateType',
   },
+];
+
+// 表单列定义
+export const searchFormSchema: FormSchema[] = [
   {
     label: '模板编码',
     field: 'templateCode',
@@ -139,13 +71,12 @@ export const searchFormSchema: FormSchema[] = [
     },
   },
   {
-    label: '发送时间',
+    label: '发送日期',
     field: 'sendTime',
-    component: 'DatePicker',
+    component: 'RangePicker',
     componentProps: {
-      placeholder: '请选择时间',
-      format: 'YYYY-MM-DD HH:mm:ss',
-      showTime: { format: 'YYYY-MM-DD HH:mm:ss' },
+      format: 'YYYY-MM-DD',
+      showTime: { format: 'YYYY-MM-DD' },
     },
   },
   {
@@ -160,225 +91,35 @@ export const searchFormSchema: FormSchema[] = [
     },
   },
 ];
-// 表单新增编辑
-export const dataFormSchema: FormSchema[] = [
-  {
-    label: '渠道id',
-    field: 'channelId',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入渠道id',
-    },
-  },
-  {
-    label: '模板id',
-    field: 'templateId',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板id',
-    },
-  },
-  {
-    label: '模板编码',
-    field: 'templateCode',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板编码',
-    },
-  },
-  {
-    label: '模板类型',
-    field: 'templateType',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板类型',
-    },
-  },
-  {
-    label: '模板参数',
-    field: 'templateParams',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板参数',
-    },
-  },
-  {
-    label: '模板内容',
-    field: 'templateContent',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板内容',
-    },
-  },
-  {
-    label: '短信API的模板编号',
-    field: 'apiTemplateId',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入短信API的模板编号',
-    },
-  },
+// 表单详情查看
+export const viewSchema: DescItem[] = [
   {
     label: '手机号',
     field: 'mobile',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入手机号',
-    },
-  },
-  {
-    label: '接收用户id',
-    field: 'userid',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入接收用户id',
-    },
-  },
-  {
-    label: '用户类型',
-    field: 'userType',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入用户类型',
-    },
   },
   {
     label: '发送状态',
     field: 'sendStatus',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_sms_send',
-      },
-    },
   },
   {
     label: '发送时间',
     field: 'sendTime',
-    component: 'DatePicker',
-    componentProps: {
-      placeholder: '请选择时间',
-      format: 'YYYY-MM-DD HH:mm:ss',
-      showTime: { format: 'YYYY-MM-DD HH:mm:ss' },
-    },
-  },
-  {
-    label: '发送结果编码',
-    field: 'sendCode',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入发送结果编码',
-    },
-  },
-  {
-    label: '发送消息',
-    field: 'sendMsg',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入发送消息',
-    },
-  },
-  {
-    label: 'API 结果编号',
-    field: 'apiSendCode',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 结果编号',
-    },
-  },
-  {
-    label: 'API 错误信息',
-    field: 'apiSendMsg',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 错误信息',
-    },
-  },
-  {
-    label: 'API 请求编号',
-    field: 'apiRequestId',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 请求编号',
-    },
-  },
-  {
-    label: 'API 返回序号',
-    field: 'apiSerialNo',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 返回序号',
-    },
   },
   {
     label: '接收状态',
     field: 'receiveStatus',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_sms_reveice',
-      },
-    },
   },
   {
     label: '接收时间',
     field: 'receiveTime',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入接收时间',
-    },
   },
   {
-    label: 'API 接收结果编码',
-    field: 'apiReceiveCode',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 接收结果编码',
-    },
+    label: '渠道名称',
+    field: 'channelName',
   },
   {
-    label: 'API 接收结果提示',
-    field: 'apiReceiveMsg',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入API 接收结果提示',
-    },
-  },
-];
-// 表单详情查看
-export const viewSchema: DescItem[] = [
-  {
-    label: 'id',
-    field: 'id',
-  },
-  {
-    label: '渠道id',
-    field: 'channelId',
-  },
-  {
-    label: '模板id',
-    field: 'templateId',
+    label: '模板名称',
+    field: 'templateName',
   },
   {
     label: '模板编码',
@@ -388,38 +129,14 @@ export const viewSchema: DescItem[] = [
     label: '模板类型',
     field: 'templateType',
   },
-  {
-    label: '模板参数',
-    field: 'templateParams',
-  },
   {
     label: '模板内容',
     field: 'templateContent',
   },
   {
-    label: '短信API模板编号',
+    label: '短信API模板编号',
     field: 'apiTemplateId',
   },
-  {
-    label: '手机号',
-    field: 'mobile',
-  },
-  {
-    label: '接收用户id',
-    field: 'userid',
-  },
-  {
-    label: '用户类型',
-    field: 'userType',
-  },
-  {
-    label: '发送状态',
-    field: 'sendStatus',
-  },
-  {
-    label: '发送时间',
-    field: 'sendTime',
-  },
   {
     label: '发送结果编码',
     field: 'sendCode',
@@ -429,43 +146,28 @@ export const viewSchema: DescItem[] = [
     field: 'sendMsg',
   },
   {
-    label: 'API 结果编号',
+    label: 'API结果编号',
     field: 'apiSendCode',
   },
   {
-    label: 'API 错误信息',
+    label: 'API错误信息',
     field: 'apiSendMsg',
   },
   {
-    label: 'API 请求编号',
+    label: 'API请求编号',
     field: 'apiRequestId',
   },
   {
-    label: 'API 返回序号',
+    label: 'API返回序号',
     field: 'apiSerialNo',
   },
+
   {
-    label: '接收状态',
-    field: 'receiveStatus',
-  },
-  {
-    label: '接收时间',
-    field: 'receiveTime',
-  },
-  {
-    label: 'API 接收结果编码',
+    label: 'API接收结果编码',
     field: 'apiReceiveCode',
   },
   {
-    label: 'API 接收结果提示',
+    label: 'API接收结果提示',
     field: 'apiReceiveMsg',
   },
-  {
-    label: 'create_time',
-    field: 'createTime',
-  },
-  {
-    label: 'update_time',
-    field: 'updateTime',
-  },
 ];

+ 0 - 71
src/views/sys/sysSms/log/formDrawer.vue

@@ -1,71 +0,0 @@
-<template>
-  <BasicDrawer
-    v-bind="$attrs"
-    destroyOnClose
-    @register="registerDrawer"
-    :title="getTitle"
-    :width="width"
-    @ok="handleSubmit"
-    :showFooter="true"
-  >
-    <BasicForm @register="registerForm" layout="vertical" />
-  </BasicDrawer>
-</template>
-<script lang="ts" setup>
-  import { ref, computed, unref } from 'vue';
-  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
-  import { BasicForm, useForm } from '/@/components/Form';
-  import { useMessage } from '/@/hooks/web/useMessage';
-  import { dataFormSchema } from './data';
-
-  import { smsLogAdd, smsLogEdit, smsLogDetail } from '/@/api/sys/smsLogApi';
-
-  const emit = defineEmits(['success', 'register']);
-
-  const getTitle = computed(() => (!unref(isUpdate) ? '新增短信日志' : '编辑短信日志'));
-  const width = '45%';
-  const isUpdate = ref(false);
-  const rowId = ref();
-
-  const { createMessage } = useMessage();
-  const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
-    labelWidth: 100,
-    schemas: dataFormSchema,
-    showActionButtonGroup: false,
-    actionColOptions: {
-      span: 23,
-    },
-  });
-  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async data => {
-    await resetFields();
-    setDrawerProps({ confirmLoading: false });
-    isUpdate.value = !!data?.isUpdate;
-
-    if (unref(isUpdate)) {
-      const resData = await smsLogDetail(data.record.id);
-      rowId.value = resData.id;
-      await setFieldsValue({
-        ...resData,
-      });
-    }
-  });
-
-  // 提交按钮事件
-  async function handleSubmit() {
-    try {
-      const values = await validate();
-      setDrawerProps({ confirmLoading: true });
-      !unref(isUpdate)
-        ? await smsLogAdd({ ...values })
-        : await smsLogEdit({ ...values, id: rowId.value });
-      !unref(isUpdate) ? createMessage.success('新增成功!') : createMessage.success('编辑成功!');
-      closeDrawer();
-      emit('success', {
-        isUpdate: unref(isUpdate),
-        values: { ...values, id: rowId.value },
-      });
-    } finally {
-      setDrawerProps({ confirmLoading: false });
-    }
-  }
-</script>

+ 8 - 35
src/views/sys/sysSms/log/index.vue

@@ -12,6 +12,11 @@
             {{ formatDictValue(receiveStatusOptions, record.receiveStatus) }}
           </Tag>
         </template>
+        <template v-if="column.key === 'templateType'">
+          <Tag :color="formatDictColor(templateTypeOptions, record.templateType)">
+            {{ formatDictValue(templateTypeOptions, record.templateType) }}
+          </Tag>
+        </template>
         <template v-if="column.key === 'action'">
           <TableAction
             :actions="[
@@ -22,13 +27,6 @@
                 label: '查看',
                 onClick: handleView.bind(null, record),
               },
-              {
-                auth: 'sms:log:edit',
-                icon: 'icon-edit|iconfont',
-                tooltip: '编辑',
-                label: '编辑',
-                onClick: handleEdit.bind(null, record),
-              },
               {
                 auth: 'sms:log:remove',
                 icon: 'icon-delete|iconfont',
@@ -46,14 +44,6 @@
         </template>
       </template>
       <template #toolbar>
-        <Button
-          v-auth="['sms:log:add']"
-          type="primary"
-          @click="handleCreate"
-          preIcon="icon-plus|iconfont"
-        >
-          新增
-        </Button>
         <Button
           v-auth="['sms:log:remove']"
           type="primary"
@@ -65,7 +55,6 @@
         </Button>
       </template>
     </BasicTable>
-    <FormDrawer @register="registerDrawer" @success="handleSuccess" />
     <ViewDrawer @register="registerDrawerView" @success="handleSuccess" />
   </div>
 </template>
@@ -78,7 +67,6 @@
 
   // import { useModal } from '/@/components/Modal';
   import { useMessage } from '/@/hooks/web/useMessage';
-  import FormDrawer from './formDrawer.vue';
   import ViewDrawer from './viewDrawer.vue';
   import { columns, searchFormSchema } from './data';
 
@@ -89,14 +77,14 @@
 
   const sendStatusOptions = ref();
   const receiveStatusOptions = ref();
+  const templateTypeOptions = ref();
   onBeforeMount(async () => {
     sendStatusOptions.value = await listDictModel({ dictCode: 'sys_sms_send' });
     receiveStatusOptions.value = await listDictModel({ dictCode: 'sys_sms_reveice' });
+    templateTypeOptions.value = await listDictModel({ dictCode: 'sys_temp_type' });
   });
 
   const { createConfirm, createMessage } = useMessage();
-  // const [registerModal, { openModal }] = useModal();
-  const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerDrawerView, { openDrawer: openDrawerView }] = useDrawer();
 
   const tableSort = ref([
@@ -107,7 +95,7 @@
   ]) as any;
 
   const [registerTable, { reload, getSelectRowKeys }] = useTable({
-    title: '门户列表 ',
+    title: ' ',
     api: smsLogQueryPage,
     rowKey: 'id',
     columns,
@@ -143,21 +131,6 @@
     });
   }
 
-  // 新增按钮事件
-  function handleCreate() {
-    openDrawer(true, {
-      isUpdate: false,
-    });
-  }
-
-  // 编辑按钮事件
-  function handleEdit(record: Recordable) {
-    openDrawer(true, {
-      record,
-      isUpdate: true,
-    });
-  }
-
   // 删除按钮事件
   async function handleDelete(record: Recordable) {
     if (record) {

+ 4 - 1
src/views/sys/sysSms/log/viewDrawer.vue

@@ -25,9 +25,11 @@
 
   const sendStatusOptions = ref();
   const receiveStatusOptions = ref();
+  const templateTypeOptions = ref();
   onBeforeMount(async () => {
     sendStatusOptions.value = await listDictModel({ dictCode: 'sys_sms_send' });
     receiveStatusOptions.value = await listDictModel({ dictCode: 'sys_sms_reveice' });
+    templateTypeOptions.value = await listDictModel({ dictCode: 'sys_temp_type' });
   });
   const [registerDrawer] = useDrawerInner(async data => {
     console.log('::::::::::', data.record);
@@ -36,6 +38,7 @@
       ...resData,
       sendStatus: formatDictValue(sendStatusOptions.value, resData.sendStatus),
       receiveStatus: formatDictValue(receiveStatusOptions.value, resData.receiveStatus),
+      templateType: formatDictValue(templateTypeOptions.value, resData.templateType),
     };
   });
   const [registerDesc] = useDescription({
@@ -43,7 +46,7 @@
     column: 2,
     size: 'middle',
     labelStyle: {
-      width: '120px',
+      width: '155px',
     },
   });
 </script>

+ 99 - 113
src/views/sys/sysSms/temp/data.ts

@@ -1,24 +1,9 @@
 import { listDictModel } from '/@/api/common';
+import { smsChannelQueryPage } from '/@/api/sys/smsChannelApi';
 import { DescItem } from '/@/components/Description';
 import { BasicColumn, FormSchema } from '/@/components/Table';
 
 export const columns: BasicColumn[] = [
-  {
-    title: '短信渠道id',
-    dataIndex: 'channelId',
-  },
-  {
-    title: '创建类型',
-    dataIndex: 'createType',
-  },
-  {
-    title: '模板类型',
-    dataIndex: 'tempType',
-  },
-  {
-    title: '模板内容',
-    dataIndex: 'content',
-  },
   {
     title: '模板编码',
     dataIndex: 'code',
@@ -28,32 +13,30 @@ export const columns: BasicColumn[] = [
     dataIndex: 'name',
   },
   {
-    title: '短信 API 模板编号',
-    dataIndex: 'apiTempCode',
+    title: '创建类型',
+    dataIndex: 'createType',
   },
   {
-    title: '状态',
-    dataIndex: 'disable',
+    title: '短信渠道',
+    dataIndex: 'channelName',
   },
   {
-    title: '备注',
-    dataIndex: 'remark',
+    title: '模板类型',
+    dataIndex: 'tempType',
+  },
+
+  {
+    title: '短信API模板编号',
+    dataIndex: 'apiTempCode',
   },
+  // {
+  //   title: '状态',
+  //   dataIndex: 'disable',
+  // },
 ];
 
 // 表单列定义
 export const searchFormSchema: FormSchema[] = [
-  {
-    label: '创建类型',
-    field: 'createType',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_create_type',
-      },
-    },
-  },
   {
     label: '模板类型',
     field: 'tempType',
@@ -65,50 +48,49 @@ export const searchFormSchema: FormSchema[] = [
       },
     },
   },
+];
+// 表单新增编辑
+export const dataFormSchema: FormSchema[] = [
   {
-    label: '模板内容',
-    field: 'content',
+    label: '模板编码',
+    field: 'code',
+    required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入模板内容',
-    },
-  },
-  {
-    label: '状态',
-    field: 'disable',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_disable_type',
-      },
+      placeholder: '请输入模板编码',
     },
   },
-];
-// 表单新增编辑
-export const dataFormSchema: FormSchema[] = [
   {
-    label: '短信渠道id',
-    field: 'channelId',
+    label: '模板名称',
+    field: 'name',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入短信渠道id',
+      placeholder: '请输入模板名称',
     },
   },
   {
-    label: '创建类型',
-    field: 'createType',
+    label: '短信渠道',
+    field: 'channelId',
+    required: true,
     component: 'ApiSelect',
     componentProps: {
-      api: listDictModel,
+      api: smsChannelQueryPage,
       params: {
-        dictCode: 'sys_create_type',
+        pageNum: 1,
+        pageSize: 999,
+        disable: '0',
       },
+      mode: 'single',
+      labelField: 'name',
+      valueField: 'id',
+      resultField: 'data',
+      placeholder: '请选择短信渠道',
     },
   },
   {
     label: '模板类型',
+    required: true,
     field: 'tempType',
     component: 'ApiSelect',
     componentProps: {
@@ -118,58 +100,42 @@ export const dataFormSchema: FormSchema[] = [
       },
     },
   },
+
   {
     label: '模板内容',
     field: 'content',
     required: true,
-    component: 'Input',
+    component: 'InputTextArea',
     componentProps: {
       placeholder: '请输入模板内容',
     },
   },
   {
-    label: '模板编码',
-    field: 'code',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板编码',
-    },
-  },
-  {
-    label: '模板名称',
-    field: 'name',
-    required: true,
-    component: 'Input',
-    componentProps: {
-      placeholder: '请输入模板名称',
-    },
-  },
-  {
-    label: '短信 API 模板编号',
+    label: '短信API模板编号',
     field: 'apiTempCode',
     required: true,
     component: 'Input',
     componentProps: {
-      placeholder: '请输入短信 API 模板编号',
-    },
-  },
-  {
-    label: '状态',
-    field: 'disable',
-    component: 'ApiSelect',
-    componentProps: {
-      api: listDictModel,
-      params: {
-        dictCode: 'sys_disable_type',
-      },
+      placeholder: '请输入短信API模板编号',
     },
   },
+  // {
+  //   label: '状态',
+  //   field: 'disable',
+  //   required: true,
+  //   component: 'ApiRadioGroup',
+  //   componentProps: {
+  //     api: listDictModel,
+  //     params: {
+  //       dictCode: 'sys_disable_type',
+  //     },
+  //   },
+  //   defaultValue: '0',
+  // },
   {
     label: '备注',
     field: 'remark',
-    required: true,
-    component: 'Input',
+    component: 'InputTextArea',
     componentProps: {
       placeholder: '请输入备注',
     },
@@ -178,12 +144,16 @@ export const dataFormSchema: FormSchema[] = [
 // 表单详情查看
 export const viewSchema: DescItem[] = [
   {
-    label: '主键',
-    field: 'id',
+    label: '模板编码',
+    field: 'code',
   },
   {
-    label: '短信渠道id',
-    field: 'channelId',
+    label: '模板名称',
+    field: 'name',
+  },
+  {
+    label: '短信渠道',
+    field: 'channelName',
   },
   {
     label: '创建类型',
@@ -193,36 +163,52 @@ export const viewSchema: DescItem[] = [
     label: '模板类型',
     field: 'tempType',
   },
+
   {
     label: '模板内容',
     field: 'content',
   },
   {
-    label: '模板编码',
-    field: 'code',
-  },
-  {
-    label: '模板名称',
-    field: 'name',
-  },
-  {
-    label: '短信 API 模板编号',
+    label: '短信API模板编号',
     field: 'apiTempCode',
   },
-  {
-    label: '状态',
-    field: 'disable',
-  },
+  // {
+  //   label: '状态',
+  //   field: 'disable',
+  // },
   {
     label: '备注',
     field: 'remark',
   },
+];
+
+export const dataSendFormSchema: FormSchema[] = [
   {
-    label: '创建时间',
-    field: 'createTime',
+    label: '手机号码',
+
+    field: 'mobile',
+    required: true,
+    component: 'InputTextArea',
+    componentProps: {
+      placeholder: '请输入手机号码,多号码以 , 隔开',
+    },
   },
-  {
-    label: '更新时间',
-    field: 'updateTime',
+  // {
+  //   label: '模板编码',
+  //   field: 'templateCode',
+  //   required: true,
+  //   component: 'Input',
+  //   componentProps: {
+  //     placeholder: '请输入模板编码',
+  //   },
+  // },
+  {
+    label: '模板参数',
+    helpMessage: '模板对应变量参数',
+    field: 'codeDividers',
+    component: 'Divider',
+    helpComponentProps: {
+      fontSize: '16px',
+    },
   },
 ];

+ 1 - 0
src/views/sys/sysSms/temp/formDrawer.vue

@@ -44,6 +44,7 @@
     if (unref(isUpdate)) {
       const resData = await smsTempDetail(data.record.id);
       rowId.value = resData.id;
+      resData.disable = String(resData.disable);
       await setFieldsValue({
         ...resData,
       });

+ 19 - 5
src/views/sys/sysSms/temp/index.vue

@@ -27,6 +27,13 @@
                 label: '查看',
                 onClick: handleView.bind(null, record),
               },
+              {
+                auth: 'sms:temp:edit',
+                icon: 'icon-send|iconfont',
+                tooltip: '发送短信',
+                label: '发送短信',
+                onClick: handleSend.bind(null, record),
+              },
               {
                 auth: 'sms:temp:edit',
                 icon: 'icon-edit|iconfont',
@@ -72,6 +79,7 @@
     </BasicTable>
     <FormDrawer @register="registerDrawer" @success="handleSuccess" />
     <ViewDrawer @register="registerDrawerView" @success="handleSuccess" />
+    <sendSmsFormDrawer @register="registerSendSmsFormDrawer" @success="handleSuccess" />
   </div>
 </template>
 <script lang="ts" setup>
@@ -86,7 +94,7 @@
   import FormDrawer from './formDrawer.vue';
   import ViewDrawer from './viewDrawer.vue';
   import { columns, searchFormSchema } from './data';
-
+  import sendSmsFormDrawer from './sendSmsFormDrawer.vue';
   import { smsTempQueryPage, smsTempRemove } from '/@/api/sys/smsTempApi';
   import { listDictModel } from '/@/api/common';
   import { formatDictColor, formatDictValue } from '/@/utils';
@@ -105,7 +113,7 @@
   // const [registerModal, { openModal }] = useModal();
   const [registerDrawer, { openDrawer }] = useDrawer();
   const [registerDrawerView, { openDrawer: openDrawerView }] = useDrawer();
-
+  const [registerSendSmsFormDrawer, { openDrawer: openSendSmsFormDrawer }] = useDrawer();
   const tableSort = ref([
     {
       field: 'create_time',
@@ -114,7 +122,7 @@
   ]) as any;
 
   const [registerTable, { reload, getSelectRowKeys }] = useTable({
-    title: '门户列表 ',
+    title: ' ',
     api: smsTempQueryPage,
     rowKey: 'id',
     columns,
@@ -135,7 +143,7 @@
     useSearchForm: true,
     bordered: true,
     actionColumn: {
-      width: 200,
+      width: 320,
       title: '操作',
       dataIndex: 'action',
     },
@@ -144,12 +152,18 @@
   });
   // 详情按钮事件
   function handleView(record: Recordable) {
-    console.log(record);
     openDrawerView(true, {
       record,
     });
   }
 
+  // 发送短信事件
+  function handleSend(record: Recordable) {
+    openSendSmsFormDrawer(true, {
+      record,
+    });
+  }
+
   // 新增按钮事件
   function handleCreate() {
     openDrawer(true, {

+ 85 - 0
src/views/sys/sysSms/temp/sendSmsFormDrawer.vue

@@ -0,0 +1,85 @@
+<template>
+  <BasicDrawer
+    v-bind="$attrs"
+    destroyOnClose
+    @register="registerDrawer"
+    :title="getTitle"
+    :width="width"
+    @ok="handleSubmit"
+    :showFooter="true"
+  >
+    <BasicForm @register="registerForm" layout="vertical" />
+  </BasicDrawer>
+</template>
+<script lang="ts" setup>
+  import { ref, computed } from 'vue';
+  import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
+  import { BasicForm, useForm } from '/@/components/Form';
+  import { useMessage } from '/@/hooks/web/useMessage';
+  import { dataSendFormSchema } from './data';
+
+  import { smsTempDetail, smsSend } from '/@/api/sys/smsTempApi';
+  const emit = defineEmits(['success', 'register']);
+
+  const getTitle = computed(() => '发送短信');
+  const width = '45%';
+  const rowId = ref();
+  const templateCode = ref();
+  const templateItme = ref([]);
+  const { createMessage } = useMessage();
+  const [registerForm, { resetFields, validate, appendSchemaByField }] = useForm({
+    labelWidth: 100,
+    schemas: dataSendFormSchema,
+    showActionButtonGroup: false,
+    actionColOptions: {
+      span: 23,
+    },
+  });
+  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async data => {
+    await resetFields();
+    setDrawerProps({ confirmLoading: false });
+    const result = await smsTempDetail(data.record.id);
+    rowId.value = result.id;
+    templateCode.value = result.code;
+    if (result && result.templateParams && result.templateParams.length > 0) {
+      templateItme.value = result.templateParams;
+      result.templateParams.forEach(item => {
+        appendSchemaByField(
+          {
+            label: item,
+            field: item,
+            required: true,
+            component: 'Input',
+          },
+          null,
+        );
+      });
+    }
+  });
+  // 提交按钮事件
+  async function handleSubmit() {
+    try {
+      const values = await validate();
+      setDrawerProps({ confirmLoading: true });
+      values.templateCode = templateCode.value;
+      values.templateParams = {};
+      await templateItme.value.forEach(item => {
+        values.templateParams[item] = values[item];
+      });
+      await smsSend(values);
+      createMessage.success('短信发送成功!');
+      closeDrawer();
+      emit('success', {
+        values: { ...values, id: rowId.value },
+      });
+    } finally {
+      setDrawerProps({ confirmLoading: false });
+    }
+  }
+</script>
+
+<style lang="less" scoped>
+  ::v-deep(.ant-divider-plain.ant-divider-with-text) {
+    font-size: 17px !important;
+  }
+</style>

+ 1 - 1
src/views/sys/sysSms/temp/viewDrawer.vue

@@ -46,7 +46,7 @@
     column: 2,
     size: 'middle',
     labelStyle: {
-      width: '120px',
+      width: '130px',
     },
   });
 </script>