董国庆
2025-12-09 332e2e6cd982c2d71028798f535a94d7b9c55b91
laboratory/src/views/dataManagement/testResultReport/list.vue
@@ -1,16 +1,32 @@
<template>
  <div class="list">
    <TableCustom :queryForm="form" :tableData="tableData" :total="total" :height="null" @handlePageChange="handlePageChange" @handleSizeChange="handleSizeChange">
    <TableCustom
      :queryForm="form"
      :tableData="tableData"
      :total="total"
      :height="null"
      @handlePageChange="handlePageChange"
      @handleSizeChange="handleSizeChange"
    >
      <template #search>
        <el-form :model="form" labelWidth="auto" inline>
          <el-form-item label="所属项目课题方案:">
            <el-input v-model="form.projectName" placeholder="请输入"></el-input>
            <el-input
              v-model="form.projectName"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item label="实验编号:">
            <el-input v-model="form.experimentCode" placeholder="请输入"></el-input>
            <el-input
              v-model="form.experimentCode"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item label="实验名称:">
            <el-input v-model="form.experimentName" placeholder="请输入"></el-input>
            <el-input
              v-model="form.experimentName"
              placeholder="请输入"
            ></el-input>
          </el-form-item>
          <el-form-item label="创建日期:">
            <el-date-picker
@@ -34,7 +50,12 @@
          </el-form-item>
          <el-form-item label="">
            <el-button type="default" @click="resetForm">重置</el-button>
            <el-button type="primary" style="margin-left: 10px;" @click="handleSearch">查询</el-button>
            <el-button
              type="primary"
              style="margin-left: 10px"
              @click="handleSearch"
              >查询</el-button
            >
          </el-form-item>
        </el-form>
      </template>
@@ -57,34 +78,69 @@
              草稿箱
            </div>
          </div>
          <el-button v-if="isProcessEngineer" @click="handleAddResult" class="el-icon-plus" type="primary">
          <el-button
            v-if="isProcessEngineer"
            @click="handleAddResult"
            class="el-icon-plus"
            type="primary"
          >
            新增实验结果汇报
          </el-button>
        </div>
      </template>
      <template #table>
        <el-table-column prop="projectName" label="所属项目课题方案"></el-table-column>
        <el-table-column prop="experimentCode" label="实验编号"></el-table-column>
        <el-table-column prop="experimentName" label="实验名称"></el-table-column>
        <el-table-column prop="processEngineerName" label="工艺工程师"></el-table-column>
        <el-table-column prop="laboratoryChemistName" label="化验师"></el-table-column>
        <el-table-column
          prop="projectName"
          label="所属项目课题方案"
        ></el-table-column>
        <el-table-column
          prop="experimentCode"
          label="实验编号"
        ></el-table-column>
        <el-table-column
          prop="experimentName"
          label="实验名称"
        ></el-table-column>
        <el-table-column
          prop="processEngineerName"
          label="工艺工程师"
        ></el-table-column>
        <el-table-column
          prop="laboratoryChemistName"
          label="化验师"
        ></el-table-column>
        <el-table-column prop="laboratoryChemistEvaluate" label="是否评定">
          <template slot-scope="scope">
            <el-tag :type="scope.row.laboratoryChemistEvaluate === 1 ? 'success' : 'danger'">
              {{ scope.row.laboratoryChemistEvaluate === 1 ? '是' : '否' }}
            <el-tag
              :type="
                scope.row.laboratoryChemistEvaluate === 1 ? 'success' : 'danger'
              "
            >
              {{ scope.row.laboratoryChemistEvaluate === 1 ? "是" : "否" }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="experimenterName" label="实验员"></el-table-column>
        <el-table-column
          prop="experimenterName"
          label="实验员"
        ></el-table-column>
        <el-table-column prop="experimenterEvaluate" label="是否评定">
          <template slot-scope="scope">
            <el-tag :type="scope.row.experimenterEvaluate === 1 ? 'success' : 'danger'">
              {{ scope.row.experimenterEvaluate === 1 ? '是' : '否' }}
            <el-tag
              :type="
                scope.row.experimenterEvaluate === 1 ? 'success' : 'danger'
              "
            >
              {{ scope.row.experimenterEvaluate === 1 ? "是" : "否" }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="createTime" label="创建日期" width="180"></el-table-column>
        <el-table-column
          prop="createTime"
          label="创建日期"
          width="180"
        ></el-table-column>
        <el-table-column prop="status" label="状态">
          <template slot-scope="scope">
            <el-tag :type="getStatusType(scope.row.status)">
@@ -97,55 +153,92 @@
            <template v-if="currentType === 'list'">
              <template v-if="isProcessEngineer">
                <template v-if="scope.row.status === 1">
                  <el-button type="text" @click="handleSubmit(scope.row)">提交</el-button>
                  <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
                  <el-button type="text" @click="handleDetail(scope.row.id)">详情</el-button>
                  <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
                  <el-button type="text" @click="handleSubmit(scope.row)"
                    >提交</el-button
                  >
                  <el-button type="text" @click="handleEdit(scope.row)"
                    >编辑</el-button
                  >
                  <el-button type="text" @click="handleDetail(scope.row.id)"
                    >详情</el-button
                  >
                  <el-button type="text" @click="handleDelete(scope.row)"
                    >删除</el-button
                  >
                </template>
                <!-- <template v-else-if="scope.row.status === 2">
                  <el-button type="text" @click="handleDetail(scope.row.id)">详情</el-button>
                </template> -->
                <template v-else>
                  <el-button type="text" @click="handleDetail(scope.row.id)">详情</el-button>
                  <el-button type="text" @click="handleDetail(scope.row.id)"
                    >详情</el-button
                  >
                </template>
              </template>
              <template v-else>
                <el-button type="text" @click="handleDetail(scope.row.id)">详情</el-button>
                <el-button
                  v-if="scope.row.status === 2"
                  type="text"
                <el-button type="text" @click="handleDetail(scope.row.id)"
                  >详情</el-button
                >
                <el-button
                  v-if="scope.row.status === 2"
                  type="text"
                  @click="handleEvaluate(scope.row)"
                >评定</el-button>
                  >评定</el-button
                >
                  <el-button
                    slot="reference"
                    v-if="scope.row.status === 2"
                    type="text"
                    @click="handleReturn(scope.row)"
                    >驳回</el-button
                  >
              </template>
            </template>
            <template v-else>
              <el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
              <el-button type="text" @click="handleDelete(scope.row)">删除</el-button>
              <el-button type="text" @click="handleEdit(scope.row)"
                >编辑</el-button
              >
              <el-button type="text" @click="handleDelete(scope.row)"
                >删除</el-button
              >
            </template>
          </template>
        </el-table-column>
      </template>
    </TableCustom>
    <ShowDelConfirm
      :title="changeStatusTitle"
      :tip="changeStatusTip"
    <ShowDelConfirm
      :title="changeStatusTitle"
      :tip="changeStatusTip"
      :show="changeStatus"
      @close="changeStatus = false"
      @confirm="handleChangeStatusConfirm"
      @close="changeStatus = false"
      @confirm="handleChangeStatusConfirm"
    />
    <!-- 评价弹窗 -->
    <evaluation-dialog
      :modelValue="evaluationDialogVisible"
    <evaluation-dialog
      :modelValue="evaluationDialogVisible"
      :type="'processEngineer'"
      :viewJson="currentEvaluationData"
      :viewJson="currentEvaluationData"
      @update:modelValue="updateEvaluationDialogVisible"
      @submit="handleEvaluationSubmit"
      @submit="handleEvaluationSubmit"
    />
    <el-dialog top="40vh" :visible.sync="returnDialogVisible" :show-close="false" :append-to-body="true"
            :close-on-click-modal="false" width="433px">
            <div class="dialog-title" slot="title">驳回</div>
            <el-form ref="form" :model="formReturn" label-width="80px">
                <el-form-item label="驳回原因" :rules="[{required: true, message: '请输入驳回原因', trigger: 'blur'}]">
                    <el-input type="textarea" v-model="formReturn.reason" placeholder="请输入驳回原因" />
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="returnDialogVisible=false">取消</el-button>
                <el-button type="primary" @click="handleChangeStatusConfirm" style="margin-left: 20px;">确定</el-button>
            </span>
        </el-dialog>
  </div>
</template>
<script>
import { getList,deleteById,commit,evaluateProcess } from './service';
import { getList, deleteById, commit, evaluateProcess ,rejectResult} from "./service";
import ShowDelConfirm from "@/components/showDelConfirm/index.vue";
import EvaluationDialog from "./components/evaluation-dialog.vue";
import moment from "moment";
@@ -154,7 +247,7 @@
  name: "TestResultReport",
  components: {
    ShowDelConfirm,
    EvaluationDialog
    EvaluationDialog,
  },
  data() {
    return {
@@ -168,7 +261,7 @@
        endTime: "",
        status: "",
        pageNum: 1,
        pageSize: 10
        pageSize: 10,
      },
      tableData: [],
      total: 0,
@@ -177,17 +270,23 @@
      changeStatusTitle: "",
      changeStatusTip: "",
      currentOperationRow: null,
      currentOperationType: '',
      currentOperationType: "",
      // 评价弹窗相关数据
      evaluationDialogVisible: false,
      currentEvaluationData: null,
      // 驳回
      returnDialogVisible: false,
      formReturn:{
        reason: ""
      }
    };
  },
  computed: {
    isProcessEngineer() {
      const userInfo = JSON.parse(sessionStorage.getItem('userInfo') || '{}');
      const userInfo = JSON.parse(sessionStorage.getItem("userInfo") || "{}");
      return userInfo.roleType === 3; // 3是工艺工程师
    }
    },
  },
  created() {
    this.getTableData();
@@ -202,7 +301,7 @@
        endTime: "",
        status: "",
        pageNum: 1,
        pageSize: 10
        pageSize: 10,
      };
      this.dateRange = [];
      this.getTableData();
@@ -213,42 +312,47 @@
    handleAddResult() {
      this.$router.push({
        path: "/dataManagement/testResultReport/detail",
        query: {
          type: 'add'
        }
        query: {
          type: "add",
        },
      });
    },
    handleEdit(row) {
      this.$router.push({
        path: "/dataManagement/testResultReport/detail",
        query: {
        query: {
          id: row.id,
          type: 'edit'
        }
          type: "edit",
        },
      });
    },
    handleDetail(id) {
      this.$router.push({
        path: "/dataManagement/testResultReport/detail",
        query: {
        query: {
          id: id,
          type: 'view'
        }
          type: "view",
        },
      });
    },
    handleSubmit(row) {
      this.currentOperationRow = row;
      this.currentOperationType = 'submit';
      this.currentOperationType = "submit";
      this.changeStatusTitle = "确认提交?";
      this.changeStatusTip = "提交之后无法再次编辑";
      this.changeStatus = true;
    },
    handleDelete(row) {
      this.currentOperationRow = row;
      this.currentOperationType = 'delete';
      this.currentOperationType = "delete";
      this.changeStatusTitle = "确认要删除这条信息吗?";
      this.changeStatusTip = "删除后信息无法找回";
      this.changeStatus = true;
    },
    handleReturn(row) {
      this.currentOperationRow = row;
      this.currentOperationType = "return";
      this.returnDialogVisible = true;
    },
    handleEvaluate(row) {
      this.currentOperationRow = row;
@@ -261,50 +365,52 @@
    getTableData() {
      const params = {
        ...this.form,
        status: this.currentType === 'draft' ? -1 : this.form.status
        status: this.currentType === "draft" ? -1 : this.form.status,
      };
      getList(params).then(res => {
        if (res.code === 200) {
          this.tableData = res.data.records || [];
          this.total = res.data.total || 0;
        } else {
          // this.$message.error(res.msg || '获取数据失败');
        }
      }).catch(err => {
        // this.$message.error('获取数据失败');
      });
      getList(params)
        .then((res) => {
          if (res.code === 200) {
            this.tableData = res.data.records || [];
            this.total = res.data.total || 0;
          } else {
            // this.$message.error(res.msg || '获取数据失败');
          }
        })
        .catch((err) => {
          // this.$message.error('获取数据失败');
        });
    },
    handleDateChange(val) {
      if (val) {
        this.form.startTime = val[0];
        this.form.endTime = val[1];
      } else {
        this.form.startTime = '';
        this.form.endTime = '';
        this.form.startTime = "";
        this.form.endTime = "";
      }
    },
    getStatusType(status) {
      const statusMap = {
        '-1': 'info',
        '1': 'warning',
        '2': 'warning',
        '3': 'success',
        '4': 'info',
        '5': 'warning'
        "-1": "info",
        1: "warning",
        2: "warning",
        3: "success",
        4: "info",
        5: "warning",
      };
      return statusMap[status] || 'info';
      return statusMap[status] || "info";
    },
    getStatusText(status) {
      const statusMap = {
        '-1': '草稿箱',
        '1': '待提交',
        '2': '待评定',
        '3': '已评定',
        '4': '已封存',
        '5': '已解封'
        "-1": "草稿箱",
        1: "待提交",
        2: "待评定",
        3: "已评定",
        4: "已封存",
        5: "已解封",
      };
      return statusMap[status] || '未知';
      return statusMap[status] || "未知";
    },
    handlePageChange(pageNum) {
      this.form.pageNum = pageNum;
@@ -316,31 +422,53 @@
    },
    handleChangeStatusConfirm() {
      if (!this.currentOperationRow) return;
      if (this.currentOperationType === 'submit') {
        commit({ id: this.currentOperationRow.id }).then(res => {
          if (res) {
            this.$message.success('提交成功');
            this.changeStatus = false;
            this.getTableData();
          } else {
            this.$message.error(res.msg || '提交失败');
          }
        }).catch(err => {
          this.$message.error('提交失败');
        });
      } else if (this.currentOperationType === 'delete') {
        deleteById({ id: this.currentOperationRow.id }).then(res => {
          if (res) {
            this.$message.success('删除成功');
            this.changeStatus = false;
            this.getTableData();
          } else {
            this.$message.error(res.msg || '删除失败');
          }
        }).catch(err => {
          this.$message.error('删除失败');
        });
      if(this.currentOperationType === "return" && !this.formReturn.reason){
        this.$message.error("请填写驳回理由");
        return;
      }
      if (this.currentOperationType === "submit") {
        commit({ id: this.currentOperationRow.id })
          .then((res) => {
            if (res) {
              this.$message.success("提交成功");
              this.changeStatus = false;
              this.getTableData();
            } else {
              this.$message.error(res.msg || "提交失败");
            }
          })
          .catch((err) => {
            this.$message.error("提交失败");
          });
      } else if (this.currentOperationType === "delete") {
        deleteById({ id: this.currentOperationRow.id })
          .then((res) => {
            if (res) {
              this.$message.success("删除成功");
              this.changeStatus = false;
              this.getTableData();
            } else {
              this.$message.error(res.msg || "删除失败");
            }
          })
          .catch((err) => {
            this.$message.error("删除失败");
          });
      }else if (this.currentOperationType === "return") {
        rejectResult({ resultReportId: this.currentOperationRow.id,rejectRemark:this.formReturn.reason })
          .then((res) => {
            if (res) {
              this.$message.success("驳回成功");
              this.returnDialogVisible = false;
              this.getTableData();
            } else {
              this.$message.error(res.msg || "驳回失败");
            }
          })
          .catch((err) => {
            this.$message.error("驳回失败");
          });
      }
    },
    // 更新弹窗显示状态
@@ -362,23 +490,25 @@
        evaluateFour: this.getEvaluateValue(activeIndex[3].score),
        evaluateFive: this.getEvaluateValue(activeIndex[4].score),
        evaluateSix: this.getEvaluateValue(activeIndex[5].score),
        evaluateTime: moment().format('YYYY-MM-DD HH:mm:ss'),
        evaluateTime: moment().format("YYYY-MM-DD HH:mm:ss"),
        resultEvaluateJson: JSON.stringify(activeIndex),
        resultReportId: this.currentOperationRow.id,
        dispatchId: this.currentOperationRow.dispatchId,
        status: 1
        status: 1,
      };
      evaluateProcess(evaluateData).then(res => {
        if (res.code == 200) {
          this.$message.success('评定成功');
          this.evaluationDialogVisible = false;
          this.getTableData(); // 重新获取列表数据
        } else {
          this.$message.error(res.msg || '评定失败');
        }
      }).catch(err => {
        this.$message.error('评定失败');
      });
      evaluateProcess(evaluateData)
        .then((res) => {
          if (res.code == 200) {
            this.$message.success("评定成功");
            this.evaluationDialogVisible = false;
            this.getTableData(); // 重新获取列表数据
          } else {
            this.$message.error(res.msg || "评定失败");
          }
        })
        .catch((err) => {
          this.$message.error("评定失败");
        });
    },
    // 将分数转换为评定值
    getEvaluateValue(score) {
@@ -386,11 +516,11 @@
      const scoreMap = {
        2: 1, // 良好
        1: 2, // 正确
        0: 3  // 失误
        0: 3, // 失误
      };
      return scoreMap[score] || 3; // 默认返回失误
    }
  }
    },
  },
};
</script>
@@ -407,7 +537,8 @@
  padding-bottom: 20px;
  justify-content: space-between;
  align-items: center;
  .title, .drafts {
  .title,
  .drafts {
    background: #fafafc;
    border-radius: 8px 8px 0px 0px;
    border: 1px solid #dcdfe6;