index.vue 8.84 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="tableData.data"
        :expand-row-keys="keyList"
        row-key="dictid"
      >
      </lb-table>
    </div>
    <EditDialog ref="addEditDialog" />
    <Roleslistdiglog ref="rolesForm" />
  </div>
</template>
<script>
import {
  getUuid,
  judgeSort,
  realMove,
  findParents,
  removeTreeListItem,
} from "@/utils/operation";
import data from "./data";
import sjsbTask from "@/api/sjsbTask.js";
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 {
      taskData: null,
      keyList: [],
      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.personnel(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.featchData();
  },
  methods: {
    // 新增角色
    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 = "修改";
    },
    featchData() {
      this.tableData.data = [
        {
          id: "2176e915-fdb4-414a-b8d6-6cf63171cffc",
          isTop: true,
          isBottom: false,
          dictid: "51b9f487861671f77782c5a23b5fe52esasq",
          createdAt: "2022-10-31T07:08:29.293+0000",
          updatedAt: "2022-10-31T07:08:29.293+0000",
          createdBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          updatedBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          sort: 29,
          name: "材料管理员",
          type: "信息员",
          category: 2,
          description: "1二点三s",
          _X_ROW_KEY: "row_365",
        },
        {
          id: "2176e915-fdb4-414a-b8d6-6cf63171c222ffc",
          isTop: false,
          isBottom: false,
          dictid: "51b9f487861671f77782c5a23b5fe52e11",
          createdAt: "2022-10-31T07:08:29.293+0000",
          updatedAt: "2022-10-31T07:08:29.293+0000",
          createdBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          updatedBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          sort: 29,
          name: "人事管理员",
          type: "管理",
          category: 2,
          description: "管qdq",
          _X_ROW_KEY: "row_365",
        },
        {
          id: "2176e915-fdb4-414a-b8324d6-6cf63171cffc",
          isTop: false,
          isBottom: true,
          dictid: "51b9f487861671f72131ddd7782c5a23b5fe52e12ewsd",
          createdAt: "2022-10-31T07:08:29.293+0000",
          updatedAt: "2022-10-31T07:08:29.293+0000",
          createdBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          updatedBy: "3127e455-43ba-45ff-9326-0e02ef89485e",
          sort: 29,
          name: "管理员",
          type: "材料",
          category: 2,
          description: "sadq",
          _X_ROW_KEY: "row_365",
        },
      ];
    },
    // 上移下移
    moveUpward(index, row) {
      realMove(row.dictid, "UP", this.tableData.data);
      this.key++;
      let id = findParents(this.tableData.data, row.dictid);
      this.keyList = id;
    },
    moveDown(index, row) {
      realMove(row.dictid, "DOWN", this.tableData.data);
      this.key++;
      let id = findParents(this.tableData.data, row.dictid);
      this.keyList = id;
    },
    //  人员配置弹框
    personnel() {
      this.$refs.rolesForm.adds();
      this.$refs.rolesForm.title = "人员配置";
    },
    // 删除
    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>