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
| <template>
| <el-form-item :label="label" :prop="prop">
| <el-select
| :model-value="formatedValue"
| @update:model-value="handleChange"
| :placeholder="label"
| style="width: 260px"
| >
| <el-option v-for="s in filtedBeforeTask" :key="s.value" :label="s.label" :value="s.value" />
| </el-select>
| </el-form-item>
| </template>
|
| <script>
| import taskApi from '@/api/fysp/taskApi'
| import dayjs from 'dayjs'
|
| export default {
| props: {
| label: {
| type: String,
| default: '总任务',
| },
| // 返回结果
| value: Object,
| // 是否默认返回初始选项
| initValue: {
| type: Boolean,
| default: true,
| },
| // form表单绑定属性名
| prop: {
| type: String,
| default: 'topTaskId',
| },
| // 选项筛选条件,筛选某任务之前的相同行政区划内的任务
| beforeTask: {
| type: Object,
| default: () => {
| return {}
| },
| },
| },
| emits: ['update:value'],
| data() {
| return {
| selected: {},
| topTasks: [],
| }
| },
| computed: {
| // 选择框中使用顶层任务id作为选项值
| formatedValue() {
| return this.value?.tguid
| },
| // 某任务之前的相同行政区划内的任务
| filtedBeforeTask() {
| const filteredTasks = this.topTasks.filter((t) => {
| return (
| (!this.beforeTask.provincecode || this.beforeTask.provincecode == t.data.provincecode) &&
| (!this.beforeTask.citycode || this.beforeTask.citycode == t.data.citycode) &&
| (!this.beforeTask.districtcode || this.beforeTask.districtcode == t.data.districtcode) &&
| (!this.beforeTask.starttime || t.data.starttime < this.beforeTask.starttime)
| )
| })
| if (filteredTasks.length > 0) {
| this.handleChange(filteredTasks[0]?.value)
| }
| return filteredTasks
| },
| },
| methods: {
| //获取查询条件
| getOptions() {
| taskApi.getTopTask().then((res) => {
| const list = res.map((r) => {
| return {
| value: r.tguid,
| label: r.name,
| data: r,
| }
| })
| this.topTasks = list.filter((e) => {
| return (
| e.data.districtname == '徐汇区' && dayjs(e.data.starttime).isBefore(dayjs('2025-12-31'))
| )
| })
| if (this.initValue) {
| this.handleChange(list[0].value)
| }
| })
| },
| //查询子任务统计信息
| handleChange(value) {
| const task = this.topTasks.find((t) => t.data.tguid == value)
| const param = task ? task.data : {}
|
| this.$emit('update:value', param)
| },
| },
| mounted() {
| this.getOptions()
| },
| }
| </script>
|
|