小猫咪心好痛 2022-10-17 17:48 采纳率: 88.9%
浏览 28
已结题

<rate组件后台数据回显并修改

怎么让存到数据库中的分值回显并能进行修改,现在是分数显示出来了,但是评分修改了之后分值不变

img


<template>
  <el-dialog @close="closeEvaluation" :workBaseId="workBaseId" :evaluationOption = "evaluationOption"
             :visible="evaluationOpen" :title="title" width="50%" append-to-body destroy-on-close
             :close-on-click-modal="false" center class="DialogStyle DialogInputStyle" v-if="evaluationOpen">
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-collapse v-model="activeNames">
        <el-collapse-item name="1">
        <template #title>
          <img src="@/assets/images/by.png" alt="" style="margin-left: -25px;height: 18px;padding-right: 25px">作业评价
        </template>
        <div>
           <li v-for="(item, index) in evaluationList" style="display: flex; justify-content: space-around;" v-if="item.workCategory === null||item.workCategory === ''||item.workCategory === '1'">

            <div style="width: 200px;font-size:15px">
              {{item.workScoringItems}}
            </div>
              <div style="margin-left: 10px;width: 200px">
              <el-rate
                v-model="item.value"
                @change="changeValue(index,item.value,item.workUuid,item.workCategoriesScore)"
                text-color="#ff9900">
              </el-rate>
              </div>
             <span>分值:</span>
             <span>{{scoreValue[index]=item.evaluationScore}}</span>
          </li>
        </div>
        </el-collapse-item>
          <el-collapse-item name="2" >
            <template #title>
              <img src="@/assets/images/by.png" alt="" style="margin-left: -25px;height: 18px;padding-right: 25px">作业内容
            </template>
        <div class="remarkBox" style="padding: 0 1% 0" >
          <el-input v-model="form.evalutionContent" type="textarea" style="text-align: center ; padding: 5px 15px;" :autosize="{ minRows: 7}"
                    resize="none"
                    :maxlength="600" placeholder="请输入内容"
                    ref="masklayer"
          />
        </div>
        </el-collapse-item>
        </el-collapse>
        </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="closeEvaluation">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>

import {getEvaluation, listNoPage} from "@/api/special/safety/evaluation";
import {addRecords, baseRecords, getRecords, listRecords, updateRecords} from "@/api/special/safety/records";
import {
  getBreakgroundInfo,
  getBreakInfo,
  getConfinedInfo,
  getElectricityInfo, getHighworkInfo, getHoistingInfo,
  getHotWorkInfo, getPluggingInfo
} from "@/api/special/safety/workBaseinfo";


export default {
  name: "index",
  props: {
    evaluationOpen: {
      type: Boolean,
      default: false
    },
    workBaseId: {
      type: String,
      default: null
    },
    evaluationOption:{
      type:String,   //0 更新,1新增
      default: null
    },
    width: {
      type: String,
      default: "70%"
    },
    title: {
      type: String,
      default: "作业评价"
    }
  },
  data() {
    return {
      activeNames: ['1', '2'],
      detail: null,
      value:3,
      scoreValue:[],
      // 作业评价设置表格数据
      evaluationList: [],
      workScoringItems:[],
      updateList:[],
      // 评价记录表格数据
      recordsList: [],
      // 评价记录子表格数据
      specialSafetymanaEvaluationRecordsChildList:[],
      // 表单参数
      form: {
        evalutionContent:''
      },
      // 表单校验
      rules: {
        workScoringItems: [],
        workCategoriesScore: [],
      }
    }
  },
  watch: {
    evaluationOpen(val) {
      console.log(123);
      console.log('val:',val);
      if (val) {
        console.log(456);
        console.log('this.evaluationOption:',this.evaluationOption);
        this.evaluationOpen = true;
        this.getList();
        this.reset();
      }
    },
  },
  created(){
    this.getList();
  },
  methods: {
    reset() {
      this.form = {
        evalutionContent: null
      };
      this.detail = null;
      this.evaluationList = []
      this.value=[];
      this.scoreValue=[];
    },
    /** 查询作业评价设置列表 */
    getList() {
        listNoPage().then(response => {
          console.log('response:', response)
          this.evaluationList = response.data;
          console.log('evaluationList', this.evaluationList)
          this.loading = false;
          if(this.evaluationOption=='0'){
          this.getUpdataList(this.workBaseId);
          console.log('this.workBaseId',this.workBaseId);
          }
        })
    },
    getUpdataList(workBaseId){
        console.log('workBaseId2', workBaseId);
        baseRecords(workBaseId).then(response => {
          console.log('dfssfdff', response);
          this.form.evalutionContent = response.data[0].evalutionContent;
          this.form.uuid = response.data[0].subUuid;
          console.log('qqqqqq1', this.evaluationList);
          response.data.forEach(items => {
            this.evaluationList.forEach(item => {
              if (items.subWorkUuid == item.workUuid) {
                item.workScoringItems = items.item;
                item.evaluationScore = items.subEvaluationScore;
                item.value = (item.evaluationScore) / (item.workCategoriesScore);
              }
            })
          })
          console.log(' this.form', this.form);
        })
      },
    closeEvaluation() {
      this.reset();
      this.$emit("closeEvaluation");
    },
    changeValue(index,value1,workUuid,value2){
      console.log("第几行",index)
      console.log('选择第几个星星:',value1);
      console.log('分值:',value2);
      console.log('workUuid:',workUuid);
      let thisScore = parseInt(value1)*parseInt(value2);
      this.scoreValue[index] = thisScore;
      let sum = 0;
      for( let i=0;i<this.scoreValue.length;i++){
        if(this.scoreValue[i] != undefined) {
          sum += this.scoreValue[i];
        }
      }
      this.totalScore = sum;
      console.log('sum:',sum);
      let obj = {};
      obj.evaluationScore = thisScore;
      obj.workUuid = workUuid;
      this.specialSafetymanaEvaluationRecordsChildList.push(obj);
      console.log('scords',this.specialSafetymanaEvaluationRecordsChildList);
    },
    /** 提交按钮 */
    submitForm() {
      this.form.workBaseId = this.workBaseId;
      this.form.specialSafetymanaEvaluationRecordsChildList = this.specialSafetymanaEvaluationRecordsChildList;
      this.form.totalScore = this.totalScore;
      console.log('this.form',this.form);
      // if(this.evaluationOption == 1 ) {
      //   addRecords(this.form).then(response => {
      //     this.$modal.msgSuccess("评价成功");
      //     console.log('chenggong', response.code);
      //     if (response.code === 200) {
      //       this.closeEvaluation();
      //     }
      //     this.getList();
      //   });
      // }
      // if(this.evaluationOption == 0){
        updateRecords(this.form).then(response => {
          this.$modal.msgSuccess("更新成功");
          console.log('chenggong2', response.code);
          if (response.code === 200) {
            this.closeEvaluation();
          }
          this.getList();
        });
      // }
  }
  }
}
</script>

  • 写回答

1条回答 默认 最新

  • 爱新觉罗·苟子 2022-10-18 09:48
    关注

    img


    这里改成 {{scoreValue[index]}}

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 10月27日
  • 已采纳回答 10月19日
  • 创建了问题 10月17日

悬赏问题

  • ¥30 STM32 INMP441无法读取数据
  • ¥100 求汇川机器人IRCB300控制器和示教器同版本升级固件文件升级包
  • ¥15 用visualstudio2022创建vue项目后无法启动
  • ¥15 x趋于0时tanx-sinx极限可以拆开算吗
  • ¥500 把面具戴到人脸上,请大家贡献智慧
  • ¥15 任意一个散点图自己下载其js脚本文件并做成独立的案例页面,不要作在线的,要离线状态。
  • ¥15 各位 帮我看看如何写代码,打出来的图形要和如下图呈现的一样,急
  • ¥30 c#打开word开启修订并实时显示批注
  • ¥15 如何解决ldsc的这条报错/index error
  • ¥15 VS2022+WDK驱动开发环境