index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. const defaultProps = {
  2. label: 'label',
  3. children: 'children',
  4. value: 'id'
  5. }
  6. const majorProps = {
  7. label: 'avmatCategoriesName',
  8. children: 'children',
  9. value: 'avmatCategoriesId'
  10. }
  11. export const columns = (_this) => {
  12. return [
  13. {
  14. prop: 'nickName',
  15. label: '用户名称',
  16. align: 'center'
  17. },
  18. {
  19. prop: 'userName',
  20. label: '登录账号'
  21. },
  22. {
  23. prop: 'deptName',
  24. label: '所属机构'
  25. },
  26. {
  27. prop: 'majorName',
  28. label: '所属专业'
  29. },
  30. {
  31. prop: 'sex',
  32. label: '性别',
  33. width: '80px',
  34. render: (h, params) => {
  35. if (params.row.sex == 1) {
  36. return h('span', '男')
  37. } else {
  38. return h('span', '女')
  39. }
  40. }
  41. },
  42. {
  43. prop: 'phonenumber',
  44. label: '联系方式'
  45. },
  46. {
  47. prop: 'status',
  48. label: '状态',
  49. width: '80px',
  50. render: (h, params) => {
  51. if (params.row.status == 0) {
  52. return h('span', { class: 'success-state' }, '启用')
  53. } else {
  54. return h('span', { class: 'warning-state' }, '禁用')
  55. }
  56. }
  57. },
  58. {
  59. prop: 'remark',
  60. label: '备注'
  61. },
  62. {
  63. button: true,
  64. label: '操作',
  65. width: '350px',
  66. group: [
  67. {
  68. name: '编辑',
  69. type: 'text',
  70. round: false,
  71. plain: false,
  72. onClick: (row, index, scope) => {
  73. _this.compileBtn(row)
  74. }
  75. },
  76. {
  77. name: '启用',
  78. type: 'text',
  79. statusKey: 'status',
  80. unDisableKey: 1,
  81. round: false,
  82. plain: false,
  83. onClick: (row, index, scope) => {
  84. _this.toggle(row.userId, '启用')
  85. }
  86. },
  87. {
  88. name: '禁用',
  89. type: 'text',
  90. statusKey: 'status',
  91. unDisableKey: 0,
  92. round: false,
  93. plain: false,
  94. onClick: (row, index, scope) => {
  95. _this.toggle(row.userId, '禁用')
  96. }
  97. },
  98. {
  99. name: '删除',
  100. type: 'text',
  101. round: false,
  102. plain: false,
  103. onClick: (row, index, scope) => {
  104. _this.handRemove(row)
  105. }
  106. },
  107. {
  108. name: '重置密码',
  109. type: 'text',
  110. round: false,
  111. plain: false,
  112. onClick: (row, index, scope) => {
  113. _this.resetPwd(row.userId)
  114. }
  115. },
  116. {
  117. name: '角色分配',
  118. type: 'text',
  119. round: false,
  120. plain: false,
  121. onClick: (row, index, scope) => {
  122. _this.powerSetup(row)
  123. }
  124. }
  125. ]
  126. }
  127. ]
  128. }
  129. export const options = {
  130. stripe: false, // 斑马纹
  131. mutiSelect: true, // 多选框
  132. index: false, // 显示序号, 多选则 mutiSelect
  133. loading: false, // 表格动画
  134. border: true,
  135. initTable: true, // 是否一挂载就加载数据
  136. height: 'calc(100vh - 345px)'
  137. }
  138. export const modalConfig = (_this) => ({
  139. formItems: [
  140. { key: 'nickName', type: 'input', label: '用户名称', placeHolder: '请输入用户名称' },
  141. { key: 'userName', type: 'input', label: '登录账号', placeHolder: '请输入登录账号', showPassword: true },
  142. {
  143. key: 'deptId',
  144. keyLabel: 'deptName',
  145. type: 'treeSelect',
  146. label: '所属机构',
  147. valueOptions: _this.valueOptions,
  148. defaultProps: defaultProps,
  149. colLayout: { span: 12 }
  150. },
  151. {
  152. key: 'majorId',
  153. keyLabel: 'majorName',
  154. type: 'treeSelect',
  155. label: '所属专业',
  156. valueOptions: _this.majorOptions,
  157. defaultProps: majorProps,
  158. colLayout: { span: 12 }
  159. },
  160. { key: 'phonenumber', type: 'input', label: '联系方式', placeHolder: '请输入联系方式' },
  161. {
  162. key: 'sex',
  163. type: 'radio',
  164. label: '性别',
  165. valueOptions: [
  166. { label: '男', value: '1' },
  167. { label: '女', value: '2' }
  168. ]
  169. },
  170. {
  171. key: 'remark',
  172. type: 'input',
  173. label: '备注',
  174. // 文本域,不写则是普通文本框
  175. inputOptions: {
  176. type: 'textarea',
  177. rows: '2',
  178. style: 'width: 100%'
  179. },
  180. colLayout: { span: 24 }
  181. }
  182. ],
  183. labelWidth: '80px',
  184. width: '600px',
  185. itemStyle: { padding: '10px' },
  186. rules: {
  187. nickName: [{ required: true, message: '请输入用户名称', trigger: 'blur' }],
  188. userName: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
  189. deptId: [{ required: true, message: '请选择所属机构', trigger: 'blur' }],
  190. majorId: [{ required: true, message: '请选择所属专业', trigger: 'blur' }],
  191. sex: [{ required: true, message: '请选择性别', trigger: 'blur' }]
  192. }
  193. })