保安服务企业管理项目备份
guoshilong
2023-11-30 81e1b297b1fabec596c1cb7187ce2d6199026429
模拟考试成绩查询
2 files added
272 ■■■■■ changed files
src/api/simulateExamRecord/simulateExamRecord.js 13 ●●●●● patch | view | raw | blame | history
src/views/exam/scoreManage.vue 259 ●●●●● patch | view | raw | blame | history
src/api/simulateExamRecord/simulateExamRecord.js
New file
@@ -0,0 +1,13 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
  return request({
    url: '/api/simulateExamRecord/page',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    }
  })
}
src/views/exam/scoreManage.vue
New file
@@ -0,0 +1,259 @@
<template>
  <basic-container
    :class="[
      'exam-card-body',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
    ]"
  >
    <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
               :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave"
               @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset"
               @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
               @refresh-change="refreshChange" @on-load="onLoad">
    </avue-crud>
  </basic-container>
</template>
<script>
import { getList} from "@/api/simulateExamRecord/simulateExamRecord"
import { mapGetters } from "vuex"
export default {
  name: "scoreManage",
  data(){
    return{
      form: {},
      query: {},
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option: {
        height: 'auto',
        calcHeight: 160,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        indexLabel: '序号',
        searchBtnText: '查 询',
        emptyBtnText: '重 置',
        emptyBtnIcon: 'el-icon-refresh',
        viewBtn: false,
        selection: false,
        dialogClickModal: false,
        header: false,
        refreshBtn: false,
        columnBtn: false,
        searchShowBtn: false,
        delBtn:false,
        editBtn:false,
        menu:false,
        column: [
          {
            label: "姓名",
            prop: "userName",
            search:true,
          },
          {
            label: "手机号",
            prop: "phone",
            search:true,
          },
          {
            label: "得分",
            prop: "score",
          },
          {
            label: "考试状态",
            prop: "status",
            type: 'select',
            props:{
              label:'name',
              value:'code'
            },
            dicData:[
              {
              name:'考试中',
              code:1
              },
              {
              name:'暂停考试',
              code:2
            },
              {
                name:'考试完成',
                code:3
              },
              {
                name:'考试已废弃',
                code:4
              },
            ]
          },
          {
            label: "剩余考试时长",
            prop: "answerTime",
          },
          {
            label: "开始时间",
            prop: "startTime",
          },
          {
            label: "结束时间",
            prop: "endTime",
          },
        ]
      },
      data: [],
    }
  },
  computed: {
    ...mapGetters(["permission","userInfo"]),
    permissionList () {
      return {
        addBtn: this.vaildData(this.permission.patrolRecord_add, false),
        viewBtn: this.vaildData(this.permission.patrolRecord_view, true),
        delBtn: this.vaildData(this.permission.patrolRecord_delete, false),
        editBtn: this.vaildData(this.permission.patrolRecord_edit, false)
      }
    },
    ids () {
      let ids = []
      this.selectionList.forEach(ele => {
        ids.push(ele.id)
      })
      return ids.join(",")
    }
  },
  methods: {
    rowSave (row, done, loading) {
      add(row).then(() => {
        this.onLoad(this.page)
        this.$message({
          type: "success",
          message: "操作成功!"
        })
        done()
      }, error => {
        loading()
      })
    },
    rowUpdate (row, index, done, loading) {
      update(row).then(() => {
        this.onLoad(this.page)
        this.$message({
          type: "success",
          message: "操作成功!"
        })
        done()
      }, error => {
        loading()
      })
    },
    rowDel (row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id)
        })
        .then(() => {
          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.onLoad(this.page)
          this.$message({
            type: "success",
            message: "操作成功!"
          })
          this.$refs.crud.toggleSelection()
        })
    },
    beforeOpen (done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data
        })
      }
      done()
    },
    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
    },
    selectionClear () {
      this.selectionList = []
      this.$refs.crud.toggleSelection()
    },
    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
      //对于管理员可以查看全部,对于其他角色只能查看本公司
     if (this.userInfo.role_name != "administrator"){
       params.deptId = this.userInfo.dept_id
     }
      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
        this.loading = false
        this.selectionClear()
      })
    },
  }
}
</script>
<style scoped>
</style>