index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <el-row :gutter="20">
  3. <!-- 左侧部门树 -->
  4. <el-col :span="4" :xs="24" v-if="!mobile">
  5. <ContentWrap class="h-1/1">
  6. <DeptTree @node-click="handleDeptNodeClick" />
  7. </ContentWrap>
  8. </el-col>
  9. <el-col :span="20" :xs="24">
  10. <!-- 搜索 -->
  11. <div class="search-one">
  12. <div style="text-align: right;" class="search-input">
  13. <el-input v-model="queryParams.username" placeholder="用户名称" clearable @keyup.enter="handleQuery">
  14. <template #suffix>
  15. <Icon class="mr-5px" icon="ep:search" @click="handleQuery" style="cursor: pointer;" />
  16. </template>
  17. <template #append>
  18. <el-button :icon="Operation" @click="showSearchMore" />
  19. </template>
  20. </el-input>
  21. <el-button type="primary" plain @click="openForm('create')" v-hasPermi="['system:user:create']"
  22. v-if="!mobile">
  23. <Icon icon="ep:plus" /> 新增
  24. </el-button>
  25. </div>
  26. </div>
  27. <div class="searchMore" v-show="searchMoreShow" :style="{width: (mobile?'88.7%' :'80.7%')}" >
  28. <el-form class="-mb-15px" :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px">
  29. <el-form-item label="用户名称" prop="username">
  30. <el-input v-model="queryParams.username" placeholder="请输入用户名称" clearable @keyup.enter="handleQuery" />
  31. </el-form-item>
  32. <el-form-item label="手机号码" prop="mobile">
  33. <el-input v-model="queryParams.mobile" placeholder="请输入手机号码" clearable @keyup.enter="handleQuery" />
  34. </el-form-item>
  35. <el-form-item label="部门" prop="deptId" v-if="mobile">
  36. <el-select v-model="queryParams.deptId" placeholder="用户部门" clearable>
  37. <el-option v-for="item in dept" :key="item.id"
  38. :label="item.name" :value="item.id" />
  39. </el-select>
  40. </el-form-item>
  41. <el-form-item label="状态" prop="status">
  42. <el-select v-model="queryParams.status" placeholder="用户状态" clearable>
  43. <el-option v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" :key="dict.value"
  44. :label="dict.label" :value="dict.value" />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item label="创建时间" prop="createTime">
  48. <el-date-picker v-model="queryParams.createTime" value-format="YYYY-MM-DD HH:mm:ss" type="datetimerange"
  49. start-placeholder="开始日期" end-placeholder="结束日期" style="width: auto;" />
  50. </el-form-item>
  51. <el-row>
  52. <el-col>
  53. <el-form-item>
  54. <el-button @click="hideSearchMore">
  55. 收起
  56. </el-button>
  57. <el-button @click="resetQuery">
  58. 重置
  59. </el-button>
  60. <el-button @click="handleQuery">
  61. <Icon icon="ep:search" />搜索
  62. </el-button>
  63. <!-- <el-button
  64. type="warning"
  65. plain
  66. @click="handleImport"
  67. v-hasPermi="['system:user:import']"
  68. >
  69. <Icon icon="ep:upload" /> 导入
  70. </el-button>
  71. <el-button
  72. type="success"
  73. plain
  74. @click="handleExport"
  75. :loading="exportLoading"
  76. v-hasPermi="['system:user:export']"
  77. >
  78. <Icon icon="ep:download" />导出
  79. </el-button> -->
  80. </el-form-item>
  81. </el-col>
  82. </el-row>
  83. </el-form>
  84. </div>
  85. <!-- 内容 -->
  86. <el-row>
  87. <el-col v-for="(o, index) in list" class="card" :key="index" :span="7" :xl="7" :lg="7" :md="7" :sm="24"
  88. :xs="24">
  89. <el-card @click="openForm('view', o)">
  90. <div style="display: flex;justify-content: space-between;align-items: center;margin-bottom: 5px;">
  91. <p style="width: 100%;white-space: nowrap;text-overflow: ellipsis;overflow: hidden;font-size: 16px;color:#000"
  92. :title="o.username">{{ o.username }}
  93. </p>
  94. <div v-show="!mobile" class="setting" @click.stop="openForm('update', o)"
  95. v-hasPermi="['system:user:update']">
  96. <el-icon size="20" color="rgb(220 223 231)">
  97. <Setting />
  98. </el-icon>
  99. </div>
  100. </div>
  101. <div style="display:flex;align-items: center;">
  102. <div
  103. style="width: 46px;height: 65px;margin-right:10px;border:1px solid rgb(220 223 231);border-radius: 5px;display: flex;align-items: center;justify-content: center;overflow: hidden;">
  104. <img :src="o.avatar" style="width: 100%;" @error="o.avatar = 'https://mall-ffkj.oss-cn-guangzhou.aliyuncs.com/2e05b76706334aef023b85ec6aef6ffd4615aae3d06f302aa7d273e97f263025.png'"/>
  105. </div>
  106. <div style='line-height: 25px;'>
  107. <p>{{ o.deptName || "无部门" }}</p>
  108. <p>{{ o.mobile }}</p>
  109. <p>状态:{{ o.status == 0 ? "启用" : "停用" }}</p>
  110. </div>
  111. </div>
  112. </el-card>
  113. </el-col>
  114. </el-row>
  115. <div v-if="list.length == 0">
  116. <p style="text-align: center;margin-top: 100px;">暂无平台用户</p>
  117. </div>
  118. <Pagination :total="total" v-model:page="queryParams.pageNo" v-model:limit="queryParams.pageSize"
  119. @pagination="getList" />
  120. </el-col>
  121. </el-row>
  122. <!-- 添加或修改用户对话框 -->
  123. <!-- <UserForm ref="formRef" @success="getList" /> -->
  124. <UserTab ref="userTabRef" @success="getList" />
  125. <!-- 用户导入对话框 -->
  126. <UserImportForm ref="importFormRef" @success="getList" />
  127. <!-- 分配角色 -->
  128. <!-- <UserAssignRoleForm ref="assignRoleFormRef" @success="getList" /> -->
  129. </template>
  130. <script lang="ts" setup>
  131. import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
  132. import download from '@/utils/download'
  133. import * as UserApi from '@/api/system/user'
  134. import * as DeptApi from '@/api/system/dept'
  135. const { currentRoute, push } = useRouter() // 路由跳转
  136. import UserTab from './UserTab.vue'
  137. import UserImportForm from './UserImportForm.vue'
  138. import DeptTree from './DeptTree.vue'
  139. defineOptions({ name: 'SystemUser' })
  140. /*********************** 中星查询列表开始 **********************/
  141. import { Setting, Search, Operation } from '@element-plus/icons-vue'
  142. // 从路由中引入store中的app仓库
  143. import { useAppStore } from '@/store/modules/app'
  144. const appStore = useAppStore()
  145. const mobile = computed(() => appStore.getMobile)
  146. const searchMoreShow = ref(false)
  147. // 打开更多搜索条件
  148. const showSearchMore = () => {
  149. searchMoreShow.value = !searchMoreShow.value
  150. }
  151. const hideSearchMore = () => {
  152. searchMoreShow.value = false
  153. }
  154. /** 查看/添加/修改操作 */
  155. const userTabRef = ref()
  156. const openForm = (type: string, obj?: object) => {
  157. if (mobile.value) {
  158. const userObj = JSON.stringify(obj)
  159. // console.log(userObj)
  160. push({ name: 'UserMobileTab', query: { 'type':type,'obj':userObj } })
  161. } else {
  162. userTabRef.value.open(type, obj)
  163. }
  164. }
  165. const dept = ref([])
  166. const getTree = async () => {
  167. const res = await DeptApi.getSimpleDeptList()
  168. dept.value = res
  169. }
  170. /************************ 中星查询列表结束 ***************************/
  171. const message = useMessage() // 消息弹窗
  172. const { t } = useI18n() // 国际化
  173. const loading = ref(true) // 列表的加载中
  174. const total = ref(0) // 列表的总页数
  175. const list = ref([]) // 列表的数
  176. const queryParams = reactive({
  177. pageNo: 1,
  178. pageSize: 10,
  179. username: undefined,
  180. mobile: undefined,
  181. status: undefined,
  182. deptId: undefined,
  183. createTime: []
  184. })
  185. const queryFormRef = ref() // 搜索的表单
  186. /** 查询列表 */
  187. const getList = async () => {
  188. loading.value = true
  189. try {
  190. const data = await UserApi.getUserPage(queryParams)
  191. list.value = data.list
  192. total.value = data.total
  193. } finally {
  194. loading.value = false
  195. }
  196. }
  197. /** 搜索按钮操作 */
  198. const handleQuery = () => {
  199. hideSearchMore()
  200. queryParams.pageNo = 1
  201. getList()
  202. }
  203. /** 重置按钮操作 */
  204. const resetQuery = () => {
  205. hideSearchMore()
  206. queryFormRef.value?.resetFields()
  207. handleQuery()
  208. }
  209. /** 处理部门被点击 */
  210. const handleDeptNodeClick = async (row) => {
  211. hideSearchMore()
  212. queryParams.deptId = row.id
  213. await getList()
  214. }
  215. /** 用户导入 */
  216. const importFormRef = ref()
  217. const handleImport = () => {
  218. importFormRef.value.open()
  219. }
  220. /** 导出按钮操作 */
  221. const exportLoading = ref(false)
  222. const handleExport = async () => {
  223. try {
  224. // 导出的二次确认
  225. await message.exportConfirm()
  226. // 发起导出
  227. exportLoading.value = true
  228. const data = await UserApi.exportUser(queryParams)
  229. download.excel(data, '用户数据.xls')
  230. } catch {
  231. } finally {
  232. exportLoading.value = false
  233. }
  234. }
  235. /** 初始化 */
  236. onMounted(() => {
  237. getList()
  238. getTree()
  239. })
  240. </script>
  241. <style src="@/styles/SearchIndex.css"  lang="scss" scoped></style>
  242. <style lang="scss" scoped>
  243. .setting {
  244. display: none !important;
  245. }
  246. .card:hover {
  247. .setting {
  248. display: block !important;
  249. .el-icon {
  250. margin-top: 5px;
  251. }
  252. }
  253. }
  254. </style>