index.tsx 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965
  1. import { PermissionButton } from '@/components';
  2. import { PageContainer } from '@ant-design/pro-layout';
  3. import { Card, Col, Row, AutoComplete } from 'antd';
  4. import styles from './index.less';
  5. import {
  6. ArrayCollapse,
  7. Form,
  8. FormButtonGroup,
  9. FormItem,
  10. Input,
  11. Select,
  12. Radio,
  13. Checkbox,
  14. FormCollapse,
  15. FormGrid,
  16. Switch,
  17. TreeSelect,
  18. ArrayTable,
  19. } from '@formily/antd';
  20. import { TreeSelect as ATreeSelect } from 'antd';
  21. import { useEffect, useRef, useState } from 'react';
  22. import { createSchemaField } from '@formily/react';
  23. import { createForm, Field, onFieldReact, onFieldValueChange, onFormInit } from '@formily/core';
  24. import { onlyMessage, randomString, testIP, useAsyncDataSource } from '@/utils/util';
  25. import { service } from '../index';
  26. import { PlusOutlined } from '@ant-design/icons';
  27. import { action } from '@formily/reactive';
  28. import type { Response } from '@/utils/typings';
  29. import usePermissions from '@/hooks/permission';
  30. import { useHistory, useLocation } from '@/hooks';
  31. import { getMenuPathByCode } from '@/utils/menu';
  32. import MenuPage from '../Menu';
  33. import _ from 'lodash';
  34. import { UploadImage } from '@/components';
  35. const Save = () => {
  36. const location = useLocation();
  37. const history = useHistory();
  38. const { permission: rolePermission } = usePermissions('system/Role');
  39. const { permission: deptPermission } = usePermissions('system/Department');
  40. const { permission } = PermissionButton.usePermission('system/Apply');
  41. const [view, setView] = useState<boolean>(false);
  42. const [id, setId] = useState<string>('');
  43. const [visible, setVisiable] = useState<boolean>(false);
  44. const [detail, setDetail] = useState<any>({});
  45. const accessRef = useRef<any>([]);
  46. const provider1 = require('/public/images/apply/provider1.png');
  47. const provider2 = require('/public/images/apply/provider2.png');
  48. const provider3 = require('/public/images/apply/provider3.png');
  49. const provider4 = require('/public/images/apply/provider4.png');
  50. const provider5 = require('/public/images/apply/provider5.png');
  51. const providerType = new Map();
  52. providerType.set('internal-standalone', provider1); //内部独立
  53. providerType.set('internal-integrated', provider2); //内部集成
  54. providerType.set('dingtalk-ent-app', provider3); //钉钉
  55. providerType.set('wechat-webapp', provider4); //微信
  56. providerType.set('third-party', provider5); //三方
  57. const formCollapse = FormCollapse.createFormCollapse!();
  58. //接入方式
  59. const integrationModesList = [
  60. {
  61. label: '页面集成',
  62. value: 'page',
  63. },
  64. {
  65. label: 'API客户端',
  66. value: 'apiClient',
  67. },
  68. {
  69. label: 'API服务',
  70. value: 'apiServer',
  71. },
  72. {
  73. label: '单点登录',
  74. value: 'ssoClient',
  75. },
  76. ];
  77. const createImageLabel = (image: string, text: string) => {
  78. return (
  79. <div
  80. style={{ textAlign: 'center', marginTop: 10, fontSize: '14px', width: 115, height: 120 }}
  81. >
  82. <img height="64px" src={image} style={{ marginTop: 10 }} />
  83. <div
  84. style={{
  85. color: '#000000',
  86. marginTop: 5,
  87. }}
  88. >
  89. {text}
  90. </div>
  91. </div>
  92. );
  93. };
  94. const providerList = [
  95. {
  96. label: createImageLabel(providerType.get('internal-standalone'), '内部独立应用'),
  97. value: 'internal-standalone',
  98. },
  99. {
  100. label: createImageLabel(providerType.get('internal-integrated'), '内部集成应用'),
  101. value: 'internal-integrated',
  102. },
  103. {
  104. label: createImageLabel(providerType.get('wechat-webapp'), '微信网站应用'),
  105. value: 'wechat-webapp',
  106. },
  107. {
  108. label: createImageLabel(providerType.get('dingtalk-ent-app'), '钉钉企业内部应用'),
  109. value: 'dingtalk-ent-app',
  110. },
  111. {
  112. label: createImageLabel(providerType.get('third-party'), '第三方应用'),
  113. value: 'third-party',
  114. },
  115. ];
  116. const SchemaField = createSchemaField({
  117. components: {
  118. FormItem,
  119. Input,
  120. Select,
  121. Radio,
  122. Checkbox,
  123. ArrayCollapse,
  124. FormCollapse,
  125. FormGrid,
  126. Switch,
  127. TreeSelect,
  128. ArrayTable,
  129. AutoComplete,
  130. UploadImage,
  131. },
  132. });
  133. // const getProvidersAll = () => {
  134. // return service.getProvidersAll().then((res) => {
  135. // if (res.status === 200) {
  136. // return res.result.map((item: any) => ({
  137. // label: createImageLabel(providerType.get(item.provider), item.name),
  138. // value: item.provider,
  139. // }));
  140. // }
  141. // });
  142. // };
  143. const getRole = () => service.queryRoleList();
  144. const getOrg = () => service.queryOrgList();
  145. const useAsyncData = (api: any) => (fields: Field) => {
  146. fields.loading = true;
  147. api(fields).then(
  148. action.bound!((resp: Response<any>) => {
  149. fields.dataSource = resp.result?.map((item: Record<string, unknown>) => ({
  150. ...item,
  151. label: item.name,
  152. value: item.id,
  153. }));
  154. fields.loading = false;
  155. }),
  156. );
  157. };
  158. const form = createForm({
  159. validateFirst: true,
  160. effects() {
  161. onFormInit(async (formInit) => {
  162. if (!id) return;
  163. const resp = await service.detail(id);
  164. const integrationModes = resp.result.integrationModes.map((item: any) => item.value);
  165. // setAccess(integrationModes)
  166. accessRef.current = integrationModes;
  167. formInit.setInitialValues({
  168. ...resp.result,
  169. integrationModes,
  170. 'apiServer.appId': id,
  171. });
  172. });
  173. onFieldValueChange('provider', (field, form1) => {
  174. const value = field.value;
  175. // console.log(value);
  176. if (field.modified) {
  177. switch (value) {
  178. case 'internal-standalone':
  179. form1.setFieldState('integrationModes', (f1) => {
  180. f1.value = [];
  181. f1.dataSource = integrationModesList;
  182. });
  183. break;
  184. case 'internal-integrated':
  185. form1.setFieldState('integrationModes', (f2) => {
  186. f2.value = [];
  187. f2.dataSource = integrationModesList?.filter(
  188. (item) => item.value === 'apiClient' || item.value === 'page',
  189. );
  190. });
  191. break;
  192. case 'dingtalk-ent-app':
  193. form1.setFieldState('integrationModes', (f3) => {
  194. f3.value = ['ssoClient'];
  195. f3.dataSource = integrationModesList?.filter((item) => item.value === 'ssoClient');
  196. });
  197. break;
  198. case 'wechat-webapp':
  199. form1.setFieldState('integrationModes', (f4) => {
  200. f4.value = ['ssoClient'];
  201. f4.dataSource = integrationModesList?.filter((item) => item.value === 'ssoClient');
  202. });
  203. break;
  204. case 'third-party':
  205. form1.setFieldState('integrationModes', (f5) => {
  206. f5.value = [];
  207. f5.dataSource = integrationModesList;
  208. });
  209. break;
  210. default:
  211. break;
  212. }
  213. }
  214. });
  215. onFieldValueChange('integrationModes', (field, form2) => {
  216. const value = field.value;
  217. formCollapse.activeKeys = field.value;
  218. const modes = ['page', 'apiClient', 'apiServer', 'ssoClient'];
  219. const items = modes.concat(field.value).filter((item) => !value?.includes(item)); //未被选中
  220. // console.log(value);
  221. items.forEach((i) => {
  222. form2.setFieldState(`config.${i}`, (state) => {
  223. state.visible = false;
  224. });
  225. });
  226. field.value?.forEach((parms: any) => {
  227. form2.setFieldState(`config.${parms}`, (state) => {
  228. state.visible = true;
  229. });
  230. });
  231. });
  232. onFieldReact('apiClient.authConfig.oauth2.clientId', (field) => {
  233. if (id && accessRef.current?.includes('apiClient')) {
  234. field.componentProps = {
  235. disabled: true,
  236. };
  237. }
  238. });
  239. onFieldReact('apiServer.ipWhiteList', (field: any) => {
  240. const value = (field as Field).value;
  241. if (value) {
  242. const str = value?.split(/[\n,]/g).filter((i: any) => i && i.trim());
  243. const NoIP = str.find((item: any) => !testIP(item.replace(/\s*/g, '')));
  244. if (NoIP) {
  245. field.selfErrors = `[${NoIP}]不是正确的IP地址`;
  246. } else {
  247. field.selfErrors = '';
  248. }
  249. } else {
  250. field.selfErrors = '';
  251. }
  252. });
  253. },
  254. });
  255. const handleSave = async () => {
  256. const data: any = await form.submit();
  257. const list = integrationModesList.map((item) => item.value);
  258. _.difference(list, data.integrationModes).forEach((item) => {
  259. if (item === 'ssoClient') {
  260. delete data['sso'];
  261. }
  262. delete data[item];
  263. });
  264. //独立应用-api客户端 id?clientId:appId
  265. if (data.provider === 'internal-standalone') {
  266. if (data.integrationModes.includes('apiClient')) {
  267. data.id = data.apiClient.authConfig.oauth2.clientId;
  268. }
  269. if (
  270. data.integrationModes.includes('apiServer') &&
  271. !data.integrationModes.includes('apiClient')
  272. ) {
  273. data.id = data.apiServer.appId;
  274. }
  275. }
  276. //api客户端 accessTokenProperty grantType 默认参数
  277. // if(data.integrationModes.includes('apiClient')){
  278. // data.apiClient.authConfig.grantType='authorization_code'
  279. // data.apiClient.authConfig.accessTokenProperty='access_token'
  280. // }
  281. //独立应用,单点登录需要api配置和单点登录配置
  282. if (
  283. data.provider === 'internal-standalone' &&
  284. data.integrationModes.includes('ssoClient') &&
  285. data.integrationModes.length === 1
  286. ) {
  287. onlyMessage('配置单点登录需同时配置api配置', 'warning');
  288. } else {
  289. if (id) {
  290. const resp: any = await service.modify(id, data);
  291. if (resp.status === 200) {
  292. const isPage = data.integrationModes.includes('page');
  293. if (isPage) {
  294. setVisiable(true);
  295. setDetail(data);
  296. } else {
  297. onlyMessage('保存成功');
  298. const url = getMenuPathByCode('system/Apply');
  299. history.push(url);
  300. }
  301. }
  302. } else {
  303. const res: any = await service.save(data);
  304. if (res.status === 200) {
  305. const isPage = data.integrationModes.includes('page');
  306. if (isPage) {
  307. setVisiable(true);
  308. setDetail(data);
  309. } else {
  310. onlyMessage('保存成功');
  311. const url = getMenuPathByCode('system/Apply');
  312. history.push(url);
  313. }
  314. }
  315. }
  316. }
  317. // console.log(data);
  318. };
  319. //单点登录
  320. //独立应用
  321. const ssoStandalone = {
  322. 'sso.configuration.oAuth2.authorizationUrl': {
  323. type: 'string',
  324. title: '授权地址',
  325. 'x-decorator': 'FormItem',
  326. 'x-decorator-props': {
  327. gridSpan: 2,
  328. layout: 'vertical',
  329. labelAlign: 'left',
  330. },
  331. required: true,
  332. 'x-component': 'Input',
  333. 'x-component-props': {
  334. placeholder: '请输入授权地址',
  335. },
  336. 'x-reactions': {
  337. dependencies: ['integrationModes'],
  338. fulfill: {
  339. state: {
  340. visible: '{{$deps[0] && !$deps[0].includes("apiClient")}}',
  341. },
  342. },
  343. },
  344. },
  345. 'sso.configuration.oAuth2.redirectUri': {
  346. type: 'string',
  347. title: '回调地址',
  348. 'x-decorator': 'FormItem',
  349. 'x-decorator-props': {
  350. gridSpan: 2,
  351. layout: 'vertical',
  352. labelAlign: 'left',
  353. },
  354. // required: true,
  355. 'x-component': 'Input',
  356. 'x-component-props': {
  357. placeholder: '请输入回调地址',
  358. },
  359. 'x-reactions': {
  360. dependencies: ['integrationModes'],
  361. fulfill: {
  362. state: {
  363. visible: '{{$deps[0] && !$deps[0].includes("apiClient")}}',
  364. },
  365. },
  366. },
  367. },
  368. 'sso.configuration.oAuth2.clientId': {
  369. type: 'string',
  370. title: 'appId',
  371. 'x-decorator': 'FormItem',
  372. 'x-decorator-props': {
  373. gridSpan: 2,
  374. layout: 'vertical',
  375. labelAlign: 'left',
  376. },
  377. required: true,
  378. 'x-component': 'Input',
  379. 'x-component-props': {
  380. placeholder: '请输入appId',
  381. },
  382. 'x-reactions': {
  383. dependencies: ['integrationModes'],
  384. fulfill: {
  385. state: {
  386. visible: '{{$deps[0] && !$deps[0].includes("apiClient")}}',
  387. },
  388. },
  389. },
  390. },
  391. 'sso.configuration.oAuth2.clientSecret': {
  392. type: 'string',
  393. title: 'appKey',
  394. 'x-decorator': 'FormItem',
  395. 'x-decorator-props': {
  396. gridSpan: 2,
  397. layout: 'vertical',
  398. labelAlign: 'left',
  399. },
  400. required: true,
  401. 'x-component': 'Input',
  402. 'x-component-props': {
  403. placeholder: '请输入appKey',
  404. },
  405. 'x-reactions': {
  406. dependencies: ['integrationModes'],
  407. fulfill: {
  408. state: {
  409. visible: '{{$deps[0] && !$deps[0].includes("apiClient")}}',
  410. },
  411. },
  412. },
  413. },
  414. 'sso.autoCreateUser': {
  415. type: 'string',
  416. title: '自动创建用户',
  417. required: true,
  418. default: false,
  419. 'x-decorator': 'FormItem',
  420. 'x-decorator-props': {
  421. gridSpan: 2,
  422. layout: 'vertical',
  423. labelAlign: 'left',
  424. },
  425. 'x-component': 'Switch',
  426. },
  427. } as any;
  428. // 微信/钉钉
  429. const ssoConfig = {
  430. 'sso.configuration.appKey': {
  431. type: 'string',
  432. title: 'appKey',
  433. 'x-decorator': 'FormItem',
  434. 'x-decorator-props': {
  435. gridSpan: 2,
  436. layout: 'vertical',
  437. labelAlign: 'left',
  438. },
  439. 'x-reactions': {
  440. dependencies: ['provider'],
  441. fulfill: {
  442. state: {
  443. visible: '{{$deps[0]==="dingtalk-ent-app" }}',
  444. },
  445. },
  446. },
  447. required: true,
  448. 'x-component': 'Input',
  449. 'x-component-props': {
  450. placeholder: '请输入appKey',
  451. },
  452. },
  453. 'sso.configuration.appId': {
  454. type: 'string',
  455. title: 'appId',
  456. 'x-decorator': 'FormItem',
  457. 'x-decorator-props': {
  458. gridSpan: 2,
  459. layout: 'vertical',
  460. labelAlign: 'left',
  461. },
  462. required: true,
  463. 'x-component': 'Input',
  464. 'x-component-props': {
  465. placeholder: '请输入appId',
  466. },
  467. 'x-validator': [
  468. {
  469. max: 64,
  470. message: '最多可输入64个字符',
  471. },
  472. {
  473. required: true,
  474. message: '请输入appId',
  475. },
  476. ],
  477. 'x-reactions': {
  478. dependencies: ['provider'],
  479. fulfill: {
  480. state: {
  481. visible: '{{$deps[0]==="wechat-webapp"}}',
  482. },
  483. },
  484. },
  485. },
  486. 'sso.configuration.appSecret': {
  487. type: 'string',
  488. title: 'appSecret',
  489. 'x-decorator': 'FormItem',
  490. 'x-decorator-props': {
  491. gridSpan: 2,
  492. layout: 'vertical',
  493. labelAlign: 'left',
  494. },
  495. required: true,
  496. 'x-component': 'Input',
  497. 'x-component-props': {
  498. placeholder: '请输入appSecret',
  499. },
  500. 'x-validator': [
  501. {
  502. max: 64,
  503. message: '最多可输入64个字符',
  504. },
  505. {
  506. required: true,
  507. message: '请输入appSecret',
  508. },
  509. ],
  510. },
  511. 'sso.autoCreateUser': {
  512. type: 'string',
  513. title: '自动创建用户',
  514. required: true,
  515. default: false,
  516. 'x-decorator': 'FormItem',
  517. 'x-decorator-props': {
  518. gridSpan: 2,
  519. layout: 'vertical',
  520. labelAlign: 'left',
  521. },
  522. 'x-component': 'Switch',
  523. },
  524. } as any;
  525. //第三方平台
  526. const ssoThird = {
  527. 'sso.configuration.oauth2.type': {
  528. type: 'string',
  529. title: '认证方式',
  530. required: true,
  531. 'x-decorator': 'FormItem',
  532. 'x-decorator-props': {
  533. gridSpan: 2,
  534. layout: 'vertical',
  535. labelAlign: 'left',
  536. },
  537. 'x-component': 'Select',
  538. 'x-component-props': {
  539. placeholder: '请选择认证方式',
  540. },
  541. enum: [{ label: 'oauth2', value: 'oauth2' }],
  542. },
  543. 'sso.configuration.oauth2.scope': {
  544. type: 'string',
  545. title: 'scope',
  546. 'x-decorator': 'FormItem',
  547. 'x-decorator-props': {
  548. gridSpan: 2,
  549. layout: 'vertical',
  550. labelAlign: 'left',
  551. },
  552. 'x-component': 'Input',
  553. 'x-component-props': {
  554. placeholder: '请输入scope',
  555. },
  556. 'x-validator': [
  557. {
  558. max: 64,
  559. message: '最多可输入64个字符',
  560. },
  561. {
  562. required: true,
  563. message: '请输入scope',
  564. },
  565. ],
  566. },
  567. 'sso.configuration.oauth2.clientId': {
  568. type: 'string',
  569. title: 'client_id',
  570. required: true,
  571. 'x-decorator': 'FormItem',
  572. 'x-decorator-props': {
  573. gridSpan: 2,
  574. layout: 'vertical',
  575. labelAlign: 'left',
  576. },
  577. 'x-component': 'Input',
  578. 'x-component-props': {
  579. placeholder: '请输入client_id',
  580. },
  581. 'x-validator': [
  582. {
  583. max: 64,
  584. message: '最多可输入64个字符',
  585. },
  586. {
  587. required: true,
  588. message: '请输入client_id',
  589. },
  590. ],
  591. },
  592. 'sso.configuration.oauth2.clientSecret': {
  593. type: 'string',
  594. title: 'client_secret',
  595. required: true,
  596. 'x-decorator': 'FormItem',
  597. 'x-decorator-props': {
  598. gridSpan: 2,
  599. layout: 'vertical',
  600. labelAlign: 'left',
  601. },
  602. 'x-component': 'Input',
  603. 'x-component-props': {
  604. placeholder: '请输入client_secret',
  605. },
  606. 'x-validator': [
  607. {
  608. max: 64,
  609. message: '最多可输入64个字符',
  610. },
  611. {
  612. required: true,
  613. message: '请输入client_secret',
  614. },
  615. ],
  616. },
  617. 'sso.configuration.oauth2.authorizationUrl': {
  618. type: 'string',
  619. title: '授权地址',
  620. required: true,
  621. 'x-decorator': 'FormItem',
  622. 'x-decorator-props': {
  623. gridSpan: 2,
  624. layout: 'vertical',
  625. labelAlign: 'left',
  626. },
  627. 'x-component': 'Input',
  628. 'x-component-props': {
  629. placeholder: '请输入授权地址',
  630. },
  631. },
  632. 'sso.configuration.oauth2.tokenUrl': {
  633. type: 'string',
  634. title: 'token地址',
  635. required: true,
  636. 'x-decorator': 'FormItem',
  637. 'x-decorator-props': {
  638. gridSpan: 2,
  639. layout: 'vertical',
  640. labelAlign: 'left',
  641. },
  642. 'x-component': 'Input',
  643. 'x-component-props': {
  644. placeholder: '请输入token地址',
  645. },
  646. },
  647. 'sso.configuration.oauth2.logoUrl': {
  648. type: 'string',
  649. title: 'logo',
  650. 'x-decorator': 'FormItem',
  651. 'x-decorator-props': {
  652. gridSpan: 2,
  653. layout: 'vertical',
  654. labelAlign: 'left',
  655. },
  656. 'x-component': 'UploadImage',
  657. 'x-component-props': {
  658. errorMessage: '请上传.jpg.png.jfif.pjp.pjpeg.jpeg格式的图片',
  659. },
  660. },
  661. 'sso.configuration.oauth2.userInfoUrl': {
  662. type: 'string',
  663. title: '用户信息地址',
  664. required: true,
  665. 'x-decorator': 'FormItem',
  666. 'x-decorator-props': {
  667. gridSpan: 2,
  668. layout: 'vertical',
  669. labelAlign: 'left',
  670. },
  671. 'x-component': 'Input',
  672. 'x-component-props': {
  673. placeholder: '请输入用户信息地址',
  674. },
  675. },
  676. 'sso.configuration.oauth2.userProperty': {
  677. type: 'object',
  678. properties: {
  679. userId: {
  680. type: 'string',
  681. title: '用户ID',
  682. required: true,
  683. 'x-decorator': 'FormItem',
  684. 'x-decorator-props': {
  685. gridSpan: 2,
  686. layout: 'vertical',
  687. labelAlign: 'left',
  688. tooltip: '通过jsonpath表达式从授权结果中获取第三方平台用户的唯一标识',
  689. },
  690. 'x-component': 'Input',
  691. 'x-component-props': {
  692. placeholder: '输入从用户信息接口返回数据中的用户ID字段。示例:result.id',
  693. },
  694. },
  695. username: {
  696. type: 'string',
  697. title: '用户名',
  698. required: true,
  699. 'x-decorator': 'FormItem',
  700. 'x-decorator-props': {
  701. gridSpan: 2,
  702. layout: 'vertical',
  703. labelAlign: 'left',
  704. },
  705. 'x-component': 'Input',
  706. 'x-component-props': {
  707. placeholder: '输入从用户信息接口返回数据中的用户名字段。示例:result.name',
  708. },
  709. },
  710. avatar: {
  711. type: 'string',
  712. title: '头像',
  713. 'x-decorator': 'FormItem',
  714. 'x-decorator-props': {
  715. gridSpan: 2,
  716. layout: 'vertical',
  717. labelAlign: 'left',
  718. },
  719. 'x-component': 'Input',
  720. 'x-component-props': {
  721. placeholder: '输入从用户信息接口返回数据中的用户头像字段。示例:result.avatar',
  722. },
  723. },
  724. },
  725. },
  726. 'sso.autoCreateUser': {
  727. type: 'string',
  728. title: '自动创建用户',
  729. required: true,
  730. default: false,
  731. 'x-decorator': 'FormItem',
  732. 'x-decorator-props': {
  733. gridSpan: 2,
  734. layout: 'vertical',
  735. labelAlign: 'left',
  736. },
  737. 'x-component': 'Switch',
  738. 'x-component-props': {
  739. placeholder: '请输入',
  740. },
  741. },
  742. } as any;
  743. //内部独立应用-客户端
  744. const clientStandalone = {
  745. 'apiClient.baseUrl': {
  746. type: 'string',
  747. title: '接口地址',
  748. 'x-decorator': 'FormItem',
  749. 'x-decorator-props': {
  750. gridSpan: 2,
  751. layout: 'vertical',
  752. labelAlign: 'left',
  753. tooltip: '访问Api服务的地址',
  754. },
  755. required: true,
  756. 'x-component': 'Input',
  757. 'x-component-props': {
  758. placeholder: '请输入接口地址',
  759. },
  760. },
  761. 'apiClient.authConfig.type': {
  762. type: 'string',
  763. title: '认证方式',
  764. 'x-hidden': true,
  765. 'x-decorator': 'FormItem',
  766. 'x-decorator-props': {
  767. gridSpan: 2,
  768. layout: 'vertical',
  769. labelAlign: 'left',
  770. },
  771. required: true,
  772. 'x-component': 'Input',
  773. default: 'oauth2',
  774. },
  775. 'apiClient.authConfig.oauth2.authorizationUrl': {
  776. type: 'string',
  777. title: '授权地址',
  778. 'x-decorator': 'FormItem',
  779. 'x-decorator-props': {
  780. gridSpan: 2,
  781. layout: 'vertical',
  782. labelAlign: 'left',
  783. },
  784. required: true,
  785. 'x-component': 'Input',
  786. 'x-component-props': {
  787. placeholder: '请输入授权地址',
  788. },
  789. },
  790. 'apiClient.authConfig.oauth2.redirectUri': {
  791. type: 'string',
  792. title: '回调地址',
  793. 'x-decorator': 'FormItem',
  794. 'x-decorator-props': {
  795. gridSpan: 2,
  796. layout: 'vertical',
  797. labelAlign: 'left',
  798. },
  799. // required: true,
  800. 'x-component': 'Input',
  801. 'x-component-props': {
  802. placeholder: '请输入回调地址',
  803. },
  804. },
  805. 'apiClient.authConfig.oauth2.clientId': {
  806. type: 'string',
  807. title: 'appId',
  808. 'x-decorator': 'FormItem',
  809. 'x-decorator-props': {
  810. gridSpan: 2,
  811. layout: 'vertical',
  812. labelAlign: 'left',
  813. },
  814. required: true,
  815. 'x-component': 'Input',
  816. 'x-component-props': {
  817. placeholder: '请输入appId',
  818. },
  819. 'x-validator': [
  820. {
  821. max: 64,
  822. message: '最多可输入64个字符',
  823. },
  824. {
  825. required: true,
  826. message: '请输入appId',
  827. },
  828. ],
  829. },
  830. 'apiClient.authConfig.oauth2.clientSecret': {
  831. type: 'string',
  832. title: 'appKey',
  833. 'x-decorator': 'FormItem',
  834. 'x-decorator-props': {
  835. gridSpan: 2,
  836. layout: 'vertical',
  837. labelAlign: 'left',
  838. },
  839. required: true,
  840. 'x-component': 'Input',
  841. 'x-component-props': {
  842. placeholder: '请输入appKey',
  843. },
  844. 'x-validator': [
  845. {
  846. max: 64,
  847. message: '最多可输入64个字符',
  848. },
  849. {
  850. required: true,
  851. message: '请输入appKey',
  852. },
  853. ],
  854. },
  855. } as any;
  856. //第三方平台-客户端
  857. const clientThird = {
  858. apiClient: {
  859. type: 'object',
  860. properties: {
  861. baseUrl: {
  862. type: 'string',
  863. title: '接口地址',
  864. 'x-decorator': 'FormItem',
  865. 'x-decorator-props': {
  866. gridSpan: 2,
  867. layout: 'vertical',
  868. labelAlign: 'left',
  869. tooltip: '访问第三方平台接口的地址',
  870. },
  871. required: true,
  872. 'x-component': 'Input',
  873. 'x-component-props': {
  874. placeholder: '请输入接口地址',
  875. },
  876. },
  877. authConfig: {
  878. type: 'object',
  879. properties: {
  880. type: {
  881. type: 'string',
  882. title: '认证方式',
  883. 'x-decorator': 'FormItem',
  884. 'x-decorator-props': {
  885. gridSpan: 2,
  886. layout: 'vertical',
  887. labelAlign: 'left',
  888. },
  889. required: true,
  890. 'x-component': 'Select',
  891. default: 'oauth2',
  892. enum: [
  893. { label: 'OAuth2', value: 'oauth2' },
  894. { label: '基本认证', value: 'basic' },
  895. { label: 'bearer认证', value: 'bearer' },
  896. ],
  897. },
  898. bearer: {
  899. type: 'object',
  900. 'x-reactions': {
  901. dependencies: ['.type'],
  902. fulfill: {
  903. state: {
  904. visible: '{{$deps[0] ==="bearer"}}',
  905. },
  906. },
  907. },
  908. properties: {
  909. token: {
  910. type: 'string',
  911. title: 'token',
  912. 'x-decorator': 'FormItem',
  913. 'x-decorator-props': {
  914. gridSpan: 2,
  915. layout: 'vertical',
  916. labelAlign: 'left',
  917. },
  918. required: true,
  919. 'x-component': 'Input',
  920. 'x-component-props': {
  921. placeholder: '请输入token',
  922. },
  923. },
  924. },
  925. },
  926. basic: {
  927. type: 'object',
  928. 'x-reactions': {
  929. dependencies: ['.type'],
  930. fulfill: {
  931. state: {
  932. visible: '{{$deps[0] ==="basic"}}',
  933. },
  934. },
  935. },
  936. properties: {
  937. username: {
  938. type: 'string',
  939. title: '用户名',
  940. 'x-decorator': 'FormItem',
  941. 'x-decorator-props': {
  942. gridSpan: 2,
  943. layout: 'vertical',
  944. labelAlign: 'left',
  945. },
  946. required: true,
  947. 'x-component': 'Input',
  948. 'x-component-props': {
  949. placeholder: '请输入用户名',
  950. },
  951. },
  952. password: {
  953. type: 'string',
  954. title: '密码',
  955. 'x-decorator': 'FormItem',
  956. 'x-decorator-props': {
  957. gridSpan: 2,
  958. layout: 'vertical',
  959. labelAlign: 'left',
  960. },
  961. required: true,
  962. 'x-component': 'Input',
  963. 'x-component-props': {
  964. placeholder: '请输入密码',
  965. },
  966. },
  967. },
  968. },
  969. oauth2: {
  970. type: 'object',
  971. 'x-reactions': {
  972. dependencies: ['.type'],
  973. fulfill: {
  974. state: {
  975. visible: '{{$deps[0] ==="oauth2"}}',
  976. },
  977. },
  978. },
  979. properties: {
  980. authorizationUrl: {
  981. type: 'string',
  982. title: '授权地址',
  983. 'x-decorator': 'FormItem',
  984. 'x-decorator-props': {
  985. gridSpan: 2,
  986. layout: 'vertical',
  987. labelAlign: 'left',
  988. },
  989. required: true,
  990. 'x-component': 'Input',
  991. },
  992. tokenRequestType: {
  993. type: 'string',
  994. title: '请求方式',
  995. 'x-decorator': 'FormItem',
  996. 'x-decorator-props': {
  997. gridSpan: 2,
  998. layout: 'vertical',
  999. labelAlign: 'left',
  1000. },
  1001. required: true,
  1002. 'x-component': 'Select',
  1003. default: 'POST_BODY',
  1004. enum: [
  1005. { label: '请求体', value: 'POST_BODY' },
  1006. { label: '请求头', value: 'POST_URI' },
  1007. ],
  1008. },
  1009. // tokenRequest: {
  1010. // type: 'string',
  1011. // title: '请求类型',
  1012. // 'x-decorator': 'FormItem',
  1013. // 'x-decorator-props': {
  1014. // gridSpan: 2,
  1015. // layout: 'vertical',
  1016. // labelAlign: 'left',
  1017. // },
  1018. // required: true,
  1019. // 'x-component': 'Select',
  1020. // default: 'POST_BODY',
  1021. // enum: [
  1022. // { label: '请求体', value: 'POST_BODY' },
  1023. // { label: '请求头', value: 'POST_URI' },
  1024. // ]
  1025. // },
  1026. clientId: {
  1027. type: 'string',
  1028. title: 'client_id',
  1029. 'x-decorator': 'FormItem',
  1030. 'x-decorator-props': {
  1031. gridSpan: 2,
  1032. layout: 'vertical',
  1033. labelAlign: 'left',
  1034. },
  1035. required: true,
  1036. 'x-component': 'Input',
  1037. },
  1038. clientSecret: {
  1039. type: 'string',
  1040. title: 'client_secret',
  1041. 'x-decorator': 'FormItem',
  1042. 'x-decorator-props': {
  1043. gridSpan: 2,
  1044. layout: 'vertical',
  1045. labelAlign: 'left',
  1046. },
  1047. required: true,
  1048. 'x-component': 'Input',
  1049. },
  1050. },
  1051. },
  1052. },
  1053. },
  1054. },
  1055. },
  1056. } as any;
  1057. const schema = {
  1058. type: 'object',
  1059. properties: {
  1060. name: {
  1061. type: 'string',
  1062. title: '名称',
  1063. required: true,
  1064. 'x-decorator': 'FormItem',
  1065. 'x-component': 'Input',
  1066. 'x-component-props': {
  1067. placeholder: '请输入名称',
  1068. },
  1069. 'x-validator': [
  1070. {
  1071. max: 64,
  1072. message: '最多可输入64个字符',
  1073. },
  1074. {
  1075. required: true,
  1076. message: '请输入名称',
  1077. },
  1078. ],
  1079. },
  1080. provider: {
  1081. title: '应用',
  1082. 'x-decorator': 'FormItem',
  1083. 'x-component': 'Radio.Group',
  1084. 'x-component-props': {
  1085. optionType: 'button',
  1086. placeholder: '请选择应用',
  1087. },
  1088. required: true,
  1089. // 'x-reactions': '{{useAsyncDataSource(getProvidersAll)}}',
  1090. 'x-decorator-props': {
  1091. gridSpan: 1,
  1092. },
  1093. default: 'internal-standalone',
  1094. enum: providerList,
  1095. 'x-validator': [
  1096. {
  1097. required: true,
  1098. message: '请选择应用',
  1099. },
  1100. ],
  1101. },
  1102. integrationModes: {
  1103. type: 'array',
  1104. title: '接入方式',
  1105. // 'x-hidden': true,
  1106. enum: integrationModesList,
  1107. 'x-decorator': 'FormItem',
  1108. 'x-component': 'Checkbox.Group',
  1109. 'x-validator': [
  1110. {
  1111. required: true,
  1112. message: '请选择接入方式',
  1113. },
  1114. ],
  1115. },
  1116. config: {
  1117. type: 'void',
  1118. // 'x-hidden': true,
  1119. 'x-decorator': 'FormItem',
  1120. 'x-decorator-props': {
  1121. gridSpan: 2,
  1122. },
  1123. 'x-component': 'FormCollapse',
  1124. 'x-reactions': {
  1125. dependencies: ['integrationModes'],
  1126. fulfill: {
  1127. state: {
  1128. visible: '{{$deps[0] && $deps[0].length!==0}}',
  1129. },
  1130. },
  1131. },
  1132. 'x-component-props': {
  1133. formCollapse: '{{formCollapse}}',
  1134. },
  1135. properties: {
  1136. apiServer: {
  1137. type: 'void',
  1138. 'x-component': 'FormCollapse.CollapsePanel',
  1139. 'x-component-props': {
  1140. header: 'API服务',
  1141. },
  1142. properties: {
  1143. 'apiServer.appId': {
  1144. type: 'string',
  1145. title: 'appId',
  1146. default: randomString(16),
  1147. 'x-decorator': 'FormItem',
  1148. 'x-decorator-props': {
  1149. gridSpan: 2,
  1150. layout: 'vertical',
  1151. labelAlign: 'left',
  1152. },
  1153. required: true,
  1154. 'x-component': 'Input',
  1155. 'x-component-props': {
  1156. disabled: true,
  1157. },
  1158. 'x-reactions': {
  1159. dependencies: ['integrationModes'],
  1160. fulfill: {
  1161. state: {
  1162. visible: '{{!$deps[0].includes("apiClient")}}',
  1163. },
  1164. },
  1165. },
  1166. },
  1167. 'apiServer.secureKey': {
  1168. type: 'string',
  1169. title: 'secureKey',
  1170. default: randomString(),
  1171. 'x-decorator': 'FormItem',
  1172. 'x-decorator-props': {
  1173. gridSpan: 2,
  1174. layout: 'vertical',
  1175. labelAlign: 'left',
  1176. },
  1177. required: true,
  1178. 'x-component': 'Input',
  1179. 'x-component-props': {
  1180. placeholder: '请输入secureKey',
  1181. },
  1182. 'x-validator': [
  1183. {
  1184. max: 64,
  1185. message: '最多可输入64个字符',
  1186. },
  1187. {
  1188. required: true,
  1189. message: '请输入secureKey',
  1190. },
  1191. ],
  1192. },
  1193. 'apiServer.redirectUri': {
  1194. type: 'string',
  1195. title: '回调地址',
  1196. 'x-decorator': 'FormItem',
  1197. 'x-decorator-props': {
  1198. gridSpan: 2,
  1199. layout: 'vertical',
  1200. labelAlign: 'left',
  1201. },
  1202. // required: true,
  1203. 'x-component': 'Input',
  1204. 'x-component-props': {
  1205. placeholder: '请输入回调地址',
  1206. },
  1207. 'x-reactions': {
  1208. dependencies: ['provider'],
  1209. fulfill: {
  1210. state: {
  1211. visible: '{{$deps[0] && $deps[0]!=="third-party"}}',
  1212. },
  1213. },
  1214. },
  1215. },
  1216. 'apiServer.roleIdList': {
  1217. title: '角色',
  1218. 'x-decorator': 'FormItem',
  1219. required: true,
  1220. 'x-component': 'Select',
  1221. 'x-component-props': {
  1222. mode: 'multiple',
  1223. showArrow: true,
  1224. placeholder: '请选择角色',
  1225. filterOption: (input: string, option: any) =>
  1226. option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
  1227. },
  1228. 'x-reactions': ['{{useAsyncData(getRole)}}'],
  1229. 'x-decorator-props': {
  1230. gridSpan: 2,
  1231. layout: 'vertical',
  1232. labelAlign: 'left',
  1233. tooltip: '为API用户分配角色',
  1234. addonAfter: (
  1235. <PermissionButton
  1236. type="link"
  1237. style={{ padding: 0 }}
  1238. isPermission={rolePermission.add}
  1239. onClick={() => {
  1240. const tab: any = window.open(`${origin}/#/system/role?save=true`);
  1241. tab!.onTabSaveSuccess = (value: any) => {
  1242. form.setFieldState('roleIdList', async (state) => {
  1243. state.dataSource = await getRole().then((resp) =>
  1244. resp.result?.map((item: Record<string, unknown>) => ({
  1245. ...item,
  1246. label: item.name,
  1247. value: item.id,
  1248. })),
  1249. );
  1250. state.value = [...(state.value || []), value.id];
  1251. });
  1252. };
  1253. }}
  1254. >
  1255. <PlusOutlined />
  1256. </PermissionButton>
  1257. ),
  1258. },
  1259. },
  1260. 'apiServer.orgIdList': {
  1261. title: '组织',
  1262. 'x-decorator': 'FormItem',
  1263. 'x-component': 'TreeSelect',
  1264. 'x-component-props': {
  1265. multiple: true,
  1266. showArrow: true,
  1267. placeholder: '请选择组织',
  1268. showCheckedStrategy: ATreeSelect.SHOW_ALL,
  1269. filterOption: (input: string, option: any) =>
  1270. option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
  1271. fieldNames: {
  1272. label: 'name',
  1273. value: 'id',
  1274. },
  1275. treeNodeFilterProp: 'name',
  1276. },
  1277. 'x-decorator-props': {
  1278. gridSpan: 2,
  1279. layout: 'vertical',
  1280. labelAlign: 'left',
  1281. tooltip: '为API用户分组所属组织',
  1282. addonAfter: (
  1283. <PermissionButton
  1284. type="link"
  1285. style={{ padding: 0 }}
  1286. isPermission={deptPermission.add}
  1287. onClick={() => {
  1288. const tab: any = window.open(`${origin}/#/system/department?save=true`);
  1289. tab!.onTabSaveSuccess = (value: any) => {
  1290. form.setFieldState('orgIdList', async (state) => {
  1291. state.dataSource = await getOrg().then((resp) =>
  1292. resp.result?.map((item: Record<string, unknown>) => ({
  1293. ...item,
  1294. label: item.name,
  1295. value: item.id,
  1296. })),
  1297. );
  1298. state.value = [...(state.value || []), value.id];
  1299. });
  1300. };
  1301. }}
  1302. >
  1303. <PlusOutlined />
  1304. </PermissionButton>
  1305. ),
  1306. },
  1307. 'x-reactions': ['{{useAsyncData(getOrg)}}'],
  1308. },
  1309. apiServerThird: {
  1310. type: 'void',
  1311. 'x-reactions': {
  1312. dependencies: ['provider'],
  1313. fulfill: {
  1314. state: {
  1315. visible: '{{$deps[0] && $deps[0]==="third-party"}}',
  1316. },
  1317. },
  1318. },
  1319. properties: {
  1320. 'apiServer.redirectUri': {
  1321. type: 'string',
  1322. title: 'redirectUrl',
  1323. 'x-decorator': 'FormItem',
  1324. 'x-decorator-props': {
  1325. gridSpan: 2,
  1326. layout: 'vertical',
  1327. labelAlign: 'left',
  1328. tooltip: '授权后自动跳转的页面地址',
  1329. },
  1330. // required: true,
  1331. 'x-component': 'Input',
  1332. 'x-component-props': {
  1333. placeholder: '请输入redirectUrl',
  1334. },
  1335. },
  1336. 'apiServer.ipWhiteList': {
  1337. type: 'string',
  1338. title: 'IP白名单',
  1339. 'x-decorator': 'FormItem',
  1340. 'x-decorator-props': {
  1341. gridSpan: 2,
  1342. layout: 'vertical',
  1343. labelAlign: 'left',
  1344. },
  1345. 'x-component': 'Input.TextArea',
  1346. 'x-component-props': {
  1347. placeholder: '请输入IP白名单,多个地址回车分隔,不填默认均可访问',
  1348. rows: 3,
  1349. },
  1350. },
  1351. },
  1352. },
  1353. },
  1354. },
  1355. apiClient: {
  1356. type: 'void',
  1357. 'x-component': 'FormCollapse.CollapsePanel',
  1358. 'x-component-props': {
  1359. header: 'API客户端',
  1360. },
  1361. properties: {
  1362. standaloneConfig: {
  1363. type: 'void',
  1364. 'x-reactions': {
  1365. dependencies: ['provider'],
  1366. fulfill: {
  1367. state: {
  1368. visible: '{{$deps[0] && $deps[0]==="internal-standalone"}}',
  1369. },
  1370. },
  1371. },
  1372. properties: { ...clientStandalone },
  1373. },
  1374. thirdConfig: {
  1375. type: 'void',
  1376. 'x-reactions': {
  1377. dependencies: ['provider'],
  1378. fulfill: {
  1379. state: {
  1380. visible: '{{$deps[0]==="third-party"}}',
  1381. },
  1382. },
  1383. },
  1384. properties: { ...clientThird },
  1385. },
  1386. integratedConfig: {
  1387. type: 'void',
  1388. 'x-reactions': {
  1389. dependencies: ['provider'],
  1390. fulfill: {
  1391. state: {
  1392. visible: '{{$deps[0]==="internal-integrated"}}',
  1393. },
  1394. },
  1395. },
  1396. properties: {
  1397. 'apiClient.baseUrl': {
  1398. type: 'string',
  1399. title: '接口地址',
  1400. 'x-decorator': 'FormItem',
  1401. 'x-decorator-props': {
  1402. gridSpan: 2,
  1403. layout: 'vertical',
  1404. labelAlign: 'left',
  1405. tooltip: '访问Api服务的地址',
  1406. },
  1407. required: true,
  1408. 'x-component': 'Input',
  1409. 'x-component-props': {
  1410. placeholder: '请输入接口地址',
  1411. },
  1412. },
  1413. },
  1414. },
  1415. 'apiClient.headers': {
  1416. type: 'array',
  1417. default: [{}],
  1418. title: '请求头',
  1419. 'x-decorator': 'FormItem',
  1420. // required: true,
  1421. 'x-component': 'ArrayTable',
  1422. 'x-reactions': {
  1423. dependencies: ['provider'],
  1424. fulfill: {
  1425. state: {
  1426. visible: '{{$deps[0] && $deps[0]!=="internal-integrated"}}',
  1427. },
  1428. },
  1429. },
  1430. 'x-decorator-props': {
  1431. gridSpan: 2,
  1432. layout: 'vertical',
  1433. labelAlign: 'left',
  1434. },
  1435. items: {
  1436. type: 'object',
  1437. properties: {
  1438. column1: {
  1439. type: 'void',
  1440. // required: true,
  1441. 'x-component': 'ArrayTable.Column',
  1442. 'x-component-props': { width: 100, title: 'key' },
  1443. properties: {
  1444. key: {
  1445. // required: true,
  1446. 'x-decorator': 'FormItem',
  1447. 'x-component': 'Input',
  1448. },
  1449. },
  1450. },
  1451. column2: {
  1452. type: 'void',
  1453. 'x-component': 'ArrayTable.Column',
  1454. 'x-component-props': { width: 100, title: 'value' },
  1455. properties: {
  1456. value: {
  1457. // required: true,
  1458. 'x-decorator': 'FormItem',
  1459. 'x-component': 'Input',
  1460. },
  1461. },
  1462. },
  1463. column3: {
  1464. type: 'void',
  1465. 'x-component': 'ArrayTable.Column',
  1466. 'x-component-props': { width: 30 },
  1467. properties: {
  1468. remove: {
  1469. type: 'void',
  1470. 'x-component': 'ArrayTable.Remove',
  1471. },
  1472. },
  1473. },
  1474. },
  1475. },
  1476. properties: {
  1477. add: {
  1478. type: 'void',
  1479. 'x-component': 'ArrayTable.Addition',
  1480. title: '添加请求头',
  1481. },
  1482. },
  1483. },
  1484. 'apiClient.parameters': {
  1485. type: 'array',
  1486. default: [{}],
  1487. title: '参数',
  1488. 'x-reactions': {
  1489. dependencies: ['provider'],
  1490. fulfill: {
  1491. state: {
  1492. visible: '{{$deps[0] && $deps[0]!=="internal-integrated"}}',
  1493. },
  1494. },
  1495. },
  1496. 'x-decorator': 'FormItem',
  1497. // required: true,
  1498. 'x-component': 'ArrayTable',
  1499. 'x-decorator-props': {
  1500. gridSpan: 2,
  1501. layout: 'vertical',
  1502. labelAlign: 'left',
  1503. },
  1504. items: {
  1505. type: 'object',
  1506. properties: {
  1507. column1: {
  1508. type: 'void',
  1509. // required: true,
  1510. 'x-component': 'ArrayTable.Column',
  1511. 'x-component-props': { width: 100, title: 'key' },
  1512. properties: {
  1513. key: {
  1514. // required: true,
  1515. 'x-decorator': 'FormItem',
  1516. 'x-component': 'Input',
  1517. },
  1518. },
  1519. },
  1520. column2: {
  1521. type: 'void',
  1522. 'x-component': 'ArrayTable.Column',
  1523. 'x-component-props': { width: 100, title: 'value' },
  1524. properties: {
  1525. value: {
  1526. // required: true,
  1527. 'x-decorator': 'FormItem',
  1528. 'x-component': 'Input',
  1529. },
  1530. },
  1531. },
  1532. column3: {
  1533. type: 'void',
  1534. 'x-component': 'ArrayTable.Column',
  1535. 'x-component-props': { width: 30 },
  1536. properties: {
  1537. remove: {
  1538. type: 'void',
  1539. 'x-component': 'ArrayTable.Remove',
  1540. },
  1541. },
  1542. },
  1543. },
  1544. },
  1545. properties: {
  1546. add: {
  1547. type: 'void',
  1548. 'x-component': 'ArrayTable.Addition',
  1549. title: '添加参数',
  1550. },
  1551. },
  1552. },
  1553. },
  1554. },
  1555. page: {
  1556. type: 'void',
  1557. 'x-component': 'FormCollapse.CollapsePanel',
  1558. 'x-component-props': {
  1559. header: '页面集成',
  1560. },
  1561. properties: {
  1562. 'page.baseUrl': {
  1563. type: 'string',
  1564. title: '接入地址',
  1565. 'x-decorator': 'FormItem',
  1566. 'x-decorator-props': {
  1567. gridSpan: 2,
  1568. layout: 'vertical',
  1569. labelAlign: 'left',
  1570. tooltip: '填写访问其它平台的地址',
  1571. },
  1572. required: true,
  1573. 'x-component': 'Input',
  1574. 'x-component-props': {
  1575. placeholder: '请输入接入地址',
  1576. },
  1577. },
  1578. 'page.routeType': {
  1579. type: 'string',
  1580. title: '路由方式',
  1581. 'x-decorator': 'FormItem',
  1582. // 'x-reactions': {
  1583. // dependencies: ['provider'],
  1584. // fulfill: {
  1585. // state: {
  1586. // visible: '{{$deps[0]==="internal-integrated"}}',
  1587. // },
  1588. // },
  1589. // },
  1590. 'x-decorator-props': {
  1591. gridSpan: 2,
  1592. layout: 'vertical',
  1593. labelAlign: 'left',
  1594. },
  1595. required: true,
  1596. 'x-component': 'Select',
  1597. default: 'hash',
  1598. enum: [
  1599. { label: 'hash', value: 'hash' },
  1600. { label: 'history', value: 'history' },
  1601. ],
  1602. },
  1603. 'page.parameters': {
  1604. type: 'array',
  1605. default: [{}],
  1606. title: '参数',
  1607. 'x-decorator': 'FormItem',
  1608. // required: true,
  1609. 'x-component': 'ArrayTable',
  1610. 'x-reactions': {
  1611. dependencies: ['provider'],
  1612. fulfill: {
  1613. state: {
  1614. visible: '{{$deps[0]==="third-party"}}',
  1615. },
  1616. },
  1617. },
  1618. 'x-decorator-props': {
  1619. gridSpan: 2,
  1620. layout: 'vertical',
  1621. labelAlign: 'left',
  1622. tooltip: '自定义参数,格式${name}',
  1623. },
  1624. items: {
  1625. type: 'object',
  1626. properties: {
  1627. column1: {
  1628. type: 'void',
  1629. // required: true,
  1630. 'x-component': 'ArrayTable.Column',
  1631. 'x-component-props': { width: 100, title: 'KEY' },
  1632. properties: {
  1633. key: {
  1634. // required: true,
  1635. 'x-decorator': 'FormItem',
  1636. 'x-component': 'Input',
  1637. },
  1638. },
  1639. },
  1640. column2: {
  1641. type: 'void',
  1642. 'x-component': 'ArrayTable.Column',
  1643. 'x-component-props': { width: 100, title: 'VALUE' },
  1644. properties: {
  1645. value: {
  1646. // required: true,
  1647. 'x-decorator': 'FormItem',
  1648. 'x-component': 'AutoComplete',
  1649. 'x-component-props': {
  1650. options: [{ value: '用户ID' }, { value: '用户名' }, { value: 'token' }],
  1651. },
  1652. },
  1653. },
  1654. },
  1655. column3: {
  1656. type: 'void',
  1657. 'x-component': 'ArrayTable.Column',
  1658. 'x-component-props': { width: 50 },
  1659. properties: {
  1660. remove: {
  1661. type: 'void',
  1662. 'x-component': 'ArrayTable.Remove',
  1663. },
  1664. },
  1665. },
  1666. },
  1667. },
  1668. properties: {
  1669. add: {
  1670. type: 'void',
  1671. 'x-component': 'ArrayTable.Addition',
  1672. title: '新增',
  1673. },
  1674. },
  1675. },
  1676. },
  1677. },
  1678. ssoClient: {
  1679. type: 'void',
  1680. 'x-component': 'FormCollapse.CollapsePanel',
  1681. 'x-component-props': {
  1682. header: '单点登录',
  1683. },
  1684. properties: {
  1685. standaloneConfig: {
  1686. type: 'void',
  1687. 'x-reactions': {
  1688. dependencies: ['provider'],
  1689. fulfill: {
  1690. state: {
  1691. visible: '{{$deps[0] && $deps[0]==="internal-standalone"}}',
  1692. },
  1693. },
  1694. },
  1695. properties: { ...ssoStandalone },
  1696. },
  1697. ssoConfig: {
  1698. type: 'void',
  1699. 'x-reactions': {
  1700. dependencies: ['provider'],
  1701. fulfill: {
  1702. state: {
  1703. visible: '{{$deps[0]==="wechat-webapp" || $deps[0]==="dingtalk-ent-app"}}',
  1704. },
  1705. },
  1706. },
  1707. properties: { ...ssoConfig },
  1708. },
  1709. thirdConfig: {
  1710. type: 'void',
  1711. 'x-reactions': {
  1712. dependencies: ['provider'],
  1713. fulfill: {
  1714. state: {
  1715. visible: '{{$deps[0]==="third-party"}}',
  1716. },
  1717. },
  1718. },
  1719. properties: { ...ssoThird },
  1720. },
  1721. userConfig: {
  1722. type: 'void',
  1723. 'x-decorator': 'FormGrid',
  1724. 'x-hidden': true,
  1725. 'x-decorator-props': {
  1726. maxColumns: 2,
  1727. minColumns: 2,
  1728. columnGap: 24,
  1729. },
  1730. 'x-reactions': {
  1731. dependencies: ['sso.autoCreateUser'],
  1732. fulfill: {
  1733. state: {
  1734. visible: '{{$deps[0]}}',
  1735. },
  1736. },
  1737. },
  1738. properties: {
  1739. 'sso.usernamePrefix': {
  1740. type: 'string',
  1741. title: '用户名前缀',
  1742. 'x-decorator': 'FormItem',
  1743. 'x-decorator-props': {
  1744. gridSpan: 2,
  1745. layout: 'vertical',
  1746. labelAlign: 'left',
  1747. },
  1748. required: true,
  1749. 'x-component': 'Input',
  1750. 'x-component-props': {
  1751. placeholder: '请输入用户名前缀',
  1752. },
  1753. },
  1754. 'sso.defaultPasswd': {
  1755. type: 'string',
  1756. title: '默认密码',
  1757. 'x-decorator': 'FormItem',
  1758. 'x-decorator-props': {
  1759. gridSpan: 2,
  1760. layout: 'vertical',
  1761. labelAlign: 'left',
  1762. },
  1763. required: true,
  1764. 'x-component': 'Input',
  1765. 'x-component-props': {
  1766. placeholder: '请输入默认密码',
  1767. },
  1768. 'x-validator': [
  1769. {
  1770. max: 64,
  1771. message: '最多可输入64个字符',
  1772. },
  1773. {
  1774. required: true,
  1775. message: '请输入默认密码',
  1776. },
  1777. ],
  1778. },
  1779. 'sso.roleIdList': {
  1780. title: '角色',
  1781. 'x-decorator': 'FormItem',
  1782. 'x-component': 'Select',
  1783. 'x-component-props': {
  1784. mode: 'multiple',
  1785. showArrow: true,
  1786. placeholder: '请选择角色',
  1787. filterOption: (input: string, option: any) =>
  1788. option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
  1789. },
  1790. 'x-reactions': ['{{useAsyncData(getRole)}}'],
  1791. 'x-decorator-props': {
  1792. gridSpan: 2,
  1793. layout: 'vertical',
  1794. labelAlign: 'left',
  1795. addonAfter: (
  1796. <PermissionButton
  1797. type="link"
  1798. style={{ padding: 0 }}
  1799. isPermission={rolePermission.add}
  1800. onClick={() => {
  1801. const tab: any = window.open(`${origin}/#/system/role?save=true`);
  1802. tab!.onTabSaveSuccess = (value: any) => {
  1803. form.setFieldState('roleIdList', async (state) => {
  1804. state.dataSource = await getRole().then((resp) =>
  1805. resp.result?.map((item: Record<string, unknown>) => ({
  1806. ...item,
  1807. label: item.name,
  1808. value: item.id,
  1809. })),
  1810. );
  1811. state.value = [...(state.value || []), value.id];
  1812. });
  1813. };
  1814. }}
  1815. >
  1816. <PlusOutlined />
  1817. </PermissionButton>
  1818. ),
  1819. },
  1820. },
  1821. 'sso.orgIdList': {
  1822. title: '组织',
  1823. 'x-decorator': 'FormItem',
  1824. 'x-component': 'TreeSelect',
  1825. 'x-component-props': {
  1826. multiple: true,
  1827. showArrow: true,
  1828. placeholder: '请选择组织',
  1829. showCheckedStrategy: ATreeSelect.SHOW_ALL,
  1830. filterOption: (input: string, option: any) =>
  1831. option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
  1832. fieldNames: {
  1833. label: 'name',
  1834. value: 'id',
  1835. },
  1836. treeNodeFilterProp: 'name',
  1837. },
  1838. 'x-decorator-props': {
  1839. gridSpan: 2,
  1840. layout: 'vertical',
  1841. labelAlign: 'left',
  1842. addonAfter: (
  1843. <PermissionButton
  1844. type="link"
  1845. style={{ padding: 0 }}
  1846. isPermission={deptPermission.add}
  1847. onClick={() => {
  1848. const tab: any = window.open(`${origin}/#/system/department?save=true`);
  1849. tab!.onTabSaveSuccess = (value: any) => {
  1850. form.setFieldState('orgIdList', async (state) => {
  1851. state.dataSource = await getOrg().then((resp) =>
  1852. resp.result?.map((item: Record<string, unknown>) => ({
  1853. ...item,
  1854. label: item.name,
  1855. value: item.id,
  1856. })),
  1857. );
  1858. state.value = [...(state.value || []), value.id];
  1859. });
  1860. };
  1861. }}
  1862. >
  1863. <PlusOutlined />
  1864. </PermissionButton>
  1865. ),
  1866. },
  1867. 'x-reactions': ['{{useAsyncData(getOrg)}}'],
  1868. },
  1869. },
  1870. },
  1871. },
  1872. },
  1873. },
  1874. },
  1875. description: {
  1876. title: '说明',
  1877. 'x-component': 'Input.TextArea',
  1878. 'x-decorator': 'FormItem',
  1879. 'x-component-props': {
  1880. rows: 3,
  1881. showCount: true,
  1882. maxLength: 200,
  1883. placeholder: '请输入说明',
  1884. },
  1885. },
  1886. },
  1887. };
  1888. useEffect(() => {
  1889. setView(false);
  1890. const params = new URLSearchParams(location.search);
  1891. const item = params.get('id');
  1892. // console.log(id);
  1893. if (item) {
  1894. setId(item);
  1895. }
  1896. if (location && location.state) {
  1897. setView(location.state.view);
  1898. }
  1899. }, [location]);
  1900. return (
  1901. <PageContainer>
  1902. <Card>
  1903. <Row gutter={24}>
  1904. <Col span={14}>
  1905. {/* <TitleComponent data={'基本信息'} /> */}
  1906. <Form form={form} layout="vertical" className={styles.form}>
  1907. <SchemaField
  1908. schema={schema}
  1909. scope={{
  1910. formCollapse,
  1911. useAsyncDataSource,
  1912. useAsyncData,
  1913. // getProvidersAll,
  1914. getRole,
  1915. getOrg,
  1916. }}
  1917. />
  1918. <FormButtonGroup.Sticky>
  1919. <FormButtonGroup.FormItem>
  1920. {!view && (
  1921. <PermissionButton
  1922. type="primary"
  1923. isPermission={permission.add || permission.update}
  1924. onClick={() => handleSave()}
  1925. >
  1926. 保存
  1927. </PermissionButton>
  1928. )}
  1929. </FormButtonGroup.FormItem>
  1930. </FormButtonGroup.Sticky>
  1931. </Form>
  1932. </Col>
  1933. <Col span={10} className={styles.apply}>
  1934. <div className={styles.doc}></div>
  1935. </Col>
  1936. </Row>
  1937. </Card>
  1938. {visible && (
  1939. <MenuPage
  1940. data={detail}
  1941. close={() => {
  1942. setVisiable(false);
  1943. }}
  1944. />
  1945. )}
  1946. </PageContainer>
  1947. );
  1948. };
  1949. export default Save;