Commit 75619be6 authored by xinzhedeai's avatar xinzhedeai

登录 中间页 用户信息

parent 7b81a862
import request from '@/utils/request'
import { encrypt } from '@/utils/rsaEncrypt'
export function getCompanyList(data) {
return request({
url: 'api/enterprise/auth/enterpriseList',
method: 'get',
data
})
}
export function add(data) {
return request({
url: 'api/users',
......
......@@ -58,27 +58,7 @@ export default {
},
},
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;
......
......@@ -187,7 +187,8 @@ export default {
return
}
}
this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' })
// this.$router.push({ path: /* 记住上次退出时的页面 */ /* this.redirect || */'/home4Login' })
this.$router.push({ path: 'login4Index' })
}).catch(() => {
this.loading = false
this.getCode()
......
......@@ -55,19 +55,37 @@
<el-radio label="女"></el-radio>
</el-radio-group>
</el-form-item>
<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 label="区域" prop="depts" >
<el-cascader
v-model="form.dept"
:options="data"
:props="{ checkStrictly: true, value: 'id' }"
:show-all-levels="false"
@change="deptChange"
></el-cascader>
</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-select
v-model="roleDatas"
style="width: 437px"
style="width: 237px"
multiple
placeholder="请选择"
@remove-tag="deleteTag"
......@@ -76,11 +94,20 @@
<el-option
v-for="item in canChoosedRoles"
:key="item.name"
:disabled="item.level <= 1 || item.level < level"
:disabled="item.level <= 1 || item.level <= level"
:label="item.name"
:value="item.id"
/>
</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>
<div slot="footer" class="dialog-footer">
......@@ -132,8 +159,10 @@
<script>
import crudUser from '@/api/system/user'
import {getCompanyList} from '@/api/system/user'
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 { getAllJob } from '@/api/system/job'
import CRUD, { presenter, header, form, crud } from '@crud/crud'
......@@ -146,7 +175,8 @@ import { mapGetters } from 'vuex'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
let userRoles = []
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 {
name: 'User',
components: { crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
......@@ -172,6 +202,7 @@ export default {
height: document.documentElement.clientHeight - 180 + 'px;',
deptName: '', depts: [], deptDatas: [], jobs: [], level: 3, roles: [],
jobDatas: [], roleDatas: [], // 多选时使用
options4enterpriseIdList: [],
defaultProps: { children: 'children', label: 'name', isLeaf: 'leaf' },
permission: {
add: ['admin', 'user:add'],
......@@ -183,6 +214,7 @@ export default {
{ key: 'false', display_name: '禁用' }
],
rules: {
username: [
{ required: true, message: '请输入用户名', trigger: 'blur' },
{ min: 2, max: 20, message: '长度在 2 到 20 个字符', trigger: 'blur' }
......@@ -193,7 +225,11 @@ export default {
],
phone: [
{ required: true, trigger: 'blur', validator: validPhone }
]
],
dept: [
{ required: true, message: '请选择部门', trigger: 'blur' }
],
}
}
},
......@@ -202,9 +238,10 @@ export default {
'user'
]),
canChoosedRoles() {
return this.roles.filter(r => {
return r.enterpriseId === this.user.enterpriseId
})
// return this.roles.filter(r => {
// return r.enterpriseId === this.user.enterpriseId
// })
return this.roles
}
},
created() {
......@@ -215,8 +252,29 @@ export default {
window.onresize = function temp() {
that.height = document.documentElement.clientHeight - 180 + 'px;'
}
this.getDeptList()
},
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) {
if (e.keyCode === 32) {
......@@ -260,14 +318,18 @@ export default {
[CRUD.HOOK.beforeToAdd]() {
this.jobDatas = []
this.roleDatas = []
this.form.dept = []
},
// 初始化编辑时候的角色与岗位
[CRUD.HOOK.beforeToEdit](crud, form) {
// this.getJobs(this.form.dept.id)
this.jobDatas = []
this.roleDatas = []
this.form.dept = []
userRoles = []
userJobs = []
const _this = this
form.roles.forEach(function(role, index) {
_this.roleDatas.push(role.id)
......@@ -289,8 +351,19 @@ export default {
})
return false
}
if(!this.form.dept.length){
this.$message({
message: '部门不能为空',
type: 'warning'
})
return false
}
crud.form.roles = userRoles
crud.form.jobs = userJobs
crud.form.dept = {id: this.form.dept[this.form.dept.length-1]}
return true
},
// 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