user.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (c) 2018-2025, lengleng All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * Redistributions of source code must retain the above copyright notice,
  8. * this list of conditions and the following disclaimer.
  9. * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * Neither the name of the pig4cloud.com developer nor the names of its
  13. * contributors may be used to endorse or promote products derived from
  14. * this software without specific prior written permission.
  15. * Author: lengleng (wangiegie@gmail.com)
  16. */
  17. import {getDetails} from '@/api/admin/user'
  18. var validateUsername = (rule, value, callback) => {
  19. getDetails(value).then(response => {
  20. if (window.boxType === 'edit') callback()
  21. let result = response.data.data
  22. if (result !== null) {
  23. callback(new Error('用户名已经存在'))
  24. } else {
  25. callback()
  26. }
  27. })
  28. }
  29. export const tableOption = {
  30. border: true,
  31. index: true,
  32. indexLabel: '序号',
  33. stripe: true,
  34. menuAlign: 'center',
  35. editBtn: false,
  36. delBtn: false,
  37. align: 'center',
  38. addBtn: false,
  39. column: [{
  40. fixed: true,
  41. label: 'id',
  42. prop: 'userId',
  43. span: 24,
  44. hide: true,
  45. editDisabled: true,
  46. addVisdiplay: false
  47. }, {
  48. fixed: true,
  49. label: '用户名',
  50. prop: 'username',
  51. editDisabled: true,
  52. solt: true,
  53. search: true,
  54. span: 24,
  55. rules: [{
  56. required: true,
  57. message: '请输入用户名'
  58. },
  59. {
  60. min: 3,
  61. max: 20,
  62. message: '长度在 3 到 20 个字符',
  63. trigger: 'blur'
  64. },
  65. {validator: validateUsername, trigger: 'blur'}
  66. ]
  67. }, {
  68. label: '密码',
  69. prop: 'password',
  70. type: 'password',
  71. value: '',
  72. hide: true,
  73. span: 24,
  74. rules: [{
  75. min: 6,
  76. max: 20,
  77. message: '长度在 6 到 20 个字符',
  78. trigger: 'blur'
  79. }]
  80. }, {
  81. label: '所属部门',
  82. prop: 'deptId',
  83. formsolt: true,
  84. solt: true,
  85. span: 24,
  86. hide: true,
  87. rules: [{
  88. required: true,
  89. message: '请选择部门',
  90. trigger: 'change'
  91. }]
  92. }, {
  93. label: '手机号',
  94. prop: 'phone',
  95. type: 'tel',
  96. value: '',
  97. span: 24,
  98. rules: [{
  99. min: 11,
  100. max: 11,
  101. message: '长度在 11 个字符',
  102. trigger: 'blur'
  103. }]
  104. }, {
  105. label: '角色',
  106. prop: 'role',
  107. formsolt: true,
  108. solt: true,
  109. overHidden: true,
  110. span: 24,
  111. rules: [{
  112. required: true,
  113. message: '请选择角色',
  114. trigger: 'blur'
  115. }]
  116. }, {
  117. label: '状态',
  118. prop: 'lockFlag',
  119. type: 'select',
  120. solt: true,
  121. span: 24,
  122. rules: [{
  123. required: true,
  124. message: '请选择状态',
  125. trigger: 'blur'
  126. }],
  127. dicData: [{
  128. label: '有效',
  129. value: '0'
  130. }, {
  131. label: '锁定',
  132. value: '9'
  133. }]
  134. }, {
  135. width: 180,
  136. label: '创建时间',
  137. prop: 'createTime',
  138. type: 'datetime',
  139. format: 'yyyy-MM-dd HH:mm',
  140. valueFormat: 'yyyy-MM-dd HH:mm:ss',
  141. editDisabled: true,
  142. addVisdiplay: false,
  143. span: 24
  144. }]
  145. }