Crunchy
2025-04-29 e5454b769d44a34af423bf87ac8a740bf8c20341
src/views/CNAS/personnel/personnelInfo/tabs/personnelTraining.vue
@@ -5,63 +5,55 @@
      <div class="title">
        <span style="font-weight: bold">年度计划</span>
      </div>
      <div style="display: flex;justify-content: space-between;">
        <el-form :model="page" ref="page" size="small" :inline="true">
          <el-form-item label="编制人">
            <el-input v-model="page.compilerName" clearable></el-input>
          </el-form-item>
          <el-form-item>
            <el-button size="small" type="primary" @click="getYearPlanList(departId)">查 询</el-button>
          </el-form-item>
        </el-form>
        <div>
      <div style="display: flex;justify-content: space-between">
        <div style="display: flex;">
          <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
            <span style="width: 88px;font-size: 14px;font-weight: 700;color: #606266;">编制人</span>
            <el-input size="small" placeholder="请输入" clearable v-model="page.compilerName"
                      @keyup.enter.native="getYearPlanList(departId)"></el-input>
          </div>
          <div style="line-height: 30px;">
            <el-button type="primary" size="mini" @click="getYearPlanList(departId)">查询</el-button>
          </div>
        </div>
        <div style="line-height: 30px;">
          <el-button size="small" type="primary" @click="uploadDia = true, getUserList()">导入</el-button>
        </div>
      </div>
      <lims-table :tableData="yearPlanTableData" :column="yearPlanColumn"
                  :currentChange="currentChange"
                  @pagination="pagination" height="40vh"
                  :page="page" :tableLoading="yearLoading"></lims-table>
      <lims-table :tableData="yearPlanTableData" :column="yearPlanColumn" :currentChange="currentChange"
        @pagination="pagination" height="40vh" :page="page" :tableLoading="yearLoading"></lims-table>
    </div>
    <div v-if="!editPlanShow" class="table">
      <div>
        <div class="title">
          <span style="font-weight: bold">年度计划明细</span>
        </div>
        <div style="display: flex;justify-content: space-between;">
          <el-form :model="inDetailForm" ref="inDetailForm" size="small" :inline="true">
            <el-form-item label="培训讲师">
              <el-input v-model="inDetailForm.trainingLecturerName" class="search" clearable placeholder="请输入" size="small"></el-input>
            </el-form-item>
            <el-form-item label="培训日期">
              <el-date-picker v-model="inDetailForm.trainingDate" clearable
                              format="yyyy-MM-dd" placeholder="选择日期" size="small"
                              type="date" value-format="yyyy-MM-dd"></el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button size="small" type="primary" @click="searchTable">查 询</el-button>
            </el-form-item>
          </el-form>
          <div>
            <el-button v-if="isDepartment && currentChangeRow && isOperation" size="small" @click="batchDelete">批量删除</el-button>
            <el-button v-if="isDepartment && currentChangeRow && isOperation" size="small" type="primary" @click="addTrainingPlan('add')">新增</el-button>
        <div style="display: flex;justify-content: space-between">
          <div style="display: flex;">
            <div style="margin-bottom: 18px;margin-right: 10px;display: flex;align-items: center;line-height: 32px;">
              <span style="width: 88px;font-size: 14px;font-weight: 700;color: #606266;">培训讲师</span>
              <el-input size="small" placeholder="请输入" clearable v-model="inDetailForm.trainingLecturerName"
                        @keyup.enter.native="searchTable"></el-input>
            </div>
            <div style="line-height: 30px;">
              <el-button size="mini" type="primary" @click="searchTable">查询</el-button>
            </div>
          </div>
          <div style="line-height: 30px;">
            <el-button v-if="isDepartment && currentChangeRow && isOperation" size="small"
                       @click="batchDelete">批量删除</el-button>
            <el-button v-if="isDepartment && currentChangeRow && isOperation" size="small" type="primary"
                       @click="addTrainingPlan('add')">新增</el-button>
          </div>
        </div>
        <lims-table :tableData="inDetailPlanTableData" :column="inDetailPlanColumn"
                    :height="isDepartment ? '40vh' : '62vh' "
                    :isSelection="true" :handleSelectionChange="handleSelectionChange"
                    @pagination="pagination1"
                    :page="inDetailPagination" :tableLoading="yearDetailLoading"></lims-table>
          :height="isDepartment ? '40vh' : '62vh'" :isSelection="true" :handleSelectionChange="handleSelectionChange"
          @pagination="pagination1" :page="inDetailPagination" :tableLoading="yearDetailLoading"></lims-table>
      </div>
    </div>
    <Add ref="addPlan" :currentChangeRow="currentChangeRow" @search="getInDetailPlan(currentRowId, departId)"></Add>
    <Edit
      v-if="editPlanShow"
      ref="editPlan"
      :currentRow="currentRow"
      @del="getInDetailPlan(currentRowId, departId)"
      @goBack="goBack"
    ></Edit>
    <Edit v-if="editPlanShow" ref="editPlan" :currentRow="currentRow" @del="getInDetailPlan(currentRowId, departId)"
      @goBack="goBack"></Edit>
    <el-dialog :visible.sync="reviewDialog" title="审核" width="30%" @close="auditRemarks = ''">
      <span>
        审核备注:
@@ -69,8 +61,7 @@
      </span>
      <span style="margin-top: 10px;display: inline-block">
        批准人:
        <el-select v-model="approverId" clearable
                   filterable size="small" style="width: 70%;">
        <el-select v-model="approverId" clearable filterable size="small" style="width: 70%;">
          <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
          </el-option>
        </el-select>
@@ -92,30 +83,23 @@
    </el-dialog>
    <el-dialog :visible.sync="uploadDia" title="数据导入" width="500px">
      <div style="display: flex;align-items: center;">
        <div style="width: 70px">年份:</div>
        <el-date-picker
          v-model="planYear"
          type="year"
          value-format="yyyy"
          clearable
          size="small"
          format="yyyy"
        <div style="width: 70px"><span class="required-span">* </span>年份:</div>
        <el-date-picker v-model="planYear" type="year" value-format="yyyy" clearable size="small" format="yyyy"
          placeholder="选择年">
        </el-date-picker>
      </div>
      <div style="display: flex;align-items: center;margin: 10px 0">
        <div style="width: 70px">审核人:</div>
        <el-select v-model="reviewerId" clearable
                   filterable size="small" style="width: 50%;">
        <div style="width: 70px"><span class="required-span">* </span>审核人:</div>
        <el-select v-model="reviewerId" clearable filterable size="small" style="width: 50%;">
          <el-option v-for="item in responsibleOptions" :key="item.id" :label="item.name" :value="item.id">
          </el-option>
        </el-select>
      </div>
      <div style="margin: 0 auto;">
        <el-upload ref="upload" :action="javaApi + '/personTraining/personTrainingImport' + '?planYear=' + planYear + '&reviewerId=' + reviewerId"
                   :auto-upload="false" :before-upload="beforeUpload" :file-list="fileList" :headers="uploadHeader"
                   :limit="1" :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag
                   name="file">
        <el-upload ref="upload"
          :action="javaApi + '/personTraining/personTrainingImport' + '?planYear=' + planYear + '&reviewerId=' + reviewerId"
          :auto-upload="false" :before-upload="beforeUpload" :file-list="fileList" :headers="uploadHeader" :limit="1"
          :on-error="onError" :on-success="onSuccess" accept=".xlsx" drag name="file">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        </el-upload>
@@ -124,7 +108,7 @@
        <el-button @click="uploadDia = false">取 消</el-button>
        <el-button :loading="uploading" type="primary" @click="submitUpload()">上 传</el-button>
      </span>
    </el-dialog >
    </el-dialog>
    <view-record v-if="ViewRecord" ref="ViewRecord"></view-record>
  </div>
</template>
@@ -134,18 +118,18 @@
import Edit from '../components/Edit.vue';
import ViewRecord from "../components/ViewRecord.vue";
import limsTable from "@/components/Table/lims-table.vue";
import {mapGetters} from "vuex";
import { mapGetters } from "vuex";
import {
  approveAnnualPersonnelTraining, deleteAnnualPlanDetailTable, exportPersonTraining, exportPersonTrainingRecord,
  personTraining,
  personTrainingDelete,
  queryTheAnnualPlanDetailsTable, reviewAnnualPersonnelTraining
} from "@/api/cnas/personal/personalTraining";
import {selectUserCondition} from "@/api/system/user";
import { selectUserCondition } from "@/api/system/user";
export default {
  name: 'PersonnelTraining',
  components: {limsTable, ViewRecord, Add, Edit },
  components: { limsTable, ViewRecord, Add, Edit },
  props: {
    departId: {
      type: Number,
@@ -184,7 +168,7 @@
          label: '创建时间',
          width: '160px',
          prop: 'createTime'
        },{
        }, {
          label: '编制人',
          prop: 'compilerName'
        }, {
@@ -251,7 +235,7 @@
          formatType: (params) => {
            if (params == 1) {
              return 'success';
            } else if (params == 2)  {
            } else if (params == 2) {
              return 'danger';
            } else {
              return null
@@ -271,7 +255,7 @@
              name: '导出',
              type: 'text',
              disabled: (row) => {
                if(row.approvalStatus === 1 && row.reviewerStatus === 1) {
                if (row.approvalStatus === 1 && row.reviewerStatus === 1) {
                  return false;
                } else {
                  return true;
@@ -285,7 +269,7 @@
              name: '审核',
              type: 'text',
              disabled: (row) => {
                if(row.reviewerStatus === 1 || this.userId != row.reviewerId) {
                if (row.reviewerStatus === 1 || this.userId != row.reviewerId) {
                  return true;
                } else {
                  return false;
@@ -299,7 +283,7 @@
              name: '批准',
              type: 'text',
              disabled: (row) => {
                if(row.approvalStatus === 1 || this.userId != row.approverId || row.reviewerStatus != 1) {
                if (row.approvalStatus === 1 || this.userId != row.approverId || row.reviewerStatus != 1) {
                  return true;
                } else {
                  return false;
@@ -317,7 +301,7 @@
                this.deleteFun(row.id);
              },
              disabled: (row) => {
                if(row.reviewerStatus === 1) {
                if (row.reviewerStatus === 1) {
                  return true;
                } else {
                  return false;
@@ -328,7 +312,7 @@
        }],
      inDetailPlanTableData: [], // 年度计划明细表表数据
      inDetailPlanColumn: [
       {
        {
          label: '培训目标',
          prop: 'trainingObjectives',
          width: '100px',
@@ -442,15 +426,15 @@
          ]
        }],
      page: {
        total:0,
        size:10,
        current:1,
        total: 0,
        size: 10,
        current: 1,
        compilerName: ""
      },
      inDetailPagination: {
        total:0,
        size:10,
        current:1,
        total: 0,
        size: 10,
        current: 1,
      },
      editPlanShow: false,
      currentRow: {},
@@ -479,19 +463,19 @@
    }
  },
  methods: {
    searchTable () {
    searchTable() {
      this.getInDetailPlan(this.currentRowId)
    },
    // 查询-年度计划表
    getYearPlanList(userId) {
      this.yearLoading = true
      const params = this.isDepartment ?
      {
        departmentId: userId,
        size: this.page.size,
        current: this.page.current,
        compilerName: this.page.compilerName,
      }: {
        {
          departmentId: userId,
          size: this.page.size,
          current: this.page.current,
          compilerName: this.page.compilerName,
        } : {
          userId: userId,
          size: this.page.size,
          current: this.page.current,
@@ -509,17 +493,17 @@
        this.yearLoading = false
      })
    },
    pagination (page) {
    pagination(page) {
      this.page.size = page.limit
      this.getYearPlanList()
    },
    currentChange (row) {
    currentChange(row) {
      const now = new Date();
      const currentYear = now.getFullYear();
      if (row) {
        this.currentChangeRow = row
        this.currentRowId = row.id
        if (row.createTime.slice(0,4) == currentYear) {
        if (row.createTime.slice(0, 4) == currentYear) {
          this.isOperation = true;
        } else {
          this.isOperation = false;
@@ -527,20 +511,20 @@
        this.getInDetailPlan(row.id)
      }
    },
    getInDetailPlan (id) {
    getInDetailPlan(id) {
      if (this.inDetailForm.trainingDate === null) {
        this.inDetailForm.trainingDate = ''
      }
      const userId = this.isDepartment ? '' : this.departId
      const params =
        {
          userId: userId,
          size: this.inDetailPagination.pageSize,
          current: this.inDetailPagination.current,
          id: id,
          trainingLecturerName: this.inDetailForm.trainingLecturerName,
          trainingDate: this.inDetailForm.trainingDate,
        }
      {
        userId: userId,
        size: this.inDetailPagination.pageSize,
        current: this.inDetailPagination.current,
        id: id,
        trainingLecturerName: this.inDetailForm.trainingLecturerName,
        trainingDate: this.inDetailForm.trainingDate,
      }
      this.yearDetailLoading = true
      queryTheAnnualPlanDetailsTable(params).then(res => {
        this.yearDetailLoading = false
@@ -550,7 +534,7 @@
        this.yearDetailLoading = false
      })
    },
    pagination1 (page) {
    pagination1(page) {
      this.inDetailPagination.size = page.limit
      this.getInDetailPlan(this.currentRowId)
    },
@@ -569,7 +553,7 @@
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        personTrainingDelete({id: id}).then(res => {
        personTrainingDelete({ id: id }).then(res => {
          this.$message.success('删除成功!');
          this.getYearPlanList(this.departId);
        });
@@ -587,7 +571,7 @@
      this.getUserList()
    },
    // 提交审核
    handleReview (status) {
    handleReview(status) {
      const personTrainingUpdateDto = {
        id: this.currentRowId,
        auditRemarks: this.auditRemarks,
@@ -612,7 +596,7 @@
      this.approvalDialog = true
    },
    // 提交批准
    handleApproval (status) {
    handleApproval(status) {
      const personTrainingUpdateDto = {
        id: this.currentRowId,
        approvalRemarks: this.approvalRemarks,
@@ -632,15 +616,22 @@
    },
    // 年度计划表-下载
    downLoadPost(row) {
      exportPersonTraining({id: row.id}).then(res => {
      exportPersonTraining({ id: row.id }).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/msword' });
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, row.fileName + '.docx')
        this.$message.success('导出成功')
      })
    },
    // 年度计划-导入
    submitUpload() {
      if (!this.planYear) {
        this.$message.error('请选择年份')
        return
      }
      if (!this.reviewerId) {
        this.$message.error('请选择审核人')
        return
      }
      if (this.$refs.upload.uploadFiles.length == 0) {
        this.$message.error('未选择文件')
        return
@@ -684,7 +675,7 @@
      this.editPlanShow = false;
      this.getInDetailPlan(this.currentRowId)
    },
    viewRecord (row) {
    viewRecord(row) {
      this.ViewRecord = true
      this.$nextTick(() => {
        this.$refs.ViewRecord.openDia(row)
@@ -692,11 +683,10 @@
    },
    // 年度计划明细表-下载
    downLoadInDetail(row) {
      exportPersonTrainingRecord({id: row.id}).then(res => {
      exportPersonTrainingRecord({ id: row.id }).then(res => {
        this.outLoading = false
        const blob = new Blob([res],{ type: 'application/msword' });
        const blob = new Blob([res], { type: 'application/msword' });
        this.$download.saveAs(blob, '人员培训与考核记录.docx')
        this.$message.success('导出成功')
      })
    },
    // 年度计划明细表-多选
@@ -704,7 +694,7 @@
      this.multipleSelection = list
    },
    // 年度明细表-删除
    batchDelete () {
    batchDelete() {
      if (this.multipleSelection.length > 0) {
        let ids = []
        this.multipleSelection.forEach(item => {
@@ -715,7 +705,7 @@
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteAnnualPlanDetailTable({ids: ids.join(',')}).then(res => {
          deleteAnnualPlanDetailTable({ ids: ids.join(',') }).then(res => {
            if (res.code == 200) {
              this.$message.success('删除成功');
              this.getInDetailPlan(this.currentRowId);
@@ -776,10 +766,12 @@
  overflow: auto;
  justify-content: space-between;
}
.search {
  width: 150px;
  margin: 0 16px;
}
.title {
  position: relative;
  font-size: 16px;