Administrator
2022-06-10 71bf70c7874885c1f333cabe073cc42357fb058f
新增异常日志查看
2 files added
347 ■■■■■ changed files
src/api/handlerlog/handlerlog.js 57 ●●●●● patch | view | raw | blame | history
src/views/logRecord/logRecord.vue 290 ●●●●● patch | view | raw | blame | history
src/api/handlerlog/handlerlog.js
New file
@@ -0,0 +1,57 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
    return request({
        url: '/api/handlerLog/page',
        method: 'get',
        params: {
            current,
            size,
            ...params
        }
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/handlerLog/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}
export const detail = (id) => {
    return request({
        url: '/api/handlerLog/detail',
        method: 'get',
        params: {
            id,
        }
    })
}
export const submit = (row) => {
    return request({
        url: '/api/handlerLog/submit',
        method: 'post',
        data: row
    })
}
export const add = (row) => {
    return request({
        url: '/api/handlerLog/save',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/handlerLog/update',
        method: 'post',
        data: row
    })
}
src/views/logRecord/logRecord.vue
New file
@@ -0,0 +1,290 @@
<template>
  <basic-container
    :class="[
      'desk1',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      :search.sync="questionBankSearch"
      :before-open="beforeOpen"
      @filter="filterChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          v-if="permission.handler_log_delete"
          plain
          @click="handleDelete"
          >删 除
        </el-button>
      </template>
    </avue-crud>
  </basic-container>
</template>
<script>
import {
  getList,
  remove,
  detail,
} from "@/api/handlerlog/handlerlog";
import { mapGetters } from "vuex";
import { mapState } from "vuex";
export default {
  data() {
    return {
      form: {},
      query: {},
      questionBankSearch: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      option: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        tip: true,
        reserveSelection: true,
        searchShow: true,
        searchMenuSpan: 6,
        align: "center",
        border: true,
        index: true,
        stripe: true,
        selection: true,
        excelBtn: false,
        addBtn:false,
        editBtn:false,
        viewBtn:true,
        menuWidth: 110,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        searchIndex: 5, //收缩展示数量
        column: [
          {
            label: "异常类型",
            prop: "type",
            type: "select",
            search: true,
            searchLabelWidth: 90,
            searchSpan: 4,
            dicData: [
              {
                label: "保安员新增",
                value: 1
              },
              {
                label: "保安员批量导入",
                value: 2
              },
              {
                label: "培训报名",
                value: 3
              }
            ]
          },
          // {
          //   label: "姓名",
          //   prop: "realName",
          //   search: true,
          //   searchSpan: 3,
          //   width: 100,
          //   disabled: true,
          //   searchLabelWidth: 50
          // },
          {
            label: "企业名称",
            searchLabelWidth: "90",
            prop: "deptName",
            slot: true,
            searchSpan: 5,
            search: true,
            disabled: true,
            overHidden: true
          },
          {
            label: "申请时间",
            prop: "operatorTime",
          },
          {
            label: "创建时间",
            prop: "createTime",
          },
          {
            label: "说明",
            prop: "remark",
            type:"textarea",
            overHidden: true
          }
        ]
      },
      data: []
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(null, false),
        viewBtn: this.vaildData(
          this.permission.handler_log_view,
          true
        ),
        delBtn: this.vaildData(
          this.permission.handler_log_delete,
          false
        ),
        editBtn: this.vaildData(null, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapState({
      userInfo: state => state.user.userInfo
    })
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  created() {
  },
  methods: {
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
      this.choiceList = [];
      for (let k in list) {
        this.choiceList.push({
          id: list[k].id
        });
      }
    },
    selectionClear() {
      this.selectionList = [];
      // this.$refs.crud.toggleSelection();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page, this.questionBankSearch);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        detail(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.questionBankSearch);
    },
    onLoad(page, params = {}) {
      params = this.questionBankSearch;
      this.deptId = JSON.parse(
        window.localStorage.getItem("saber-userInfo")
      ).content.dept_id;
      if (this.userInfo.role_name == "保安公司管理员" || this.userInfo.role_name == "培训公司管理员") {
        //如果是保安公司管理员
        params["deptId"] = this.userInfo.dept_id;
      }
      if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        //如果是公安管理员
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      this.loading = true;
      getList(page.currentPage, page.pageSize, params).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.$store.commit("setWindowSizeHeightAdd");
        this.selectionClear();
      });
    },
  }
};
</script>
<style lang="scss" scoped>
</style>