|
@@ -18,32 +18,22 @@
|
|
|
</div> -->
|
|
|
<div>
|
|
|
<!-- <button type="submmit" class="delBtn" @click="delate">删除</button> -->
|
|
|
- <button type="submmit" class="saveBtn" @click="saveJob()">
|
|
|
+ <button type="submmit" style="cursor: pointer;" class="saveBtn" @click="saveJob('form')">
|
|
|
保存
|
|
|
</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="titleContent">
|
|
|
- <el-form ref="form" :model="FormData" label-width="80px">
|
|
|
+ <el-form ref="form" :model="FormData" :rules="rules" label-width="80px">
|
|
|
<el-row :gutter="40">
|
|
|
<el-col :span="5">
|
|
|
- <el-form-item label="岗位名称" prop="name">
|
|
|
- <el-input
|
|
|
- v-model="FormData.JobName"
|
|
|
- maxlength="32"
|
|
|
- placeholder="请输入岗位名称"
|
|
|
- size="small"
|
|
|
- ></el-input>
|
|
|
+ <el-form-item label="岗位名称" prop="JobName">
|
|
|
+ <el-input v-model="FormData.JobName" maxlength="32" placeholder="请输入岗位名称" size="small"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="10">
|
|
|
<el-form-item label="描述" prop="diesc">
|
|
|
- <el-input
|
|
|
- v-model="FormData.JobDesc"
|
|
|
- maxlength="128"
|
|
|
- placeholder="描述内容"
|
|
|
- size="small"
|
|
|
- ></el-input>
|
|
|
+ <el-input v-model="FormData.JobDesc" maxlength="128" placeholder="描述内容" size="small"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -52,92 +42,9 @@
|
|
|
</div>
|
|
|
<div class="content">
|
|
|
<el-row :gutter="25">
|
|
|
- <el-col :span="24" v-if="systemSet.UserOfficerMulti != 0">
|
|
|
+ <el-col :span="24">
|
|
|
<div class="part">
|
|
|
- <Organization
|
|
|
- title="所属组织"
|
|
|
- :data="dataList"
|
|
|
- :defaultProps="defaultProps"
|
|
|
- :nodekey="'Organid'"
|
|
|
- @getCheckedData="getOrganTreeData"
|
|
|
- :checkedKeys="checkedIdList"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8" v-if="systemSet.UserOfficerMulti === 0">
|
|
|
- <div class="part">
|
|
|
- <Organization
|
|
|
- title="所属组织"
|
|
|
- :data="originData"
|
|
|
- :defaultProps="defaultProps"
|
|
|
- :nodekey="'Organid'"
|
|
|
- :checkedKeys="checkedIdList"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- <el-col
|
|
|
- :span="8"
|
|
|
- v-if="
|
|
|
- systemSet.OpenRole === 0 &&
|
|
|
- systemSet.OpenGroup == 0 &&
|
|
|
- systemSet.UserOfficerMulti === 0
|
|
|
- "
|
|
|
- >
|
|
|
- <div class="part">
|
|
|
- <Permissiontree
|
|
|
- @getTreeData="getAuthTreeData"
|
|
|
- :checkedKeys="checkedAuthKeys"
|
|
|
- :queryType="queryType"
|
|
|
- :queryId="originId"
|
|
|
- title="权限树"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- <el-col
|
|
|
- :span="8"
|
|
|
- v-if="
|
|
|
- systemSet.OpenRole === 0 &&
|
|
|
- systemSet.OpenGroup == 0 &&
|
|
|
- systemSet.UserOfficerMulti === 0
|
|
|
- "
|
|
|
- >
|
|
|
- <div class="part">
|
|
|
- <Rulesofcompetency title="权限规则" />
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- <el-col
|
|
|
- :span="8"
|
|
|
- v-if="
|
|
|
- (systemSet.OpenRole != 0 || systemSet.OpenGroup != 0) &&
|
|
|
- systemSet.UserOfficerMulti === 0
|
|
|
- "
|
|
|
- >
|
|
|
- <div class="part">
|
|
|
- <rolelist
|
|
|
- :title="title"
|
|
|
- @checkChange="checkRoleChange"
|
|
|
- :dataList="originRoleList"
|
|
|
- :checkBoxList="checkedRoleKeys"
|
|
|
- @checkClick="roleClick"
|
|
|
- :number="8"
|
|
|
- />
|
|
|
- </div>
|
|
|
- </el-col>
|
|
|
- <el-col
|
|
|
- :span="8"
|
|
|
- v-if="
|
|
|
- (systemSet.OpenRole != 0 || systemSet.OpenGroup != 0) &&
|
|
|
- systemSet.UserOfficerMulti === 0
|
|
|
- "
|
|
|
- >
|
|
|
- <div class="part">
|
|
|
- <permissionlist
|
|
|
- title="权限列表"
|
|
|
- :RoleList="powerList"
|
|
|
- :check="true"
|
|
|
- class="hucPower"
|
|
|
- @Competen="Competen"
|
|
|
- />
|
|
|
+ <Organization title="上级组织" :active="0" :data="dataObj" :defaultProps="defaultProps" nodekey="OrganId" @getTreeData="getOrganTreeData" :checkedKeys="checkedIdList" />
|
|
|
</div>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
@@ -145,35 +52,17 @@
|
|
|
</div>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import Permissiontree from "@/components/permissiontree/index.vue";
|
|
|
-import Rulesofcompetency from "@/components/rulesofcompetency/index.vue";
|
|
|
-import Organization from "@/components/organization/index.vue";
|
|
|
-import rolelist from "@/components/rolelist/index.vue";
|
|
|
-import permissionlist from "@/components/permissionlist/index.vue";
|
|
|
-
|
|
|
+import Organization from "@/components/organization";
|
|
|
import treeData from "./minixs/treeData";
|
|
|
-import roleData from "./minixs/roleData";
|
|
|
-
|
|
|
import { GetJobDetails, EditJob } from "@/api/jobApi";
|
|
|
-import { newOrganall } from "@/api/postInterface";
|
|
|
-import { RoleAuths } from "@/api/apiAuthority";
|
|
|
-import { GroupAuths } from "@/api/authGroupApi";
|
|
|
-
|
|
|
export default {
|
|
|
- data() {
|
|
|
+ data () {
|
|
|
return {
|
|
|
- queryType: "origin",
|
|
|
- JobId: 0, //当前岗位ID
|
|
|
- systemSet: null, //系统设置
|
|
|
+ JobId: null, //当前岗位ID
|
|
|
+ OrganId: null,
|
|
|
FormData: {
|
|
|
JobName: "",
|
|
|
- AuthList: [],
|
|
|
JobDesc: "",
|
|
|
- JobId: 0,
|
|
|
- JobName: "",
|
|
|
- OrganId: 0,
|
|
|
- RoleList: [],
|
|
|
- GroupList: [],
|
|
|
},
|
|
|
rules: {
|
|
|
JobName: [
|
|
@@ -190,241 +79,92 @@ export default {
|
|
|
children: "children",
|
|
|
label: "OrganName",
|
|
|
},
|
|
|
- listData: [], //上级组织树
|
|
|
- originId: "-1", //所属组织ID
|
|
|
- originData: [], //所属组织详情
|
|
|
- checkedIdList: [], //选中组织树
|
|
|
- AuthList: [], //选中权限(包含规则组)
|
|
|
- RoleList: [], //选中角色/权限组组
|
|
|
- checkedAuthKeys: [],
|
|
|
- checkedRoleKeys: [],
|
|
|
- originRoleList: [], //所属组织角色/权限组列表
|
|
|
- powerList: [], //角色/权限组权限列表
|
|
|
+ dataObj: [], //上级组织树
|
|
|
+ checkedIdList: [],
|
|
|
title: "",
|
|
|
};
|
|
|
},
|
|
|
- mixins: [treeData, roleData],
|
|
|
- watch: {
|
|
|
- arrs: {
|
|
|
- handler(arr) {
|
|
|
- arr.forEach((item) => {
|
|
|
- item.name = item.RoleName;
|
|
|
- if (this.systemSet.OpenRole != 0) {
|
|
|
- item.name = item.RoleName;
|
|
|
- } else {
|
|
|
- item.name = item.GroupName;
|
|
|
- }
|
|
|
- if (
|
|
|
- item.IsSelected == 1 &&
|
|
|
- _.indexOf(this.originRoleList, item) == -1
|
|
|
- ) {
|
|
|
- this.originRoleList.push(item);
|
|
|
- }
|
|
|
- });
|
|
|
- this.checkedRoleKeys = [];
|
|
|
- this.RoleList.forEach((item) => {
|
|
|
- this.originRoleList.forEach((value, index) => {
|
|
|
- if (this.systemSet.OpenRole != 0) {
|
|
|
- if (item.RoleId == value.RoleId) {
|
|
|
- this.checkedRoleKeys.push(index);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (item.GroupId == value.GroupId) {
|
|
|
- this.checkedRoleKeys.push(index);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
- deep: true,
|
|
|
- },
|
|
|
- },
|
|
|
- created: function () {
|
|
|
- const systemData = this.$store.state.app.systemSet;
|
|
|
- if (typeof systemData == "string") {
|
|
|
- this.systemSet = JSON.parse(systemData);
|
|
|
- } else {
|
|
|
- this.systemSet = systemData;
|
|
|
- }
|
|
|
- if (this.systemSet.OpenRole != 0) {
|
|
|
- this.title = "角色列表";
|
|
|
- } else {
|
|
|
- this.title = "权限组列表";
|
|
|
- }
|
|
|
- this.JobId = this.$route.query.JobId;
|
|
|
- this.getJobDetails();
|
|
|
- console.log(this.$route)
|
|
|
+ mixins: [treeData],
|
|
|
+ created () {
|
|
|
+ const { JobId } = this.$route.query;
|
|
|
+ this.getJobDetails(JobId);
|
|
|
},
|
|
|
components: {
|
|
|
Organization,
|
|
|
- Permissiontree,
|
|
|
- Rulesofcompetency,
|
|
|
- rolelist,
|
|
|
- permissionlist,
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ dataList: {
|
|
|
+ handler (val) {
|
|
|
+ this.decompose([val], this.OrganId)
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
+ }
|
|
|
},
|
|
|
methods: {
|
|
|
- //获取岗位详情
|
|
|
- getJobDetails() {
|
|
|
- try {
|
|
|
- let data = {
|
|
|
- JobId: this.JobId,
|
|
|
- };
|
|
|
- GetJobDetails(data).then((result) => {
|
|
|
- if (result.code === 0) {
|
|
|
- this.FormData = _.cloneDeep(result.returnData);
|
|
|
- this.originId = result.returnData.OrganId + "";
|
|
|
- this.AuthList = _.cloneDeep(result.returnData.AuthList);
|
|
|
- this.$store.state.auth.authList = _.cloneDeep(
|
|
|
- result.returnData.AuthList
|
|
|
- );
|
|
|
-
|
|
|
- if (this.AuthList) {
|
|
|
- this.AuthList.forEach((item) => {
|
|
|
- this.checkedAuthKeys.push(item.AuthId);
|
|
|
- });
|
|
|
- }
|
|
|
- this.checkedIdList.push(result.returnData.OrganId);
|
|
|
- this.getOrganDetails();
|
|
|
-
|
|
|
- let list = [];
|
|
|
- if (
|
|
|
- this.systemSet.OpenRole != 0 &&
|
|
|
- this.systemSet.UserOfficerMulti === 0
|
|
|
- ) {
|
|
|
- list = _.cloneDeep(result.returnData.RoleList)
|
|
|
- this.getRoleByOrgan(this.originId);
|
|
|
- } else if (
|
|
|
- this.systemSet.OpenRole == 0 &&
|
|
|
- this.systemSet.OpenGroup != 0 &&
|
|
|
- this.systemSet.UserOfficerMulti === 0
|
|
|
- ) {
|
|
|
- list = _.cloneDeep(result.returnData.GroupList)
|
|
|
- this.getGroupByOrgan(this.originId);
|
|
|
- }
|
|
|
- if (list) {
|
|
|
- list.forEach((item, index) => {
|
|
|
- if (item.IsSelected == 1) {
|
|
|
- this.RoleList.push(item);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.log("GetJobDetails");
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
+ //点击获取组织
|
|
|
+ getOrganTreeData (arr) {
|
|
|
+ const { OrganId } = arr[0]
|
|
|
+ this.OrganId = OrganId
|
|
|
},
|
|
|
- //获取所属组织详情
|
|
|
- getOrganDetails() {
|
|
|
+ //获取岗位详情
|
|
|
+ async getJobDetails (id) {
|
|
|
try {
|
|
|
let data = {
|
|
|
- OrganId: this.originId,
|
|
|
+ JobId: id,
|
|
|
};
|
|
|
- newOrganall(data).then((result) => {
|
|
|
- if (result.code == 0) {
|
|
|
- this.originData = [];
|
|
|
- this.originData.push(result.returnData);
|
|
|
- }
|
|
|
- });
|
|
|
+ const result = await GetJobDetails(data)
|
|
|
+ if (result.code === 0) {
|
|
|
+ const obj = result.returnData
|
|
|
+ const { JobDesc, JobName, JobId, OrganId } = obj
|
|
|
+ this.FormData.JobName = JobName
|
|
|
+ this.FormData.JobDesc = JobDesc
|
|
|
+ this.JobId = JobId
|
|
|
+ this.OrganId = OrganId
|
|
|
+ this.checkedIdList = [OrganId]
|
|
|
+ } else {
|
|
|
+ this.$message.error(result.message)
|
|
|
+ }
|
|
|
} catch (error) {
|
|
|
- console.log("newOrganall");
|
|
|
- console.log(error);
|
|
|
+ this.$message.error(error)
|
|
|
}
|
|
|
},
|
|
|
- //获取当权选中权限树
|
|
|
- getAuthTreeData(data) {
|
|
|
- this.checkedAuthTreeList = _.cloneDeep(data);
|
|
|
- },
|
|
|
- //获取组织树点击
|
|
|
- getOrganTreeData(data) {
|
|
|
- console.log(data);
|
|
|
- },
|
|
|
- //角色/权限组选中后角色/权限组
|
|
|
- checkRoleChange(data) {
|
|
|
- this.RoleList = [];
|
|
|
- data.forEach((item) => {
|
|
|
- this.originRoleList[item].IsSelected = 1;
|
|
|
- this.RoleList.push(this.originRoleList[item]);
|
|
|
- });
|
|
|
- },
|
|
|
- //点击角色/权限组后
|
|
|
- roleClick(data) {
|
|
|
- if (this.systemSet.OpenRole != 0) {
|
|
|
- try {
|
|
|
- let params = {
|
|
|
- RoleId: data.RoleId,
|
|
|
- };
|
|
|
- RoleAuths(params).then((result) => {
|
|
|
- this.powerList = result.returnData;
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.log("RoleAuths");
|
|
|
- console.log(error);
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- try {
|
|
|
- let params = {
|
|
|
- GroupId: data.GroupId,
|
|
|
- };
|
|
|
- GroupAuths(params).then((result) => {
|
|
|
- this.powerList = result.returnData;
|
|
|
- });
|
|
|
- } catch (error) {
|
|
|
- console.log("GroupAuths");
|
|
|
- console.log(error);
|
|
|
+ //保存
|
|
|
+ async saveJob (formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.saveData()
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
},
|
|
|
- //保存
|
|
|
- saveJob() {
|
|
|
+ async saveData () {
|
|
|
try {
|
|
|
- let arr = _.cloneDeep(this.checkedAuthTreeList);
|
|
|
- let authArrs = _.cloneDeep(this.$store.state.auth.authArrs);
|
|
|
- if (arr) {
|
|
|
- this.AuthList = [];
|
|
|
- arr.forEach((item) => {
|
|
|
- this.AuthList.push(item.AuthList);
|
|
|
- });
|
|
|
- this.AuthList.forEach((item, index) => {
|
|
|
- authArrs.forEach((item2) => {
|
|
|
- if (item.AuthId == item2.AuthId) {
|
|
|
- this.AuthList[index] = item2.AuthList;
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
+ const data = {
|
|
|
+ JobName: this.FormData.JobName,
|
|
|
+ JobDesc: this.FormData.JobDesc,
|
|
|
+ OrganId: this.OrganId,
|
|
|
+ JobId: this.JobId
|
|
|
}
|
|
|
- this.FormData.AuthList = this.AuthList;
|
|
|
- if (this.systemSet.OpenRole != 0) {
|
|
|
- this.FormData.RoleList = this.RoleList;
|
|
|
+ const result = await EditJob(data)
|
|
|
+ if (result.code == 0) {
|
|
|
+ this.$message.success(result.message)
|
|
|
+ this.$store.dispatch('tagsView/delView', this.$route)
|
|
|
+ this.$router.push("/jobs")
|
|
|
} else {
|
|
|
- this.FormData.GroupList = this.RoleList;
|
|
|
+ this.$message.error(result.message)
|
|
|
}
|
|
|
- let data = _.cloneDeep(this.FormData);
|
|
|
- EditJob(data).then((result) => {
|
|
|
- if (result.code == 0) {
|
|
|
- this.$message.success(result.message);
|
|
|
- this.$store.dispatch('tagsView/delView', this.$route)
|
|
|
- this.$router.push("/jobs");
|
|
|
- }
|
|
|
- });
|
|
|
} catch (error) {
|
|
|
- console.log("EditJob");
|
|
|
- console.log(error);
|
|
|
+ this.$message.error(error)
|
|
|
}
|
|
|
},
|
|
|
- //查看权限列表明细
|
|
|
- Competen(data) {
|
|
|
- this.$emit("Competen", data);
|
|
|
- },
|
|
|
//获取指定数据
|
|
|
- decompose(data, id) {
|
|
|
+ decompose (data, id) {
|
|
|
for (let i = 0; i < data.length; i++) {
|
|
|
- if (data[i].GroupId == id) {
|
|
|
- this.dataObj = data[i];
|
|
|
- delete this.dataObj.children;
|
|
|
- this.dataObj = [this.dataObj];
|
|
|
+ if (data[i].OrganId == id) {
|
|
|
+ delete data[i].children;
|
|
|
+ this.dataObj = [data[i]];
|
|
|
} else if (data[i].children && data[i].children.length > 0) {
|
|
|
this.decompose(data[i].children, id);
|
|
|
}
|