123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <!--
- * @Author: your name
- * @Date: 2021-11-29 11:26:07
- * @LastEditTime: 2022-03-15 11:50:58
- * @LastEditors: your name
- * @Description:新增组织
- * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityPower.vue
- -->
- <template>
- <div class="authorityPower">
- <!--新增组织-->
- <div class="addApp-form">
- <div class="addApp-form-title flex">
- <div class="title">新增组织</div>
- <div v-is="['organ_btn_save']" class="btn">
- <el-button @click="saveBtn('form')" type="primary">保存</el-button>
- </div>
- </div>
- <div class="addApp-form-content dialog-public-background">
- <el-form :inline="true" ref="form" :rules="rules" class="form" :model="form">
- <el-form-item prop="name" label="组织名称">
- <el-input placeholder="请输入组织名称" v-model="form.name"></el-input>
- </el-form-item>
- <el-form-item prop="id" label="组织类型">
- <el-select v-model="form.id" placeholder="请选择">
- <el-option label="集团内" :value="1"></el-option>
- <el-option label="集团外" :value="0"></el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="app" label="描述">
- <el-input style="width: 835px" placeholder="请输入描述" v-model="form.app"></el-input>
- </el-form-item>
- <div class="top24">
- <el-form-item prop="oneCode" label="1级编码">
- <el-input placeholder="最多输入2个字符" v-model="form.oneCode"></el-input>
- </el-form-item>
- <el-form-item prop="twoCode" class="twoCode" label="2级编码">
- <el-input placeholder="最多输入3个字符" style="width: 202px" v-model="form.twoCode"></el-input>
- </el-form-item>
- <el-form-item prop="threeCode" label="3级编码">
- <el-input placeholder="最多输入8个字符" v-model="form.threeCode"></el-input>
- </el-form-item>
- <el-form-item prop="fourCode" label="4级编码">
- <el-input placeholder="最多输入2个字符" v-model="form.fourCode"></el-input>
- </el-form-item>
- <el-form-item prop="fiveCode" label="5级编码">
- <el-input placeholder="最多输入2个字符" v-model="form.fiveCode"></el-input>
- </el-form-item>
- </div>
- </el-form>
- </div>
- </div>
- <div class="power-content flex-wrap">
- <div class="flex1 part">
- <Organization :defaultProps="defaultProps" :data="data" nodekey="OrganId" :checkedKeys="checkedKeys" title="上级组织" />
- </div>
- </div>
- </div>
- </template>
- <script>
- import Permissiontree from "@/components/permissiontree";
- import Rulesofcompetency from "@/components/rulesofcompetency";
- import Organization from "@/components/organization";
- import Permissionlist from "@/components/permissionlist";
- import Rolelist from "@/components/rolelist";
- import treeData from "../minixs/treeData";
- import roleData from "../minixs/roleData";
- import { mapGetters } from "vuex";
- import { RoleAuths } from "@/api/apiAuthority";
- import { newOrgan } from "@/api/postInterface";
- import { lengthValidator } from '@/utils/validate'
- export default {
- name: "AuthorityPower",
- mixins: [treeData, roleData],
- components: {
- Rulesofcompetency,
- Organization,
- Permissiontree,
- Permissionlist,
- Rolelist,
- },
- data () {
- return {
- Status: null,
- AppId: null,
- form: {
- //应用表单
- name: "",
- id: "",
- app: "",
- oneCode: "",
- twoCode: "",
- threeCode: "",
- fourCode: "",
- fiveCode: ""
- },
- title: "角色",
- rules: {
- //表单验证
- name: [
- { required: true, message: "请输入组织名称", trigger: "blur" },
- { validator: lengthValidator, max: 32, message: '最多输入32个字符', trigger: ['change', 'blur'] }
- ],
- id: [{ required: true, message: "请输入标识符", trigger: "blur" }],
- app: [{ validator: lengthValidator, max: 128, message: '最多输入128个字符', trigger: ['change', 'blur'] }],
- oneCode: [{ validator: lengthValidator, max: 2, message: '最多输入2个字符', trigger: ['change', 'blur'] }],
- twoCode: [{ validator: lengthValidator, max: 3, message: '最多输入3个字符', trigger: ['change', 'blur'] }],
- threeCode: [{ validator: lengthValidator, max: 8, message: '最多输入8个字符', trigger: ['change', 'blur'] }],
- fourCode: [{ validator: lengthValidator, max: 2, message: '最多输入2个字符', trigger: ['change', 'blur'] }],
- fiveCode: [{ validator: lengthValidator, max: 2, message: '最多输入2个字符', trigger: ['change', 'blur'] }],
- },
- defaultProps: {
- children: "children",
- label: "OrganName",
- },
- checkedKeys: [], //上级组织选中
- RoleList: [],
- checkedBoxs: [],
- arrs: [],
- queryType: null, //权限树类型
- openRole: null,
- OpenGroup: null,
- dataObj: {}, //上级权限指定树数据
- data: [], //上级权限
- roleList: [], //角色
- checkRoles: [], //选中的角色
- checkTrees: [], //上级权限选中树数据
- rulesObj: {}, //权限规则数据
- };
- },
- computed: {
- ...mapGetters(["systemSet"]),
- },
- watch: {
- //监听上级组织数据
- dataList: {
- handler (val) {
- const arr = [val];
- this.decompose(arr, this.AppId);
- this.data = [this.dataObj];
- this.checkedKeys = [this.AppId];
- },
- deep: true,
- },
- },
- created () {
- const { OrganId, Status } = this.$route.query;
- const { OpenRole, OpenGroup } =
- typeof this.systemSet === "string"
- ? JSON.parse(this.systemSet)
- : this.systemSet; //1是请求角色 0是请求用户
- this.Status = Status;
- this.AppId = OrganId;
- this.openRole = OpenRole;
- this.OpenGroup = OpenGroup;
- this.getOrganTree();
- },
- methods: {
- //获取指定数据
- decompose (data, id) {
- for (let i = 0; i < data.length; i++) {
- if (data[i].OrganId == id) {
- if (data[i].children && data[i].children.length) {
- delete data[i].children;
- }
- this.dataObj = data[i];
- } else if (data[i].children && data[i].children.length > 0) {
- this.decompose(data[i].children, id);
- }
- }
- },
- //权限树点击
- nodeClick (obj) {
- const arr = this.$store.getters.authArrs;
- arr.push(obj);
- this.$store.dispatch("auth/changeAuthArrs", arr);
- },
- //角色点击回调
- checkClick (item) {
- this.roleAuths(item.RoleId);
- },
- //岗位点击回调
- checkGroup (item) {
- this.groupAuths(item.GroupId);
- },
- //根据角色查看权限列表
- async roleAuths (id) {
- try {
- let params = {
- RoleId: id,
- };
- const res = await RoleAuths(params);
- if (res.code === 0) {
- this.RoleList = res.returnData;
- } else {
- this.$message.error(res.message);
- }
- } catch (error) {
- console.log("出错了", error);
- }
- },
- //角色选取
- checkChange (arr) {
- const datas = [];
- for (let i = 0; i < arr.length; i++) {
- datas.push(this.arrs[arr[i]]);
- }
- datas.forEach((item) => {
- item.IsSelected = "1";
- });
- this.checkRoles = datas;
- },
- //获取权限规则
- getData (obj) {
- this.rulesObj = obj;
- },
- //保存
- saveBtn (formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- this.saveOrgan();
- } else {
- console.log("error submit!!");
- return false;
- }
- });
- },
- //组织新增保存
- async saveOrgan () {
- try {
- const datas = [];
- this.checkTrees.forEach((item) => {
- datas.push(item.AuthList);
- });
- const res = await newOrgan({
- OrganName: this.form.name,
- OrganType: this.form.id,
- OrganDesc: this.form.app,
- OrganUpid: this.AppId,
- RoleList: this.openRole ? this.checkRoles : [],
- AuthList: this.openRole ? [] : datas,
- GroupList: this.OpenGroup ? this.checkRoles : [],
- L1: this.form.oneCode,
- L2: this.form.twoCode,
- L3: this.form.threeCode,
- L4: this.form.fourCode,
- L5: this.form.fiveCode
- });
- if (res.code === 0) {
- this.$message.success(res.message);
- this.$store.dispatch("tagsView/delView", this.$route);
- this.$router.push("/organization");
- } else {
- this.$message.error(res.message);
- }
- } catch (error) {
- console.log("出错了", error);
- }
- },
- },
- };
- </script>
- <style lang="scss" scoped>
- .authorityPower {
- padding: 0 64px;
- padding-top: 32px;
- }
- .addApp-form {
- background: #ffffff;
- box-shadow: 0px 6px 7px 0px rgba(0, 0, 0, 0.06);
- border-radius: 16px;
- padding: 32px 32px 40px 32px;
- .title {
- font-size: 24px;
- font-family: Microsoft YaHei;
- font-weight: bold;
- color: #303133;
- .isqy {
- span {
- font-weight: 400;
- font-size: 14px;
- margin: 0 28px 0 42px;
- }
- }
- }
- .addApp-form-content {
- margin-top: 40px;
- ::v-deep .form {
- .el-form-item {
- margin-bottom: 0;
- margin-right: 40px;
- }
- .el-input__inner {
- height: 32px;
- line-height: 32px;
- min-width: 184px;
- }
- .content {
- .el-form-item__content {
- flex: 1;
- }
- .el-form-item__label {
- margin-left: 27px;
- }
- }
- .top24 {
- margin-top: 24px;
- .el-form-item__label {
- margin-left: 16px;
- }
- }
- }
- }
- }
- .power-content {
- margin-top: 24px;
- // min-height: 58vh;
- .part {
- height: 704px;
- }
- }
- </style>
|