wangting
2024-12-04 ed52d8cb0db78eb8bff70329ac01a38d50d7f672
数据授权
已修改5个文件
309 ■■■■ 文件已修改
Source/plt-web/plt-web-ui/src/components/PLT-basic-component/transfer.vue 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue 257 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/system/role/index.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/views/system/user/index.vue 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/plt-web/plt-web-ui/src/components/PLT-basic-component/transfer.vue
@@ -6,7 +6,7 @@
    :visible.sync="visible"
    append-to-body="true"
    class="avue-dialog"
    width="830px"
    width="800px"
    @close="dialogClose">
    <div style="height: 42px;line-height: 30px;margin-top: -5px;" v-if="topMethodsObj !== {} && topMethodsObj">
      <div>
@@ -27,6 +27,7 @@
        :data="data"
        :filter-method="filterMethod"
        :render-content="renderFunc"
        @change="handleChange"
        :titles="transferTitle"
        filter-placeholder="关键词搜索"
        filterable
@@ -82,8 +83,9 @@
          this.data = [];
          newval.forEach((item) => {
            this.data.push({
              ...item,
              label: item.name,
              key: item.oid,
              key: item.oid
            });
          });
          this.loading = false;
@@ -97,8 +99,8 @@
  methods: {
    dialogClose() {
      this.visible = false;
      this.data = [];
      this.leftRoleData = [];
      //this.data = [];
      //this.rightRoleData = [];
    },
    sendHandler() {
      if (func.isEmptyObject(this.topMethodsObj)) {
@@ -117,6 +119,9 @@
      this.visible = false;
    },
    handleChange(value, direction, movedKeys) {
      console.log(value, direction, movedKeys);
    }
  }
}
</script>
@@ -124,13 +129,23 @@
<style lang="scss" scoped>
/deep/ .el-transfer-panel {
  height: 450px; /* 左右两个穿梭框的高度和宽度 */
  width: 300px;
  width: 322px;
}
/deep/ .el-transfer-panel__list.is-filterable {
  height: 323px; /* 穿梭框列表高度 */
}
/deep/ .el-transfer__buttons .el-button{
  display: block;
  margin: 30px 0;
  padding: 8px 15px;
}
/deep/ .el-transfer__button:first-child{
  transform: translateY(200%);
}
/deep/ .el-transfer__button:nth-child(2){
  transform: translateY(-200%);
}
.valueInfo {
  float: left;
  border: 1px solid #E9E7E7;
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/dataView.vue
@@ -12,23 +12,26 @@
          <fieldset style="width: 48%">
            <legend>&nbsp;主体 </legend>
            <div>
              <avue-crud  ref="mainCrud" :data="mainData" :option="mainOption">
              <avue-crud  ref="mainCrud" :data="mainData" :option="mainOption"
                          @current-row-change="mainCurrentRowHandler"
              >
                <template #type="{ row }">
                  <el-tag v-if="row.type=='用户'" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
                  <el-tag v-else-if="row.type=='角色'" type="info" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
                  <el-tag v-else="row.type=='部门'" type="warning" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
                  <el-tag v-else="row.type=='用户组'" type="warning" :key="row.oid" effect="dark">{{ row.type }}</el-tag>
                </template>
              </avue-crud>
            </div>
          </fieldset>
          <div style="text-align: center;">
            <el-button icon="el-icon-arrow-right" size="mini" @click="rightHandler" style="margin-bottom: 50px;"></el-button><br/>
            <el-button icon="el-icon-arrow-left" size="mini" @click="leftHandler"></el-button>
            <el-button icon="el-icon-arrow-right" type="primary" size="small" @click="rightHandler" style="margin-bottom: 50px;"></el-button><br/>
            <el-button icon="el-icon-arrow-left" type="primary" size="small" @click="leftHandler"></el-button>
          </div>
          <fieldset style="width: 42%">
            <legend>&nbsp;授权主体 </legend>
            <div>
              <avue-crud  ref="authCrud" :data="authData" :option="authOption" :table-loading="tableLoading">
              <avue-crud  ref="authCrud" :data="authData" :option="authOption" :table-loading="tableLoading"
                @current-row-change="authCurrentRowHandler">
              </avue-crud>
            </div>
          </fieldset>
@@ -112,9 +115,32 @@
    </transfer>
    <!-- 选择用户穿梭框   -->
    <transfer ref="roletransfer" :left-role-data="leftRoleData" :right-role-data="rightRoleData"
              :transferTitle="['现有角色','拥有角色']" title="添加角色"
              :transferTitle="['现有角色','拥有角色']" title="分配角色"
              @transferSend="roleSendHandler">
    </transfer>
    <!-- 选择部门对话框    -->
    <el-dialog
      v-dialogDrag
      v-loading="departLoading"
      :visible.sync="departVisible"
      append-to-body="true"
      class="avue-dialog"
      title="选择部门"
      width="50%"
    >
      <avue-crud
        ref="departCrud"
        :data="departData"
        :option="departOption"
        @selection-change="selectDepartChange"
        @row-click="rowClickDeptHandler"
      >
      </avue-crud>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" type="primary" @click="saveDepartHandler">确 定</el-button>
        <el-button size="small" @click="departVisible = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
@@ -123,8 +149,8 @@
import formQueryDialog from "@/views/modelingMenu/queryTemplate/linkTypeQuery/formQueryDialog.vue";
import {queryTemplateListByAttr} from "@/api/queryTemplate/queryDefine";
import {getCriteria} from "@/api/queryTemplate/linkTypeQuery";
import {listUserByUserType} from "@/api/system/user/api";
import {listUserByRoleOid, listUserUnInRoleOid, saveRight} from "@/api/system/role/api";
import {listUserByUserType, gridRoles, departmentQueryController} from "@/api/system/user/api";
import func from "@/util/func";
export default {
  name: "dataView",
@@ -159,7 +185,40 @@
      rightUserData: [], // 选择成员穿梭框右侧初始数据
      leftRoleData: [],  // 选择角色穿梭框左侧初始数据
      rightRoleData: [], // 选择角色穿梭框右侧初始数据
      departCurrenRows: [],
      departOption: {
        ...basicOption,
        addBtn: false,
        rowKey: 'oid',
        rowParentKey: 'parentId',
        selection: true,
        highlightCurrentRow: true,
        stripe: false,
        menu: false,
        refreshBtn: false,
        gridBtn: false,
        header: false,
        column: [
          {
            label: '名称',
            prop: 'name',
            align: 'left'
          },
          {
            label: '编号',
            prop: 'id',
          },
          {
            label: '描述',
            prop: 'description',
          },
        ]
      },
      departData: [],//选择部门数据
      departLoading: false,
      departVisible: false,
      mainData:[],
      mainCurrentRow:{},
      tableLoading: false,
      mainOption: {
        ...basicOption,
@@ -178,7 +237,7 @@
          label: ' 分类',
          prop: 'type',
          sortable: true,
          width:110
          width:90
        },{
          label: '编码',
          prop: 'id'
@@ -188,6 +247,7 @@
          }]
      },
      authData:[],
      authCurrentRow:{},
      authOption:{
        ...basicOption,
        header:false,
@@ -242,7 +302,14 @@
          value: '3',
          disabled:true
        }],
        value: '0'
        value: '0',
        change:function (column,value){
          if(value=='1' || value=='3'){
            this.form.btmName=this.btmNode.attributes.name;
            this.form.levelFlag=0;
            this.form.queryTemplate={};
          }
        }
      }],
      form:{
        btmName:'',
@@ -254,14 +321,14 @@
        "userGroups": "",//显示到授权主体界面,部门名称,多个使用逗号分隔
        "users": "",//显示到授权主体界面,用户名称,多个使用逗号分隔
        "expToSQL": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
        "identifier": "terminology_query",//业务类型(terminology)+下划线(_)+操作区的一般操作的按钮英文名称(query),多个按钮的话是多条数据不是使用逗号分隔
        "identifier": "",//业务类型(terminology)+下划线(_)+操作区的一般操作的按钮英文名称(query),多个按钮的话是多条数据不是使用逗号分隔
        "isGrand": 49, //此处为操作区的一般操作的按钮是否为选择情况,未选中值为48,选中为49,这里是将0和1转为了byte值,所以为48,49
        "lexpToSQL": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
        "lruleText": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
        "lseniorRuleText": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
        "ruleName": "assssss",//规则名称
        "ruleName": "",//规则名称
        "ruleText": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
        "ruleType": "2",//0全部允许,1允许权限,2全部拒绝,3拒绝权限,由于暂时只做全部允许与全部拒绝,所以暂时可以不用管
        "ruleType": "",//0全部允许,1允许权限,2全部拒绝,3拒绝权限,由于暂时只做全部允许与全部拒绝,所以暂时可以不用管
        "seniorRuleText": "",//此处为允许权限或拒绝权限需填充的数据,暂时不做处理,为空字符串即可
      },
      radioForm:0,
@@ -314,24 +381,40 @@
  },
  created() {
    listUserByUserType().then(res => {
      if(typeof res.data == 'string'){
        res.data=eval('('+res.data +')')
      }
      // 组装好穿梭框可用数据
      this.leftUserData = res.data.data.map(item => {
        return {
          ...item,
          name: item.name + `(${item.id})`,
          oid: item.oid
        }
      })
      this.rightUserData = [];
    })
    gridRoles(1,-1).then(res => {
      // 组装好穿梭框可用数据
      this.leftRoleData = res.data.data.map(item => {
        return {
          ...item,
          name: item.name ,
          oid: item.oid
        }
      })
      this.rightRoleData = [];
    })
    departmentQueryController({queryAllLevel: true}).then(res => {
      const data = res.data.treeData;
      this.departData = this.departDtaFormAtter(data);
    }).catch(err => {
      this.$message.error(err);
    })
  },
  watch: {
    selectRow:{
      handler(val) {
      handler(val,oldval) {
        this.authData=[];
        if(val && val.rules){
          this.form=JSON.parse(JSON.stringify(val.rules));
          //this.getTemp(true);
          //this.getTemp(false)
          //构建授权主体数据
@@ -362,6 +445,8 @@
              }
            })
          }
        }else {
          this.form={};
        }
      },
      immediate: true,
@@ -391,45 +476,135 @@
    // 选中用户穿梭框回填
    userSendHandler(row) {
      this.mainData=this.mainData.filter(item=>{
        return item.type!='用户'
      })
      row.forEach((item,index)=>{
        this.authData.push({
          type:'user',
          ...item
        var addItem=this.leftUserData.find(leftitem=>leftitem.oid==item);
        this.mainData.push({
          type:'用户',
          id:addItem.id,
          name:addItem.name.split('(')[0],
          oid:addItem.oid
        })
      })
      this.rightUserData=row;
      this.$refs.usertransfer.visible = false;
    },
    //选择角色
    roleHandler(){
      Promise.all([
        listUserUnInRoleOid({pkRole: this.selectList.oid}),
        listUserByRoleOid({pkRole: this.selectList.oid})
      ]).then(([unInRoleRes, byRoleRes]) => {
        if (unInRoleRes.data.code === 200 && byRoleRes.data.code === 200) {
          const leftData = [...unInRoleRes.data.data, ...byRoleRes.data.data];
          // 组装好穿梭框可用数据
          this.leftRoleData = leftData.map(item => {
            return {
              name: item.name + `(${item.id})`,
              oid: item.oid
            }
          })
          this.rightRoleData = byRoleRes.data.data.map(item => item.oid);
          this.$refs.transfer.visible = true;
        }
      });
      this.$refs.roletransfer.visible = true;
    },
    // 选择角色穿梭框回填
    roleSendHandler(row) {
      this.mainData=this.mainData.filter(item=>{
        return item.type!='角色'
      })
      row.forEach((item,index)=>{
        this.authData.push({
          type:'role',
          ...item
        var addItem=this.leftRoleData.find(leftitem=>leftitem.oid==item);
        this.mainData.push({
          type:'角色',
          id:addItem.name,
          name:addItem.name,
          oid:addItem.oid
        })
      })
      this.rightRoleData=row;
      this.$refs.roletransfer.visible = false;
    },
    //选择用户组
    deptHandler(){
      this.departVisible=true;
    },
    // 选择部门数据转换
    departDtaFormAtter(items) {
      return items.map(item => {
        // 转换当前节点的属性
        const formList = {
          oid: item.oid,
          id: item.attributes.id,
          name: item.attributes.name,
          description: item.attributes.description,
          parentId: item.parentId,
          parentName: item.parentName,
          parentBtmName: item.parentBtmName,
          // 如果children存在且不为空,则递归转换children
          children: item.children && item.children.length > 0 ? this.departDtaFormAtter(item.children) : undefined
        };
        return formList;
      });
    },
    // 选择部门
    selectDepartChange(row) {
      this.departCurrenRows = row;
    },
    // 选择部门 行单选
    rowClickDeptHandler(row) {
      func.rowClickHandler(
        row,
        this.$refs.departCrud,
        this.lastIndex,
        (newIndex) => { this.lastIndex = newIndex; },
        () => { this.departCurrenRows = [row]; }
      );
    },
    // 选择部门 确定
    saveDepartHandler() {
      if (this.departCurrenRows.length==0) {
        this.$message.warning('请选择部门节点!')
        return;
      }
      this.mainData=this.mainData.filter(item=>{
        return item.type!='用户组'
      })
      this.departCurrenRows.forEach((addItem,index)=>{
        this.mainData.push({
          type:'用户组',
          id:addItem.id,
          name:addItem.name,
          oid:addItem.oid
        })
      })
      this.departVisible = false;
    },
    //主体列表行点击
    mainCurrentRowHandler(row){
      this.mainCurrentRow=row;
    },
    //授权主体列表行点击
    authCurrentRowHandler(row){
      this.authCurrentRow=row;
    },
    rightHandler() {
      if(func.isEmptyObject(this.mainCurrentRow)){
        this.$message.warning('请选择用户、用户组、角色信息!')
        return;
      }
      let name='{' + this.mainCurrentRow.id + ', ' + this.mainCurrentRow.name + ', ';
      if (this.mainCurrentRow.type == '用户') {
        name+='user}';
      } else if (this.mainCurrentRow.type == '角色') {
        name+='role}';
      } else if (this.mainCurrentRow.type == '用户组') {
        name+='userGroup}';
      }
      let canAdd = !this.authData.some(item => {
        return item.name == name
      })
      if(canAdd) {
        this.authData.push({
          name: name
        })
        this.$refs.mainCrud.setCurrentRow();
        this.mainCurrentRow={}
      }else {
        this.$message.warning('授权主体信息选择重复!')
      }
    },
    leftHandler() {
      this.authData = this.authData.filter(item => {
        return item.name != this.authCurrentRow.name
      })
    },
    initFormData() {
      let formData = {
Source/plt-web/plt-web-ui/src/views/authority/ui/dataAuthorization/index.vue
@@ -47,7 +47,7 @@
          width="70%"
          @close="addDialogClose">
            <div>
              <data-view ref="editView" key="editView" :btmNode="nodeRow" :selectRow="selectRow" :actionMap="actionMap" :readOnly="false" :height="clientHeight-340"></data-view>
              <data-view ref="editView" key="editView" :btmNode="nodeRow" :selectRow="title === 'add'?{}:selectRow" :actionMap="actionMap" :readOnly="false" :height="clientHeight-260"></data-view>
            </div>
            <span slot="footer" class="dialog-footer">
               <el-button size="small" type="primary" @click="addDialogSavaHandler">确 定</el-button>
@@ -170,9 +170,9 @@
    },
    getTableList() {
      getData(this.nodeRow.attributes.name).then(res => {
        /*if(typeof res.data == 'string'){
        if(typeof res.data == 'string'){
          res.data=eval('('+res.data +')')
        }*/
        }
        if(res.data.obj.tableHeader){
          this.option.column=[ {
            label: '规则名称',
@@ -255,8 +255,8 @@
    },
    //修改
    editHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
        this.$message.error('请至少选择一条数据');
      if (func.isEmptyObject(this.selectRow)) {
        this.$message.error('请选择一条数据');
        return;
      }
      this.title = 'edit';
@@ -278,7 +278,7 @@
    },
    //删除
    delHandler(){
      if (func.isEmptyObject(this.nodeRow)) {
      if (func.isEmptyObject(this.selectRow)) {
        this.$message.error('请选择数据');
        return;
      }
Source/plt-web/plt-web-ui/src/views/system/role/index.vue
@@ -182,7 +182,7 @@
        this.$refs.roleCrud,
        this.lastIndex,
        (newIndex) => { this.lastIndex = newIndex; },
        () => { this.selectList = []; }
        () => { this.selectList = [row]; }
      );
    },
@@ -283,6 +283,8 @@
        listUserUnInRoleOid({pkRole: this.selectList[0].oid}),
        listUserByRoleOid({pkRole: this.selectList[0].oid})
      ]).then(([unInRoleRes, byRoleRes]) => {
        this.leftRoleData=[];
        this.rightRoleData=[];
        if (unInRoleRes.data.code === 200 && byRoleRes.data.code === 200) {
          const leftData = [...unInRoleRes.data.data, ...byRoleRes.data.data];
          // 组装好穿梭框可用数据
Source/plt-web/plt-web-ui/src/views/system/user/index.vue
@@ -61,12 +61,11 @@
      class="avue-dialog"
      style="margin-top: -15vh !important;"
      title="设置密码策略"
      width="30%"
      width="500px"
    >
      <div class="password-strategy-container">
        <div><i class="el-icon-setting"/>设置密码策略:</div>
        <el-select v-model="pwdValue" placeholder="请选择密码策略">
        <div style="width:115px;"><i class="el-icon-setting"/>设置密码策略:</div>
        <el-select v-model="pwdValue" placeholder="请选择密码策略" style="width: 330px;">
          <el-option v-for="(item,index) in pwdList" :key="index" :label="item.name" :value="item.id"></el-option>
        </el-select>
      </div>
@@ -549,7 +548,7 @@
<style lang="scss" scoped>
.password-strategy-container {
  padding-left: 20px;
  margin-bottom: 20px;
  display: flex;
  //justify-content: center;
  align-items: center;