This commit is contained in:
liuxi 2024-12-19 10:50:52 +08:00
parent 91c31f2fbc
commit 79d1901f8c

View File

@ -39,6 +39,13 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row type="flex" align="middle">
<el-col :span="24" v-if="Object.keys(addOrEditUserConfig.data).length == 0">
<el-form-item label="用户密码" prop="password">
<el-input v-model="userInfo.password" maxlength="18" type="password"></el-input>
</el-form-item>
</el-col>
</el-row>
<el-row type="flex" align="middle"> <el-row type="flex" align="middle">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="电子邮箱" prop="email"> <el-form-item label="电子邮箱" prop="email">
@ -65,7 +72,8 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row type="flex" align="middle">
<!-- <el-row type="flex" align="middle">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="选择团队" prop="deptId"> <el-form-item label="选择团队" prop="deptId">
<el-cascader class="width100" <el-cascader class="width100"
@ -79,12 +87,43 @@
</template> </template>
</el-cascader> </el-cascader>
</el-form-item>
</el-col>
</el-row> -->
<el-row type="flex" align="middle">
<el-col :span="24">
<el-form-item label="选择区域" prop="regionId">
<el-select v-model="userInfo.regionId" placeholder="请选择" class="width100" @change="regionChange">
<el-option
v-for="item in regionOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row type="flex" align="middle">
<el-col :span="24">
<el-form-item label="选择团队" prop="teamId">
<el-select v-model="userInfo.teamId" placeholder="请选择" class="width100">
<el-option
v-for="item in teamOptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row type="flex" align="middle"> <el-row type="flex" align="middle">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="区域负责人" prop="deptFlag"> <el-form-item label="负责人" prop="deptFlag">
<el-switch <el-switch
v-model="userInfo.identity" v-model="userInfo.identity"
active-color="#535AFF" active-color="#535AFF"
@ -95,13 +134,7 @@
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row type="flex" align="middle">
<el-col :span="24" v-if="Object.keys(addOrEditUserConfig.data).length == 0">
<el-form-item label="用户密码" prop="password">
<el-input v-model="userInfo.password" maxlength="18" type="password"></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form> </el-form>
</div> </div>
@ -137,6 +170,8 @@ export default {
email:'', email:'',
realName:'', realName:'',
roleIds:[], roleIds:[],
regionId:'',
teamId:'',
deptId:'', deptId:'',
deptIds:[], deptIds:[],
type: 2, type: 2,
@ -154,9 +189,12 @@ export default {
roleIds: [ roleIds: [
{ required: true, message: '请选择员工角色', trigger: ['blur','change'] } { required: true, message: '请选择员工角色', trigger: ['blur','change'] }
], ],
deptId: [ regionId: [
{ required: true, message: '请选择团队', trigger: ['blur','change'] } { required: true, message: '请选择区域', trigger: ['blur','change'] }
], ],
// deptId: [
// { required: true, message: '', trigger: ['blur','change'] }
// ],
phone: [ phone: [
{ required: true, message: '请输入手机号码', trigger: 'blur' }, { required: true, message: '请输入手机号码', trigger: 'blur' },
{ pattern: /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})|(19[0-9]{9})$/, message: '请输入正确手机号码', trigger: ['blur', 'change']} { pattern: /^(13[0-9]{9})|(18[0-9]{9})|(14[0-9]{9})|(17[0-9]{9})|(15[0-9]{9})|(19[0-9]{9})$/, message: '请输入正确手机号码', trigger: ['blur', 'change']}
@ -168,7 +206,9 @@ export default {
}, },
userRoleOptions: [], userRoleOptions: [],
deptOptions: [] deptOptions: [],
regionOptions:[],//
teamOptions:[]//
}; };
}, },
@ -176,6 +216,7 @@ export default {
handleSubmit(){ handleSubmit(){
if(!this.$clickThrottle()) { return } if(!this.$clickThrottle()) { return }
let _this=this; let _this=this;
console.log(_this.userInfo,'_this.userInfo')
this.$refs.ruleForm.validate(async(valid) => { this.$refs.ruleForm.validate(async(valid) => {
if (valid) { if (valid) {
_this.userInfo.username = _this.userInfo.phone; _this.userInfo.username = _this.userInfo.phone;
@ -240,7 +281,51 @@ export default {
}, },
handleCascaderChange(e){ handleCascaderChange(e){
this.userInfo.deptId = e[1] this.userInfo.deptId = e[1]
},
getRegion(){
api.getDeptList({current: 1,size: 100,companyId:this.$store.state.userinfo.companyId}).then(res => {
res.records.forEach(item =>{
if(item.pid == 0)
{
this.regionOptions.push({id:item.id.toString(),name:item.name})
if(this.userInfo.deptId == item.id){
this.userInfo.regionId = item.id.toString()
}
}
if(this.userInfo.deptId == item.id)
{
if(item.pid == 0)
{
this.userInfo.regionId = item.id.toString()
}
else
{
this.userInfo.regionId = item.pid.toString()
this.userInfo.teamId = item.id.toString()
}
}
})
if(this.userInfo.regionId != '')
{
this.regionChange(0)
}
})
},
regionChange(type){
this.teamOptions = []
if(type != 0){ this.userInfo.teamId = '' }
if(this.userInfo.regionId != '')
{
api.getDeptList({current: 1,size: 100,companyId:this.$store.state.userinfo.companyId,pid:this.userInfo.regionId}).then(res => {
res.records.forEach(item =>{
this.teamOptions.push({id:item.id.toString(),name:item.name})
})
})
}
} }
}, },
async created() async created()
{ {
@ -248,22 +333,27 @@ export default {
this.userId = JSON.parse(sessionStorage.getItem('userInfo')).id this.userId = JSON.parse(sessionStorage.getItem('userInfo')).id
} }
if(Object.keys(this.addOrEditUserConfig.data).length>0)
{
this.userInfo = JSON.parse(JSON.stringify(this.addOrEditUserConfig.data));
this.userInfo.regionId = '0'
this.userInfo.teamId = ''
}
api.getRoleListByUserId({userId:this.userId}).then(res => { api.getRoleListByUserId({userId:this.userId}).then(res => {
res.forEach(element => { res.forEach(element => {
this.userRoleOptions.push({name:element.name,id:element.id}) this.userRoleOptions.push({name:element.name,id:element.id})
}); });
}) })
api.getDeptTree({current: 1,size: 100,companyId:this.$store.state.userinfo.companyId}).then(res => { this.getRegion()
this.deptOptions = res // api.getDeptTree({current: 1,size: 100,companyId:this.$store.state.userinfo.companyId}).then(res => {
this.ShowRecursive(this.deptOptions) // this.deptOptions = res
// this.ShowRecursive(this.deptOptions)
}) // })
if(Object.keys(this.addOrEditUserConfig.data).length>0)
{
this.userInfo = JSON.parse(JSON.stringify(this.addOrEditUserConfig.data));
}
} }
}; };