user.data.ts 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  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: '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. dynamicDisabled: ({ values }) => {
  139. return !!values.id;
  140. },
  141. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'username', model, schema, true),
  142. },
  143. {
  144. label: '登录密码',
  145. field: 'password',
  146. component: 'StrengthMeter',
  147. rules: [
  148. {
  149. required: true,
  150. message: '请输入登录密码',
  151. },
  152. ],
  153. },
  154. {
  155. label: '确认密码',
  156. field: 'confirmPassword',
  157. component: 'InputPassword',
  158. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  159. },
  160. {
  161. label: '用户姓名',
  162. field: 'realname',
  163. required: true,
  164. component: 'Input',
  165. },
  166. {
  167. label: '工号',
  168. field: 'workNo',
  169. required: true,
  170. component: 'Input',
  171. dynamicRules: ({ model, schema }) => rules.duplicateCheckRule('sys_user', 'work_no', model, schema, true),
  172. },
  173. {
  174. label: '职务',
  175. field: 'post',
  176. required: false,
  177. component: 'JSelectPosition',
  178. componentProps: {
  179. rowKey: 'code',
  180. labelKey: 'name',
  181. },
  182. },
  183. {
  184. label: '角色',
  185. field: 'selectedroles',
  186. component: 'ApiSelect',
  187. componentProps: {
  188. mode: 'multiple',
  189. api: getAllRolesList,
  190. labelField: 'roleName',
  191. valueField: 'id',
  192. },
  193. },
  194. {
  195. label: '所属部门',
  196. field: 'selecteddeparts',
  197. component: 'JSelectDept',
  198. componentProps: ({ formActionType, formModel }) => {
  199. return {
  200. sync: false,
  201. checkStrictly: true,
  202. defaultExpandLevel: 2,
  203. onSelect: (options, values) => {
  204. const { updateSchema } = formActionType;
  205. //所属部门修改后更新负责部门下拉框数据
  206. updateSchema([
  207. {
  208. field: 'departIds',
  209. componentProps: { options },
  210. },
  211. ]);
  212. //所属部门修改后更新负责部门数据
  213. formModel.departIds && (formModel.departIds = formModel.departIds.filter((item) => values.value.indexOf(item) > -1));
  214. },
  215. };
  216. },
  217. },
  218. {
  219. label: '租户',
  220. field: 'relTenantIds',
  221. component: 'ApiSelect',
  222. componentProps: {
  223. mode: 'multiple',
  224. api: getAllTenantList,
  225. numberToString: true,
  226. labelField: 'name',
  227. valueField: 'id',
  228. },
  229. },
  230. {
  231. label: '身份',
  232. field: 'userIdentity',
  233. component: 'RadioGroup',
  234. defaultValue: 1,
  235. componentProps: ({ formModel }) => {
  236. return {
  237. options: [
  238. { label: '普通用户', value: 1, key: '1' },
  239. { label: '上级', value: 2, key: '2' },
  240. ],
  241. onChange: () => {
  242. formModel.userIdentity == 1 && (formModel.departIds = []);
  243. },
  244. };
  245. },
  246. },
  247. {
  248. label: '负责部门',
  249. field: 'departIds',
  250. component: 'Select',
  251. componentProps: {
  252. mode: 'multiple',
  253. },
  254. ifShow: ({ values }) => values.userIdentity == 2,
  255. },
  256. {
  257. label: '头像',
  258. field: 'avatar',
  259. component: 'JImageUpload',
  260. componentProps: {
  261. fileMax: 1,
  262. },
  263. },
  264. {
  265. label: '生日',
  266. field: 'birthday',
  267. component: 'DatePicker',
  268. },
  269. {
  270. label: '性别',
  271. field: 'sex',
  272. component: 'JDictSelectTag',
  273. componentProps: {
  274. dictCode: 'sex',
  275. placeholder: '请选择性别',
  276. stringToNumber: true,
  277. },
  278. },
  279. {
  280. label: '邮箱',
  281. field: 'email',
  282. component: 'Input',
  283. rules: rules.rule('email', false),
  284. },
  285. {
  286. label: '手机号码',
  287. field: 'phone',
  288. component: 'Input',
  289. dynamicRules: ({ model, schema }) => {
  290. return [
  291. { ...rules.duplicateCheckRule('sys_user', 'phone', model, schema, true)[0] },
  292. { pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误' },
  293. ];
  294. },
  295. },
  296. {
  297. label: '座机',
  298. field: 'telephone',
  299. component: 'Input',
  300. rules: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }],
  301. },
  302. {
  303. label: '工作流引擎',
  304. field: 'activitiSync',
  305. defaultValue: 1,
  306. component: 'JDictSelectTag',
  307. componentProps: {
  308. dictCode: 'activiti_sync',
  309. type: 'radio',
  310. stringToNumber: true,
  311. },
  312. },
  313. ];
  314. export const formPasswordSchema: FormSchema[] = [
  315. {
  316. label: '用户账号',
  317. field: 'username',
  318. component: 'Input',
  319. componentProps: { readOnly: true },
  320. },
  321. {
  322. label: '登录密码',
  323. field: 'password',
  324. component: 'StrengthMeter',
  325. componentProps: {
  326. placeholder: '请输入登录密码',
  327. },
  328. rules: [
  329. {
  330. required: true,
  331. message: '请输入登录密码',
  332. },
  333. ],
  334. },
  335. {
  336. label: '确认密码',
  337. field: 'confirmPassword',
  338. component: 'InputPassword',
  339. dynamicRules: ({ values }) => rules.confirmPassword(values, true),
  340. },
  341. ];
  342. export const formAgentSchema: FormSchema[] = [
  343. {
  344. label: '',
  345. field: 'id',
  346. component: 'Input',
  347. show: false,
  348. },
  349. {
  350. field: 'userName',
  351. label: '用户名',
  352. component: 'Input',
  353. componentProps: {
  354. readOnly: true,
  355. allowClear: false,
  356. },
  357. },
  358. {
  359. field: 'agentUserName',
  360. label: '代理人用户名',
  361. required: true,
  362. component: 'JSelectUser',
  363. componentProps: {
  364. rowKey: 'username',
  365. labelKey: 'realname',
  366. maxSelectCount: 10,
  367. },
  368. },
  369. {
  370. field: 'startTime',
  371. label: '代理开始时间',
  372. component: 'DatePicker',
  373. required: true,
  374. componentProps: {
  375. showTime: true,
  376. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  377. placeholder: '请选择代理开始时间',
  378. },
  379. },
  380. {
  381. field: 'endTime',
  382. label: '代理结束时间',
  383. component: 'DatePicker',
  384. required: true,
  385. componentProps: {
  386. showTime: true,
  387. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  388. placeholder: '请选择代理结束时间',
  389. },
  390. },
  391. {
  392. field: 'status',
  393. label: '状态',
  394. component: 'JDictSelectTag',
  395. defaultValue: '1',
  396. componentProps: {
  397. dictCode: 'valid_status',
  398. type: 'radioButton',
  399. },
  400. },
  401. ];