index.vue 10.2 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">
            <el-form-item>
              <btn nativeType="cx" @click="handleAdd">添加人员</btn>
            </el-form-item>
          </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>
    <edit-dialog ref="dialogForm" />
  </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";
export default {
  name: "menus",
  mixins: [tableMixin],
  components: {
    EditDialog,
  },
  data() {
    return {
      taskData: null,
        keyList: [],
      form: {
        job_name: "",
        currentPage: 1,
      },
      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>
                );
              },
            },
            {
              label: "操作",
              width: 380,
              render: (h, scope) => {
                return (
                  <div>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-edit"
                      onClick={() => {
                        this.updateLock(scope.row, scope.row.name);
                      }}
                    >
                      解锁
                    </el-button>
                    <el-button
                      type="text"
                      size="mini"
                      icon="el-icon-video-pause"
                      onClick={() => {
                        this.resetPassword(scope.row.id);
                      }}
                    >
                      重置
                    </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.handleDelete(scope.row.id, scope.row.name);
                      }}
                    >
                      删除
                    </el-button>
                  </div>
                );
              },
            },
          ]),
        data: [],
      },
      pageData: {
        total: 5,
        pageSize: 15,
        current: 1,
      },
    };
  },
  methods: {
    // 添加索引
    // addIndexes (data = this.tableData.data, isAdd = true) {
    //   data.forEach((item, index) => {
    //     if (index == 0) {
    //       item.codeShow = true;
    //       item.nameShow = false;
    //       item.normcodeShow = false;
    //       item.normnameShow = false;
    //     } else {
    //       item.codeShow = false;
    //       item.nameShow = false;
    //       item.normcodeShow = false;
    //       item.normnameShow = false;
    //     }
    //     if (isAdd) {
    //       item.index = index + 1;
    //     }
    //     if (item.children) {
    //       this.addIndexes(item.children, false);
    //     }
    //   });
    // },
    handleAdd() {
      this.taskData = null;
      this.$refs.dialogForm.add();
      this.$refs.dialogForm.title = "添加";
    },
    featchData() {

      this.tableData.data = [
    {
        "dictid": "51b9f487861671f77782c5a23b5fe52e",
        "children": null,
        "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
        "PARENTID": "ouyds",
        "DCODE": "1223",
        "DNAME": "小红",
        "SORT": null,
        "index": 1,
    },
    {
        "dictid": "2291d9e298274c1ea1f40df63fbcff47",
        "children": null,
        "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
        "PARENTID": "wer",
        "DCODE": "124334",
        "DNAME": "小李",
        "SORT": null,
        "index": 2,
    },
    {
        "dictid": "e6a5aeb8957b8029fa31586fb30dd5b8",
        "children": null,
        "TYPEID": "1F460F6E5E354C1AA3C470434D7A67DF",
        "PARENTID": "underf",
        "DCODE": "2344",
        "DNAME": "小田",
        "SORT": null,
        "index": 13,
    }
]
this.tableData.data=judgeSort(this.tableData.data)
},

    // 更新用户解锁状态
    updateLock(id, name) {
      this.$confirm(
        `<div  class="customer-message-wrapper">
              <h5 class="title">确定要更新用户解锁状态吗</h5>
               <p class="result">执行后,数据将
                 <span >无法恢复</span>
                </p>
        </div>`,
        "执行确认",
        {
          dangerouslyUseHTMLString: true,
          customClass: "customer-delete",
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          // updateLock(id).then((res) => {
          //   if (res.status === 1) {
          //     this.$message.success({ message: res.message, showClose: true })
          //     this.getTableList()
          //   } else {
          //     this.$message.error({ message: res.message, showClose: true })
          //   }
          // })
        })
        .catch(() => {});
    },
    // 上移下移
    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;
    },
    // 重置用户密码
    resetPassword(data) {
      const ids = [];
      if (data instanceof Array) {
        data.forEach((item) => {
          ids.push(item.id);
        });
      } else {
        ids.push(data);
      }
      if (ids.length === 0) {
        this.$message({
          message: "请选择需要重置密码的用户!",
          showClose: true,
        });
        return;
      }
      this.$confirm(
        `<div  class="customer-message-wrapper">
              <h5 class="title">确定要重置密码吗</h5>
               <p class="result">执行后,数据将
                 <span >无法恢复</span>
                </p>
        </div>`,
        "执行确认",
        {
          dangerouslyUseHTMLString: true,
          customClass: "customer-delete",
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          // resetPassword(ids).then((res) => {
          //   if (res.status === 1) {
          //     this.$message.success({ message: res.message, showClose: true })
          //     this.getTableList()
          //   } else {
          //     this.$message.error({ message: res.message, showClose: true })
          //   }
          // })
        })
        .catch(() => {});
    },
    // 修改人员信息
    handleEdit(row) {
      this.$refs.dialogForm.edit(row);
      this.$refs.dialogForm.title = "修改";
    },
    // 删除
    handleDelete(id, content) {
      this.$confirm("此操将进行删除操作, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // deleteAction(`${api.users}/${id}`).then((res) => {
          //   if (res.status === 1) {
          //     this.$message.success({ message: res.message, showClose: true })
          //   } else {
          //     this.$message.error({ message: res.message, showClose: true })
          //   }
          //   this.getTableList()
          // })
        })
        .catch(() => {});
    },
  },
};
</script>
<style scoped lang="scss">
@import "~@/styles/mixin.scss";
@import "~@/styles/public.scss";
.btnColRight {
  margin-top: 20px;
}
</style>