user.data.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { getAllRolesListNoByTenant, getAllTenantList } from './user.api';
  4. import { rules } from '/@/utils/helper/validator';
  5. import { render } from '/@/utils/common/renderUtils';
  6. export const columns: BasicColumn[] = [
  7. {
  8. title: '用户账号',
  9. dataIndex: 'username',
  10. width: 120,
  11. },
  12. {
  13. title: '用户姓名',
  14. dataIndex: 'realname',
  15. width: 100,
  16. },
  17. {
  18. title: '头像',
  19. dataIndex: 'avatar',
  20. width: 120,
  21. customRender: render.renderAvatar,
  22. },
  23. {
  24. title: '性别',
  25. dataIndex: 'sex',
  26. width: 80,
  27. sorter: true,
  28. customRender: ({ text }) => {
  29. return render.renderDict(text, 'sex');
  30. },
  31. },
  32. {
  33. title: '生日',
  34. dataIndex: 'birthday',
  35. width: 100,
  36. },
  37. {
  38. title: '手机号',
  39. dataIndex: 'phone',
  40. width: 100,
  41. },
  42. {
  43. title: '部门',
  44. width: 150,
  45. dataIndex: 'orgCodeTxt',
  46. },
  47. {
  48. title: '负责部门',
  49. width: 150,
  50. dataIndex: 'departIds_dictText',
  51. },
  52. {
  53. title: '状态',
  54. dataIndex: 'status_dictText',
  55. width: 80,
  56. },
  57. ];
  58. export const recycleColumns: BasicColumn[] = [
  59. {
  60. title: '用户账号',
  61. dataIndex: 'username',
  62. width: 100,
  63. },
  64. {
  65. title: '用户姓名',
  66. dataIndex: 'realname',
  67. width: 100,
  68. },
  69. {
  70. title: '头像',
  71. dataIndex: 'avatar',
  72. width: 80,
  73. customRender: render.renderAvatar,
  74. },
  75. {
  76. title: '性别',
  77. dataIndex: 'sex',
  78. width: 80,
  79. sorter: true,
  80. customRender: ({ text }) => {
  81. return render.renderDict(text, 'sex');
  82. },
  83. },
  84. ];
  85. export const searchFormSchema: FormSchema[] = [
  86. {
  87. label: '账号',
  88. field: 'username',
  89. component: 'JInput',
  90. //colProps: { span: 6 },
  91. },
  92. {
  93. label: '名字',
  94. field: 'realname',
  95. component: 'JInput',
  96. //colProps: { span: 6 },
  97. },
  98. {
  99. label: '性别',
  100. field: 'sex',
  101. component: 'JDictSelectTag',
  102. componentProps: {
  103. dictCode: 'sex',
  104. placeholder: '请选择性别',
  105. stringToNumber: true,
  106. },
  107. //colProps: { span: 6 },
  108. },
  109. {
  110. label: '手机号码',
  111. field: 'phone',
  112. component: 'Input',
  113. //colProps: { span: 6 },
  114. },
  115. {
  116. label: '用户状态',
  117. field: 'status',
  118. component: 'JDictSelectTag',
  119. componentProps: {
  120. dictCode: 'user_status',
  121. placeholder: '请选择状态',
  122. stringToNumber: true,
  123. },
  124. //colProps: { span: 6 },
  125. },
  126. ];
  127. export const formSchema: FormSchema[] = [
  128. {
  129. label: '',
  130. field: 'id',
  131. component: 'Input',
  132. show: false,
  133. },
  134. {
  135. label: '用户账号',
  136. field: 'username',
  137. component: 'Input',
  138. required: true,
  139. dynamicDisabled: ({ values }) => {
  140. return !!values.id;
  141. },
  142. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'username', model, schema, true),
  143. },
  144. {
  145. label: '登录密码',
  146. field: 'password',
  147. component: 'StrengthMeter',
  148. componentProps: {
  149. autocomplete: 'new-password',
  150. },
  151. rules: [
  152. {
  153. required: true,
  154. message: '请输入登录密码',
  155. },
  156. {
  157. pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
  158. message: '密码由8位数字、大小写字母和特殊符号组成!',
  159. },
  160. ],
  161. },
  162. {
  163. label: '确认密码',
  164. field: 'confirmPassword',
  165. component: 'InputPassword',
  166. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  167. },
  168. {
  169. label: '用户姓名',
  170. field: 'realname',
  171. required: true,
  172. component: 'Input',
  173. },
  174. {
  175. label: '工号',
  176. field: 'workNo',
  177. required: true,
  178. component: 'Input',
  179. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'work_no', model, schema, true),
  180. },
  181. {
  182. label: '职务',
  183. field: 'post',
  184. required: false,
  185. component: 'JSelectPosition',
  186. componentProps: {
  187. labelKey: 'name',
  188. },
  189. },
  190. {
  191. label: '角色',
  192. field: 'selectedroles',
  193. component: 'ApiSelect',
  194. componentProps: {
  195. mode: 'multiple',
  196. api: getAllRolesListNoByTenant,
  197. labelField: 'roleName',
  198. valueField: 'id',
  199. immediate: false,
  200. },
  201. required: true,
  202. },
  203. {
  204. label: '所属部门',
  205. field: 'selecteddeparts',
  206. component: 'JSelectDept',
  207. componentProps: ({ formActionType, formModel }) => {
  208. return {
  209. sync: false,
  210. checkStrictly: true,
  211. defaultExpandLevel: 2,
  212. onSelect: (options, values) => {
  213. const { updateSchema } = formActionType;
  214. //所属部门修改后更新负责部门下拉框数据
  215. updateSchema([
  216. {
  217. field: 'departIds',
  218. componentProps: { options },
  219. },
  220. ]);
  221. //update-begin---author:wangshuai---date:2024-05-11---for:【issues/1222】用户编辑界面“所属部门”与“负责部门”联动出错整---
  222. if (!values) {
  223. formModel.departIds = [];
  224. return;
  225. }
  226. //update-end---author:wangshuai---date:2024-05-11---for:【issues/1222】用户编辑界面“所属部门”与“负责部门”联动出错整---
  227. //所属部门修改后更新负责部门数据
  228. formModel.departIds && (formModel.departIds = formModel.departIds.filter((item) => values.value.indexOf(item) > -1));
  229. },
  230. };
  231. },
  232. required: true,
  233. },
  234. {
  235. label: '租户',
  236. field: 'relTenantIds',
  237. component: 'JSearchSelect',
  238. componentProps: {
  239. dict: 'sys_tenant,name,id',
  240. async: true,
  241. multiple: true,
  242. },
  243. },
  244. {
  245. label: '身份',
  246. field: 'userIdentity',
  247. component: 'RadioGroup',
  248. defaultValue: 1,
  249. componentProps: ({ formModel }) => {
  250. return {
  251. options: [
  252. { label: '普通用户', value: 1, key: '1' },
  253. { label: '上级', value: 2, key: '2' },
  254. ],
  255. onChange: () => {
  256. formModel.userIdentity == 1 && (formModel.departIds = []);
  257. },
  258. };
  259. },
  260. },
  261. {
  262. label: '负责部门',
  263. field: 'departIds',
  264. component: 'Select',
  265. componentProps: {
  266. mode: 'multiple',
  267. },
  268. ifShow: ({ values }) => values.userIdentity == 2,
  269. },
  270. {
  271. label: '头像',
  272. field: 'avatar',
  273. component: 'JImageUpload',
  274. componentProps: {
  275. fileMax: 1,
  276. },
  277. },
  278. {
  279. label: '生日',
  280. field: 'birthday',
  281. component: 'DatePicker',
  282. },
  283. {
  284. label: '性别',
  285. field: 'sex',
  286. component: 'JDictSelectTag',
  287. componentProps: {
  288. dictCode: 'sex',
  289. placeholder: '请选择性别',
  290. stringToNumber: true,
  291. },
  292. },
  293. {
  294. label: '邮箱',
  295. field: 'email',
  296. component: 'Input',
  297. required: true,
  298. dynamicRules: ({ model, schema }) => {
  299. return [
  300. { ...rules.duplicateCheckRule('sys_user', 'email', model, schema, true)[0], trigger: 'blur' },
  301. { ...rules.rule('email', false)[0], trigger: 'blur' },
  302. ];
  303. },
  304. },
  305. {
  306. label: '手机号码',
  307. field: 'phone',
  308. component: 'Input',
  309. required: true,
  310. dynamicRules: ({ model, schema }) => {
  311. return [
  312. { ...rules.duplicateCheckRule('sys_user', 'phone', model, schema, true)[0], trigger: 'blur' },
  313. { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式有误', trigger: 'blur' },
  314. ];
  315. },
  316. },
  317. {
  318. label: '座机',
  319. field: 'telephone',
  320. component: 'Input',
  321. rules: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }],
  322. },
  323. {
  324. label: '工作流引擎',
  325. field: 'activitiSync',
  326. defaultValue: 1,
  327. component: 'JDictSelectTag',
  328. componentProps: {
  329. dictCode: 'activiti_sync',
  330. type: 'radio',
  331. stringToNumber: true,
  332. },
  333. },
  334. ];
  335. export const formPasswordSchema: FormSchema[] = [
  336. {
  337. label: '用户账号',
  338. field: 'username',
  339. component: 'Input',
  340. componentProps: { readOnly: true },
  341. },
  342. {
  343. label: '登录密码',
  344. field: 'password',
  345. component: 'StrengthMeter',
  346. componentProps: {
  347. placeholder: '请输入登录密码',
  348. },
  349. rules: [
  350. {
  351. required: true,
  352. message: '请输入登录密码',
  353. },
  354. {
  355. pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
  356. message: '密码由8位数字、大小写字母和特殊符号组成!',
  357. },
  358. ],
  359. },
  360. {
  361. label: '确认密码',
  362. field: 'confirmPassword',
  363. component: 'InputPassword',
  364. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  365. },
  366. ];
  367. export const formAgentSchema: FormSchema[] = [
  368. {
  369. label: '',
  370. field: 'id',
  371. component: 'Input',
  372. show: false,
  373. },
  374. {
  375. field: 'userName',
  376. label: '用户名',
  377. component: 'Input',
  378. componentProps: {
  379. readOnly: true,
  380. allowClear: false,
  381. },
  382. },
  383. {
  384. field: 'agentUserName',
  385. label: '代理人用户名',
  386. required: true,
  387. component: 'JSelectUser',
  388. componentProps: {
  389. rowKey: 'username',
  390. labelKey: 'realname',
  391. maxSelectCount: 10,
  392. },
  393. },
  394. {
  395. field: 'startTime',
  396. label: '代理开始时间',
  397. component: 'DatePicker',
  398. required: true,
  399. componentProps: {
  400. showTime: true,
  401. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  402. placeholder: '请选择代理开始时间',
  403. getPopupContainer: () => document.body,
  404. },
  405. },
  406. {
  407. field: 'endTime',
  408. label: '代理结束时间',
  409. component: 'DatePicker',
  410. required: true,
  411. componentProps: {
  412. showTime: true,
  413. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  414. placeholder: '请选择代理结束时间',
  415. getPopupContainer: () => document.body,
  416. },
  417. },
  418. {
  419. field: 'status',
  420. label: '状态',
  421. component: 'JDictSelectTag',
  422. defaultValue: '1',
  423. componentProps: {
  424. dictCode: 'valid_status',
  425. type: 'radioButton',
  426. },
  427. },
  428. ];
  429. export const formQuitAgentSchema: FormSchema[] = [
  430. {
  431. label: '',
  432. field: 'id',
  433. component: 'Input',
  434. show: false,
  435. },
  436. {
  437. field: 'userName',
  438. label: '用户名',
  439. component: 'Input',
  440. componentProps: {
  441. readOnly: true,
  442. allowClear: false,
  443. },
  444. },
  445. {
  446. field: 'agentUserName',
  447. label: '交接人员',
  448. //required: true,
  449. component: 'JSelectUser',
  450. componentProps: {
  451. rowKey: 'username',
  452. labelKey: 'realname',
  453. maxSelectCount: 1,
  454. },
  455. },
  456. {
  457. field: 'startTime',
  458. label: '交接开始时间',
  459. component: 'DatePicker',
  460. //required: true,
  461. componentProps: {
  462. showTime: true,
  463. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  464. placeholder: '请选择交接开始时间',
  465. getPopupContainer: () => document.body,
  466. },
  467. },
  468. {
  469. field: 'endTime',
  470. label: '交接结束时间',
  471. component: 'DatePicker',
  472. //required: true,
  473. componentProps: {
  474. showTime: true,
  475. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  476. placeholder: '请选择交接结束时间',
  477. getPopupContainer: () => document.body,
  478. },
  479. },
  480. {
  481. field: 'status',
  482. label: '状态',
  483. component: 'JDictSelectTag',
  484. defaultValue: '1',
  485. componentProps: {
  486. dictCode: 'valid_status',
  487. type: 'radioButton',
  488. },
  489. },
  490. ];
  491. //租户用户列表
  492. export const userTenantColumns: BasicColumn[] = [
  493. {
  494. title: '用户账号',
  495. dataIndex: 'username',
  496. width: 120,
  497. },
  498. {
  499. title: '用户姓名',
  500. dataIndex: 'realname',
  501. width: 100,
  502. },
  503. {
  504. title: '头像',
  505. dataIndex: 'avatar',
  506. width: 120,
  507. customRender: render.renderAvatar,
  508. },
  509. {
  510. title: '手机号',
  511. dataIndex: 'phone',
  512. width: 100,
  513. },
  514. {
  515. title: '部门',
  516. width: 150,
  517. dataIndex: 'orgCodeTxt',
  518. },
  519. {
  520. title: '状态',
  521. dataIndex: 'status',
  522. width: 80,
  523. customRender: ({ text }) => {
  524. if (text === '1') {
  525. return '正常';
  526. } else if (text === '3') {
  527. return '审批中';
  528. } else {
  529. return '已拒绝';
  530. }
  531. },
  532. },
  533. ];
  534. //用户租户搜索表单
  535. export const userTenantFormSchema: FormSchema[] = [
  536. {
  537. label: '账号',
  538. field: 'username',
  539. component: 'Input',
  540. colProps: { span: 6 },
  541. },
  542. {
  543. label: '名字',
  544. field: 'realname',
  545. component: 'Input',
  546. colProps: { span: 6 },
  547. },
  548. {
  549. label: '性别',
  550. field: 'sex',
  551. component: 'JDictSelectTag',
  552. componentProps: {
  553. dictCode: 'sex',
  554. placeholder: '请选择性别',
  555. stringToNumber: true,
  556. },
  557. colProps: { span: 6 },
  558. },
  559. ];