user.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. const 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. searchShow: false,
  36. editBtn: false,
  37. delBtn: false,
  38. align: 'center',
  39. addBtn: false,
  40. column: [{
  41. fixed: true,
  42. label: 'id',
  43. prop: 'userId',
  44. span: 24,
  45. hide: true,
  46. editDisabled: true,
  47. addDisplay: false
  48. }, {
  49. fixed: true,
  50. label: '用户名',
  51. prop: 'username',
  52. editDisabled: true,
  53. slot: true,
  54. search: true,
  55. span: 24,
  56. rules: [{
  57. required: true,
  58. message: '请输入用户名'
  59. },
  60. {
  61. min: 3,
  62. max: 20,
  63. message: '长度在 3 到 20 个字符',
  64. trigger: 'blur'
  65. },
  66. {validator: validateUsername, trigger: 'blur'}
  67. ]
  68. }, {
  69. label: '密码',
  70. prop: 'password',
  71. type: 'password',
  72. value: '',
  73. hide: true,
  74. span: 24,
  75. rules: [{
  76. min: 6,
  77. max: 20,
  78. message: '长度在 6 到 20 个字符',
  79. trigger: 'blur'
  80. }]
  81. }, {
  82. label: '所属部门',
  83. prop: 'deptId',
  84. formslot: true,
  85. slot: true,
  86. span: 24,
  87. hide: true,
  88. dataType:"number",
  89. rules: [{
  90. required: true,
  91. message: '请选择部门',
  92. trigger: 'change'
  93. }]
  94. }, {
  95. label: '手机号',
  96. prop: 'phone',
  97. type: 'tel',
  98. value: '',
  99. span: 24,
  100. rules: [{
  101. min: 11,
  102. max: 11,
  103. message: '长度在 11 个字符',
  104. trigger: 'blur'
  105. }]
  106. }, {
  107. label: '角色',
  108. prop: 'role',
  109. formslot: true,
  110. slot: true,
  111. overHidden: true,
  112. span: 24,
  113. rules: [{
  114. required: true,
  115. message: '请选择角色',
  116. trigger: 'blur'
  117. }]
  118. }, {
  119. label: '状态',
  120. prop: 'lockFlag',
  121. type: 'radio',
  122. slot: true,
  123. border:true,
  124. span: 24,
  125. rules: [{
  126. required: true,
  127. message: '请选择状态',
  128. trigger: 'blur'
  129. }],
  130. dicData: [{
  131. label: '有效',
  132. value: '0'
  133. }, {
  134. label: '锁定',
  135. value: '9'
  136. }]
  137. }, {
  138. width: 180,
  139. label: '创建时间',
  140. prop: 'createTime',
  141. type: 'datetime',
  142. format: 'yyyy-MM-dd HH:mm',
  143. valueFormat: 'yyyy-MM-dd HH:mm:ss',
  144. editDisabled: true,
  145. addDisplay: false,
  146. span: 24
  147. }]
  148. }