黄何裕
2024-07-17 1a4493f0dd1a81d4fd021f48e47f7f3dc351dd33
src/views/system/check/result/detail/detail.vue
@@ -1,26 +1,72 @@
<template>
  <div class="app-container">
    <el-container>
      <el-main>
        <h2>考核规则</h2>
        <el-table v-loading="loading" :data="checkRuleList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="55" align="center"/>
          <el-table-column label="规则名称" align="center" prop="checkRuleName"/>
          <el-table-column label="规则权重" align="center" prop="weight"/>
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <el-row :gutter="20">
          <el-col
            :xl="3"
            :lg="3"
            :md="6"
            :sm="6"
            :xs="12"
            v-for="(item, index) in checkRuleList"
            :key="index"
            :style="item.name == '' ? 'display:none' : ''"
            class="col-margin"
          >
            <el-card
              style="
                min-width: 150px;
                width: 100%;
                height: 150px;
                text-align: center;
                margin-bottom: 20px;
              "
            >
              <div style="display: flex; flex-direction: row-reverse">
                <el-button
                  size="mini"
                  type="text"
                  icon="el-icon-edit"
                  @click="handleRuleUpdate(item)"
                  >修改
                </el-button>
              </div>
              <div style="font-size: 14px;height: 50px; font-weight: bold;">{{ item.checkRuleName }}</div>
              <div style="font-size: 14px;">规则权重:{{ item.weight }}</div>
            </el-card>
          </el-col>
        </el-row>
        <!-- <div></div>
        <el-table
          v-loading="loading"
          :data="checkRuleList"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column
            label="规则名称"
            align="center"
            prop="checkRuleName"
          />
          <el-table-column label="规则权重" align="center" prop="weight" />
          <el-table-column
            label="操作"
            align="center"
            class-name="small-padding fixed-width"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleRuleUpdate(scope.row)"
              >修改
                >修改
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        </el-table> -->
      </el-main>
    </el-container>
@@ -35,29 +81,62 @@
              icon="el-icon-download"
              size="mini"
              @click="handleExport"
            >导出
              >导出
            </el-button>
          </el-col>
          <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
          <el-form
            :model="queryParams"
            ref="queryForm"
            size="small"
            :inline="true"
            v-show="showSearch"
          >
            <el-form-item label="考核日期" prop="name">
              <el-date-picker v-model="date" format="yyyy-MM" value-format="yyyy-MM" type="month" placeholder="选择日期"
                              @change="dateChange">
              <el-date-picker
                v-model="date"
                format="yyyy-MM"
                value-format="yyyy-MM"
                type="month"
                placeholder="选择日期"
                @change="dateChange"
              >
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
              <el-button
                type="primary"
                icon="el-icon-search"
                size="mini"
                @click="handleQuery"
                >搜索</el-button
              >
            </el-form-item>
          </el-form>
        </el-row>
        <el-table v-loading="loading" :data="dataMap" @selection-change="handleSelectionChange">
          <el-table-column label="考核日期" align="center" prop="create_time" width="120px" fixed>
        <el-table
          v-loading="loading"
          :data="dataMap"
          @selection-change="handleSelectionChange"
        >
          <el-table-column
            label="考核日期"
            align="center"
            prop="create_time"
            width="120px"
            fixed
          >
            <template slot-scope="scope">
              <span>{{ scope.row.create_time.split('T')[0] }}</span>
              <span>{{ scope.row.create_time.split("T")[0] }}</span>
            </template>
          </el-table-column>
          <el-table-column label="考核对象" align="center" prop="dept_id" width="120px" fixed>
          <el-table-column
            label="考核对象"
            align="center"
            prop="dept_id"
            width="120px"
            fixed
          >
            <template slot-scope="scope">
              <span>{{ translateDeptId(scope.row.dept_id) }}</span>
            </template>
@@ -89,13 +168,27 @@
    </el-container>
    <!-- 修改考核权重对话框 -->
    <el-dialog :title="title" :visible.sync="ruleOpen" width="600px" append-to-body>
    <el-dialog
      :title="title"
      :visible.sync="ruleOpen"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="ruleForm" :rules="rules" label-width="80px">
        <el-form-item label="规则名称" prop="checkRuleName">
          <el-input v-model="ruleForm.checkRuleName" placeholder="请输入规则名称" disabled/>
          <el-input
            v-model="ruleForm.checkRuleName"
            placeholder="请输入规则名称"
            disabled
          />
        </el-form-item>
        <el-form-item label="规则权重" prop="weight">
          <el-input-number v-model="ruleForm.weight" :precision="1" :step="0.1" placeholder="请输入规则权重"/>
          <el-input-number
            v-model="ruleForm.weight"
            :precision="1"
            :step="0.1"
            placeholder="请输入规则权重"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
@@ -105,7 +198,12 @@
    </el-dialog>
    <!-- 修改考核指标对话框 -->
    <el-dialog :title="title" :visible.sync="indexOpen" width="600px" append-to-body>
    <el-dialog
      :title="title"
      :visible.sync="indexOpen"
      width="600px"
      append-to-body
    >
      <el-form ref="form" :model="indexForm" :rules="rules" label-width="150px">
        <el-form-item label="考核日期" prop="create_time">
          <el-input v-model="formattedCreateTime" placeholder="" disabled>
@@ -113,7 +211,12 @@
        </el-form-item>
        <div v-for="item in tableData" :key="item.ruleIndex">
          <el-form-item :label="item.ruleName" :prop="item.ruleIndex">
            <el-input-number v-model="indexForm[item.ruleIndex]" :precision="4" :step="0.1" placeholder="请输入指标"></el-input-number>
            <el-input-number
              v-model="indexForm[item.ruleIndex]"
              :precision="4"
              :step="0.1"
              placeholder="请输入指标"
            ></el-input-number>
          </el-form-item>
        </div>
      </el-form>
@@ -126,19 +229,24 @@
</template>
<script>
import {listScore, getScoreIndex, delScore, addScore, updateScore} from "@/api/platform/check-score";
import {updateWeight} from "@/api/platform/check-template";
import {areaSelect} from '@/api/system/dept'
import {
  listScore,
  getScoreIndex,
  delScore,
  addScore,
  updateScore,
} from "@/api/platform/check-score";
import { updateWeight } from "@/api/platform/check-template";
import { areaSelect } from "@/api/system/dept";
export default {
  name: "CheckResult",
  dicts: ['platform_audit_state'],
  dicts: ["platform_audit_state"],
  data() {
    return {
      id: null,
      examineCategory: null,
      date: '',
      date: "",
      examineTag: null,
      deptId: null,
      areaList: [],
@@ -146,7 +254,7 @@
      dataMap: [],
      manualScoreOpen: false,
      manualScoreForm: {},
      manualScoreTitle: '',
      manualScoreTitle: "",
      // 遮罩层
      loading: true,
      // 选中数组
@@ -178,19 +286,21 @@
        date: null,
      },
      // 表单校验
      rules: {}
      rules: {},
    };
  },
  computed: {
    formattedCreateTime() {
      // 如果 create_time 存在,则返回日期部分,否则返回空字符串
      return this.indexForm.create_time ? this.indexForm.create_time.split('T')[0] : '';
      return this.indexForm.create_time
        ? this.indexForm.create_time.split("T")[0]
        : "";
    },
  },
  created() {
    //考核成绩详情跳转参数接收
    if (this.$route.query.id) {
      this.queryParams.id = this.$route.query.id
      this.queryParams.id = this.$route.query.id;
    }
    // 考核积分列表
    this.getList();
@@ -200,10 +310,10 @@
    /** 查询考核计分列表 */
    getList() {
      this.loading = true;
      getScoreIndex(this.queryParams).then(response => {
      getScoreIndex(this.queryParams).then((response) => {
        this.checkRuleList = response.data.checkRuleList;
        this.dataMap = response.data.scoreMap.dataMap;
        this.tableData = response.data.scoreMap.tableData
        this.tableData = response.data.scoreMap.tableData;
        this.loading = false;
      });
    },
@@ -224,18 +334,25 @@
      this.resetForm(formName);
    },
    translateDeptId(deptId) {
      const department = this.areaList.find(dept => dept.id == deptId);
      return department ? department.value : '未知';
      const department = this.areaList.find((dept) => dept.id == deptId);
      return department ? department.value : "未知";
    },
    // 区域下拉数据
    areaSelect() {
      areaSelect().then(res => {
      areaSelect().then((res) => {
        this.areaList = res.data;
      })
      });
    },
    /** 返回按钮 */
    goBack() {
      const obj = { path: "/check/detail", query: { index: this.$route.query.deptId, examineTag: this.$route.query.examineTag, pageNum: this.$route.query.pageNum } };
      const obj = {
        path: "/check/detail",
        query: {
          index: this.$route.query.deptId,
          examineTag: this.$route.query.examineTag,
          pageNum: this.$route.query.pageNum,
        },
      };
      this.$tab.closeOpenPage(obj);
    },
    // 关闭当前tab页签,打开新页签
@@ -262,9 +379,9 @@
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
@@ -288,10 +405,10 @@
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.ruleForm.id != null) {
            updateWeight(this.ruleForm).then(response => {
            updateWeight(this.ruleForm).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.ruleOpen = false;
              this.getList();
@@ -302,21 +419,22 @@
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('/check/score/export', {
        ...this.queryParams
      }, `考核指标_${new Date().getTime()}.xlsx`)
      this.download(
        "/check/score/export",
        {
          ...this.queryParams,
        },
        `考核指标_${new Date().getTime()}.xlsx`
      );
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
  }
  },
};
</script>
<style scoped>
.header-container h2 {
  margin-right: 10px; /* 根据需要调整标题和菜单之间的间距 */
}
</style>