index.vue 8.75 KB
<template>
  <div class="timedTask from-clues">
    <div class="from-clues-header">
      <el-form ref="ruleForm" :model="form" label-width="100px">
        <el-form-item>
          <Breadcrumb />
        </el-form-item>
        <el-row class="mb-5">
          <el-col :span="2" class="btnColRight">
            <btn nativeType="cx" @click="handleAdd">增加角色</btn>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <div class="from-clues-content">
      <lb-table
        :page-size="pageData.size"
        :current-page.sync="pageData.current"
        :total="pageData.total"
        @size-change="handleSizeChange"
        @p-current-change="handleCurrentChange"
        :column="tableData.columns"
        :data="listdata"
        :expand-row-keys="keyList"
        row-key="id"
      >
      </lb-table>
    </div>
    <EditDialog ref="addEditDialog" />
    <Roleslistdiglog ref="rolesForm" />
  </div>
</template>
<script>
import {
  getUuid,
  judgeSort,
  realMove,
  findParents,
  removeTreeListItem,
} from "@/utils/operation";
import { getRolesById, getUserRoles } from "@/api/Rolemanagement";
import data from "./data";
import sjsbTask from "@/api/sjsbTask.js";
import { api, getAction } from "@/api/manageApi";
import tableMixin from "@/mixins/tableMixin.js";
import EditDialog from "./edit-dialog.vue";
import Roleslistdiglog from "./roleslistdiglog.vue";
export default {
  name: "menus",
  mixins: [tableMixin],
  components: {
    EditDialog,
    Roleslistdiglog,
  },
  data() {
    return {
      personlist: null,
      waitMemberList: [],
      keyList: [],
      listdata: [],
      form: {
        job_name: "",
        currentPage: 1,
      },
      // 当前所选角色id
      roleId: "",
      title: "",
      queryParam: {},
      selectType: "0",
      queryName: "",
      organizationId: "", // 组织机构ID
      departmentId: "", // 部门ID
      departmentList: [], // 部门列表
      levelList: [], // 职务级别
      sexList: [],
      typeOptions: [
        {
          value: "0",
          label: "姓名",
        },
        {
          value: "1",
          label: "工号",
        },
        {
          value: "2",
          label: "部门",
        },
        {
          value: "3",
          label: "机构",
        },
      ],

      selectionList: [],
      tableData: {
        columns: [
          {
            label: "序号",
            type: "index",
            width: "50",
            index: this.indexMethod,
          },
        ]
          .concat(data.columns())
          .concat([
            {
              label: "排序",
              width: 380,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      disabled={scope.row.isTop}
                      onClick={() => {
                        this.moveUpward(scope.$index, scope.row);
                      }}
                    >
                      上移
                    </el-button>
                    <el-button
                      type="text"
                      disabled={scope.row.isBottom}
                      onClick={() => {
                        this.moveDown(scope.$index, scope.row);
                      }}
                    >
                      下移
                    </el-button>
                  </div>
                );
              },
            },
          ])
          .concat([
            {
              label: "操作",
              width: 380,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-video-pause"
                      onClick={() => {
                        this.getUserList(scope.row);
                      }}
                    >
                      人员
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-edit"
                      onClick={() => {
                        this.handleEdit(scope.row);
                      }}
                    >
                      修改
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-delete"
                      style="color:#F56C6C"
                      onClick={() => {
                        this.handleDel(scope.row);
                      }}
                    >
                      删除
                    </el-button>
                  </div>
                );
              },
            },
          ]),
        data: [],
      },
      pageData: {
        total: 5,
        pageSize: 15,
        current: 1,
      },
    };
  },
  created() {
    this.getTableData();
  },
  mounted() {},
  methods: {
    // 获取角色列表
    getTableData() {
      getRolesById()
        .then((res) => {
          this.listdata = res.content;

          this.listdata = judgeSort(this.listdata);
        })
        .catch((e) => console.error(e));
    },

    getUserList(row) {
       const params = {};
      const queryOptions = {
        conditionGroup: {
          conditions: [
            {
              property: "organizationId",
              value: row.organizationId,
              operator: "EQ",
            },
            {
              property: "departmentId",
              value: row.departmentId,
              operator: "EQ",
            },
          ],
          queryRelation: "AND",
        },
        orderBys: [{ property: "sort", direction: "desc" }],
      };
      params.queryOptions = JSON.stringify(queryOptions);
      getUserRoles(row.id).then((res) => {
        if (res.status === 1) {
          this.personlist = res.content;
             getAction(api.users, params).then((res) => {
        if (res.status === 1) {
          this.waitMemberList = res.content;
          if (this.personlist) {
            this.waitMemberList.forEach((item, i) => {
              this.personlist.forEach((val) => {
                if (item.id === val.id) {
                  this.waitMemberList[i].selectStatus = 0;
                }
              });
            });
          }

          this.$refs.rolesForm.adds(this.waitMemberList,row.id);
        } else {
          this.$message.error({ message: res.message, showClose: true });
        }
      });
          this.$refs.rolesForm.title = "人员配置";
        } else this.$message.error({ message: res.message, showClose: true });
      });


    },
    // 新增角色
    handleAdd() {
      // this.$refs.addEditDialog.roleId = value.id
      // this.roleSort = value.sort ? value.sort : 0

      this.$refs.addEditDialog.showAddEditDialog = true;
      this.$refs.addEditDialog.dialogTitle = "新增";
    },
    //  修改角色
    handleEdit(row) {
      this.$refs.addEditDialog.roleId = row.id;
      this.roleSort = row.sort ? row.sort : 0;
      if (row.id) {
        this.$refs.addEditDialog.dialogForm.roleName = row.name;
        this.$refs.addEditDialog.dialogForm.roleType = row.type;
        this.$refs.addEditDialog.dialogForm.roleTextArea = row.description;
      }
      this.$refs.addEditDialog.showAddEditDialog = true;
      this.$refs.addEditDialog.dialogTitle = "修改";
    },
    // 上移下移
    moveUpward(index, row) {
      realMove(row.id, "UP", this.listdata);
      this.key++;
      let id = findParents(this.listdata, row.id);
      this.keyList = id;
    },
    moveDown(index, row) {
      realMove(row.id, "DOWN", this.listdata);
      this.key++;
      let id = findParents(this.listdata, row.id);
      this.keyList = id;
    },

    // 删除
    handleDel(row) {
      this.$confirm("此操将进行删除操作, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          sjsbTask
            .sjsbTaskRemove(row.id)
            .then((res) => {
              if ((res.code = 200)) {
                this.$message({
                  type: "success",
                  message: res.message,
                });
                // this.featchData();
              }
            })
            .catch((error) => {
              this.$alert(error, "提示", {
                confirmButtonText: "确定",
                type: "error",
              });
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },

  },
};
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
.btnColRight {
  margin-left: -30px;
  margin-top: 20px;
}
</style>