role.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <!-- -->
  2. <template>
  3. <div class="hc-layout-box role-page">
  4. <hc-card :scrollbar="false" action-size="lg">
  5. <template #header>
  6. <el-button color="#20C98B" type="primary" @click="addClick">
  7. <hc-icon name="add" class="text-white" />
  8. <span class="text-white">新增</span>
  9. </el-button>
  10. <el-button color="#FF6C6C" :disabled="tableCheckedKeys.length === 0" @click="rowDelClick">
  11. <hc-icon name="delete-bin-2" class="text-white" />
  12. <span class="text-white">删除</span>
  13. </el-button>
  14. </template>
  15. <hc-table
  16. is-check
  17. :column="tableColumn"
  18. :datas="tableData"
  19. :header-row-style="tableHeaderRowStyle"
  20. @selection-change="tableSelectionChange"
  21. >
  22. <template #action="{ row }">
  23. <el-link type="success" @click="rowEditClick(row)"> <hc-icon name="edit" />编辑</el-link>
  24. <el-link type="danger" @click="rowDelClick(row)"> <hc-icon name="delete-bin-2" />删除</el-link>
  25. </template>
  26. </hc-table>
  27. <template #action>
  28. <HcPages :pages="searchForm" @change="pageChange" />
  29. </template>
  30. </hc-card>
  31. </div>
  32. <hc-dialog v-model="addModal" title="新增" widths="50rem">
  33. <hc-icon name="user" style="font-size: 18px;" class="font-bold" />
  34. <span class="font-bold">基础信息</span>
  35. <el-divider style="margin-top: 10px;" />
  36. <el-form :inline="true" :model="baseForm" label-width="auto" :rules="baseFormRules">
  37. <div class="hc-form-item">
  38. <el-form-item label="角色名称:" prop="user">
  39. <el-input v-model="baseForm.user" placeholder="请输入" clearable />
  40. </el-form-item>
  41. </div>
  42. </el-form>
  43. <hc-icon name="user-settings" style="font-size: 18px;" class="font-bold" />
  44. <span class="font-bold">权限设置</span>
  45. <el-divider style="margin-top: 10px;" />
  46. <el-tree
  47. ref="treeRef"
  48. style="max-width: 600px"
  49. :data="data"
  50. show-checkbox
  51. default-expand-all
  52. node-key="id"
  53. highlight-current
  54. :props="defaultProps"
  55. />
  56. </hc-dialog>
  57. </template>
  58. <script setup>
  59. import { ref, watch } from 'vue'
  60. import { HcDelMsg } from 'hc-vue3-ui'
  61. const tableColumn = [
  62. { key: 'key1', name: '角色名称' },
  63. { key: 'action', name: '操作' },
  64. ]
  65. const tableData = ref([
  66. { key1: 'admin', key2: 'xxx', key3: '超级管理员' },
  67. { key1: '13028304756', key2: 'aaa', key3: '角色' },
  68. ])
  69. //设置表头行的样式
  70. const tableHeaderRowStyle = ({ row, rowIndex }) => {
  71. // --el-table-header-bg-color 是表格,表头行的背景色
  72. return '--el-table-header-bg-color: #4b4b4b; color: white;'
  73. }
  74. const addModal = ref(false)
  75. const addClick = ()=>{
  76. addModal.value = true
  77. }
  78. const baseForm = ref({
  79. user:'',
  80. username: '',
  81. password: '',
  82. role: '',
  83. })
  84. const baseFormRules = {
  85. user: {
  86. required: true,
  87. trigger: 'blur',
  88. message: '请输入登陆账户',
  89. },
  90. password: {
  91. required: true,
  92. trigger: 'blur',
  93. message: '请输入密码',
  94. },
  95. username: {
  96. required: true,
  97. trigger: 'blur',
  98. message: '请输入用户名',
  99. },
  100. role: {
  101. required: true,
  102. trigger: 'blur',
  103. message: '请选择角色',
  104. },
  105. }
  106. const tableCheckedKeys = ref([])
  107. //多选事件
  108. const tableSelectionChange = (rows) => {
  109. tableCheckedKeys.value = rows
  110. }
  111. //搜索表单
  112. const searchForm = ref({
  113. queryValue: null, current: 1, size: 20, total: 0,
  114. })
  115. const getTableData = ()=>{
  116. }
  117. //分页被点击
  118. const pageChange = ({ current, size }) => {
  119. searchForm.value.current = current
  120. searchForm.value.size = size
  121. getTableData()
  122. }
  123. const rowEditClick = (row)=>{
  124. addModal.value = true
  125. baseForm.value = row
  126. }
  127. const rowDelClick = ()=>{
  128. HcDelMsg( async ( resolve) => {
  129. // await removeContractTreeNode()
  130. resolve() //关闭弹窗的回调
  131. })
  132. }
  133. const refreshPassword = async (_, resolve) => {
  134. //这里可以写一些操作
  135. resolve() //这个一定要存在,否则不会关闭弹窗
  136. }
  137. const exportClick = async (_, resolve) => {
  138. //这里可以写一些操作
  139. resolve() //这个一定要存在,否则不会关闭弹窗
  140. }
  141. const roleOptions = ref([ {
  142. value: 'Option1',
  143. label: 'Option1',
  144. },
  145. {
  146. value: 'Option2',
  147. label: 'Option2',
  148. },
  149. {
  150. value: 'Option3',
  151. label: 'Option3',
  152. },
  153. {
  154. value: 'Option4',
  155. label: 'Option4',
  156. },
  157. {
  158. value: 'Option5',
  159. label: 'Option5',
  160. }])
  161. const treeRef = ref(null)
  162. const defaultProps = {
  163. children: 'children',
  164. label: 'label',
  165. }
  166. const data = [
  167. {
  168. id: 1,
  169. label: 'Level one 1',
  170. children: [
  171. {
  172. id: 4,
  173. label: 'Level two 1-1',
  174. children: [
  175. {
  176. id: 9,
  177. label: 'Level three 1-1-1',
  178. },
  179. {
  180. id: 10,
  181. label: 'Level three 1-1-2',
  182. },
  183. ],
  184. },
  185. ],
  186. },
  187. {
  188. id: 2,
  189. label: 'Level one 2',
  190. children: [
  191. {
  192. id: 5,
  193. label: 'Level two 2-1',
  194. },
  195. {
  196. id: 6,
  197. label: 'Level two 2-2',
  198. },
  199. ],
  200. },
  201. {
  202. id: 3,
  203. label: 'Level one 3',
  204. children: [
  205. {
  206. id: 7,
  207. label: 'Level two 3-1',
  208. },
  209. {
  210. id: 8,
  211. label: 'Level two 3-2',
  212. },
  213. ],
  214. },
  215. ]
  216. </script>
  217. <style lang='scss' scoped>
  218. .hc-layout-box{
  219. position: relative;
  220. height: 100%;
  221. width: 100%;
  222. }
  223. </style>
  224. <style>
  225. .role-page .el-table {
  226. color:black
  227. }
  228. </style>