user.vue 6.5 KB

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