123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440 |
- <template>
- <div class="pageBody">
- <div class="topPart">
- <div class="title">
- <div class="tltleLeft">编辑岗位</div>
- <!-- <div class="isUsed">
- 是否启用
- <el-radio
- v-model="FormData.isUsed"
- v-if="FormData.isUsed == 1 || form.isUsed == 3"
- :label="1"
- >是</el-radio
- >
- <el-radio v-model="FormData.isUsed" v-if="FormData.isUsed == 2" :label="2"
- >是</el-radio
- >
- <el-radio v-model="FormData.isUsed" :label="3">否</el-radio>
- </div> -->
- <div>
- <!-- <button type="submmit" class="delBtn" @click="delate">删除</button> -->
- <button type="submmit" class="saveBtn" @click="saveJob()">
- 保存
- </button>
- </div>
- </div>
- <div class="titleContent">
- <el-form ref="form" :model="FormData" 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>
- </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-form-item>
- </el-col>
- </el-row>
- </el-form>
- </div>
- </div>
- <div class="content">
- <el-row :gutter="25">
- <el-col :span="24" v-if="systemSet.UserOfficerMulti != 0">
- <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.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.UserOfficerMulti === 0"
- >
- <div class="part">
- <Rulesofcompetency title="权限规则" />
- </div>
- </el-col>
- <el-col
- :span="8"
- v-if="systemSet.OpenRole != 0 && systemSet.UserOfficerMulti === 0"
- >
- <div class="part">
- <rolelist
- title="角色列表"
- @checkChange="checkRoleChange"
- :dataList="originRoleList"
- :checkBoxList="checkedRoleKeys"
- @checkClick="roleClick"
- :number="8"
- />
- </div>
- </el-col>
- <el-col
- :span="8"
- v-if="systemSet.OpenRole != 0 && systemSet.UserOfficerMulti === 0"
- >
- <div class="part">
- <permissionlist
- title="权限列表"
- :RoleList="powerList"
- :check="true"
- class="hucPower"
- @Competen="Competen"
- />
- </div>
- </el-col>
- </el-row>
- </div>
- </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 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";
- export default {
- data() {
- return {
- queryType: "origin",
- JobId: 0, //当前岗位ID
- systemSet: null, //系统设置
- FormData: {
- JobName: "",
- AuthList: [],
- JobDesc: "",
- JobId: 0,
- JobName: "",
- OrganId: 0,
- RoleList: [],
- },
- rules: {
- JobName: [
- { required: true, message: "请输入岗位名称", trigger: "blur" },
- {
- min: 1,
- max: 16,
- message: "长度在 1 到 16 个字符",
- trigger: "blur",
- },
- ],
- },
- defaultProps: {
- children: "children",
- label: "OrganName",
- },
- listData: [], //上级组织树
- originId: "-1", //所属组织ID
- originData: [], //所属组织详情
- checkedIdList: [], //选中组织树
- AuthList: [], //选中权限(包含规则组)
- RoleList: [], //选中角色组
- checkedAuthKeys: [],
- checkedRoleKeys: [],
- originRoleList: [], //所属组织角色列表
- powerList:[],//角色权限列表
- };
- },
- mixins: [treeData, roleData],
- watch: {
- arrs: {
- handler(arr) {
- arr.forEach((item) => {
- item.name = item.RoleName;
- 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 (item.RoleId == value.RoleId) {
- 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;
- }
- this.JobId = this.$route.query.JobId;
- this.getJobDetails();
- },
- components: {
- Organization,
- Permissiontree,
- Rulesofcompetency,
- rolelist,
- permissionlist,
- },
- 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
- );
- let list = _.cloneDeep(result.returnData.RoleList);
- if(list){
- list.forEach((item, index) => {
- if (item.IsSelected == 1) {
- this.RoleList.push(item);
- }
- });
- }
- if (this.AuthList) {
- this.AuthList.forEach((item) => {
- this.checkedAuthKeys.push(item.AuthId);
- });
- }
- this.checkedIdList.push(result.returnData.OrganId);
- this.getOrganDetails();
- this.getRoleByOrgan(this.originId);
- }
- });
- } catch (error) {
- console.log("GetJobDetails");
- console.log(error);
- }
- },
- //获取所属组织详情
- getOrganDetails() {
- try {
- let data = {
- OrganId: this.originId,
- };
- newOrganall(data).then((result) => {
- if (result.code == 0) {
- this.originData = [];
- this.originData.push(result.returnData);
- }
- });
- } catch (error) {
- console.log("newOrganall");
- console.log(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) {
- try {
- let params = {
- RoleId: data.RoleId,
- };
- RoleAuths(params).then((result) => {
- this.powerList = result.returnData;
- });
- } catch (error) {
- console.log("RoleAuths");
- console.log(error);
- }
- },
- //保存
- saveJob() {
- 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;
- }
- });
- });
- }
- this.FormData.AuthList = this.AuthList;
- this.FormData.RoleList = this.RoleList;
- let data = _.cloneDeep(this.FormData);
- EditJob(data).then((result) => {
- if (result.code == 0) {
- this.$message.success(result.message);
- this.$router.push("/jobs");
- }
- });
- } catch (error) {
- console.log("EditJob");
- console.log(error);
- }
- },
- //查看权限列表明细
- Competen(data) {
- this.$emit("Competen", data);
- },
- //获取指定数据
- 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];
- } else if (data[i].children && data[i].children.length > 0) {
- this.decompose(data[i].children, id);
- }
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .pageBody {
- width: 100%;
- height: calc(100vh - 178px);
- padding: 0 64px;
- padding-top: 32px;
- .topPart {
- box-sizing: border-box;
- width: 100%;
- height: 184px;
- padding: 32px;
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- .title {
- display: flex;
- justify-content: space-between;
- flex-direction: row;
- position: relative;
- .isUsed {
- position: absolute;
- left: 194px;
- top: 6px;
- }
- .tltleLeft {
- font-size: 24px;
- font-weight: bold;
- color: #303133;
- }
- .saveBtn {
- width: 80px;
- height: 40px;
- background: linear-gradient(0deg, #777dba, #6983be);
- border-radius: 6px;
- color: #fff;
- border: none;
- }
- .delBtn {
- width: 80px;
- height: 40px;
- background: #f56c6c;
- border-radius: 6px;
- color: #fff;
- border: none;
- margin-right: 24px;
- }
- }
- .titleContent {
- width: 100%;
- padding-top: 35px;
- box-sizing: border-box;
- .resetPass {
- background: #6e81bc;
- color: #fff;
- margin-top: 4px;
- margin-left: -25px;
- }
- }
- }
- .content {
- width: 100%;
- height: calc(100% - 184px);
- padding-top: 24px;
- box-sizing: border-box;
- .part {
- width: 100%;
- height: 720px;
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- }
- }
- }
- </style>
|