index.tsx 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574
  1. import {
  2. ArrayItems,
  3. ArrayTable,
  4. Editable,
  5. Form,
  6. FormButtonGroup,
  7. FormGrid,
  8. FormItem,
  9. Input,
  10. NumberPicker,
  11. PreviewText,
  12. Radio,
  13. Select,
  14. Space,
  15. Switch,
  16. } from '@formily/antd';
  17. import type { Field } from '@formily/core';
  18. import {
  19. createForm,
  20. FormPath,
  21. onFieldInit,
  22. onFieldReact,
  23. onFieldValueChange,
  24. registerValidateRules,
  25. } from '@formily/core';
  26. import { createSchemaField, observer } from '@formily/react';
  27. import type { ISchema } from '@formily/json-schema';
  28. import styles from './index.less';
  29. import { useEffect, useMemo, useRef, useState } from 'react';
  30. import FUpload from '@/components/Upload';
  31. import { useParams } from 'umi';
  32. import { PageContainer } from '@ant-design/pro-layout';
  33. import { Card, Col, Row, Tooltip } from 'antd';
  34. import { typeList } from '@/pages/notice';
  35. import { configService, service, state } from '@/pages/notice/Template';
  36. import FBraftEditor from '@/components/FBraftEditor';
  37. import { onlyMessage, phoneRegEx, useAsyncDataSource } from '@/utils/util';
  38. import WeixinCorp from '@/pages/notice/Template/Detail/doc/WeixinCorp';
  39. import WeixinApp from '@/pages/notice/Template/Detail/doc/WeixinApp';
  40. import DingTalk from '@/pages/notice/Template/Detail/doc/DingTalk';
  41. import DingTalkRebot from '@/pages/notice/Template/Detail/doc/DingTalkRebot';
  42. import AliyunVoice from '@/pages/notice/Template/Detail/doc/AliyunVoice';
  43. import AliyunSms from '@/pages/notice/Template/Detail/doc/AliyunSms';
  44. import Email from '@/pages/notice/Template/Detail/doc/Email';
  45. import { Store } from 'jetlinks-store';
  46. import FAutoComplete from '@/components/FAutoComplete';
  47. import { PermissionButton } from '@/components';
  48. import usePermissions from '@/hooks/permission';
  49. import FMonacoEditor from '@/components/FMonacoEditor';
  50. import Webhook from './doc/Webhook';
  51. import { useModel } from '@@/plugin-model/useModel';
  52. import { QuestionCircleOutlined } from '@ant-design/icons';
  53. export const docMap = {
  54. weixin: {
  55. corpMessage: <WeixinCorp />,
  56. officialMessage: <WeixinApp />,
  57. },
  58. dingTalk: {
  59. dingTalkMessage: <DingTalk />,
  60. dingTalkRobotWebHook: <DingTalkRebot />,
  61. },
  62. voice: {
  63. aliyun: <AliyunVoice />,
  64. },
  65. sms: {
  66. aliyunSms: <AliyunSms />,
  67. },
  68. email: {
  69. embedded: <Email />,
  70. },
  71. webhook: {
  72. http: <Webhook />,
  73. },
  74. };
  75. const Detail = observer(() => {
  76. const { id } = useParams<{ id: string }>();
  77. const [provider, setProvider] = useState<string>('embedded');
  78. const { initialState } = useModel('@@initialState');
  79. // 正则提取${}里面的值
  80. const pattern = /(?<=\$\{).*?(?=\})/g;
  81. // 提取微信服务号里面的值 {{}}
  82. const weixinPattern = /(?<=\{\{).*?(?=\.DATA}})/g;
  83. const getConfig = (provider1: string) =>
  84. configService
  85. .queryNoPagingPost({
  86. terms: [
  87. { column: 'type$IN', value: id },
  88. { column: 'provider', value: provider1 },
  89. ],
  90. })
  91. .then((resp: any) => {
  92. return resp.result?.map((item: any) => ({
  93. label: item.name,
  94. value: item.id,
  95. }));
  96. });
  97. //需要复杂联动才可以完成
  98. const getWeixinDept = (configId: string) => service.weixin.getDepartments(configId);
  99. const getWeixinTags = (configId: string) => service.weixin.getTags(configId);
  100. const getWeixinUser = (configId: string) => service.weixin.getUser(configId);
  101. const getDingTalkDept = (configId: string) => service.dingTalk.getDepartments(configId);
  102. const getDingTalkDeptTree = (configId: string) => service.dingTalk.getDepartmentsTree(configId);
  103. const getDingTalkUser = (configId: string) => service.dingTalk.getUser(configId);
  104. const getWeixinOfficialTags = (configId: string) => service.weixin.getOfficialTags(configId);
  105. const getWeixinOfficialTemplates = (configId: string) =>
  106. service.weixin.getOfficialTemplates(configId);
  107. const getAliyunSigns = (configId: string) => service.aliyun.getSigns(configId);
  108. const getAliyunTemplates = (configId: string) => service.aliyun.getTemplates(configId);
  109. const variableDefinitionsRef =
  110. useRef<{ id: string; name: string; type: string; format: string }[]>();
  111. const form = useMemo(
  112. () =>
  113. createForm({
  114. validateFirst: true,
  115. effects() {
  116. onFieldInit('template.message', (field) => {
  117. if (id === 'email') {
  118. field.setComponent(FBraftEditor, {
  119. placeholder:
  120. '变量格式:${name};\n 示例:尊敬的${name},${time}有设备触发告警,请注意处理',
  121. // height: '100px',
  122. });
  123. }
  124. const _provider = field.query('provider').value();
  125. if (_provider === 'corpMessage') {
  126. field.componentProps = {
  127. // disabled: true,
  128. rows: 5,
  129. placeholder:
  130. '变量格式:${name};\n 示例:尊敬的${name},${time}有设备触发告警,请注意处理',
  131. };
  132. }
  133. // if (id === 'voice') {
  134. // const type = field.query('template.*.templateType').value();
  135. // console.log(type,'111111')
  136. // field.hidden = false
  137. // field.disabled = false
  138. // }
  139. });
  140. onFieldValueChange('provider', (field, form1) => {
  141. const value = field.value;
  142. setProvider(value);
  143. if (field.modified) {
  144. form1.setValuesIn('configId', null);
  145. form1.setValuesIn('template', null);
  146. }
  147. // 设置绑定配置的数据
  148. form1.setFieldState('configId', async (state1) => {
  149. state1.dataSource = await getConfig(value);
  150. });
  151. if (value === 'officialMessage') {
  152. form1.setFieldState('template.message', (state5) => {
  153. state5.decoratorProps = {
  154. tooltip: '服务号模版消息内容',
  155. };
  156. });
  157. }
  158. });
  159. onFieldValueChange('configId', (field, form1) => {
  160. const value = field.value;
  161. // 判断provider
  162. if (!value) return;
  163. switch (form1.values.provider) {
  164. case 'corpMessage':
  165. form1.setFieldState('template.toUser', async (state8) => {
  166. state8.dataSource = await getWeixinUser(value);
  167. });
  168. form1.setFieldState('template.toParty', async (state9) => {
  169. state9.dataSource = await getWeixinDept(value);
  170. });
  171. form1.setFieldState('template.toTag', async (state10) => {
  172. state10.dataSource = await getWeixinTags(value);
  173. });
  174. break;
  175. case 'officialMessage':
  176. form1.setFieldState('template.tagid', async (state1) => {
  177. state1.dataSource = await getWeixinOfficialTags(value);
  178. });
  179. form1.setFieldState('template.wxTemplateId', async (state2) => {
  180. const list = await getWeixinOfficialTemplates(value);
  181. Store.set('wxTemplate', list);
  182. state2.dataSource = list;
  183. });
  184. break;
  185. case 'dingTalkMessage':
  186. form1.setFieldState('template.userIdList', async (state3) => {
  187. state3.dataSource = await getDingTalkUser(value);
  188. });
  189. form1.setFieldState('template.departmentIdList', async (state4) => {
  190. const list = await getDingTalkDept(value);
  191. Store.set('wxTemplate', list);
  192. state4.dataSource = list;
  193. });
  194. break;
  195. case 'aliyun':
  196. // 阿里云语音
  197. form1.setFieldState('template.ttsCode', async (state5) => {
  198. const list = await getAliyunTemplates(value);
  199. Store.set('AliyunTemplate', list);
  200. state5.dataSource = list;
  201. });
  202. break;
  203. case 'aliyunSms':
  204. // 阿里云短信
  205. form1.setFieldState('template.code', async (state6) => {
  206. const list = await getAliyunTemplates(value);
  207. Store.set('AliyunTemplate', list);
  208. state6.dataSource = list;
  209. });
  210. form1.setFieldState('template.signName', async (state7) => {
  211. // const list =
  212. // Store.set('AliyunTemplate', list);
  213. state7.dataSource = await getAliyunSigns(value);
  214. });
  215. break;
  216. default:
  217. break;
  218. }
  219. });
  220. onFieldValueChange('template.wxTemplateId', (field, form1) => {
  221. const value = field.value;
  222. // 处理消息模版。
  223. const template = Store.get('wxTemplate');
  224. const data = template?.find((i: { id: any }) => i.id === value);
  225. if (data) {
  226. form1.setFieldState('template.title', (state1) => {
  227. state1.value = data.title;
  228. state1.disabled = true;
  229. });
  230. form1.setFieldState('template.message', (state1) => {
  231. state1.value = data.content;
  232. state1.disabled = true;
  233. });
  234. }
  235. });
  236. onFieldValueChange('template.code', (field, form1) => {
  237. const value = field.value;
  238. const template = Store.get('AliyunTemplate');
  239. const data = template?.find((i: { templateCode: any }) => i.templateCode === value);
  240. if (data) {
  241. form1.setFieldState('template.message', (state1) => {
  242. state1.value = data.templateContent;
  243. state1.disabled = true;
  244. });
  245. }
  246. });
  247. onFieldValueChange('template.*(subject,markdown.title,link.title)', (field, form1) => {
  248. const value = (field as Field).value;
  249. const _message = field.query('template.message').value();
  250. const titleList =
  251. (typeof value === 'string' &&
  252. (value + _message)?.match(pattern)?.filter((i: string) => i)) ||
  253. // .map((item: string) => ({id: item, type: 'string', format: '--'}))) ||
  254. [];
  255. // 拼接message的内容
  256. form1.setFieldState('variableDefinitions', (state1) => {
  257. state1.visible = !!titleList && titleList.length > 0;
  258. });
  259. if (form1.modified) {
  260. const oldKey = variableDefinitionsRef.current?.map((i) => i.id);
  261. const newKey = [...new Set(titleList)];
  262. const _result = newKey.map((item) =>
  263. oldKey?.includes(item)
  264. ? variableDefinitionsRef.current?.find((i) => i.id === item)
  265. : {
  266. id: item,
  267. type: 'string',
  268. format: '%s',
  269. },
  270. );
  271. form1.setValuesIn('variableDefinitions', _result);
  272. }
  273. });
  274. onFieldValueChange('template.message', (field, form1) => {
  275. const _provider = field.query('provider').value();
  276. const value = (field as Field).value;
  277. const idList =
  278. (typeof value === 'string' &&
  279. value
  280. ?.match(_provider === 'officialMessage' ? weixinPattern : pattern)
  281. ?.filter((i: string) => i)) ||
  282. [];
  283. if (id === 'email') {
  284. const subject = field.query('template.subject');
  285. const title = subject.value();
  286. const titleList = title?.match(pattern)?.filter((i: string) => i);
  287. // .map((item: string) => ({id: item, type: 'string', format: '--'}));
  288. if (idList && titleList?.length > 0) {
  289. idList.unshift(...titleList);
  290. }
  291. }
  292. if (_provider === 'dingTalkRobotWebHook') {
  293. const title = field.query('template.markdown.title').value();
  294. const titleList = title?.match(pattern)?.filter((i: string) => i);
  295. // .map((item: string) => ({id: item, type: 'string', format: '--'}));
  296. if (idList && titleList?.length > 0) {
  297. idList.unshift(...titleList);
  298. }
  299. }
  300. form1.setFieldState('variableDefinitions', (state1) => {
  301. state1.visible = !!idList && idList.length > 0;
  302. });
  303. if (form1.modified) {
  304. // 获取缓存的KEY;
  305. const oldKey = variableDefinitionsRef.current?.map((i) => i.id);
  306. const newKey = [...new Set(idList)];
  307. const _result = newKey.map((item) =>
  308. oldKey?.includes(item)
  309. ? variableDefinitionsRef.current?.find((i) => i.id === item)
  310. : {
  311. id: item,
  312. type: 'string',
  313. format: '%s',
  314. },
  315. );
  316. form1.setValuesIn('variableDefinitions', _result);
  317. }
  318. });
  319. onFieldValueChange('template.body', (field, form1) => {
  320. const value = (field as Field).value;
  321. console.log(value);
  322. const idList = value.match(pattern)?.filter((i: string) => i);
  323. form1.setFieldState('variableDefinitions', (state1) => {
  324. state1.visible = !!idList && idList.length > 0;
  325. });
  326. if (form1.modified) {
  327. // 获取缓存的KEY;
  328. const oldKey = variableDefinitionsRef.current?.map((i) => i.id);
  329. const newKey = [...new Set(idList)];
  330. const _result = newKey.map((item: any) =>
  331. oldKey?.includes(item)
  332. ? variableDefinitionsRef.current?.find((i) => i.id === item)
  333. : {
  334. id: item,
  335. type: 'string',
  336. format: '%s',
  337. },
  338. );
  339. form1.setValuesIn('variableDefinitions', _result);
  340. }
  341. });
  342. onFieldValueChange('variableDefinitions.*.*', (field) => {
  343. // 缓存编辑后的数据
  344. variableDefinitionsRef.current = field.query('variableDefinitions').value();
  345. });
  346. onFieldReact('variableDefinitions.*.type', (field) => {
  347. const value = (field as Field).value;
  348. const formatPath = FormPath.transform(
  349. field.path,
  350. /\d+/,
  351. (index) => `variableDefinitions.${parseInt(index)}.format`,
  352. );
  353. const format = field.query(formatPath).take() as any;
  354. const fieldModified = field && (field as Field).modified;
  355. if (!format) return;
  356. if (fieldModified) {
  357. format.setValue(undefined);
  358. }
  359. switch (value) {
  360. case 'date':
  361. format.setComponent(FAutoComplete);
  362. format.setDataSource([
  363. { label: 'timestamp', value: 'timestamp' },
  364. { label: 'yyyy-MM-dd', value: 'yyyy-MM-dd' },
  365. { label: 'yyyy-MM-dd HH:mm:ss', value: 'yyyy-MM-dd HH:mm:ss' },
  366. // { label: 'yyyy-MM-dd HH:mm:ss EE', value: 'yyyy-MM-dd HH:mm:ss EE' },
  367. // { label: 'yyyy-MM-dd HH:mm:ss zzz', value: 'yyyy-MM-dd HH:mm:ss zzz' },
  368. ]);
  369. if (fieldModified) {
  370. format.setValue('timestamp');
  371. }
  372. break;
  373. case 'string':
  374. format.setComponent(PreviewText.Input);
  375. if (fieldModified) {
  376. format.setValue('%s');
  377. }
  378. break;
  379. case 'double':
  380. format.setComponent(Input);
  381. if (fieldModified) {
  382. format.setValue('%.0f');
  383. }
  384. break;
  385. // case 'file':
  386. // format.setComponent(Select);
  387. // format.setDataSource([
  388. // {label: '视频', value: 'video'},
  389. // {label: '图片', value: 'img'},
  390. // {label: '全部', value: 'any'},
  391. // ]);
  392. // format.setValue('any');
  393. // break;
  394. // case 'other':
  395. // format.setComponent(PreviewText.Input);
  396. // format.setValue('--');
  397. // break;
  398. }
  399. });
  400. onFieldValueChange('template.templateType', (field, form1) => {
  401. const value = (field as Field).value;
  402. // console.log(value,'11111')
  403. if (value === 'tts') {
  404. form1.setFieldState('template.message', (state1) => {
  405. state1.disabled = false;
  406. state1.hidden = false;
  407. });
  408. }
  409. });
  410. },
  411. }),
  412. [id],
  413. );
  414. useEffect(() => {
  415. setTimeout(() => {
  416. if (initialState?.settings?.title) {
  417. document.title = `通知模板 - ${initialState?.settings?.title}`;
  418. } else {
  419. document.title = '通知模板';
  420. }
  421. }, 0);
  422. if (state.current) {
  423. form.setValues(state.current);
  424. }
  425. }, []);
  426. const SchemaField = createSchemaField({
  427. components: {
  428. FormItem,
  429. Input,
  430. Select,
  431. Switch,
  432. Radio,
  433. Editable,
  434. PreviewText,
  435. Space,
  436. FUpload,
  437. NumberPicker,
  438. FBraftEditor,
  439. ArrayItems,
  440. FormGrid,
  441. ArrayTable,
  442. FAutoComplete,
  443. FMonacoEditor,
  444. },
  445. });
  446. const handleSave = async () => {
  447. const data: TemplateItem = await form.submit();
  448. // dingTalkRobotWebHook
  449. // 提交的时候处理内容
  450. // 钉钉机器人-->dingTalkRobotWebHook
  451. // r如果是text 的话。template.message=>template.text.content
  452. // 如果是markdown 的话。 template.message=>template.markdown.text
  453. // 如果是link的话。 template.message =>template.markdown.text
  454. // 微信服务号: template.message =>template.content
  455. if (data.provider === 'dingTalkRobotWebHook') {
  456. const type = data.template.messageType;
  457. // emplate.messageType
  458. switch (type) {
  459. case 'text':
  460. data.template.text = {
  461. content: data.template.message,
  462. };
  463. // data.template.text.content = data.template.message;
  464. break;
  465. case 'markdown':
  466. data.template.markdown.text = data.template.message;
  467. break;
  468. case 'link':
  469. data.template.link.text = data.template.message;
  470. }
  471. }
  472. if (id === 'email') {
  473. data.provider = 'embedded';
  474. data.template.text = data.template.message;
  475. }
  476. let response;
  477. if (data.id) {
  478. response = await service.update(data);
  479. } else {
  480. response = await service.save(data);
  481. }
  482. if (response?.status === 200) {
  483. onlyMessage('保存成功');
  484. history.back();
  485. }
  486. };
  487. registerValidateRules({
  488. batchCheckEmail(value) {
  489. const regEmail = /^([A-Za-z0-9_\-\.])+@[a-zA-Z0-9]+\.([a-zA-Z]{2,4})$/;
  490. let error;
  491. if (value) {
  492. value.some((item: string) => {
  493. if (!regEmail.test(item)) {
  494. error = item;
  495. return true;
  496. }
  497. return false;
  498. });
  499. }
  500. return error ? `${error}邮件格式错误` : '';
  501. },
  502. });
  503. const schema: ISchema = {
  504. type: 'object',
  505. properties: {
  506. name: {
  507. title: '名称',
  508. type: 'string',
  509. 'x-decorator': 'FormItem',
  510. 'x-component': 'Input',
  511. 'x-component-props': {
  512. placeholder: '请输入名称',
  513. },
  514. name: 'name',
  515. 'x-validator': [
  516. {
  517. max: 64,
  518. message: '最多可输入64个字符',
  519. },
  520. {
  521. required: true,
  522. message: '请输入名称',
  523. },
  524. ],
  525. },
  526. type: {
  527. title: '类型',
  528. 'x-value': id,
  529. 'x-hidden': true,
  530. },
  531. provider: {
  532. title: '类型',
  533. type: 'string',
  534. 'x-decorator': 'FormItem',
  535. 'x-component': 'Radio.Group',
  536. 'x-component-props': {
  537. optionType: 'button',
  538. placeholder: '请选择类型',
  539. },
  540. required: true,
  541. 'x-visible': typeList[id]?.length > 0,
  542. 'x-hidden': id === 'email' || id === 'webhook',
  543. 'x-value': typeList[id]?.[0]?.value,
  544. enum: typeList[id] || [],
  545. },
  546. configId: {
  547. title: '绑定配置',
  548. type: 'string',
  549. 'x-decorator': 'FormItem',
  550. 'x-component': 'Select',
  551. 'x-component-props': {
  552. placeholder: '请选择绑定配置',
  553. },
  554. required: true,
  555. 'x-decorator-props': {
  556. tooltip: '使用固定的通知配置来发送此通知模版',
  557. },
  558. 'x-visible': id !== 'email',
  559. },
  560. template: {
  561. type: 'object',
  562. properties: {
  563. weixin: {
  564. type: 'void',
  565. 'x-visible': id === 'weixin',
  566. properties: {
  567. corpMessage: {
  568. type: 'void',
  569. properties: {
  570. agentId: {
  571. title: 'AgentId',
  572. 'x-component': 'Input',
  573. 'x-decorator': 'FormItem',
  574. 'x-decorator-props': {
  575. tooltip: '应用唯一标识',
  576. },
  577. required: true,
  578. 'x-component-props': {
  579. placeholder: '请输入AgentID',
  580. },
  581. 'x-validator': [
  582. {
  583. max: 64,
  584. message: '最多可输入64个字符',
  585. },
  586. ],
  587. },
  588. layout: {
  589. type: 'void',
  590. 'x-decorator': 'FormGrid',
  591. 'x-decorator-props': {
  592. maxColumns: 2,
  593. minColumns: 2,
  594. },
  595. properties: {
  596. toUser: {
  597. title: '收信人',
  598. 'x-component': 'Select',
  599. 'x-decorator': 'FormItem',
  600. 'x-decorator-props': {
  601. tooltip: '如果不填写该字段,将在使用此模版发送通知时进行指定。',
  602. gridSpan: 1,
  603. },
  604. 'x-component-props': {
  605. placeholder: '请选择收信人',
  606. },
  607. },
  608. toParty: {
  609. title: '收信部门',
  610. 'x-component': 'Select',
  611. 'x-decorator': 'FormItem',
  612. // 'x-decorator-props': {
  613. // tooltip: '如果不填写该字段,将在使用此模版发送通知时进行指定。',
  614. // gridSpan: 1,
  615. // },
  616. 'x-component-props': {
  617. placeholder: '请选择收信部门',
  618. },
  619. },
  620. },
  621. },
  622. toTag: {
  623. title: '标签推送',
  624. 'x-component': 'Select',
  625. 'x-decorator': 'FormItem',
  626. 'x-decorator-props': {
  627. tooltip:
  628. '本企业微信的标签ID列表,最多支持100个,如果不填写该字段,将在使用此模版发送通知时进行指定',
  629. },
  630. 'x-component-props': {
  631. placeholder: '请选择标签推送,多个标签用,号分隔',
  632. },
  633. },
  634. },
  635. 'x-reactions': {
  636. dependencies: ['provider'],
  637. fulfill: {
  638. state: {
  639. visible: '{{$deps[0]==="corpMessage"}}',
  640. },
  641. },
  642. },
  643. },
  644. officialMessage: {
  645. type: 'void',
  646. properties: {
  647. tagid: {
  648. title: '用户标签',
  649. type: 'string',
  650. 'x-decorator': 'FormItem',
  651. 'x-component': 'Select',
  652. 'x-component-props': {
  653. placeholder: '请选择用户标签',
  654. },
  655. 'x-decorator-props': {
  656. tooltip: '如果不填写该字段,将在使用此模板发送通知时进行指定',
  657. },
  658. },
  659. layout: {
  660. type: 'void',
  661. 'x-decorator': 'FormGrid',
  662. 'x-decorator-props': {
  663. maxColumns: 2,
  664. minColumns: 2,
  665. },
  666. properties: {
  667. wxTemplateId: {
  668. title: '消息模版',
  669. type: 'string',
  670. 'x-decorator': 'FormItem',
  671. 'x-component': 'Select',
  672. 'x-component-props': {
  673. placeholder: '请选择消息模版',
  674. },
  675. required: true,
  676. 'x-decorator-props': {
  677. gridSpan: 1,
  678. tooltip: '微信公众号中配置的消息模版',
  679. },
  680. },
  681. url: {
  682. title: '模版跳转链接',
  683. type: 'string',
  684. 'x-decorator': 'FormItem',
  685. 'x-component': 'Input',
  686. 'x-component-props': {
  687. placeholder: '请输入模版跳转链接',
  688. },
  689. 'x-decorator-props': {
  690. gridSpan: 1,
  691. tooltip: '用于点击消息后进行页面跳转',
  692. },
  693. },
  694. },
  695. },
  696. toMiniProgram: {
  697. title: '跳转小程序',
  698. type: 'string',
  699. 'x-decorator': 'FormItem',
  700. 'x-component': 'Radio.Group',
  701. 'x-component-props': {
  702. // optionType: 'button'
  703. },
  704. 'x-decorator-props': {
  705. tooltip: '配置后点击通知消息将跳转到对应小程序',
  706. },
  707. default: false,
  708. enum: [
  709. { label: '是', value: true },
  710. { label: '否', value: false },
  711. ],
  712. },
  713. miniProgram: {
  714. type: 'void',
  715. properties: {
  716. layout: {
  717. type: 'void',
  718. 'x-decorator': 'FormGrid',
  719. 'x-decorator-props': {
  720. maxColumns: 2,
  721. minColumns: 2,
  722. },
  723. properties: {
  724. miniProgramId: {
  725. title: '跳转小程序AppId',
  726. type: 'string',
  727. 'x-decorator': 'FormItem',
  728. 'x-component': 'Input',
  729. 'x-component-props': {
  730. placeholder: '请输入跳转小程序AppId',
  731. },
  732. 'x-decorator-props': {
  733. gridSpan: 1,
  734. tooltip: '小程序唯一性id',
  735. },
  736. },
  737. miniProgramPath: {
  738. title: '跳转小程序具体路径',
  739. type: 'string',
  740. 'x-decorator': 'FormItem',
  741. 'x-component': 'Input',
  742. 'x-component-props': {
  743. placeholder: '请输入跳转小程序具体路径',
  744. },
  745. 'x-decorator-props': {
  746. gridSpan: 1,
  747. tooltip: '用于点击消息之后跳转到小程序的具体页面',
  748. },
  749. },
  750. },
  751. },
  752. },
  753. 'x-reactions': {
  754. dependencies: ['.toMiniProgram'],
  755. fulfill: {
  756. state: {
  757. visible: '{{$deps[0]===true}}',
  758. },
  759. },
  760. },
  761. },
  762. title: {
  763. title: '模版标题',
  764. type: 'string',
  765. 'x-decorator': 'FormItem',
  766. 'x-component': 'Input',
  767. 'x-component-props': {
  768. placeholder: '这里是回显内容',
  769. },
  770. 'x-decorator-props': {
  771. tooltip: '服务号消息模版标题',
  772. },
  773. 'x-disabled': true,
  774. 'x-validator': [
  775. {
  776. max: 64,
  777. message: '最多可输入64个字符',
  778. },
  779. ],
  780. },
  781. },
  782. 'x-reactions': {
  783. dependencies: ['provider'],
  784. fulfill: {
  785. state: {
  786. visible: '{{$deps[0]==="officialMessage"}}',
  787. },
  788. },
  789. },
  790. },
  791. },
  792. },
  793. dingTalk: {
  794. type: 'void',
  795. 'x-visible': id === 'dingTalk',
  796. properties: {
  797. dingTalkMessage: {
  798. type: 'void',
  799. properties: {
  800. agentId: {
  801. title: 'AgentID',
  802. required: true,
  803. 'x-component': 'Input',
  804. 'x-decorator': 'FormItem',
  805. 'x-decorator-props': {
  806. tooltip: '应用唯一标识',
  807. },
  808. 'x-component-props': {
  809. placeholder: '请输入AgentID',
  810. },
  811. 'x-validator': [
  812. {
  813. max: 64,
  814. message: '最多可输入64个字符',
  815. },
  816. ],
  817. },
  818. layout: {
  819. type: 'void',
  820. 'x-decorator': 'FormGrid',
  821. 'x-decorator-props': {
  822. maxColumns: 2,
  823. minColumns: 2,
  824. },
  825. properties: {
  826. departmentIdList: {
  827. title: '收信部门',
  828. // required: true,
  829. 'x-component': 'Select',
  830. 'x-decorator': 'FormItem',
  831. // 'x-decorator-props': {
  832. // tooltip: '如果不填写该字段,将在使用此模板发送通知时进行指定',
  833. // gridSpan: 1,
  834. // },
  835. 'x-component-props': {
  836. placeholder: '请选择收信部门',
  837. },
  838. // 'x-reactions': {
  839. // dependencies: ['configId'],
  840. // fulfill: {
  841. // run: '{{useAsyncDataSource(getDingTalkDept($deps[0]))}}',
  842. // },
  843. // },
  844. },
  845. userIdList: {
  846. title: '收信人',
  847. 'x-component': 'Select',
  848. 'x-decorator': 'FormItem',
  849. 'x-decorator-props': {
  850. tooltip: '如果不填写该字段,将在使用此模板发送通知时进行指定',
  851. gridSpan: 1,
  852. },
  853. 'x-component-props': {
  854. placeholder: '请选择收信人',
  855. },
  856. // 'x-reactions': {
  857. // dependencies: ['configId'],
  858. // fulfill: {
  859. // run: '{{useAsyncDataSource(getDingTalkUser($deps[0]))}}',
  860. // },
  861. // },
  862. },
  863. },
  864. },
  865. },
  866. 'x-reactions': {
  867. dependencies: ['provider'],
  868. fulfill: {
  869. state: {
  870. visible: '{{$deps[0]==="dingTalkMessage"}}',
  871. },
  872. },
  873. },
  874. },
  875. dingTalkRobotWebHook: {
  876. type: 'void',
  877. properties: {
  878. messageType: {
  879. title: '消息类型',
  880. 'x-component': 'Select',
  881. 'x-decorator': 'FormItem',
  882. required: true,
  883. 'x-component-props': {
  884. placeholder: '请选择消息类型',
  885. },
  886. enum: [
  887. { label: 'markdown', value: 'markdown' },
  888. { label: 'text', value: 'text' },
  889. { label: 'link', value: 'link' },
  890. ],
  891. },
  892. markdown: {
  893. type: 'object',
  894. properties: {
  895. title: {
  896. required: true,
  897. title: '标题',
  898. 'x-component': 'Input',
  899. 'x-decorator': 'FormItem',
  900. 'x-component-props': {
  901. placeholder: '请输入标题',
  902. },
  903. 'x-validator': [
  904. {
  905. max: 64,
  906. message: '最多可输入64个字符',
  907. },
  908. ],
  909. },
  910. },
  911. 'x-reactions': {
  912. dependencies: ['.messageType'],
  913. fulfill: {
  914. state: {
  915. visible: '{{$deps[0]==="markdown"}}',
  916. },
  917. },
  918. },
  919. },
  920. link: {
  921. type: 'object',
  922. properties: {
  923. title: {
  924. required: true,
  925. title: '标题',
  926. 'x-component': 'Input',
  927. 'x-decorator': 'FormItem',
  928. 'x-component-props': {
  929. placeholder: '请输入标题',
  930. },
  931. 'x-validator': [
  932. {
  933. max: 64,
  934. message: '最多可输入64个字符',
  935. },
  936. ],
  937. },
  938. '{url:picUrl}': {
  939. title: '图片链接',
  940. 'x-component': 'FUpload',
  941. 'x-decorator': 'FormItem',
  942. 'x-component-props': {
  943. type: 'file',
  944. placeholder: '请输入图片链接',
  945. },
  946. },
  947. messageUrl: {
  948. title: '内容链接',
  949. 'x-component': 'Input',
  950. 'x-decorator': 'FormItem',
  951. 'x-component-props': {
  952. placeholder: '请输入内容链接',
  953. },
  954. },
  955. },
  956. 'x-reactions': {
  957. dependencies: ['.messageType'],
  958. fulfill: {
  959. state: {
  960. visible: '{{$deps[0]==="link"}}',
  961. },
  962. },
  963. },
  964. },
  965. },
  966. 'x-reactions': {
  967. dependencies: ['provider'],
  968. fulfill: {
  969. state: {
  970. visible: '{{$deps[0]==="dingTalkRobotWebHook"}}',
  971. },
  972. },
  973. },
  974. },
  975. },
  976. // 钉钉群机器人配置参数名 类型 说明
  977. // messageType String 钉钉-消息类型 markdown、text、link
  978. // ${messageType} String 钉钉-内容
  979. },
  980. aliyun: {
  981. type: 'void',
  982. properties: {
  983. voice: {
  984. 'x-visible': id === 'voice',
  985. type: 'void',
  986. properties: {
  987. templateType: {
  988. title: '类型',
  989. required: true,
  990. 'x-component': 'Select',
  991. 'x-decorator': 'FormItem',
  992. 'x-decorator-props': {
  993. tooltip: '语音验证码类型可配置变量,并且只支持数字和英文字母',
  994. },
  995. 'x-component-props': {
  996. placeholder: '请选择类型',
  997. },
  998. enum: [
  999. { label: '语音通知', value: 'voice' },
  1000. { label: '语音验证码', value: 'tts' },
  1001. ],
  1002. },
  1003. layout: {
  1004. type: 'void',
  1005. 'x-decorator': 'FormGrid',
  1006. 'x-decorator-props': {
  1007. maxColumns: 2,
  1008. minColumns: 2,
  1009. },
  1010. properties: {
  1011. templateCode: {
  1012. title: '模版ID',
  1013. 'x-component': 'Input',
  1014. 'x-decorator': 'FormItem',
  1015. 'x-decorator-props': {
  1016. tooltip: '阿里云内部分配的唯一ID标识',
  1017. gridSpan: 1,
  1018. },
  1019. required: true,
  1020. 'x-component-props': {
  1021. placeholder: '请输入模版ID',
  1022. },
  1023. },
  1024. ttsCode: {
  1025. title: '模版ID',
  1026. 'x-component': 'Input',
  1027. 'x-decorator': 'FormItem',
  1028. 'x-hidden': true,
  1029. 'x-reactions': {
  1030. dependencies: ['.templateCode'],
  1031. fulfill: {
  1032. state: {
  1033. value: '{{$deps[0]}}',
  1034. },
  1035. },
  1036. },
  1037. },
  1038. calledNumber: {
  1039. title: '被叫号码',
  1040. 'x-component': 'Input',
  1041. 'x-decorator': 'FormItem',
  1042. 'x-decorator-props': {
  1043. tooltip: '仅支持中国大陆号码',
  1044. gridSpan: 1,
  1045. },
  1046. 'x-component-props': {
  1047. placeholder: '请输入被叫号码',
  1048. },
  1049. 'x-validator': [
  1050. {
  1051. max: 64,
  1052. message: '最多可输入64个字符',
  1053. },
  1054. {
  1055. validator: (value: string) => {
  1056. return new Promise((resolve) => {
  1057. if (!value) resolve('');
  1058. if (!phoneRegEx(value)) {
  1059. resolve('请输入有效号码');
  1060. }
  1061. resolve('');
  1062. });
  1063. },
  1064. },
  1065. ],
  1066. },
  1067. },
  1068. },
  1069. calledShowNumbers: {
  1070. title: '被叫显号',
  1071. 'x-component': 'Input',
  1072. 'x-decorator': 'FormItem',
  1073. 'x-decorator-props': {
  1074. tooltip: '必须是已购买的号码,用于呼叫号码显示',
  1075. },
  1076. 'x-component-props': {
  1077. placeholder: '请输入被叫显号',
  1078. },
  1079. 'x-validator': [
  1080. {
  1081. max: 64,
  1082. message: '最多可输入64个字符',
  1083. },
  1084. {
  1085. validator: (value: string) => {
  1086. return new Promise((resolve) => {
  1087. if (!value) resolve('');
  1088. if (!phoneRegEx(value)) {
  1089. resolve('请输入有效号码');
  1090. }
  1091. resolve('');
  1092. });
  1093. },
  1094. },
  1095. ],
  1096. },
  1097. PlayTimes: {
  1098. title: '播放次数',
  1099. 'x-component': 'NumberPicker',
  1100. 'x-decorator': 'FormItem',
  1101. 'x-decorator-props': {
  1102. tooltip: '语音文件的播放次数',
  1103. },
  1104. default: 1,
  1105. 'x-validator': [
  1106. {
  1107. min: 1,
  1108. max: 3,
  1109. message: '仅支持1~3次',
  1110. },
  1111. ],
  1112. 'x-component-props': {
  1113. placeholder: '请输入播放次数',
  1114. },
  1115. },
  1116. },
  1117. },
  1118. sms: {
  1119. 'x-visible': id === 'sms',
  1120. type: 'void',
  1121. properties: {
  1122. layout: {
  1123. type: 'void',
  1124. 'x-decorator': 'FormGrid',
  1125. 'x-decorator-props': {
  1126. maxColumns: 2,
  1127. minColumns: 2,
  1128. },
  1129. properties: {
  1130. code: {
  1131. title: '模版',
  1132. required: true,
  1133. 'x-component': 'Select',
  1134. 'x-decorator': 'FormItem',
  1135. 'x-decorator-props': {
  1136. tooltip: '阿里云短信平台自定义的模版名称',
  1137. gridSpan: 1,
  1138. },
  1139. 'x-component-props': {
  1140. placeholder: '请选择模版',
  1141. },
  1142. 'x-reactions': {
  1143. dependencies: ['configId'],
  1144. fulfill: {
  1145. run: '{{useAsyncDataSource(getAliyunTemplates($deps[0]))}}',
  1146. },
  1147. },
  1148. },
  1149. phoneNumber: {
  1150. title: '收信人',
  1151. 'x-component': 'Input',
  1152. 'x-decorator': 'FormItem',
  1153. 'x-decorator-props': {
  1154. tooltip: '仅支持中国大陆号码',
  1155. gridSpan: 1,
  1156. },
  1157. 'x-validator': ['phone'],
  1158. 'x-component-props': {
  1159. placeholder: '请输入收信人',
  1160. },
  1161. },
  1162. },
  1163. },
  1164. signName: {
  1165. title: '签名',
  1166. required: true,
  1167. 'x-component': 'Select',
  1168. 'x-decorator': 'FormItem',
  1169. 'x-decorator-props': {
  1170. tooltip: '用于短信内容签名信息显示',
  1171. },
  1172. 'x-component-props': {
  1173. placeholder: '请输入签名',
  1174. },
  1175. 'x-reactions': {
  1176. dependencies: ['configId'],
  1177. fulfill: {
  1178. run: '{{useAsyncDataSource(getAliyunSigns($deps[0]))}}',
  1179. },
  1180. },
  1181. },
  1182. },
  1183. },
  1184. },
  1185. },
  1186. email: {
  1187. type: 'void',
  1188. 'x-visible': id === 'email',
  1189. properties: {
  1190. subject: {
  1191. 'x-component': 'Input',
  1192. 'x-decorator': 'FormItem',
  1193. title: '标题',
  1194. 'x-decorator-props': {
  1195. tooltip: '邮件标题',
  1196. },
  1197. required: true,
  1198. 'x-component-props': {
  1199. placeholder: '请输入标题',
  1200. },
  1201. 'x-validator': [
  1202. {
  1203. max: 64,
  1204. message: '最多可输入64个字符',
  1205. },
  1206. ],
  1207. },
  1208. sendTo: {
  1209. 'x-component': 'Select',
  1210. 'x-decorator': 'FormItem',
  1211. title: '收件人',
  1212. 'x-decorator-props': {
  1213. tooltip: '多个收件人用换行分隔 \n最大支持1000个号码',
  1214. },
  1215. 'x-component-props': {
  1216. mode: 'tags',
  1217. placeholder: '请输入收件人邮箱,多个收件人用换行分隔',
  1218. },
  1219. 'x-validator': {
  1220. batchCheckEmail: true,
  1221. },
  1222. },
  1223. attachments: {
  1224. type: 'array',
  1225. title: '附件信息',
  1226. 'x-decorator': 'FormItem',
  1227. 'x-component': 'ArrayItems',
  1228. 'x-decorator-props': {
  1229. style: {
  1230. width: '100%',
  1231. },
  1232. tooltip: '附件只输入文件名称将在发送邮件时进行文件上传',
  1233. },
  1234. items: {
  1235. type: 'object',
  1236. 'x-decorator': 'FormGrid',
  1237. 'x-decorator-props': {
  1238. maxColumns: 24,
  1239. minColumns: 24,
  1240. },
  1241. properties: {
  1242. '{url:location,name:name}': {
  1243. 'x-component': 'FUpload',
  1244. 'x-decorator': 'FormItem',
  1245. 'x-decorator-props': {
  1246. style: {
  1247. width: '100%',
  1248. },
  1249. gridSpan: 23,
  1250. },
  1251. required: true,
  1252. 'x-component-props': {
  1253. type: 'file',
  1254. display: 'name',
  1255. placeholder: '请上传文件或输入文件名称',
  1256. },
  1257. },
  1258. remove: {
  1259. type: 'void',
  1260. 'x-decorator': 'FormItem',
  1261. 'x-component': 'ArrayItems.Remove',
  1262. 'x-decorator-props': {
  1263. gridSpan: 1,
  1264. },
  1265. },
  1266. },
  1267. },
  1268. properties: {
  1269. add: {
  1270. type: 'void',
  1271. 'x-component': 'ArrayItems.Addition',
  1272. title: '添加附件',
  1273. },
  1274. },
  1275. },
  1276. },
  1277. },
  1278. webhook: {
  1279. type: 'void',
  1280. 'x-visible': id === 'webhook',
  1281. properties: {
  1282. contextAsBody: {
  1283. title: '请求体',
  1284. type: 'boolean',
  1285. 'x-component': 'Radio.Group',
  1286. 'x-decorator': 'FormItem',
  1287. default: true,
  1288. enum: [
  1289. { label: '默认', value: true },
  1290. { label: '自定义', value: false },
  1291. ],
  1292. },
  1293. body: {
  1294. 'x-decorator': 'FormItem',
  1295. 'x-component': 'FMonacoEditor',
  1296. required: true,
  1297. 'x-component-props': {
  1298. height: 250,
  1299. theme: 'vs',
  1300. language: 'json',
  1301. editorDidMount: (editor1: any) => {
  1302. editor1.onDidScrollChange?.(() => {
  1303. editor1.getAction('editor.action.formatDocument').run();
  1304. });
  1305. },
  1306. },
  1307. // 'x-decorator-props': {
  1308. // style: {
  1309. // zIndex: 9998,
  1310. // },
  1311. // },
  1312. 'x-reactions': {
  1313. dependencies: ['.contextAsBody'],
  1314. fulfill: {
  1315. state: {
  1316. visible: '{{$deps[0]===false}}',
  1317. },
  1318. },
  1319. },
  1320. },
  1321. defaultBody: {
  1322. 'x-decorator': 'FormItem',
  1323. 'x-component': 'Input.TextArea',
  1324. 'x-component-props': {
  1325. rows: 3,
  1326. placeholder: '请求体中的数据来自于发送通知时指定的所有变量',
  1327. },
  1328. 'x-disabled': true,
  1329. 'x-reactions': {
  1330. dependencies: ['.contextAsBody'],
  1331. fulfill: {
  1332. state: {
  1333. visible: '{{$deps[0]===true}}',
  1334. },
  1335. },
  1336. },
  1337. },
  1338. },
  1339. },
  1340. },
  1341. },
  1342. 'template.message': {
  1343. title: '模版内容',
  1344. 'x-component': 'Input.TextArea',
  1345. 'x-decorator': 'FormItem',
  1346. 'x-decorator-props': {
  1347. tooltip: '发送的内容,支持录入变量',
  1348. },
  1349. required: true,
  1350. 'x-reactions': {
  1351. dependencies: ['provider'],
  1352. fulfill: {
  1353. state: {
  1354. hidden: '{{$deps[0]==="aliyun"||$deps[0]==="http"}}',
  1355. disabled: '{{["aliyunSms","aliyun"].includes($deps[0])}}',
  1356. },
  1357. },
  1358. },
  1359. 'x-component-props': {
  1360. rows: 5,
  1361. placeholder: '变量格式:${name};\n 示例:尊敬的${name},${time}有设备触发告警,请注意处理',
  1362. },
  1363. 'x-validator': [
  1364. {
  1365. max: 500,
  1366. message: '最多可输入500个字符',
  1367. },
  1368. ],
  1369. },
  1370. variableDefinitions: {
  1371. type: 'array',
  1372. title: '变量列表',
  1373. 'x-decorator': 'FormItem',
  1374. 'x-component': 'ArrayTable',
  1375. 'x-component-props': {
  1376. pagination: { pageSize: 9999 },
  1377. scroll: { x: '100%' },
  1378. },
  1379. 'x-decorator-props': {
  1380. style: {
  1381. zIndex: 999,
  1382. },
  1383. },
  1384. 'x-visible': false,
  1385. items: {
  1386. type: 'object',
  1387. properties: {
  1388. column1: {
  1389. type: 'void',
  1390. 'x-component': 'ArrayTable.Column',
  1391. 'x-component-props': { title: '变量', width: '120px' },
  1392. properties: {
  1393. id: {
  1394. type: 'string',
  1395. 'x-decorator': 'FormItem',
  1396. 'x-component': 'PreviewText.Input',
  1397. 'x-disabled': true,
  1398. },
  1399. },
  1400. },
  1401. column2: {
  1402. type: 'void',
  1403. 'x-component': 'ArrayTable.Column',
  1404. 'x-component-props': { title: '名称', minWidth: '120px' },
  1405. properties: {
  1406. name: {
  1407. type: 'string',
  1408. 'x-decorator': 'FormItem',
  1409. required: true,
  1410. 'x-component': 'Input',
  1411. 'x-component-props': {
  1412. style: {
  1413. width: 100,
  1414. },
  1415. },
  1416. 'x-validator': [
  1417. {
  1418. max: 64,
  1419. message: '最多可输入64个字符',
  1420. },
  1421. ],
  1422. },
  1423. },
  1424. },
  1425. column3: {
  1426. type: 'void',
  1427. 'x-component': 'ArrayTable.Column',
  1428. 'x-component-props': { title: '类型', width: '120px' },
  1429. properties: {
  1430. type: {
  1431. type: 'string',
  1432. 'x-decorator': 'FormItem',
  1433. 'x-component': 'Select',
  1434. required: true,
  1435. enum: [
  1436. { label: '字符串', value: 'string' },
  1437. { label: '时间', value: 'date' },
  1438. { label: '数字', value: 'double' },
  1439. ],
  1440. },
  1441. },
  1442. },
  1443. column4: {
  1444. type: 'void',
  1445. 'x-component': 'ArrayTable.Column',
  1446. 'x-component-props': { title: '格式', width: '300px' },
  1447. required: true,
  1448. properties: {
  1449. format: {
  1450. type: 'string',
  1451. 'x-decorator': 'FormItem',
  1452. 'x-component': 'Input',
  1453. 'x-reactions': {
  1454. dependencies: ['.type'],
  1455. when: "{{$deps[0]!=='string'}}",
  1456. fulfill: {
  1457. schema: {
  1458. 'x-component-props': {
  1459. suffix: (
  1460. <Tooltip title="格式为:%.xf x代表数字保留的小数位数。当x=0时,代表格式为整数">
  1461. <QuestionCircleOutlined />
  1462. </Tooltip>
  1463. ),
  1464. },
  1465. },
  1466. },
  1467. otherwise: {
  1468. schema: {
  1469. 'x-component-props.suffix': '',
  1470. },
  1471. },
  1472. },
  1473. },
  1474. },
  1475. },
  1476. },
  1477. },
  1478. },
  1479. description: {
  1480. title: '说明',
  1481. 'x-decorator': 'FormItem',
  1482. 'x-component': 'Input.TextArea',
  1483. 'x-component-props': {
  1484. rows: 4,
  1485. },
  1486. 'x-validator': [
  1487. {
  1488. max: 200,
  1489. message: '最多可输入200个字符',
  1490. },
  1491. ],
  1492. // 'x-decorator-props': {
  1493. // style: {
  1494. // zIndex: 998,
  1495. // },
  1496. // },
  1497. },
  1498. },
  1499. };
  1500. const { permission } = usePermissions('notice');
  1501. return (
  1502. <PageContainer>
  1503. <Card>
  1504. <Row>
  1505. <Col span={10}>
  1506. <Form className={styles.form} form={form} layout={'vertical'}>
  1507. <SchemaField
  1508. schema={schema}
  1509. scope={{
  1510. getConfig,
  1511. getDingTalkDept,
  1512. getDingTalkDeptTree,
  1513. getDingTalkUser,
  1514. getWeixinDept,
  1515. getWeixinTags,
  1516. getWeixinUser,
  1517. getAliyunSigns,
  1518. getAliyunTemplates,
  1519. useAsyncDataSource,
  1520. getWeixinOfficialTags,
  1521. getWeixinOfficialTemplates,
  1522. }}
  1523. />
  1524. <FormButtonGroup.Sticky>
  1525. <FormButtonGroup.FormItem>
  1526. <PermissionButton
  1527. type="primary"
  1528. isPermission={permission.add || permission.update}
  1529. onClick={handleSave}
  1530. >
  1531. 保存
  1532. </PermissionButton>
  1533. </FormButtonGroup.FormItem>
  1534. </FormButtonGroup.Sticky>
  1535. </Form>
  1536. </Col>
  1537. <Col span={12} push={2}>
  1538. {docMap?.[id]?.[provider]}
  1539. </Col>
  1540. </Row>
  1541. </Card>
  1542. </PageContainer>
  1543. );
  1544. });
  1545. export default Detail;