user.data.ts 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. import { BasicColumn } from '/@/components/Table';
  2. import { FormSchema } from '/@/components/Table';
  3. import { getAllRolesList, 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: 'userRoles',
  26. width: 100,
  27. customRender: ({ value }) => {
  28. const nameList = [];
  29. value.forEach((item) => {
  30. nameList.push(item['roleName']);
  31. });
  32. return nameList.toString();
  33. },
  34. },
  35. {
  36. title: '性别',
  37. dataIndex: 'sex',
  38. width: 80,
  39. sorter: true,
  40. customRender: ({ text }) => {
  41. return render.renderDict(text, 'sex');
  42. },
  43. },
  44. {
  45. title: '生日',
  46. dataIndex: 'birthday',
  47. width: 100,
  48. },
  49. {
  50. title: '手机号',
  51. dataIndex: 'phone',
  52. width: 100,
  53. },
  54. {
  55. title: '部门',
  56. width: 150,
  57. dataIndex: 'orgCodeTxt',
  58. },
  59. {
  60. title: '负责部门',
  61. width: 150,
  62. dataIndex: 'departIds_dictText',
  63. },
  64. {
  65. title: '状态',
  66. dataIndex: 'status_dictText',
  67. width: 80,
  68. },
  69. ];
  70. export const recycleColumns: BasicColumn[] = [
  71. {
  72. title: '用户账号',
  73. dataIndex: 'username',
  74. width: 100,
  75. },
  76. {
  77. title: '用户姓名',
  78. dataIndex: 'realname',
  79. width: 100,
  80. },
  81. {
  82. title: '头像',
  83. dataIndex: 'avatar',
  84. width: 80,
  85. customRender: render.renderAvatar,
  86. },
  87. {
  88. title: '性别',
  89. dataIndex: 'sex',
  90. width: 80,
  91. sorter: true,
  92. customRender: ({ text }) => {
  93. return render.renderDict(text, 'sex');
  94. },
  95. },
  96. ];
  97. export const searchFormSchema: FormSchema[] = [
  98. {
  99. label: '账号',
  100. field: 'username',
  101. component: 'JInput',
  102. colProps: { span: 6 },
  103. },
  104. {
  105. label: '名字',
  106. field: 'realname',
  107. component: 'JInput',
  108. colProps: { span: 6 },
  109. },
  110. {
  111. label: '性别',
  112. field: 'sex',
  113. component: 'JDictSelectTag',
  114. componentProps: {
  115. dictCode: 'sex',
  116. placeholder: '请选择性别',
  117. stringToNumber: true,
  118. },
  119. colProps: { span: 6 },
  120. },
  121. {
  122. label: '手机号码',
  123. field: 'phone',
  124. component: 'Input',
  125. colProps: { span: 6 },
  126. },
  127. {
  128. label: '用户状态',
  129. field: 'status',
  130. component: 'JDictSelectTag',
  131. componentProps: {
  132. dictCode: 'user_status',
  133. placeholder: '请选择状态',
  134. stringToNumber: true,
  135. },
  136. colProps: { span: 6 },
  137. },
  138. ];
  139. export const formSchema: FormSchema[] = [
  140. {
  141. label: '',
  142. field: 'id',
  143. component: 'Input',
  144. show: false,
  145. },
  146. {
  147. label: '用户账号',
  148. field: 'username',
  149. component: 'Input',
  150. dynamicDisabled: ({ values }) => {
  151. return !!values.id;
  152. },
  153. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'username', model, schema, true),
  154. },
  155. {
  156. label: '登录密码',
  157. field: 'password',
  158. component: 'StrengthMeter',
  159. rules: [
  160. {
  161. required: true,
  162. message: '请输入登录密码',
  163. },
  164. ],
  165. },
  166. {
  167. label: '确认密码',
  168. field: 'confirmPassword',
  169. component: 'InputPassword',
  170. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  171. },
  172. {
  173. label: '用户姓名',
  174. field: 'realname',
  175. required: true,
  176. component: 'Input',
  177. },
  178. {
  179. label: '工号',
  180. field: 'workNo',
  181. required: true,
  182. component: 'Input',
  183. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'work_no', model, schema, true),
  184. },
  185. {
  186. label: '职务',
  187. field: 'post',
  188. required: false,
  189. component: 'JSelectPosition',
  190. componentProps: {
  191. rowKey: 'code',
  192. labelKey: 'name',
  193. },
  194. },
  195. {
  196. label: '角色',
  197. field: 'selectedroles',
  198. component: 'ApiSelect',
  199. componentProps: {
  200. mode: 'multiple',
  201. api: getAllRolesList,
  202. labelField: 'roleName',
  203. valueField: 'id',
  204. },
  205. },
  206. {
  207. label: '所属部门',
  208. field: 'selecteddeparts',
  209. component: 'JSelectDept',
  210. componentProps: ({ formActionType, formModel }) => {
  211. return {
  212. sync: false,
  213. checkStrictly: true,
  214. defaultExpandLevel: 2,
  215. onSelect: (options, values) => {
  216. const { updateSchema } = formActionType;
  217. //所属部门修改后更新负责部门下拉框数据
  218. updateSchema([
  219. {
  220. field: 'departIds',
  221. componentProps: { options },
  222. },
  223. ]);
  224. //所属部门修改后更新负责部门数据
  225. formModel.departIds && (formModel.departIds = formModel.departIds.filter((item) => values.value.indexOf(item) > -1));
  226. },
  227. };
  228. },
  229. },
  230. {
  231. label: '租户',
  232. field: 'relTenantIds',
  233. component: 'ApiSelect',
  234. componentProps: {
  235. mode: 'multiple',
  236. api: getAllTenantList,
  237. numberToString: true,
  238. labelField: 'name',
  239. valueField: 'id',
  240. },
  241. },
  242. {
  243. label: '身份',
  244. field: 'userIdentity',
  245. component: 'RadioGroup',
  246. defaultValue: 1,
  247. componentProps: ({ formModel }) => {
  248. return {
  249. options: [
  250. { label: '普通用户', value: 1, key: '1' },
  251. { label: '上级', value: 2, key: '2' },
  252. ],
  253. onChange: () => {
  254. formModel.userIdentity == 1 && (formModel.departIds = []);
  255. },
  256. };
  257. },
  258. },
  259. {
  260. label: '负责部门',
  261. field: 'departIds',
  262. component: 'Select',
  263. componentProps: {
  264. mode: 'multiple',
  265. },
  266. ifShow: ({ values }) => values.userIdentity == 2,
  267. },
  268. {
  269. label: '头像',
  270. field: 'avatar',
  271. component: 'JImageUpload',
  272. componentProps: {
  273. fileMax: 1,
  274. },
  275. },
  276. {
  277. label: '生日',
  278. field: 'birthday',
  279. component: 'DatePicker',
  280. },
  281. {
  282. label: '性别',
  283. field: 'sex',
  284. component: 'JDictSelectTag',
  285. componentProps: {
  286. dictCode: 'sex',
  287. placeholder: '请选择性别',
  288. stringToNumber: true,
  289. },
  290. },
  291. {
  292. label: '区队',
  293. field: 'districtTeam',
  294. component: 'JDictSelectTag',
  295. componentProps: {
  296. dictCode: 'districtTeam',
  297. placeholder: '请选择区队',
  298. },
  299. },
  300. {
  301. label: '邮箱',
  302. field: 'email',
  303. component: 'Input',
  304. rules: rules.rule('email', false),
  305. },
  306. {
  307. label: '手机号码',
  308. field: 'phone',
  309. component: 'Input',
  310. dynamicRules: ({ model, schema }) => {
  311. return [
  312. { ...rules.duplicateCheckRule('sys_user', 'phone', model, schema, true)[0] },
  313. { pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误' },
  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. },
  356. {
  357. label: '确认密码',
  358. field: 'confirmPassword',
  359. component: 'InputPassword',
  360. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  361. },
  362. ];
  363. export const formAgentSchema: FormSchema[] = [
  364. {
  365. label: '',
  366. field: 'id',
  367. component: 'Input',
  368. show: false,
  369. },
  370. {
  371. field: 'userName',
  372. label: '用户名',
  373. component: 'Input',
  374. componentProps: {
  375. readOnly: true,
  376. allowClear: false,
  377. },
  378. },
  379. {
  380. field: 'agentUserName',
  381. label: '代理人用户名',
  382. required: true,
  383. component: 'JSelectUser',
  384. componentProps: {
  385. rowKey: 'username',
  386. labelKey: 'realname',
  387. maxSelectCount: 10,
  388. },
  389. },
  390. {
  391. field: 'startTime',
  392. label: '代理开始时间',
  393. component: 'DatePicker',
  394. required: true,
  395. componentProps: {
  396. showTime: true,
  397. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  398. placeholder: '请选择代理开始时间',
  399. },
  400. },
  401. {
  402. field: 'endTime',
  403. label: '代理结束时间',
  404. component: 'DatePicker',
  405. required: true,
  406. componentProps: {
  407. showTime: true,
  408. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  409. placeholder: '请选择代理结束时间',
  410. },
  411. },
  412. {
  413. field: 'status',
  414. label: '状态',
  415. component: 'JDictSelectTag',
  416. defaultValue: '1',
  417. componentProps: {
  418. dictCode: 'valid_status',
  419. type: 'radioButton',
  420. },
  421. },
  422. ];