user.data.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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. {
  158. pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
  159. message: '密码由8位数字、大小写字母和特殊符号组成!',
  160. }, */
  161. ],
  162. },
  163. {
  164. label: '确认密码',
  165. field: 'confirmPassword',
  166. component: 'InputPassword',
  167. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  168. },
  169. {
  170. label: '用户姓名',
  171. field: 'realname',
  172. required: true,
  173. component: 'Input',
  174. },
  175. {
  176. label: '工号',
  177. field: 'workNo',
  178. // required: true,
  179. component: 'Input',
  180. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'work_no', model, schema, true),
  181. },
  182. {
  183. label: '职务',
  184. field: 'post',
  185. required: false,
  186. component: 'JSelectPosition',
  187. componentProps: {
  188. labelKey: 'name',
  189. },
  190. },
  191. {
  192. label: '角色',
  193. field: 'selectedroles',
  194. component: 'ApiSelect',
  195. componentProps: {
  196. mode: 'multiple',
  197. api: getAllRolesListNoByTenant,
  198. labelField: 'roleName',
  199. valueField: 'id',
  200. immediate: false,
  201. },
  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. },
  233. {
  234. label: '租户',
  235. field: 'relTenantIds',
  236. component: 'ApiSelect',
  237. componentProps: {
  238. mode: 'multiple',
  239. api: getAllTenantList,
  240. numberToString: true,
  241. labelField: 'name',
  242. valueField: 'id',
  243. immediate: false,
  244. },
  245. },
  246. {
  247. label: '身份',
  248. field: 'userIdentity',
  249. component: 'RadioGroup',
  250. defaultValue: 1,
  251. componentProps: ({ formModel }) => {
  252. return {
  253. options: [
  254. { label: '普通用户', value: 1, key: '1' },
  255. { label: '上级', value: 2, key: '2' },
  256. ],
  257. onChange: () => {
  258. formModel.userIdentity == 1 && (formModel.departIds = []);
  259. },
  260. };
  261. },
  262. },
  263. {
  264. label: '负责部门',
  265. field: 'departIds',
  266. component: 'Select',
  267. componentProps: {
  268. mode: 'multiple',
  269. },
  270. ifShow: ({ values }) => values.userIdentity == 2,
  271. },
  272. {
  273. label: '头像',
  274. field: 'avatar',
  275. component: 'JImageUpload',
  276. componentProps: {
  277. fileMax: 1,
  278. },
  279. },
  280. {
  281. label: '生日',
  282. field: 'birthday',
  283. component: 'DatePicker',
  284. },
  285. {
  286. label: '性别',
  287. field: 'sex',
  288. component: 'JDictSelectTag',
  289. componentProps: {
  290. dictCode: 'sex',
  291. placeholder: '请选择性别',
  292. stringToNumber: true,
  293. },
  294. },
  295. {
  296. label: '邮箱',
  297. field: 'email',
  298. component: 'Input',
  299. // required: true,
  300. dynamicRules: ({ model, schema }) => {
  301. return [
  302. { ...rules.duplicateCheckRule('sys_user', 'email', model, schema, true)[0], trigger: 'blur' },
  303. { ...rules.rule('email', false)[0], trigger: 'blur' },
  304. ];
  305. },
  306. },
  307. {
  308. label: '手机号码',
  309. field: 'phone',
  310. component: 'Input',
  311. // required: true,
  312. dynamicRules: ({ model, schema }) => {
  313. return [
  314. { ...rules.duplicateCheckRule('sys_user', 'phone', model, schema, true)[0], trigger: 'blur' },
  315. { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式有误', trigger: 'blur' },
  316. ];
  317. },
  318. },
  319. {
  320. label: '座机',
  321. field: 'telephone',
  322. component: 'Input',
  323. rules: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }],
  324. },
  325. {
  326. label: '工作流引擎',
  327. field: 'activitiSync',
  328. defaultValue: 1,
  329. component: 'JDictSelectTag',
  330. componentProps: {
  331. dictCode: 'activiti_sync',
  332. type: 'radio',
  333. stringToNumber: true,
  334. },
  335. },
  336. ];
  337. export const formPasswordSchema: FormSchema[] = [
  338. {
  339. label: '用户账号',
  340. field: 'username',
  341. component: 'Input',
  342. componentProps: { readOnly: true },
  343. },
  344. {
  345. label: '登录密码',
  346. field: 'password',
  347. component: 'StrengthMeter',
  348. componentProps: {
  349. placeholder: '请输入登录密码',
  350. },
  351. rules: [
  352. {
  353. required: true,
  354. message: '请输入登录密码',
  355. },
  356. // {
  357. // pattern: /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,./]).{8,}$/,
  358. // message: '密码由8位数字、大小写字母和特殊符号组成!',
  359. // },
  360. ],
  361. },
  362. {
  363. label: '确认密码',
  364. field: 'confirmPassword',
  365. component: 'InputPassword',
  366. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  367. },
  368. ];
  369. export const formAgentSchema: FormSchema[] = [
  370. {
  371. label: '',
  372. field: 'id',
  373. component: 'Input',
  374. show: false,
  375. },
  376. {
  377. field: 'userName',
  378. label: '用户名',
  379. component: 'Input',
  380. componentProps: {
  381. readOnly: true,
  382. allowClear: false,
  383. },
  384. },
  385. {
  386. field: 'agentUserName',
  387. label: '代理人用户名',
  388. required: true,
  389. component: 'JSelectUser',
  390. componentProps: {
  391. rowKey: 'username',
  392. labelKey: 'realname',
  393. maxSelectCount: 10,
  394. },
  395. },
  396. {
  397. field: 'startTime',
  398. label: '代理开始时间',
  399. component: 'DatePicker',
  400. required: true,
  401. componentProps: {
  402. showTime: true,
  403. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  404. placeholder: '请选择代理开始时间',
  405. getPopupContainer: () => document.body,
  406. },
  407. },
  408. {
  409. field: 'endTime',
  410. label: '代理结束时间',
  411. component: 'DatePicker',
  412. required: true,
  413. componentProps: {
  414. showTime: true,
  415. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  416. placeholder: '请选择代理结束时间',
  417. getPopupContainer: () => document.body,
  418. },
  419. },
  420. {
  421. field: 'status',
  422. label: '状态',
  423. component: 'JDictSelectTag',
  424. defaultValue: '1',
  425. componentProps: {
  426. dictCode: 'valid_status',
  427. type: 'radioButton',
  428. },
  429. },
  430. ];
  431. export const formQuitAgentSchema: FormSchema[] = [
  432. {
  433. label: '',
  434. field: 'id',
  435. component: 'Input',
  436. show: false,
  437. },
  438. {
  439. field: 'userName',
  440. label: '用户名',
  441. component: 'Input',
  442. componentProps: {
  443. readOnly: true,
  444. allowClear: false,
  445. },
  446. },
  447. {
  448. field: 'agentUserName',
  449. label: '交接人员',
  450. //required: true,
  451. component: 'JSelectUser',
  452. componentProps: {
  453. rowKey: 'username',
  454. labelKey: 'realname',
  455. maxSelectCount: 1,
  456. },
  457. },
  458. {
  459. field: 'startTime',
  460. label: '交接开始时间',
  461. component: 'DatePicker',
  462. //required: true,
  463. componentProps: {
  464. showTime: true,
  465. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  466. placeholder: '请选择交接开始时间',
  467. getPopupContainer: () => document.body,
  468. },
  469. },
  470. {
  471. field: 'endTime',
  472. label: '交接结束时间',
  473. component: 'DatePicker',
  474. //required: true,
  475. componentProps: {
  476. showTime: true,
  477. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  478. placeholder: '请选择交接结束时间',
  479. getPopupContainer: () => document.body,
  480. },
  481. },
  482. {
  483. field: 'status',
  484. label: '状态',
  485. component: 'JDictSelectTag',
  486. defaultValue: '1',
  487. componentProps: {
  488. dictCode: 'valid_status',
  489. type: 'radioButton',
  490. },
  491. },
  492. ];
  493. //租户用户列表
  494. export const userTenantColumns: BasicColumn[] = [
  495. {
  496. title: '用户账号',
  497. dataIndex: 'username',
  498. width: 120,
  499. },
  500. {
  501. title: '用户姓名',
  502. dataIndex: 'realname',
  503. width: 100,
  504. },
  505. {
  506. title: '头像',
  507. dataIndex: 'avatar',
  508. width: 120,
  509. customRender: render.renderAvatar,
  510. },
  511. {
  512. title: '手机号',
  513. dataIndex: 'phone',
  514. width: 100,
  515. },
  516. {
  517. title: '部门',
  518. width: 150,
  519. dataIndex: 'orgCodeTxt',
  520. },
  521. {
  522. title: '状态',
  523. dataIndex: 'status',
  524. width: 80,
  525. customRender: ({ text }) => {
  526. if (text === '1') {
  527. return '正常';
  528. } else if (text === '3') {
  529. return '审批中';
  530. } else {
  531. return '已拒绝';
  532. }
  533. },
  534. },
  535. ];
  536. //用户租户搜索表单
  537. export const userTenantFormSchema: FormSchema[] = [
  538. {
  539. label: '账号',
  540. field: 'username',
  541. component: 'Input',
  542. colProps: { span: 6 },
  543. },
  544. {
  545. label: '名字',
  546. field: 'realname',
  547. component: 'Input',
  548. colProps: { span: 6 },
  549. },
  550. {
  551. label: '性别',
  552. field: 'sex',
  553. component: 'JDictSelectTag',
  554. componentProps: {
  555. dictCode: 'sex',
  556. placeholder: '请选择性别',
  557. stringToNumber: true,
  558. },
  559. colProps: { span: 6 },
  560. },
  561. ];