user.data.ts 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  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: 'sex',
  95. component: 'JDictSelectTag',
  96. componentProps: {
  97. dictCode:'sex',
  98. placeholder:'请选择性别',
  99. stringToNumber:true
  100. },
  101. colProps: {span: 6},
  102. },
  103. {
  104. label: '真实名称',
  105. field: 'realname',
  106. component: 'Input',
  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. field: 'departIds',
  208. componentProps: {options},
  209. }]);
  210. //所属部门修改后更新负责部门数据
  211. formModel.departIds&&(formModel.departIds = formModel.departIds.filter(item=>values.value.indexOf(item)>-1));
  212. }
  213. }
  214. }
  215. },
  216. {
  217. label: '租户',
  218. field: 'relTenantIds',
  219. component: 'ApiSelect',
  220. componentProps: {
  221. mode: "multiple",
  222. api: getAllTenantList,
  223. numberToString:true,
  224. labelField: 'name',
  225. valueField: 'id',
  226. }
  227. },
  228. {
  229. label: '身份',
  230. field: 'userIdentity',
  231. component: 'RadioGroup',
  232. defaultValue: 1,
  233. componentProps:({ formModel }) => {
  234. return {
  235. options: [{label: '普通用户',value: 1,key: '1'},{label: '上级',value: 2,key: '2'}],
  236. onChange: () => {
  237. formModel.userIdentity==1&&(formModel.departIds=[]);
  238. }
  239. }
  240. },
  241. },
  242. {
  243. label: '负责部门',
  244. field: 'departIds',
  245. component: 'Select',
  246. componentProps: {
  247. mode: "multiple",
  248. },
  249. ifShow: ({values}) => (values.userIdentity==2),
  250. },
  251. {
  252. label: '头像',
  253. field: 'avatar',
  254. component: 'JImageUpload',
  255. componentProps: {
  256. fileMax:1
  257. },
  258. },
  259. {
  260. label: '生日',
  261. field: 'birthday',
  262. component: 'DatePicker',
  263. },
  264. {
  265. label: '性别',
  266. field: 'sex',
  267. component: 'JDictSelectTag',
  268. componentProps: {
  269. dictCode:'sex',
  270. placeholder:'请选择性别',
  271. stringToNumber:true
  272. },
  273. },
  274. {
  275. label: '邮箱',
  276. field: 'email',
  277. component: 'Input',
  278. rules: rules.rule('email',false),
  279. },
  280. {
  281. label: '手机号码',
  282. field: 'phone',
  283. component: 'Input',
  284. dynamicRules: ({model,schema}) => {
  285. return [
  286. {...rules.duplicateCheckRule( "sys_user", "phone",model,schema,true)[0]},
  287. { pattern: /^1[3|4|5|7|8|9][0-9]\d{8}$/, message: '手机号码格式有误' }
  288. ];
  289. },
  290. },
  291. {
  292. label: '座机',
  293. field: 'telephone',
  294. component: 'Input',
  295. rules: [{ pattern: /^0\d{2,3}-[1-9]\d{6,7}$/, message: '请输入正确的座机号码' }]
  296. },
  297. {
  298. label: '工作流引擎',
  299. field: 'activitiSync',
  300. defaultValue: 1,
  301. component: 'JDictSelectTag',
  302. componentProps: {
  303. dictCode:'activiti_sync',
  304. type:'radio',
  305. stringToNumber:true
  306. },
  307. }
  308. ];
  309. export const formPasswordSchema: FormSchema[] = [
  310. {
  311. label: '用户账号',
  312. field: 'username',
  313. component: 'Input',
  314. componentProps: {readOnly: true}
  315. },
  316. {
  317. label: '登录密码',
  318. field: 'password',
  319. component: 'StrengthMeter',
  320. componentProps: {
  321. placeholder: '请输入登录密码',
  322. },
  323. rules: [
  324. {
  325. required: true,
  326. message: '请输入登录密码',
  327. },
  328. ],
  329. },
  330. {
  331. label: '确认密码',
  332. field: 'confirmPassword',
  333. component: 'InputPassword',
  334. dynamicRules: ({values}) => rules.confirmPassword(values,true)
  335. }
  336. ];
  337. export const formAgentSchema: FormSchema[] = [{
  338. label: '',
  339. field: 'id',
  340. component: 'Input',
  341. show: false
  342. },{
  343. field: 'userName',
  344. label: '用户名',
  345. component: 'Input',
  346. componentProps: {
  347. readOnly: true,
  348. allowClear:false
  349. }
  350. },
  351. {
  352. field: 'agentUserName',
  353. label: '代理人用户名',
  354. required: true,
  355. component: 'JSelectUser',
  356. componentProps: {
  357. rowKey:'username',
  358. labelKey:'realname',
  359. maxSelectCount:10
  360. },
  361. },
  362. {
  363. field: 'startTime',
  364. label: '代理开始时间',
  365. component: 'DatePicker',
  366. required: true,
  367. componentProps: {
  368. showTime: true,
  369. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  370. placeholder: '请选择代理开始时间',
  371. }
  372. },
  373. {
  374. field: 'endTime',
  375. label: '代理结束时间',
  376. component: 'DatePicker',
  377. required: true,
  378. componentProps: {
  379. showTime: true,
  380. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  381. placeholder: '请选择代理结束时间',
  382. }
  383. },
  384. {
  385. field: 'status',
  386. label: '状态',
  387. component: 'JDictSelectTag',
  388. defaultValue: "1",
  389. componentProps: {
  390. dictCode:'valid_status',
  391. type:'radioButton'
  392. },
  393. }]