Commit 75619be6 authored by xinzhedeai's avatar xinzhedeai

登录 中间页 用户信息

parent 7b81a862
import request from '@/utils/request' import request from '@/utils/request'
import { encrypt } from '@/utils/rsaEncrypt' import { encrypt } from '@/utils/rsaEncrypt'
export function getCompanyList(data) {
return request({
url: 'api/enterprise/auth/enterpriseList',
method: 'get',
data
})
}
export function add(data) { export function add(data) {
return request({ return request({
url: 'api/users', url: 'api/users',
......
...@@ -58,27 +58,7 @@ export default { ...@@ -58,27 +58,7 @@ export default {
}, },
}, },
created() { created() {
/**
* 矿产信息固定值
*/
localStorage.setItem(
"kd.selected.mine",
JSON.stringify({
address: "测试地址",
code: "1452562",
enterpriseId: 1,
hasEnable: true,
id: 1,
latitude: "37.05",
liablePerson: "人员",
liablePersonPhone: "15455248718",
longitude: "117.74",
mineType: 1,
name: "测试地下矿山",
runState: null,
})
);
// 按照不同域名加载不同页面样式(企业、应急局),加载完毕后再显示页面 // 按照不同域名加载不同页面样式(企业、应急局),加载完毕后再显示页面
const host = window.location.host; const host = window.location.host;
......
...@@ -187,7 +187,8 @@ export default { ...@@ -187,7 +187,8 @@ export default {
return return
} }
} }
this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' }) // this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' })
this.$router.push({ path: 'login4Index' })
}).catch(() => { }).catch(() => {
this.loading = false this.loading = false
this.getCode() this.getCode()
......
...@@ -55,19 +55,37 @@ ...@@ -55,19 +55,37 @@
<el-radio label="女"></el-radio> <el-radio label="女"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="form.enabled" :disabled="form.id === user.id"> <el-form-item label="区域" prop="depts" >
<el-radio-button <el-cascader
v-for="item in user_status" v-model="form.dept"
:key="item.value" :options="data"
:label="item.value" :props="{ checkStrictly: true, value: 'id' }"
>{{ item.label }}</el-radio-button> :show-all-levels="false"
</el-radio-group> @change="deptChange"
></el-cascader>
</el-form-item> </el-form-item>
<el-form-item label="企业" prop="enterpriseIdList">
<el-select
v-model="form.enterpriseIdList"
placeholder="请输入企业"
:multiple="true"
>
<el-option
v-for="item in options4enterpriseIdList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
<el-form-item style="margin-bottom: 0;" label="角色" prop="roles"> <el-form-item style="margin-bottom: 0;" label="角色" prop="roles">
<el-select <el-select
v-model="roleDatas" v-model="roleDatas"
style="width: 437px" style="width: 237px"
multiple multiple
placeholder="请选择" placeholder="请选择"
@remove-tag="deleteTag" @remove-tag="deleteTag"
...@@ -76,11 +94,20 @@ ...@@ -76,11 +94,20 @@
<el-option <el-option
v-for="item in canChoosedRoles" v-for="item in canChoosedRoles"
:key="item.name" :key="item.name"
:disabled="item.level <= 1 || item.level < level" :disabled="item.level <= 1 || item.level <= level"
:label="item.name" :label="item.name"
:value="item.id" :value="item.id"
/> />
</el-select> </el-select>
<el-form-item label="状态">
<el-radio-group v-model="form.enabled" :disabled="form.id === user.id">
<el-radio-button
v-for="item in user_status"
:key="item.value"
:label="item.value"
>{{ item.label }}</el-radio-button>
</el-radio-group>
</el-form-item>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
...@@ -132,8 +159,10 @@ ...@@ -132,8 +159,10 @@
<script> <script>
import crudUser from '@/api/system/user' import crudUser from '@/api/system/user'
import {getCompanyList} from '@/api/system/user'
import { isvalidPhone } from '@/utils/validate' import { isvalidPhone } from '@/utils/validate'
// import { getDepts, getDeptSuperior } from '@/api/system/dept' import { getDeptList, getDeptSuperior } from '@/api/system/dept'
import { getAll, getLevel } from '@/api/system/role' import { getAll, getLevel } from '@/api/system/role'
import { getAllJob } from '@/api/system/job' import { getAllJob } from '@/api/system/job'
import CRUD, { presenter, header, form, crud } from '@crud/crud' import CRUD, { presenter, header, form, crud } from '@crud/crud'
...@@ -146,7 +175,8 @@ import { mapGetters } from 'vuex' ...@@ -146,7 +175,8 @@ import { mapGetters } from 'vuex'
import '@riophae/vue-treeselect/dist/vue-treeselect.css' import '@riophae/vue-treeselect/dist/vue-treeselect.css'
let userRoles = [] let userRoles = []
let userJobs = [] let userJobs = []
const defaultForm = { id: null, username: null, nickName: null, gender: '', email: null, enabled: 'false', roles: [], jobs: [], dept: { id: null }, phone: null }
const defaultForm = { id: null, username: null, nickName: null, gender: '', email: null, enabled: 'false', roles: [], jobs: [], dept: [], phone: null, enterpriseIdList:[]}
export default { export default {
name: 'User', name: 'User',
components: { crudOperation, rrOperation, udOperation, pagination, DateRangePicker }, components: { crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
...@@ -172,6 +202,7 @@ export default { ...@@ -172,6 +202,7 @@ export default {
height: document.documentElement.clientHeight - 180 + 'px;', height: document.documentElement.clientHeight - 180 + 'px;',
deptName: '', depts: [], deptDatas: [], jobs: [], level: 3, roles: [], deptName: '', depts: [], deptDatas: [], jobs: [], level: 3, roles: [],
jobDatas: [], roleDatas: [], // 多选时使用 jobDatas: [], roleDatas: [], // 多选时使用
options4enterpriseIdList: [],
defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' }, defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' },
permission: { permission: {
add: ['admin', 'user:add'], add: ['admin', 'user:add'],
...@@ -183,6 +214,7 @@ export default { ...@@ -183,6 +214,7 @@ export default {
{ key: 'false', display_name: '禁用' } { key: 'false', display_name: '禁用' }
], ],
rules: { rules: {
username: [ username: [
{ required: true, message: '请输入用户名', trigger: 'blur' }, { required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' } { min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
...@@ -193,7 +225,11 @@ export default { ...@@ -193,7 +225,11 @@ export default {
], ],
phone: [ phone: [
{ required: true, trigger: 'blur', validator: validPhone } { required: true, trigger: 'blur', validator: validPhone }
] ],
dept: [
{ required: true, message: '请选择部门', trigger: 'blur' }
],
} }
} }
}, },
...@@ -202,9 +238,10 @@ export default { ...@@ -202,9 +238,10 @@ export default {
'user' 'user'
]), ]),
canChoosedRoles() { canChoosedRoles() {
return this.roles.filter(r => { // return this.roles.filter(r => {
return r.enterpriseId === this.user.enterpriseId // return r.enterpriseId === this.user.enterpriseId
}) // })
return this.roles
} }
}, },
created() { created() {
...@@ -215,8 +252,29 @@ export default { ...@@ -215,8 +252,29 @@ export default {
window.onresize = function temp() { window.onresize = function temp() {
that.height = document.documentElement.clientHeight - 180 + 'px;' that.height = document.documentElement.clientHeight - 180 + 'px;'
} }
this.getDeptList()
}, },
methods: { methods: {
getCompanyList(deptId){
getCompanyList({
deptId: deptId.length > 1 ? deptId[deptId.length-1] : deptId[0]
})
.then((res) => {
this.options4enterpriseIdList = res.body;
});
},
deptChange(value){
console.log('value', value)
this.getCompanyList(value)
},
getDeptList() {
getDeptList({
}).then((res) => {
this.data = res.body.content;
});
},
// 禁止输入空格 // 禁止输入空格
keydown(e) { keydown(e) {
if (e.keyCode === 32) { if (e.keyCode === 32) {
...@@ -260,14 +318,18 @@ export default { ...@@ -260,14 +318,18 @@ export default {
[CRUD.HOOK.beforeToAdd]() { [CRUD.HOOK.beforeToAdd]() {
this.jobDatas = [] this.jobDatas = []
this.roleDatas = [] this.roleDatas = []
this.form.dept = []
}, },
// 初始化编辑时候的角色与岗位 // 初始化编辑时候的角色与岗位
[CRUD.HOOK.beforeToEdit](crud, form) { [CRUD.HOOK.beforeToEdit](crud, form) {
// this.getJobs(this.form.dept.id) // this.getJobs(this.form.dept.id)
this.jobDatas = [] this.jobDatas = []
this.roleDatas = [] this.roleDatas = []
this.form.dept = []
userRoles = [] userRoles = []
userJobs = [] userJobs = []
const _this = this const _this = this
form.roles.forEach(function(role, index) { form.roles.forEach(function(role, index) {
_this.roleDatas.push(role.id) _this.roleDatas.push(role.id)
...@@ -289,8 +351,19 @@ export default { ...@@ -289,8 +351,19 @@ export default {
}) })
return false return false
} }
if(!this.form.dept.length){
this.$message({
message: '部门不能为空',
type: 'warning'
})
return false
}
crud.form.roles = userRoles crud.form.roles = userRoles
crud.form.jobs = userJobs crud.form.jobs = userJobs
crud.form.dept = {id: this.form.dept[this.form.dept.length-1]}
return true return true
}, },
// getDepts() { // getDepts() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment