保安服务企业管理项目备份
Administrator
2022-03-02 2afc9c68c658d75789b59e19d2d65f9797b8bccc
新增考勤打卡页面,权限菜单设置,新增导出
3 files added
878 ■■■■■ changed files
src/api/clock/clock.js 39 ●●●●● patch | view | raw | blame | history
src/views/clock/clock.vue 460 ●●●●● patch | view | raw | blame | history
src/views/rail/rail.vue 379 ●●●●● patch | view | raw | blame | history
src/api/clock/clock.js
New file
@@ -0,0 +1,39 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
    return request({
        url: '/api/attendance/page',
        method: 'get',
        params: {
            ...params,
            current,
            size,
        }
    })
}
export const add = (row) => {
    return request({
        url: '/api/attendance/save',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/attendance/update',
        method: 'post',
        data: row
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/attendance/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}
src/views/clock/clock.vue
New file
@@ -0,0 +1,460 @@
<template>
  <basic-container
    :class="[
      'securityUnit',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :data="data"
      :page.sync="page"
      ref="crud"
      :permission="permissionList"
      :search.sync="questionBankSearch"
      @on-load="onLoad"
      :table-loading="loading"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @row-update="rowUpdate"
      @row-del="rowDel"
      @selection-change="selectionChange"
      @refresh-change="refreshChange"
    >
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          plain
          icon="el-icon-delete"
          v-if="permission.clock_delete"
          @click="handleDelete"
          >删 除
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.clock_export"
          @click="handleExport"
          >导出
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import {
  getList,
  add,
  update,
  remove
} from "@/api/clock/clock";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
import Qs from "qs";
export default {
  data() {
    return {
      loading: true,
      selectionList: [],
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      query: {},
      questionBankSearch: {},
      data: [],
      option: {
        index: true,
        tip:false,
        addBtn: true,
        viewBtn: true,
        searchSize: "mini",
        searchMenuSpan: 6,
        height: 583,
        menuWidth: 280,
        border: true,
        align: "center",
        selection: true,
        column: [
          {
            label: "日期",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            searchSpan: 5,
            rules: [
              {
                required: true,
                message: "请输入申请时间",
                trigger: "blur"
              }
            ]
          },
          {
            label: "姓名",
            prop: "realName",
            search: true,
            searchSpan: 4,
            labelWidth: 145,
            minWidth: 160,
            span:12,
            rules: [
              {
                required: true,
                message: "请输入姓名",
                trigger: "click"
              }
            ],
            overHidden: true
          },
          {
            label: "打卡时间",
            prop: "clockTime",
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: true,
                message: "请输入打卡时间",
                trigger: "blur"
              }
            ]
          },
          {
            label: "打卡类型",
            prop: "clockType",
            span: 12,
            labelWidth: 145,
            disabled: false,
            type: "select",
            dataType: "number",
            search:true,
            searchSpan:4,
            dicData:[
              {
                label:"上班",
                value:1
              },
              {
                label:"下班",
                value:2
              }
            ],
            rules: [
              {
                required: true,
                message: "请输入打卡类型",
                trigger: "blur"
              }
            ]
          },
          {
            label: "状态",
            prop: "attendanceType",
            span: 12,
            labelWidth: 145,
            disabled: false,
            search:true,
            searchSpan:4,
            type: "select",
            dicUrl:
              "/api/blade-system/dict-biz/dictionary?code=attendanceType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            dataType: "number",
            rules: [
              {
                required: true,
                message: "请输入状态",
                trigger: "blur"
              }
            ]
          },
        ],
        ...this.$store.state.control.clearOtherBut
      }
    };
  },
  created() {
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.clock_add, false),
        viewBtn: this.vaildData(this.permission.clock_view, false),
        delBtn: this.vaildData(this.permission.clock_delete, false),
        editBtn: this.vaildData(this.permission.clock_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  methods: {
    sizeChange(val) {
      this.page1.currentPage = 1;
      this.page1.pageSize = val;
      this.onLoad(this.page, this.query);
    },
    currentChange(val) {
      this.page1.currentPage = val;
      // this.getData();
      this.onLoad(this.page, this.query);
    },
    rowSave(form, done, loading) {
      add(form).then(res => {
        if (res.data.success) {
          this.$message({
            message: "操作成功",
            type: "success"
          });
          this.refreshChange();
          done();
        } else {
          this.$message({
            message: "操作失败",
            type: "warning"
          });
          done();
        }
      });
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm(
        "确定删除当前合同信息数据?",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(() => {
          console.log(row);
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定批量将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids).then(res => {
            this.refreshChange();
          });
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crudrec.toggleSelection();
        })
        .catch(res => {});
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    //保安员证信息导出
    handleExport() {
      this.$confirm("是否导出考勤打卡信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.questionBankSearch;
        if (releaseTimeRange) {
          this.questionBankSearch["beginTime"] = releaseTimeRange[0];
          this.questionBankSearch["endTime"] = releaseTimeRange[1];
        }
        var data = {
          clockType: this.questionBankSearch.clockType,
          attendanceType: this.questionBankSearch.attendanceType,
          realName: this.questionBankSearch.realName,
          beginTime: this.questionBankSearch.beginTime,
          endTime: this.questionBankSearch.endTime
        };
        //导出
        if (this.userInfo.role_name == "保安公司管理员") {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/attendance/export-Attendance?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    onLoad(page, params = {}) {
      params = this.questionBankSearch;
      if(this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警" || this.userInfo.role_name == "administrator"){
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      if(this.userInfo.role_name == "保安公司管理员" || this.userInfo.role_name == "分公司管理员"){
        params["deptId"] = this.userInfo.dept_id;
      }
      const { releaseTimeRange } = this.query;
      let values = {
        ...params
      };
      if (releaseTimeRange) {
        values = {
          ...params,
          beginTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query
        };
        values.releaseTimeRange = null;
      }
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(values, this.query)
      ).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        window.localStorage.setItem("danweidataS", JSON.stringify(this.data));
        this.$store.commit("setWindowSizeHeightAdd");
        this.loading = false;
      });
    }
  },
};
</script>
<style lang="scss">
.securityUnit {
  width: 100%;
  height: 100%;
  //   border: 1px solid #000;
  box-sizing: border-box;
}
// .el-card__body {
//   padding-bottom: 5px !important;
// }
// .avue-crud__tip,
// .el-tag,
// .el-tag--light {
//   padding: 0 !important;
// }
.lod {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba($color: #000000, $alpha: 0.5);
  padding: 100px 0 0 0;
  z-index: 1500 !important;
  display: flex;
  // align-items: center;
  justify-content: center;
  .trees {
    z-index: 501 !important;
    position: absolute;
    width: 15%;
    top: 100px;
    left: 0;
    // display: none;
  }
  .lod-in {
    width: 70%;
    height: auto;
    background-color: transparent;
    // padding: 10px 0 0 0;
  }
  .el-collapse-item {
    padding-top: 15px !important;
  }
}
.el-collapse {
  border-top: 1px solid transparent !important;
}
.rowClickSelf {
  &:hover {
    cursor: pointer;
  }
}
</style>
src/views/rail/rail.vue
New file
@@ -0,0 +1,379 @@
<template>
  <basic-container
    :class="[
      'securityUnit',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :data="data"
      :page.sync="page"
      ref="crud"
      :permission="permissionList"
      @on-load="onLoad"
      :table-loading="loading"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @row-update="rowUpdate"
      @row-del="rowDel"
      @selection-change="selectionChange"
      @refresh-change="refreshChange"
    >
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          plain
          icon="el-icon-delete"
          v-if="permission.contract_delete"
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import {
  getList,
  add,
  update,
  remove
} from "@/api/contract/contract";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
export default {
  data() {
    return {
      loading: true,
      selectionList: [],
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      query: {},
      data: [],
      option: {
        index: true,
        tip:false,
        addBtn: true,
        searchSize: "mini",
        searchMenuSpan: 6,
        height: 583,
        menuWidth: 180,
        border: true,
        align: "center",
        selection: true,
        column: [
          {
            label: "合同名称",
            prop: "name",
            search: true,
            searchSpan: 4,
            labelWidth: 145,
            minWidth: 160,
            span:24,
            rules: [
              {
                required: true,
                message: "请选择合同名称",
                trigger: "click"
              }
            ],
            overHidden: true
          },
          {
            label: "合同甲方",
            prop: "partya",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: true,
                message: "请输入合同甲方",
                trigger: "blur"
              }
            ]
          },
          {
            label: "合同乙方",
            prop: "partyb",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: true,
                message: "请输入合同乙方",
                trigger: "blur"
              }
            ]
          },
          {
            label: "合同金额",
            prop: "money",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: true,
                message: "请输入合同金额",
                trigger: "blur"
              }
            ]
          },
          {
            label: "签订日期",
            prop: "signedTime",
            labelWidth: 145,
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            rules: [
              {
                required: true,
                message: "请选择签订日期",
                trigger: "blur"
              }
            ]
          },
          {
            label: "纸质合同图片",
            prop: "urls",
            labelWidth: 145,
            type: "upload",
            dataType: "string",
            span: 24,
            limit: 5,
            listType: "picture-card",
            tip: "只能上传jpg/png文件,最多上传5张",
            propsHttp: {
              res: "data",
              url: "url"
            },
            action: "/api/blade-resource/oss/endpoint/put-files"
          }
        ],
        ...this.$store.state.control.clearOtherBut
      }
    };
  },
  created() {
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.contract_add, false),
        viewBtn: this.vaildData(this.permission.contract_view, false),
        delBtn: this.vaildData(this.permission.contract_delete, false),
        editBtn: this.vaildData(this.permission.contract_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  methods: {
    sizeChange(val) {
      this.page1.currentPage = 1;
      this.page1.pageSize = val;
      this.onLoad(this.page, this.query);
    },
    currentChange(val) {
      this.page1.currentPage = val;
      // this.getData();
      this.onLoad(this.page, this.query);
    },
    rowSave(form, done, loading) {
      add(form).then(res => {
        if (res.data.success) {
          this.$message({
            message: "操作成功",
            type: "success"
          });
          this.refreshChange();
          done();
        } else {
          this.$message({
            message: "操作失败",
            type: "warning"
          });
          done();
        }
      });
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    rowUpdate(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm(
        "确定删除当前合同信息数据?",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }
      )
        .then(() => {
          console.log(row);
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定批量将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids).then(res => {
            this.refreshChange();
          });
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crudrec.toggleSelection();
        })
        .catch(res => {});
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      if(this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警" || this.userInfo.role_name == "administrator"){
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        window.localStorage.setItem("danweidataS", JSON.stringify(this.data));
        this.$store.commit("setWindowSizeHeightAdd");
        this.loading = false;
      });
    }
  },
};
</script>
<style lang="scss">
.securityUnit {
  width: 100%;
  height: 100%;
  //   border: 1px solid #000;
  box-sizing: border-box;
}
// .el-card__body {
//   padding-bottom: 5px !important;
// }
// .avue-crud__tip,
// .el-tag,
// .el-tag--light {
//   padding: 0 !important;
// }
.lod {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba($color: #000000, $alpha: 0.5);
  padding: 100px 0 0 0;
  z-index: 1500 !important;
  display: flex;
  // align-items: center;
  justify-content: center;
  .trees {
    z-index: 501 !important;
    position: absolute;
    width: 15%;
    top: 100px;
    left: 0;
    // display: none;
  }
  .lod-in {
    width: 70%;
    height: auto;
    background-color: transparent;
    // padding: 10px 0 0 0;
  }
  .el-collapse-item {
    padding-top: 15px !important;
  }
}
.el-collapse {
  border-top: 1px solid transparent !important;
}
.rowClickSelf {
  &:hover {
    cursor: pointer;
  }
}
</style>