描述:添加园区管理员时,将界面中“所属租户”改成“所属地区”,同时添加必须选择所属园区

This commit is contained in:
SelfRidicule 2024-04-01 15:54:16 +08:00
parent 6573ff81ca
commit 2be81744cf

View File

@ -44,37 +44,44 @@
>
</a-tree-select>
</a-form-item>
<a-form-item v-if='tenantId === null' :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属租户'>
<a-select v-decorator="['tenantId', {rules: [{ required: true, message: '请选择所属租户' }]}]">
<a-select-option v-for='item in tenantData' :key='item.value'>{{ item.text }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-if='tenantId !== null' :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属园区'>
<a-select v-decorator="['parkId', {rules: [{ required: true, message: '请选择所属园区' }]}]">
<a-select-option v-for='item in parkData' :key='item.value'>{{ item.text }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='拥有角色' hasFeedback>
<a-select
style='width: 100%'
mode='multiple'
v-decorator="['roleIds', {rules: [{ required: true, message: '请选择角色' }]}]"
:allowClear='true'
mode='multiple'
@change='roleSelectChange'
>
<a-select-option v-for='(action) in roleAll' :key='action.id'>{{ action.roleName }}</a-select-option>
<a-select-option v-for='(action) in roleAll' :key='action.id' :disabled='selectRoleEnable'>
{{ action.roleName
}}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='选择企业'>
<a-select v-decorator="['customerId', {rules: [{ required: true, message: '请选择企业' }]}]">
<a-form-item v-if='tenantShow' :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属地区'>
<a-select v-decorator="['tenantId', {rules: [{ required: true, message: '请选择所属地区' }]}]"
@change='selectTenant'>
<a-select-option v-for='item in tenantData' :key='item.value'>{{ item.text }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-if='parkShow' :labelCol='labelCol' :wrapperCol='wrapperCol' label='所属园区'>
<a-select v-decorator="['parkId', {rules: [{ required: true, message: '请选择所属园区' }]}]"
@change='selectPark'>
<a-select-option v-for='item in parkData' :key='item.value'>{{ item.text }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item v-if='customerShow' :labelCol='labelCol' :wrapperCol='wrapperCol' label='选择企业'>
<a-select v-decorator="['customerId', {rules: [{ required: true, message: '请选择企业' }]}]"
@change='selectEnterprise'>
<a-select-option v-for='item in customerList' :key='item.value'>{{ item.text }}</a-select-option>
</a-select>
</a-form-item>
<a-form-item :labelCol='labelCol' :wrapperCol='wrapperCol' label='选择用户'>
<a-form-item v-if='selectUserShow' :labelCol='labelCol' :wrapperCol='wrapperCol' label='选择用户'>
<a-select
show-search
v-decorator="['staffId', {rules: [{required: true, message: '请选择手机号码'}]}]"
placeholder='请选择手机号码'
style='width: 200px'
style='width: 100%'
:default-active-first-option='false'
:show-arrow='false'
:filter-option='false'
@ -82,7 +89,7 @@
@search='handleSearch'
@change='handleChange'
>
<a-select-option v-for='item in data' :value='item.id' :key='item.id'>
<a-select-option v-for='item in searchUserList' :value='item.id' :key='item.id'>
{{ item.username }} -{{ item.mobile }}
</a-select-option>
</a-select>
@ -135,25 +142,24 @@ export default {
confirmLoading: false,
roleAll: [],
mdl: {},
data: [],
searchUserList: [],
customerList: [],
deptCheck: true,
spinning: false,
tenantData: [],
parkData: [],
form: this.$form.createForm(this)
form: this.$form.createForm(this),
selectRoleEnable: false,
tenantShow: false,
parkShow: false,
customerShow: false,
selectUserShow: false
}
},
beforeCreate() {
},
created() {
getCustomerList().then(res => {
res.rows.forEach(r => {
this.customerList.push({ value: r.id, text: r.name })
})
})
//
//
getTenantList().then(res => {
if (res.code === 0) {
res.rows.forEach(r => {
@ -161,23 +167,134 @@ export default {
})
}
})
//
getParkList().then(res => {
if (res.code === 0) {
res.rows.forEach(r => {
this.parkData.push({ value: r.id, text: r.name })
})
}
})
this.loadRoleAll()
},
methods: {
//
roleSelectChange(value) {
console.log('roleSelectChange', value)
//
this.searchUserList = []
//
this.mdl.roleIds = value
//
if (value.length > 0) {
this.selectRoleEnable = true
//
if (value[0] == 4) { // 4
this.tenantShow = true
this.parkShow = true
this.customerShow = true
} else if (value[0] == 5) { // 5
this.tenantShow = true
this.parkShow = true
} else {
this.tenantShow = false
this.parkShow = false
this.customerShow = false
this.selectUserShow = false
}
} else {
this.selectRoleEnable = false
//
this.tenantShow = false
this.parkShow = false
this.customerShow = false
this.selectUserShow = false
}
},
// ->
selectTenant(id) {
console.log('selectTenant', id)
getParkList({
tenantId: id
}).then(res => {
this.parkData = res.rows.map(item => {
return {
value: item.id,
text: item.name
}
})
})
//
this.mdl.tenantId = id
//
this.searchUserList = []
//
this.selectUserShow = false
//
this.mdl.parkId = null
this.mdl.customerId = null
this.mdl.staffId = null
this.form.setFieldsValue({
parkId: null,
customerId: null,
staffId: null
})
},
// ->
selectPark(id) {
getCustomerList({
parkId: id
}).then(res => {
this.customerList = res.data.map(item => {
return {
value: item.id,
text: item.name
}
})
})
//
this.mdl.parkId = id
//
this.searchUserList = []
//
this.mdl.customerId = null
this.mdl.staffId = null
this.form.setFieldsValue({
customerId: null,
staffId: null
})
//
console.log('this.mdl.roleIds', this.mdl.roleIds)
if (this.mdl.roleIds[0] == 5) {
this.selectUserShow = true
} else {
//
this.selectUserShow = false
}
},
//
selectEnterprise(id) {
//
this.mdl.customerId = id
//
this.selectUserShow = true
//
this.searchUserList = []
//
this.mdl.staffId = null
this.form.setFieldsValue({
staffId: null
})
},
handleSearch(value) {
let param = {
mobile: value
}
//
if (this.mdl.roleIds[0] == 4) { // 4
param.customerId = this.mdl.customerId
} else if (this.mdl.roleIds[0] == 5) { // 5
param.parkId = this.mdl.parkId
} else {
}
getStaffList(param).then(res => {
this.data = res.rows
this.searchUserList = res.rows
})
},
handleChange() {
@ -190,11 +307,12 @@ export default {
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.mdl, 'id', 'username', 'nickname', 'status', 'mobile', 'roleIds', 'staffId', 'customerId', 'remark', 'deptId', 'parkId', 'tenantId'))
})
let param = {}
getStaffListByUser(param).then(res => {
this.data = res.rows
})
//
this.selectRoleEnable = false
this.tenantShow = false
this.parkShow = false
this.customerShow = false
this.selectUserShow = false
},
edit(record) {
if (record.id > 0) {
@ -202,20 +320,54 @@ export default {
this.spinning = true
getUser(record.id).then(res => {
this.mdl = Object.assign({}, res)
let copyMdl = JSON.parse(JSON.stringify(this.mdl))
this.visible = true
this.$nextTick(() => {
this.form.setFieldsValue(pick(this.mdl, 'id', 'username', 'nickname', 'status', 'mobile', 'roleIds', 'customerId', 'staffId', 'remark', 'deptId', 'parkId', 'tenantId'))
this.spinning = false
// this.form.setFieldsValue({ ...record })
//
getStaffListByUser({
staffId: this.mdl.staffId
}).then(res => {
console.log('edit getStaffListByUser', res)
this.data = res.rows
})
})
//
if (this.mdl.roleIds[0] == 4) { // 4
// ->
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectTenant(copyMdl.tenantId)
// ->
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectPark(copyMdl.parkId)
//
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.handleSearch(copyMdl.staffPhone)
//
this.mdl.customerId = copyMdl.customerId
this.mdl.staffId = copyMdl.staffId
//
this.tenantShow = true
this.parkShow = true
this.customerShow = true
this.selectUserShow = true
} else if (this.mdl.roleIds[0] == 5) { // 5
// ->
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.selectTenant(copyMdl.tenantId)
//
this.mdl = JSON.parse(JSON.stringify(copyMdl))
this.handleSearch(copyMdl.staffPhone)
//
this.mdl.staffId = copyMdl.staffId
//
this.tenantShow = true
this.parkShow = true
this.customerShow = false
this.selectUserShow = true
} else {
this.tenantShow = false
this.parkShow = false
this.customerShow = false
this.selectUserShow = false
}
})
}
},