gaoluyang
2025-02-28 fe67cd0c17d827b6a858ceff2eedf8b48e2f5f2a
人员-奖惩记录搬迁
已修改2个文件
已添加1个文件
236 ■■■■ 文件已修改
src/api/cnas/personal/personRewardPunishmentRecord.js 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/personnel/personnelInfo/index.vue 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue 193 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/cnas/personal/personRewardPunishmentRecord.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,35 @@
import request from "@/utils/request";
// äººå‘˜ - å¥–惩记录 åˆ†é¡µæŸ¥è¯¢
export function rewardPunishmentPage(query) {
  return request({
    url: "/personRewardPunishmentRecord/rewardPunishmentPage",
    method: "get",
    params: query
  });
}
// äººå‘˜ - å¥–惩记录 å¯¼å‡º
export function rewardPunishmentExport(query) {
  return request({
    url: "/personRewardPunishmentRecord/rewardPunishmentExport",
    method: "get",
    params: query,
    responseType: 'blob'
  });
}
// äººå‘˜ - å¥–惩记录 æ–°å¢ž/更新
export function addOrUpdateRewardPunishment(query) {
  return request({
    url: "/personRewardPunishmentRecord/addOrUpdateRewardPunishment",
    method: "post",
    data: query,
  });
}
// äººå‘˜ - å¥–惩记录 æ–°å¢ž/更新
export function deleteRewardPunishment(query) {
  return request({
    url: "/personRewardPunishmentRecord/deleteRewardPunishment",
    method: "delete",
    params: query,
  });
}
src/views/CNAS/personnel/personnelInfo/index.vue
@@ -66,10 +66,10 @@
                                :departId="departId"
                                :isDepartment="isDepartment"></job-responsibilities>
        </el-tab-pane>
<!--        <el-tab-pane label="奖惩记录" name="奖惩记录">-->
<!--          <rewardPunishmentRecord v-if="activeName === '奖惩记录'"-->
<!--                                  :departId="departId" :isDepartment="isDepartment"></rewardPunishmentRecord>-->
<!--        </el-tab-pane>-->
        <el-tab-pane label="奖惩记录" name="奖惩记录">
          <rewardPunishmentRecord v-if="activeName === '奖惩记录'"
                                  :departId="departId" :isDepartment="isDepartment"></rewardPunishmentRecord>
        </el-tab-pane>
<!--        <el-tab-pane label="培训记录" name="培训记录">-->
<!--          <training-record v-if="activeName === '培训记录'" ref="trainingRecord"-->
<!--                           :departId="departId"-->
src/views/CNAS/personnel/personnelInfo/tabs/reward-punishment-record.vue
@@ -1,33 +1,41 @@
<!-- å¥–惩记录 -->
<template>
  <div>
    <div style="text-align: left; margin-bottom: 15px;">
      <label>姓名</label>
      <el-input v-model="search.userName" clearable placeholder="请输入关键字" size="small" style="width: 20vh;"></el-input>
      <label style="margin-left: 1em">奖惩日期</label>
      <el-date-picker
        v-model="search.searchTimeList"
        :picker-options="pickerOptions"
        align="right"
        clearable
        end-placeholder="结束日期"
        format="yyyy-MM-dd"
        range-separator="至"
        size="small"
        start-placeholder="开始日期"
        style="width: 20%"
        type="daterange"
        unlink-panels
        value-format="yyyy-MM-dd 00:00:00">
      </el-date-picker>
      <el-button size="small" type="primary" @click="getPersonnelTraining(departId)">查询</el-button>
      <div style="float: right;">
        <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">导出</el-button>
        <el-button size="small" type="primary" @click="addRow">新增</el-button>
    <div class="view">
      <div style="display: flex;justify-content: space-between;">
        <el-form :model="search" ref="page" size="small" :inline="true">
          <el-form-item label="姓名">
            <el-input v-model="search.userName" clearable placeholder="请输入关键字" size="small" style="width: 20vh;"></el-input>
          </el-form-item>
          <el-form-item label="奖惩日期">
            <el-date-picker
              v-model="search.searchTimeList"
              :picker-options="pickerOptions"
              align="right"
              clearable
              end-placeholder="结束日期"
              format="yyyy-MM-dd"
              range-separator="至"
              size="small"
              start-placeholder="开始日期"
              style="width: 100%"
              type="daterange"
              unlink-panels
              value-format="yyyy-MM-dd 00:00:00">
            </el-date-picker>
          </el-form-item>
          <el-form-item>
            <el-button size="small" type="primary" @click="getPersonnelTraining(departId)">查询</el-button>
          </el-form-item>
        </el-form>
        <div>
          <el-button :loading="outLoading" size="small" type="primary" @click="handleDown">导出</el-button>
          <el-button size="small" type="primary" @click="addRow">新增</el-button>
        </div>
      </div>
    </div>
    <div class="table">
      <el-table :data="tableData" height="70vh" style="width: 100%">
      <el-table :data="tableData" v-loading="tableLoading" height="66.5vh" style="width: 100%">
        <el-table-column label="序号" type="index" width="120">
          <template v-slot="scope">
            <span>{{ (search.current - 1) * search.size + scope.$index + 1 }}</span>
@@ -49,22 +57,24 @@
        </el-table-column>
        <el-table-column label="创建人" min-width="180" prop="createUserName">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="100">
        <el-table-column fixed="right" label="操作" width="100" align="center">
          <template v-slot="scope">
            <el-button size="small" type="text" @click="editForm(scope.row)">编辑</el-button>
            <el-button size="small" type="text" @click="deleteRow(scope.row)">删除</el-button>
            <el-button size="small" type="text" style="color: #f56c6c" @click="deleteRow(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="1" :page-size="search.size" :page-sizes="[10, 20, 30, 50, 100]"
      <el-pagination :current-page="1" :page-size="search.size"
                     :page-sizes="[10, 20, 30, 50, 100]"
                     :total="search.total" layout="->,total, sizes, prev, pager, next, jumper"
                     background
                     @size-change="handleSizeChange"
                     @current-change="handleCurrentChange">
      </el-pagination>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      title="提示"
      title="奖惩记录"
      width="50%"
      @open="getUserList">
      <div style="height: 40vh">
@@ -119,14 +129,22 @@
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 æ¶ˆ</el-button>
    <el-button type="primary" @click="saveOrUpdate">ç¡® å®š</el-button>
  </span>
        <el-button @click="dialogVisible = false">取 æ¶ˆ</el-button>
        <el-button type="primary" @click="saveOrUpdate">ç¡® å®š</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  addOrUpdateRewardPunishment, deleteRewardPunishment,
  rewardPunishmentExport,
  rewardPunishmentPage
} from "@/api/cnas/personal/personRewardPunishmentRecord";
import {selectUserCondition} from "@/api/system/user";
import {delCustomById} from "@/api/system/customer";
export default {
  props: {
    departId: {
@@ -143,6 +161,7 @@
  data() {
    return {
      tableData: [],
      tableLoading: false,
      search: {
        size: 20,
        current: 1,
@@ -213,23 +232,23 @@
      this.getPersonnelTraining(this.departId);
    },
    async getPersonnelTraining() {
      const {code, data} = await this.$axios({
        method: 'get',
        url: rewardPunishmentPageApi,
        params: {
          userId: this.isDepartment ? '' : this.departId,
      const params = {
        userId: this.isDepartment ? '' : this.departId,
          departmentId: this.isDepartment ? this.departId : '',
          current: this.search.curent,
          size: this.search.size,
          userName: this.search.userName,
          startTime: this.search.searchTimeList && this.search.searchTimeList[0],
          endTime: this.search.searchTimeList && this.search.searchTimeList[1],
        }
      })
      if (code == 200) {
        this.tableData = data.records
        this.search.total = data.total
      }
      this.tableLoading = true
      rewardPunishmentPage(params).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records
        this.search.total = res.data.total
      }).catch(err => {
        this.tableLoading = false
      })
    },
    addRow () {
      this.dialogVisible = true
@@ -240,60 +259,28 @@
    },
    handleDown(){
      this.outLoading = true
      this.$axios.post(this.$api.deviceCheck.rewardPunishmentExport,{
      rewardPunishmentExport({
        userId: this.isDepartment ? '' : this.departId,
        departmentId: this.isDepartment ? this.departId : '',
        userName: this.search.userName,
        startTime: this.search.searchTimeList && this.search.searchTimeList[0],
        endTime: this.search.searchTimeList && this.search.searchTimeList[1]
      },{responseType: 'blob'}).then(res => {
      }).then(res => {
        this.outLoading = false
        const blob = new Blob([res], {
          type: 'application/force-download'
        })
        //将Blob å¯¹è±¡è½¬æ¢æˆå­—符串
        let reader = new FileReader();
        reader.readAsText(blob, 'utf-8');
        reader.onload = () => {
          try {
            let result = JSON.parse(reader.result);
            if (result.message) {
              this.$message.error(result.message);
            } else {
              // åˆ›å»ºä¸€ä¸ªè¶…链接,将文件流赋进去,然后实现这个超链接的单击事件
              const elink = document.createElement('a')
              elink.download = decodeURI('奖惩记录'+'.xlsx')
              elink.style.display = 'none'
              elink.href = URL.createObjectURL(blob)
              document.body.appendChild(elink)
              elink.click();
              URL.revokeObjectURL(elink.href) // é‡Šæ”¾URL å¯¹è±¡
              document.body.removeChild(elink)
              this.$message.success('导出成功')
            }
          } catch (err) {
            console.log(err);
            // åˆ›å»ºä¸€ä¸ªè¶…链接,将文件流赋进去,然后实现这个超链接的单击事件
            const elink = document.createElement('a')
            elink.download = decodeURI('奖惩记录'+'.xlsx')
            elink.style.display = 'none'
            elink.href = URL.createObjectURL(blob)
            document.body.appendChild(elink)
            elink.click();
            URL.revokeObjectURL(elink.href) // é‡Šæ”¾URL å¯¹è±¡
            document.body.removeChild(elink)
            this.$message.success('导出成功')
          }
        }
        this.$download.saveAs(blob, '奖惩记录.xlsx')
        this.$message.success('导出成功')
      })
    },
    // èŽ·å–è´Ÿè´£äººä¿¡æ¯æŽ¥å£
    getUserList() {
      this.$axios.get(this.$api.deviceScope.selectUserList).then(res => {
      selectUserCondition().then(res => {
        if (res.code == 200) {
          this.responsibleOptions = res.data
        }
      })
      });
    },
    selectUserChange(val) {
      const index = this.responsibleOptions.findIndex(item => item.id === val)
@@ -302,42 +289,40 @@
        this.form.account = this.responsibleOptions[index].account
      }
    },
    // æ‰“开表单弹框
    editForm(row) {
      this.dialogVisible = true
      this.form = {...row};
    },
    // æäº¤è¡¨å•数据
    saveOrUpdate() {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          this.dialogVisible = false
          const {code, data} = await this.$axios({
            method: 'post',
            url: addOrUpdateRewardPunishmentApi,
            data: this.form,
            headers: {
              'Content-Type': 'application/json'
            },
            noQs: true
          })
          if (code == 200) {
            this.$message.success("操作成功!")
          addOrUpdateRewardPunishment(this.form).then(res => {
            this.dialogVisible = false
            this.$message.success("操作成功")
            this.getPersonnelTraining(this.departId);
          }
          })
        }
      })
    },
    async deleteRow(row) {
      const {code, data} = await this.$axios({
        method: 'delete',
        url: deleteRewardPunishmentApi,
        params: {
          id: row.id
        }
      })
      if (code == 200) {
        this.$message.success("操作成功!")
        this.getPersonnelTraining(this.departId);
      }
    deleteRow(row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        deleteRewardPunishment({id: row.id}).then(res => {
          if (res.code === 500) {
            return
          }
          this.$message.success('删除成功')
          this.getPersonnelTraining(this.departId);
        }).catch(e => {
          this.$message.error('删除失败')
        })
      }).catch(() => {})
    }
  },
  watch: {