riku
2024-07-29 cda6938d898dc9744cea408c6e34d591710f6003
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<template>
  <FYTable @search="onSearch" :pagination="false" ref="tableRef">
    <template #options>
      <!-- 区县 -->
      <FYOptionLocation
        :allOption="false"
        :level="3"
        :checkStrictly="false"
        v-model:value="formSearch.locations"
      ></FYOptionLocation>
      <!-- 场景类型 -->
      <FYOptionScene
        :allOption="false"
        :type="2"
        v-model:value="formSearch.scenetype"
      ></FYOptionScene>
      <!-- 时间 -->
      <FYOptionTime :initValue="false" type="month" v-model:value="formSearch.time"></FYOptionTime>
    </template>
    <template #buttons>
      <!-- <el-button icon="Download" size="default" type="success" @click="download"
        >规范性评估与分析报告</el-button
      > -->
      <CompReport
        :locations="formSearch.locations"
        :scenetype="formSearch.scenetype"
        :time="formSearch.time"
      ></CompReport>
    </template>
 
    <template #options-expand>
      <el-form :inline="true">
        <CompQuickSet @quick-set="setOptions"></CompQuickSet>
      </el-form>
    </template>
 
    <template #table-column>
      <el-table-column fixed="left" sortable prop="sceneIndex" label="编号" width="80">
      </el-table-column>
      <el-table-column prop="sceneName" :show-overflow-tooltip="true" label="名称" width="300">
      </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"
        :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 fixed="right" align="right" label="操作" width="160">
        <!-- <template #header>
          <el-button icon="Download" size="default" type="success" @click="exportExcel"
            >导出结果</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 dayjs from 'dayjs';
import evaluateApi from '@/api/fysp/evaluateApi';
import { envCreditCode } from '@/constants/index';
import CompQuickSet from './components/CompQuickSet.vue';
import CompReport from './components/CompReport.vue';
 
export default {
  name: 'ResultManage',
  components: { CompQuickSet, CompReport },
  data() {
    return {
      formSearch: {
        locations: {},
        scenetype: {},
        time: dayjs().add(-1, 'M').date(1).toDate()
      },
      townFilters: []
    };
  },
  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}`);
    },
    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 (typeof func === 'function') {
          func({ data: res.data });
        }
        if (res.data) {
          this.getFilters(res.data);
        }
      });
    },
    // 规范性评估与分析报告后台生成任务
    download() {
      const area = this._getParam();
      evaluateApi.downloadAutoEvaluation(area).then((res) => {
        if (res == false) {
          // 未下载文档,而是开启了文档生成后台任务
          this.$parent;
        }
      });
    },
    // 导出表格为excel格式
    exportExcel() {},
    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>