|
@@ -2,50 +2,50 @@
|
|
|
<!-- 添加人员信息 -->
|
|
|
<div class="addWagonLoad">
|
|
|
<PageTitle>返回</PageTitle>
|
|
|
- <div class="form-box" style="margin-right: 10rem">
|
|
|
- <dil-form :formId="325" v-model="form1" ref="from1"></dil-form>
|
|
|
- </div>
|
|
|
+ <div class="form-box" style="margin-right: 10rem">
|
|
|
+ <dil-form :formId="325" v-model="form1" ref="from1"></dil-form>
|
|
|
+ </div>
|
|
|
|
|
|
- <div class="department">
|
|
|
- <div class="department2">
|
|
|
- <span>二级部门:</span>
|
|
|
- <el-select v-model="value1" placeholder="请选择" @change="onchange1">
|
|
|
- <el-option
|
|
|
- v-for="(item,i) in options1"
|
|
|
- :key="i"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
- <div class="department3">
|
|
|
- <span>三级部门:</span>
|
|
|
- <el-select v-model="value2" placeholder="请选择" @change="onchange2">
|
|
|
- <el-option
|
|
|
- v-for="(item,i) in options2"
|
|
|
- :key="i"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
+ <div class="department">
|
|
|
+ <div class="department2">
|
|
|
+ <span>二级部门:</span>
|
|
|
+ <el-select v-model="value1" placeholder="请选择" @change="onchange1">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, i) in options1"
|
|
|
+ :key="i"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
- <div>
|
|
|
- <div class="role">
|
|
|
- <span>赋权角色:</span>
|
|
|
- <el-select v-model="value3" placeholder="请选择">
|
|
|
- <el-option
|
|
|
- v-for="(item,i) in options3"
|
|
|
- :key="i"
|
|
|
- :label="item.roleName"
|
|
|
- :value="item.roleId"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </div>
|
|
|
+ <div class="department3">
|
|
|
+ <span>三级部门:</span>
|
|
|
+ <el-select v-model="value2" placeholder="请选择" @change="onchange2">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, i) in options2"
|
|
|
+ :key="i"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <div class="role">
|
|
|
+ <span>赋权角色:</span>
|
|
|
+ <el-select v-model="value3" placeholder="请选择">
|
|
|
+ <el-option
|
|
|
+ v-for="(item, i) in options3"
|
|
|
+ :key="i"
|
|
|
+ :label="item.roleName"
|
|
|
+ :value="item.roleId"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</div>
|
|
|
+ </div>
|
|
|
|
|
|
<div class="button-box">
|
|
|
<el-button @click="cancel">取消</el-button>
|
|
@@ -62,46 +62,46 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
form1: {
|
|
|
- personnelJobNumber : '',
|
|
|
- personnelName : '',
|
|
|
- personnelPost : '',
|
|
|
- personnelWorkshopid : '',
|
|
|
- shipperId : '',
|
|
|
- personnelShifts : '',
|
|
|
- personnelTeam : ''
|
|
|
+ personnelJobNumber: "",
|
|
|
+ personnelName: "",
|
|
|
+ personnelPost: "",
|
|
|
+ personnelWorkshopid: "",
|
|
|
+ shipperId: "",
|
|
|
+ personnelShifts: "",
|
|
|
+ personnelTeam: ""
|
|
|
},
|
|
|
value: undefined,
|
|
|
//新增用户的SSO主键
|
|
|
- personnelSsoId:'',
|
|
|
+ personnelSsoId: "",
|
|
|
//token
|
|
|
token: null,
|
|
|
//二级部门
|
|
|
- options1:[],
|
|
|
+ options1: [],
|
|
|
//选中的二级部门名称
|
|
|
- value1:'',
|
|
|
+ value1: "",
|
|
|
//选中的二级部门机构ID和机构编码
|
|
|
- map1:{
|
|
|
- shipperOrgCode : '',
|
|
|
- shipperSsoId : ''
|
|
|
+ map1: {
|
|
|
+ shipperOrgCode: "",
|
|
|
+ shipperSsoId: ""
|
|
|
},
|
|
|
// 三级部门
|
|
|
- options2:[],
|
|
|
+ options2: [],
|
|
|
// 选中的三级部门名称
|
|
|
- value2:'',
|
|
|
+ value2: "",
|
|
|
//选中的三级部门机构ID和机构编码
|
|
|
- map2:{
|
|
|
- shipperOrgCode : '',
|
|
|
- shipperSsoId : ''
|
|
|
+ map2: {
|
|
|
+ shipperOrgCode: "",
|
|
|
+ shipperSsoId: ""
|
|
|
},
|
|
|
// 角色
|
|
|
- options3:[],
|
|
|
+ options3: [],
|
|
|
// 选中的角色名称
|
|
|
- value3:'',
|
|
|
+ value3: "",
|
|
|
// 选中的角色ID
|
|
|
- roleId:''
|
|
|
+ roleId: ""
|
|
|
};
|
|
|
},
|
|
|
- created(){
|
|
|
+ created() {
|
|
|
this.token = getCookie("accessToken");
|
|
|
},
|
|
|
mounted() {
|
|
@@ -109,203 +109,217 @@ export default {
|
|
|
this.initialization();
|
|
|
},
|
|
|
methods: {
|
|
|
- initialization(){
|
|
|
- //初始化选择二级机构
|
|
|
- this.axios.get('/api/v1/rms/getSecondShipper').then((res)=>{
|
|
|
- this.options1 = res.data.data;
|
|
|
- })
|
|
|
- //初始化角色
|
|
|
- const formData = new FormData();
|
|
|
- this.$store.dispatch('system/rolesManage/list',formData)
|
|
|
- .then((res)=>{
|
|
|
- var roleList = [];
|
|
|
- roleList=res.data;
|
|
|
- roleList.forEach((item,i)=>{
|
|
|
- if(item.roleId!='superadmin'){
|
|
|
- this.options3.push(item);
|
|
|
- }
|
|
|
- })
|
|
|
- // this.options3 = res.data;
|
|
|
- })
|
|
|
- },
|
|
|
- onchange1(val){
|
|
|
- // 查询选中的二级机构下的三级机构
|
|
|
- this.value2 = '';
|
|
|
- this.axios.get('/api/v1/rms/getThirdShipper?shipperId='+val).then((res)=>{
|
|
|
- this.options2 = res.data.data;
|
|
|
- })
|
|
|
- //获取二级部门的机构ID和机构编码
|
|
|
- this.axios.post('/api/v1/rms/getShipperMap?shipperId='+val).then((res)=>{
|
|
|
- this.map1 = res.data.data;
|
|
|
- })
|
|
|
- },
|
|
|
- onchange2(val){
|
|
|
- //获取三级部门的机构ID和机构编码
|
|
|
- this.axios.post('/api/v1/rms/getShipperMap?shipperId='+val).then((res)=>{
|
|
|
- this.map2 = res.data.data;
|
|
|
- })
|
|
|
- },
|
|
|
+ initialization() {
|
|
|
+ //初始化选择二级机构
|
|
|
+ this.axios.get("/api/v1/rms/getSecondShipper").then(res => {
|
|
|
+ this.options1 = res.data.data;
|
|
|
+ });
|
|
|
+ //初始化角色
|
|
|
+ const formData = new FormData();
|
|
|
+ this.$store.dispatch("system/rolesManage/list", formData).then(res => {
|
|
|
+ var roleList = [];
|
|
|
+ roleList = res.data;
|
|
|
+ roleList.forEach((item, i) => {
|
|
|
+ if (item.roleId != "superadmin") {
|
|
|
+ this.options3.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // this.options3 = res.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onchange1(val) {
|
|
|
+ // 查询选中的二级机构下的三级机构
|
|
|
+ this.value2 = "";
|
|
|
+ this.axios
|
|
|
+ .get("/api/v1/rms/getThirdShipper?shipperId=" + val)
|
|
|
+ .then(res => {
|
|
|
+ this.options2 = res.data.data;
|
|
|
+ });
|
|
|
+ //获取二级部门的机构ID和机构编码
|
|
|
+ this.axios
|
|
|
+ .post("/api/v1/rms/getShipperMap?shipperId=" + val)
|
|
|
+ .then(res => {
|
|
|
+ this.map1 = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onchange2(val) {
|
|
|
+ //获取三级部门的机构ID和机构编码
|
|
|
+ this.axios
|
|
|
+ .post("/api/v1/rms/getShipperMap?shipperId=" + val)
|
|
|
+ .then(res => {
|
|
|
+ this.map2 = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- //确定人员新增
|
|
|
- makeSure() {
|
|
|
+ //确定人员新增
|
|
|
+ makeSure() {
|
|
|
//初始化用户信息
|
|
|
let userInfo = {
|
|
|
- orgCode : '',
|
|
|
- orgName : '',
|
|
|
- orgId : '',
|
|
|
+ orgCode: "",
|
|
|
+ orgName: "",
|
|
|
+ orgId: ""
|
|
|
};
|
|
|
//该用户没有三级部门
|
|
|
- if(this.options2.length==0){
|
|
|
- userInfo = {
|
|
|
- userName : this.form1.personnelName,
|
|
|
- userCode : this.form1.personnelJobNumber,
|
|
|
- orgCode : this.map1.shipperOrgCode,
|
|
|
- orgName : this.value1,
|
|
|
- orgId : this.map1.shipperSsoId,
|
|
|
- // mobile : '13500000011',
|
|
|
- // email : '123456789@qq.com',
|
|
|
- groupId : '506514577756917769',
|
|
|
- companyId : '713710108567277568'
|
|
|
- }
|
|
|
- //该用户有三级部门
|
|
|
- }else{
|
|
|
+ if (this.options2.length == 0) {
|
|
|
userInfo = {
|
|
|
- userName : this.form1.personnelName,
|
|
|
- userCode : this.form1.personnelJobNumber,
|
|
|
- orgCode : this.map2.shipperOrgCode,
|
|
|
- orgName : this.value1,
|
|
|
- orgId : this.map2.shipperSsoId,
|
|
|
- // mobile : '13500000011',
|
|
|
- // email : '123456789@qq.com',
|
|
|
- groupId : '506514577756917769',
|
|
|
- companyId : '713710108567277568'
|
|
|
- }
|
|
|
+ userName: this.form1.personnelName,
|
|
|
+ userCode: this.form1.personnelJobNumber,
|
|
|
+ orgCode: this.map1.shipperOrgCode,
|
|
|
+ orgName: this.value1,
|
|
|
+ orgId: this.map1.shipperSsoId,
|
|
|
+ // mobile : '13500000011',
|
|
|
+ // email : '123456789@qq.com',
|
|
|
+ groupId: "506514577756917769",
|
|
|
+ companyId: "713710108567277568"
|
|
|
+ };
|
|
|
+ //该用户有三级部门
|
|
|
+ } else {
|
|
|
+ userInfo = {
|
|
|
+ userName: this.form1.personnelName,
|
|
|
+ userCode: this.form1.personnelJobNumber,
|
|
|
+ orgCode: this.map2.shipperOrgCode,
|
|
|
+ orgName: this.value1,
|
|
|
+ orgId: this.map2.shipperSsoId,
|
|
|
+ // mobile : '13500000011',
|
|
|
+ // email : '123456789@qq.com',
|
|
|
+ groupId: "506514577756917769",
|
|
|
+ companyId: "713710108567277568"
|
|
|
+ };
|
|
|
}
|
|
|
- //先新增SSO中的用户
|
|
|
+ //先新增SSO中的用户
|
|
|
const formData = new FormData();
|
|
|
-
|
|
|
- Object.keys(userInfo).forEach((key) => {
|
|
|
- formData.append(key, userInfo[key]);
|
|
|
+
|
|
|
+ Object.keys(userInfo).forEach(key => {
|
|
|
+ formData.append(key, userInfo[key]);
|
|
|
});
|
|
|
//判断数据是否都填了
|
|
|
- if(
|
|
|
- this.form1.personnelJobNumber =='' ||
|
|
|
- this.form1.personnelPost =='' ||
|
|
|
- this.form1.personnelName =='' ||
|
|
|
- // RmsPersonnel.personnelWorkshopid==null ||
|
|
|
- this.form1.shipperId=='' ||
|
|
|
- this.form1.personnelShifts=='' ||
|
|
|
- this.form1.personnelTeam=='' ||
|
|
|
- userInfo.orgName=='' ||
|
|
|
- userInfo.orgCode=='' ||
|
|
|
- userInfo.orgId=='' ||
|
|
|
- this.value3==''
|
|
|
- ){
|
|
|
- this.$message.error("存在空值!");
|
|
|
- }else{
|
|
|
- //判断RMS_PERSONNEL表中是否存在该人员信息,存在提示存在,否则开始赋权新增
|
|
|
- this.axios.post('/api/v1/rms/isInHere?personnelJobNumber='+this.form1.personnelJobNumber)
|
|
|
- .then((res)=>{
|
|
|
- console.log("res",res);
|
|
|
- if(res.data==0){
|
|
|
- this.$message.error("新增失败,该账号已存在!");
|
|
|
- }else{
|
|
|
- //开始赋权新增
|
|
|
- //新增用户表
|
|
|
- this.$store.dispatch('system/usersManage/addUser',formData)
|
|
|
- .then((res)=>{
|
|
|
- //console.log("role",res)
|
|
|
- //保存权限表中的用户主键Id
|
|
|
- this.personnelSsoId = res.data.userId;
|
|
|
- //再新增RMS_PERSONNEL表信息
|
|
|
- let rmsPersonnel = {
|
|
|
- personnelJobNumber : this.form1.personnelJobNumber,
|
|
|
- personnelPost : this.form1.personnelPost,
|
|
|
- personnelName : this.form1.personnelName,
|
|
|
- personnelDepartmentId : this.form1.shipperId,
|
|
|
- // personnelWorkshopid : this.form1.personnelWorkshopid,
|
|
|
- personnelShifts : this.form1.personnelShifts,
|
|
|
- personnelTeam : this.form1.personnelTeam,
|
|
|
- personnelSsoId : this.personnelSsoId
|
|
|
- }
|
|
|
- // console.log("rmsPersonnel",rmsPersonnel)
|
|
|
- this.axios.post('/api/v1/rms/addPersonnel',rmsPersonnel)
|
|
|
- .then((res)=>{
|
|
|
- // console.log("Personnel",res)
|
|
|
- if (res.data.code == 200) {
|
|
|
+ if (
|
|
|
+ this.form1.personnelJobNumber == "" ||
|
|
|
+ this.form1.personnelPost == "" ||
|
|
|
+ this.form1.personnelName == "" ||
|
|
|
+ // RmsPersonnel.personnelWorkshopid==null ||
|
|
|
+ this.form1.shipperId == "" ||
|
|
|
+ this.form1.personnelShifts == "" ||
|
|
|
+ this.form1.personnelTeam == "" ||
|
|
|
+ this.form1.ConcatTelephone == "" ||
|
|
|
+ userInfo.orgName == "" ||
|
|
|
+ userInfo.orgCode == "" ||
|
|
|
+ userInfo.orgId == "" ||
|
|
|
+ this.value3 == ""
|
|
|
+ ) {
|
|
|
+ this.$message.error("存在空值!");
|
|
|
+ } else {
|
|
|
+ //判断RMS_PERSONNEL表中是否存在该人员信息,存在提示存在,否则开始赋权新增
|
|
|
+ this.axios
|
|
|
+ .post(
|
|
|
+ "/api/v1/rms/isInHere?personnelJobNumber=" +
|
|
|
+ this.form1.personnelJobNumber
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
+ console.log("res", res);
|
|
|
+ if (res.data == 0) {
|
|
|
+ this.$message.error("新增失败,该账号已存在!");
|
|
|
+ } else {
|
|
|
+ //开始赋权新增
|
|
|
+ //新增用户表
|
|
|
+ this.$store
|
|
|
+ .dispatch("system/usersManage/addUser", formData)
|
|
|
+ .then(res => {
|
|
|
+ //console.log("role",res)
|
|
|
+ //保存权限表中的用户主键Id
|
|
|
+ this.personnelSsoId = res.data.userId;
|
|
|
+ //再新增RMS_PERSONNEL表信息
|
|
|
+ let map1 = {
|
|
|
+ personnelJobNumber: this.form1.personnelJobNumber,
|
|
|
+ personnelPost: this.form1.personnelPost,
|
|
|
+ personnelName: this.form1.personnelName,
|
|
|
+ personnelDepartmentId: this.form1.shipperId,
|
|
|
+ // personnelWorkshopid : this.form1.personnelWorkshopid,
|
|
|
+ personnelShifts: this.form1.personnelShifts,
|
|
|
+ personnelTeam: this.form1.personnelTeam,
|
|
|
+ personnelSsoId: this.personnelSsoId,
|
|
|
+ //联系电话
|
|
|
+ ConcatTelephone: this.form1.ConcatTelephone,
|
|
|
+ userId: getCookie("userId")
|
|
|
+ };
|
|
|
+ // console.log("rmsPersonnel",rmsPersonnel)
|
|
|
+ this.axios
|
|
|
+ .post("/api/v1/rms/addPersonnel", map1)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code == 200) {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
- message: "新增成功!",
|
|
|
+ message: "新增成功!"
|
|
|
});
|
|
|
// this.$refs.table.refreshData();
|
|
|
-
|
|
|
//最后新增角色赋权表
|
|
|
-
|
|
|
- this.axios.post('pass/v1/sysuserroles/addUserroles?userId='
|
|
|
- +this.personnelSsoId+'&userCode='+this.form1.personnelJobNumber+'&roleId='+this.value3)
|
|
|
- .then((res)=>{
|
|
|
+ this.axios
|
|
|
+ .post(
|
|
|
+ "pass/v1/sysuserroles/addUserroles?userId=" +
|
|
|
+ this.personnelSsoId +
|
|
|
+ "&userCode=" +
|
|
|
+ this.form1.personnelJobNumber +
|
|
|
+ "&roleId=" +
|
|
|
+ this.value3
|
|
|
+ )
|
|
|
+ .then(res => {
|
|
|
// console.log("success")
|
|
|
- this.$router.go(-1);
|
|
|
- })
|
|
|
-
|
|
|
+ // this.$router.go(-1);
|
|
|
+ });
|
|
|
} else {
|
|
|
this.$message.error("新增失败,可能存在重复!");
|
|
|
}
|
|
|
// this.$refs['table'].resetField();
|
|
|
- })
|
|
|
-
|
|
|
- });//end
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- }//else
|
|
|
-
|
|
|
+ });
|
|
|
+ }); //end
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } //else
|
|
|
},
|
|
|
// 取消
|
|
|
cancel() {
|
|
|
this.$router.go(-1);
|
|
|
- },
|
|
|
- },
|
|
|
+ }
|
|
|
+ }
|
|
|
};
|
|
|
</script>
|
|
|
-<style lang='scss' >
|
|
|
- .button-box{
|
|
|
- display: flex;
|
|
|
- justify-content: center;
|
|
|
- margin-top: 2rem;
|
|
|
- .el-button{
|
|
|
- width: 80px;
|
|
|
- margin-right: 10px;
|
|
|
- }
|
|
|
+<style lang="scss">
|
|
|
+.button-box {
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ margin-top: 2rem;
|
|
|
+ .el-button {
|
|
|
+ width: 80px;
|
|
|
+ margin-right: 10px;
|
|
|
}
|
|
|
-.form-box{
|
|
|
+}
|
|
|
+.form-box {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- .el-form-item{
|
|
|
+ .el-form-item {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- .el-form-item__label{
|
|
|
+ .el-form-item__label {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
}
|
|
|
- .el-form-item__content{
|
|
|
- .el-input{
|
|
|
- .el-input__inner{
|
|
|
+ .el-form-item__content {
|
|
|
+ .el-input {
|
|
|
+ .el-input__inner {
|
|
|
width: 250px;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-.department{
|
|
|
+.department {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
- .department3{
|
|
|
+ .department3 {
|
|
|
margin-left: 2rem;
|
|
|
}
|
|
|
}
|
|
|
-.role{
|
|
|
+.role {
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
margin-top: 2rem;
|