xieyonghong 3 سال پیش
والد
کامیت
b602ea6e54

+ 1 - 1
src/pages/device/Product/Detail/Access/index.tsx

@@ -59,7 +59,7 @@ const Access = () => {
 
   const queryAccess = (id: string) => {
     service.queryList({ pageSize: 1000 }).then((resp) => {
-      const dt = resp.result.data.find((i: any) => i.id === id);
+      const dt = resp.result?.data.find((i: any) => i.id === id);
       setAccess(dt);
       if (dt) {
         queryNetworkList(dt?.provider);

+ 1 - 0
src/pages/device/components/Metadata/Base/Edit/index.tsx

@@ -409,6 +409,7 @@ const Edit = observer((props: Props) => {
               id: 'pages.device.productDetail.metadata.source',
               defaultMessage: '来源',
             }),
+            'x-disabled': MetadataModel.action === 'edit',
             required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Select',

+ 3 - 1
src/pages/device/components/Metadata/Import/index.tsx

@@ -35,7 +35,9 @@ const Import = (props: Props) => {
 
   const loadData = () => async (field: Field) => {
     field.loading = true;
-    const product = (await service.queryNoPaging({})) as any;
+    const product = (await service.queryNoPagingPost({
+      terms: [{ column: 'id$not', value: param.id }],
+    })) as any;
     field.dataSource = product.result.map((item: any) => ({
       label: item.name,
       value: item.metadata,

+ 74 - 34
src/pages/link/Type/Detail/index.tsx

@@ -18,7 +18,7 @@ import type { ISchema } from '@formily/json-schema';
 import { useEffect, useMemo, useRef } from 'react';
 import type { Field } from '@formily/core';
 import { createForm, onFieldValueChange } from '@formily/core';
-import { Button, Card, message } from 'antd';
+import { Card, message } from 'antd';
 import styles from './index.less';
 import { useAsyncDataSource } from '@/utils/util';
 import { service } from '../index';
@@ -97,7 +97,7 @@ const Save = observer(() => {
   const form = useMemo(
     () =>
       createForm({
-        readPretty: false,
+        // readPretty: true,
         // initialValues: {},
         effects() {
           onFieldValueChange('type', (field, f) => {
@@ -168,7 +168,7 @@ const Save = observer(() => {
   useEffect(() => {
     const subscription = Store.subscribe('current-network-data', (data) => {
       if (!data) return;
-      form.readPretty = true;
+      // form.readPretty = true;
       const _data = _.cloneDeep(data);
       // 处理一下集群模式数据
       if (!_data.shareCluster) {
@@ -255,7 +255,7 @@ const Save = observer(() => {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
               visible:
-                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
+                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER"].includes($deps[0])}}',
             },
           },
         },
@@ -279,7 +279,7 @@ const Save = observer(() => {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
               visible:
-                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
+                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER"].includes($deps[0])}}',
             },
           },
         },
@@ -312,7 +312,7 @@ const Save = observer(() => {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
               visible:
-                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
+                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER"].includes($deps[0])}}',
             },
           },
         },
@@ -334,7 +334,7 @@ const Save = observer(() => {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
               visible:
-                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
+                '{{["COAP_SERVER","MQTT_SERVER","WEB_SOCKET_SERVER","TCP_SERVER","UDP","HTTP_SERVER"].includes($deps[0])}}',
             },
           },
         },
@@ -356,43 +356,87 @@ const Save = observer(() => {
           fulfill: {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
-              visible: '{{["MQTT_Client"].includes($deps[0])}}',
+              visible: '{{["MQTT_CLIENT"].includes($deps[0])}}',
             },
           },
         },
         properties: {
           remoteHost: {
             title: '远程地址',
+            'x-decorator-props': {
+              gridSpan: 1,
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
+            'x-validator': ['ipv4'],
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
           remotePort: {
             title: '远程端口',
+            'x-decorator-props': {
+              gridSpan: 1,
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
             'x-decorator': 'FormItem',
-            'x-component': 'Input',
+            'x-component': 'NumberPicker',
           },
           clientId: {
             title: 'clientId',
+            'x-decorator-props': {
+              gridSpan: 1,
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
           username: {
             title: '用户名',
+            'x-decorator-props': {
+              gridSpan: 1,
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
           password: {
             title: '密码',
+            'x-decorator-props': {
+              gridSpan: 1,
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
           maxMessageSize: {
             title: '最大消息长度',
+            'x-decorator-props': {
+              gridSpan: 1,
+              tooltip: '单次收发消息的最大长度,单位:字节;设置过大可能会影响性能',
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
+            required: true,
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
           topicPrefix: {
             title: '订阅前缀',
+            'x-decorator-props': {
+              gridSpan: 1,
+              tooltip: '当连接的服务为EMQ时,可能需要使用共享的订阅前缀,如:$queue或$share',
+              layout: 'vertical',
+              labelAlign: 'left',
+            },
             'x-decorator': 'FormItem',
             'x-component': 'Input',
           },
@@ -413,30 +457,30 @@ const Save = observer(() => {
           fulfill: {
             state: {
               // visible: '{{$deps[0]==="UDP"}}',
-              visible: '{{["MQTT_SERVER","MQTT_CLIENT"].includes($deps[0])}}',
-            },
-          },
-        },
-      },
-      topicPrefix: {
-        title: '订阅前缀',
-        'x-decorator': 'FormItem',
-        'x-component': 'Input',
-        'x-decorator-props': {
-          gridSpan: 1,
-          labelAlign: 'left',
-          layout: 'vertical',
-        },
-        'x-reactions': {
-          dependencies: ['type'],
-          fulfill: {
-            state: {
-              // visible: '{{$deps[0]==="UDP"}}',
-              visible: '{{["MQTT_CLIENT"].includes($deps[0])}}',
+              visible: '{{["MQTT_SERVER"].includes($deps[0])}}',
             },
           },
         },
       },
+      // topicPrefix: {
+      //   title: '订阅前缀',
+      //   'x-decorator': 'FormItem',
+      //   'x-component': 'Input',
+      //   'x-decorator-props': {
+      //     gridSpan: 1,
+      //     labelAlign: 'left',
+      //     layout: 'vertical',
+      //   },
+      //   'x-reactions': {
+      //     dependencies: ['type'],
+      //     fulfill: {
+      //       state: {
+      //         // visible: '{{$deps[0]==="UDP"}}',
+      //         visible: '{{["MQTT_CLIENT"].includes($deps[0])}}',
+      //       },
+      //     },
+      //   },
+      // },
       parserType: {
         // TCP
         required: true,
@@ -741,11 +785,7 @@ const Save = observer(() => {
           />
           <FormButtonGroup.Sticky>
             <FormButtonGroup.FormItem>
-              {!form.readPretty ? (
-                <Submit onSubmit={handleSave}>保存</Submit>
-              ) : (
-                <Button onClick={() => (form.readPretty = false)}>编辑</Button>
-              )}
+              <Submit onSubmit={handleSave}>保存</Submit>
             </FormButtonGroup.FormItem>
           </FormButtonGroup.Sticky>
         </Form>

+ 3 - 3
src/pages/link/Type/index.tsx

@@ -5,7 +5,7 @@ import { Badge, Button, message, Popconfirm, Tooltip } from 'antd';
 import {
   CloseCircleOutlined,
   DeleteOutlined,
-  EyeOutlined,
+  EditOutlined,
   PlayCircleOutlined,
   PlusOutlined,
 } from '@ant-design/icons';
@@ -107,7 +107,7 @@ const Network = () => {
         <Button
           type="link"
           style={{ padding: 0 }}
-          disabled={getButtonPermission('link/Type', ['view'])}
+          // disabled={getButtonPermission('link/Type', ['view'])}
           key="edit"
           onClick={() => {
             Store.set('current-network-data', record);
@@ -115,7 +115,7 @@ const Network = () => {
           }}
         >
           <Tooltip title="查看">
-            <EyeOutlined />
+            <EditOutlined />
           </Tooltip>
         </Button>,
 

+ 1 - 2
src/pages/media/SplitScreen/index.tsx

@@ -3,9 +3,8 @@ import { PageContainer } from '@ant-design/pro-layout';
 import { Card } from 'antd';
 import LeftTree from './tree';
 import { ScreenPlayer } from '@/components';
-import { ptzStop, ptzTool } from './service';
+import { ptzStart, ptzStop, ptzTool } from './service';
 import { useRef, useState } from 'react';
-import { ptzStart } from './service';
 import './index.less';
 
 const SplitScreen = () => {

+ 3 - 1
src/pages/notice/Config/Detail/doc/AliyunSms.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const AliyunSms = () => {
   const accessKey = require('/public/images/notice/doc/config/aliyun-sms-voice/AccesskeyIDSecret.jpg');
   return (
@@ -30,7 +32,7 @@ const AliyunSms = () => {
         <div>用于程序通知方式调用云服务费API的用户标识和秘钥</div>
         <div>获取路径:“阿里云管理控制台”--“用户头像”--“”--“AccessKey管理”--“查看”</div>
         <div>
-          <img style={{ width: '100%' }} src={accessKey} alt="accessKey" />
+          <Image width="100%" src={accessKey} />
         </div>
       </div>
     </div>

+ 3 - 1
src/pages/notice/Config/Detail/doc/AliyunVoice.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const AliyunVoice = () => {
   const accessKey = require('/public/images/notice/doc/config/aliyun-sms-voice/AccesskeyIDSecret.jpg');
 
@@ -31,7 +33,7 @@ const AliyunVoice = () => {
         <div>获取路径:“阿里云管理控制台”--“用户头像”--“”--“AccessKey管理”--“查看”</div>
       </div>
       <div>
-        <img style={{ width: '100%' }} src={accessKey} alt="accessKey" />
+        <Image width="100%" src={accessKey} />
       </div>
     </div>
   );

+ 4 - 2
src/pages/notice/Config/Detail/doc/DingTalk.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const DingTalk = () => {
   const appKey = require('/public/images/notice/doc/config/dingTalk-message/01-AppKey.jpg');
   const appSecret = require('/public/images/notice/doc/config/dingTalk-message/02-AppSecret.jpg');
@@ -25,7 +27,7 @@ const DingTalk = () => {
         </div>
         <div>获取路径:“钉钉开放平台”--“应用开发”--“应用信息”</div>
         <div>
-          <img style={{ width: '100%' }} src={appKey} alt="appKey" />
+          <Image width="100%" src={appKey} />
         </div>
       </div>
       <b>2. AppSecret</b>
@@ -33,7 +35,7 @@ const DingTalk = () => {
         <div>钉钉应用对应的调用密钥</div>
         <div>获取路径:“钉钉开放平台”--“应用开发”--“应用信息”</div>
         <div>
-          <img style={{ width: '100%' }} src={appSecret} alt="appSecret" />
+          <Image width="100%" src={appSecret} />
         </div>
       </div>
     </div>

+ 5 - 3
src/pages/notice/Config/Detail/doc/DingTalkRebot.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const DingTalkRebot = () => {
   const groupSetting = require('/public/images/notice/doc/config/dingTalk-rebot/01-group-setting.jpg');
 
@@ -16,15 +18,15 @@ const DingTalkRebot = () => {
         <div>在钉钉群内每创建一个钉钉群自定义机器人都会产生唯一的WebHook地址。</div>
         <div>获取路径:“钉钉桌面客户端”--“群设置”--“智能群助手”--“机器人信息”</div>
         <div>
-          <img style={{ width: '100%' }} src={rebot} alt="rebot" />
+          <Image width="100%" src={rebot} />
         </div>
         <div>1、登录钉钉桌面客户端,进入群设置</div>
         <div>
-          <img style={{ width: '100%' }} src={groupSetting} alt="groupSetting" />
+          <Image width="100%" src={groupSetting} />
         </div>
         <div>2、点击智能群助手,查看机器人信息</div>
         <div>
-          <img style={{ width: '100%' }} src={webhook} alt="webhook" />
+          <Image width="100%" src={webhook} />
         </div>
       </div>
     </div>

+ 4 - 2
src/pages/notice/Config/Detail/doc/WeixinApp.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const WeixinApp = () => {
   const appId = require('/public/images/notice/doc/config/weixin-official/01-AppID.jpg');
   const appSecret = require('/public/images/notice/doc/config/weixin-official/02-AppSecret.jpg');
@@ -24,7 +26,7 @@ const WeixinApp = () => {
         <div>微信服务号的唯一专属编号。</div>
         <div>获取路径:“微信公众平台”管理后台--“设置与开发”--“基本配置”</div>
         <div>
-          <img style={{ width: '100%' }} src={appId} alt="appId" />
+          <Image width="100%" src={appId} />
         </div>
       </div>
       <b>2. AppSecret</b>
@@ -32,7 +34,7 @@ const WeixinApp = () => {
         <div>公众号开发者身份的密码</div>
         <div>获取路径:“微信公众平台”管理后台--“设置与开发”--“基本配置”</div>
         <div>
-          <img style={{ width: '100%' }} src={appSecret} alt="appSercet" />
+          <Image width="100%" src={appSecret} />
         </div>
       </div>
     </div>

+ 4 - 2
src/pages/notice/Config/Detail/doc/WeixinCorp.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const WeixinCorp = () => {
   const corpId = require('/public/images/notice/doc/config/weixin-corp/01-corpId.jpg');
   const corpSecret = require('/public/images/notice/doc/config/weixin-corp/02-corpSecret.jpg');
@@ -23,7 +25,7 @@ const WeixinCorp = () => {
         <div>企业号的唯一专属编号。</div>
         <div>获取路径:“企业微信”管理后台--“我的企业”--“企业ID”</div>
         <div>
-          <img style={{ width: '100%' }} src={corpId} alt="corpId" />
+          <Image width="100%" src={corpId} />
         </div>
       </div>
 
@@ -32,7 +34,7 @@ const WeixinCorp = () => {
         <div>应用的唯一secret,一个企业微信中可以有多个corpSecret</div>
         <div>获取路径:“企业微信”--“应用与小程序”--“自建应用”中获取</div>
         <div>
-          <img style={{ width: '100%' }} src={corpSecret} alt="corpSecret" />
+          <Image width="100%" src={corpSecret} />
         </div>
       </div>
     </div>

+ 64 - 6
src/pages/notice/Config/Detail/index.tsx

@@ -120,6 +120,7 @@ const Detail = observer(() => {
     properties: {
       name: {
         title: '名称',
+        required: true,
         'x-component': 'Input',
         'x-decorator': 'FormItem',
       },
@@ -152,6 +153,7 @@ const Detail = observer(() => {
                 title: 'corpId',
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
+                required: true,
                 // 企业消息
                 'x-reactions': {
                   dependencies: ['provider'],
@@ -161,11 +163,18 @@ const Detail = observer(() => {
                     },
                   },
                 },
+                'x-component-props': {
+                  placeholder: '请输入corpId',
+                },
               },
               corpSecret: {
                 title: 'corpSecret',
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入corpSecret',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -178,7 +187,11 @@ const Detail = observer(() => {
               appId: {
                 title: 'appID',
                 'x-component': 'Input',
+                required: true,
                 'x-decorator': 'FormItem',
+                'x-component-props': {
+                  placeholder: '请输入appId',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -191,7 +204,11 @@ const Detail = observer(() => {
               secret: {
                 title: 'AppSecret',
                 'x-component': 'Input',
+                required: true,
                 'x-decorator': 'FormItem',
+                'x-component-props': {
+                  placeholder: '请输入secret',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -212,7 +229,10 @@ const Detail = observer(() => {
                 title: 'AppKey',
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
-                // 钉钉消息通知
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入AppKey',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -226,7 +246,10 @@ const Detail = observer(() => {
                 title: 'AppSecret',
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
-                // 钉钉消息通知
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入AppSecret',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -240,7 +263,10 @@ const Detail = observer(() => {
                 title: 'webHook',
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
-                // 群机器人
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入webhook',
+                },
                 'x-reactions': {
                   dependencies: ['provider'],
                   fulfill: {
@@ -257,18 +283,30 @@ const Detail = observer(() => {
             type: 'void',
             'x-visible': id === 'voice' || id === 'sms',
             properties: {
-              RegionId: {
+              regionId: {
                 title: 'regionId',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入regionId',
+                },
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
               },
-              AccessKeyId: {
+              accessKeyId: {
                 title: 'accessKeyId',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入accessKeyId',
+                },
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
               },
-              Secret: {
+              secret: {
                 title: 'secret',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入secret',
+                },
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
               },
@@ -290,11 +328,19 @@ const Detail = observer(() => {
                 properties: {
                   host: {
                     // title: '服务器地址',
+                    required: true,
+                    'x-component-props': {
+                      placeholder: '请输入服务器地址',
+                    },
                     'x-component': 'Input',
                     'x-decorator': 'FormItem',
                   },
                   port: {
                     // title: '端口',
+                    required: true,
+                    'x-component-props': {
+                      placeholder: '请输入端口',
+                    },
                     'x-component': 'NumberPicker',
                     'x-decorator': 'FormItem',
                   },
@@ -309,16 +355,28 @@ const Detail = observer(() => {
               },
               sender: {
                 title: '发件人',
+                required: true,
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
+                'x-component-props': {
+                  placeholder: '请输入发件人',
+                },
               },
               username: {
                 title: '用户名',
+                required: true,
                 'x-component': 'Input',
+                'x-component-props': {
+                  placeholder: '请输入用户名',
+                },
                 'x-decorator': 'FormItem',
               },
               password: {
                 title: '密码',
+                required: true,
+                'x-component-props': {
+                  placeholder: '请输入密码',
+                },
                 'x-component': 'Input',
                 'x-decorator': 'FormItem',
               },

+ 5 - 3
src/pages/notice/Template/Detail/doc/DingTalk.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const DingTalk = () => {
   const agentId = require('/public/images/notice/doc/template/dingTalk-message/01-Agentid.jpg');
   const userId = require('/public/images/notice/doc/template/dingTalk-message/02-user-id.jpg');
@@ -26,7 +28,7 @@ const DingTalk = () => {
       <div> 2. Agentid</div>
       <div> 应用唯一标识</div>
       <div>
-        <img style={{ width: '100%' }} src={agentId} alt="agentId" />
+        <Image width="100%" src={agentId} />
       </div>
       <div> 获取路径:“钉钉开发平台”--“应用开发”--“查看应用”</div>
       <div> 3. 收信人ID、收信部门ID</div>
@@ -36,8 +38,8 @@ const DingTalk = () => {
       <div> 收信人ID获取路径:“钉钉管理后台”--“通讯录”--“查看用户”</div>
       <div> 收信部门ID获取路径:“钉钉管理后台”--“通讯录”--“编辑部门”</div>
       <div>
-        <img style={{ width: '100%' }} src={userId} alt="userId" />
-        <img style={{ width: '100%' }} src={dept} alt="dept" />
+        <Image width="100%" src={userId} />
+        <Image width="100%" src={dept} />
       </div>
       <div> 4. 模板内容</div>
       <div>

+ 5 - 3
src/pages/notice/Template/Detail/doc/DingTalkRebot.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const DingTalkRebot = () => {
   const text = require('/public/images/notice/doc/template/dingTalk-rebot/01-text.jpg');
   const markdown = require('/public/images/notice/doc/template/dingTalk-rebot/02-markdown.jpg');
@@ -26,9 +28,9 @@ const DingTalkRebot = () => {
         <div> 2、消息类型</div>
         <div> 目前支持text、markdown、link3种,对应的发送效果示例,如下图:</div>
         <div>
-          <img style={{ width: '100%' }} src={text} alt="text" />
-          <img style={{ width: '100%' }} src={markdown} alt="markdown" />
-          <img style={{ width: '100%' }} src={link} alt="link" />
+          <Image width="100%" src={text} />
+          <Image width="100%" src={markdown} />
+          <Image width="100%" src={link} />
         </div>
         <div> 3. 模板内容</div>
         <div>

+ 4 - 2
src/pages/notice/Template/Detail/doc/WeixinApp.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const WeixinApp = () => {
   const agentId = require('/public/images/notice/doc/template/weixin-official/01-Agentid.jpg');
   const appId = require('/public/images/notice/doc/template/weixin-official/02-mini-Program-Appid.jpg');
@@ -24,7 +26,7 @@ const WeixinApp = () => {
         <div>微信服务号的唯一专属编号。</div>
         <div>获取路径:“微信公众平台”管理后台--“设置与开发”--“基本配置”</div>
         <div>
-          <img style={{ width: '100%' }} src={agentId} alt="agentId" />
+          <Image width="100%" src={agentId} />
         </div>
       </div>
       <b>2. AppSecret</b>
@@ -32,7 +34,7 @@ const WeixinApp = () => {
         <div>公众号开发者身份的密码</div>
         <div>获取路径:“微信公众平台”管理后台--“设置与开发”--“基本配置”</div>
         <div>
-          <img style={{ width: '100%' }} src={appId} alt="appId" />
+          <Image width="100%" src={appId} />
         </div>
       </div>
     </div>

+ 6 - 4
src/pages/notice/Template/Detail/doc/WeixinCorp.tsx

@@ -1,3 +1,5 @@
+import { Image } from 'antd';
+
 const WeixinCorp = () => {
   const agentId = require('/public/images/notice/doc/template/weixin-corp/01-Agentid.jpg');
   const userId = require('/public/images/notice/doc/template/weixin-corp/02-userID.jpg');
@@ -28,7 +30,7 @@ const WeixinCorp = () => {
         <div> 应用唯一标识</div>
         <div> 获取路径:“企业微信”管理后台--“应用管理”--“应用”--“查看应用”</div>
         <div>
-          <img style={{ width: '100%' }} src={agentId} alt="agentId" />
+          <Image width="100%" src={agentId} />
         </div>
         <div> 3. 收信人ID、收信部门ID、标签推送</div>
         <div>
@@ -37,9 +39,9 @@ const WeixinCorp = () => {
         <div> 收信人ID获取路径:【通讯录】-{'>'}【成员信息】查看成员账号</div>
         <div> 收信部门ID获取路径:【通讯录】-{'>'}【部门信息】查看部门ID</div>
         <div>
-          <img style={{ width: '100%' }} src={userId} alt="userId" />
-          <img style={{ width: '100%' }} src={toDept} alt="toDept" />
-          <img style={{ width: '100%' }} src={toTags} alt="toTags" />
+          <Image width="100%" src={userId} />
+          <Image width="100%" src={toDept} />
+          <Image width="100%" src={toTags} />
         </div>
       </div>
     </div>

+ 346 - 198
src/pages/notice/Template/Detail/index.tsx

@@ -36,6 +36,7 @@ import DingTalkRebot from '@/pages/notice/Template/Detail/doc/DingTalkRebot';
 import AliyunVoice from '@/pages/notice/Template/Detail/doc/AliyunVoice';
 import AliyunSms from '@/pages/notice/Template/Detail/doc/AliyunSms';
 import Email from '@/pages/notice/Template/Detail/doc/Email';
+import { Store } from 'jetlinks-store';
 
 export const docMap = {
   weixin: {
@@ -63,6 +64,37 @@ const Detail = observer(() => {
   // 正则提取${}里面的值
   const pattern = /(?<=\$\{).*?(?=\})/g;
 
+  const getConfig = (provider1: string) =>
+    configService
+      .queryNoPagingPost({
+        terms: [
+          { column: 'type$IN', value: id },
+          { column: 'provider', value: provider1 },
+        ],
+      })
+      .then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      });
+
+  //需要复杂联动才可以完成
+  const getWeixinDept = (configId: string) => service.weixin.getDepartments(configId);
+  const getWeixinTags = (configId: string) => service.weixin.getTags(configId);
+  const getWeixinUser = (configId: string) => service.weixin.getUser(configId);
+
+  const getDingTalkDept = (configId: string) => service.dingTalk.getDepartments(configId);
+  const getDingTalkDeptTree = (configId: string) => service.dingTalk.getDepartmentsTree(configId);
+  const getDingTalkUser = (configId: string) => service.dingTalk.getUser(configId);
+
+  const getWeixinOfficialTags = (configId: string) => service.weixin.getOfficialTags(configId);
+  const getWeixinOfficialTemplates = (configId: string) =>
+    service.weixin.getOfficialTemplates(configId);
+
+  const getAliyunSigns = (configId: string) => service.aliyun.getSigns(configId);
+  const getAliyunTemplates = (configId: string) => service.aliyun.getTemplates(configId);
+
   const form = useMemo(
     () =>
       createForm({
@@ -76,8 +108,103 @@ const Detail = observer(() => {
           onFieldValueChange('provider', (field, form1) => {
             const value = field.value;
             setProvider(value);
-            form1.setValuesIn('configId', null);
-            form1.setValuesIn('template', null);
+            // form1.setValuesIn('configId', null);
+            // form1.setValuesIn('template', null);
+            // 设置绑定配置的数据
+            form1.setFieldState('configId', async (state1) => {
+              state1.dataSource = await getConfig(value);
+            });
+          });
+          onFieldValueChange('configId', (field, form1) => {
+            const value = field.value;
+            // 判断provider
+            if (!value) return;
+            switch (form1.values.provider) {
+              case 'corpMessage':
+                form1.setFieldState('template.toUser', async (state8) => {
+                  state8.dataSource = await getWeixinUser(value);
+                });
+                form1.setFieldState('template.toParty', async (state9) => {
+                  state9.dataSource = await getWeixinDept(value);
+                });
+                form1.setFieldState('template.toTag', async (state10) => {
+                  state10.dataSource = await getWeixinTags(value);
+                });
+                break;
+              case 'officialMessage':
+                // TODO 通知配置不能为空
+                form1.setFieldState('template.tagid', async (state1) => {
+                  state1.dataSource = await getWeixinOfficialTags(value);
+                });
+                form1.setFieldState('template.wxTemplateId', async (state2) => {
+                  const list = await getWeixinOfficialTemplates(value);
+                  Store.set('wxTemplate', list);
+                  state2.dataSource = list;
+                });
+                break;
+              case 'dingTalkMessage':
+                form1.setFieldState('template.userIdList', async (state3) => {
+                  state3.dataSource = await getDingTalkUser(value);
+                });
+                form1.setFieldState('template.departmentIdList', async (state4) => {
+                  const list = await getDingTalkDept(value);
+                  Store.set('wxTemplate', list);
+                  state4.dataSource = list;
+                });
+                break;
+              case 'aliyun':
+                // 阿里云语音
+                form1.setFieldState('template.ttsCode', async (state5) => {
+                  const list = await getAliyunTemplates(value);
+                  Store.set('AliyunTemplate', list);
+                  state5.dataSource = list;
+                });
+                break;
+              case 'aliyunSms':
+                // 阿里云短信
+                form1.setFieldState('template.code', async (state6) => {
+                  const list = await getAliyunTemplates(value);
+                  Store.set('AliyunTemplate', list);
+                  state6.dataSource = list;
+                });
+
+                form1.setFieldState('template.signName', async (state7) => {
+                  // const list =
+                  // Store.set('AliyunTemplate', list);
+                  state7.dataSource = await getAliyunSigns(value);
+                });
+
+                break;
+              default:
+                break;
+            }
+          });
+          onFieldValueChange('template.wxTemplateId', (field, form1) => {
+            const value = field.value;
+            // 处理消息模版。
+            const template = Store.get('wxTemplate');
+            const data = template?.find((i: { id: any }) => i.id === value);
+            if (data) {
+              form1.setFieldState('template.title', (state1) => {
+                state1.value = data.title;
+                state1.disabled = true;
+              });
+              form1.setFieldState('template.message', (state1) => {
+                state1.value = data.content;
+                state1.disabled = true;
+              });
+            }
+          });
+          onFieldValueChange('template.code', (field, form1) => {
+            const value = field.value;
+            const template = Store.get('AliyunTemplate');
+            const data = template?.find((i: { templateCode: any }) => i.templateCode === value);
+            if (data) {
+              form1.setFieldState('template.message', (state1) => {
+                state1.value = data.templateContent;
+                state1.disabled = true;
+              });
+            }
           });
           onFieldValueChange('template.message', (field, form1) => {
             const value = (field as Field).value;
@@ -134,38 +261,6 @@ const Detail = observer(() => {
     [id],
   );
 
-  const getConfig = () =>
-    configService
-      .queryNoPagingPost({
-        terms: [
-          { column: 'type$IN', value: id },
-          { column: 'provider', value: form.values?.provider },
-        ],
-      })
-      .then((resp: any) => {
-        return resp.result?.map((item: any) => ({
-          label: item.name,
-          value: item.id,
-        }));
-      });
-
-  const getDingTalkDept = (configId: string) => service.dingTalk.getDepartments(configId);
-  const getDingTalkDeptTree = (configId: string) => service.dingTalk.getDepartmentsTree(configId);
-  const getDingTalkUser = (configId: string, departmentId: string) =>
-    service.dingTalk.getUserByDepartment(configId, departmentId);
-
-  //需要复杂联动才可以完成
-  const getWeixinDept = () => service.weixin.getDepartments(form?.values.configId);
-  const getWeixinTags = () => service.weixin.getTags(form?.values.configId);
-  const getWeixinUser = () => service.weixin.getUser(form?.values.configId);
-
-  const getWeixinOfficialTags = (configId: string) => service.weixin.getOfficialTags(configId);
-  const getWeixinOfficialTemplates = (configId: string) =>
-    service.weixin.getOfficialTemplates(configId);
-
-  const getAliyunSigns = (configId: string) => service.aliyun.getSigns(configId);
-  const getAliyunTemplates = (configId: string) => service.aliyun.getTemplates(configId);
-
   useEffect(() => {
     if (state.current) {
       form.setValues(state.current);
@@ -201,6 +296,8 @@ const Detail = observer(() => {
     // r如果是text 的话。template.message=>template.text.content
     // 如果是markdown 的话。 template.message=>template.markdown.text
     // 如果是link的话。 template.message =>template.markdown.text
+
+    // 微信服务号: template.message =>template.content
     if (data.provider === 'dingTalkRobotWebHook') {
       const type = data.template.messageType;
       // emplate.messageType
@@ -284,7 +381,7 @@ const Detail = observer(() => {
         //   {label: '测试配置2', value: 'test2'},
         //   {label: '测试配置3', value: 'test3'},
         // ],
-        'x-reactions': '{{useAsyncDataSource(getConfig)}}',
+        // 'x-reactions': '{{useAsyncDataSource(getConfig)}}',
         'x-visible': id !== 'email',
       },
       template: {
@@ -308,34 +405,37 @@ const Detail = observer(() => {
                       placeholder: '请输入AgentID',
                     },
                   },
-                  toUser: {
-                    title: '收信人ID',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
-                    'x-decorator-props': {
-                      tooltip: '请输入收信人ID',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入收信人ID',
-                      mode: 'tags',
-                    },
-                    'x-reactions': '{{useAsyncDataSource(getWeixinUser)}}',
-                  },
-                  toParty: {
-                    title: '收信部门ID',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
+                  layout: {
+                    type: 'void',
+                    'x-decorator': 'FormGrid',
                     'x-decorator-props': {
-                      tooltip: '请输入收信部门ID',
+                      maxColumns: 2,
+                      minColumns: 2,
                     },
-                    'x-component-props': {
-                      placeholder: '请输入收信部门ID',
-                      mode: 'tags',
-                    },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getWeixinDept($deps[0]))}}',
+                    properties: {
+                      toUser: {
+                        title: '收信人',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入收信人ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入收信人ID',
+                        },
+                      },
+                      toParty: {
+                        title: '收信部门',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入收信部门ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入收信部门ID',
+                        },
                       },
                     },
                   },
@@ -348,13 +448,6 @@ const Detail = observer(() => {
                     },
                     'x-component-props': {
                       placeholder: '请输入标签推送,多个标签用,号分隔',
-                      mode: 'tags',
-                    },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getWeixinTags($deps[0]))}}',
-                      },
                     },
                   },
                 },
@@ -387,35 +480,39 @@ const Detail = observer(() => {
                     'x-component-props': {
                       placeholder: '请选择用户标签',
                     },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getWeixinOfficialTags($deps[0]))}}',
-                      },
-                    },
                   },
-                  wxTemplateId: {
-                    title: '消息模版',
-                    type: 'string',
-                    'x-decorator': 'FormItem',
-                    'x-component': 'Select',
-                    'x-component-props': {
-                      placeholder: '请选择消息模版',
+                  layout: {
+                    type: 'void',
+                    'x-decorator': 'FormGrid',
+                    'x-decorator-props': {
+                      maxColumns: 2,
+                      minColumns: 2,
                     },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getWeixinOfficialTemplates($deps[0]))}}',
+                    properties: {
+                      wxTemplateId: {
+                        title: '消息模版',
+                        type: 'string',
+                        'x-decorator': 'FormItem',
+                        'x-component': 'Select',
+                        'x-component-props': {
+                          placeholder: '请选择消息模版',
+                        },
+                        'x-decorator-props': {
+                          gridSpan: 1,
+                        },
+                      },
+                      url: {
+                        title: '模版跳转链接',
+                        type: 'string',
+                        'x-decorator': 'FormItem',
+                        'x-component': 'Input',
+                        'x-component-props': {
+                          placeholder: '请输入模版跳转链接',
+                        },
+                        'x-decorator-props': {
+                          gridSpan: 1,
+                        },
                       },
-                    },
-                  },
-                  url: {
-                    title: '模版跳转链接',
-                    type: 'string',
-                    'x-decorator': 'FormItem',
-                    'x-component': 'Input',
-                    'x-component-props': {
-                      placeholder: '请输入模版跳转链接',
                     },
                   },
                   toMiniProgram: {
@@ -435,22 +532,38 @@ const Detail = observer(() => {
                   miniProgram: {
                     type: 'void',
                     properties: {
-                      miniProgramId: {
-                        title: '跳转小程序AppId',
-                        type: 'string',
-                        'x-decorator': 'FormItem',
-                        'x-component': 'Input',
-                        'x-component-props': {
-                          placeholder: '请输入跳转小程序AppId',
+                      layout: {
+                        type: 'void',
+                        'x-decorator': 'FormGrid',
+                        'x-decorator-props': {
+                          maxColumns: 2,
+                          minColumns: 2,
                         },
-                      },
-                      miniProgramPath: {
-                        title: '跳转小程序具体路径',
-                        type: 'string',
-                        'x-decorator': 'FormItem',
-                        'x-component': 'Input',
-                        'x-component-props': {
-                          placeholder: '请输入跳转小程序具体路径',
+                        properties: {
+                          miniProgramId: {
+                            title: '跳转小程序AppId',
+                            type: 'string',
+                            'x-decorator': 'FormItem',
+                            'x-component': 'Input',
+                            'x-component-props': {
+                              placeholder: '请输入跳转小程序AppId',
+                            },
+                            'x-decorator-props': {
+                              gridSpan: 1,
+                            },
+                          },
+                          miniProgramPath: {
+                            title: '跳转小程序具体路径',
+                            type: 'string',
+                            'x-decorator': 'FormItem',
+                            'x-component': 'Input',
+                            'x-component-props': {
+                              placeholder: '请输入跳转小程序具体路径',
+                            },
+                            'x-decorator-props': {
+                              gridSpan: 1,
+                            },
+                          },
                         },
                       },
                     },
@@ -472,12 +585,12 @@ const Detail = observer(() => {
                       placeholder: '这里是回显内容',
                     },
                   },
-                  content: {
-                    title: '模版内容',
-                    type: 'string',
-                    'x-decorator': 'FormItem',
-                    'x-component': 'Input.TextArea',
-                  },
+                  // content: {
+                  //   title: '模版内容',
+                  //   type: 'string',
+                  //   'x-decorator': 'FormItem',
+                  //   'x-component': 'Input.TextArea',
+                  // },
                 },
                 'x-reactions': {
                   dependencies: ['provider'],
@@ -499,6 +612,7 @@ const Detail = observer(() => {
                 properties: {
                   agentId: {
                     title: 'AgentID',
+                    required: true,
                     'x-component': 'Input',
                     'x-decorator': 'FormItem',
                     'x-decorator-props': {
@@ -508,47 +622,49 @@ const Detail = observer(() => {
                       placeholder: '请输入AgentID',
                     },
                   },
-                  toAllUser: {
-                    title: '通知全部用户',
-                    type: 'boolean',
-                    'x-component': 'Radio.Group',
-                    'x-decorator': 'FormItem',
-                    enum: [
-                      { label: '是', value: true },
-                      { label: '否', value: false },
-                    ],
-                  },
-                  userIdList: {
-                    title: '收信人ID',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
+                  layout: {
+                    type: 'void',
+                    'x-decorator': 'FormGrid',
                     'x-decorator-props': {
-                      tooltip: '请输入收信人ID',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入收信人ID',
+                      maxColumns: 2,
+                      minColumns: 2,
                     },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getDingTalkUser($deps[0]))}}',
+                    properties: {
+                      userIdList: {
+                        title: '收信人',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入收信人ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入收信人ID',
+                        },
+                        'x-reactions': {
+                          dependencies: ['configId'],
+                          fulfill: {
+                            run: '{{useAsyncDataSource(getDingTalkUser($deps[0]))}}',
+                          },
+                        },
                       },
-                    },
-                  },
-                  departmentIdList: {
-                    title: '收信部门ID',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
-                    'x-decorator-props': {
-                      tooltip: '请输入收信部门ID',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入AgentID',
-                    },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getDingTalkDept($deps[0]))}}',
+                      departmentIdList: {
+                        title: '收信部门',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入收信部门ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入AgentID',
+                        },
+                        'x-reactions': {
+                          dependencies: ['configId'],
+                          fulfill: {
+                            run: '{{useAsyncDataSource(getDingTalkDept($deps[0]))}}',
+                          },
+                        },
                       },
                     },
                   },
@@ -569,6 +685,7 @@ const Detail = observer(() => {
                     title: '消息类型',
                     'x-component': 'Select',
                     'x-decorator': 'FormItem',
+                    required: true,
                     enum: [
                       { label: 'markdown', value: 'markdown' },
                       { label: 'text', value: 'text' },
@@ -579,6 +696,7 @@ const Detail = observer(() => {
                     type: 'object',
                     properties: {
                       title: {
+                        required: true,
                         title: '标题',
                         'x-component': 'Input',
                         'x-decorator': 'FormItem',
@@ -597,6 +715,7 @@ const Detail = observer(() => {
                     type: 'object',
                     properties: {
                       title: {
+                        required: true,
                         title: '标题',
                         'x-component': 'Input',
                         'x-decorator': 'FormItem',
@@ -647,30 +766,38 @@ const Detail = observer(() => {
                 'x-visible': id === 'voice',
                 type: 'void',
                 properties: {
-                  // ttsCode	String	语音-模版ID
-                  // calledShowNumbers	String	语音-被叫显号
-                  // CalledNumber	String	语音-被叫号码
-                  // PlayTimes	String	语音-播放次数
-                  ttsCode: {
-                    title: '模版ID',
-                    'x-component': 'Input',
-                    'x-decorator': 'FormItem',
-                    'x-decorator-props': {
-                      tooltip: '请输入模版ID',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入模版ID',
-                    },
-                  },
-                  calledShowNumbers: {
-                    title: '被叫号码',
-                    'x-component': 'Input',
-                    'x-decorator': 'FormItem',
+                  layout: {
+                    type: 'void',
+                    'x-decorator': 'FormGrid',
                     'x-decorator-props': {
-                      tooltip: '请输入calledShowNumbers',
+                      maxColumns: 2,
+                      minColumns: 2,
                     },
-                    'x-component-props': {
-                      placeholder: '请输入calledShowNumbers',
+                    properties: {
+                      ttsCode: {
+                        title: '模版ID',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入模版ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入模版ID',
+                        },
+                      },
+                      calledShowNumbers: {
+                        title: '被叫号码',
+                        'x-component': 'Input',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入calledShowNumbers',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入calledShowNumbers',
+                        },
+                      },
                     },
                   },
                   calledNumber: {
@@ -701,32 +828,44 @@ const Detail = observer(() => {
                 'x-visible': id === 'sms',
                 type: 'void',
                 properties: {
-                  code: {
-                    title: '模版ID',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
+                  layout: {
+                    type: 'void',
+                    'x-decorator': 'FormGrid',
                     'x-decorator-props': {
-                      tooltip: '请输入模版ID',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入模版ID',
+                      maxColumns: 2,
+                      minColumns: 2,
                     },
-                    'x-reactions': {
-                      dependencies: ['configId'],
-                      fulfill: {
-                        run: '{{useAsyncDataSource(getAliyunTemplates($deps[0]))}}',
+                    properties: {
+                      code: {
+                        title: '模版ID',
+                        'x-component': 'Select',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入模版ID',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入模版ID',
+                        },
+                        'x-reactions': {
+                          dependencies: ['configId'],
+                          fulfill: {
+                            run: '{{useAsyncDataSource(getAliyunTemplates($deps[0]))}}',
+                          },
+                        },
+                      },
+                      phoneNumber: {
+                        title: '收信人',
+                        'x-component': 'Input',
+                        'x-decorator': 'FormItem',
+                        'x-decorator-props': {
+                          tooltip: '请输入收信人',
+                          gridSpan: 1,
+                        },
+                        'x-component-props': {
+                          placeholder: '请输入收信人',
+                        },
                       },
-                    },
-                  },
-                  phoneNumber: {
-                    title: '收信人',
-                    'x-component': 'Select',
-                    'x-decorator': 'FormItem',
-                    'x-decorator-props': {
-                      tooltip: '请输入收信人',
-                    },
-                    'x-component-props': {
-                      placeholder: '请输入收信人',
                     },
                   },
                   signName: {
@@ -832,6 +971,15 @@ const Detail = observer(() => {
         'x-decorator-props': {
           tooltip: '请输入模版内容',
         },
+        required: true,
+        'x-reactions': {
+          dependencies: ['provider'],
+          fulfill: {
+            state: {
+              hidden: '{{$deps[0]==="aliyun"}}',
+            },
+          },
+        },
         'x-component-props': {
           rows: 5,
           placeholder: '变量格式:${name};\n 示例:尊敬的${name},${time}有设备触发告警,请注意处理',

+ 77 - 11
src/pages/notice/Template/service.ts

@@ -44,28 +44,94 @@ class Service extends BaseService<TemplateItem> {
 
   dingTalk = {
     getDepartments: (id: string) =>
-      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/departments`),
+      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/departments`).then(
+        (resp: any) => {
+          return resp.result?.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+          }));
+        },
+      ),
     getDepartmentsTree: (id: string) =>
-      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/departments/tree`),
-    getUserByDepartment: (id: string, departmentId: string) =>
-      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/${departmentId}/users`),
+      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/departments/tree`).then(
+        (resp: any) => {
+          return resp.result?.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+          }));
+        },
+      ),
+    getUser: (id: string) =>
+      request(`${SystemConst.API_BASE}/notifier/dingtalk/corp/${id}/users`).then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      }),
   };
 
   weixin = {
-    getTags: (id: string) => request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/tags`),
+    getTags: (id: string) =>
+      request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/tags`).then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      }),
     getDepartments: (id: string) =>
-      request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/departments`),
-    getUser: (id: string) => request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/users`),
+      request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/departments`).then(
+        (resp: any) => {
+          return resp.result?.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+          }));
+        },
+      ),
+    getUser: (id: string) =>
+      request(`${SystemConst.API_BASE}/notifier/wechat/corp/${id}/users`).then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          label: item.name,
+          value: item.id,
+        }));
+      }),
     getOfficialTags: (configId: string) =>
-      request(`${SystemConst.API_BASE}/notifier/wechat/official/${configId}/tags`),
+      request(`${SystemConst.API_BASE}/notifier/wechat/official/${configId}/tags`).then(
+        (resp: any) => {
+          return resp.result?.map((item: any) => ({
+            label: item.name,
+            value: item.id,
+          }));
+        },
+      ),
     getOfficialTemplates: (configId: string) =>
-      request(`${SystemConst.API_BASE}/notifier/wechat/official/${configId}/templates`),
+      request(`${SystemConst.API_BASE}/notifier/wechat/official/${configId}/templates`).then(
+        (resp: any) => {
+          return resp.result?.map((item: any) => ({
+            ...item,
+            label: item.title,
+            value: item.id,
+          }));
+        },
+      ),
   };
 
   aliyun = {
-    getSigns: (id: string) => request(`${SystemConst.API_BASE}/notifier/sms/aliyun/${id}/signs`),
+    getSigns: (id: string) =>
+      request(`${SystemConst.API_BASE}/notifier/sms/aliyun/${id}/signs`).then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          ...item,
+          label: item.signName,
+          value: item.signName,
+        }));
+      }),
     getTemplates: (id: string) =>
-      request(`${SystemConst.API_BASE}/notifier/sms/aliyun/${id}/templates`),
+      request(`${SystemConst.API_BASE}/notifier/sms/aliyun/${id}/templates`).then((resp: any) => {
+        return resp.result?.map((item: any) => ({
+          ...item,
+          label: item.templateName,
+          value: item.templateCode,
+        }));
+      }),
   };
 }
 

+ 7 - 1
src/pages/system/User/Save/index.tsx

@@ -134,7 +134,13 @@ const Save = (props: Props) => {
                 service
                   .validateField('username', value)
                   .then((resp) => {
-                    console.log(resp);
+                    if (resp.status === 200) {
+                      if (resp.result.passed) {
+                        resolve('');
+                      } else {
+                        resolve(resp.result.reason);
+                      }
+                    }
                     resolve('');
                   })
                   .catch(() => {