riku
2025-09-18 c1d2051abc8ca88cd07f0d7c56c0dbf8165d5c33
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
<template>
  <FYTable
    id="fyTable"
    @search="onSearch"
    :data="tableData"
    :pagination="false"
    ref="tableRef"
    @cell-click="cellClick"
    :cell-class-name="cellClassName"
    @table-paste="handlePaste"
  >
    <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 #options-expand>
      <el-form :inline="true">
        <CompQuickSet @quick-set="setOptions"></CompQuickSet>
      </el-form>
      <el-descriptions
        v-if="this.tableData.length > 0"
        title=""
        :column="1"
        direction="vertical"
        border
      >
        <el-descriptions-item label="联合执法清单">
          {{ listSummary }}
        </el-descriptions-item>
      </el-descriptions>
    </template>
    <template #buttons>
      <FYDownloadTableButton
        label="下载清单"
        table-id="fyTable"
        :file-name="fileName"
        :disabled="downloadDisabled"
      ></FYDownloadTableButton>
    </template>
    <template #table-column="{ size }">
      <el-table-column fixed="left" label="序号" width="53">
        <template #default="{ row }">
          {{ row.index + 1 }}
        </template>
      </el-table-column>
      <el-table-column fixed="left" label="编号" width="53" prop="sceneIndex">
      </el-table-column>
      <el-table-column
        prop="sceneName"
        :show-overflow-tooltip="true"
        label="名称"
        width="300"
      >
      </el-table-column>
      <el-table-column prop="evaluation.scenseaddress" label="地址" />
      <el-table-column prop="_problems" label="问题" width="300">
        <template #default="{ row }">
          <el-icon class="is-loading" v-if="row._loading">
            <Loading color="#409eff" />
          </el-icon>
          <div v-else>
            <template v-if="row._problems.length > 0">
              <div v-for="(p, i) in row._problems" :key="p.guid">
                <el-text>{{ i + 1 }}、</el-text>
                <el-text>{{ p.problemname }}</el-text>
              </div>
            </template>
            <el-text v-else>/</el-text>
          </div>
        </template>
      </el-table-column>
      <!-- <el-table-column
          prop="subTaskTime"
          label="巡查日期"
          width="110"
          sortable="custom"
          :formatter="timeFormat"
        /> -->
      <!-- <el-table-column
        prop="evaluation.resultscorebef"
        label="得分"
        width="90"
      /> -->
      <el-table-column prop="" label="监测数据" width="81">
        <template #default="{ row }">
          <el-icon class="is-loading" v-if="row._loading">
            <Loading color="#409eff" />
          </el-icon>
          <el-text v-else>/</el-text>
        </template>
      </el-table-column>
      <!-- <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="_contacts" label="联系人" width="70">
        <template #default="{ row }">
          <el-icon class="is-loading" v-if="row._loading2">
            <Loading color="#409eff" />
          </el-icon>
          <el-text v-else>{{ row._contacts }}</el-text>
        </template>
      </el-table-column>
      <el-table-column prop="_contactst" label="联系电话" width="112">
        <template #default="{ row }">
          <el-icon class="is-loading" v-if="row._loading2">
            <Loading color="#409eff" />
          </el-icon>
          <el-text v-else>{{ row._contactst }}</el-text>
        </template>
      </el-table-column>
      <!-- <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 #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 problemApi from '@/api/fysp/problemApi';
import sceneApi from '@/api/fysp/sceneApi';
import { envCreditCode } from '@/constants/index';
import { useTablePaste } from '@/composables/tablePaste';
 
export default {
  setup() {
    const {
      cellClick,
      cellClassName,
      handlePaste,
      setTableData,
      addRefreshEvent,
      tableData
    } = useTablePaste({
      score1: 8,
      score2: 9
    });
    return {
      cellClick,
      cellClassName,
      handlePaste,
      setTableData,
      addRefreshEvent,
      tableData
    };
  },
  data() {
    return {
      formSearch: {
        locations: {},
        scenetype: {},
        time: dayjs().add(-1, 'M').date(1).toDate()
      },
      townFilters: [],
      // 原始数据,用于排序取消后
      orginData: [],
      dlLoading: false
    };
  },
  computed: {
    area() {
      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
      };
    },
    listSummary() {
      if (this.tableData.length > 0) {
        const { locations, scenetype, time } = this.formSearch;
        return `根据${locations.dName}${dayjs(time).format(
          'YYYY年MM月'
        )}的现场整改情况以及自动评分结果,并结合历史巡查记录,得出以下综合得分最差的10家${
          scenetype.label
        }作为联合执法备选清单。`;
      } else {
        return ``;
      }
    },
    downloadDisabled() {
      if (this.tableData.length == 0) {
        return true;
      } else {
        let b = false;
        this.tableData.forEach((e) => {
          b = b || e._loading || e._loading2;
        });
        return b;
      }
    },
    fileName() {
      const { locations, scenetype, time } = this.formSearch;
      return `${locations.dName}${dayjs(time).format(
        'YYYY年MM月'
      )}联合执法清单`;
    }
  },
  methods: {
    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) {
      this.$refs.tableRef.clearSort();
      // this.fetchEvaluationRule(this.area).then(() => {
      evaluateApi.fetchAutoEvaluation(this.area).then((res) => {
        if (res.data) {
          res.data.sort((a, b) => {
            const s1 = a.evaluation ? parseInt(a.evaluation.resultscorebef) : 0;
            const s2 = b.evaluation ? parseInt(b.evaluation.resultscorebef) : 0;
            return s1 - s2;
          });
          this.tableData = res.data
            .filter((d) => {
              return (
                d.evaluation != null &&
                parseInt(d.evaluation.resultscorebef) < 90
              );
            })
            .slice(0, 10);
          this.tableData.forEach((e) => {
            e._loading = true;
            problemApi
              .getProBySubtask(e.subTaskId)
              .then((res) => {
                e._problems = res;
              })
              .finally(() => {
                e._loading = false;
              });
 
            e._loading2 = true;
            sceneApi
              .getSceneDetail(e.sceneId)
              .then((res) => {
                //场景
                if (res.data.scense) {
                  e._contacts = res.data.scense.contacts;
                  e._contactst = res.data.scense.contactst;
                }
              })
              .finally(() => {
                e._loading2 = false;
              });
          });
          // this.orginData = useCloned(this.tableData).cloned;
          if (typeof func === 'function') {
            func();
          }
        } else {
          this.tableData = [];
          // this.orginData = [];
          if (typeof func === 'function') {
            func();
          }
        }
      });
      // });
    },
    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;
    },
  },
  mounted() {
    this.addRefreshEvent(this.$refs.tableRef.doLayout);
  }
};
</script>
<style scoped></style>