user.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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/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. editDisabled: true,
  45. addVisdiplay: false,
  46. }, {
  47. fixed: true,
  48. label: '用户名',
  49. prop: 'username',
  50. editDisabled: true,
  51. solt: true,
  52. search: true,
  53. span: 24,
  54. rules: [{
  55. required: true,
  56. message: "请输入用户名",
  57. },
  58. {
  59. min: 3,
  60. max: 20,
  61. message: "长度在 3 到 20 个字符",
  62. trigger: "blur"
  63. },
  64. { validator: validateUsername, trigger: 'blur' }
  65. ]
  66. }, {
  67. label: '密码',
  68. prop: 'password',
  69. type: 'password',
  70. value: '',
  71. hide: true,
  72. span: 24,
  73. rules: [{
  74. min: 6,
  75. max: 20,
  76. message: "长度在 6 到 20 个字符",
  77. trigger: "blur"
  78. }]
  79. }, {
  80. label: '所属部门',
  81. prop: 'deptId',
  82. formsolt: true,
  83. solt: true,
  84. span: 24,
  85. rules: [{
  86. required: true,
  87. message: "请选择部门",
  88. trigger: "blur"
  89. }]
  90. }, {
  91. label: '角色',
  92. prop: 'role',
  93. formsolt: true,
  94. solt: true,
  95. span: 24,
  96. rules: [{
  97. required: true,
  98. message: "请选择角色",
  99. trigger: "blur"
  100. }],
  101. }, {
  102. label: '状态',
  103. prop: 'lockFlag',
  104. type: "select",
  105. solt: true,
  106. span: 24,
  107. rules: [{
  108. required: true,
  109. message: "请选择状态",
  110. trigger: "blur"
  111. }],
  112. dicData: [{
  113. label: '有效',
  114. value: '0'
  115. }, {
  116. label: '锁定',
  117. value: '9'
  118. }]
  119. }, {
  120. width: 180,
  121. label: '创建时间',
  122. prop: 'createTime',
  123. type: 'datetime',
  124. format: 'yyyy-MM-dd HH:mm',
  125. valueFormat: 'yyyy-MM-dd HH:mm:ss',
  126. more: true,
  127. editDisabled: true,
  128. addVisdiplay: false,
  129. span: 24,
  130. }]
  131. }