src/views/fysp/evaluation/ResultManage.vue
@@ -1,7 +1,7 @@
<template>
  <!-- <CompPreCheck @pre-check="autoEvaluate"></CompPreCheck> -->
  <FYTable @search="onSearch" :pagination="false">
  <FYTable @search="onSearch" :pagination="false" ref="tableRef">
    <template #options>
      <!-- 区县 -->
      <FYOptionLocation
@@ -21,18 +21,14 @@
    </template>
    <template #options-expand>
      <CompQuickSet @quick-set="setOptions"></CompQuickSet>
      <el-form :inline="true">
        <CompQuickSet @quick-set="setOptions"></CompQuickSet>
      </el-form>
    </template>
    <template #table-column>
      <el-table-column
        type="index"
        fixed="left"
        prop="sceneName"
        label="名称"
        width="400"
      >
        <template #default="{row}">
      <el-table-column type="index" fixed="left" prop="sceneName" label="名称" width="300">
        <template #default="{ row }">
          <el-tooltip
            effect="dark"
            :content="row.sceneName"
@@ -43,60 +39,143 @@
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        prop="subTaskTime"
        label="巡查日期"
        width="110"
        sortable
        :formatter="timeFormat"
      />
      <el-table-column
        prop="evaluation.resultscorebef"
        label="得分"
        width="90"
        sortable
        :sort-method="sortScore"
      />
      <el-table-column prop="evaluation.resultscorebef" label="环信码" width="100">
        <template #default="{ row }">
          <span :style="`color: ${toCode(row).color};`">{{ toCode(row).name }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="dname" label="区县" width="90" />
      <el-table-column prop="tname" label="街道" width="110" />
      <el-table-column
        prop="tname"
        label="街道"
        width="110"
        :filters="townFilters"
        :filter-method="filterHandler"
      />
      <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 prop="evaluation.resultscorebef" label="得分" width="110" />
      <el-table-column fixed="right" align="right" label="操作" width="160">
        <template #header>
          <el-button icon="Download" size="default" type="success" @click="download"
            >下载结果</el-button
          >
        </template>
        <template #default="{ row }">
          <el-button type="primary" size="small" @click="editRow(row)">查看</el-button>
        </template>
      </el-table-column>
    </template>
  </FYTable>
</template>
<script>
import CompPreCheck from './components/CompPreCheck.vue'
import evaluateApi from '@/api/fysp/evaluateApi'
import dayjs from 'dayjs'
import CompQuickSet from './components/CompQuickSet.vue'
import dayjs from 'dayjs';
import evaluateApi from '@/api/fysp/evaluateApi';
import { envCreditCode } from '@/constants/index';
import CompQuickSet from './components/CompQuickSet.vue';
export default {
  name: 'ResultManage',
  components: { CompPreCheck, CompQuickSet },
  components: { CompQuickSet },
  data() {
    return {
      formSearch: {
        locations: {},
        scenetype: {},
        time: dayjs().add(-1, 'M').date(1).toDate()
      }
    }
      },
      townFilters: []
    };
  },
  methods: {
    setOptions(param) {
      this.formSearch.locations = param.locations
      this.formSearch.scenetype = param.scenetype
    },
    onSearch(page, func) {
      const { locations, scenetype, time } = this.formSearch
      const area = {
    _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'),
        starttime: dayjs(time).format('YYYY-MM-DD HH:mm:ss'),
        scensetypeid: scenetype.value
      }
      };
    },
    setOptions(param) {
      this.formSearch.locations = param.locations;
      this.formSearch.scenetype = param.scenetype;
      this.formSearch.sourceType = param.sourceType;
      this.$refs.tableRef.onSearch();
    },
    onSearch(page, func) {
      const area = this._getParam()
      evaluateApi.fetchAutoEvaluation(area).then((res) => {
        if (res) {
          func({
            data: res.data
          })
        if (typeof func === 'function') {
          func({ data: res.data });
        }
        if (res.data) {
          this.getFilters(res.data);
        }
      });
    },
    download() {
      const area = this._getParam()
      evaluateApi.downloadAutoEvaluation(area).then(res=>{
        this.$parent
      })
    },
    getFilters(data) {
      const townList = [];
      data.forEach((e) => {
        if (townList.indexOf(e.tname) == -1) {
          townList.push(e.tname);
        }
      });
      this.townFilters = townList.map((v) => {
        return { text: v, value: v };
      });
    },
    toCode(row, column) {
      if (row.evaluation) {
        return envCreditCode(row.evaluation.resultscorebef);
      } else {
        return '';
      }
    },
    timeFormat(row, column) {
      const time = row.subTaskTime;
      if (time) {
        return dayjs(time).format('MM-DD');
      } else {
        return '';
      }
    },
    filterHandler(value, row, column) {
      const property = column['property'];
      return row[property] === value;
    },
    sortScore(a, b) {
      const s1 = a.evaluation ? parseInt(a.evaluation.resultscorebef) : 0;
      const s2 = b.evaluation ? parseInt(b.evaluation.resultscorebef) : 0;
      return s1 - s2;
    }
  }
}
};
</script>
<style scoped></style>