角色管理
This commit is contained in:
parent
0f32e0ee45
commit
b891b8faad
|
|
@ -23,7 +23,7 @@
|
|||
"driver.js": "0.9.5",
|
||||
"dropzone": "5.5.1",
|
||||
"echarts": "4.2.1",
|
||||
"element-ui": "2.13.2",
|
||||
"element-ui": "2.15.13",
|
||||
"file-saver": "2.0.1",
|
||||
"fuse.js": "3.4.4",
|
||||
"js-cookie": "2.2.0",
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import './styles/element-variables.scss'
|
|||
// import enLang from 'element-ui/lib/locale/lang/en'// 如果使用中文语言包请默认支持,无需额外引入,请删除该依赖
|
||||
|
||||
import '@/styles/index.scss' // global css
|
||||
import '@/styles/ruoyi.scss' // ruoyi css
|
||||
|
||||
import App from './App'
|
||||
import store from './store'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,277 @@
|
|||
/**
|
||||
* 通用css样式布局处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
|
||||
/** 基础通用 **/
|
||||
.pt5 {
|
||||
padding-top: 5px;
|
||||
}
|
||||
.pr5 {
|
||||
padding-right: 5px;
|
||||
}
|
||||
.pb5 {
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
.mt5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.mr5 {
|
||||
margin-right: 5px;
|
||||
}
|
||||
.mb5 {
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.mb8 {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.ml5 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
.mt10 {
|
||||
margin-top: 10px;
|
||||
}
|
||||
.mr10 {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.mb10 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.ml10 {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.mt20 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
.mr20 {
|
||||
margin-right: 20px;
|
||||
}
|
||||
.mb20 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.ml20 {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.h1, .h2, .h3, .h4, .h5, .h6, h1, h2, h3, h4, h5, h6 {
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
line-height: 1.1;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.el-message-box__status + .el-message-box__message{
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.el-dialog:not(.is-fullscreen) {
|
||||
margin-top: 6vh !important;
|
||||
}
|
||||
|
||||
.el-dialog__wrapper.scrollbar .el-dialog .el-dialog__body {
|
||||
overflow: auto;
|
||||
overflow-x: hidden;
|
||||
max-height: 70vh;
|
||||
padding: 10px 20px 0;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
.el-table__header-wrapper, .el-table__fixed-header-wrapper {
|
||||
th {
|
||||
word-break: break-word;
|
||||
background-color: #f8f8f9;
|
||||
color: #515a6e;
|
||||
height: 40px;
|
||||
font-size: 13px;
|
||||
}
|
||||
}
|
||||
.el-table__body-wrapper {
|
||||
.el-button [class*="el-icon-"] + span {
|
||||
margin-left: 1px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 表单布局 **/
|
||||
.form-header {
|
||||
font-size:15px;
|
||||
color:#6379bb;
|
||||
border-bottom:1px solid #ddd;
|
||||
margin:8px 10px 25px 10px;
|
||||
padding-bottom:5px
|
||||
}
|
||||
|
||||
/** 表格布局 **/
|
||||
.pagination-container {
|
||||
position: relative;
|
||||
height: 25px;
|
||||
margin-bottom: 10px;
|
||||
margin-top: 15px;
|
||||
padding: 10px 20px !important;
|
||||
}
|
||||
|
||||
/* tree border */
|
||||
.tree-border {
|
||||
margin-top: 5px;
|
||||
border: 1px solid #e5e6e7;
|
||||
background: #FFFFFF none;
|
||||
border-radius:4px;
|
||||
}
|
||||
|
||||
.pagination-container .el-pagination {
|
||||
right: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
@media ( max-width : 768px) {
|
||||
.pagination-container .el-pagination > .el-pagination__jump {
|
||||
display: none !important;
|
||||
}
|
||||
.pagination-container .el-pagination > .el-pagination__sizes {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
.el-table .fixed-width .el-button--mini {
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
width: inherit;
|
||||
}
|
||||
|
||||
/** 表格更多操作下拉样式 */
|
||||
.el-table .el-dropdown-link,.el-table .el-dropdown-selfdefine {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
.el-table .el-dropdown, .el-icon-arrow-down {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.el-tree-node__content > .el-checkbox {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.list-group-striped > .list-group-item {
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-radius: 0;
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.list-group {
|
||||
padding-left: 0px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
border-bottom: 1px solid #e7eaec;
|
||||
border-top: 1px solid #e7eaec;
|
||||
margin-bottom: -1px;
|
||||
padding: 11px 0px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.pull-right {
|
||||
float: right !important;
|
||||
}
|
||||
|
||||
.el-card__header {
|
||||
padding: 14px 15px 7px;
|
||||
min-height: 40px;
|
||||
}
|
||||
|
||||
.el-card__body {
|
||||
padding: 15px 20px 20px 20px;
|
||||
}
|
||||
|
||||
.card-box {
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* button color */
|
||||
.el-button--cyan.is-active,
|
||||
.el-button--cyan:active {
|
||||
background: #20B2AA;
|
||||
border-color: #20B2AA;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.el-button--cyan:focus,
|
||||
.el-button--cyan:hover {
|
||||
background: #48D1CC;
|
||||
border-color: #48D1CC;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.el-button--cyan {
|
||||
background-color: #20B2AA;
|
||||
border-color: #20B2AA;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
/* text color */
|
||||
.text-navy {
|
||||
color: #1ab394;
|
||||
}
|
||||
|
||||
.text-primary {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #1c84c6;
|
||||
}
|
||||
|
||||
.text-info {
|
||||
color: #23c6c8;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #f8ac59;
|
||||
}
|
||||
|
||||
.text-danger {
|
||||
color: #ed5565;
|
||||
}
|
||||
|
||||
.text-muted {
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
/* image */
|
||||
.img-circle {
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.img-lg {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
}
|
||||
|
||||
.avatar-upload-preview {
|
||||
position: relative;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 200px;
|
||||
height: 200px;
|
||||
border-radius: 50%;
|
||||
box-shadow: 0 0 4px #ccc;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* 拖拽列样式 */
|
||||
.sortable-ghost{
|
||||
opacity: .8;
|
||||
color: #fff!important;
|
||||
background: #42b983!important;
|
||||
}
|
||||
|
||||
.top-right-btn {
|
||||
position: relative;
|
||||
float: right;
|
||||
}
|
||||
|
|
@ -1,303 +1,404 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<div class="filter-container">
|
||||
<el-input v-model="listQuery.roleId" placeholder="角色ID" style="width: 200px;" class="filter-item" @keyup.enter.native="handleFilter" />
|
||||
<el-input v-model="listQuery.roleName" placeholder="角色名" style="width: 200px;" class="filter-item ml-20" @keyup.enter.native="handleFilter" />
|
||||
<el-select v-model="listQuery.type" placeholder="角色类型" clearable class="filter-item ml-20" style="width: 130px">
|
||||
<el-option v-for="item in calendarTypeOptions" :key="item.key" :label="item.display_name+'('+item.key+')'" :value="item.key" />
|
||||
</el-select>
|
||||
|
||||
<el-button v-waves style="margin-left: 40px;" class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
|
||||
<el-input v-model="listQuery.userName" placeholder="用户名" style="width: 200px" class="filter-item" :maxlength="30"
|
||||
@keyup.enter.native="handleFilter" />
|
||||
<el-input v-model="listQuery.loginName" placeholder="用户昵称" style="width: 200px" class="filter-item ml-20"
|
||||
:maxlength="30" @keyup.enter.native="handleFilter" />
|
||||
<el-input v-model="listQuery.phone" placeholder="手机号" style="width: 200px" class="filter-item ml-20" :maxlength="11"
|
||||
@keyup.enter.native="handleFilter" />
|
||||
<el-button v-waves style="margin-left: 40px" class="filter-item" type="primary" icon="el-icon-search"
|
||||
@click="handleFilter">
|
||||
查询
|
||||
</el-button>
|
||||
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">
|
||||
<el-button class="filter-item" style="margin-left: 10px" type="primary" icon="el-icon-plus" @click="handleCreate">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download" @click="handleDownload">
|
||||
导出
|
||||
</el-button>
|
||||
<!-- <el-checkbox v-model="showReviewer" class="filter-item" style="margin-left:15px;" @change="tableKey=tableKey+1">
|
||||
reviewer
|
||||
</el-checkbox> -->
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
:key="tableKey"
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
border
|
||||
fit
|
||||
highlight-current-row
|
||||
style="width: 100%;"
|
||||
@sort-change="sortChange"
|
||||
>
|
||||
<el-table-column label="角色ID" prop="id" sortable="custom" align="center" :class-name="getSortClass('id')">
|
||||
<template slot-scope="{row}">
|
||||
<span>{{ row.id }}</span>
|
||||
<el-table :key="tableKey" v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"
|
||||
:max-height="tableHeight">
|
||||
<el-table-column label="序号" align="center" width="80" type="index">
|
||||
<template scope="scope">
|
||||
<span>{{ (listQuery.pageNum - 1) * 10 + scope.$index + 1 }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="角色名称">
|
||||
<template slot-scope="{row}">
|
||||
<span class="link-type" @click="handleUpdate(row)">{{ row.name }}</span>
|
||||
<el-table-column label="用户名" min-width="40px" align="center">
|
||||
<template slot-scope="{ row }">
|
||||
<span class="link-type" @click="handleUpdate(row)">{{
|
||||
row.userName
|
||||
}}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="呢称" key="nickName" prop="nickName" min-width="40px" align="center" />
|
||||
<el-table-column label="手机号码" align="center" key="phone" prop="phone" :show-overflow-tooltip="true" /> -->
|
||||
<el-table-column label="创建日期" align="center" :show-overflow-tooltip="true">
|
||||
<template slot-scope="{row}">
|
||||
<span>{{ row.date | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
|
||||
<el-table-column key="nickName" label="登录名" prop="loginName" min-width="40px" align="center" />
|
||||
<el-table-column key="phone" label="手机号码" align="center" prop="phone" :show-overflow-tooltip="true" />
|
||||
<el-table-column prop="delFlag" label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="scope.row.delFlag === 0 ? 'primary' : 'danger'" disable-transitions>{{ scope.row.delFlag === 0 ?
|
||||
'在用' : '注销' }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="状态" class-name="status-col">
|
||||
<template slot-scope="{row}">
|
||||
<el-tag :type="row.status | statusFilter">
|
||||
{{ row.status }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="230" class-name="small-padding fixed-width">
|
||||
<template slot-scope="{row,$index}">
|
||||
<el-button type="primary" size="mini" @click="handleUpdate(row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<!-- <el-button v-if="row.status!='published'" size="mini" type="success" @click="handleModifyStatus(row,'published')">
|
||||
Publish
|
||||
</el-button> -->
|
||||
<!-- <el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')">
|
||||
Draft
|
||||
</el-button> -->
|
||||
<el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleDelete(row,$index)">
|
||||
删除
|
||||
</el-button>
|
||||
<el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width">
|
||||
<template slot-scope="{ row, $index }">
|
||||
<el-button type="primary" size="mini" plain icon="el-icon-edit" title="修改" @click="handleUpdate(row)" />
|
||||
<el-button v-if="row.status != 'deleted'" plain size="mini" type="danger" icon="el-icon-delete" title="删除"
|
||||
@click="handleDelete(row, $index)" />
|
||||
<el-button size="mini" type="warning" plain icon="el-icon-user" title="重置密码" @click="editPwd(row, $index)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="600px">
|
||||
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="80px" style="width: 400px; margin-left:50px;">
|
||||
<el-form-item label="角色名" prop="name">
|
||||
<el-input v-model="temp.name" placeholder="用户名" />
|
||||
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="right" label-width="80px"
|
||||
style="width: 400px; margin-left: 50px">
|
||||
<el-form-item label="用户名" prop="userName">
|
||||
<el-input v-model="temp.userName" placeholder="用户名" :maxlength="30" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-select v-model="temp.status" class="filter-item" placeholder="请选择状态" style="width: 100%;">
|
||||
<el-option v-for="item in statusOptions" :key="item" :label="item" :value="item" />
|
||||
<el-form-item label="登录名" prop="loginName">
|
||||
<el-input v-model="temp.loginName" placeholder="登录名" :maxlength="30" :disabled="dialogStatus === 'update'" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号" prop="phone">
|
||||
<el-input v-model="temp.phone" placeholder="手机号" :maxlength="11" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="dialogStatus === 'create'" label="密码" prop="password">
|
||||
<el-input v-model="temp.password" type="password" placeholder="请输入密码" show-password :maxlength="16" />
|
||||
</el-form-item>
|
||||
<el-form-item label="组织机构" prop="orgId">
|
||||
<treeselect v-model="temp.orgId" :options="orgOptions" :show-count="true" placeholder="请选择组织机构" />
|
||||
</el-form-item>
|
||||
<el-form-item label="登录权限" prop="loginType">
|
||||
<el-checkbox-group v-model="loginType">
|
||||
<el-checkbox v-for="item in loginTypeArr" :key="item.value" :label="item.value">{{ item.name }}</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="账号类型" prop="userType">
|
||||
<el-radio-group v-model="temp.userType">
|
||||
<el-radio v-for="item in userTypeArr" :key="item.value" :label="item.value">{{ item.name }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色类型" prop="roleId">
|
||||
<el-select v-model="temp.roleId" class="filter-item" placeholder="请选择角色类型" style="width: 100%"
|
||||
@change="roleChange">
|
||||
<el-option v-for="item in roleArr" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="日期" prop="timestamp">
|
||||
<el-date-picker v-model="temp.timestamp" type="datetime" placeholder="选择日期" style="width: 100%;" />
|
||||
<el-form-item label="账号状态" prop="accountStatus">
|
||||
<el-radio-group v-model="temp.accountStatus">
|
||||
<el-radio v-for="item in accountStatusArr" :key="item.value" :label="item.value">{{ item.name }}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="temp.remark" :autosize="{ minRows: 2, maxRows: 4}" type="textarea" placeholder="备注" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">
|
||||
关闭
|
||||
</el-button>
|
||||
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">
|
||||
<el-button @click="dialogFormVisible = false"> 关闭 </el-button>
|
||||
<el-button type="primary" @click="dialogStatus === 'create' ? createData() : updateData()">
|
||||
提交
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :visible.sync="dialogPvVisible" title="Reading statistics">
|
||||
<el-table :data="pvData" border fit highlight-current-row style="width: 100%">
|
||||
<el-table-column prop="key" label="Channel" />
|
||||
<el-table-column prop="pv" label="Pv" />
|
||||
</el-table>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="dialogPvVisible = false">Confirm</el-button>
|
||||
</span>
|
||||
<el-dialog title="重置密码" :visible.sync="dialogFormVisible2" width="600px">
|
||||
<el-form ref="dataForm2" :rules="rules2" :model="pwdForm" label-position="right" label-width="80px"
|
||||
style="width: 400px; margin-left: 50px">
|
||||
<el-form-item label="密码" prop="password">
|
||||
<el-input v-model="pwdForm.password" type="password" placeholder="请输入密码" show-password :maxlength="16" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible2 = false"> 关闭 </el-button>
|
||||
<el-button type="primary" @click="editPwdData()">
|
||||
提交
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { fetchList, fetchPv, createArticle, updateArticle } from '@/api/article'
|
||||
import waves from '@/directive/waves' // waves directive
|
||||
import { fetchList, addUser, getUserById, editUser, delUser, editPwd } from '@/api/user'
|
||||
import { fetchOrgList, fetchRoleList } from '@/api/select'
|
||||
import { validPhone, validPwd } from '@/utils/validate'
|
||||
import waves from '@/directive/waves'
|
||||
import { parseTime } from '@/utils'
|
||||
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
|
||||
import Pagination from '@/components/Pagination'
|
||||
import Treeselect from '@riophae/vue-treeselect'
|
||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||
|
||||
const calendarTypeOptions = [
|
||||
{ key: 'aa', display_name: '1' },
|
||||
{ key: 'bb', display_name: '2' },
|
||||
{ key: 'cc', display_name: '3' },
|
||||
{ key: 'dd', display_name: '4' }
|
||||
const loginTypeArr = [
|
||||
{
|
||||
value: '1',
|
||||
name: 'app'
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
name: '大屏'
|
||||
},
|
||||
{
|
||||
value: '3',
|
||||
name: '后台'
|
||||
}
|
||||
]
|
||||
const userTypeArr = [
|
||||
{
|
||||
value: '0',
|
||||
name: '内部账号'
|
||||
},
|
||||
{
|
||||
value: '1',
|
||||
name: '外部账号'
|
||||
}
|
||||
]
|
||||
const accountStatusArr = [
|
||||
{
|
||||
value: '0',
|
||||
name: '正常'
|
||||
},
|
||||
{
|
||||
value: '1',
|
||||
name: '锁定'
|
||||
},
|
||||
{
|
||||
value: '2',
|
||||
name: '停用'
|
||||
}
|
||||
]
|
||||
|
||||
// arr to obj, such as { CN : "China", US : "USA" }
|
||||
const calendarTypeKeyValue = calendarTypeOptions.reduce((acc, cur) => {
|
||||
acc[cur.key] = cur.display_name
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
export default {
|
||||
name: 'ComplexTable',
|
||||
components: { Pagination },
|
||||
components: { Pagination, Treeselect },
|
||||
directives: { waves },
|
||||
filters: {
|
||||
statusFilter(status) {
|
||||
const statusMap = {
|
||||
// use: 'use',
|
||||
// deleted: 'danger'
|
||||
}
|
||||
return statusMap[status]
|
||||
},
|
||||
typeFilter(type) {
|
||||
return calendarTypeKeyValue[type]
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
tableKey: 0,
|
||||
loginTypeArr: loginTypeArr,
|
||||
userTypeArr: userTypeArr,
|
||||
orgOptions: [],
|
||||
roleArr: [],
|
||||
accountStatusArr: accountStatusArr,
|
||||
loginType: [],
|
||||
list: null,
|
||||
total: 0,
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
page: 1,
|
||||
limit: 10,
|
||||
importance: undefined,
|
||||
title: undefined,
|
||||
type: undefined,
|
||||
sort: '+id'
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
},
|
||||
importanceOptions: [1, 2, 3],
|
||||
calendarTypeOptions,
|
||||
sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
|
||||
statusOptions: ['在用', 'draft', '禁止'],
|
||||
tableHeight: 650,
|
||||
showReviewer: false,
|
||||
temp: {
|
||||
id: undefined,
|
||||
importance: 1,
|
||||
remark: '',
|
||||
timestamp: new Date(),
|
||||
title: '',
|
||||
type: '',
|
||||
status: 'published'
|
||||
userId: null,
|
||||
userName: '',
|
||||
loginName: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
orgId: null,
|
||||
loginType: null,
|
||||
userType: null,
|
||||
roleId: null,
|
||||
roleName: null,
|
||||
accountStatus: null
|
||||
},
|
||||
pwdForm: {
|
||||
userId: null,
|
||||
password: ''
|
||||
},
|
||||
dialogFormVisible: false,
|
||||
dialogFormVisible2: false,
|
||||
dialogStatus: '',
|
||||
downloadLoading: false,
|
||||
textMap: {
|
||||
update: '编辑',
|
||||
create: '新增'
|
||||
},
|
||||
dialogPvVisible: false,
|
||||
pvData: [],
|
||||
rules: {
|
||||
name: [{ required: true, message: '用户名不能为空', trigger: 'blur' }],
|
||||
nickName: [{ required: true, message: '用户昵称不能为空', trigger: 'blur' }],
|
||||
phone: [{ required: true, message: '用户名手机号不能为空', trigger: 'blur' }]
|
||||
// type: [{ required: true, message: 'type is required', trigger: 'change' }],
|
||||
// timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
|
||||
|
||||
userName: [
|
||||
{ required: true, message: '用户名不能为空', trigger: 'blur' }
|
||||
],
|
||||
loginName: [
|
||||
{ required: true, message: '登录名不能为空', trigger: 'blur' }
|
||||
],
|
||||
phone: [
|
||||
{ required: true, message: '手机号不能为空', trigger: 'blur' },
|
||||
{ validator: this.validatePhone, trigger: 'blur' }
|
||||
],
|
||||
password: [
|
||||
{ required: true, message: '密码不能为空', trigger: 'blur' },
|
||||
{ min: 8, max: 16, message: '密码长度在8到16个字符', trigger: 'blur' },
|
||||
{ validator: this.validatePwd, trigger: 'blur' }
|
||||
],
|
||||
orgId: [
|
||||
{ required: true, message: '请选择组织机构' }
|
||||
],
|
||||
loginType: [
|
||||
{ validator: this.validateLoginType, trigger: 'change' }
|
||||
],
|
||||
userType: [
|
||||
{ required: true, message: '请选择账号类型', trigger: 'change' }
|
||||
],
|
||||
roleId: [
|
||||
{ required: true, message: '请选择角色类型', trigger: 'change' }
|
||||
],
|
||||
accountStatus: [
|
||||
{ required: true, message: '请选择账号状态', trigger: 'change' }
|
||||
]
|
||||
},
|
||||
downloadLoading: false
|
||||
rules2: {
|
||||
password: [
|
||||
{ required: true, message: '密码不能为空', trigger: 'blur' },
|
||||
{ min: 8, max: 16, message: '密码长度在8到16个字符', trigger: 'blur' },
|
||||
{ validator: this.validatePwd, trigger: 'blur' }
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getList()
|
||||
this.getOrgList()
|
||||
this.getRoleList()
|
||||
},
|
||||
methods: {
|
||||
validateLoginType(rule, value, callback) {
|
||||
if (this.loginType.length > 0) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('请至少选择一个登录权限'))
|
||||
}
|
||||
},
|
||||
validatePhone(rule, value, callback) {
|
||||
if (validPhone(value)) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('手机号格式不正确'))
|
||||
}
|
||||
},
|
||||
validatePwd(rule, value, callback) {
|
||||
if (validPwd(value)) {
|
||||
callback()
|
||||
} else {
|
||||
callback(new Error('密码规则为:至少一个字母,一个数字和一个特殊字符'))
|
||||
}
|
||||
},
|
||||
roleChange(roleId) {
|
||||
var obj = {}
|
||||
obj = this.roleArr.find(function (i) {
|
||||
return i.id === roleId
|
||||
})
|
||||
this.temp.roleName = obj.name
|
||||
},
|
||||
getList() {
|
||||
this.listLoading = true
|
||||
this.list = [{ id: 1, name: 'admin1', nickName: '管理员1', status: '在用', date: '2024-02-21' }, { id: 2, name: 'admin2', nickName: '管理员2', status: '禁用', date: '2024-02-22' }, { id: 3, name: 'admin3', nickName: '管理员3', status: '在用', date: '2024-02-23' }]
|
||||
this.total = 3
|
||||
// fetchList(this.listQuery).then(response => {
|
||||
// this.list = response.data.items
|
||||
// this.total = response.data.total
|
||||
// // Just to simulate the time of the request
|
||||
// setTimeout(() => {
|
||||
this.listLoading = false
|
||||
// }, 1.5 * 1000)
|
||||
// })
|
||||
fetchList(this.listQuery).then((response) => {
|
||||
this.list = response.rows
|
||||
this.total = response.total
|
||||
setTimeout(() => {
|
||||
this.listLoading = false
|
||||
}, 1 * 500)
|
||||
})
|
||||
},
|
||||
getOrgList() {
|
||||
fetchOrgList().then((response) => {
|
||||
this.orgOptions = response.data
|
||||
})
|
||||
},
|
||||
getRoleList() {
|
||||
fetchRoleList().then((response) => {
|
||||
this.roleArr = response.data
|
||||
})
|
||||
},
|
||||
handleFilter() {
|
||||
this.listQuery.page = 1
|
||||
this.listQuery.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
handleModifyStatus(row, status) {
|
||||
this.$message({
|
||||
message: '操作Success',
|
||||
type: 'success'
|
||||
})
|
||||
row.status = status
|
||||
},
|
||||
sortChange(data) {
|
||||
const { prop, order } = data
|
||||
if (prop === 'id') {
|
||||
this.sortByID(order)
|
||||
}
|
||||
},
|
||||
sortByID(order) {
|
||||
if (order === 'ascending') {
|
||||
this.listQuery.sort = '+id'
|
||||
} else {
|
||||
this.listQuery.sort = '-id'
|
||||
}
|
||||
this.handleFilter()
|
||||
},
|
||||
resetTemp() {
|
||||
this.temp = {
|
||||
id: undefined,
|
||||
importance: 1,
|
||||
remark: '',
|
||||
timestamp: new Date(),
|
||||
title: '',
|
||||
status: 'published',
|
||||
type: ''
|
||||
}
|
||||
},
|
||||
handleCreate() {
|
||||
this.resetTemp()
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
})
|
||||
this.loginType = this.loginType.slice(0, 0)
|
||||
this.dialogStatus = 'create'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
createData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id
|
||||
this.temp.author = 'vue-element-admin'
|
||||
createArticle(this.temp).then(() => {
|
||||
this.list.unshift(this.temp)
|
||||
console.log(this.temp)
|
||||
this.temp.loginType = this.loginType.toString()
|
||||
addUser(this.temp).then((response) => {
|
||||
this.dialogFormVisible = false
|
||||
this.$notify({
|
||||
title: 'Success',
|
||||
message: 'Created Successfully',
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleUpdate(row) {
|
||||
this.temp = Object.assign({}, row) // copy obj
|
||||
this.temp.timestamp = new Date(this.temp.timestamp)
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].resetFields()
|
||||
})
|
||||
getUserById({ userId: row.userId }).then((response) => {
|
||||
this.temp = Object.assign({}, response.data)
|
||||
this.loginType = response.data.loginType.split(',')
|
||||
this.temp.userType = response.data.userType + ''
|
||||
this.temp.accountStatus = response.data.accountStatus + ''
|
||||
})
|
||||
this.dialogStatus = 'update'
|
||||
this.dialogFormVisible = true
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm'].clearValidate()
|
||||
})
|
||||
},
|
||||
updateData() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
const tempData = Object.assign({}, this.temp)
|
||||
tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
|
||||
updateArticle(tempData).then(() => {
|
||||
const index = this.list.findIndex(v => v.id === this.temp.id)
|
||||
this.list.splice(index, 1, this.temp)
|
||||
console.log(this.temp)
|
||||
this.temp.loginType = this.loginType.toString()
|
||||
editUser(this.temp).then((response) => {
|
||||
this.dialogFormVisible = false
|
||||
this.$notify({
|
||||
title: 'Success',
|
||||
message: 'Update Successfully',
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
handleDelete(row, index) {
|
||||
this.$confirm(`确定要删除该数据吗?`, {
|
||||
type: 'warning',
|
||||
title: '操作提示',
|
||||
beforeClose: async (action, instance, done) => {
|
||||
if (action === 'confirm') {
|
||||
delUser({ userId: row.userId }).then((response) => {
|
||||
this.getList()
|
||||
done()
|
||||
})
|
||||
} else {
|
||||
done()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
editPwd(row, index) {
|
||||
this.dialogFormVisible2 = true
|
||||
this.pwdForm.userId = row.userId
|
||||
this.$nextTick(() => {
|
||||
this.$refs['dataForm2'].clearValidate()
|
||||
})
|
||||
},
|
||||
editPwdData() {
|
||||
this.$refs['dataForm2'].validate((valid) => {
|
||||
if (valid) {
|
||||
editPwd(this.pwdForm).then((response) => {
|
||||
this.dialogFormVisible2 = false
|
||||
this.$message({
|
||||
showClose: true,
|
||||
message: response.msg,
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
|
|
@ -305,47 +406,16 @@ export default {
|
|||
}
|
||||
})
|
||||
},
|
||||
handleDelete(row, index) {
|
||||
this.$notify({
|
||||
title: 'Success',
|
||||
message: 'Delete Successfully',
|
||||
type: 'success',
|
||||
duration: 2000
|
||||
})
|
||||
this.list.splice(index, 1)
|
||||
},
|
||||
handleFetchPv(pv) {
|
||||
fetchPv(pv).then(response => {
|
||||
this.pvData = response.data.pvData
|
||||
this.dialogPvVisible = true
|
||||
})
|
||||
},
|
||||
handleDownload() {
|
||||
this.downloadLoading = true
|
||||
import('@/vendor/Export2Excel').then(excel => {
|
||||
const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
|
||||
const data = this.formatJson(filterVal)
|
||||
excel.export_json_to_excel({
|
||||
header: tHeader,
|
||||
data,
|
||||
filename: 'table-list'
|
||||
})
|
||||
this.downloadLoading = false
|
||||
})
|
||||
},
|
||||
formatJson(filterVal) {
|
||||
return this.list.map(v => filterVal.map(j => {
|
||||
if (j === 'timestamp') {
|
||||
return parseTime(v[j])
|
||||
} else {
|
||||
return v[j]
|
||||
}
|
||||
}))
|
||||
},
|
||||
getSortClass: function(key) {
|
||||
const sort = this.listQuery.sort
|
||||
return sort === `+${key}` ? 'ascending' : 'descending'
|
||||
return this.list.map((v) =>
|
||||
filterVal.map((j) => {
|
||||
if (j === 'timestamp') {
|
||||
return parseTime(v[j])
|
||||
} else {
|
||||
return v[j]
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ export default {
|
|||
{ required: true, message: '请选择组织机构' }
|
||||
],
|
||||
loginType: [
|
||||
{ validator: this.validateLoginType, trigger: 'change' }
|
||||
{ required: true,validator: this.validateLoginType, trigger: 'change' }
|
||||
],
|
||||
userType: [
|
||||
{ required: true, message: '请选择账号类型', trigger: 'change' }
|
||||
|
|
|
|||
Loading…
Reference in New Issue