index.tsx 56 KB

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