Administrator
2021-07-13 a6810bf6a2db02fa855e7e18a8f97bb354e892e5
1.保安员管理修改 2.组织机构修改
3 files modified
717 ■■■■ changed files
src/views/securityGuard/data.js 23 ●●●● patch | view | raw | blame | history
src/views/securityGuard/securityGuard.vue 68 ●●●●● patch | view | raw | blame | history
src/views/system/dept.vue 626 ●●●● patch | view | raw | blame | history
src/views/securityGuard/data.js
@@ -414,7 +414,7 @@
export var securityFormPageColumn = [{
        label: "用户姓名",
        label: "姓名",
        prop: "realName",
        search: true,
        searchSpan: 4,
@@ -491,12 +491,12 @@
        display: false
    },
    {
        label: "组织机构名称",
        label: "保安公司名称",
        searchLabelWidth: "110",
        // prop: "deptName",
        prop: "deptId",
        type: "tree",
        dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
        dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
        props: {
            label: "title",
            value: "id",
@@ -508,10 +508,21 @@
        width: 260
    },
    {
        label: "岗位",
        prop: "postName",
        label: "是否持证",
        prop: "hold",
        slot: true,
        display: false
        display: false,
        dicUrl: "/api/blade-system/dict-biz/dictionary?code=equipage",
        props: {
            label: "dictValue",
            value: "dictKey"
        },
        type: "select",
        rules: [{
            required: true,
            message: "请选择",
            trigger: "blur"
        }],
    },
    // {
    //     label: "入职时间",
src/views/securityGuard/securityGuard.vue
@@ -227,7 +227,7 @@
  saveOrUpdateUserPractitionersInfo,
} from "@/api/system/user";
import { getList } from "@/api/securityGuard/securityGuard";
import { getDeptTree, getDeptLazyTree } from "@/api/system/dept";
import { getDeptLazyTree } from "@/api/system/dept";
import { getRoleTree } from "@/api/system/role";
import { getPostList } from "@/api/system/post";
import { mapGetters } from "vuex";
@@ -269,6 +269,8 @@
        currentPage: 1,
        total: 0,
      },
      roleId: "1412226235153731586",
      deptId: "1413470343230877697",
      platformPage: {
        pageSize: 10,
        currentPage: 1,
@@ -335,11 +337,12 @@
            icon: "el-icon-user-solid",
            column: [
              {
                label: "所属组织机构",
                label: "所属保安公司",
                prop: "deptId",
                type: "tree",
                // dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
                dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
                dicUrl:
                  "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
                // dicUrl: "/api/blade-system/dept/lazy-tree?parentId=0",
                props: {
                  label: "title",
                  value: "id",
@@ -349,7 +352,7 @@
                rules: [
                  {
                    required: true,
                    message: "请选择组织机构",
                    message: "请选择保安公司",
                    trigger: "blur",
                  },
                ],
@@ -387,12 +390,12 @@
                ],
              },
              {
                label: "用户姓名",
                label: "姓名",
                prop: "realName",
                rules: [
                  {
                    required: true,
                    message: "请输入用户姓名",
                    message: "请输入姓名",
                    trigger: "blur",
                  },
                  {
@@ -403,11 +406,11 @@
                ],
              },
              {
                label: "用户编号",
                label: "编号",
                prop: "code",
              },
              {
                label: "用户昵称",
                label: "昵称",
                prop: "name",
              },
              {
@@ -464,6 +467,23 @@
                    required: false,
                    message: "请选择所属岗位",
                    trigger: "click",
                  },
                ],
              },
              {
                label: "是否持证",
                prop: "hold",
                dicUrl: "/api/blade-system/dict-biz/dictionary?code=equipage",
                props: {
                  label: "dictValue",
                  value: "dictKey",
                },
                type: "select",
                rules: [
                  {
                    required: true,
                    message: "请选择",
                    trigger: "blur",
                  },
                ],
              },
@@ -541,7 +561,7 @@
                valueFormat: "yyyy-MM-dd",
              },
              {
                label: "用户性别",
                label: "性别",
                prop: "sex",
                type: "select",
                slot: true,
@@ -561,7 +581,7 @@
                ],
              },
              {
                label: "用户生日",
                label: "生日",
                type: "date",
                prop: "birthday",
              },
@@ -677,19 +697,19 @@
            display: false,
          },
          {
            label: "用户姓名",
            label: "姓名",
            prop: "realName",
            search: true,
            display: false,
          },
          {
            label: "用户平台",
            label: "平台",
            prop: "userTypeName",
            slot: true,
            display: false,
          },
          {
            label: "用户平台",
            label: "平台",
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=user_type",
            props: {
@@ -704,13 +724,13 @@
            rules: [
              {
                required: true,
                message: "请选择用户平台",
                message: "请选择平台",
                trigger: "blur",
              },
            ],
          },
          {
            label: "用户拓展",
            label: "拓展",
            prop: "userExt",
            type: "textarea",
            minRows: 8,
@@ -841,10 +861,10 @@
        const column = this.findObject(this.option.group, "roleId");
        column.dicData = res.data.data;
      });
      getDeptTree(tenantId).then((res) => {
        const column = this.findObject(this.option.group, "deptId");
        column.dicData = res.data.data;
      });
      // getDeptTree(tenantId).then((res) => {
      //   const column = this.findObject(this.option.group, "deptId");
      //   column.dicData = res.data.data;
      // });
      getPostList(tenantId).then((res) => {
        const column = this.findObject(this.option.group, "postId");
        column.dicData = res.data.data;
@@ -970,7 +990,7 @@
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择用户登记离职?", {
      this.$confirm("确定将选择保安登记离职?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
@@ -1010,7 +1030,7 @@
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择用户注销?", {
      this.$confirm("确定将选择保安注销?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
@@ -1075,7 +1095,7 @@
      done();
    },
    handleExport() {
      this.$confirm("是否导出用户数据?", "提示", {
      this.$confirm("是否导出保安数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
@@ -1143,6 +1163,8 @@
      };
      values = {
        ...params,
        deptId: this.deptId,
        roleId: this.roleId,
        ...this.query,
      };
      this.loading = true;
src/views/system/dept.vue
@@ -1,31 +1,35 @@
<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               ref="crud"
               v-model="form"
               :permission="permissionList"
               :before-open="beforeOpen"
               :before-close="beforeClose"
               @row-del="rowDel"
               @row-update="rowUpdate"
               @row-save="rowSave"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad"
               @tree-load="treeLoad">
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      ref="crud"
      v-model="form"
      :permission="permissionList"
      :before-open="beforeOpen"
      :before-close="beforeClose"
      @row-del="rowDel"
      @row-update="rowUpdate"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
      @tree-load="treeLoad"
    >
      <template slot="menuLeft">
        <el-button type="danger"
                   size="small"
                   icon="el-icon-delete"
                   v-if="permission.dept_delete"
                   plain
                   @click="handleDelete">删 除
        <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          v-if="permission.dept_delete"
          plain
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
@@ -33,199 +37,214 @@
          type="text"
          icon="el-icon-circle-plus-outline"
          size="small"
          @click.stop="handleAdd(scope.row,scope.index)"
          @click.stop="handleAdd(scope.row, scope.index)"
          v-if="userInfo.role_name.includes('admin')"
        >新增子项
          >新增子项
        </el-button>
      </template>
      <template slot-scope="{row}"
                slot="deptCategory">
        <el-tag>{{row.deptCategoryName}}</el-tag>
      <template slot-scope="{ row }" slot="deptCategory">
        <el-tag>{{ row.deptCategoryName }}</el-tag>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
  import {
    getLazyList,
    remove,
    update,
    add,
    getDept,
    getDeptTree
  } from "@/api/system/dept";
  import {mapGetters} from "vuex";
  import website from '@/config/website';
import {
  getLazyList,
  remove,
  update,
  add,
  getDept,
  getDeptTree,
} from "@/api/system/dept";
import { mapGetters } from "vuex";
import website from "@/config/website";
  export default {
    data() {
      return {
        form: {},
        selectionList: [],
        query: {},
        loading: true,
        parentId: 0,
        page: {
          pageSize: 10,
          currentPage: 1,
          total: 0,
        },
        option: {
          lazy: true,
          tip: false,
          simplePage: true,
          searchShow: true,
          searchMenuSpan: 6,
          tree: true,
          border: true,
          index: true,
          selection: true,
          viewBtn: true,
          menuWidth: 300,
          dialogClickModal: false,
          column: [
            {
              label: "机构名称",
              prop: "deptName",
              searchSpan:5,
              search: true,
              rules: [{
export default {
  data() {
    return {
      form: {},
      selectionList: [],
      query: {},
      loading: true,
      parentId: 0,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        lazy: true,
        tip: false,
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        tree: true,
        border: true,
        index: true,
        selection: true,
        viewBtn: true,
        menuWidth: 300,
        dialogClickModal: false,
        column: [
          {
            label: "机构名称",
            prop: "deptName",
            searchSpan: 5,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入机构名称",
                trigger: "blur"
              }]
            },
            {
              label: "所属保安单位",
              prop: "tenantId",
              type: "tree",
              dicUrl: "/api/blade-system/tenant/select",
              addDisplay: false,
              editDisplay: false,
              viewDisplay: website.tenantMode,
              span: 24,
              props: {
                label: "tenantName",
                value: "tenantId"
                trigger: "blur",
              },
              hide: !website.tenantMode,
              search: website.tenantMode,
              searchSpan:5,
              searchLabelWidth:"110",
              rules: [{
                required: true,
                message: "请输入所属保安单位",
                trigger: "click"
              }]
            },
            {
              label: "机构全称",
              prop: "fullName",
              searchSpan:5,
              search: true,
              rules: [{
            ],
          },
          // {
          //   label: "所属保安单位",
          //   prop: "tenantId",
          //   type: "tree",
          //   dicUrl: "/api/blade-system/tenant/select",
          //   addDisplay: false,
          //   editDisplay: false,
          //   hide: true,
          //   viewDisplay: website.tenantMode,
          //   span: 24,
          //   props: {
          //     label: "tenantName",
          //     value: "tenantId",
          //   },
          //   hide: !website.tenantMode,
          //   search: website.tenantMode,
          //   searchSpan: 5,
          //   searchLabelWidth: "110",
          //   rules: [
          //     {
          //       required: true,
          //       message: "请输入所属保安单位",
          //       trigger: "click",
          //     },
          //   ],
          // },
          {
            label: "机构全称",
            prop: "fullName",
            searchSpan: 5,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入机构全称",
                trigger: "blur"
              }]
            },
            {
              label: "上级机构",
              prop: "parentId",
              dicData: [],
              type: "tree",
              hide: true,
              addDisabled: false,
              props: {
                label: "title"
                trigger: "blur",
              },
              rules: [{
            ],
          },
          {
            label: "上级机构",
            prop: "parentId",
            dicData: [],
            type: "tree",
            hide: true,
            addDisabled: false,
            props: {
              label: "title",
            },
            rules: [
              {
                required: false,
                message: "请选择上级机构",
                trigger: "click"
              }]
            },
            {
              label: "机构类型",
              searchSpan:5,
              type: "select",
              dicUrl: "/api/blade-system/dict/dictionary?code=org_category",
              props: {
                label: "dictValue",
                value: "dictKey"
                trigger: "click",
              },
              dataType: "number",
              width: 120,
              prop: "deptCategory",
              slot: true,
              rules: [{
            ],
          },
          {
            label: "机构类型",
            searchSpan: 5,
            type: "select",
            dicUrl: "/api/blade-system/dict/dictionary?code=org_category",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            width: 120,
            prop: "deptCategory",
            slot: true,
            rules: [
              {
                required: true,
                message: "请输入机构类型",
                trigger: "blur"
              }]
            },
            {
              label: "排序",
              prop: "sort",
              type: "number",
              align: "right",
              width: 80,
              rules: [{
                trigger: "blur",
              },
            ],
          },
          {
            label: "排序",
            prop: "sort",
            type: "number",
            align: "right",
            width: 80,
            rules: [
              {
                required: true,
                message: "请输入排序",
                trigger: "blur"
              }]
            },
            {
              label: "备注",
              prop: "remark",
              rules: [{
                trigger: "blur",
              },
            ],
          },
          {
            label: "备注",
            prop: "remark",
            rules: [
              {
                required: false,
                message: "请输入备注",
                trigger: "blur"
              }],
              hide: true
            }
          ]
        },
        data: []
                trigger: "blur",
              },
            ],
            hide: true,
          },
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.dept_add, false),
        viewBtn: this.vaildData(this.permission.dept_view, false),
        delBtn: this.vaildData(this.permission.dept_delete, false),
        editBtn: this.vaildData(this.permission.dept_edit, false),
      };
    },
    computed: {
      ...mapGetters(["userInfo", "permission"]),
      permissionList() {
        return {
          addBtn: this.vaildData(this.permission.dept_add, false),
          viewBtn: this.vaildData(this.permission.dept_view, false),
          delBtn: this.vaildData(this.permission.dept_delete, false),
          editBtn: this.vaildData(this.permission.dept_edit, false)
        };
      },
      ids() {
        let ids = [];
        this.selectionList.forEach(ele => {
          ids.push(ele.id);
        });
        return ids.join(",");
      }
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    methods: {
      initData() {
        getDeptTree().then(res => {
          const column = this.findObject(this.option.column, "parentId");
          column.dicData = res.data.data;
        });
      },
      handleAdd(row) {
        this.parentId = row.id;
  },
  methods: {
    initData() {
      getDeptTree().then((res) => {
        const column = this.findObject(this.option.column, "parentId");
        column.value = row.id;
        column.addDisabled = true;
        this.$refs.crud.rowAdd();
      },
      rowSave(row, done, loading) {
        add(row).then((res) => {
        column.dicData = res.data.data;
      });
    },
    handleAdd(row) {
      this.parentId = row.id;
      const column = this.findObject(this.option.column, "parentId");
      column.value = row.id;
      column.addDisabled = true;
      this.$refs.crud.rowAdd();
    },
    rowSave(row, done, loading) {
      add(row).then(
        (res) => {
          // 获取新增数据的相关字段
          const data = res.data.data;
          row.id = data.id;
@@ -233,135 +252,142 @@
          row.tenantId = data.tenantId;
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          // 数据回调进行刷新
          done(row);
        }, error => {
        },
        (error) => {
          window.console.log(error);
          loading();
        });
      },
      rowUpdate(row, index, done, loading) {
        update(row).then(() => {
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.$message({
            type: "success",
            message: "操作成功!"
            message: "操作成功!",
          });
          // 数据回调进行刷新
          done(row);
        }, error => {
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row, index, done) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          // 数据回调进行刷新
          done(row);
        });
      },
      rowDel(row, index, done) {
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
          .then(() => {
            return remove(row.id);
          })
          .then(() => {
            this.$message({
              type: "success",
              message: "操作成功!"
            });
            // 数据回调进行刷新
            done(row);
        .then(() => {
          // 刷新表格数据并重载
          this.data = [];
          this.parentId = 0;
          this.$refs.crud.refreshTable();
          this.$refs.crud.toggleSelection();
          // 表格数据重载
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
      },
      handleDelete() {
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        this.$confirm("确定将选择数据删除?", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            return remove(this.ids);
          })
          .then(() => {
            // 刷新表格数据并重载
            this.data = [];
            this.parentId = 0;
            this.$refs.crud.refreshTable();
            this.$refs.crud.toggleSelection();
            // 表格数据重载
            this.onLoad(this.page);
            this.$message({
              type: "success",
              message: "操作成功!"
            });
          });
      },
      searchReset() {
        this.query = {};
        this.parentId = 0;
        this.onLoad(this.page);
      },
      searchChange(params, done) {
        this.query = params;
        this.parentId = '';
        this.page.currentPage = 1;
        this.onLoad(this.page, params);
        done();
      },
      selectionChange(list) {
        this.selectionList = list;
      },
      selectionClear() {
        this.selectionList = [];
        this.$refs.crud.toggleSelection();
      },
      beforeOpen(done, type) {
        if (["add", "edit"].includes(type)) {
          this.initData();
        }
        if (["edit", "view"].includes(type)) {
          getDept(this.form.id).then(res => {
            this.form = res.data.data;
          });
        }
        done();
      },
      beforeClose(done) {
        this.parentId = "";
        const column = this.findObject(this.option.column, "parentId");
        column.value = "";
        column.addDisabled = false;
        done();
      },
      currentChange(currentPage) {
        this.page.currentPage = currentPage;
      },
      sizeChange(pageSize) {
        this.page.pageSize = pageSize;
      },
      refreshChange() {
        this.onLoad(this.page, this.query);
      },
      onLoad(page, params = {}) {
        this.loading = true;
        getLazyList(this.parentId, Object.assign(params, this.query)).then(res => {
        });
    },
    searchReset() {
      this.query = {};
      this.parentId = 0;
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.parentId = "";
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    beforeOpen(done, type) {
      if (["add", "edit"].includes(type)) {
        this.initData();
      }
      if (["edit", "view"].includes(type)) {
        getDept(this.form.id).then((res) => {
          this.form = res.data.data;
        });
      }
      done();
    },
    beforeClose(done) {
      this.parentId = "";
      const column = this.findObject(this.option.column, "parentId");
      column.value = "";
      column.addDisabled = false;
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getLazyList(this.parentId, Object.assign(params, this.query)).then(
        (res) => {
          this.data = res.data.data;
          this.loading = false;
          this.selectionClear();
        });
      },
      treeLoad(tree, treeNode, resolve) {
        const parentId = tree.id;
        getLazyList(parentId).then(res => {
          resolve(res.data.data);
        });
      }
    }
  };
        }
      );
    },
    treeLoad(tree, treeNode, resolve) {
      const parentId = tree.id;
      getLazyList(parentId).then((res) => {
        resolve(res.data.data);
      });
    },
  },
};
</script>
<style>