|
@@ -5,6 +5,48 @@
|
|
|
<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>
|
|
|
+ <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>
|
|
|
<el-button type="primary" @click="makeSure">确定</el-button>
|
|
@@ -14,64 +56,213 @@
|
|
|
|
|
|
<script>
|
|
|
import PageTitle from "@/components/Page/Title";
|
|
|
-
|
|
|
+import { getCookie } from "@/utils/util.js";
|
|
|
export default {
|
|
|
components: { PageTitle },
|
|
|
data() {
|
|
|
return {
|
|
|
form1: {},
|
|
|
value: undefined,
|
|
|
+ //新增用户的SSO主键
|
|
|
+ personnelSsoId:'',
|
|
|
+ //token
|
|
|
+ token: null,
|
|
|
+ //二级部门
|
|
|
+ options1:[],
|
|
|
+ //选中的二级部门名称
|
|
|
+ value1:'',
|
|
|
+ //选中的二级部门机构ID和机构编码
|
|
|
+ map1:[],
|
|
|
+ // 三级部门
|
|
|
+ options2:[],
|
|
|
+ // 选中的三级部门名称
|
|
|
+ value2:'',
|
|
|
+ //选中的三级部门机构ID和机构编码
|
|
|
+ map2:[],
|
|
|
+ // 角色
|
|
|
+ options3:[],
|
|
|
+ // 选中的角色名称
|
|
|
+ value3:'',
|
|
|
+ // 选中的角色ID
|
|
|
+ roleId:''
|
|
|
};
|
|
|
},
|
|
|
- mounted() {},
|
|
|
+ created(){
|
|
|
+ this.token = getCookie("accessToken");
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ //初始化二级机构和角色
|
|
|
+ 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;
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ //确定人员新增
|
|
|
makeSure() {
|
|
|
- console.log(this.form1)
|
|
|
- let RmsPersonnel={
|
|
|
- personnelId:this.form1.personnelId,
|
|
|
- personnelJobNumber: this.form1.personnelJobNumber,
|
|
|
- personnelName: this.form1.personnelName,
|
|
|
- personnelPost: this.form1.personnelPost,
|
|
|
- personnelWorkshopid: this.form1.personnelWorkshopid,
|
|
|
- personnelShifts: this.form1.personnelShifts,
|
|
|
- personnelTeam:this.form1.personnelTeam,
|
|
|
- departmentId: this.form1.shipperId,
|
|
|
- username:this.form1.username
|
|
|
- };
|
|
|
- let userName={
|
|
|
+ //初始化用户信息
|
|
|
+ let userInfo = {};
|
|
|
+ //该用户没有三级部门
|
|
|
+ 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{
|
|
|
+ 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中的用户
|
|
|
+ const formData = new FormData();
|
|
|
+
|
|
|
+ Object.keys(userInfo).forEach((key) => {
|
|
|
+ formData.append(key, userInfo[key]);
|
|
|
+ });
|
|
|
+ //新增用户
|
|
|
+ this.$store.dispatch('system/usersManage/addUser',formData)
|
|
|
+ .then((res)=>{
|
|
|
|
|
|
+ //再新增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 : res.data.userId
|
|
|
}
|
|
|
if(
|
|
|
RmsPersonnel.personnelJobNumber ==null ||
|
|
|
RmsPersonnel.personnelName ==null ||
|
|
|
RmsPersonnel.personnelPost ==null ||
|
|
|
- RmsPersonnel.personnelWorkshopid==null ||
|
|
|
+ // RmsPersonnel.personnelWorkshopid==null ||
|
|
|
RmsPersonnel.personnelShifts==null ||
|
|
|
RmsPersonnel.departmentId==null ||
|
|
|
- RmsPersonnel.personnelTeam==null
|
|
|
+ RmsPersonnel.personnelTeam==null ||
|
|
|
+ userInfo.orgName==null ||
|
|
|
+ userInfo.orgCode==null ||
|
|
|
+ userInfo.orgId==null ||
|
|
|
+ this.value3==null
|
|
|
)this.$message.error("存在空值!");
|
|
|
else
|
|
|
- this.axios
|
|
|
- .post(
|
|
|
|
|
|
- )
|
|
|
- .post(
|
|
|
- "/api/v1/rms/insertPersonnel",
|
|
|
- RmsPersonnel
|
|
|
- )
|
|
|
- .then((res) => {
|
|
|
- if (res.data.code == 200) {
|
|
|
+ this.axios.post('/api/v1/rms/addPersonnel',rmsPersonnel)
|
|
|
+ .then((res)=>{
|
|
|
+ if (res.data.code == 200) {
|
|
|
this.$message({
|
|
|
type: "success",
|
|
|
message: "新增成功!",
|
|
|
});
|
|
|
// this.$refs.table.refreshData();
|
|
|
- this.$router.go(-1);
|
|
|
} else {
|
|
|
this.$message.error("新增失败,可能存在重复!");
|
|
|
}
|
|
|
- this.$refs['table'].resetField();
|
|
|
- });
|
|
|
+ // this.$refs['table'].resetField();
|
|
|
+ })
|
|
|
+
|
|
|
+ //最后新增角色赋权表
|
|
|
+ this.axios.post('pass/v1/sysuserroles/addUserroles?userId='
|
|
|
+ +res.data.userId+'&userCode='+this.form1.personnelJobNumber+'&roleId='+this.value3)
|
|
|
+ .then((res)=>{
|
|
|
+ this.$router.go(-1);
|
|
|
+ })
|
|
|
+ });
|
|
|
+
|
|
|
+ //最后新增角色赋权表
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ // let RmsPersonnel={
|
|
|
+ // personnelId:this.form1.personnelId,
|
|
|
+ // personnelJobNumber: this.form1.personnelJobNumber,
|
|
|
+ // personnelName: this.form1.personnelName,
|
|
|
+ // personnelPost: this.form1.personnelPost,
|
|
|
+ // personnelWorkshopid: this.form1.personnelWorkshopid,
|
|
|
+ // personnelShifts: this.form1.personnelShifts,
|
|
|
+ // personnelTeam:this.form1.personnelTeam,
|
|
|
+ // departmentId: this.form1.shipperId
|
|
|
+ // };
|
|
|
+ // if(
|
|
|
+ // RmsPersonnel.personnelJobNumber ==null ||
|
|
|
+ // RmsPersonnel.personnelName ==null ||
|
|
|
+ // RmsPersonnel.personnelPost ==null ||
|
|
|
+ // RmsPersonnel.personnelWorkshopid==null ||
|
|
|
+ // RmsPersonnel.personnelShifts==null ||
|
|
|
+ // RmsPersonnel.departmentId==null ||
|
|
|
+ // RmsPersonnel.personnelTeam==null
|
|
|
+ // )this.$message.error("存在空值!");
|
|
|
+ // else
|
|
|
+ // this.axios
|
|
|
+ // .post(
|
|
|
+ // "/api/v1/rms/insertPersonnel",
|
|
|
+ // RmsPersonnel
|
|
|
+ // )
|
|
|
+ // .then((res) => {
|
|
|
+ // if (res.data.code == 200) {
|
|
|
+ // this.$message({
|
|
|
+ // type: "success",
|
|
|
+ // message: "新增成功!",
|
|
|
+ // });
|
|
|
+ // // this.$refs.table.refreshData();
|
|
|
+ // this.$router.go(-1);
|
|
|
+ // } else {
|
|
|
+ // this.$message.error("新增失败,可能存在重复!");
|
|
|
+ // }
|
|
|
+ // this.$refs['table'].resetField();
|
|
|
+ // });
|
|
|
},
|
|
|
// 取消
|
|
|
cancel() {
|
|
@@ -84,6 +275,7 @@ export default {
|
|
|
.button-box{
|
|
|
display: flex;
|
|
|
justify-content: center;
|
|
|
+ margin-top: 2rem;
|
|
|
.el-button{
|
|
|
width: 80px;
|
|
|
margin-right: 10px;
|
|
@@ -108,4 +300,16 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+.department{
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ .department3{
|
|
|
+ margin-left: 2rem;
|
|
|
+ }
|
|
|
+}
|
|
|
+.role{
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ margin-top: 2rem;
|
|
|
+}
|
|
|
</style>
|