riku
2025-09-19 58c0f11fe2f23a1be2dec768f9ac02107301a634
src/views/fysp/evaluation/EvalutationRecord.vue
@@ -23,7 +23,11 @@
        v-model:value="formSearch.scenetype"
      ></FYOptionScene>
      <!-- 时间 -->
      <FYOptionTime :initValue="false" type="month" v-model:value="formSearch.time"></FYOptionTime>
      <FYOptionTime
        :initValue="false"
        type="month"
        v-model:value="formSearch.time"
      ></FYOptionTime>
    </template>
    <template #buttons>
      <!-- <el-button icon="Download" size="default" type="success" @click="download"
@@ -42,10 +46,21 @@
      </el-form>
    </template>
    <template #table-column>
      <el-table-column fixed="left" sortable="custom" prop="sceneIndex" label="编号" width="80">
    <template #table-column="{ size }">
      <el-table-column
        fixed="left"
        sortable="custom"
        prop="sceneIndex"
        label="编号"
        width="80"
      >
      </el-table-column>
      <el-table-column prop="sceneName" :show-overflow-tooltip="true" label="名称" width="300">
      <el-table-column
        prop="sceneName"
        :show-overflow-tooltip="true"
        label="名称"
        width="300"
      >
      </el-table-column>
      <el-table-column
        prop="subTaskTime"
@@ -54,10 +69,21 @@
        sortable="custom"
        :formatter="timeFormat"
      />
      <el-table-column prop="evaluation.resultscorebef" label="得分" width="90" sortable="custom" />
      <el-table-column prop="evaluation.resultscorebef" label="环信码" width="100">
      <el-table-column
        prop="evaluation.resultscorebef"
        label="得分"
        width="90"
        sortable="custom"
      />
      <el-table-column
        prop="evaluation.resultscorebef"
        label="环信码"
        width="100"
      >
        <template #default="{ row }">
          <span :style="`color: ${toCode(row).color};`">{{ toCode(row).name }}</span>
          <span :style="`color: ${toCode(row).color};`">{{
            toCode(row).name
          }}</span>
        </template>
      </el-table-column>
@@ -72,24 +98,58 @@
      <el-table-column prop="evaluation.scenseaddress" label="地址" />
      <!-- <el-table-column prop="biArea" label="集中区" width="110" />
      <el-table-column prop="biManagementCompany" label="物业" min-width="110"/> -->
      <el-table-column fixed="right" align="right" label="监测数据超标" width="160">
      <el-table-column
        v-if="scoreShow"
        fixed="right"
        align="right"
        label="监测数据超标"
        width="160"
      >
        <template #default="{ row }">
          <el-input v-model="row.score1" />
          <el-input :size="size" v-model="row.score1" />
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="right" label="监测数据超区月均值" width="160">
      <el-table-column
        v-if="scoreShow"
        fixed="right"
        align="right"
        label="监测数据超区月均值"
        width="160"
      >
        <template #default="{ row }">
          <el-input v-model="row.score2" />
          <el-input :size="size" v-model="row.score2" />
        </template>
      </el-table-column>
      <el-table-column fixed="right" align="right" label="操作" width="160">
        <!-- <template #header>
          <el-button icon="Download" size="default" type="success" @click="exportExcel"
            >导出结果</el-button
        <template #header>
          <el-button
            v-show="!scoreShow"
            icon="ArrowLeft"
            size="small"
            type="success"
            @click="scoreShow = true"
            >监测数据得分</el-button
          >
        </template> -->
          <el-button
            v-show="scoreShow"
            size="small"
            type="primary"
            @click="updateMultipleScore"
            :loading="updateLoading"
            >上传</el-button
          >
          <el-button
            v-show="scoreShow"
            size="small"
            type="error"
            @click="scoreShow = false"
            >取消</el-button
          >
        </template>
        <template #default="{ row }">
          <el-button type="primary" size="small" @click="editRow(row)">查看</el-button>
          <el-button type="primary" size="small" @click="editRow(row)"
            >查看</el-button
          >
        </template>
      </el-table-column>
    </template>
@@ -103,15 +163,29 @@
import CompReport from './components/CompReport.vue';
import { useTablePaste } from '@/composables/tablePaste';
import { useCloned } from '@vueuse/core';
import { useMessageBoxTip } from '@/composables/messageBox';
export default {
  setup() {
    const { cellClick, cellClassName, handlePaste, setTableData, addRefreshEvent, tableData } =
      useTablePaste({
        score1: 8,
        score2: 9
      });
    return { cellClick, cellClassName, handlePaste, setTableData, addRefreshEvent, tableData };
    const {
      cellClick,
      cellClassName,
      handlePaste,
      setTableData,
      addRefreshEvent,
      tableData
    } = useTablePaste({
      score1: 8,
      score2: 9
    });
    return {
      cellClick,
      cellClassName,
      handlePaste,
      setTableData,
      addRefreshEvent,
      tableData
    };
  },
  components: { CompReport },
  data() {
@@ -123,11 +197,26 @@
      },
      townFilters: [],
      // 原始数据,用于排序取消后
      orginData: []
      orginData: [],
      evaluationRule: undefined,
      evaluationSubRule: undefined,
      //监测数据规则名称
      ruleName: {
        score1: {
          id: undefined,
          name: '监测数据出现单日及以上有效超标'
        },
        score2: {
          id: undefined,
          name: '监测数据月均值超区域月均值20%以上或数据明显异常'
        }
      },
      scoreShow: false,
      updateLoading: false
    };
  },
  methods: {
    _getParam() {
  computed: {
    area() {
      const { locations, scenetype, time } = this.formSearch;
      return {
        provincecode: locations.pCode,
@@ -139,7 +228,22 @@
        starttime: dayjs(time).format('YYYY-MM-DD HH:mm:ss'),
        scensetypeid: scenetype.value
      };
    },
    }
  },
  methods: {
    // _getParam() {
    //   const { locations, scenetype, time } = this.formSearch;
    //   return {
    //     provincecode: locations.pCode,
    //     provincename: locations.pName,
    //     citycode: locations.cCode,
    //     cityname: locations.cName,
    //     districtcode: locations.dCode,
    //     districtname: locations.dName,
    //     starttime: dayjs(time).format('YYYY-MM-DD HH:mm:ss'),
    //     scensetypeid: scenetype.value
    //   };
    // },
    editRow(row) {
      this.$router.push(`evalutationEdit/${row.subTaskId}`);
    },
@@ -151,23 +255,106 @@
    },
    onSearch(page, func) {
      this.$refs.tableRef.clearSort();
      const area = this._getParam();
      evaluateApi.fetchAutoEvaluation(area).then((res) => {
        if (res.data) {
          this.tableData = res.data;
          this.orginData = useCloned(this.tableData).cloned;
          console.log(this.orginData);
          this.getFilters(res.data);
          if (typeof func === 'function') {
            func({ data: this.tableData });
      this.fetchEvaluationRule(this.area).then(() => {
        evaluateApi.fetchAutoEvaluation(this.area).then((res) => {
          if (res.data) {
            this.tableData = res.data;
            this.tableData.forEach((v) => {
              // 将原始的得分展示到表格中
              if (v.itemEvaluations) {
                for (const key in this.ruleName) {
                  const value = this.ruleName[key];
                  const itemEva = v.itemEvaluations.find((ie) => {
                    return ie.esrguid == value.id && ie.extension1 == 'true';
                  });
                  if (itemEva) {
                    v[key] = itemEva.value;
                  }
                }
              }
            });
            this.orginData = useCloned(this.tableData).cloned;
            this.getFilters(res.data);
            if (typeof func === 'function') {
              func({ data: this.tableData });
            }
          } else {
            this.tableData = [];
            this.orginData = [];
            if (typeof func === 'function') {
              func({ data: this.tableData });
            }
          }
        });
      });
    },
    fetchEvaluationRule() {
      const param = {
        // 自动评估类型
        taskTypeId: 99,
        ...this.area
      };
      // 获取评估总规则
      return evaluateApi.fetchEvaluationRule(param).then((res) => {
        if (res.data.length > 0) {
          this.evaluationRule = res.data[0];
          // 获取具体子规则
          return evaluateApi
            .getSubRules(this.evaluationRule.guid)
            .then((res) => {
              this.evaluationSubRule = res.data;
              // 查找可导入得分的规则id
              for (const key in this.ruleName) {
                const value = this.ruleName[key];
                const subrule = this.evaluationSubRule.find((v) => {
                  return v.itemname == value.name;
                });
                if (subrule) {
                  value.id = subrule.guid;
                }
              }
            });
        }
      });
    },
    // 批量更新监测数据得分
    updateMultipleScore() {
      this.updateLoading = true;
      useMessageBoxTip({
        confirmMsg: '是否上传监测数据得分',
        confirmTitle: '上传监测数据得分',
        onConfirm: async () => {
          if (this.evaluationRule) {
            const subTaskEvaList = this.tableData.map((v) => {
              const subRule = [];
              for (const key in this.ruleName) {
                const value = this.ruleName[key];
                subRule.push({
                  id: value.id,
                  selected: v[key] && (v[key] + '').trim() != ''
                });
              }
              return {
                subTaskId: v.subTaskId,
                ruleId: this.evaluationRule.guid,
                subRule
              };
            });
            const param = {
              ...this.area,
              subTaskEvaList
            };
            return await evaluateApi
              .updateMultipleScore(param)
              .finally(() => (this.updateLoading = false));
          }
        }
      });
    },
    // 规范性评估与分析报告后台生成任务
    download() {
      const area = this._getParam();
      evaluateApi.downloadAutoEvaluation(area).then((res) => {
      evaluateApi.downloadAutoEvaluation(this.area).then((res) => {
        if (res == false) {
          // 未下载文档,而是开启了文档生成后台任务
          this.$parent;